From b40ecc3933260232a20e9959add89b15384f7480 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Wed, 13 Nov 2019 18:37:08 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/accountancy/admin/account.php | 58 +- htdocs/accountancy/admin/fiscalyear.php | 14 +- htdocs/accountancy/admin/productaccount.php | 34 +- htdocs/accountancy/bookkeeping/list.php | 62 +- .../accountancy/bookkeeping/listbyaccount.php | 114 +- .../thirdparty_lettering_customer.php | 12 +- .../thirdparty_lettering_supplier.php | 8 +- htdocs/adherents/agenda.php | 40 +- htdocs/adherents/subscription/list.php | 96 +- htdocs/adherents/type.php | 76 +- htdocs/admin/dav.php | 12 +- .../class/PSWebServiceLibrary.class.php | 12 +- .../admin/dolistore/class/dolistore.class.php | 24 +- htdocs/admin/export.php | 12 +- htdocs/admin/index.php | 18 +- htdocs/admin/menus/index.php | 144 +- htdocs/admin/ticket.php | 62 +- htdocs/admin/translation.php | 184 +- htdocs/bookmarks/list.php | 4 +- htdocs/cashdesk/class/Facturation.class.php | 70 +- htdocs/categories/class/categorie.class.php | 500 +++--- htdocs/categories/index.php | 50 +- htdocs/collab/index.php | 56 +- htdocs/comm/action/card.php | 324 ++-- htdocs/comm/action/peruser.php | 334 ++-- htdocs/comm/mailing/list.php | 78 +- htdocs/commande/class/commande.class.php | 1406 +++++++-------- htdocs/compta/bank/document.php | 24 +- htdocs/compta/bank/list.php | 134 +- .../compta/bank/various_payment/document.php | 12 +- htdocs/compta/bank/various_payment/list.php | 40 +- htdocs/compta/deplacement/document.php | 24 +- .../facture/class/api_invoices.class.php | 292 ++-- htdocs/compta/paiement/cheque/list.php | 42 +- htdocs/compta/paiement/list.php | 114 +- htdocs/compta/prelevement/bons.php | 22 +- htdocs/compta/sociales/list.php | 48 +- htdocs/contact/agenda.php | 68 +- .../actions_contactcard_common.class.php | 100 +- htdocs/contact/card.php | 246 +-- htdocs/contrat/card.php | 432 ++--- .../core/actions_changeselectedfields.inc.php | 10 +- .../core/class/commondocgenerator.class.php | 140 +- htdocs/core/class/conf.class.php | 154 +- htdocs/core/class/cstate.class.php | 96 +- htdocs/core/class/extrafields.class.php | 514 +++--- htdocs/core/class/html.formactions.class.php | 54 +- htdocs/core/class/html.formother.class.php | 322 ++-- htdocs/core/lib/company.lib.php | 272 +-- htdocs/core/lib/files.lib.php | 728 ++++---- htdocs/core/lib/functions2.lib.php | 686 ++++---- htdocs/core/lib/order.lib.php | 4 +- htdocs/core/lib/pdf.lib.php | 774 ++++----- htdocs/core/lib/product.lib.php | 66 +- htdocs/core/lib/project.lib.php | 184 +- htdocs/core/lib/website.lib.php | 70 +- htdocs/core/login/functions_googleoauth.php | 4 +- htdocs/core/menus/standard/auguria.lib.php | 110 +- htdocs/core/menus/standard/eldy.lib.php | 434 ++--- htdocs/core/menus/standard/empty.php | 162 +- .../commande/doc/pdf_eratosthene.modules.php | 286 +-- .../modules/contract/mod_contract_magre.php | 24 +- .../modules/contract/mod_contract_olive.php | 10 +- .../modules/contract/mod_contract_serpis.php | 42 +- .../expedition/doc/pdf_espadon.modules.php | 158 +- .../expedition/mod_expedition_ribera.php | 66 +- .../expedition/mod_expedition_safor.php | 50 +- .../doc/pdf_standard.modules.php | 160 +- .../expensereport/mod_expensereport_sand.php | 60 +- .../modules/facture/doc/pdf_crabe.modules.php | 344 ++-- .../facture/doc/pdf_sponge.modules.php | 394 ++--- .../modules/livraison/mod_livraison_jade.php | 56 +- .../livraison/mod_livraison_saphir.php | 62 +- htdocs/core/modules/modAccounting.class.php | 10 +- htdocs/core/modules/modAdherent.class.php | 24 +- htdocs/core/modules/modAsset.class.php | 26 +- htdocs/core/modules/modProduct.class.php | 108 +- htdocs/core/modules/modSociete.class.php | 150 +- .../modules/propale/doc/pdf_cyan.modules.php | 338 ++-- .../supplier_order/pdf/pdf_cornas.modules.php | 320 ++-- htdocs/core/tpl/bloc_comment.tpl.php | 16 +- htdocs/core/tpl/commonfields_add.tpl.php | 4 +- htdocs/core/tpl/commonfields_edit.tpl.php | 4 +- .../tpl/extrafields_list_print_fields.tpl.php | 24 +- .../tpl/extrafields_list_search_param.tpl.php | 12 +- htdocs/core/tpl/notes.tpl.php | 2 +- htdocs/don/card.php | 142 +- htdocs/don/list.php | 30 +- .../class/emailcollector.class.php | 140 +- .../class/emailcollectorfilter.class.php | 66 +- htdocs/expedition/card.php | 566 +++--- htdocs/expedition/class/expedition.class.php | 750 ++++---- htdocs/expedition/shipment.php | 120 +- htdocs/expensereport/document.php | 36 +- htdocs/expensereport/stats/index.php | 58 +- htdocs/fichinter/card.php | 336 ++-- .../class/fournisseur.commande.class.php | 1176 ++++++------- .../fourn/class/fournisseur.facture.class.php | 832 ++++----- htdocs/fourn/facture/paiement.php | 192 +- htdocs/holiday/month_report.php | 30 +- htdocs/loan/card.php | 114 +- htdocs/loan/class/loanschedule.class.php | 206 +-- htdocs/loan/class/paymentloan.class.php | 156 +- htdocs/loan/list.php | 40 +- htdocs/main.inc.php | 434 ++--- htdocs/master.inc.php | 94 +- htdocs/modulebuilder/admin/setup.php | 48 +- htdocs/modulebuilder/index.php | 400 ++--- htdocs/mrp/index.php | 4 +- htdocs/opensurvey/results.php | 326 ++-- htdocs/product/agenda.php | 28 +- htdocs/product/class/product.class.php | 1546 ++++++++--------- htdocs/product/class/productbatch.class.php | 210 +-- .../inventory/class/inventory.class.php | 50 +- htdocs/projet/activity/index.php | 260 +-- htdocs/projet/activity/perday.php | 172 +- htdocs/projet/activity/perweek.php | 274 +-- htdocs/projet/class/project.class.php | 350 ++-- htdocs/projet/element.php | 242 +-- htdocs/projet/ganttview.php | 72 +- htdocs/projet/info.php | 42 +- htdocs/projet/tasks/time.php | 320 ++-- htdocs/public/payment/paymentko.php | 144 +- htdocs/public/ticket/list.php | 66 +- htdocs/resource/list.php | 38 +- htdocs/societe/agenda.php | 28 +- htdocs/societe/document.php | 20 +- htdocs/takepos/admin/setup.php | 28 +- htdocs/takepos/floors.php | 10 +- htdocs/takepos/freezone.php | 10 +- htdocs/takepos/pay.php | 32 +- htdocs/theme/eldy/global.inc.php | 68 +- htdocs/user/group/list.php | 74 +- htdocs/user/list.php | 74 +- htdocs/user/logout.php | 40 +- htdocs/webservices/server_contact.php | 224 +-- .../webservices/server_productorservice.php | 260 +-- 137 files changed, 11957 insertions(+), 11957 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 10a65cab2fe..c00042cc5b9 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -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); @@ -287,9 +287,9 @@ if ($resql) while ($i < $numbis) { $obj = $db->fetch_object($resqlchart); - print ''; + print '>'.$obj->pcg_version.' - '.$obj->label.' - ('.$obj->country_code.')'; $i++; } @@ -351,27 +351,27 @@ if ($resql) print ''; // Account number - if (! empty($arrayfields['aa.account_number']['checked'])) + if (!empty($arrayfields['aa.account_number']['checked'])) { print ""; print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1); 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 ""; print $obj->label; 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; diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 6d321e60756..262428c7073 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'); @@ -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) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 6fedd7706d0..ef4c64bb774 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 diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index f449a99c8bf..8374e20803c 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -88,7 +88,7 @@ $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $search_lettering_code = GETPOST('search_lettering_code', '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'); @@ -120,9 +120,9 @@ if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! $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'); - 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; if ($month_end < 1) @@ -137,7 +137,7 @@ if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! } -$arrayfields=array( +$arrayfields = array( 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), @@ -166,8 +166,8 @@ $error = 0; * 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 @@ -318,7 +318,7 @@ if (empty($reshook)) if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { $import_key = GETPOST('importkey', 'alpha'); - if (! empty($import_key)) { + if (!empty($import_key)) { $result = $object->deleteByImportkey($import_key); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -331,15 +331,15 @@ if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->suppri } if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { $delyear = GETPOST('delyear', 'int'); - if ($delyear==-1) { - $delyear=0; + if ($delyear == -1) { + $delyear = 0; } $deljournal = GETPOST('deljournal', 'alpha'); - if ($deljournal==-1) { - $deljournal=0; + if ($deljournal == -1) { + $deljournal = 0; } - if (! empty($delyear) || ! empty($deljournal)) + if (!empty($delyear) || !empty($deljournal)) { $result = $object->deleteByYearAndJournal($delyear, $deljournal); if ($result < 0) { @@ -362,7 +362,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { $mvt_num = GETPOST('mvt_num', 'int'); - if (! empty($mvt_num)) { + if (!empty($mvt_num)) { $result = $object->deleteMvtNum($mvt_num); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -584,16 +584,16 @@ if ($action == 'delbookkeepingyear') { $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); - $form_question['delyear'] = array ( + $form_question['delyear'] = array( 'name' => 'delyear', 'type' => 'select', 'label' => $langs->trans('DelYear'), 'values' => $year_array, 'default' => $delyear ); - $form_question['deljournal'] = array ( + $form_question['deljournal'] = array( 'name' => 'deljournal', - 'type' => 'other', // We don't use select here, the journal_array is already a select html component + 'type' => 'other', // We don't use select here, the journal_array is already a select html component 'label' => $langs->trans('DelJournal'), 'value' => $journal_array, 'default' => $deljournal @@ -650,52 +650,52 @@ print ''; // Filters lines print ''; // Movement number -if (! empty($arrayfields['t.piece_num']['checked'])) +if (!empty($arrayfields['t.piece_num']['checked'])) { - print ''; + print ''; } // Date document -if (! empty($arrayfields['t.doc_date']['checked'])) +if (!empty($arrayfields['t.doc_date']['checked'])) { print ''; } // Ref document -if (! empty($arrayfields['t.doc_ref']['checked'])) +if (!empty($arrayfields['t.doc_ref']['checked'])) { - print ''; + print ''; } // Accountancy account -if (! empty($arrayfields['t.numero_compte']['checked'])) +if (!empty($arrayfields['t.numero_compte']['checked'])) { print ''; } // Subledger account -if (! empty($arrayfields['t.subledger_account']['checked'])) +if (!empty($arrayfields['t.subledger_account']['checked'])) { print ''; print ''; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; @@ -321,9 +321,9 @@ $total_debit = 0; $total_credit = 0; $sous_total_debit = 0; $sous_total_credit = 0; -$displayed_account_number = null; // Start with undefined to be able to distinguish with empty +$displayed_account_number = null; // Start with undefined to be able to distinguish with empty -$i=0; +$i = 0; while ($i < min($num, $limit)) { $line = $object->lines[$i]; @@ -361,8 +361,8 @@ while ($i < min($num, $limit)) print ''; print ''; - print ''; - print ''; + print ''; + print ''; // TODO Add a link according to doc_type and fk_doc print ''; } // Date modification -if (! empty($arrayfields['c.tms']['checked'])) +if (!empty($arrayfields['c.tms']['checked'])) { print ''; @@ -380,7 +380,7 @@ if (! empty($arrayfields['c.tms']['checked'])) // Action column print ''; @@ -594,15 +594,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 ''; } $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 "
'; print '
'; - print $langs->trans('From') . ' '; - print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1); + print $langs->trans('From').' '; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1); print '
'; print '
'; - print $langs->trans('to') . ' '; - print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1); + print $langs->trans('to').' '; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1); print '
'; print '
'; print '
'; print $langs->trans('From').' '; - print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); + print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); print '
'; print '
'; print $langs->trans('to').' '; - print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); + print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); print '
'; print '
'; print '
'; print $langs->trans('From').' '; // 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($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); } @@ -708,7 +708,7 @@ if (! empty($arrayfields['t.subledger_account']['checked'])) print $langs->trans('to').' '; // 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($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 4f275e3e2b0..5ceb9eb66a8 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -27,12 +27,12 @@ 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 . '/accountancy/class/accountingjournal.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/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.'/accountancy/class/accountingjournal.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/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy")); @@ -59,7 +59,7 @@ $search_debit = GETPOST('search_debit', 'alpha'); $search_credit = GETPOST('search_credit', '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'); @@ -81,9 +81,9 @@ if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search $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'); - 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; if ($month_end < 1) @@ -112,76 +112,76 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_label_operation = ''; $search_direction = ''; $search_ledger_code = ''; - $search_date_start=''; - $search_date_end=''; - $search_date_startyear=''; - $search_date_startmonth=''; - $search_date_startday=''; - $search_date_endyear=''; - $search_date_endmonth=''; - $search_date_endday=''; + $search_date_start = ''; + $search_date_end = ''; + $search_date_startyear = ''; + $search_date_startmonth = ''; + $search_date_startday = ''; + $search_date_endyear = ''; + $search_date_endmonth = ''; + $search_date_endday = ''; $search_debit = ''; $search_credit = ''; } // Must be after the remove filter action, before the export. $param = ''; -$filter = array (); +$filter = array(); -if (! empty($search_date_start)) { +if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int'); + $param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int'); } -if (! empty($search_date_end)) { +if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); + $param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int'); } -if (! empty($search_doc_date)) { +if (!empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; - $param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); + $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', '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=' . urlencode($search_accountancy_code_start); + $param .= '&search_accountancy_code_start='.urlencode($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=' . urlencode($search_accountancy_code_end); + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); } -if (! empty($search_label_account)) { +if (!empty($search_label_account)) { $filter['t.label_compte'] = $search_label_account; - $param .= '&search_label_compte=' . urlencode($search_label_account); + $param .= '&search_label_compte='.urlencode($search_label_account); } -if (! empty($search_doc_ref)) { +if (!empty($search_doc_ref)) { $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref=' . urlencode($search_doc_ref); + $param .= '&search_doc_ref='.urlencode($search_doc_ref); } -if (! empty($search_label_operation)) { +if (!empty($search_label_operation)) { $filter['t.label_operation'] = $search_label_operation; - $param .= '&search_label_operation=' . urlencode($search_label_operation); + $param .= '&search_label_operation='.urlencode($search_label_operation); } -if (! empty($search_direction)) { +if (!empty($search_direction)) { $filter['t.sens'] = $search_direction; - $param .= '&search_direction=' . urlencode($search_direction); + $param .= '&search_direction='.urlencode($search_direction); } -if (! empty($search_ledger_code)) { +if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code=' . urlencode($search_ledger_code); + $param .= '&search_ledger_code='.urlencode($search_ledger_code); } -if (! empty($search_debit)) { +if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; - $param .= '&search_debit=' . urlencode($search_debit); + $param .= '&search_debit='.urlencode($search_debit); } -if (! empty($search_credit)) { +if (!empty($search_credit)) { $filter['t.credit'] = $search_credit; - $param .= '&search_credit=' . urlencode($search_credit); + $param .= '&search_credit='.urlencode($search_credit); } if ($action == 'delmouvconfirm') { $mvt_num = GETPOST('mvt_num', 'int'); - if (! empty($mvt_num)) { + if (!empty($mvt_num)) { $result = $object->deleteMvtNum($mvt_num); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -200,7 +200,7 @@ $formaccounting = new FormAccounting($db); $formother = new FormOther($db); $form = new Form($db); -$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . strtolower($langs->trans("AccountAccounting")); +$title_page = $langs->trans("Bookkeeping").' '.strtolower($langs->trans("By")).' '.strtolower($langs->trans("AccountAccounting")); llxHeader('', $title_page); @@ -236,7 +236,7 @@ if ($action == 'delbookkeepingyear') { } $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $form_question['delyear'] = array ( + $form_question['delyear'] = array( 'name' => 'delyear', 'type' => 'select', 'label' => $langs->trans('DelYear'), @@ -278,28 +278,28 @@ print '
'; print '
'; print $langs->trans('From').' '; -print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); +print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); print '
'; print '
'; print $langs->trans('to').' '; -print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); +print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); print '
'; print '
'; -print $langs->trans('From') . ': '; +print $langs->trans('From').': '; print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1); print '
'; -print $langs->trans('to') . ': '; +print $langs->trans('to').': '; print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1); print '
'; -$searchpicto=$form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
 '.$line->piece_num.'' . dol_print_date($line->doc_date, 'day') . ''.$line->piece_num.''.dol_print_date($line->doc_date, 'day').''; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 4e96bf64602..9cb863aec7d 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -67,7 +67,7 @@ $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); */ $lettering = GETPOST('lettering', 'alpha'); -if (! empty($lettering)) { +if (!empty($lettering)) { $action = $lettering; } @@ -127,8 +127,8 @@ if ($action == 'autolettrage') { $form = new Form($db); $formaccounting = new FormAccounting($db); -$title=$object->name." - ".$langs->trans('TabLetteringCustomer'); -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = $object->name." - ".$langs->trans('TabLetteringCustomer'); +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); $head = societe_prepare_head($object); @@ -164,13 +164,13 @@ $solde = 0; // Count total nb of records and calc total sum $nbtotalofrecords = ''; $resql = $db->query($sql); -if (! $resql) { +if (!$resql) { dol_print_error($db); exit(); } $nbtotalofrecords = $db->num_rows($resql); -while ( $obj = $db->fetch_object($resql) ) { +while ($obj = $db->fetch_object($resql)) { $debit += $obj->debit; $credit += $obj->credit; @@ -181,7 +181,7 @@ $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEBUG); $resql = $db->query($sql); -if (! $resql) { +if (!$resql) { dol_print_error($db); exit(); } diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index d35eba34963..338c795b4b2 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -89,7 +89,7 @@ $lettering = new Lettering($db); $object = new Societe($db); $object->id = $socid; $result = $object->fetch($socid); -if ($result<0) +if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -126,8 +126,8 @@ if ($action == 'autolettrage') { $form = new Form($db); $formaccounting = new FormAccounting($db); -$title=$object->name." - ".$langs->trans('TabLetteringSupplier'); -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = $object->name." - ".$langs->trans('TabLetteringSupplier'); +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); $head = societe_prepare_head($object); @@ -159,7 +159,7 @@ $solde = 0; // Count total nb of records and calc total sum $nbtotalofrecords = ''; $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 2c7fd1445ab..bc738cfa18f 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -34,11 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","members")); +$langs->loadLangs(array("companies", "members")); -$id = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('rowid', 'int'); +$id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('rowid', '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'); @@ -46,31 +46,31 @@ 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'; 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'); +$search_agenda_label = GETPOST('search_agenda_label'); // Security check -$result=restrictedArea($user, 'adherent', $id); +$result = restrictedArea($user, 'adherent', $id); $object = new Adherent($db); -$result=$object->fetch($id); +$result = $object->fetch($id); if ($result > 0) { $object->fetch_thirdparty(); $adht = new AdherentType($db); - $result=$adht->fetch($object->typeid); + $result = $adht->fetch($object->typeid); } @@ -78,14 +78,14 @@ if ($result > 0) * 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; @@ -94,8 +94,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 = ''; } } @@ -119,11 +119,11 @@ if ($object->id > 0) $langs->load("companies"); - $title=$langs->trans("Member") . " - " . $langs->trans("Agenda"); - $helpurl="EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros"; + $title = $langs->trans("Member")." - ".$langs->trans("Agenda"); + $helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros"; llxHeader("", $title, $helpurl); - if (! empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = member_prepare_head($object); dol_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user'); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index c66dce0e8fd..2c996c99afa 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -29,37 +29,37 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -$langs->loadLangs(array("members","companies")); +$langs->loadLangs(array("members", "companies")); -$action=GETPOST('action', 'aZ09'); -$massaction=GETPOST('massaction', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$filter=GETPOST("filter", "alpha"); -$statut=(GETPOSTISSET("statut")?GETPOST("statut", "alpha"):1); -$search_ref=GETPOST('search_ref', 'alpha'); -$search_type=GETPOST('search_type', 'alpha'); -$search_lastname=GETPOST('search_lastname', 'alpha'); -$search_firstname=GETPOST('search_firstname', 'alpha'); -$search_login=GETPOST('search_login', 'alpha'); -$search_note=GETPOST('search_note', 'alpha'); -$search_account=GETPOST('search_account', 'int'); -$search_amount=GETPOST('search_amount', 'alpha'); +$filter = GETPOST("filter", "alpha"); +$statut = (GETPOSTISSET("statut") ?GETPOST("statut", "alpha") : 1); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_type = GETPOST('search_type', 'alpha'); +$search_lastname = GETPOST('search_lastname', 'alpha'); +$search_firstname = GETPOST('search_firstname', 'alpha'); +$search_login = GETPOST('search_login', 'alpha'); +$search_note = GETPOST('search_note', 'alpha'); +$search_account = GETPOST('search_account', 'int'); +$search_amount = GETPOST('search_amount', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -$date_select=GETPOST("date_select", 'alpha'); +$date_select = GETPOST("date_select", '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="c.dateadh"; } +if (!$sortorder) { $sortorder = "DESC"; } +if (!$sortfield) { $sortfield = "c.dateadh"; } $object = new Subscription($db); @@ -94,18 +94,18 @@ $arrayfields=array( ); // Security check -$result=restrictedArea($user, 'adherent', '', '', 'cotisation'); +$result = restrictedArea($user, 'adherent', '', '', 'cotisation'); /* * 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)) @@ -116,17 +116,17 @@ 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_type=""; - $search_ref=""; - $search_lastname=""; - $search_firstname=""; - $search_login=""; - $search_note=""; - $search_amount=""; - $search_account=""; - $toselect=''; - $search_array_options=array(); + $search = ""; + $search_type = ""; + $search_ref = ""; + $search_lastname = ""; + $search_firstname = ""; + $search_login = ""; + $search_note = ""; + $search_amount = ""; + $search_account = ""; + $toselect = ''; + $search_array_options = array(); } } @@ -194,10 +194,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } // Add limit -$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; @@ -205,9 +205,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) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -362,17 +362,17 @@ if (! empty($arrayfields['d.amount']['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 ''; print ''; print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'.$langs->trans("NoRecordFound").'
"; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 0c1ec419a32..f6aafab509d 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -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"]); @@ -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 = ''; } } @@ -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 @@ -372,13 +372,13 @@ 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)) { @@ -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("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 '"; // 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"); @@ -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 '
'.$langs->trans("AddMember").'
'; } else { @@ -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) { @@ -626,7 +626,7 @@ if ($rowid > 0) $moreforfilter = ''; 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 diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index a531a9c870c..354d35a9579 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(); @@ -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("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 '
'; 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 ''; @@ -372,7 +372,7 @@ if ($conf->use_javascript_ajax) // Process remaining records (records that are not linked to root by any path) $remainingdata = array(); - foreach($data as $datar) + foreach ($data as $datar) { if (empty($datar['rowid']) || $tree_recur_alreadyadded[$datar['rowid']]) continue; $remainingdata[] = $datar; @@ -389,9 +389,9 @@ if ($conf->use_javascript_ajax) print ''; 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 "
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index e5acf71857e..3c735707c4a 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -88,7 +88,7 @@ class PrestaShopWebservice protected function checkStatusCode($status_code) { $error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.'; - switch($status_code) + switch ($status_code) { case 200: case 201: @@ -106,7 +106,7 @@ class PrestaShopWebservice case 500: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Internal Server Error')); default: - throw new PrestaShopWebserviceException('This call to PrestaShop Web Services returned an unexpected HTTP status of:' . $status_code); + throw new PrestaShopWebserviceException('This call to PrestaShop Web Services returned an unexpected HTTP status of:'.$status_code); } } @@ -125,7 +125,7 @@ class PrestaShopWebservice CURLINFO_HEADER_OUT => true, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => $this->key.':', - CURLOPT_HTTPHEADER => array( 'Expect:' ) + CURLOPT_HTTPHEADER => array('Expect:') ); dol_syslog("curl_init url=".$url); @@ -328,7 +328,7 @@ class PrestaShopWebservice throw new PrestaShopWebserviceException('Bad parameters given '); $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); - self::checkStatusCode($request['status_code']);// check the response validity + self::checkStatusCode($request['status_code']); // check the response validity return self::parseXML($request['response']); } @@ -360,7 +360,7 @@ class PrestaShopWebservice else throw new PrestaShopWebserviceException('Bad parameters given'); $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => true)); - self::checkStatusCode($request['status_code']);// check the response validity + self::checkStatusCode($request['status_code']); // check the response validity return $request['header']; } /** @@ -392,7 +392,7 @@ class PrestaShopWebservice throw new PrestaShopWebserviceException('Bad parameters given'); $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml)); - self::checkStatusCode($request['status_code']);// check the response validity + self::checkStatusCode($request['status_code']); // check the response validity return self::parseXML($request['response']); } } diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 22029b2c691..c0c611f35f5 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -40,15 +40,15 @@ class Dolistore */ public $end; - public $per_page; // pagination: display per page - public $categorie; // the current categorie - public $search; // the search keywords + public $per_page; // pagination: display per page + public $categorie; // the current categorie + public $search; // the search keywords // setups - public $url; // the url of this page - public $shop_url; // the url of the shop - public $lang; // the integer representing the lang in the store - public $debug_api; // usefull if no dialog + public $url; // the url of this page + public $shop_url; // the url of the shop + public $lang; // the integer representing the lang in the store + public $debug_api; // usefull if no dialog /** @@ -66,8 +66,8 @@ class Dolistore $langtmp = explode('_', $langs->defaultlang); $lang = $langtmp[0]; - $lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1 - if (! in_array($lang, array_keys($lang_array))) $lang = 'en'; + $lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1 + if (!in_array($lang, array_keys($lang_array))) $lang = 'en'; $this->lang = $lang_array[$lang]; } @@ -142,7 +142,7 @@ class Dolistore // make a search to limit the id returned. if ($this->search != '') { - $opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang; // It seems for search, key start with + $opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang; // It seems for search, key start with // Call dol_syslog("Call API with opt2 = ".var_export($opt2, true)); @@ -277,12 +277,12 @@ class Dolistore // free or pay ? if ($product->price > 0) { - $price = '

'.price(price2num($product->price, 'MT'), 0, $langs, 1, -1, -1, 'EUR').' '.$langs->trans("HT").'

'; + $price = '

'.price(price2num($product->price, 'MT'), 0, $langs, 1, -1, -1, 'EUR').' '.$langs->trans("HT").'

'; $download_link = ''; } else { $price = '

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

'; $download_link = ''; - $download_link.= '

'; + $download_link .= '

'; } //checking versions diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php index 4812b056e6a..42aa330d1bd 100644 --- a/htdocs/admin/export.php +++ b/htdocs/admin/export.php @@ -34,11 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'exports', 'other')); -if (! $user->admin) +if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); -$value=GETPOST('value', 'alpha'); +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); /* * Actions @@ -51,18 +51,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; * View */ -$form=new Form($db); +$form = new Form($db); $page_name = "ExportSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback); //$head = export_admin_prepare_head(); -$h=0; +$h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/admin/export.php'; $head[$h][1] = $langs->trans("Setup"); diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 2fe4d02e495..a7fe135d930 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -74,13 +74,13 @@ print $langs->trans("SetupDescription2", $langs->transnoentities("MenuCompanySet print '
'; // Show info setup company -if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; -print img_picto('', 'puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); -if (! empty($setupcompanynotcomplete)) +if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete = 1; +print img_picto('', 'puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); +if (!empty($setupcompanynotcomplete)) { $langs->load("errors"); - $warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"'); - print '
'; + $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"'); + print '
'; } print '
'; print '
'; @@ -96,10 +96,10 @@ if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouM print '
'.$moreinfo; */ -if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled +if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled { $langs->load("errors"); - $warnpicto=img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"'); + $warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"'); print '
'; } print '
'; @@ -108,8 +108,8 @@ print '
'; print '
'; // Add hook to add information -$parameters=array(); -$reshook=$hookmanager->executeHooks('addHomeSetup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; if (empty($reshook)) { diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 34543456bfe..c0c7b320a38 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -29,35 +29,35 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.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', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); -$menu_handler_top=$conf->global->MAIN_MENU_STANDARD; -$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE; -$menu_handler_top=preg_replace('/(_backoffice\.php|_menu\.php)/i', '', $menu_handler_top); -$menu_handler_top=preg_replace('/(_frontoffice\.php|_menu\.php)/i', '', $menu_handler_top); -$menu_handler_smartphone=preg_replace('/(_backoffice\.php|_menu\.php)/i', '', $menu_handler_smartphone); -$menu_handler_smartphone=preg_replace('/(_frontoffice\.php|_menu\.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|_menu\.php)/i', '', $menu_handler_top); +$menu_handler_top = preg_replace('/(_frontoffice\.php|_menu\.php)/i', '', $menu_handler_top); +$menu_handler_smartphone = preg_replace('/(_backoffice\.php|_menu\.php)/i', '', $menu_handler_smartphone); +$menu_handler_smartphone = preg_replace('/(_frontoffice\.php|_menu\.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"); -$menu_handler_to_search=preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php)?/i', '', $menu_handler); +$menu_handler_to_search = preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php)?/i', '', $menu_handler); /* @@ -66,18 +66,18 @@ $menu_handler_to_search=preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php)? if ($action == 'up') { - $current=array(); - $previous=array(); + $current = array(); + $previous = array(); // Get current position $sql = "SELECT m.rowid, m.position, m.type, m.fk_menu"; - $sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; - $sql.= " WHERE m.rowid = ".GETPOST("menuId", "int"); + $sql .= " FROM ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE m.rowid = ".GETPOST("menuId", "int"); dol_syslog("admin/menus/index.php ".$sql); $result = $db->query($sql); $num = $db->num_rows($result); $i = 0; - while($i < $num) + while ($i < $num) { $obj = $db->fetch_object($result); $current['rowid'] = $obj->rowid; @@ -89,18 +89,18 @@ if ($action == 'up') // Menu before $sql = "SELECT m.rowid, m.position"; - $sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; - $sql.= " WHERE (m.position < ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid < ".GETPOST("menuId", "int")."))"; - $sql.= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'"; - $sql.= " AND m.entity = ".$conf->entity; - $sql.= " AND m.type = '".$db->escape($current['type'])."'"; - $sql.= " AND m.fk_menu = '".$db->escape($current['fk_menu'])."'"; - $sql.= " ORDER BY m.position, m.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE (m.position < ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid < ".GETPOST("menuId", "int")."))"; + $sql .= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'"; + $sql .= " AND m.entity = ".$conf->entity; + $sql .= " AND m.type = '".$db->escape($current['type'])."'"; + $sql .= " AND m.fk_menu = '".$db->escape($current['fk_menu'])."'"; + $sql .= " ORDER BY m.position, m.rowid"; dol_syslog("admin/menus/index.php ".$sql); $result = $db->query($sql); $num = $db->num_rows($result); $i = 0; - while($i < $num) + while ($i < $num) { $obj = $db->fetch_object($result); $previous['rowid'] = $obj->rowid; @@ -109,31 +109,31 @@ if ($action == 'up') } $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; - $sql.= " SET m.position = ".$previous['order']; - $sql.= " WHERE m.rowid = ".$current['rowid']; // Up the selected entry + $sql .= " SET m.position = ".$previous['order']; + $sql .= " WHERE m.rowid = ".$current['rowid']; // Up the selected entry dol_syslog("admin/menus/index.php ".$sql); $db->query($sql); $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; - $sql.= " SET m.position = ".($current['order']!=$previous['order']?$current['order']:$current['order']+1); - $sql.= " WHERE m.rowid = ".$previous['rowid']; // Descend celui du dessus + $sql .= " SET m.position = ".($current['order'] != $previous['order'] ? $current['order'] : $current['order'] + 1); + $sql .= " WHERE m.rowid = ".$previous['rowid']; // Descend celui du dessus dol_syslog("admin/menus/index.php ".$sql); $db->query($sql); } elseif ($action == 'down') { - $current=array(); - $next=array(); + $current = array(); + $next = array(); // Get current position $sql = "SELECT m.rowid, m.position, m.type, m.fk_menu"; - $sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; - $sql.= " WHERE m.rowid = ".GETPOST("menuId", "int"); + $sql .= " FROM ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE m.rowid = ".GETPOST("menuId", "int"); dol_syslog("admin/menus/index.php ".$sql); $result = $db->query($sql); $num = $db->num_rows($result); $i = 0; - while($i < $num) + while ($i < $num) { $obj = $db->fetch_object($result); $current['rowid'] = $obj->rowid; @@ -145,18 +145,18 @@ elseif ($action == 'down') // Menu after $sql = "SELECT m.rowid, m.position"; - $sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; - $sql.= " WHERE (m.position > ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid > ".GETPOST("menuId", "int")."))"; - $sql.= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'"; - $sql.= " AND m.entity = ".$conf->entity; - $sql.= " AND m.type = '".$db->escape($current['type'])."'"; - $sql.= " AND m.fk_menu = '".$db->escape($current['fk_menu'])."'"; - $sql.= " ORDER BY m.position, m.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE (m.position > ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid > ".GETPOST("menuId", "int")."))"; + $sql .= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'"; + $sql .= " AND m.entity = ".$conf->entity; + $sql .= " AND m.type = '".$db->escape($current['type'])."'"; + $sql .= " AND m.fk_menu = '".$db->escape($current['fk_menu'])."'"; + $sql .= " ORDER BY m.position, m.rowid"; dol_syslog("admin/menus/index.php ".$sql); $result = $db->query($sql); $num = $db->num_rows($result); $i = 0; - while($i < $num) + while ($i < $num) { $obj = $db->fetch_object($result); $next['rowid'] = $obj->rowid; @@ -165,13 +165,13 @@ elseif ($action == 'down') } $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; - $sql.= " SET m.position = ".($current['order']!=$next['order']?$next['order']:$current['order']+1); // Down the selected entry - $sql.= " WHERE m.rowid = ".$current['rowid']; + $sql .= " SET m.position = ".($current['order'] != $next['order'] ? $next['order'] : $current['order'] + 1); // Down the selected entry + $sql .= " WHERE m.rowid = ".$current['rowid']; dol_syslog("admin/menus/index.php ".$sql); $db->query($sql); - $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; // Up the next entry - $sql.= " SET m.position = ".$current['order']; - $sql.= " WHERE m.rowid = ".$next['rowid']; + $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; // Up the next entry + $sql .= " SET m.position = ".$current['order']; + $sql .= " WHERE m.rowid = ".$next['rowid']; dol_syslog("admin/menus/index.php ".$sql); $db->query($sql); } @@ -181,8 +181,8 @@ elseif ($action == 'confirm_delete' && $confirm == 'yes') $db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; - $sql.= " WHERE rowid = ".GETPOST('menuId', 'int'); - $resql=$db->query($sql); + $sql .= " WHERE rowid = ".GETPOST('menuId', 'int'); + $resql = $db->query($sql); if ($resql) { $db->commit(); @@ -190,14 +190,14 @@ elseif ($action == 'confirm_delete' && $confirm == 'yes') setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs'); header("Location: ".DOL_URL_ROOT.'/admin/menus/index.php?menu_handler='.$menu_handler); - exit ; + exit; } else { $db->rollback(); $reload = 0; - $action=''; + $action = ''; } } @@ -206,11 +206,11 @@ elseif ($action == 'confirm_delete' && $confirm == 'yes') * View */ -$form=new Form($db); -$formadmin=new FormAdmin($db); +$form = new Form($db); +$formadmin = new FormAdmin($db); -$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); -$arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css'); +$arrayofjs = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); +$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css'); llxHeader('', $langs->trans("Menus"), '', '', 0, 0, $arrayofjs, $arrayofcss); @@ -303,16 +303,16 @@ if ($conf->use_javascript_ajax) //il faut d'abord declarer un element racine de l'arbre - $data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>''); + $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); //puis tous les elements enfants $sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.position, m.module"; - $sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; - $sql.= " WHERE menu_handler = '".$db->escape($menu_handler_to_search)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE menu_handler = '".$db->escape($menu_handler_to_search)."'"; + $sql .= " AND entity = ".$conf->entity; //$sql.= " AND fk_menu >= 0"; - $sql.= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same) + $sql .= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same) $res = $db->query($sql); if ($res) @@ -322,7 +322,7 @@ if ($conf->use_javascript_ajax) $i = 1; while ($menu = $db->fetch_array($res)) { - if (! empty($menu['langs'])) $langs->load($menu['langs']); + if (!empty($menu['langs'])) $langs->load($menu['langs']); $titre = $langs->trans($menu['titre']); $data[] = array( @@ -354,13 +354,13 @@ if ($conf->use_javascript_ajax) } } - global $tree_recur_alreadyadded; // This var was def into tree_recur + global $tree_recur_alreadyadded; // This var was def into tree_recur //var_dump($data); // Appelle de la fonction recursive (ammorce) avec recherche depuis la racine. //tree_recur($data, $data[0], 0, 'iddivjstree', 0, 1); // use this to get info on name and foreign keys of menu entry - tree_recur($data, $data[0], 0, 'iddivjstree', 0, 0); // $data[0] is virtual record 'racine' + tree_recur($data, $data[0], 0, 'iddivjstree', 0, 0); // $data[0] is virtual record 'racine' print '
'; - foreach($remainingdata as $datar) + foreach ($remainingdata as $datar) { - $father = array('rowid'=>$datar['rowid'],'title'=>"???",'mainmenu'=>$datar['fk_mainmenu'],'leftmenu'=>$datar['fk_leftmenu'],'fk_mainmenu'=>'','fk_leftmenu'=>''); + $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'
'."\n"; tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); } diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index fa6a558e444..6d3998948ef 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)) { @@ -199,17 +199,17 @@ print load_fiche_titre($langs->trans("TicketNumberingModules")); print ''; 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 ''; @@ -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 '

'; 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 ''."\n"; print ''; // Limit to superadmin /*if (! empty($conf->multicompany->enabled) && !$user->entity) @@ -316,10 +316,10 @@ if ($mode == 'overwrite') // Show constants $sql = "SELECT rowid, entity, lang, transkey, transvalue"; - $sql.= " FROM ".MAIN_DB_PREFIX."overwrite_trans"; - $sql.= " WHERE 1 = 1"; - $sql.= " AND entity IN (".getEntity('overwrite_trans').")"; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans"; + $sql .= " WHERE 1 = 1"; + $sql .= " AND entity IN (".getEntity('overwrite_trans').")"; + $sql .= $db->order($sortfield, $sortorder); dol_syslog("translation::select from table", LOG_DEBUG); $result = $db->query($sql); @@ -366,9 +366,9 @@ if ($mode == 'overwrite') } else { - print ''.img_edit().''; + print ''.img_edit().''; print '   '; - print ''.img_delete().''; + print ''.img_delete().''; } print ''; @@ -384,21 +384,21 @@ if ($mode == 'overwrite') if ($mode == 'searchkey') { - $langcode=GETPOST('langcode')?GETPOST('langcode'):$langs->defaultlang; + $langcode = GETPOST('langcode') ?GETPOST('langcode') : $langs->defaultlang; - $newlang=new Translate('', $conf); + $newlang = new Translate('', $conf); $newlang->setDefaultLang($langcode); - $newlangfileonly=new Translate('', $conf); + $newlangfileonly = new Translate('', $conf); $newlangfileonly->setDefaultLang($langcode); - $recordtoshow=array(); + $recordtoshow = array(); // Search modules dirs $modulesdir = dolGetModulesDirs(); - $nbtotaloffiles=0; - $nbempty=0; + $nbtotaloffiles = 0; + $nbempty = 0; /*var_dump($langcode); var_dump($transkey); var_dump($transvalue);*/ @@ -412,27 +412,27 @@ if ($mode == 'searchkey') else { // Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root) - $i=0; - foreach($modulesdir as $keydir => $tmpsearchdir) + $i = 0; + foreach ($modulesdir as $keydir => $tmpsearchdir) { - $searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/' + $searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/' // Directory of translation files - $dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels - $dir_lang_osencoded=dol_osencode($dir_lang); + $dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels + $dir_lang_osencoded = dol_osencode($dir_lang); - $filearray=dol_dir_list($dir_lang_osencoded, 'files', 0, '', '', $sortfield, (strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC), 1); - foreach($filearray as $file) + $filearray = dol_dir_list($dir_lang_osencoded, 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); + foreach ($filearray as $file) { - $tmpfile=preg_replace('/.lang/i', '', basename($file['name'])); - $moduledirname =(basename(dirname(dirname($dir_lang)))); + $tmpfile = preg_replace('/.lang/i', '', basename($file['name'])); + $moduledirname = (basename(dirname(dirname($dir_lang)))); - $langkey=$tmpfile; - if ($i > 0) $langkey.='@'.$moduledirname; + $langkey = $tmpfile; + if ($i > 0) $langkey .= '@'.$moduledirname; //var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey); - $result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite - $result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only + $result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite + $result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only if ($result < 0) print 'Failed to load language file '.$tmpfile.'
'."\n"; else $nbtotaloffiles++; //print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records
'."\n"; @@ -441,11 +441,11 @@ if ($mode == 'searchkey') } // Now search into translation array - foreach($newlang->tab_translate as $key => $val) + foreach ($newlang->tab_translate as $key => $val) { - if ($transkey && ! preg_match('/'.preg_quote($transkey, '/').'/i', $key)) continue; - if ($transvalue && ! preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) continue; - $recordtoshow[$key]=$val; + if ($transkey && !preg_match('/'.preg_quote($transkey, '/').'/i', $key)) continue; + if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) continue; + $recordtoshow[$key] = $val; } } @@ -497,7 +497,7 @@ if ($mode == 'searchkey') print ''; // Action column print ''; print ''; @@ -508,8 +508,8 @@ if ($mode == 'searchkey') if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') arsort($recordtoshow); // Show result - $i=0; - foreach($recordtoshow as $key => $val) + $i = 0; + foreach ($recordtoshow as $key => $val) { $i++; if ($i <= $offset) continue; @@ -517,24 +517,24 @@ if ($mode == 'searchkey') print ''; print ''; print ''; print ''; +print $langs->trans("Name").':'; /* // faire une rech dans une sous categorie uniquement print ''."\n"; print "\t\t\n"; @@ -153,24 +153,24 @@ print '

'; $cate_arbo = $categstatic->get_full_arbo($typetext); // Define fulltree array -$fulltree=$cate_arbo; +$fulltree = $cate_arbo; // Define data (format for treeview) -$data=array(); -$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>''); -foreach($fulltree as $key => $val) +$data = array(); +$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); +foreach ($fulltree as $key => $val) { - $categstatic->id=$val['id']; - $categstatic->ref=$val['label']; - $categstatic->color=$val['color']; - $categstatic->type=$type; - $li=$categstatic->getNomUrl(1, '', 60); - $desc=dol_htmlcleanlastbr($val['description']); + $categstatic->id = $val['id']; + $categstatic->ref = $val['label']; + $categstatic->color = $val['color']; + $categstatic->type = $type; + $li = $categstatic->getNomUrl(1, '', 60); + $desc = dol_htmlcleanlastbr($val['description']); $data[] = array( 'rowid'=>$val['rowid'], 'fk_menu'=>$val['fk_parent'], - 'entry'=>'
' . $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/translation.php b/htdocs/admin/translation.php index ffdecdecbd1..99a198df394 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -28,21 +28,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","products","admin","sms","other","errors")); +$langs->loadLangs(array("companies", "products", "admin", "sms", "other", "errors")); if (!$user->admin) accessforbidden(); -$id=GETPOST('rowid', 'int'); -$action=GETPOST('action', 'alpha'); +$id = GETPOST('rowid', 'int'); +$action = GETPOST('action', 'alpha'); -$langcode=GETPOST('langcode', 'alpha'); -$transkey=GETPOST('transkey', 'alpha'); -$transvalue=GETPOST('transvalue', 'alpha'); +$langcode = GETPOST('langcode', 'alpha'); +$transkey = GETPOST('transkey', 'alpha'); +$transvalue = GETPOST('transvalue', 'alpha'); -$mode = GETPOST('mode', 'aZ09')?GETPOST('mode', 'aZ09'):'overwrite'; +$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'overwrite'; -$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,22 +50,22 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='lang,transkey'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 'lang,transkey'; +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('admintranslation','globaladmin')); +$hookmanager->initHooks(array('admintranslation', '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'; @@ -73,10 +73,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 { - $transkey=''; - $transvalue=''; - $toselect=''; - $search_array_options=array(); + $transkey = ''; + $transvalue = ''; + $toselect = ''; + $search_array_options = array(); } if ($action == 'setMAIN_ENABLE_OVERWRITE_TRANSLATION') @@ -92,7 +92,7 @@ if ($action == 'update') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->begin(); @@ -102,9 +102,9 @@ if ($action == 'update') { $db->commit(); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action=""; - $transkey=""; - $transvalue=""; + $action = ""; + $transkey = ""; + $transvalue = ""; } else { @@ -117,14 +117,14 @@ if ($action == 'update') { setEventMessages($db->lasterror(), null, 'errors'); } - $action=''; + $action = ''; } } } if ($action == 'add') { - $error=0; + $error = 0; if (empty($langcode)) { @@ -141,7 +141,7 @@ if ($action == 'add') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->begin(); @@ -151,9 +151,9 @@ if ($action == 'add') { $db->commit(); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action=""; - $transkey=""; - $transvalue=""; + $action = ""; + $transkey = ""; + $transvalue = ""; } else { @@ -166,7 +166,7 @@ if ($action == 'add') { setEventMessages($db->lasterror(), null, 'errors'); } - $action=''; + $action = ''; } } } @@ -198,26 +198,26 @@ if ($action == 'delete') $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=''; -$enabledisablehtml.= $langs->trans("EnableOverwriteTranslation").' '; +$enabledisablehtml = ''; +$enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' '; if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // 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("Translation"), $enabledisablehtml, 'title_setup'); @@ -247,7 +247,7 @@ print ''; print ''; print ''; -$head=translation_prepare_head(); +$head = translation_prepare_head(); dol_fiche_head($head, $mode, '', -1, ''); @@ -255,14 +255,14 @@ if ($mode == 'overwrite') { //print load_fiche_titre($langs->trans("TranslationOverwriteKey"), '', '')."\n"; - $disabled=''; - if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disabled=' disabled="disabled"'; - $disablededit=''; - if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disablededit=' disabled'; + $disabled = ''; + if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disabled = ' disabled="disabled"'; + $disablededit = ''; + if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disablededit = ' disabled'; print '
'; print img_info().' '.$langs->trans("SomeTranslationAreUncomplete"); - $urlwikitranslatordoc='https://wiki.dolibarr.org/index.php/Translator_documentation'; + $urlwikitranslatordoc = 'https://wiki.dolibarr.org/index.php/Translator_documentation'; print ' ('.$langs->trans("SeeAlso", ''.$langs->trans("Here").'').')
'; print $langs->trans("TranslationOverwriteDesc", $langs->transnoentitiesnoconv("Language"), $langs->transnoentitiesnoconv("Key"), $langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n"; print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."
\n"; @@ -271,7 +271,7 @@ if ($mode == 'overwrite') print '
'; - print ''; + print ''; print ''; print '
'; @@ -289,12 +289,12 @@ if ($mode == 'overwrite') print "\n"; print '
'; - print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit?1:0, 'maxwidthonsmartphone', 1); + print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit ? 1 : 0, 'maxwidthonsmartphone', 1); print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '
'.$langcode.''.$key.''; print dol_escape_htmltag($val); print ''; - if (! empty($newlangfileonly->tab_translate[$key])) + if (!empty($newlangfileonly->tab_translate[$key])) { if ($val != $newlangfileonly->tab_translate[$key]) { // retrieve rowid $sql = "SELECT rowid"; - $sql.= " FROM " . MAIN_DB_PREFIX . "overwrite_trans"; - $sql.= " WHERE transkey = '".$key."'"; - $sql.= " AND entity IN (" . getEntity('overwrite_trans') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans"; + $sql .= " WHERE transkey = '".$key."'"; + $sql .= " AND entity IN (".getEntity('overwrite_trans').")"; dol_syslog("translation::select from table", LOG_DEBUG); $result = $db->query($sql); if ($result) { $obj = $db->fetch_object($result); } - print '' . img_edit() . ''; + print ''.img_edit().''; print '  '; - print '' . img_delete() . ''; + print ''.img_delete().''; print '  '; $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); print $form->textwithpicto('', $htmltext, 1, 'info'); @@ -542,12 +542,12 @@ if ($mode == 'searchkey') elseif (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { //print $key.'-'.$val; - print '' . img_edit_add($langs->trans("Overwrite")) . ''; + print ''.img_edit_add($langs->trans("Overwrite")).''; } - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { - $transifexlangfile='$'; // $ means 'All' + $transifexlangfile = '$'; // $ means 'All' //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key; $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key; @@ -574,7 +574,7 @@ dol_fiche_end(); print "\n"; -if (! empty($langcode)) +if (!empty($langcode)) { dol_set_focus('#transvalue'); } diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 2b34f673107..351f50438ed 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -49,8 +49,8 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST( $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='position'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 'position'; +if (!$sortorder) $sortorder = 'ASC'; $id = GETPOST("id", 'int'); diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index a8119225db9..782280e6d2b 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -94,7 +94,7 @@ class Facturation */ public function ajoutArticle() { - global $conf,$db,$mysoc; + global $conf, $db, $mysoc; $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; @@ -108,21 +108,21 @@ class Facturation $vatrowid = $this->tva(); $tmp = getTaxesFromId($vatrowid); - $txtva = $tmp['rate'].(empty($tmp['code'])?'':' ('.$tmp['code'].')'); + $txtva = $tmp['rate'].(empty($tmp['code']) ? '' : ' ('.$tmp['code'].')'); $vat_npr = $tmp['npr']; $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); // 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. } // Define part of HT, VAT, TTC - $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); + $resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); // Calculation of total HT without discount $total_ht = $resultarray[0]; @@ -141,20 +141,20 @@ class Facturation $montant_remise_ht = ($resultarray[6] - $resultarray[0]); $this->montantRemise($montant_remise_ht); - $newcartarray=$_SESSION['poscart']; + $newcartarray = $_SESSION['poscart']; $i = 0; if (!is_null($newcartarray) && !empty($newcartarray)) { - $i=count($newcartarray); + $i = count($newcartarray); } - $newcartarray[$i]['id']=$i; - $newcartarray[$i]['ref']=$product->ref; - $newcartarray[$i]['label']=$product->label; - $newcartarray[$i]['price']=$product->price; - $newcartarray[$i]['price_ttc']=$product->price_ttc; + $newcartarray[$i]['id'] = $i; + $newcartarray[$i]['ref'] = $product->ref; + $newcartarray[$i]['label'] = $product->label; + $newcartarray[$i]['price'] = $product->price; + $newcartarray[$i]['price_ttc'] = $product->price_ttc; - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { if (isset($product->multiprices[$societe->price_level])) { @@ -163,17 +163,17 @@ class Facturation } } - $newcartarray[$i]['fk_article']=$this->id; - $newcartarray[$i]['qte']=$this->qte(); - $newcartarray[$i]['fk_tva']=$this->tva(); // Vat rowid - $newcartarray[$i]['remise_percent']=$remise_percent; - $newcartarray[$i]['remise']=price2num($montant_remise_ht); - $newcartarray[$i]['total_ht']=price2num($total_ht, 'MT'); - $newcartarray[$i]['total_ttc']=price2num($total_ttc, 'MT'); - $newcartarray[$i]['total_vat']=price2num($total_vat, 'MT'); - $newcartarray[$i]['total_localtax1']=price2num($total_localtax1, 'MT'); - $newcartarray[$i]['total_localtax2']=price2num($total_localtax2, 'MT'); - $_SESSION['poscart']=$newcartarray; + $newcartarray[$i]['fk_article'] = $this->id; + $newcartarray[$i]['qte'] = $this->qte(); + $newcartarray[$i]['fk_tva'] = $this->tva(); // Vat rowid + $newcartarray[$i]['remise_percent'] = $remise_percent; + $newcartarray[$i]['remise'] = price2num($montant_remise_ht); + $newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT'); + $newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT'); + $newcartarray[$i]['total_vat'] = price2num($total_vat, 'MT'); + $newcartarray[$i]['total_localtax1'] = price2num($total_localtax1, 'MT'); + $newcartarray[$i]['total_localtax2'] = price2num($total_localtax2, 'MT'); + $_SESSION['poscart'] = $newcartarray; $this->raz(); } @@ -213,16 +213,16 @@ class Facturation { global $db; - $total_ht=0; - $total_ttc=0; + $total_ht = 0; + $total_ttc = 0; $total_vat = 0; $total_localtax1 = 0; $total_localtax2 = 0; - $tab = (! empty($_SESSION['poscart'])?$_SESSION['poscart']:array()); + $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); - $tab_size=count($tab); - for($i=0;$i < $tab_size;$i++) + $tab_size = count($tab); + for ($i = 0; $i < $tab_size; $i++) { // Total HT $remise = $tab[$i]['remise']; @@ -290,11 +290,11 @@ class Facturation public function id($aId = null) { - if ( !$aId ) + if (!$aId) { return $this->id; } - elseif ( $aId == 'RESET' ) + elseif ($aId == 'RESET') { $this->id = null; } @@ -317,7 +317,7 @@ class Facturation { return $this->ref; } - elseif ( $aRef == 'RESET' ) + elseif ($aRef == 'RESET') { $this->ref = null; } @@ -339,7 +339,7 @@ class Facturation { return $this->qte; } - elseif ( $aQte == 'RESET' ) + elseif ($aQte == 'RESET') { $this->qte = null; } @@ -362,7 +362,7 @@ class Facturation { return $this->stock; } - elseif ( $aStock == 'RESET' ) + elseif ($aStock == 'RESET') { $this->stock = null; } @@ -582,7 +582,7 @@ class Facturation { return $this->prix_total_ttc; } - elseif ( $aTotalTtc == 'RESET' ) + elseif ($aTotalTtc == 'RESET') { $this->prix_total_ttc = null; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f184f1b433f..25cf0287292 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -143,7 +143,7 @@ class Categorie extends CommonObject 'member' => 'Adherent', 'contact' => 'Contact', 'user' => 'User', - 'account' => 'Account', // old for bank account + 'account' => 'Account', // old for bank account 'bank_account' => 'Account', 'project' => 'Project', 'warehouse'=> 'Entrepot', @@ -169,12 +169,12 @@ class Categorie extends CommonObject /** * @var string ID to identify managed object */ - public $element='category'; + public $element = 'category'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='categorie'; + public $table_element = 'categorie'; /** * @var int ID @@ -251,18 +251,18 @@ class Categorie extends CommonObject // Check parameters if (empty($id) && empty($label)) return -1; - if (! is_numeric($type)) $type=$this->MAP_ID[$type]; + if (!is_numeric($type)) $type = $this->MAP_ID[$type]; $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; if ($id > 0) { - $sql.= " WHERE rowid = ".$id; + $sql .= " WHERE rowid = ".$id; } else { - $sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; - if (! is_null($type)) $sql.= " AND type = ".$this->db->escape($type); + $sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; + if (!is_null($type)) $sql .= " AND type = ".$this->db->escape($type); } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -273,16 +273,16 @@ class Categorie extends CommonObject { $res = $this->db->fetch_array($resql); - $this->id = $res['rowid']; + $this->id = $res['rowid']; //$this->ref = $res['rowid']; $this->fk_parent = $res['fk_parent']; $this->label = $res['label']; - $this->description = $res['description']; + $this->description = $res['description']; $this->color = $res['color']; $this->socid = $res['fk_soc']; - $this->visible = $res['visible']; + $this->visible = $res['visible']; $this->type = $res['type']; - $this->entity = $res['entity']; + $this->entity = $res['entity']; // Retreive all extrafield // fetch optionals attributes and labels @@ -291,7 +291,7 @@ class Categorie extends CommonObject $this->db->free($resql); // multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); return 1; } @@ -318,14 +318,14 @@ class Categorie extends CommonObject */ public function create($user) { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('categories'); - $type=$this->type; + $type = $this->type; - if (! is_numeric($type)) $type=$this->MAP_ID[$type]; + if (!is_numeric($type)) $type = $this->MAP_ID[$type]; - $error=0; + $error = 0; dol_syslog(get_class($this).'::create', LOG_DEBUG); @@ -334,13 +334,13 @@ class Categorie extends CommonObject $this->description = trim($this->description); $this->color = trim($this->color); $this->import_key = trim($this->import_key); - if (empty($this->visible)) $this->visible=0; + if (empty($this->visible)) $this->visible = 0; $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); if ($this->already_exists()) { - $this->error=$langs->trans("ImpossibleAddCat", $this->label); - $this->error.=" : ".$langs->trans("CategoryExistsAtSameLevel"); + $this->error = $langs->trans("ImpossibleAddCat", $this->label); + $this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel"); dol_syslog($this->error, LOG_WARNING); return -4; } @@ -348,32 +348,32 @@ class Categorie extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie ("; - $sql.= "fk_parent,"; - $sql.= " label,"; - $sql.= " description,"; - $sql.= " color,"; - if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) + $sql .= "fk_parent,"; + $sql .= " label,"; + $sql .= " description,"; + $sql .= " color,"; + if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { - $sql.= "fk_soc,"; + $sql .= "fk_soc,"; } - $sql.= " visible,"; - $sql.= " type,"; - $sql.= " import_key,"; - $sql.= " entity"; - $sql.= ") VALUES ("; - $sql.= $this->db->escape($this->fk_parent).","; - $sql.= "'".$this->db->escape($this->label)."',"; - $sql.= "'".$this->db->escape($this->description)."',"; - $sql.= "'".$this->db->escape($this->color)."',"; - if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) + $sql .= " visible,"; + $sql .= " type,"; + $sql .= " import_key,"; + $sql .= " entity"; + $sql .= ") VALUES ("; + $sql .= $this->db->escape($this->fk_parent).","; + $sql .= "'".$this->db->escape($this->label)."',"; + $sql .= "'".$this->db->escape($this->description)."',"; + $sql .= "'".$this->db->escape($this->color)."',"; + if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { - $sql.= ($this->socid != -1 ? $this->socid : 'null').","; + $sql .= ($this->socid != -1 ? $this->socid : 'null').","; } - $sql.= "'".$this->db->escape($this->visible)."',"; - $sql.= $this->db->escape($type).","; - $sql.= (! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":'null').","; - $sql.= $this->db->escape($conf->entity); - $sql.= ")"; + $sql .= "'".$this->db->escape($this->visible)."',"; + $sql .= $this->db->escape($type).","; + $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').","; + $sql .= $this->db->escape($conf->entity); + $sql .= ")"; $res = $this->db->query($sql); if ($res) @@ -384,27 +384,27 @@ class Categorie extends CommonObject { $this->id = $id; - $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++; } } - if (! $error) + if (!$error) { // Call trigger - $result=$this->call_trigger('CATEGORY_CREATE', $user); + $result = $this->call_trigger('CATEGORY_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if ( ! $error ) + if (!$error) { $this->db->commit(); return $id; @@ -423,7 +423,7 @@ class Categorie extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -439,30 +439,30 @@ class Categorie extends CommonObject */ public function update(User $user) { - global $conf, $langs,$hookmanager; + global $conf, $langs, $hookmanager; - $error=0; + $error = 0; // Clean parameters - $this->label=trim($this->label); - $this->description=trim($this->description); + $this->label = trim($this->label); + $this->description = trim($this->description); $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); $this->visible = ($this->visible != "" ? intval($this->visible) : 0); if ($this->already_exists()) { - $this->error=$langs->trans("ImpossibleUpdateCat"); - $this->error.=" : ".$langs->trans("CategoryExistsAtSameLevel"); + $this->error = $langs->trans("ImpossibleUpdateCat"); + $this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel"); return -1; } $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; - $sql.= " SET label = '".$this->db->escape($this->label)."',"; - $sql.= " description = '".$this->db->escape($this->description)."',"; - $sql.= " color = '".$this->db->escape($this->color)."'"; - if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) + $sql .= " SET label = '".$this->db->escape($this->label)."',"; + $sql .= " description = '".$this->db->escape($this->description)."',"; + $sql .= " color = '".$this->db->escape($this->color)."'"; + if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { $sql .= ", fk_soc = ".($this->socid != -1 ? $this->socid : 'null'); } @@ -473,22 +473,22 @@ class Categorie extends CommonObject 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++; } } - if (! $error) + if (!$error) { // Call trigger - $result=$this->call_trigger('CATEGORY_MODIFY', $user); + $result = $this->call_trigger('CATEGORY_MODIFY', $user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } // End call triggers } @@ -514,9 +514,9 @@ class Categorie extends CommonObject */ public function delete($user, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; // Clean parameters $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); @@ -525,24 +525,24 @@ class Categorie extends CommonObject $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('CATEGORY_DELETE', $user); + $result = $this->call_trigger('CATEGORY_DELETE', $user); if ($result < 0) $error++; // End call triggers } /* FIX #1317 : Check for child category and move up 1 level*/ - if (! $error) + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; - $sql.= " SET fk_parent = ".$this->fk_parent; - $sql.= " WHERE fk_parent = ".$this->id; + $sql .= " SET fk_parent = ".$this->fk_parent; + $sql .= " WHERE fk_parent = ".$this->id; if (!$this->db->query($sql)) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -559,7 +559,7 @@ class Categorie extends CommonObject 'categorie' => 'rowid', ); foreach ($arraydelete as $key => $value) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . $key; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$key; $sql .= " WHERE ".$value." = ".$this->id; if (!$this->db->query($sql)) { $this->errors[] = $this->db->lasterror(); @@ -569,9 +569,9 @@ class Categorie 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++; @@ -579,7 +579,7 @@ class Categorie extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -602,28 +602,28 @@ class Categorie extends CommonObject public function add_type($obj, $type) { // phpcs:enable - global $user,$langs,$conf; + global $user, $langs, $conf; - $error=0; + $error = 0; if ($this->id == -1) return -2; $this->db->begin(); - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type]; - $sql .= " (fk_categorie, fk_" . $this->MAP_CAT_FK[$type] . ")"; - $sql .= " VALUES (" . $this->id . ", " . $obj->id . ")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]; + $sql .= " (fk_categorie, fk_".$this->MAP_CAT_FK[$type].")"; + $sql .= " VALUES (".$this->id.", ".$obj->id.")"; dol_syslog(get_class($this).'::add_type', LOG_DEBUG); if ($this->db->query($sql)) { - if (! empty($conf->global->CATEGORIE_RECURSIV_ADD)) + if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) { $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'categorie'; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::add_type", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql) > 0) @@ -648,7 +648,7 @@ class Categorie extends CommonObject else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } if ($error) @@ -661,12 +661,12 @@ class Categorie extends CommonObject // Call trigger - $this->context=array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger - $result=$this->call_trigger('CATEGORY_LINK', $user); + $this->context = array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger + $result = $this->call_trigger('CATEGORY_LINK', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -682,12 +682,12 @@ class Categorie extends CommonObject $this->db->rollback(); if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$this->db->lasterrno(); + $this->error = $this->db->lasterrno(); return -3; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } return -1; } @@ -705,35 +705,35 @@ class Categorie extends CommonObject public function del_type($obj, $type) { // phpcs:enable - global $user,$langs,$conf; + global $user, $langs, $conf; - $error=0; + $error = 0; // For backward compatibility if ($type == 'societe') { $type = 'customer'; - dol_syslog(get_class($this) . "::del_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING); + dol_syslog(get_class($this)."::del_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING); } elseif ($type == 'fournisseur') { $type = 'supplier'; - dol_syslog(get_class($this) . "::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING); + dol_syslog(get_class($this)."::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING); } $this->db->begin(); - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type]; - $sql .= " WHERE fk_categorie = " . $this->id; - $sql .= " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $obj->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]; + $sql .= " WHERE fk_categorie = ".$this->id; + $sql .= " AND fk_".$this->MAP_CAT_FK[$type]." = ".$obj->id; dol_syslog(get_class($this).'::del_type', LOG_DEBUG); if ($this->db->query($sql)) { // Call trigger - $this->context=array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger - $result=$this->call_trigger('CATEGORY_UNLINK', $user); + $this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger + $result = $this->call_trigger('CATEGORY_UNLINK', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -747,7 +747,7 @@ class Categorie extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -794,12 +794,12 @@ class Categorie extends CommonObject { if ($onlyids) { - $objs[] = $rec['fk_' . $this->MAP_CAT_FK[$type]]; + $objs[] = $rec['fk_'.$this->MAP_CAT_FK[$type]]; } else { - $obj = new $this->MAP_OBJ_CLASS[$type]( $this->db ); - $obj->fetch($rec['fk_' . $this->MAP_CAT_FK[$type]]); + $obj = new $this->MAP_OBJ_CLASS[$type]($this->db); + $obj->fetch($rec['fk_'.$this->MAP_CAT_FK[$type]]); $objs[] = $obj; } } @@ -807,7 +807,7 @@ class Categorie extends CommonObject } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -822,14 +822,14 @@ class Categorie extends CommonObject */ public function containsObject($type, $object_id) { - $sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type]; - $sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $object_id; + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]; + $sql .= " WHERE fk_categorie = ".$this->id." AND fk_".$this->MAP_CAT_FK[$type]." = ".$object_id; dol_syslog(get_class($this)."::containsObject", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { return $this->db->fetch_object($resql)->nb; } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -912,20 +912,20 @@ class Categorie extends CommonObject $category_static = new Categorie($this->db); if ($category_static->fetch($obj->rowid)) { - $categories[$i]['id'] = $category_static->id; + $categories[$i]['id'] = $category_static->id; $categories[$i]['fk_parent'] = $category_static->fk_parent; $categories[$i]['label'] = $category_static->label; - $categories[$i]['description'] = $category_static->description; + $categories[$i]['description'] = $category_static->description; $categories[$i]['color'] = $category_static->color; $categories[$i]['socid'] = $category_static->socid; - $categories[$i]['visible'] = $category_static->visible; - $categories[$i]['type'] = $category_static->type; - $categories[$i]['entity'] = $category_static->entity; - $categories[$i]['array_options'] = $category_static->array_options; + $categories[$i]['visible'] = $category_static->visible; + $categories[$i]['type'] = $category_static->type; + $categories[$i]['entity'] = $category_static->entity; + $categories[$i]['array_options'] = $category_static->array_options; // multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) { - $categories[$i]['multilangs'] = $category_static->multilangs; + if (!empty($conf->global->MAIN_MULTILANGS)) { + $categories[$i]['multilangs'] = $category_static->multilangs; } } $i++; @@ -935,7 +935,7 @@ class Categorie extends CommonObject $this->error = $this->db->lasterror(); return -1; } - if ( ! count($categories)) { + if (!count($categories)) { return 0; } @@ -952,9 +952,9 @@ class Categorie extends CommonObject { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE fk_parent = ".$this->id; + $sql .= " WHERE fk_parent = ".$this->id; - $res = $this->db->query($sql); + $res = $this->db->query($sql); if ($res) { $cats = array(); @@ -982,21 +982,21 @@ class Categorie extends CommonObject protected function load_motherof() { // phpcs:enable - $this->motherof=array(); + $this->motherof = array(); // Load array[child]=parent $sql = "SELECT fk_parent as id_parent, rowid as id_son"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE fk_parent != 0"; - $sql.= " AND entity IN (".getEntity('category').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql .= " WHERE fk_parent != 0"; + $sql .= " AND entity IN (".getEntity('category').")"; dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - while ($obj= $this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->motherof[$obj->id_son]=$obj->id_parent; + $this->motherof[$obj->id_son] = $obj->id_parent; } return 1; } @@ -1032,7 +1032,7 @@ class Categorie extends CommonObject // phpcs:enable global $conf, $langs; - if (! is_numeric($type)) $type = $this->MAP_ID[$type]; + if (!is_numeric($type)) $type = $this->MAP_ID[$type]; if (is_string($markafterid)) { @@ -1061,25 +1061,25 @@ class Categorie extends CommonObject $current_lang = $langs->getDefaultLang(); // Init $this->cats array - $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates - if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ", t.label as label_trans, t.description as description_trans"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c"; - if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'"; - $sql .= " WHERE c.entity IN (" . getEntity('category') . ")"; - $sql .= " AND c.type = " . (int) $type; + $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates + if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ", t.label as label_trans, t.description as description_trans"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as c"; + if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'"; + $sql .= " WHERE c.entity IN (".getEntity('category').")"; + $sql .= " AND c.type = ".(int) $type; dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $i=0; + $i = 0; while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['rowid'] = $obj->rowid; $this->cats[$obj->rowid]['id'] = $obj->rowid; $this->cats[$obj->rowid]['fk_parent'] = $obj->fk_parent; - $this->cats[$obj->rowid]['label'] = ! empty($obj->label_trans) ? $obj->label_trans : $obj->label; - $this->cats[$obj->rowid]['description'] = ! empty($obj->description_trans) ? $obj->description_trans : $obj->description; + $this->cats[$obj->rowid]['label'] = !empty($obj->label_trans) ? $obj->label_trans : $obj->label; + $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; $i++; @@ -1093,10 +1093,10 @@ class Categorie extends CommonObject // We add the fullpath property to each elements of first level (no parent exists) dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); - foreach($this->cats as $key => $val) + foreach ($this->cats as $key => $val) { //print 'key='.$key.'
'."\n"; - $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) + $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) } // Include or exclude leaf including $markafterid from tree @@ -1105,14 +1105,14 @@ class Categorie extends CommonObject $keyfiltercatid = implode('|', $markafterid); //print "Look to discard category ".$markafterid."\n"; - $keyfilter1 = '^' . $keyfiltercatid . '$'; - $keyfilter2 = '_' . $keyfiltercatid . '$'; - $keyfilter3 = '^' . $keyfiltercatid . '_'; - $keyfilter4 = '_' . $keyfiltercatid . '_'; - foreach($this->cats as $key => $val) + $keyfilter1 = '^'.$keyfiltercatid.'$'; + $keyfilter2 = '_'.$keyfiltercatid.'$'; + $keyfilter3 = '^'.$keyfiltercatid.'_'; + $keyfilter4 = '_'.$keyfiltercatid.'_'; + foreach ($this->cats as $key => $val) { - $test = (preg_match('/' . $keyfilter1 . '/', $val['fullpath']) || preg_match('/' . $keyfilter2 . '/', $val['fullpath']) - || preg_match('/' . $keyfilter3 . '/', $val['fullpath']) || preg_match('/' . $keyfilter4 . '/', $val['fullpath'])); + $test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) + || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])); if (($test && !$include) || (!$test && $include)) { @@ -1122,7 +1122,7 @@ class Categorie extends CommonObject } dol_syslog(get_class($this)."::get_full_arbo dol_sort_array", LOG_DEBUG); - $this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); + $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); //$this->debug_cats(); @@ -1143,7 +1143,7 @@ class Categorie extends CommonObject // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); - if (! empty($this->cats[$id_categ]['fullpath'])) + if (!empty($this->cats[$id_categ]['fullpath'])) { // Already defined dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); @@ -1156,20 +1156,20 @@ class Categorie extends CommonObject // Define fullpath and fulllabel $this->cats[$id_categ]['fullpath'] = '_'.$id_categ; $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label']; - $i=0; $cursor_categ=$id_categ; + $i = 0; $cursor_categ = $id_categ; //print 'Work for id_categ='.$id_categ.'
'."\n"; - while ((empty($protection) || $i < $protection) && ! empty($this->motherof[$cursor_categ])) + while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) { //print '  cursor_categ='.$cursor_categ.' i='.$i.' '.$this->motherof[$cursor_categ].'
'."\n"; $this->cats[$id_categ]['fullpath'] = '_'.$this->motherof[$cursor_categ].$this->cats[$id_categ]['fullpath']; $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->motherof[$cursor_categ]]['label'].' >> '.$this->cats[$id_categ]['fulllabel']; //print '  Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].' '.$this->cats[$id_categ]['fulllabel'].'
'."\n"; - $i++; $cursor_categ=$this->motherof[$cursor_categ]; + $i++; $cursor_categ = $this->motherof[$cursor_categ]; } //print 'Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].'
'."\n"; // We count number of _ to have level - $this->cats[$id_categ]['level']=dol_strlen(preg_replace('/[^_]/i', '', $this->cats[$id_categ]['fullpath'])); + $this->cats[$id_categ]['level'] = dol_strlen(preg_replace('/[^_]/i', '', $this->cats[$id_categ]['fullpath'])); return; } @@ -1184,7 +1184,7 @@ class Categorie extends CommonObject { // phpcs:enable // Display $this->cats - foreach($this->cats as $key => $val) + foreach ($this->cats as $key => $val) { print 'id: '.$this->cats[$key]['id']; print ' label: '.$this->cats[$key]['label']; @@ -1208,19 +1208,19 @@ class Categorie extends CommonObject public function get_all_categories($type = null, $parent = false) { // phpcs:enable - if (! is_numeric($type)) $type = $this->MAP_ID[$type]; + if (!is_numeric($type)) $type = $this->MAP_ID[$type]; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE entity IN (".getEntity('category').")"; - if (! is_null($type)) - $sql.= " AND type = ".$type; + $sql .= " WHERE entity IN (".getEntity('category').")"; + if (!is_null($type)) + $sql .= " AND type = ".$type; if ($parent) - $sql.= " AND fk_parent = 0"; + $sql .= " AND fk_parent = 0"; $res = $this->db->query($sql); if ($res) { - $cats = array (); + $cats = array(); while ($rec = $this->db->fetch_array($res)) { $cat = new Categorie($this->db); @@ -1258,19 +1258,19 @@ class Categorie extends CommonObject public function already_exists() { // phpcs:enable - $type=$this->type; + $type = $this->type; - if (! is_numeric($type)) $type=$this->MAP_ID[$type]; + if (!is_numeric($type)) $type = $this->MAP_ID[$type]; /* We have to select any rowid from llx_categorie which category's mother and label * are equals to those of the calling category */ $sql = "SELECT c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c "; - $sql.= " WHERE c.entity IN (".getEntity('category').")"; - $sql.= " AND c.type = ".$type; - $sql.= " AND c.fk_parent = ".$this->fk_parent; - $sql.= " AND c.label = '".$this->db->escape($this->label)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as c "; + $sql .= " WHERE c.entity IN (".getEntity('category').")"; + $sql .= " AND c.type = ".$type; + $sql .= " AND c.fk_parent = ".$this->fk_parent; + $sql .= " AND c.label = '".$this->db->escape($this->label)."'"; dol_syslog(get_class($this)."::already_exists", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1284,7 +1284,7 @@ class Categorie extends CommonObject * So if the result have the same id, update is not for label, and if result have an other one, * update may be for label. */ - if($obj[0] > 0 && $obj[0] != $this->id) + if ($obj[0] > 0 && $obj[0] != $this->id) { dol_syslog(get_class($this)."::already_exists category with name=".$this->label." and parent ".$this->fk_parent." exists: rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG); return 1; @@ -1295,7 +1295,7 @@ class Categorie extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1321,29 +1321,29 @@ class Categorie extends CommonObject { $w = array(); $i = 0; - $forced_color=''; + $forced_color = ''; foreach ($way as $cat) { $i++; if (empty($nocolor)) { - $forced_color='toreplace'; + $forced_color = 'toreplace'; if ($i == count($way)) { // Check contrast with background and correct text color - $forced_color='categtextwhite'; + $forced_color = 'categtextwhite'; if ($cat->color) { - if (colorIsLight($cat->color)) $forced_color='categtextblack'; + if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; } } } if ($url == '') { - $link = ''; - $linkend=''; + $link = ''; + $linkend = ''; $w[] = $link.$cat->label.$linkend; } else @@ -1372,9 +1372,9 @@ class Categorie extends CommonObject $parents = array(); $sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; - $res = $this->db->query($sql); + $res = $this->db->query($sql); if ($res) { @@ -1408,17 +1408,17 @@ class Categorie extends CommonObject // phpcs:enable $ways = array(); - $parents=$this->get_meres(); - if (! empty($parents)) + $parents = $this->get_meres(); + if (!empty($parents)) { foreach ($parents as $parent) { - $allways=$parent->get_all_ways(); + $allways = $parent->get_all_ways(); foreach ($allways as $way) { - $w = $way; - $w[] = $this; - $ways[] = $w; + $w = $way; + $w[] = $this; + $ways[] = $w; } } } @@ -1449,9 +1449,9 @@ class Categorie extends CommonObject { // Load bank groups $sql = "SELECT c.label, c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; - $sql.= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; - $sql.= " ORDER BY c.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; + $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; + $sql .= " ORDER BY c.label"; $res = $this->db->query($sql); if ($res) @@ -1479,9 +1479,9 @@ class Categorie extends CommonObject else { $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; - $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as ct, " . MAIN_DB_PREFIX . "categorie as c"; - $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . (int) $id . " AND c.type = " . $this->MAP_ID[$type]; - $sql .= " AND c.entity IN (" . getEntity('category') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as ct, ".MAIN_DB_PREFIX."categorie as c"; + $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".$this->MAP_CAT_FK[$type]." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type]; + $sql .= " AND c.entity IN (".getEntity('category').")"; $res = $this->db->query($sql); if ($res) @@ -1525,7 +1525,7 @@ class Categorie extends CommonObject { // Deprecation warning if (is_numeric($type)) { - dol_syslog(__METHOD__ . ': using numeric types is deprecated.', LOG_WARNING); + dol_syslog(__METHOD__.': using numeric types is deprecated.', LOG_WARNING); } $cats = array(); @@ -1535,25 +1535,25 @@ class Categorie extends CommonObject // We want to reverse lookup $map_type = array_flip($this->MAP_ID); $type = $map_type[$type]; - dol_syslog(get_class($this) . "::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); + dol_syslog(get_class($this)."::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); } // Generation requete recherche - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie"; - $sql .= " WHERE type = " . $this->MAP_ID[$type]; - $sql .= " AND entity IN (" . getEntity('category') . ")"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; + $sql .= " WHERE type = ".$this->MAP_ID[$type]; + $sql .= " AND entity IN (".getEntity('category').")"; if ($nom) { - if (! $exact) + if (!$exact) $nom = '%'.str_replace('*', '%', $nom).'%'; - if (! $case) - $sql.= " AND label LIKE '".$this->db->escape($nom)."'"; + if (!$case) + $sql .= " AND label LIKE '".$this->db->escape($nom)."'"; else - $sql.= " AND label LIKE BINARY '".$this->db->escape($nom)."'"; + $sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'"; } if ($id) { - $sql.=" AND rowid = '".$id."'"; + $sql .= " AND rowid = '".$id."'"; } $res = $this->db->query($sql); @@ -1570,7 +1570,7 @@ class Categorie extends CommonObject } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -1588,25 +1588,25 @@ class Categorie extends CommonObject { global $langs; - $result=''; - $label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label); + $result = ''; + $label = $langs->trans("ShowCategory").': '.($this->ref ? $this->ref : $this->label); // Check contrast with background and correct text color - $forced_color='categtextwhite'; + $forced_color = 'categtextwhite'; if ($this->color) { - if (colorIsLight($this->color)) $forced_color='categtextblack'; + if (colorIsLight($this->color)) $forced_color = 'categtextblack'; } - $link = ''; - $linkend=''; + $link = ''; + $linkend = ''; - $picto='category'; + $picto = 'category'; - if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.dol_trunc(($this->ref?$this->ref:$this->label), $maxlength).$linkend; + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; return $result; } @@ -1624,10 +1624,10 @@ class Categorie extends CommonObject // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $dir = $sdir .'/'. get_exdir($this->id, 2, 0, 0, $this, 'category') . $this->id ."/"; + $dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, 'category').$this->id."/"; $dir .= "photos/"; - if (! file_exists($dir)) + if (!file_exists($dir)) { dol_mkdir($dir); } @@ -1648,7 +1648,7 @@ class Categorie extends CommonObject } } } else { - $originImage = $dir . $file['name']; + $originImage = $dir.$file['name']; // Cree fichier en taille origine dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0); @@ -1672,16 +1672,16 @@ class Categorie extends CommonObject public function liste_photos($dir, $nbmax = 0) { // phpcs:enable - include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $nbphoto=0; - $tabobj=array(); + $nbphoto = 0; + $tabobj = array(); $dirthumb = $dir.'thumbs/'; if (file_exists($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) @@ -1692,19 +1692,19 @@ class Categorie extends CommonObject $photo = $file; // On determine nom du fichier vignette - $photo_vignette=''; + $photo_vignette = ''; if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/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]; } // Objet - $obj=array(); - $obj['photo']=$photo; - if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette']='thumbs/' . $photo_vignette; - else $obj['photo_vignette']=""; + $obj = array(); + $obj['photo'] = $photo; + if ($photo_vignette && 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; @@ -1740,7 +1740,7 @@ class Categorie extends CommonObject // Si elle existe, on efface la vignette if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/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($dirthumb.$photo_vignette)) { dol_delete_file($dirthumb.$photo_vignette, 1); @@ -1780,9 +1780,9 @@ class Categorie extends CommonObject foreach ($langs_available as $key => $value) { $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_lang"; - $sql.= " WHERE fk_category=".$this->id; - $sql.= " AND lang='".$key."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; + $sql .= " WHERE fk_category=".$this->id; + $sql .= " AND lang='".$key."'"; $result = $this->db->query($sql); @@ -1791,20 +1791,20 @@ class Categorie extends CommonObject if ($this->db->num_rows($result)) // si aucune ligne dans la base { $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; - $sql2.= " SET label='".$this->db->escape($this->label)."',"; - $sql2.= " description='".$this->db->escape($this->description)."'"; - $sql2.= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; + $sql2 .= " SET label='".$this->db->escape($this->label)."',"; + $sql2 .= " description='".$this->db->escape($this->description)."'"; + $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; - $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->label); - $sql2.= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; + $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label); + $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; } dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (! $this->db->query($sql2)) + if (!$this->db->query($sql2)) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1813,23 +1813,23 @@ class Categorie extends CommonObject if ($this->db->num_rows($result)) // si aucune ligne dans la base { $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; - $sql2.= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; - $sql2.= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; + $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; + $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; - $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->multilangs["$key"]["label"]); - $sql2.= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; + $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]); + $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; } // on ne sauvegarde pas des champs vides - if ( $this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"] ) + if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (! $this->db->query($sql2)) + if (!$this->db->query($sql2)) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1858,28 +1858,28 @@ class Categorie extends CommonObject $current_lang = $langs->getDefaultLang(); $sql = "SELECT lang, label, description"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_lang"; - $sql.= " WHERE fk_category=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; + $sql .= " WHERE fk_category=".$this->id; $result = $this->db->query($sql); if ($result) { - while ( $obj = $this->db->fetch_object($result) ) + while ($obj = $this->db->fetch_object($result)) { //print 'lang='.$obj->lang.' current='.$current_lang.'
'; - if( $obj->lang == $current_lang ) // si on a les traduct. dans la langue courante on les charge en infos principales. + 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->label = $obj->label; + $this->description = $obj->description; } - $this->multilangs["$obj->lang"]["label"] = $obj->label; - $this->multilangs["$obj->lang"]["description"] = $obj->description; + $this->multilangs["$obj->lang"]["label"] = $obj->label; + $this->multilangs["$obj->lang"]["description"] = $obj->description; } return 1; } else { - $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; return -1; } } @@ -1908,10 +1908,10 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::initAsSpecimen"); // Initialise parametres - $this->id=0; - $this->fk_parent=0; + $this->id = 0; + $this->fk_parent = 0; $this->label = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->description = 'This is a description'; $this->socid = 1; $this->type = self::TYPE_PRODUCT; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index e0886da002c..61e3e4a09df 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -34,13 +34,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page $langs->load("categories"); -if (! $user->rights->categorie->lire) accessforbidden(); +if (!$user->rights->categorie->lire) accessforbidden(); -$id=GETPOST('id', 'int'); -$type=(GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT); -$catname=GETPOST('catname', 'alpha'); +$id = GETPOST('id', 'int'); +$type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT); +$catname = GETPOST('catname', 'alpha'); -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 /* @@ -92,7 +92,7 @@ print '
'.$langs->trans("Search").'
'; -print $langs->trans("Name").':
'; @@ -124,12 +124,12 @@ if ($catname || $id > 0) { print "\t".'
"; - $categstatic->id=$cat->id; - $categstatic->ref=$cat->label; - $categstatic->label=$cat->label; - $categstatic->type=$cat->type; - $categstatic->color=$cat->color; - print 'color?' style="background: #'.$categstatic->color.';"':' style="background: #aaa"').'>'; + $categstatic->id = $cat->id; + $categstatic->ref = $cat->label; + $categstatic->label = $cat->label; + $categstatic->type = $cat->type; + $categstatic->color = $cat->color; + print 'color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"').'>'; print $categstatic->getNomUrl(1, ''); print ''; print "
'. + 'entry'=>'
color?' style="background: #'.$categstatic->color.';"':' style="background: #aaa"').'>'.$li.'
'. //''. ''. '
color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"').'>'.$li.''.dolGetFirstLineOfText($desc).''.img_view().'
' @@ -182,13 +182,13 @@ foreach($fulltree as $key => $val) print ''; print ''; -$nbofentries=(count($data) - 1); +$nbofentries = (count($data) - 1); if ($nbofentries > 0) { diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php index 3e30164409b..d295daefdd4 100644 --- a/htdocs/collab/index.php +++ b/htdocs/collab/index.php @@ -29,29 +29,29 @@ 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("admin","other","website")); +$langs->loadLangs(array("admin", "other", "website")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$conf->dol_hide_leftmenu = 1; // Force hide of left menu. +$conf->dol_hide_leftmenu = 1; // Force hide of left menu. -$error=0; -$website=GETPOST('website', 'alpha'); -$page=GETPOST('page', 'alpha'); -$pageid=GETPOST('pageid', 'int'); -$action=GETPOST('action', 'alpha'); +$error = 0; +$website = GETPOST('website', 'alpha'); +$page = GETPOST('page', 'alpha'); +$pageid = GETPOST('pageid', 'int'); +$action = GETPOST('action', 'alpha'); -if (GETPOST('delete')) { $action='delete'; } -if (GETPOST('preview')) $action='preview'; -if (GETPOST('create')) { $action='create'; } -if (GETPOST('editmedia')) { $action='editmedia'; } -if (GETPOST('editcss')) { $action='editcss'; } -if (GETPOST('editmenu')) { $action='editmenu'; } -if (GETPOST('setashome')) { $action='setashome'; } -if (GETPOST('editmeta')) { $action='editmeta'; } -if (GETPOST('editcontent')) { $action='editcontent'; } +if (GETPOST('delete')) { $action = 'delete'; } +if (GETPOST('preview')) $action = 'preview'; +if (GETPOST('create')) { $action = 'create'; } +if (GETPOST('editmedia')) { $action = 'editmedia'; } +if (GETPOST('editcss')) { $action = 'editcss'; } +if (GETPOST('editmenu')) { $action = 'editmenu'; } +if (GETPOST('setashome')) { $action = 'setashome'; } +if (GETPOST('editmeta')) { $action = 'editmeta'; } +if (GETPOST('editcontent')) { $action = 'editcontent'; } -if (empty($action)) $action='preview'; +if (empty($action)) $action = 'preview'; @@ -60,8 +60,8 @@ if (empty($action)) $action='preview'; * Actions */ -if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid. -if (GETPOST('refreshpage')) $action='preview'; +if (GETPOST('refreshsite')) $pageid = 0; // If we change the site, we reset the pageid. +if (GETPOST('refreshpage')) $action = 'preview'; // Add a collab page @@ -80,7 +80,7 @@ if ($action == 'add') $error++; } - if (! $error) + if (!$error) { $res = $objectpage->create($user); if ($res <= 0) @@ -89,11 +89,11 @@ if ($action == 'add') setEventMessages($objectpage->error, $objectpage->errors, 'errors'); } } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); - $action=''; + $action = ''; } else { @@ -116,13 +116,13 @@ if ($action == 'delete') if ($res > 0) { $res = $objectpage->delete($user); - if (! $res > 0) + if (!$res > 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs'); @@ -149,7 +149,7 @@ if ($action == 'delete') $form = new Form($db); -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, '', '', '', '', '', ''."\n".'
'); @@ -162,8 +162,8 @@ if ($action == 'create') // Add a margin under toolbar ? -$style=''; -if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;'; +$style = ''; +if ($action != 'preview' && $action != 'editcontent') $style = ' margin-bottom: 5px;'; //var_dump($objectpage);exit; print '
'; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 09c8e344794..24549f4bdfa 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -118,18 +118,18 @@ $listUserAssignedUpdated = false; // Remove user to assigned list if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')) { - $idtoremove=GETPOST('removedassigned'); + $idtoremove = GETPOST('removedassigned'); - if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=json_decode($_SESSION['assignedtouser'], 1); - else $tmpassigneduserids=array(); + if (!empty($_SESSION['assignedtouser'])) $tmpassigneduserids = json_decode($_SESSION['assignedtouser'], 1); + else $tmpassigneduserids = array(); foreach ($tmpassigneduserids as $key => $val) { if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]); } //var_dump($_POST['removedassigned']);exit; - $_SESSION['assignedtouser']=json_encode($tmpassigneduserids); - $donotclearsession=1; + $_SESSION['assignedtouser'] = json_encode($tmpassigneduserids); + $donotclearsession = 1; if ($action == 'add') $action = 'create'; if ($action == 'update') $action = 'edit'; @@ -142,15 +142,15 @@ if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedt // Add a new user if (GETPOST('assignedtouser') > 0) { - $assignedtouser=array(); - if (! empty($_SESSION['assignedtouser'])) + $assignedtouser = array(); + if (!empty($_SESSION['assignedtouser'])) { - $assignedtouser=json_decode($_SESSION['assignedtouser'], true); + $assignedtouser = json_decode($_SESSION['assignedtouser'], true); } - $assignedtouser[GETPOST('assignedtouser')]=array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'), 'mandatory'=>1); - $_SESSION['assignedtouser']=json_encode($assignedtouser); + $assignedtouser[GETPOST('assignedtouser')] = array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'), 'mandatory'=>1); + $_SESSION['assignedtouser'] = json_encode($assignedtouser); } - $donotclearsession=1; + $donotclearsession = 1; if ($action == 'add') $action = 'create'; if ($action == 'update') $action = 'edit'; @@ -168,7 +168,7 @@ if (empty($reshook) && $action == 'classin' && ($user->rights->agenda->allaction // Action clone object if (empty($reshook) && $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'); } @@ -182,7 +182,7 @@ if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') } $result = $object->createFromClone($user, GETPOST('socid', 'int')); if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -195,17 +195,17 @@ if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') // Add event if (empty($reshook) && $action == 'add') { - $error=0; + $error = 0; if (empty($backtopage)) { if ($socid > 0) $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; - else $backtopage=DOL_URL_ROOT.'/comm/action/index.php'; + else $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; } if (!empty($socpeopleassigned[0])) { - $result=$contact->fetch($socpeopleassigned[0]); + $result = $contact->fetch($socpeopleassigned[0]); } if ($cancel) @@ -322,29 +322,29 @@ if (empty($reshook) && $action == 'add') if (GETPOST('socid', 'int') > 0) { - $object->socid=GETPOST('socid', 'int'); + $object->socid = GETPOST('socid', 'int'); $object->fetch_thirdparty(); - $object->societe = $object->thirdparty; // For backward compatibility + $object->societe = $object->thirdparty; // For backward compatibility } // Check parameters if (empty($object->userownerid) && empty($_SESSION['assignedtouser'])) { - $error++; $donotclearsession=1; + $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ActionsOwnedBy")), null, 'errors'); } if ($object->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent)))) { - $error++; $donotclearsession=1; + $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); } - if (! GETPOST('apyear') && ! GETPOST('adyear')) + if (!GETPOST('apyear') && !GETPOST('adyear')) { - $error++; $donotclearsession=1; + $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } @@ -400,16 +400,16 @@ if (empty($reshook) && $action == 'add') // If error $db->rollback(); $langs->load("errors"); - $error=$langs->trans($object->error); + $error = $langs->trans($object->error); setEventMessages($error, null, 'errors'); - $action = 'create'; $donotclearsession=1; + $action = 'create'; $donotclearsession = 1; } } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $action = 'create'; $donotclearsession=1; + $action = 'create'; $donotclearsession = 1; } } } @@ -587,11 +587,11 @@ if (empty($reshook) && $action == 'update') } } - if (! $error) + if (!$error) { $db->begin(); - $result=$object->update($user); + $result = $object->update($user); if ($result > 0) { @@ -607,9 +607,9 @@ if (empty($reshook) && $action == 'update') } } - if (! $error) + if (!$error) { - if (! empty($backtopage)) + if (!empty($backtopage)) { unset($_SESSION['assignedtouser']); header("Location: ".$backtopage); @@ -631,7 +631,7 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) { - $result=$object->delete(); + $result = $object->delete(); if ($result >= 0) { @@ -766,10 +766,10 @@ if (empty($reshook)) { * View */ -$form=new Form($db); -$formproject=new FormProjets($db); +$form = new Form($db); +$formproject = new FormProjets($db); -$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); if ($action == 'create') @@ -779,13 +779,13 @@ if ($action == 'create') $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); if (!empty($socpeopleassigned[0])) { - $result=$contact->fetch($socpeopleassigned[0]); + $result = $contact->fetch($socpeopleassigned[0]); if ($result < 0) dol_print_error($db, $contact->error); } dol_set_focus("#label"); - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\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 ''; @@ -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("Categories").''; -if (! empty($conf->use_javascript_ajax)) +if (!empty($conf->use_javascript_ajax)) { 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/action/peruser.php b/htdocs/comm/action/peruser.php index 3280ddc7af4..54373fcf8a9 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -39,11 +39,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; -$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); +$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); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; $showbirthday = 0; @@ -150,11 +150,11 @@ $hookmanager->initHooks(array('agenda')); * Actions */ -if ($action =='delete_action') +if ($action == 'delete_action') { $event = new ActionComm($db); $event->fetch($actionid); - $result=$event->delete(); + $result = $event->delete(); } @@ -163,21 +163,21 @@ if ($action =='delete_action') * View */ -$form=new Form($db); -$companystatic=new Societe($db); +$form = new Form($db); +$companystatic = new Societe($db); -$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); -$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']; // Define list of all external calendars (global setup) -$listofextcals=array(); +$listofextcals = array(); $prev = dol_get_first_day_week($day, $month, $year); $first_day = $prev['first_day']; @@ -198,31 +198,31 @@ $tmpday = $first_day; //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_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' || $action != 'show_peruser') $param.='&action='.urlencode($action); -if ($begin_h != '') $param.='&begin_h='.urlencode($begin_h); -if ($end_h != '') $param.='&end_h='.urlencode($end_h); -if ($begin_d != '') $param.='&begin_d='.urlencode($begin_d); -if ($end_d != '') $param.='&end_d='.urlencode($end_d); -$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' || $action != 'show_peruser') $param .= '&action='.urlencode($action); +if ($begin_h != '') $param .= '&begin_h='.urlencode($begin_h); +if ($end_h != '') $param .= '&end_h='.urlencode($end_h); +if ($begin_d != '') $param .= '&begin_d='.urlencode($begin_d); +if ($end_d != '') $param .= '&end_d='.urlencode($end_d); +$param .= "&maxprint=".urlencode($maxprint); $prev = dol_get_first_day_week($day, $month, $year); @@ -232,7 +232,7 @@ $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']; @@ -244,10 +244,10 @@ $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); +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); -$nb_weeks_to_show = (! empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7; -$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd'); +$nb_weeks_to_show = (!empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7; +$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd'); //print $firstday.'-'.$first_month.'-'.$first_year; //print dol_print_date($firstdaytoshow,'dayhour'); //print dol_print_date($lastdaytoshow,'dayhour'); @@ -255,13 +255,13 @@ $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $tmpday = $first_day; -$picto='calendarweek'; +$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").")"; +$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").")"; /*$nav.='  
'; $nav.=''; @@ -279,24 +279,24 @@ $nav.=''; $nav.=''; $nav.=''; */ -$nav.= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -$nav.=' '; +$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); +$nav .= ' '; //$nav.='
'; // Must be after the nav definition -$param.='&year='.urlencode($year).'&month='.urlencode($month).($day?'&day='.urlencode($day):''); +$param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($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'; -if ($action == 'show_peruser') $tabactive='cardperuser'; +$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'; +if ($action == 'show_peruser') $tabactive = 'cardperuser'; -$paramnoaction=preg_replace('/action=[a-z_]+/', '', $param); +$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); $head = calendars_prepare_head($paramnoaction); @@ -306,51 +306,51 @@ dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); dol_fiche_end(); -$showextcals=$listofextcals; +$showextcals = $listofextcals; // Legend if ($conf->use_javascript_ajax) { - $s=''; - $s.='' . "\n"; - if (! empty($conf->use_javascript_ajax)) + $s .= '});'."\n"; + $s .= ''."\n"; + if (!empty($conf->use_javascript_ajax)) { - $s.='
' . $langs->trans("LocalAgenda").'  
'; + $s .= '
'.$langs->trans("LocalAgenda").'  
'; if (is_array($showextcals) && count($showextcals) > 0) { foreach ($showextcals as $val) { $htmlname = md5($val['name']); - $s.='' . "\n"; - $s.='
' . $val ['name'] . '  
'; + $s .= ''."\n"; + $s .= '
'.$val ['name'].'  
'; } } //$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) { @@ -555,29 +555,29 @@ if ($resql) else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; - $event->fetch_userassigned(); // This load $event->userassigned + $event->fetch_userassigned(); // This load $event->userassigned - 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); @@ -593,10 +593,10 @@ else dol_print_error($db); } -$maxnbofchar=18; -$cachethirdparties=array(); -$cachecontacts=array(); -$cacheusers=array(); +$maxnbofchar = 18; +$cachethirdparties = array(); +$cachecontacts = array(); +$cacheusers = array(); // Define theme_datacolor array $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; @@ -604,23 +604,23 @@ 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)); -$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'; echo ''; echo ''; -echo '' ; +echo ''; // Line header with list of days @@ -644,7 +644,7 @@ while($currentdaytoshow<$lastdaytoshow) { continue; } echo '
'; - 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 ''; // 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 ''; @@ -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 ""; // Project status print ''; - $projectstatic->statut=$lines[$i]->projectstatus; + $projectstatic->statut = $lines[$i]->projectstatus; print $projectstatic->getLibStatut(2); print ""; } @@ -494,7 +494,7 @@ 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 '
    '; } @@ -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 ''; @@ -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/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 '