From f413ce6aacc02468576500c53df58d6a3a13016d Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Thu, 12 Mar 2020 11:45:44 +0000 Subject: [PATCH 1/2] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/accountancy/admin/defaultaccounts.php | 22 +- htdocs/accountancy/admin/productaccount.php | 210 +++--- htdocs/accountancy/bookkeeping/list.php | 28 +- htdocs/accountancy/supplier/list.php | 6 +- htdocs/adherents/class/adherent.class.php | 460 ++++++------- htdocs/admin/ihm.php | 120 ++-- .../comm/propal/class/api_proposals.class.php | 170 ++--- htdocs/comm/propal/class/propal.class.php | 6 +- .../comm/propal/class/propalestats.class.php | 112 ++-- htdocs/comm/propal/list.php | 14 +- htdocs/commande/class/api_orders.class.php | 160 ++--- htdocs/commande/class/commande.class.php | 4 +- htdocs/commande/class/commandestats.class.php | 96 +-- htdocs/commande/list.php | 6 +- htdocs/compta/accounting-files.php | 24 +- htdocs/compta/bank/list.php | 124 ++-- htdocs/compta/deplacement/index.php | 68 +- htdocs/compta/facture/card.php | 8 +- htdocs/compta/facture/class/facture.class.php | 16 +- .../facture/class/facturestats.class.php | 104 +-- htdocs/compta/facture/list.php | 6 +- htdocs/core/actions_extrafields.inc.php | 176 ++--- .../boxes/box_graph_product_distribution.php | 6 +- htdocs/core/class/canvas.class.php | 30 +- .../core/class/commondocgenerator.class.php | 266 ++++---- htdocs/core/class/conf.class.php | 2 +- htdocs/core/class/dolgraph.class.php | 62 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formother.class.php | 102 +-- htdocs/core/class/stats.class.php | 206 +++--- htdocs/core/customreports.php | 42 +- htdocs/core/lib/functions.lib.php | 8 +- htdocs/core/lib/security.lib.php | 4 +- htdocs/core/lib/website.lib.php | 212 +++--- htdocs/core/lib/website2.lib.php | 2 +- htdocs/core/modules/modProduct.class.php | 288 ++++---- htdocs/core/modules/modService.class.php | 288 ++++---- htdocs/core/tpl/admin_extrafields_add.tpl.php | 22 +- .../core/tpl/admin_extrafields_edit.tpl.php | 74 +-- .../core/tpl/admin_extrafields_view.tpl.php | 18 +- htdocs/core/tpl/contacts.tpl.php | 32 +- htdocs/core/tpl/extrafields_add.tpl.php | 4 +- htdocs/core/tpl/extrafields_edit.tpl.php | 8 +- htdocs/core/tpl/objectline_create.tpl.php | 4 +- .../interface_20_all_Logevents.class.php | 80 +-- ...terface_50_modAgenda_ActionsAuto.class.php | 620 +++++++++--------- htdocs/don/list.php | 72 +- .../class/emailcollector.class.php | 30 +- htdocs/expedition/class/expedition.class.php | 304 ++++----- htdocs/expensereport/payment/payment.php | 70 +- htdocs/fichinter/class/fichinter.class.php | 4 +- .../fichinter/class/fichinterstats.class.php | 82 +-- htdocs/fourn/commande/list.php | 92 +-- htdocs/fourn/facture/list.php | 174 ++--- .../template/class/myobject.class.php | 18 +- htdocs/mrp/index.php | 46 +- htdocs/product/class/product.class.php | 2 +- htdocs/product/stats/commande.php | 122 ++-- htdocs/product/stats/facture.php | 134 ++-- .../canvas/actions_card_common.class.php | 224 +++---- htdocs/societe/class/societe.class.php | 8 +- htdocs/supplier_proposal/list.php | 108 +-- htdocs/takepos/admin/setup.php | 2 +- htdocs/takepos/admin/terminal.php | 12 +- htdocs/takepos/invoice.php | 40 +- htdocs/takepos/pay.php | 38 +- htdocs/takepos/reduction.php | 2 +- htdocs/takepos/takepos.php | 6 +- .../website/migrate_news_joomla2dolibarr.php | 12 +- 69 files changed, 2962 insertions(+), 2962 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 43dc3ccea67..ad22a88f415 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -46,13 +46,13 @@ if (empty($user->rights->accounting->chartofaccount)) $action = GETPOST('action', 'aZ09'); -$list_account_main = array ( +$list_account_main = array( 'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_SUPPLIER', 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', ); -$list_account = array (); +$list_account = array(); $list_account[] = '---Product---'; $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT'; if ($mysoc->isInEEC()) { @@ -120,25 +120,25 @@ if ($action == 'update') { foreach ($list_account_main as $constname) { $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; } } foreach ($list_account as $constname) { - $reg=array(); + $reg = array(); if (preg_match('/---(.*)---/', $constname, $reg)) { // This is a separator continue; } $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; } } - if (! $error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -190,7 +190,7 @@ foreach ($list_account_main as $key) { foreach ($list_account as $key) { - $reg=array(); + $reg = array(); if (preg_match('/---(.*)---/', $key, $reg)) { print ''.$langs->trans($reg[1]).''; } @@ -198,9 +198,9 @@ foreach ($list_account as $key) { print ''; // Param $label = $langs->trans($key); - print '' . $label . ''; + print ''.$label.''; // Value - print ''; // Do not force class=right, or it align also the content of the select box + print ''; // Do not force class=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print ''; print ''; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 6946f8df831..fb909ecb7ad 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -59,7 +59,7 @@ $search_label = GETPOST('search_label', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha'); $search_current_account = GETPOST('search_current_account', 'alpha'); $search_current_account_valid = GETPOST('search_current_account_valid', 'alpha'); -if ($search_current_account_valid == '') $search_current_account_valid='withoutvalidaccount'; +if ($search_current_account_valid == '') $search_current_account_valid = 'withoutvalidaccount'; $search_onsell = GETPOST('search_onsell', 'alpha'); $search_onpurchase = GETPOST('search_onpurchase', 'alpha'); @@ -67,9 +67,9 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $btn_changeaccount = GETPOST('changeaccount', 'alpha'); $btn_changetype = GETPOST('changetype', 'alpha'); -if (empty($accounting_product_mode)) $accounting_product_mode='ACCOUNTANCY_SELL'; +if (empty($accounting_product_mode)) $accounting_product_mode = 'ACCOUNTANCY_SELL'; -$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'); @@ -224,56 +224,56 @@ $aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_P $aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT, 1); $aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1); -$aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servbuy_intra = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servbuy_export = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy_intra = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy_export = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell_intra = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell_export = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell_intra = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell_export = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy_intra = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy_export = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy_export = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servsell_intra = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servsell_export = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodsell_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodsell_export = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); llxHeader('', $langs->trans("ProductsBinding")); $pcgverid = $conf->global->CHARTOFACCOUNTS; $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); -if (empty($pcgvercode)) $pcgvercode=$pcgverid; +if (empty($pcgvercode)) $pcgvercode = $pcgverid; $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy,"; -$sql.= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; -$sql.= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; -$sql.= " p.tms, p.fk_product_type as product_type,"; -$sql.= " aa.rowid as aaid"; -$sql.= " FROM " . MAIN_DB_PREFIX . "product as p"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; +$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; +$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +$sql .= " p.tms, p.fk_product_type as product_type,"; +$sql .= " aa.rowid as aaid"; +$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $sql.=" p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $sql.=" p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $sql.=" p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $sql.=" p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } else { - $sql.=" p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } -$sql.= ' WHERE p.entity IN ('.getEntity('product').')'; +$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_buy", $search_current_account); @@ -319,8 +319,8 @@ if (strlen(trim($search_label))) { if (strlen(trim($search_desc))) { $sql .= natural_search("p.description", $search_desc); } -if ($search_onsell != '' && $search_onsell != '-1') $sql.= natural_search('p.tosell', $search_onsell, 1); -if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql.= natural_search('p.tobuy', $search_onpurchase, 1); +if ($search_onsell != '' && $search_onsell != '-1') $sql .= natural_search('p.tosell', $search_onsell, 1); +if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql .= natural_search('p.tobuy', $search_onpurchase, 1); $sql .= $db->order($sortfield, $sortorder); @@ -367,60 +367,60 @@ if ($result) print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); print '
'; - print ''.$langs->trans("InitAccountancyDesc") . '
'; + print ''.$langs->trans("InitAccountancyDesc").'
'; print '
'; // Select mode print ''; print ''; - print ''; + print ''; print "\n"; - print ''; + print ''; print '\n"; if ($mysoc->isInEEC()) { - print ''; + print ''; print '\n"; } - print ''; + print ''; print '\n"; - print ''; + print ''; print '\n"; if ($mysoc->isInEEC()) { - print ''; - print '\n"; + print ''; + print '\n"; } - print ''; + print ''; print '\n"; print "
' . $langs->trans('Options') . '' . $langs->trans('Description') . ''.$langs->trans('Options').''.$langs->trans('Description').'
' . $langs->trans('OptionModeProductSell') . '
'.$langs->trans('OptionModeProductSell').''.$langs->trans('OptionModeProductSellDesc'); print "
' . $langs->trans('OptionModeProductSellIntra') . '
'.$langs->trans('OptionModeProductSellIntra').''.$langs->trans('OptionModeProductSellIntraDesc'); print "
' . $langs->trans('OptionModeProductSellExport') . '
'.$langs->trans('OptionModeProductSellExport').''.$langs->trans('OptionModeProductSellExportDesc'); print "
' . $langs->trans('OptionModeProductBuy') . '
'.$langs->trans('OptionModeProductBuy').''.$langs->trans('OptionModeProductBuyDesc')."
' . $langs->trans('OptionModeProductBuyIntra') . '' . $langs->trans('OptionModeProductBuyDesc') . "
'.$langs->trans('OptionModeProductBuyIntra').''.$langs->trans('OptionModeProductBuyDesc')."
' . $langs->trans('OptionModeProductBuyExport') . '
'.$langs->trans('OptionModeProductBuyExport').''.$langs->trans('OptionModeProductBuyDesc')."
\n"; - print '
'; + print '
'; print "
\n"; // Filter on categories - $moreforfilter=''; - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $moreforfilter = ''; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $buttonsave = ''; + $buttonsave = ''; //print '
'.$buttonsave.'
'; - $texte=$langs->trans("ListOfProductsServices"); + $texte = $langs->trans("ListOfProductsServices"); print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit); print '
'; - print ''; + print '
'; print ''; - print ''; - print ''; - if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print ''; + print ''; + print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print ''; // On sell if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { print ''; @@ -431,13 +431,13 @@ if ($result) } // Current account print ''; print ''; print ''; print ''; @@ -445,36 +445,36 @@ if ($result) print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); - if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); // On sell / On purchase if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_sell"; + $fieldtosortaccount = "p.accountancy_code_sell"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_sell_intra"; + $fieldtosortaccount = "p.accountancy_code_sell_intra"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_sell_export"; + $fieldtosortaccount = "p.accountancy_code_sell_export"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_buy"; + $fieldtosortaccount = "p.accountancy_code_buy"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_buy_intra"; + $fieldtosortaccount = "p.accountancy_code_buy_intra"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_buy_export"; + $fieldtosortaccount = "p.accountancy_code_buy_export"; } print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); - $clickpitco=$form->showCheckAddButtons('checkforselect', 1); + $clickpitco = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center '); print ''; $product_static = new Product($db); - $i=0; + $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); @@ -491,37 +491,37 @@ if ($result) // Sales if ($obj->product_type == 0) { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell_export; } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } } else { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell_export; } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell; } } @@ -529,37 +529,37 @@ if ($result) // Purchases if ($obj->product_type == 0) { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy_export; } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy; } } else { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy_export; } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy; } } @@ -611,72 +611,72 @@ if ($result) print ''; // New account to set - $defaultvalue=''; + $defaultvalue = ''; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { // Accounting account buy print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { // Accounting account buy intra (In EEC) print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { // Accounting account buy export (Out of EEC) print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { // Accounting account sell print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { // Accounting account sell intra (In EEC) print ''; } else { // Accounting account sell export (Out of EEC) print ''; } // Checkbox select print ''; + print ''; print ""; - $i ++; + $i++; } print '
'.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).''; - print ''; - $listofvals=array('withoutvalidaccount'=>$langs->trans("WithoutValidAccount"), 'withvalidaccount'=>$langs->trans("WithValidAccount")); + print ''; + $listofvals = array('withoutvalidaccount'=>$langs->trans("WithoutValidAccount"), 'withvalidaccount'=>$langs->trans("WithValidAccount")); print ' '.$langs->trans("or").' '.$form->selectarray('search_current_account_valid', $listofvals, $search_current_account_valid, 1); print ' '; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy; - $codesell=length_accountg($obj->accountancy_code_buy); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; + $codesell = length_accountg($obj->accountancy_code_buy); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy_intra; - $codesell=length_accountg($obj->accountancy_code_buy_intra); + if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy_intra; + $codesell = length_accountg($obj->accountancy_code_buy_intra); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy_export; - $codesell=length_accountg($obj->accountancy_code_buy_export); + if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy_export; + $codesell = length_accountg($obj->accountancy_code_buy_export); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodsell; - $codesell=length_accountg($obj->accountancy_code_sell); + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodsell; - $codesell=length_accountg($obj->accountancy_code_sell_intra); + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_intra); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodsell; - $codesell=length_accountg($obj->accountancy_code_sell_export); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_export); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; - print '
'; print '
'; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 9b6ad2fbbb0..4b0337c7848 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -204,7 +204,7 @@ if (empty($reshook)) $search_debit = ''; $search_credit = ''; $search_lettering_code = ''; - $search_not_reconciled=''; + $search_not_reconciled = ''; } // Must be after the remove filter action, before the export. @@ -276,32 +276,32 @@ if (empty($reshook)) if (!empty($search_date_creation_start)) { $filter['t.date_creation>='] = $search_date_creation_start; $tmp = dol_getdate($search_date_creation_start); - $param .= '&date_creation_startmonth=' . urlencode($tmp['mon']) . '&date_creation_startday=' . urlencode($tmp['mday']) . '&date_creation_startyear=' . urlencode($tmp['year']); + $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']); } if (!empty($search_date_creation_end)) { $filter['t.date_creation<='] = $search_date_creation_end; $tmp = dol_getdate($search_date_creation_end); - $param .= '&date_creation_endmonth=' .urlencode($tmp['mon']) . '&date_creation_endday=' . urlencode($tmp['mday']) . '&date_creation_endyear=' . urlencode($tmp['year']); + $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']); } if (!empty($search_date_modification_start)) { $filter['t.tms>='] = $search_date_modification_start; $tmp = dol_getdate($search_date_modification_start); - $param .= '&date_modification_startmonth=' . urlencode($tmp['mon']) . '&date_modification_startday=' . urlencode($tmp['mday']) . '&date_modification_startyear=' . urlencode($tmp['year']); + $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']); } if (!empty($search_date_modification_end)) { $filter['t.tms<='] = $search_date_modification_end; $tmp = dol_getdate($search_date_modification_end); - $param .= '&date_modification_endmonth=' . urlencode($tmp['mon']) . '&date_modification_endday=' . urlencode($tmp['mday']) . '&date_modification_endyear=' . urlencode($tmp['year']); + $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']); } if (!empty($search_date_export_start)) { $filter['t.date_export>='] = $search_date_export_start; $tmp = dol_getdate($search_date_export_start); - $param .= '&date_export_startmonth=' . urlencode($tmp['mon']) . '&date_export_startday=' . urlencode($tmp['mday']) . '&date_export_startyear=' . urlencode($tmp['year']); + $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']); } if (!empty($search_date_export_end)) { $filter['t.date_export<='] = $search_date_export_end; $tmp = dol_getdate($search_date_export_end); - $param .= '&date_export_endmonth=' . urlencode($tmp['mon']) . '&date_export_endday=' . urlencode($tmp['mday']) . '&date_export_endyear=' . urlencode($tmp['year']); + $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; @@ -315,9 +315,9 @@ if (empty($reshook)) $filter['t.lettering_code'] = $search_lettering_code; $param .= '&search_lettering_code='.urlencode($search_lettering_code); } - if (! empty($search_not_reconciled)) { + if (!empty($search_not_reconciled)) { $filter['t.reconciled_option'] = $search_not_reconciled; - $param .= '&search_not_reconciled=' . urlencode($search_not_reconciled); + $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); } } @@ -768,7 +768,7 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) { print ''; print ''; - print '
'.$langs->trans("NotReconciled").''; + print '
'.$langs->trans("NotReconciled").''; print ''; } // Code journal @@ -953,9 +953,9 @@ while ($i < min($num, $limit)) $objectstatic->fetch($line->fk_doc); //$modulepart = 'expensereport'; - $filename=dol_sanitizeFileName($line->doc_ref); - $filedir=$conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); } else @@ -969,7 +969,7 @@ while ($i < min($num, $limit)) // Picto + Ref print ''; - if($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') + if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $documentlink; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 2c8ad2432a3..bcc042d8c71 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -480,7 +480,7 @@ if ($result) { } } - if (! empty($objp->code_buy_p)) { + if (!empty($objp->code_buy_p)) { // Value was defined previously } else { $code_buy_p_notset = 'color:orange'; @@ -561,7 +561,7 @@ if ($result) { // Suggested accounting account print ''; $suggestedid = $objp->aarowid_suggest; - if (empty($suggestedid) && empty($objp->code_buy_p) && ! empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) + if (empty($suggestedid) && empty($objp->code_buy_p) && !empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) { if (empty($accountingaccount_codetotid_cache[$objp->code_buy_l])) { @@ -597,7 +597,7 @@ if ($result) { print $db->error(); } if ($db->type == 'mysqli') { - $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation + $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation } // Add code to auto check the box when we select an account diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index a14cdec8fff..fa8ae9fc2f3 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -32,9 +32,9 @@ * \ingroup member * \brief File of class to manage members of a foundation */ -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; /** @@ -341,7 +341,7 @@ class Adherent extends CommonObject if (dol_textishtml($text, 0)) $msgishtml = 1; } - dol_syslog('send_an_email msgishtml=' . $msgishtml); + dol_syslog('send_an_email msgishtml='.$msgishtml); $texttosend = $this->makeSubstitution($text); $subjecttosend = $this->makeSubstitution($subject); @@ -351,15 +351,15 @@ class Adherent extends CommonObject $from = $conf->email_from; if (!empty($conf->global->ADHERENT_MAIL_FROM)) $from = $conf->global->ADHERENT_MAIL_FROM; - $trackid = 'mem' . $this->id; + $trackid = 'mem'.$this->id; // Send email (substitutionarray must be done just before this) - include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, '', '', $trackid, $moreinheader); if ($mailfile->sendfile()) { return 1; } else { - $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email) . '. ' . $mailfile->error; + $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email).'. '.$mailfile->error; return -1; } } @@ -381,26 +381,26 @@ class Adherent extends CommonObject if (dol_textishtml($text, 1)) $msgishtml = 1; $infos = ''; - if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle") . ": " . $this->getCivilityLabel() . "\n"; - $infos .= $langs->transnoentities("id") . ": " . $this->id . "\n"; - $infos .= $langs->transnoentities("Lastname") . ": " . $this->lastname . "\n"; - $infos .= $langs->transnoentities("Firstname") . ": " . $this->firstname . "\n"; - $infos .= $langs->transnoentities("Company") . ": " . $this->company . "\n"; - $infos .= $langs->transnoentities("Address") . ": " . $this->address . "\n"; - $infos .= $langs->transnoentities("Zip") . ": " . $this->zip . "\n"; - $infos .= $langs->transnoentities("Town") . ": " . $this->town . "\n"; - $infos .= $langs->transnoentities("Country") . ": " . $this->country . "\n"; - $infos .= $langs->transnoentities("EMail") . ": " . $this->email . "\n"; - $infos .= $langs->transnoentities("PhonePro") . ": " . $this->phone . "\n"; - $infos .= $langs->transnoentities("PhonePerso") . ": " . $this->phone_perso . "\n"; - $infos .= $langs->transnoentities("PhoneMobile") . ": " . $this->phone_mobile . "\n"; + if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n"; + $infos .= $langs->transnoentities("id").": ".$this->id."\n"; + $infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; + $infos .= $langs->transnoentities("Firstname").": ".$this->firstname."\n"; + $infos .= $langs->transnoentities("Company").": ".$this->company."\n"; + $infos .= $langs->transnoentities("Address").": ".$this->address."\n"; + $infos .= $langs->transnoentities("Zip").": ".$this->zip."\n"; + $infos .= $langs->transnoentities("Town").": ".$this->town."\n"; + $infos .= $langs->transnoentities("Country").": ".$this->country."\n"; + $infos .= $langs->transnoentities("EMail").": ".$this->email."\n"; + $infos .= $langs->transnoentities("PhonePro").": ".$this->phone."\n"; + $infos .= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n"; + $infos .= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n"; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $infos .= $langs->transnoentities("Login") . ": " . $this->login . "\n"; - $infos .= $langs->transnoentities("Password") . ": " . $this->pass . "\n"; + $infos .= $langs->transnoentities("Login").": ".$this->login."\n"; + $infos .= $langs->transnoentities("Password").": ".$this->pass."\n"; } - $infos .= $langs->transnoentities("Birthday") . ": " . $birthday . "\n"; - $infos .= $langs->transnoentities("Photo") . ": " . $this->photo . "\n"; - $infos .= $langs->transnoentities("Public") . ": " . yn($this->public); + $infos .= $langs->transnoentities("Birthday").": ".$birthday."\n"; + $infos .= $langs->transnoentities("Photo").": ".$this->photo."\n"; + $infos .= $langs->transnoentities("Public").": ".yn($this->public); // Substitutions $substitutionarray = array('__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(), @@ -481,22 +481,22 @@ class Adherent extends CommonObject $this->db->begin(); // Insert member - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "adherent"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent"; $sql .= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)"; $sql .= " VALUES ("; - $sql .= " '" . $this->db->idate($this->datec) . "'"; - $sql .= ", " . ($this->login ? "'" . $this->db->escape($this->login) . "'" : "null"); - $sql .= ", " . ($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script - $sql .= ", null, null, '" . $this->db->escape($this->morphy) . "'"; - $sql .= ", " . $this->typeid; - $sql .= ", " . $conf->entity; - $sql .= ", " . (!empty($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null"); + $sql .= " '".$this->db->idate($this->datec)."'"; + $sql .= ", ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); + $sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script + $sql .= ", null, null, '".$this->db->escape($this->morphy)."'"; + $sql .= ", ".$this->typeid; + $sql .= ", ".$conf->entity; + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ")"; - dol_syslog(get_class($this) . "::create", LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "adherent"); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); if ($id > 0) { $this->id = $id; $this->ref = (string) $id; @@ -511,10 +511,10 @@ class Adherent extends CommonObject // Add link to user if ($this->user_id) { // Add link to user - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET"; - $sql .= " fk_member = " . $this->id; - $sql .= " WHERE rowid = " . $this->user_id; - dol_syslog(get_class($this) . "::create", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; + $sql .= " fk_member = ".$this->id; + $sql .= " WHERE rowid = ".$this->user_id; + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = 'Failed to update user to make link with member'; @@ -533,7 +533,7 @@ class Adherent extends CommonObject } if (count($this->errors)) { - dol_syslog(get_class($this) . "::create " . implode(',', $this->errors), LOG_ERR); + dol_syslog(get_class($this)."::create ".implode(',', $this->errors), LOG_ERR); $this->db->rollback(); return -3; } else { @@ -542,7 +542,7 @@ class Adherent extends CommonObject } } else { $this->error = 'Failed to get last insert id'; - dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); $this->db->rollback(); return -2; } @@ -572,7 +572,7 @@ class Adherent extends CommonObject $nbrowsaffected = 0; $error = 0; - dol_syslog(get_class($this) . "::update notrigger=" . $notrigger . ", nosyncuser=" . $nosyncuser . ", nosyncuserpass=" . $nosyncuserpass . " nosyncthirdparty=" . $nosyncthirdparty . ", email=" . + dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=". $this->email); // Clean parameters @@ -598,43 +598,43 @@ class Adherent extends CommonObject $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; - $sql .= " civility = " . ($this->civility_id ? "'" . $this->db->escape($this->civility_id) . "'" : "null"); - $sql .= ", firstname = " . ($this->firstname ? "'" . $this->db->escape($this->firstname) . "'" : "null"); - $sql .= ", lastname = " . ($this->lastname ? "'" . $this->db->escape($this->lastname) . "'" : "null"); - $sql .= ", gender = " . ($this->gender != -1 ? "'" . $this->db->escape($this->gender) . "'" : "null"); // 'man' or 'woman' - $sql .= ", login = " . ($this->login ? "'" . $this->db->escape($this->login) . "'" : "null"); - $sql .= ", societe = " . ($this->company ? "'" . $this->db->escape($this->company) . "'" : ($this->societe ? "'" . $this->db->escape($this->societe) . "'" : "null")); - $sql .= ", fk_soc = " . ($this->socid > 0 ? $this->db->escape($this->socid) : "null"); - $sql .= ", address = " . ($this->address ? "'" . $this->db->escape($this->address) . "'" : "null"); - $sql .= ", zip = " . ($this->zip ? "'" . $this->db->escape($this->zip) . "'" : "null"); - $sql .= ", town = " . ($this->town ? "'" . $this->db->escape($this->town) . "'" : "null"); - $sql .= ", country = " . ($this->country_id > 0 ? $this->db->escape($this->country_id) : "null"); - $sql .= ", state_id = " . ($this->state_id > 0 ? $this->db->escape($this->state_id) : "null"); - $sql .= ", email = '" . $this->db->escape($this->email) . "'"; - $sql .= ", socialnetworks = '" . $this->db->escape(json_encode($this->socialnetworks)) . "'"; - $sql .= ", phone = " . ($this->phone ? "'" . $this->db->escape($this->phone) . "'" : "null"); - $sql .= ", phone_perso = " . ($this->phone_perso ? "'" . $this->db->escape($this->phone_perso) . "'" : "null"); - $sql .= ", phone_mobile = " . ($this->phone_mobile ? "'" . $this->db->escape($this->phone_mobile) . "'" : "null"); - $sql .= ", note_private = " . ($this->note_private ? "'" . $this->db->escape($this->note_private) . "'" : "null"); - $sql .= ", note_public = " . ($this->note_public ? "'" . $this->db->escape($this->note_public) . "'" : "null"); - $sql .= ", photo = " . ($this->photo ? "'" . $this->db->escape($this->photo) . "'" : "null"); - $sql .= ", public = '" . $this->db->escape($this->public) . "'"; - $sql .= ", statut = " . $this->db->escape($this->statut); - $sql .= ", fk_adherent_type = " . $this->db->escape($this->typeid); - $sql .= ", morphy = '" . $this->db->escape($this->morphy) . "'"; - $sql .= ", birth = " . ($this->birth ? "'" . $this->db->idate($this->birth) . "'" : "null"); - if ($this->socid) $sql .= ", fk_soc = '" . $this->db->escape($this->socid) . "'"; // Must be modified only when creating from a third-party - if ($this->datefin) $sql .= ", datefin = '" . $this->db->idate($this->datefin) . "'"; // Must be modified only when deleting a subscription - if ($this->datevalid) $sql .= ", datevalid = '" . $this->db->idate($this->datevalid) . "'"; // Must be modified only when validating a member - $sql .= ", fk_user_mod = " . ($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; + $sql .= " civility = ".($this->civility_id ? "'".$this->db->escape($this->civility_id)."'" : "null"); + $sql .= ", firstname = ".($this->firstname ? "'".$this->db->escape($this->firstname)."'" : "null"); + $sql .= ", lastname = ".($this->lastname ? "'".$this->db->escape($this->lastname)."'" : "null"); + $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' + $sql .= ", login = ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); + $sql .= ", societe = ".($this->company ? "'".$this->db->escape($this->company)."'" : ($this->societe ? "'".$this->db->escape($this->societe)."'" : "null")); + $sql .= ", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) : "null"); + $sql .= ", address = ".($this->address ? "'".$this->db->escape($this->address)."'" : "null"); + $sql .= ", zip = ".($this->zip ? "'".$this->db->escape($this->zip)."'" : "null"); + $sql .= ", town = ".($this->town ? "'".$this->db->escape($this->town)."'" : "null"); + $sql .= ", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) : "null"); + $sql .= ", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) : "null"); + $sql .= ", email = '".$this->db->escape($this->email)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", phone = ".($this->phone ? "'".$this->db->escape($this->phone)."'" : "null"); + $sql .= ", phone_perso = ".($this->phone_perso ? "'".$this->db->escape($this->phone_perso)."'" : "null"); + $sql .= ", phone_mobile = ".($this->phone_mobile ? "'".$this->db->escape($this->phone_mobile)."'" : "null"); + $sql .= ", note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); + $sql .= ", public = '".$this->db->escape($this->public)."'"; + $sql .= ", statut = ".$this->db->escape($this->statut); + $sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid); + $sql .= ", morphy = '".$this->db->escape($this->morphy)."'"; + $sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null"); + if ($this->socid) $sql .= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party + if ($this->datefin) $sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription + if ($this->datevalid) $sql .= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member + $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest + $sql .= " WHERE rowid = ".$this->id; // If we change the type of membership, we set also label of new type if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { $sql2 = "SELECT libelle as label"; - $sql2 .= " FROM " . MAIN_DB_PREFIX . "adherent_type"; - $sql2 .= " WHERE rowid = " . $this->typeid; + $sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql2 .= " WHERE rowid = ".$this->typeid; $resql2 = $this->db->query($sql2); if ($resql2) { while ($obj = $this->db->fetch_object($resql2)) { @@ -643,7 +643,7 @@ class Adherent extends CommonObject } } - dol_syslog(get_class($this) . "::update update member", LOG_DEBUG); + dol_syslog(get_class($this)."::update update member", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { unset($this->country_code); @@ -666,7 +666,7 @@ class Adherent extends CommonObject // Update password if (!$error && $this->pass) { - dol_syslog(get_class($this) . "::update update password"); + dol_syslog(get_class($this)."::update update password"); if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) { $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1; @@ -678,9 +678,9 @@ class Adherent extends CommonObject // Remove links to user and replace with new one if (!$error) { - dol_syslog(get_class($this) . "::update update link to user"); - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL WHERE fk_member = " . $this->id; - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update update link to user"); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id; + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); @@ -689,8 +689,8 @@ class Adherent extends CommonObject } // If there is a user linked to this member if ($this->user_id > 0) { - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = " . $this->id . " WHERE rowid = " . $this->user_id; - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id." WHERE rowid = ".$this->user_id; + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); @@ -704,9 +704,9 @@ class Adherent extends CommonObject { // Update information on linked user if it is an update if (!$error && $this->user_id > 0 && !$nosyncuser) { - require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - dol_syslog(get_class($this) . "::update update linked user"); + dol_syslog(get_class($this)."::update update linked user"); $luser = new User($this->db); $result = $luser->fetch($this->user_id); @@ -743,7 +743,7 @@ class Adherent extends CommonObject $result = $luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates if ($result < 0) { $this->error = $luser->error; - dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); $error++; } } else { @@ -754,9 +754,9 @@ class Adherent extends CommonObject // Update information on linked thirdparty if it is an update if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - dol_syslog(get_class($this) . "::update update linked thirdparty"); + dol_syslog(get_class($this)."::update update linked thirdparty"); // This member is linked with a thirdparty, so we also update thirdparty informations // if this is an update. @@ -779,7 +779,7 @@ class Adherent extends CommonObject if ($result < 0) { $this->error = $lthirdparty->error; $this->errors = $lthirdparty->errors; - dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); $error++; } } elseif ($result < 0) { @@ -828,11 +828,11 @@ class Adherent extends CommonObject // Search for last subscription id and end date $sql = "SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin"; - $sql .= " FROM " . MAIN_DB_PREFIX . "subscription"; - $sql .= " WHERE fk_adherent=" . $this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; + $sql .= " WHERE fk_adherent=".$this->id; $sql .= " ORDER by dateadh DESC"; // Sort by start subscription date - dol_syslog(get_class($this) . "::update_end_date", LOG_DEBUG); + dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -840,11 +840,11 @@ class Adherent extends CommonObject $datedeb = $this->db->jdate($obj->datedeb); $datefin = $this->db->jdate($obj->datefin); - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; - $sql .= " datefin=" . ($datefin != '' ? "'" . $this->db->idate($datefin) . "'" : "null"); - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; + $sql .= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null"); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this) . "::update_end_date", LOG_DEBUG); + dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->last_subscription_date = $dateop; @@ -893,8 +893,8 @@ class Adherent extends CommonObject } // Remove category - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_member WHERE fk_member = " . $rowid; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -904,8 +904,8 @@ class Adherent extends CommonObject // Remove subscription if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "subscription WHERE fk_adherent = " . $rowid; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -932,15 +932,15 @@ class Adherent extends CommonObject if ($result < 0) { $error++; $errorflag = -4; - dol_syslog(get_class($this) . "::delete erreur " . $errorflag . " " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); } } } // Remove adherent if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "adherent WHERE rowid = " . $rowid; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -975,11 +975,11 @@ class Adherent extends CommonObject $error = 0; - dol_syslog(get_class($this) . "::setPassword user=" . $user->id . " password=" . preg_replace('/./i', '*', $password) . " isencrypted=" . $isencrypted); + dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted); // If new password not provided, we generate one if (!$password) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $password = getRandomPassword(false); } @@ -994,18 +994,18 @@ class Adherent extends CommonObject $this->db->begin(); // Mise a jour - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent"; - $sql .= " SET pass_crypted = '" . $this->db->escape($password_crypted) . "'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; + $sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."'"; //if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) if ($isencrypted) { $sql .= ", pass = null"; } else { - $sql .= ", pass = '" . $this->db->escape($password_indatabase) . "'"; + $sql .= ", pass = '".$this->db->escape($password_indatabase)."'"; } - $sql .= " WHERE rowid = " . $this->id; + $sql .= " WHERE rowid = ".$this->id; //dol_syslog("Adherent::Password sql=hidden"); - dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG); + dol_syslog(get_class($this)."::setPassword", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $nbaffectedrows = $this->db->affected_rows($result); @@ -1016,7 +1016,7 @@ class Adherent extends CommonObject $this->pass_indatabase_crypted = $password_crypted; if ($this->user_id && !$nosyncuser) { - require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // This member is linked with a user, so we also update users informations // if this is an update. @@ -1027,7 +1027,7 @@ class Adherent extends CommonObject $result = $luser->setPassword($user, $this->pass, 0, 0, 1); if ($result < 0) { $this->error = $luser->error; - dol_syslog(get_class($this) . "::setPassword " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR); $error++; } } else { @@ -1074,8 +1074,8 @@ class Adherent extends CommonObject $this->db->begin(); // If user is linked to this member, remove old link to this member - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL WHERE fk_member = " . $this->id; - dol_syslog(get_class($this) . "::setUserId", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id; + dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); @@ -1085,9 +1085,9 @@ class Adherent extends CommonObject // Set link to user if ($userid > 0) { - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = " . $this->id; - $sql .= " WHERE rowid = " . $userid; - dol_syslog(get_class($this) . "::setUserId", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id; + $sql .= " WHERE rowid = ".$userid; + dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); @@ -1116,18 +1116,18 @@ class Adherent extends CommonObject // Remove link to third party onto any other members if ($thirdpartyid > 0) { - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET fk_soc = null"; - $sql .= " WHERE fk_soc = '" . $thirdpartyid . "'"; - $sql .= " AND entity = " . $conf->entity; - dol_syslog(get_class($this) . "::setThirdPartyId", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = null"; + $sql .= " WHERE fk_soc = '".$thirdpartyid."'"; + $sql .= " AND entity = ".$conf->entity; + dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG); $resql = $this->db->query($sql); } // Add link to third party for current member - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET fk_soc = " . ($thirdpartyid > 0 ? $thirdpartyid : 'null'); - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid : 'null'); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this) . "::setThirdPartyId", LOG_DEBUG); + dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -1152,9 +1152,9 @@ class Adherent extends CommonObject // phpcs:enable global $conf; - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent"; - $sql .= " WHERE login='" . $this->db->escape($login) . "'"; - $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; + $sql .= " WHERE login='".$this->db->escape($login)."'"; + $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { @@ -1180,10 +1180,10 @@ class Adherent extends CommonObject // phpcs:enable global $conf; - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent"; - $sql .= " WHERE firstname='" . $this->db->escape($firstname) . "'"; - $sql .= " AND lastname='" . $this->db->escape($lastname) . "'"; - $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; + $sql .= " WHERE firstname='".$this->db->escape($firstname)."'"; + $sql .= " AND lastname='".$this->db->escape($lastname)."'"; + $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { @@ -1227,24 +1227,24 @@ class Adherent extends CommonObject $sql .= " dep.nom as state, dep.code_departement as state_code,"; $sql .= " t.libelle as type, t.subscription as subscription,"; $sql .= " u.rowid as user_id, u.login as user_login"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as t, " . MAIN_DB_PREFIX . "adherent as d"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON d.country = c.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_departements as dep ON d.state_id = dep.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u ON d.rowid = u.fk_member"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member"; $sql .= " WHERE d.fk_adherent_type = t.rowid"; if ($rowid) - $sql .= " AND d.rowid=" . $rowid; + $sql .= " AND d.rowid=".$rowid; elseif ($ref || $fk_soc) { - $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; if ($ref) - $sql .= " AND d.rowid='" . $this->db->escape($ref) . "'"; + $sql .= " AND d.rowid='".$this->db->escape($ref)."'"; elseif ($fk_soc > 0) - $sql .= " AND d.fk_soc=" . $fk_soc; + $sql .= " AND d.fk_soc=".$fk_soc; } elseif ($ref_ext) { - $sql .= " AND d.ref_ext='" . $this->db->escape($ref_ext) . "'"; + $sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; } - dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { @@ -1257,7 +1257,7 @@ class Adherent extends CommonObject $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility $this->civility_code = $obj->civility_code; - $this->civility = $obj->civility_code ? ($langs->trans("Civility" . $obj->civility_code) != ("Civility" . $obj->civility_code) ? $langs->trans("Civility" . $obj->civility_code) : $obj->civility_code) : ''; + $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; $this->firstname = $obj->firstname; $this->lastname = $obj->lastname; @@ -1281,8 +1281,8 @@ class Adherent extends CommonObject $this->country_id = $obj->country_id; $this->country_code = $obj->country_code; - if ($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) - $this->country = $langs->transnoentitiesnoconv("Country" . $obj->country_code); + if ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) + $this->country = $langs->transnoentitiesnoconv("Country".$obj->country_code); else $this->country = $obj->country; @@ -1354,17 +1354,17 @@ class Adherent extends CommonObject // phpcs:enable global $langs; - require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $sql = "SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note, c.fk_bank,"; $sql .= " c.tms as datem,"; $sql .= " c.datec as datec,"; $sql .= " c.dateadh as dateh,"; $sql .= " c.datef as datef"; - $sql .= " FROM " . MAIN_DB_PREFIX . "subscription as c"; - $sql .= " WHERE c.fk_adherent = " . $this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription as c"; + $sql .= " WHERE c.fk_adherent = ".$this->id; $sql .= " ORDER BY c.dateadh"; - dol_syslog(get_class($this) . "::fetch_subscriptions", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_subscriptions", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1401,7 +1401,7 @@ class Adherent extends CommonObject } return 1; } else { - $this->error = $this->db->error() . ' sql=' . $sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -1425,7 +1425,7 @@ class Adherent extends CommonObject { global $conf, $langs, $user; - require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $error = 0; @@ -1505,12 +1505,12 @@ class Adherent extends CommonObject $this->invoice = null; // This will contains invoice if an invoice is created - dol_syslog("subscriptionComplementaryActions subscriptionid=" . $subscriptionid . " option=" . $option . " accountid=" . $accountid . " datesubscription=" . $datesubscription . " paymentdate=" . - $paymentdate . " label=" . $label . " amount=" . $amount . " num_chq=" . $num_chq . " autocreatethirdparty=" . $autocreatethirdparty); + dol_syslog("subscriptionComplementaryActions subscriptionid=".$subscriptionid." option=".$option." accountid=".$accountid." datesubscription=".$datesubscription." paymentdate=". + $paymentdate." label=".$label." amount=".$amount." num_chq=".$num_chq." autocreatethirdparty=".$autocreatethirdparty); // Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect' if ($option == 'bankdirect' && $accountid) { - require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acct = new Account($this->db); $result = $acct->fetch($accountid); @@ -1519,11 +1519,11 @@ class Adherent extends CommonObject $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); if ($insertid > 0) { - $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT . '/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); + $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); if ($inserturlid > 0) { // Update table subscription - $sql = "UPDATE " . MAIN_DB_PREFIX . "subscription SET fk_bank=" . $insertid; - $sql .= " WHERE rowid=" . $subscriptionid; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; + $sql .= " WHERE rowid=".$subscriptionid; dol_syslog("subscription::subscription", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1546,8 +1546,8 @@ class Adherent extends CommonObject // If option choosed, we create invoice if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly') { - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/paymentterm.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; $invoice = new Facture($this->db); $customer = new Societe($this->db); @@ -1659,9 +1659,9 @@ class Adherent extends CommonObject // Add payment onto invoice if (!$error && $option == 'bankviainvoice' && $accountid) { - require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; - require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; $amounts = array(); $amounts[$invoice->id] = price2num($amount); @@ -1695,8 +1695,8 @@ class Adherent extends CommonObject if (!$error && !empty($bank_line_id)) { // Update fk_bank into subscription table - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'subscription SET fk_bank=' . $bank_line_id; - $sql .= ' WHERE rowid=' . $subscriptionid; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id; + $sql .= ' WHERE rowid='.$subscriptionid; $result = $this->db->query($sql); if (!$result) { @@ -1751,19 +1751,19 @@ class Adherent extends CommonObject // Check parameters if ($this->statut == 1) { - dol_syslog(get_class($this) . "::validate statut of member does not allow this", LOG_WARNING); + dol_syslog(get_class($this)."::validate statut of member does not allow this", LOG_WARNING); return 0; } $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql .= " statut = 1"; - $sql .= ", datevalid = '" . $this->db->idate($now) . "'"; - $sql .= ", fk_user_valid=" . $user->id; - $sql .= " WHERE rowid = " . $this->id; + $sql .= ", datevalid = '".$this->db->idate($now)."'"; + $sql .= ", fk_user_valid=".$user->id; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this) . "::validate", LOG_DEBUG); + dol_syslog(get_class($this)."::validate", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->statut = 1; @@ -1803,16 +1803,16 @@ class Adherent extends CommonObject // Check parameters if ($this->statut == 0) { - dol_syslog(get_class($this) . "::resiliate statut of member does not allow this", LOG_WARNING); + dol_syslog(get_class($this)."::resiliate statut of member does not allow this", LOG_WARNING); return 0; } $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql .= " statut = 0"; - $sql .= ", fk_user_valid=" . $user->id; - $sql .= " WHERE rowid = " . $this->id; + $sql .= ", fk_user_valid=".$user->id; + $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); if ($result) { @@ -1848,7 +1848,7 @@ class Adherent extends CommonObject // phpcs:enable global $conf, $langs; - include_once DOL_DOCUMENT_ROOT . '/mailmanspip/class/mailmanspip.class.php'; + include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; $mailmanspip = new MailmanSpip($this->db); $err = 0; @@ -1898,7 +1898,7 @@ class Adherent extends CommonObject // phpcs:enable global $conf, $langs; - include_once DOL_DOCUMENT_ROOT . '/mailmanspip/class/mailmanspip.class.php'; + include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; $mailmanspip = new MailmanSpip($this->db); $err = 0; @@ -1949,7 +1949,7 @@ class Adherent extends CommonObject $code = (empty($this->civility_id) ? '' : $this->civility_id); if (empty($code)) return ''; - return $langs->getLabelFromKey($this->db, "Civility" . $code, "c_civility", "code", "label", $code); + return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); } /** @@ -1982,15 +1982,15 @@ class Adherent extends CommonObject } $label .= '
'; - $label .= '' . $langs->trans("Member") . ''; - if (!empty($this->ref)) $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; - if (!empty($this->firstname) || !empty($this->lastname)) $label .= '
' . $langs->trans('Name') . ': ' . $this->getFullName($langs); - if (!empty($this->company)) $label .= '
' . $langs->trans('Company') . ': ' . $this->company; + $label .= ''.$langs->trans("Member").''; + if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->firstname) || !empty($this->lastname)) $label .= '
'.$langs->trans('Name').': '.$this->getFullName($langs); + if (!empty($this->company)) $label .= '
'.$langs->trans('Company').': '.$this->company; $label .= '
'; - $url = DOL_URL_ROOT . '/adherents/card.php?rowid=' . $this->id; + $url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id; if ($option == 'subscription') { - $url = DOL_URL_ROOT . '/adherents/subscription.php?rowid=' . $this->id; + $url = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$this->id; } if ($option != 'nolink') { @@ -2000,19 +2000,19 @@ class Adherent extends CommonObject if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkstart .= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); $label = $langs->trans("ShowUser"); - $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"'; - $linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - $linkstart .= $linkclose . '>'; + $linkstart .= $linkclose.'>'; $linkend = ''; $result .= $linkstart; @@ -2022,19 +2022,19 @@ class Adherent extends CommonObject if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-right: 3px;"'; // Only picto if ($withpictoimg > 0) - $picto = '' . - img_object('', 'user', $paddafterimage . ' ' . ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . ''; + $picto = ''. + img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; // Picto must be a photo else { - $picto = ''; - $picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto' . ($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1); + $picto = ''; + $picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1); $picto .= ''; } $result .= $picto; } if ($withpictoimg > -2 && $withpictoimg != 2) { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= ''; + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= ''; if ($mode == 'login') $result .= dol_trunc($this->login, $maxlen); elseif ($mode == 'ref') @@ -2126,9 +2126,9 @@ class Adherent extends CommonObject $this->nb = array(); $sql = "SELECT count(a.rowid) as nb"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql .= " WHERE a.statut > 0"; - $sql .= " AND a.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND a.entity IN (".getEntity('adherent').")"; $resql = $this->db->query($sql); if ($resql) { @@ -2162,16 +2162,16 @@ class Adherent extends CommonObject $now = dol_now(); $sql = "SELECT a.rowid, a.datefin, a.statut"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a"; - $sql .= ", " . MAIN_DB_PREFIX . "adherent_type as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; + $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE a.fk_adherent_type = t.rowid"; if ($mode == 'expired') { $sql .= " AND a.statut = 1"; - $sql .= " AND a.entity IN (" . getEntity('adherent') . ")"; - $sql .= " AND ((a.datefin IS NULL or a.datefin < '" . $this->db->idate($now) . "') AND t.subscription = 1)"; + $sql .= " AND a.entity IN (".getEntity('adherent').")"; + $sql .= " AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND t.subscription = 1)"; } elseif ($mode == 'shift') { $sql .= " AND a.statut = -1"; - $sql .= " AND a.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND a.entity IN (".getEntity('adherent').")"; } $resql = $this->db->query($sql); @@ -2187,10 +2187,10 @@ class Adherent extends CommonObject $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24; $label = $langs->trans("MembersWithSubscriptionToReceive"); $labelShort = $langs->trans("MembersWithSubscriptionToReceiveShort"); - $url = DOL_URL_ROOT . '/adherents/list.php?mainmenu=members&statut=1&filter=outofdate'; + $url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1&filter=outofdate'; } elseif ($mode == 'shift') { $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24; - $url = DOL_URL_ROOT . '/adherents/list.php?mainmenu=members&statut=-1'; + $url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=-1'; $label = $langs->trans("MembersListToValid"); $labelShort = $langs->trans("ToValidate"); } @@ -2331,9 +2331,9 @@ class Adherent extends CommonObject // phpcs:enable global $conf; $dn = ''; - if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS . "=" . $info[$conf->global->LDAP_KEY_MEMBERS] . "," . $conf->global->LDAP_MEMBER_DN; + if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS].",".$conf->global->LDAP_MEMBER_DN; if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_DN; - if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS . "=" . $info[$conf->global->LDAP_KEY_MEMBERS]; + if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS]; return $dn; } @@ -2413,7 +2413,7 @@ class Adherent extends CommonObject if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) { // Create OpenLDAP MD5 password from Dolibarr MD5 password // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))" - $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}' . base64_encode(hex2bin($this->pass_indatabase_crypted)); + $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}'.base64_encode(hex2bin($this->pass_indatabase_crypted)); } } } // Use $this->pass_indatabase value if exists @@ -2445,10 +2445,10 @@ class Adherent extends CommonObject $sql .= ' a.datevalid as datev,'; $sql .= ' a.tms as datem,'; $sql .= ' a.fk_user_author, a.fk_user_valid, a.fk_user_mod'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'adherent as a'; - $sql .= ' WHERE a.rowid = ' . $id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'adherent as a'; + $sql .= ' WHERE a.rowid = '.$id; - dol_syslog(get_class($this) . "::info", LOG_DEBUG); + dol_syslog(get_class($this)."::info", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { @@ -2491,8 +2491,8 @@ class Adherent extends CommonObject public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; - $sql .= " FROM " . MAIN_DB_PREFIX . "mailing_cibles as mc"; - $sql .= " WHERE mc.email = '" . $this->db->escape($this->email) . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE mc.email = '".$this->db->escape($this->email)."'"; $sql .= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes $resql = $this->db->query($sql); @@ -2526,7 +2526,7 @@ class Adherent extends CommonObject } // Get current categories - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, Categorie::TYPE_MEMBER, 'id'); @@ -2627,7 +2627,7 @@ class Adherent extends CommonObject $arraydaysbeforeend = explode(';', $daysbeforeendlist); foreach ($arraydaysbeforeend as $daysbeforeend) // Loop on each delay { - dol_syslog(__METHOD__ . ' - Process delta = ' . $daysbeforeend, LOG_DEBUG); + dol_syslog(__METHOD__.' - Process delta = '.$daysbeforeend, LOG_DEBUG); if (!is_numeric($daysbeforeend)) { $blockingerrormsg = "Value for delta is not a positive or negative numeric"; @@ -2638,15 +2638,15 @@ class Adherent extends CommonObject $tmp = dol_getdate($now); $datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), $daysbeforeend, 'd'); - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'adherent'; - $sql .= " WHERE entity = " . $conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; - $sql .= " AND datefin = '" . $this->db->idate($datetosearchfor) . "'"; + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent'; + $sql .= " WHERE entity = ".$conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; + $sql .= " AND datefin = '".$this->db->idate($datetosearchfor)."'"; $resql = $this->db->query($sql); if ($resql) { $num_rows = $this->db->num_rows($resql); - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $adherent = new Adherent($this->db); $formmail = new FormMail($this->db); @@ -2670,7 +2670,7 @@ class Adherent extends CommonObject $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($languagecodeformember); $outputlangs->loadLangs(array("main", "members")); - dol_syslog("sendReminderForExpiredSubscription Language for member id " . $adherent->id . " set to " . $outputlangs->defaultlang . " mysoc->default_lang=" . $mysoc->default_lang); + dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang); $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION; @@ -2687,10 +2687,10 @@ class Adherent extends CommonObject $from = $conf->global->ADHERENT_MAIL_FROM; $to = $adherent->email; - $trackid = 'mem' . $adherent->id; - $moreinheader = 'X-Dolibarr-Info: sendReminderForExpiredSubscription' . "\r\n"; + $trackid = 'mem'.$adherent->id; + $moreinheader = 'X-Dolibarr-Info: sendReminderForExpiredSubscription'."\r\n"; - include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, $moreinheader); $result = $cmail->sendfile(); if (!$result) { @@ -2713,24 +2713,24 @@ class Adherent extends CommonObject $extraparams = ''; $actionmsg = ''; - $actionmsg2 = $langs->transnoentities('MailSentBy') . ' ' . CMailFile::getValidAddress($from, 4, 0, 1) . ' ' . $langs->transnoentities('To') . ' ' . + $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '. CMailFile::getValidAddress($sendto, 4, 0, 1); if ($message) { - $actionmsg = $langs->transnoentities('MailFrom') . ': ' . dol_escape_htmltag($from); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo') . ': ' . dol_escape_htmltag($sendto)); - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc)); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); $actionmsg = dol_concatdesc($actionmsg, $message); } - require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; // Insert record of emails sent $actioncomm = new ActionComm($this->db); $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) - $actioncomm->code = 'AC_' . $actioncode; + $actioncomm->code = 'AC_'.$actioncode; $actioncomm->label = $actionmsg2; $actioncomm->note_private = $actionmsg; $actioncomm->fk_project = 0; @@ -2780,8 +2780,8 @@ class Adherent extends CommonObject $this->error = $blockingerrormsg; return 1; } else { - $this->output = 'Found ' . ($nbok + $nbko) . ' members to send reminder to.'; - $this->output .= ' Send email successfuly to ' . $nbok . ' members'; + $this->output = 'Found '.($nbok + $nbko).' members to send reminder to.'; + $this->output .= ' Send email successfuly to '.$nbok.' members'; if (is_array($listofmembersok)) { $listofids = ''; $i = 0; @@ -2801,7 +2801,7 @@ class Adherent extends CommonObject $this->output .= $listofids; } if ($nbko) { - $this->output .= ' - Canceled for ' . $nbko . ' member (no email or email sending error)'; + $this->output .= ' - Canceled for '.$nbko.' member (no email or email sending error)'; if (is_array($listofmembersko)) { $listofids = ''; $i = 0; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 70ea29360c8..2f33b3ab49b 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -36,12 +36,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'projects', 'hrm', 'agenda')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'aZ09'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'adminihm'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminihm'; // To manage different context of search -if (! defined("MAIN_MOTD")) define("MAIN_MOTD", ""); +if (!defined("MAIN_MOTD")) define("MAIN_MOTD", ""); @@ -49,13 +49,13 @@ if (! defined("MAIN_MOTD")) define("MAIN_MOTD", ""); * Action */ -$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 (GETPOST('cancel', 'alpha')) { - $action=''; + $action = ''; } // Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff) @@ -65,15 +65,15 @@ if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) { else dolibarr_del_const($db, $regs[2], $conf->entity); } -if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACKGROUND)) +if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKGROUND)) { - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $logofile=$conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND; + $logofile = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND; dol_delete_file($logofile); dolibarr_del_const($db, "MAIN_LOGIN_BACKGROUND", $conf->entity); - $mysoc->logo=''; + $mysoc->logo = ''; /*$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; dol_delete_file($logosmallfile); @@ -89,7 +89,7 @@ if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACK if ($action == 'update') { dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); //dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity); @@ -98,53 +98,53 @@ if ($action == 'update') if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity); else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/ - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity); else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity); else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); @@ -158,29 +158,29 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", GETPOST("MAIN_DEFAULT_WORKING_HOURS", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", GETPOST("MAIN_FIRSTNAME_NAME_POSITION", 'aZ09'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", GETPOST('MAIN_HELPCENTER_DISABLELINK', 'aZ09'), 'chaine', 0, '', 0); // Param for all entities + dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", GETPOST('MAIN_HELPCENTER_DISABLELINK', 'aZ09'), 'chaine', 0, '', 0); // Param for all entities dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr(GETPOST("main_motd", 'none')), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr(GETPOST("main_home", 'none')), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities + dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", GETPOST('MAIN_BUGTRACK_ENABLELINK', 'aZ09'), 'chaine', 0, '', $conf->entity); - $varforimage='imagebackground'; $dirforimage=$conf->mycompany->dir_output.'/logos/'; + $varforimage = 'imagebackground'; $dirforimage = $conf->mycompany->dir_output.'/logos/'; if ($_FILES[$varforimage]["tmp_name"]) { $reg = array(); if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { - $original_file=$reg[1]; + $original_file = $reg[1]; - $isimage=image_format_supported($original_file); + $isimage = image_format_supported($original_file); if ($isimage >= 0) { dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); - if (! is_dir($dirforimage)) + if (!is_dir($dirforimage)) { dol_mkdir($dirforimage); } - $result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); + $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); if ($result > 0) { dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND", $original_file, 'chaine', 0, '', $conf->entity); @@ -189,7 +189,7 @@ if ($action == 'update') { $error++; $langs->load("errors"); - $tmparray=explode(':', $result); + $tmparray = explode(':', $result); setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors'); } else @@ -209,7 +209,7 @@ if ($action == 'update') - $_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer + $_SESSION["mainmenu"] = ""; // Le gestionnaire de menu a pu changer header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -220,12 +220,12 @@ if ($action == 'update') * View */ -$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; +$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('', $langs->trans("Setup"), $wikihelp); -$form=new Form($db); -$formother=new FormOther($db); -$formadmin=new FormAdmin($db); +$form = new Form($db); +$formother = new FormOther($db); +$formadmin = new FormAdmin($db); print load_fiche_titre($langs->trans("GUISetup"), '', 'title_setup'); @@ -281,12 +281,12 @@ print ' '; print ''; // Max size of lists -print ''.$langs->trans("DefaultMaxSizeList").''; +print ''.$langs->trans("DefaultMaxSizeList").''; print ' '; print ''; // Max size of short lists on customer card -print ''.$langs->trans("DefaultMaxSizeShortList").''; +print ''.$langs->trans("DefaultMaxSizeShortList").''; print ' '; print ''; @@ -301,36 +301,36 @@ print ''; // First day for weeks print ''.$langs->trans("WeekStartOnDay").''; -print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'), 'MAIN_START_WEEK', 0); +print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'), 'MAIN_START_WEEK', 0); print ''; print ' '; print ''; // DefaultWorkingDays print ''.$langs->trans("DefaultWorkingDays").''; -print ''; +print ''; print ''; print ' '; print ''; // DefaultWorkingHours print ''.$langs->trans("DefaultWorkingHours").''; -print ''; +print ''; print ''; print ' '; print ''; // Firstname/Name print ''.$langs->trans("FirstnameNamePosition").''; -$array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); -print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0)); +$array = array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); +print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? $conf->global->MAIN_FIRSTNAME_NAME_POSITION : 0)); print ''; print ' '; print ''; // Hide unauthorized button print ''.$langs->trans("ButtonHideUnauthorized").''; -print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0, 1); +print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED : 0, 1); print ''; print ' '; print ''; @@ -353,28 +353,28 @@ print ' '; print ''; // Hide wiki link on login page -$pictohelp=''; +$pictohelp = ''; print ''.$langs->trans("DisableLinkToHelp", $pictohelp).''; -print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0, 1); +print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK) ? $conf->global->MAIN_HELP_DISABLELINK : 0, 1); print ''; print ' '; print ''; // Message of the day on home page -$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount')); +$substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount')); complete_substitutions_array($substitutionarray, $langs); print ''; -$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -foreach($substitutionarray as $key => $val) +$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
'; +foreach ($substitutionarray as $key => $val) { - $texthelp.=$key.'
'; + $texthelp .= $key.'
'; } print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday'); print ''; -$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); +$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD) ? $conf->global->MAIN_MOTD : ''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); $doleditor->Create(); print ''."\n"; @@ -391,23 +391,23 @@ print ' '; print ''; // Message on login page -$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount','user')); +$substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount', 'user')); complete_substitutions_array($substitutionarray, $langs); print ''; -$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -foreach($substitutionarray as $key => $val) +$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
'; +foreach ($substitutionarray as $key => $val) { - $texthelp.=$key.'
'; + $texthelp .= $key.'
'; } print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin'); print ''; -$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); +$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME) ? $conf->global->MAIN_HOME : ''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); $doleditor->Create(); print ''."\n"; // Hide helpcenter link on login page print ''.$langs->trans("DisableLinkToHelpCenter").''; -print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK', isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0, 1); +print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK', isset($conf->global->MAIN_HELPCENTER_DISABLELINK) ? $conf->global->MAIN_HELPCENTER_DISABLELINK : 0, 1); print ''; print ' '; print ''; @@ -416,13 +416,13 @@ print ''; print ''; print '
'; $disabled = ''; -if (! empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) $disabled = ' disabled="disabled"'; +if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) $disabled = ' disabled="disabled"'; print ''; if ($disabled) { print '('.$langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND").') '; } -if (! empty($conf->global->MAIN_LOGIN_BACKGROUND)) { +if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) { print ''.img_delete($langs->trans("Delete")).''; if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) { print '   '; diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9326082b193..87c91d0f621 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -119,16 +119,16 @@ class Proposals extends DolibarrApi */ private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) { - if(! DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } $result = $this->propal->fetch($id, $ref, $ref_ext); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -162,18 +162,18 @@ class Proposals 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."propal as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal 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('propal').')'; - 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 + $sql .= ' WHERE t.entity IN ('.getEntity('propal').')'; + 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 // Insert sale filter if ($search_sale > 0) { @@ -182,23 +182,23 @@ class Proposals 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); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -213,7 +213,7 @@ class Proposals extends DolibarrApi { $obj = $db->fetch_object($result); $proposal_static = new Propal($db); - if($proposal_static->fetch($obj->rowid)) { + if ($proposal_static->fetch($obj->rowid)) { // Add external contacts ids $proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1); $obj_ret[] = $this->_cleanObjectDatas($proposal_static); @@ -224,7 +224,7 @@ class Proposals extends DolibarrApi else { throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No proposal found'); } return $obj_ret; @@ -238,13 +238,13 @@ class Proposals extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->propal->$field = $value; } /*if (isset($request_data["lines"])) { @@ -272,16 +272,16 @@ class Proposals extends DolibarrApi */ public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->propal->getLinesArray(); @@ -304,16 +304,16 @@ class Proposals extends DolibarrApi */ public function postLine($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -368,16 +368,16 @@ class Proposals extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if($result <= 0) { + if ($result <= 0) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -391,27 +391,27 @@ class Proposals extends DolibarrApi $updateRes = $this->propal->updateline( $lineid, - isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, - isset($request_data->qty)?$request_data->qty:$propalline->qty, - isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, - isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, - isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, - isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, - isset($request_data->desc)?$request_data->desc:$propalline->desc, + isset($request_data->subprice) ? $request_data->subprice : $propalline->subprice, + isset($request_data->qty) ? $request_data->qty : $propalline->qty, + isset($request_data->remise_percent) ? $request_data->remise_percent : $propalline->remise_percent, + isset($request_data->tva_tx) ? $request_data->tva_tx : $propalline->tva_tx, + isset($request_data->localtax1_tx) ? $request_data->localtax1_tx : $propalline->localtax1_tx, + isset($request_data->localtax2_tx) ? $request_data->localtax2_tx : $propalline->localtax2_tx, + isset($request_data->desc) ? $request_data->desc : $propalline->desc, 'HT', - isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, - isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, - isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, + isset($request_data->info_bits) ? $request_data->info_bits : $propalline->info_bits, + isset($request_data->special_code) ? $request_data->special_code : $propalline->special_code, + isset($request_data->fk_parent_line) ? $request_data->fk_parent_line : $propalline->fk_parent_line, 0, - isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, - isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, - isset($request_data->label)?$request_data->label:$propalline->label, - isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, - isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, - isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, - isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, - isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, - isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice + isset($request_data->fk_fournprice) ? $request_data->fk_fournprice : $propalline->fk_fournprice, + isset($request_data->pa_ht) ? $request_data->pa_ht : $propalline->pa_ht, + isset($request_data->label) ? $request_data->label : $propalline->label, + isset($request_data->product_type) ? $request_data->product_type : $propalline->product_type, + isset($request_data->date_start) ? $request_data->date_start : $propalline->date_start, + isset($request_data->date_end) ? $request_data->date_end : $propalline->date_end, + isset($request_data->array_options) ? $request_data->array_options : $propalline->array_options, + isset($request_data->fk_unit) ? $request_data->fk_unit : $propalline->fk_unit, + isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice ); if ($updateRes > 0) { @@ -438,16 +438,16 @@ class Proposals extends DolibarrApi */ public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -479,13 +479,13 @@ class Proposals extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if(!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if(!$result) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } @@ -493,7 +493,7 @@ class Proposals extends DolibarrApi throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); } - if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -522,17 +522,17 @@ class Proposals extends DolibarrApi */ public function deleteContact($id, $rowid) { - if(!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if(!$result) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -555,16 +555,16 @@ class Proposals extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { @@ -579,7 +579,7 @@ class Proposals extends DolibarrApi } if (!empty($this->propal->fin_validite)) { - if($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite)<0) + if ($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite) < 0) { throw new RestException(500, $this->propal->error); } @@ -604,19 +604,19 @@ class Proposals extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->propal->supprimer) { + if (!DolibarrApiAccess::$user->rights->propal->supprimer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->propal->delete(DolibarrApiAccess::$user)) { + if (!$this->propal->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error); } @@ -639,15 +639,15 @@ class Proposals extends DolibarrApi */ public function settodraft($id) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -660,11 +660,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -696,15 +696,15 @@ class Proposals extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -717,11 +717,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -744,15 +744,15 @@ class Proposals extends DolibarrApi */ public function close($id, $status, $note_private = '', $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -765,11 +765,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -789,15 +789,15 @@ class Proposals extends DolibarrApi */ public function setinvoiced($id) { - if (! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -807,11 +807,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index bea546eeae8..9be7f50cbbf 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -252,13 +252,13 @@ class Propal extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1), 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>20), 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>22), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>40), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>45), // deprecated + 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>45), // deprecated 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>23), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>24), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), @@ -290,7 +290,7 @@ class Propal extends CommonObject 'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>190), 'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>195), - 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated + 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated 'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>205), 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>215), 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>220), diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index ee42ca26471..d5c48006430 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -24,10 +24,10 @@ * \brief File of class to manage proposals statistics */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; -include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -66,36 +66,36 @@ class PropaleStats extends Stats if ($mode == 'customer') { - $object=new Propal($this->db); + $object = new Propal($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date='p.datep'; - $this->field='total_ht'; - $this->field_line='total_ht'; + $this->field_date = 'p.datep'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - $this->where.= " p.fk_statut > 0"; + $this->where .= " p.fk_statut > 0"; } if ($mode == 'supplier') { - $object=new SupplierProposal($this->db); + $object = new SupplierProposal($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date='p.date_valid'; - $this->field='total_ht'; - $this->field_line='total_ht'; + $this->field_date = 'p.date_valid'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - $this->where.= " p.fk_statut > 0"; // Validated, accepted, refused and closed + $this->where .= " p.fk_statut > 0"; // Validated, accepted, refused and closed } //$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; - $this->where.= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if($this->socid) + $this->where .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($this->socid) { - $this->where.=" AND p.fk_soc = ".$this->socid; + $this->where .= " AND p.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND fk_user_author = '.$this->userid; } @@ -111,14 +111,14 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); return $res; } @@ -133,11 +133,11 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -154,14 +154,14 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); return $res; } @@ -176,12 +176,12 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -196,11 +196,11 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -219,13 +219,13 @@ class PropaleStats extends Stats global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; - $sql.= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; - $sql.= $this->db->order('nb', 'DESC'); + $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; + $sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " GROUP BY product.ref"; + $sql .= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); return $this->_getAllByProduct($sql, $limit); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 365308a224b..94e68b8bb02 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -167,15 +167,15 @@ $arrayfields = array( 'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), - 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), - 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>! empty($conf->multicurrency->enabled) && ! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), - 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>! empty($conf->multicurrency->enabled) && ! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), @@ -344,7 +344,7 @@ if ($search_login) $sql .= natural_search("u.login", $search_login); if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1); -if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"'; +if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; if ($search_multicurrency_tx != '') $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1); if ($search_multicurrency_montant_ht != '') $sql .= natural_search('p.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('p.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); @@ -1099,7 +1099,7 @@ if ($resql) // Currency if (!empty($arrayfields['p.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."\n"; + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; if (!$i) $totalarray['nbfield']++; } @@ -1107,7 +1107,7 @@ if ($resql) if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); print "\n"; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 03cdf990071..eb3c165d447 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -118,16 +118,16 @@ class Orders extends DolibarrApi */ private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) { - if(! DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } $result = $this->commande->fetch($id, $ref, $ref_ext); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -163,18 +163,18 @@ class Orders 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."commande as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande 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('commande').')'; - 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 + $sql .= ' WHERE t.entity IN ('.getEntity('commande').')'; + 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 // Insert sale filter if ($search_sale > 0) { @@ -183,23 +183,23 @@ class Orders 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); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -209,12 +209,12 @@ class Orders extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - $i=0; + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); $commande_static = new Commande($db); - if($commande_static->fetch($obj->rowid)) { + if ($commande_static->fetch($obj->rowid)) { // Add external contacts ids $commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1); $obj_ret[] = $this->_cleanObjectDatas($commande_static); @@ -225,7 +225,7 @@ class Orders extends DolibarrApi else { throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No order found'); } return $obj_ret; @@ -239,13 +239,13 @@ class Orders extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->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->commande->$field = $value; } /*if (isset($request_data["lines"])) { @@ -274,16 +274,16 @@ class Orders extends DolibarrApi */ public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->commande->getLinesArray(); @@ -306,16 +306,16 @@ class Orders extends DolibarrApi */ public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -368,16 +368,16 @@ class Orders extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -430,16 +430,16 @@ class Orders extends DolibarrApi */ public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -469,16 +469,16 @@ class Orders extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -507,16 +507,16 @@ class Orders extends DolibarrApi */ public function deleteContact($id, $rowid) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -539,19 +539,19 @@ class Orders extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->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->commande->$field = $value; } @@ -580,19 +580,19 @@ class Orders extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->commande->supprimer) { + if (!DolibarrApiAccess::$user->rights->commande->supprimer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->commande->delete(DolibarrApiAccess::$user)) { + if (!$this->commande->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting order : '.$this->commande->error); } @@ -628,15 +628,15 @@ class Orders extends DolibarrApi */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -648,11 +648,11 @@ class Orders extends DolibarrApi throw new RestException(500, 'Error when validating Order: '.$this->commande->error); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -681,21 +681,21 @@ class Orders extends DolibarrApi public function reopen($id) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Order ID is mandatory'); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } $result = $this->commande->set_reopen(DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->commande->error); - }elseif( $result == 0) { + }elseif ($result == 0) { throw new RestException(304); } @@ -719,28 +719,28 @@ class Orders extends DolibarrApi public function setinvoiced($id) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Order ID is mandatory'); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } $result = $this->commande->classifyBilled(DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(400, $this->commande->error); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -761,15 +761,15 @@ class Orders extends DolibarrApi */ public function close($id, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -782,11 +782,11 @@ class Orders extends DolibarrApi } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -807,15 +807,15 @@ class Orders extends DolibarrApi */ public function settodraft($id, $idwarehouse = -1) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -828,11 +828,11 @@ class Orders extends DolibarrApi } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -859,26 +859,26 @@ class Orders extends DolibarrApi public function createOrderFromProposal($proposalid) { - require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - if(! DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - if(empty($proposalid)) { + if (empty($proposalid)) { throw new RestException(400, 'Proposal ID is mandatory'); } $propal = new Propal($this->db); $result = $propal->fetch($proposalid); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } $result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->commande->error); } $this->commande->fetchObjectLinked(); @@ -921,7 +921,7 @@ class Orders extends DolibarrApi $commande = array(); foreach (Orders::$FIELDS as $field) { if (!isset($data[$field])) - throw new RestException(400, $field ." field missing"); + throw new RestException(400, $field." field missing"); $commande[$field] = $data[$field]; } return $commande; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ddd6d7723d5..a34dcc76377 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -262,12 +262,12 @@ class Commande extends CommonOrder /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>25), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>26), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated + 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>28), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>25), diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 522bd7b2e31..8b6dc4db6ec 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -23,10 +23,10 @@ * \ingroup commandes * \brief File of class to manage order statistics */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; -include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -67,31 +67,31 @@ class CommandeStats extends Stats if ($mode == 'customer') { - $object=new Commande($this->db); + $object = new Commande($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total_ht'; - $this->field_line='total_ht'; - $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; + $this->where .= " c.fk_statut > 0"; // Not draft and not cancelled } elseif ($mode == 'supplier') { - $object=new CommandeFournisseur($this->db); + $object = new CommandeFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total_ht'; - $this->field_line='total_ht'; - $this->where.= " c.fk_statut > 2"; // Only approved & ordered + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; + $this->where .= " c.fk_statut > 2"; // Only approved & ordered } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where.= ' AND c.entity IN ('.getEntity('commande').')'; + $this->where .= ' AND c.entity IN ('.getEntity('commande').')'; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if ($this->socid) { - $this->where.=" AND c.fk_soc = ".$this->socid; + $this->where .= " AND c.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid; } /** @@ -106,14 +106,14 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); return $res; } @@ -128,11 +128,11 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -149,14 +149,14 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); return $res; } @@ -171,12 +171,12 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -191,11 +191,11 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -212,13 +212,13 @@ class CommandeStats extends Stats global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; - $sql.= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; - $sql.= $this->db->order('nb', 'DESC'); + $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; + $sql .= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " GROUP BY product.ref"; + $sql .= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); return $this->_getAllByProduct($sql, $limit); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 5e2353110e7..429a42464d1 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -346,7 +346,7 @@ if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); if ($search_total_vat != '') $sql .= natural_search('c.tva', $search_total_vat, 1); if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); -if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"'; +if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; if ($search_multicurrency_tx != '') $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1); if ($search_multicurrency_montant_ht != '') $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); @@ -1168,7 +1168,7 @@ if ($resql) // Currency if (!empty($arrayfields['c.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."\n"; + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; if (!$i) $totalarray['nbfield']++; } @@ -1176,7 +1176,7 @@ if ($resql) if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); print "\n"; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 7a8832be2b5..d1e15c10553 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -133,7 +133,7 @@ if (($action == "searchfiles" || $action == "dl")) { // Customer invoices if (GETPOST('selectinvoices')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; @@ -142,7 +142,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Vendor invoices if (GETPOST('selectsupplierinvoices')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; @@ -151,7 +151,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Expense reports if (GETPOST('selectexpensereports')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE date_fin between ".$wheretail; @@ -160,7 +160,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Donations if (GETPOST('selectdonations')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; $sql .= " WHERE datedon between ".$wheretail; @@ -169,7 +169,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Paiements of salaries if (GETPOST('selectpaymentsofsalaries')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE datep between ".$wheretail; @@ -178,7 +178,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Social contributions if (GETPOST('selectsocialcontributions')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.date_creation as date, t.date_ech as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; $sql .= " WHERE date_creation between ".$wheretail; @@ -467,7 +467,7 @@ print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n if (!empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($conf->entity); - print '('.$langs->trans("Entity").' : '; + print '('.$langs->trans("Entity").' : '; print ""; if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true); @@ -488,8 +488,8 @@ $listofchoices = array( 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries'), 'selectsocialcontributions'=>array('label'=>'SocialContributions') ); -foreach($listofchoices as $choice => $val) { - $checked = (((! GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice))?' checked="checked"':''); +foreach ($listofchoices as $choice => $val) { + $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); print '
'.$langs->trans($val['label']).'
'; } @@ -508,8 +508,8 @@ if (!empty($date_start) && !empty($date_stop)) $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); - foreach($listofchoices as $choice => $val) { - $param.='&'.$choice.'='.(GETPOST($choice, 'int')?1:0); + foreach ($listofchoices as $choice => $val) { + $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); } print '
'."\n"; print ''; @@ -518,7 +518,7 @@ if (!empty($date_start) && !empty($date_stop)) print ''; print ''; - foreach($listofchoices as $choice => $val) { + foreach ($listofchoices as $choice => $val) { print ''; } diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 37193726b01..8c146a65470 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -39,17 +39,17 @@ if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categori // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'accountancy', 'compta')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bankaccountlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bankaccountlist'; // To manage different context of search -$search_ref=GETPOST('search_ref', 'alpha'); -$search_label=GETPOST('search_label', 'alpha'); -$search_number=GETPOST('search_number', 'alpha'); -$search_status=GETPOST('search_status')?GETPOST('search_status', 'alpha'):'opened'; // 'all' or ''='opened' +$search_ref = GETPOST('search_ref', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_number = GETPOST('search_number', 'alpha'); +$search_status = GETPOST('search_status') ?GETPOST('search_status', 'alpha') : 'opened'; // 'all' or ''='opened' $optioncss = GETPOST('optioncss', 'alpha'); if (!empty($conf->categorie->enabled)) @@ -58,13 +58,13 @@ if (!empty($conf->categorie->enabled)) } // Security check -if ($user->socid) $socid=$user->socid; -if (! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Dictionary with list of banks accounting account allowed to manager of chart account -if (! $allowed) $result=restrictedArea($user, 'banque'); +if ($user->socid) $socid = $user->socid; +if (!empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with list of banks accounting account allowed to manager of chart account +if (!$allowed) $result = restrictedArea($user, 'banque'); -$diroutputmassaction=$conf->bank->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->bank->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -82,7 +82,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -108,10 +108,10 @@ $arrayfields = array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -155,41 +155,41 @@ $accounts = array(); $sql = "SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.= $hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_ACCOUNT, "b.rowid"); } -$sql.= " WHERE b.entity IN (".getEntity('bank_account').")"; -if ($search_status == 'opened') $sql.= " AND clos = 0"; -if ($search_status == 'closed') $sql.= " AND clos = 1"; +$sql .= " WHERE b.entity IN (".getEntity('bank_account').")"; +if ($search_status == 'opened') $sql .= " AND clos = 0"; +if ($search_status == 'closed') $sql .= " AND clos = 1"; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_ACCOUNT, "b.rowid", $search_category_list); } -if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref); -if ($search_label != '') $sql.=natural_search('b.label', $search_label); -if ($search_number != '') $sql.=natural_search('b.number', $search_number); +if ($search_ref != '') $sql .= natural_search('b.ref', $search_ref); +if ($search_label != '') $sql .= natural_search('b.label', $search_label); +if ($search_number != '') $sql .= natural_search('b.number', $search_number); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -438,52 +438,52 @@ foreach ($accounts as $key=>$type) $solde = $objecttmp->solde(1); - if (! empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code) + if (!empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code) { - $lastcurrencycode='various'; // We found several different currencies + $lastcurrencycode = 'various'; // We found several different currencies } if ($lastcurrencycode != 'various') { - $lastcurrencycode=$objecttmp->currency_code; + $lastcurrencycode = $objecttmp->currency_code; } print ''; // Ref - if (! empty($arrayfields['b.ref']['checked'])) + if (!empty($arrayfields['b.ref']['checked'])) { print ''.$objecttmp->getNomUrl(1).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Label - if (! empty($arrayfields['b.label']['checked'])) + if (!empty($arrayfields['b.label']['checked'])) { print ''.$objecttmp->label.''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account type - if (! empty($arrayfields['accountype']['checked'])) + if (!empty($arrayfields['accountype']['checked'])) { print ''; print $objecttmp->type_lib[$objecttmp->type]; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Number - if (! empty($arrayfields['b.number']['checked'])) + if (!empty($arrayfields['b.number']['checked'])) { print ''.$objecttmp->number.''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account number - if (! empty($arrayfields['b.account_number']['checked'])) + if (!empty($arrayfields['b.account_number']['checked'])) { print ''; - if (! empty($conf->accounting->enabled) && ! empty($objecttmp->account_number)) + if (!empty($conf->accounting->enabled) && !empty($objecttmp->account_number)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $objecttmp->account_number, 1); @@ -494,14 +494,14 @@ foreach ($accounts as $key=>$type) print $objecttmp->account_number; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Accountancy journal - if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) + if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { print ''; - if (! empty($conf->accounting->enabled) && ! empty($objecttmp->fk_accountancy_journal)) + if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) { $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($objecttmp->fk_accountancy_journal); @@ -547,47 +547,47 @@ foreach ($accounts as $key=>$type) print ''.$langs->trans("FeatureDisabled").''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['b.datec']['checked'])) + if (!empty($arrayfields['b.datec']['checked'])) { print ''; print dol_print_date($objecttmp->date_creation, 'dayhour'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['b.tms']['checked'])) + if (!empty($arrayfields['b.tms']['checked'])) { print ''; print dol_print_date($objecttmp->date_update, 'dayhour'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['b.clos']['checked'])) + if (!empty($arrayfields['b.clos']['checked'])) { print ''.$objecttmp->getLibStatut(5).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Balance - if (! empty($arrayfields['balance']['checked'])) + if (!empty($arrayfields['balance']['checked'])) { print ''; print ''.price($solde, 0, $langs, 0, -1, -1, $objecttmp->currency_code).''; print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='balance'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'balance'; $totalarray['val']['balance'] += $solde; } diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index ea180a6b0ee..2229ea22609 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -32,7 +32,7 @@ $langs->loadLangs(array('companies', 'users', 'trips')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'deplacement', '', ''); $sortfield = GETPOST("sortfield", 'alpha'); @@ -42,33 +42,33 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="d.dated"; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "d.dated"; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; /* * View */ -$tripandexpense_static=new Deplacement($db); +$tripandexpense_static = new Deplacement($db); $childids = $user->getAllChildIds(); -$childids[]=$user->id; +$childids[] = $user->id; //$help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'; -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans("ListOfFees"), $help_url); -$totalnb=0; +$totalnb = 0; $sql = "SELECT count(d.rowid) as nb, sum(d.km) as km, d.type"; -$sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d"; -$sql.= " WHERE d.entity = ".$conf->entity; -if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',', $childids).')'; -$sql.= " GROUP BY d.type"; -$sql.= " ORDER BY d.type"; +$sql .= " FROM ".MAIN_DB_PREFIX."deplacement as d"; +$sql .= " WHERE d.entity = ".$conf->entity; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql .= ' AND d.fk_user IN ('.join(',', $childids).')'; +$sql .= " GROUP BY d.type"; +$sql .= " ORDER BY d.type"; $result = $db->query($sql); if ($result) @@ -102,10 +102,10 @@ print ''; print ''.$langs->trans("Statistics").''; print "\n"; -$listoftype=$tripandexpense_static->listOfTypes(); +$listoftype = $tripandexpense_static->listOfTypes(); foreach ($listoftype as $code => $label) { - $dataseries[]=array($label, (isset($nb[$code])?(int) $nb[$code]:0)); + $dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0)); } if ($conf->use_javascript_ajax) @@ -120,7 +120,7 @@ if ($conf->use_javascript_ajax) $dolgraph->SetType(array('pie')); $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($totalnb?0:1); + print $dolgraph->show($totalnb ? 0 : 1); print ''; } @@ -137,25 +137,25 @@ print ''; print '
'; -$max=10; +$max = 10; $langs->load("boxes"); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; -if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE u.rowid = d.fk_user"; -$sql.= " AND d.entity = ".$conf->entity; -if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',', $childids).')'; -if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql.= " AND d.fk_soc = ".$socid; -$sql.= $db->order("d.tms", "DESC"); -$sql.= $db->plimit($max, 0); +$sql .= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; +if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE u.rowid = d.fk_user"; +$sql .= " AND d.entity = ".$conf->entity; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql .= ' AND d.fk_user IN ('.join(',', $childids).')'; +if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND d.fk_soc = ".$socid; +$sql .= $db->order("d.tms", "DESC"); +$sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { - $var=false; + $var = false; $num = $db->num_rows($result); $i = 0; @@ -171,16 +171,16 @@ if ($result) { $total_ttc = $totalam = $total = 0; - $deplacementstatic=new Deplacement($db); - $userstatic=new User($db); + $deplacementstatic = new Deplacement($db); + $userstatic = new User($db); while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); - $deplacementstatic->ref=$obj->rowid; - $deplacementstatic->id=$obj->rowid; - $userstatic->id=$obj->uid; - $userstatic->lastname=$obj->lastname; - $userstatic->firstname=$obj->firstname; + $deplacementstatic->ref = $obj->rowid; + $deplacementstatic->id = $obj->rowid; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; print ''; print ''.$deplacementstatic->getNomUrl(1).''; print ''.$userstatic->getNomUrl(1).''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8510f1caa16..43e62d4b3a9 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -302,7 +302,7 @@ if (empty($reshook)) // Note: Other solution if you want to add a negative line on invoice, is to create a discount for customer and consumme it (but this is possible on standard invoice only). $array_of_total_ht_per_vat_rate = array(); $array_of_total_ht_devise_per_vat_rate = array(); - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if (empty($array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; if (empty($array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; $array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->total_ht; @@ -310,7 +310,7 @@ if (empty($reshook)) } //var_dump($array_of_total_ht_per_vat_rate);exit; - foreach($array_of_total_ht_per_vat_rate as $vatrate => $tmpvalue) + foreach ($array_of_total_ht_per_vat_rate as $vatrate => $tmpvalue) { $tmp_total_ht = $array_of_total_ht_per_vat_rate[$vatrate]; $tmp_total_ht_devise = $array_of_total_ht_devise_per_vat_rate[$vatrate]; @@ -1524,7 +1524,7 @@ if (empty($reshook)) // If we create a deposit with all lines and a percent, we change amount if ($_POST['type'] == Facture::TYPE_DEPOSIT && $typeamount == 'variablealllines') { if (is_array($lines)) { - foreach($lines as $line) { + foreach ($lines as $line) { // We keep ->subprice and ->pa_ht, but we change the qty $line->qty = price2num($line->qty * $valuedeposit / 100, 'MS'); } @@ -5119,7 +5119,7 @@ elseif ($id > 0 || !empty($ref)) } // For credit note if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercancreate - && (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) + && (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) ) { print ''.$langs->trans('ConvertToReduc').''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b9e80ca1cf8..312c34d0ecb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -117,7 +117,7 @@ class Facture extends CommonInvoice * @var int Ref Int * @deprecated */ - public $ref_int; // deprecated + public $ref_int; // deprecated //Check constants for types public $type = self::TYPE_STANDARD; @@ -261,7 +261,7 @@ class Facture extends CommonInvoice 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>25), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>30), // deprecated + 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>30), // deprecated 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'Ref client', 'enabled'=>1, 'visible'=>-1, 'position'=>40), //'increment' =>array('type'=>'varchar(10)', 'label'=>'Increment', 'enabled'=>1, 'visible'=>-1, 'position'=>45), @@ -1499,7 +1499,7 @@ class Facture extends CommonInvoice $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid if ($ref) $sql .= " AND f.ref='".$this->db->escape($ref)."'"; if ($ref_ext) $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($notused) $sql .= " AND f.ref_int='".$this->db->escape($notused)."'"; // deprecated + if ($notused) $sql .= " AND f.ref_int='".$this->db->escape($notused)."'"; // deprecated } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -2439,9 +2439,9 @@ class Facture extends CommonInvoice $productStatic = null; $warehouseStatic = null; if ($batch_rule > 0) { - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; - require_once DOL_DOCUMENT_ROOT . '/product/class/productbatch.class.php'; - require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $productStatic = new Product($this->db); $warehouseStatic = new Entrepot($this->db); } @@ -2621,7 +2621,7 @@ class Facture extends CommonInvoice $langs->load('errors'); $warehouseStatic->fetch($idwarehouse); $this->error = $langs->trans('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref); - dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR); + dol_syslog(__METHOD__.' Error: '.$langs->transnoentitiesnoconv('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR); } foreach ($batchList as $batch) { @@ -2660,7 +2660,7 @@ class Facture extends CommonInvoice $langs->load('errors'); $warehouseStatic->fetch($idwarehouse); $this->error = $langs->trans('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref); - dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR); + dol_syslog(__METHOD__.' Error: '.$langs->transnoentitiesnoconv('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR); } } } diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 730df6ee6e4..ea0b17bc59a 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -22,10 +22,10 @@ * \ingroup factures * \brief Fichier de la classe de gestion des stats des factures */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** * Class to manage stats for invoices (customer and supplier) @@ -64,32 +64,32 @@ class FactureStats extends Stats if ($mode == 'customer') { - $object=new Facture($this->db); + $object = new Facture($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as f"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total'; - $this->field_line='total_ht'; + $this->field = 'total'; + $this->field_line = 'total_ht'; } if ($mode == 'supplier') { - $object=new FactureFournisseur($this->db); + $object = new FactureFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as f"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total_ht'; - $this->field_line='total_ht'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; } $this->where = " f.fk_statut >= 0"; - $this->where.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($mode == 'customer') $this->where.=" AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) + $this->where .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($mode == 'customer') $this->where .= " AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) if ($this->socid) { - $this->where.=" AND f.fk_soc = ".$this->socid; + $this->where .= " AND f.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2,5)"; - else $this->where.= " AND f.type IN (0,1,2,3,5)"; + if ($this->userid > 0) $this->where .= ' AND f.fk_user_author = '.$this->userid; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where .= " AND f.type IN (0,1,2,5)"; + else $this->where .= " AND f.type IN (0,1,2,3,5)"; } @@ -105,14 +105,14 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(f.datef,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } @@ -128,11 +128,11 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(f.datef,'%Y') as dm, COUNT(*), SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -150,14 +150,14 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(datef,'%m') as dm, SUM(f.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } @@ -173,12 +173,12 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -193,11 +193,11 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -214,13 +214,13 @@ class FactureStats extends Stats global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; - $sql.= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; - $sql.= $this->db->order('nb', 'DESC'); + $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; + $sql .= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " GROUP BY product.ref"; + $sql .= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); return $this->_getAllByProduct($sql, $limit); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 82f92085abf..81607613947 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -477,7 +477,7 @@ if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_v if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); -if ($search_multicurrency_code != '') $sql .= ' AND f.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"'; +if ($search_multicurrency_code != '') $sql .= ' AND f.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', $search_multicurrency_tx, 1); if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); @@ -1402,7 +1402,7 @@ if ($resql) // Currency if (!empty($arrayfields['f.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."\n"; + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; if (!$i) $totalarray['nbfield']++; } @@ -1410,7 +1410,7 @@ if ($resql) if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); print "\n"; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 5c8fc84a843..bb5a7516fb2 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -23,18 +23,18 @@ * \brief Code for actions on extrafields admin pages */ -$maxsizestring=255; -$maxsizeint=10; -$mesg=array(); +$maxsizestring = 255; +$maxsizeint = 10; +$mesg = array(); -$extrasize=GETPOST('size', 'intcomma'); -$type=GETPOST('type', 'alpha'); -$param=GETPOST('param', 'alpha'); +$extrasize = GETPOST('size', 'intcomma'); +$type = GETPOST('type', 'alpha'); +$param = GETPOST('param', 'alpha'); -if ($type=='double' && strpos($extrasize, ',')===false) $extrasize='24,8'; -if ($type=='date') $extrasize=''; -if ($type=='datetime') $extrasize=''; -if ($type=='select') $extrasize=''; +if ($type == 'double' && strpos($extrasize, ',') === false) $extrasize = '24,8'; +if ($type == 'date') $extrasize = ''; +if ($type == 'datetime') $extrasize = ''; +if ($type == 'select') $extrasize = ''; // Add attribute @@ -43,83 +43,83 @@ if ($action == 'add') if ($_POST["button"] != $langs->trans("Cancel")) { // Check values - if (! $type) + if (!$type) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'create'; } - if ($type=='varchar' && $extrasize <= 0) + if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } - if ($type=='varchar' && $extrasize > $maxsizestring) + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'create'; } - if ($type=='int' && $extrasize > $maxsizeint) + if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'create'; } - if ($type=='select' && !$param) + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'create'; } - if ($type=='sellist' && !$param) + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectListType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'create'; } - if ($type=='checkbox' && !$param) + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'create'; } - if ($type=='link' && !$param) + if ($type == 'link' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForLinkType"); + $mesg[] = $langs->trans("ErrorNoValueForLinkType"); $action = 'create'; } - if ($type=='radio' && !$param) + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForRadioType"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'create'; } - if ((($type=='radio') || ($type=='checkbox')) && $param) + if ((($type == 'radio') || ($type == 'checkbox')) && $param) { // Construct array for parameter (value of select list) $parameters = $param; $parameters_array = explode("\r\n", $parameters); - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { if (!empty($param_ligne)) { if (preg_match_all('/,/', $param_ligne, $matches)) { - if (count($matches[0])>1) { + if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } @@ -127,14 +127,14 @@ if ($action == 'add') { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } } } - if (! $error) + if (!$error) { // attrname must be alphabetical and lower case only if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) @@ -144,8 +144,8 @@ if ($action == 'add') $parameters = $param; $parameters_array = explode("\r\n", $parameters); //In sellist we have only one line and it can have come to do SQL expression - if ($type=='sellist') { - foreach($parameters_array as $param_ligne) + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } @@ -153,37 +153,37 @@ if ($action == 'add') else { //Esle it's separated key/value and coma list - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { - list($key,$value) = explode(',', $param_ligne); + list($key, $value) = explode(',', $param_ligne); $params['options'][$key] = $value; } } // Visibility: -1=not visible by default in list, 1=visible, 0=hidden $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility=3; + if ($type == 'separate') $visibility = 3; - $result=$extrafields->addExtraField( + $result = $extrafields->addExtraField( GETPOST('attrname', 'alpha'), GETPOST('label', 'alpha'), $type, GETPOST('pos', 'int'), $extrasize, $elementtype, - (GETPOST('unique', 'alpha')?1:0), - (GETPOST('required', 'alpha')?1:0), + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), $default_value, $params, - (GETPOST('alwayseditable', 'alpha')?1:0), - (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), $visibility, GETPOST('help', 'alpha'), GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:''), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile', 'alpha'), 1, - (GETPOST('totalizable', 'alpha')?1:0), + (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha') ); if ($result > 0) @@ -195,7 +195,7 @@ if ($action == 'add') else { $error++; - $mesg=$extrafields->error; + $mesg = $extrafields->error; setEventMessages($mesg, null, 'errors'); } } @@ -203,7 +203,7 @@ if ($action == 'add') { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); setEventMessages($mesg, null, 'errors'); $action = 'create'; } @@ -221,76 +221,76 @@ if ($action == 'update') if ($_POST["button"] != $langs->trans("Cancel")) { // Check values - if (! $type) + if (!$type) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'edit'; } - if ($type=='varchar' && $extrasize <= 0) + if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } - if ($type=='varchar' && $extrasize > $maxsizestring) + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'edit'; } - if ($type=='int' && $extrasize > $maxsizeint) + if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'edit'; } - if ($type=='select' && !$param) + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'edit'; } - if ($type=='sellist' && !$param) + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectListType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'edit'; } - if ($type=='checkbox' && !$param) + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'edit'; } - if ($type=='radio' && !$param) + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForRadioType"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'edit'; } - if ((($type=='radio') || ($type=='checkbox')) && $param) + if ((($type == 'radio') || ($type == 'checkbox')) && $param) { // Construct array for parameter (value of select list) $parameters = $param; $parameters_array = explode("\r\n", $parameters); - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { if (!empty($param_ligne)) { if (preg_match_all('/,/', $param_ligne, $matches)) { - if (count($matches[0])>1) { + if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } @@ -298,14 +298,14 @@ if ($action == 'update') { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } } } - if (! $error) + if (!$error) { if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) { @@ -314,8 +314,8 @@ if ($action == 'update') $parameters = $param; $parameters_array = explode("\r\n", $parameters); //In sellist we have only one line and it can have come to do SQL expression - if ($type=='sellist') { - foreach($parameters_array as $param_ligne) + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } @@ -323,37 +323,37 @@ if ($action == 'update') else { //Esle it's separated key/value and coma list - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { - list($key,$value) = explode(',', $param_ligne); + list($key, $value) = explode(',', $param_ligne); $params['options'][$key] = $value; } } // Visibility: -1=not visible by default in list, 1=visible, 0=hidden $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility=3; + if ($type == 'separate') $visibility = 3; - $result=$extrafields->update( + $result = $extrafields->update( GETPOST('attrname', 'alpha'), GETPOST('label', 'alpha'), $type, $extrasize, $elementtype, - (GETPOST('unique', 'alpha')?1:0), - (GETPOST('required', 'alpha')?1:0), + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), $pos, $params, - (GETPOST('alwayseditable', 'alpha')?1:0), - (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), $visibility, GETPOST('help', 'alpha'), GETPOST('default_value', 'alpha'), GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:''), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), 1, - (GETPOST('totalizable', 'alpha')?1:0), + (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha') ); if ($result > 0) @@ -365,7 +365,7 @@ if ($action == 'update') else { $error++; - $mesg=$extrafields->error; + $mesg = $extrafields->error; setEventMessages($mesg, null, 'errors'); } } @@ -373,7 +373,7 @@ if ($action == 'update') { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); setEventMessages($mesg, null, 'errors'); } } @@ -387,20 +387,20 @@ if ($action == 'update') // Delete attribute if ($action == 'delete') { - if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) + if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) { - $result=$extrafields->delete($_GET["attrname"], $elementtype); + $result = $extrafields->delete($_GET["attrname"], $elementtype); if ($result >= 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } - else $mesg=$extrafields->error; + else $mesg = $extrafields->error; } else { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); } } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 3447b76a2b7..e8337d74303 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -163,7 +163,7 @@ class box_graph_product_distribution extends ModeleBoxes { $i = 0; $legend = array(); - foreach($data1 as $key => $val) + foreach ($data1 as $key => $val) { $data1[$key][0] = dol_trunc($data1[$key][0], 32); $legend[] = $data1[$key][0]; @@ -222,7 +222,7 @@ class box_graph_product_distribution extends ModeleBoxes { $i = 0; $legend = array(); - foreach($data2 as $key => $val) + foreach ($data2 as $key => $val) { $data2[$key][0] = dol_trunc($data2[$key][0], 32); $legend[] = $data2[$key][0]; @@ -282,7 +282,7 @@ class box_graph_product_distribution extends ModeleBoxes { $i = 0; $legend = array(); - foreach($data3 as $key => $val) + foreach ($data3 as $key => $val) { $data3[$key][0] = dol_trunc($data3[$key][0], 32); $legend[] = $data3[$key][0]; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 68f2e9b1ba8..80c6ff1b7a6 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -36,7 +36,7 @@ class Canvas /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -45,13 +45,13 @@ class Canvas public $actiontype; - public $dirmodule; // Module directory - public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - public $canvas; // Name of canvas (ex: company, individual, product, service, ...) - public $card; // Tab (sub-canvas) + public $dirmodule; // Module directory + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + public $card; // Tab (sub-canvas) - public $template_dir; // Initialized by getCanvas with templates directory - public $control; // Initialized by getCanvas with controller instance + public $template_dir; // Initialized by getCanvas with templates directory + public $control; // Initialized by getCanvas with controller instance /** @@ -76,9 +76,9 @@ class Canvas private function _cleanaction($action) { $newaction = $action; - if ($newaction == 'add') $newaction='create'; - if ($newaction == 'update') $newaction='edit'; - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view'; + if ($newaction == 'add') $newaction = 'create'; + if ($newaction == 'update') $newaction = 'edit'; + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; return $newaction; } @@ -114,7 +114,7 @@ class Canvas if (file_exists($controlclassfile)) { // Include actions class (controller) - $this->control_file=$controlclassfile; + $this->control_file = $controlclassfile; require_once $controlclassfile; // Instantiate actions class (controller) @@ -124,9 +124,9 @@ class Canvas // Template dir $this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/'); - if (! is_dir($this->template_dir)) + if (!is_dir($this->template_dir)) { - $this->template_dir=''; + $this->template_dir = ''; } //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; @@ -158,7 +158,7 @@ class Canvas { if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; + if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; else return 0; } @@ -177,7 +177,7 @@ class Canvas global $form, $formfile; //var_dump($this->card.'-'.$action); - include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template + include $this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index b0001a695b8..6f151698cfc 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -221,24 +221,24 @@ abstract class CommonDocGenerator ); // Retrieve extrafields - if(is_array($object->array_options) && count($object->array_options)) + if (is_array($object->array_options) && count($object->array_options)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); + $array_thirdparty = array_merge($array_thirdparty, array('company_options_'.$key => $object->array_options ['options_'.$key])); } } return $array_thirdparty; @@ -258,61 +258,61 @@ 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); } - $array_contact = array ( - $array_key . '_fullname' => $object->getFullName($outputlangs, 1), - $array_key . '_lastname' => $object->lastname, - $array_key . '_firstname' => $object->firstname, - $array_key . '_address' => $object->address, - $array_key . '_zip' => $object->zip, - $array_key . '_town' => $object->town, - $array_key . '_state_id' => $object->state_id, - $array_key . '_state_code' => $object->state_code, - $array_key . '_state' => $object->state, - $array_key . '_country_id' => $object->country_id, - $array_key . '_country_code' => $object->country_code, - $array_key . '_country' => $object->country, - $array_key . '_poste' => $object->poste, - $array_key . '_socid' => $object->socid, - $array_key . '_statut' => $object->statut, - $array_key . '_code' => $object->code, - $array_key . '_email' => $object->email, - $array_key . '_jabberid' => $object->jabberid, - $array_key . '_phone_pro' => $object->phone_pro, - $array_key . '_phone_perso' => $object->phone_perso, - $array_key . '_phone_mobile' => $object->phone_mobile, - $array_key . '_fax' => $object->fax, - $array_key . '_birthday' => $object->birthday, - $array_key . '_default_lang' => $object->default_lang, - $array_key . '_note_public' => $object->note_public, - $array_key . '_note_private' => $object->note_private + $array_contact = array( + $array_key.'_fullname' => $object->getFullName($outputlangs, 1), + $array_key.'_lastname' => $object->lastname, + $array_key.'_firstname' => $object->firstname, + $array_key.'_address' => $object->address, + $array_key.'_zip' => $object->zip, + $array_key.'_town' => $object->town, + $array_key.'_state_id' => $object->state_id, + $array_key.'_state_code' => $object->state_code, + $array_key.'_state' => $object->state, + $array_key.'_country_id' => $object->country_id, + $array_key.'_country_code' => $object->country_code, + $array_key.'_country' => $object->country, + $array_key.'_poste' => $object->poste, + $array_key.'_socid' => $object->socid, + $array_key.'_statut' => $object->statut, + $array_key.'_code' => $object->code, + $array_key.'_email' => $object->email, + $array_key.'_jabberid' => $object->jabberid, + $array_key.'_phone_pro' => $object->phone_pro, + $array_key.'_phone_perso' => $object->phone_perso, + $array_key.'_phone_mobile' => $object->phone_mobile, + $array_key.'_fax' => $object->fax, + $array_key.'_birthday' => $object->birthday, + $array_key.'_default_lang' => $object->default_lang, + $array_key.'_note_public' => $object->note_public, + $array_key.'_note_private' => $object->note_private ); // Retrieve extrafields - require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $label) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { - $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); + $object->array_options['options_'.$key] = price($object->array_options ['options_'.$key], 0, $outputlangs, 0, 0, - 1, $conf->currency); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $object->array_options['options_' . $key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_' . $key]]; + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - $array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); + $array_contact = array_merge($array_contact, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); } return $array_contact; } @@ -478,20 +478,20 @@ abstract class CommonDocGenerator } // Add vat by rates - if (is_array($object->lines) && count($object->lines)>0) + if (is_array($object->lines) && count($object->lines) > 0) { $totalUp = 0; foreach ($object->lines as $line) { // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward compatibility - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; - $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx] = 0; + $resarray[$array_key.'_total_vat_'.$line->tva_tx] += $line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx] = price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) - $vatformated=vatrate($line->tva_tx); - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; - $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); + $vatformated = vatrate($line->tva_tx); + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated] = 0; + $resarray[$array_key.'_total_vat_'.$vatformated] += $line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$vatformated] = price($resarray[$array_key.'_total_vat_'.$vatformated]); $totalUp += $line->subprice * $line->qty; } @@ -589,13 +589,13 @@ abstract class CommonDocGenerator // Units if ($conf->global->PRODUCT_USE_UNITS) { - $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); - $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); + $resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long')); + $resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short')); } // Retrieve extrafields - $extrafieldkey=$line->element; - $array_key="line"; + $extrafieldkey = $line->element; + $array_key = "line"; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($extrafieldkey, true); @@ -608,7 +608,7 @@ abstract class CommonDocGenerator { // Add the product supplier extrafields to the substitutions $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; if (!empty($extralabels) && is_array($extralabels)) { @@ -622,7 +622,7 @@ abstract class CommonDocGenerator if ($columns != "") { $columns = substr($columns, 0, strlen($columns) - 2); - $resql = $this->db->query("SELECT $columns FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields AS ex INNER JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '" . $line->ref_supplier . "'"); + $resql = $this->db->query("SELECT $columns FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields AS ex INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '".$line->ref_supplier."'"); if ($this->db->num_rows($resql) > 0) { @@ -737,14 +737,14 @@ abstract class CommonDocGenerator 'line_qty'=>$line->qty, 'line_qty_shipped'=>$line->qty_shipped, 'line_qty_asked'=>$line->qty_asked, - 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), + 'line_discount_percent'=>($line->remise_percent ? $line->remise_percent.'%' : ''), 'line_price_ht'=>price($line->total_ht), 'line_price_ttc'=>price($line->total_ttc), 'line_price_vat'=>price($line->total_tva), - 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuringUnitString(0, 'weight', $line->weight_units), - 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuringUnitString(0, 'size', $line->length_units), - 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuringUnitString(0, 'surface', $line->surface_units), - 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuringUnitString(0, 'volume', $line->volume_units), + 'line_weight'=>empty($line->weight) ? '' : $line->weight * $line->qty_shipped.' '.measuringUnitString(0, 'weight', $line->weight_units), + 'line_length'=>empty($line->length) ? '' : $line->length * $line->qty_shipped.' '.measuringUnitString(0, 'size', $line->length_units), + 'line_surface'=>empty($line->surface) ? '' : $line->surface * $line->qty_shipped.' '.measuringUnitString(0, 'surface', $line->surface_units), + 'line_volume'=>empty($line->volume) ? '' : $line->volume * $line->qty_shipped.' '.measuringUnitString(0, 'volume', $line->volume_units), ); // Retrieve extrafields @@ -807,37 +807,37 @@ abstract class CommonDocGenerator global $conf; if (is_array($extrafields->attributes[$object->table_element]['label'])) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); //Add value to store price with currency - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $valArray=explode(',', $object->array_options['options_'.$key]); - $output=array(); - foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { - if (in_array($keyopt, $valArray)) { - $output[]=$valopt; + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { + $valArray = explode(',', $object->array_options['options_'.$key]); + $output = array(); + foreach ($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { + if (in_array($keyopt, $valArray)) { + $output[] = $valopt; } } $object->array_options['options_'.$key] = implode(', ', $output); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { - if (strlen($object->array_options['options_'.$key])>0) + if (strlen($object->array_options['options_'.$key]) > 0) { $date = $object->array_options['options_'.$key]; - $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language - $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format - $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format + $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language + $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format + $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format } else { @@ -845,29 +845,29 @@ abstract class CommonDocGenerator $object->array_options['options_'.$key.'_locale'] = ''; $object->array_options['options_'.$key.'_rfc'] = ''; } - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') + elseif ($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') { $datetime = $object->array_options['options_'.$key]; - $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language - $object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs):''); // using output language format - $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc'):''); // international format - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); + $object->array_options['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour') : ''); // using company output language + $object->array_options['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format + $object->array_options['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc') : ''); // international format + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'link') { $id = $object->array_options['options_'.$key]; if ($id != "") { $param = $extrafields->attributes[$object->table_element]['param'][$key]; - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' $InfoFieldList = explode(":", $param_list[0]); - $classname=$InfoFieldList[0]; - $classpath=$InfoFieldList[1]; - if (! empty($classpath)) + $classname = $InfoFieldList[0]; + $classpath = $InfoFieldList[1]; + if (!empty($classpath)) { dol_include_once($InfoFieldList[1]); if ($classname && class_exists($classname)) @@ -948,27 +948,27 @@ abstract class CommonDocGenerator uasort($this->cols, array($this, 'columnSort')); // Positionning - $curX = $this->page_largeur-$this->marge_droite; // start from right + $curX = $this->page_largeur - $this->marge_droite; // start from right // Array width - $arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche; + $arrayWidth = $this->page_largeur - $this->marge_droite - $this->marge_gauche; // Count flexible column $totalDefinedColWidth = 0; $countFlexCol = 0; foreach ($this->cols as $colKey =>& $colDef) { - if(!$this->getColumnStatus($colKey)) continue; // continue if disabled + if (!$this->getColumnStatus($colKey)) continue; // continue if disabled - if(!empty($colDef['scale'])){ + if (!empty($colDef['scale'])) { // In case of column width is defined by percentage $colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100); } - if(empty($colDef['width'])){ + if (empty($colDef['width'])) { $countFlexCol++; } - else{ + else { $totalDefinedColWidth += $colDef['width']; } } @@ -1161,7 +1161,7 @@ abstract class CommonDocGenerator 'printableEnableNotEmpty' => array(4) ); $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ + if (!empty($extrafieldDesc)) { $this->printStdColumnContent($pdf, $posYAfterDescription, $colKey, $extrafieldDesc); } } @@ -1178,13 +1178,13 @@ abstract class CommonDocGenerator { global $hookmanager; - if(empty($object->table_element)){ return; } + if (empty($object->table_element)) { return; } $extrafieldsKeyPrefix = "options_"; // Cleanup extrafield key to remove prefix if present $pos = strpos($extrafieldKey, $extrafieldsKeyPrefix); - if($pos===0){ + if ($pos === 0) { $extrafieldKey = substr($extrafieldKey, strlen($extrafieldsKeyPrefix)); } @@ -1192,14 +1192,14 @@ abstract class CommonDocGenerator // Load extrafiels if not allready does - if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); } - if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } + if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } + if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } $extrafields = $this->extrafieldsCache; $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element); // TODO : allow showOutputField to be pdf public friendly, ex: in a link to object, clean getNomUrl to remove link and images... like a getName methode ... - if($extrafields->attributes[$object->table_element]['type'][$extrafieldKey] == 'link'){ + if ($extrafields->attributes[$object->table_element]['type'][$extrafieldKey] == 'link') { // for lack of anything better we cleanup all html tags $extrafieldOutputContent = dol_string_nohtmltag($extrafieldOutputContent); } @@ -1233,13 +1233,13 @@ abstract class CommonDocGenerator { global $hookmanager; - if(empty($object->table_element)){ + if (empty($object->table_element)) { return; } // Load extrafiels if not allready does - if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); } - if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } + if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } + if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } $extrafields = $this->extrafieldsCache; $defaultParams = array( @@ -1283,9 +1283,9 @@ abstract class CommonDocGenerator // Enable extrafield ? $enabled = 0; $disableOnEmpty = 0; - if(!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { + if (!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { $printable = intval($extrafields->attributes[$object->table_element]['printable'][$key]); - if(in_array($printable, $params['printableEnable']) || in_array($printable, $params['printableEnableNotEmpty']) ) { + if (in_array($printable, $params['printableEnable']) || in_array($printable, $params['printableEnableNotEmpty'])) { $enabled = 1; } @@ -1294,7 +1294,7 @@ abstract class CommonDocGenerator } } - if(empty($enabled)){ + if (empty($enabled)) { continue; } @@ -1305,7 +1305,7 @@ abstract class CommonDocGenerator $field->type = $extrafields->attributes[$object->table_element]['type'][$key]; // dont display if empty - if($disableOnEmpty && empty($field->content)) { + if ($disableOnEmpty && empty($field->content)) { continue; } @@ -1313,40 +1313,40 @@ abstract class CommonDocGenerator } } - if(!empty($fields)) + if (!empty($fields)) { // Sort extrafields by rank - uasort($fields, function ($a, $b) { + uasort($fields, function($a, $b) { return ($a->rank > $b->rank) ? -1 : 1; }); // define some HTML content with style - $html.= !empty($params['style'])?'':''; + $html .= !empty($params['style']) ? '' : ''; // auto select display format - if($params['display'] == 'auto') { + if ($params['display'] == 'auto') { $lastNnumbItems = 0; - foreach ($params['auto'] as $display => $numbItems){ - if($lastNnumbItems <= $numbItems && count($fields) > $numbItems){ + foreach ($params['auto'] as $display => $numbItems) { + if ($lastNnumbItems <= $numbItems && count($fields) > $numbItems) { $lastNnumbItems = $numbItems; $params['display'] = $display; } } } - if($params['display'] == 'list') { + if ($params['display'] == 'list') { // Display in list format - $i=0; + $i = 0; foreach ($fields as $field) { - $html .= !empty($i)?$params['list']['separator']:''; - $html .= '' . $field->label . ' : '; + $html .= !empty($i) ? $params['list']['separator'] : ''; + $html .= ''.$field->label.' : '; $html .= $field->content; $i++; } } - elseif($params['display'] == 'table') { + elseif ($params['display'] == 'table') { // Display in table format - $html .= ''; + $html .= '
'; $html .= ""; $itemsInRow = 0; @@ -1373,14 +1373,14 @@ abstract class CommonDocGenerator } $itemsInRow = $maxItemsInRow; - $html .= '"; } else { $itemsInRow++; $html .= '"; @@ -1460,7 +1460,7 @@ abstract class CommonDocGenerator // set cell padding with column title definition $pdf->setCellPaddings($colDef['title']['padding'][3], $colDef['title']['padding'][0], $colDef['title']['padding'][1], 0.5); } - else{ + else { // set cell padding with column title definition $pdf->setCellPaddings($colDef['title']['padding'][3], $colDef['title']['padding'][0], $colDef['title']['padding'][1], $colDef['title']['padding'][2]); } @@ -1501,17 +1501,17 @@ abstract class CommonDocGenerator { global $conf; - if(!empty($hidedetails)){ + if (!empty($hidedetails)) { return; } - if(empty($object->table_element)){ + if (empty($object->table_element)) { return; } // Load extrafiels if not allready does - if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); } - if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } + if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } + if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } $extrafields = $this->extrafieldsCache; @@ -1526,15 +1526,15 @@ abstract class CommonDocGenerator // Enable extrafield ? $enabled = 0; - if(!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { + if (!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { $printable = intval($extrafields->attributes[$object->table_element]['printable'][$key]); - if($printable === 1 || $printable === 2) { + if ($printable === 1 || $printable === 2) { $enabled = 1; } // Note : if $printable === 3 or 4 so, it's displayed after line description not in cols } - if (!$enabled){ continue; } // don't wast resourses if we don't need them... + if (!$enabled) { continue; } // don't wast resourses if we don't need them... // Load language if required if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $outputlangs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); @@ -1556,12 +1556,12 @@ abstract class CommonDocGenerator ); $alignTypeRight = array('double', 'int', 'price'); - if(in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeRight)){ + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeRight)) { $def['content']['align'] = 'R'; } - $alignTypeLeft = array('text', 'html'); - if(in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeLeft)){ + $alignTypeLeft = array('text', 'html'); + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeLeft)) { $def['content']['align'] = 'L'; } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index c715f53194a..9a804256dac 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -683,7 +683,7 @@ class Conf if (!isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0; - if (!isset($this->global->MAIN_JS_GRAPH)) $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library + if (!isset($this->global->MAIN_JS_GRAPH)) $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com'; if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567'; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 8edad43dce0..d59ab8ce6bc 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -115,7 +115,7 @@ class DolGraph $this->_library = $library; if ($this->_library == 'auto') { - $this->_library = (empty($conf->global->MAIN_JS_GRAPH) ? 'jflot': $conf->global->MAIN_JS_GRAPH); + $this->_library = (empty($conf->global->MAIN_JS_GRAPH) ? 'jflot' : $conf->global->MAIN_JS_GRAPH); } } @@ -535,7 +535,7 @@ class DolGraph public function GetMaxValueInData() { // phpcs:enable - if (! is_array($this->data)) return 0; + if (!is_array($this->data)) return 0; $k = 0; $vals = array(); @@ -564,7 +564,7 @@ class DolGraph public function GetMinValueInData() { // phpcs:enable - if (! is_array($this->data)) return 0; + if (!is_array($this->data)) return 0; $k = 0; $vals = array(); @@ -748,9 +748,9 @@ class DolGraph } // Start the div that will contains all the graph - $dolxaxisvertical=''; - if (count($this->data) > 20) $dolxaxisvertical='dol-xaxis-vertical'; - $this->stringtoshow .= '
'."\n"; + $dolxaxisvertical = ''; + if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical'; + $this->stringtoshow .= '
'."\n"; $this->stringtoshow .= ''."\n"; @@ -607,8 +607,8 @@ function getStructuredData($type, $data = array()) elseif ($type == 'product') { $ret = ''."\n"; - $ret.= ''."\n"; + $ret .= ''."\n"; } return $ret; } @@ -656,55 +656,55 @@ function getStructuredData($type, $data = array()) */ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25) { - global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers. + global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers. $error = 0; $arrayresult = array('code'=>'', 'list'=>array()); - if (! is_object($weblangs)) $weblangs = $langs; + if (!is_object($weblangs)) $weblangs = $langs; if (empty($searchstring)) { $error++; - $arrayresult['code']='KO'; - $arrayresult['message']=$weblangs->trans("EmptySearchString"); + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = $weblangs->trans("EmptySearchString"); } elseif (dol_strlen($searchstring) < 2) { $weblangs->load("errors"); $error++; - $arrayresult['code']='KO'; - $arrayresult['message']=$weblangs->trans("ErrorSearchCriteriaTooSmall"); + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = $weblangs->trans("ErrorSearchCriteriaTooSmall"); } - elseif (! in_array($type, array('', 'page'))) + elseif (!in_array($type, array('', 'page'))) { $error++; - $arrayresult['code']='KO'; - $arrayresult['message']='Bad value for parameter $type'; + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = 'Bad value for parameter $type'; } $searchdone = 0; $found = 0; - if (! $error && (empty($max) || ($found < $max)) && (preg_match('/meta/', $algo) || preg_match('/content/', $algo))) + if (!$error && (empty($max) || ($found < $max)) && (preg_match('/meta/', $algo) || preg_match('/content/', $algo))) { $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page'; - $sql.= " WHERE fk_website = ".$website->id; - if ($type) $sql.= " AND type_container = '".$db->escape($type)."'"; - $sql.= " AND ("; + $sql .= " WHERE fk_website = ".$website->id; + if ($type) $sql .= " AND type_container = '".$db->escape($type)."'"; + $sql .= " AND ("; $searchalgo = ''; if (preg_match('/meta/', $algo)) { - $searchalgo.= ($searchalgo?' OR ':'')."title LIKE '%".$db->escape($searchstring)."%' OR description LIKE '%".$db->escape($searchstring)."%'"; - $searchalgo.= ($searchalgo?' OR ':'')."keywords LIKE '".$db->escape($searchstring).",%' OR keywords LIKE '% ".$db->escape($searchstring)."%'"; // TODO Use a better way to scan keywords + $searchalgo .= ($searchalgo ? ' OR ' : '')."title LIKE '%".$db->escape($searchstring)."%' OR description LIKE '%".$db->escape($searchstring)."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."keywords LIKE '".$db->escape($searchstring).",%' OR keywords LIKE '% ".$db->escape($searchstring)."%'"; // TODO Use a better way to scan keywords } if (preg_match('/content/', $algo)) { - $searchalgo.= ($searchalgo?' OR ':'')."content LIKE '%".$db->escape($searchstring)."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."content LIKE '%".$db->escape($searchstring)."%'"; } - $sql.=$searchalgo; - $sql.= ")"; - $sql.= $db->plimit($max); + $sql .= $searchalgo; + $sql .= ")"; + $sql .= $db->plimit($max); $resql = $db->query($sql); if ($resql) @@ -716,7 +716,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25) { $tmpwebsitepage = new WebsitePage($db); $tmpwebsitepage->fetch($obj->rowid); - if ($tmpwebsitepage->id > 0) $arrayresult['list'][]=$tmpwebsitepage; + if ($tmpwebsitepage->id > 0) $arrayresult['list'][] = $tmpwebsitepage; $found++; } $i++; @@ -725,69 +725,69 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25) else { $error++; - $arrayresult['code']=$db->lasterrno(); - $arrayresult['message']=$db->lasterror(); + $arrayresult['code'] = $db->lasterrno(); + $arrayresult['message'] = $db->lasterror(); } $searchdone = 1; } - if (! $error && (empty($max) || ($found < $max)) && (preg_match('/sitefiles/', $algo))) + if (!$error && (empty($max) || ($found < $max)) && (preg_match('/sitefiles/', $algo))) { global $dolibarr_main_data_root; - $pathofwebsite=$dolibarr_main_data_root.'/website/'.$website->ref; - $filehtmlheader=$pathofwebsite.'/htmlheader.html'; - $filecss=$pathofwebsite.'/styles.css.php'; - $filejs=$pathofwebsite.'/javascript.js.php'; - $filerobot=$pathofwebsite.'/robots.txt'; - $filehtaccess=$pathofwebsite.'/.htaccess'; - $filemanifestjson=$pathofwebsite.'/manifest.json.php'; - $filereadme=$pathofwebsite.'/README.md'; + $pathofwebsite = $dolibarr_main_data_root.'/website/'.$website->ref; + $filehtmlheader = $pathofwebsite.'/htmlheader.html'; + $filecss = $pathofwebsite.'/styles.css.php'; + $filejs = $pathofwebsite.'/javascript.js.php'; + $filerobot = $pathofwebsite.'/robots.txt'; + $filehtaccess = $pathofwebsite.'/.htaccess'; + $filemanifestjson = $pathofwebsite.'/manifest.json.php'; + $filereadme = $pathofwebsite.'/README.md'; $filecontent = file_get_contents($filehtmlheader); if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $arrayresult['list'][]=array('type'=>'website_htmlheadercontent'); + $arrayresult['list'][] = array('type'=>'website_htmlheadercontent'); } $filecontent = file_get_contents($filecss); if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $arrayresult['list'][]=array('type'=>'website_csscontent'); + $arrayresult['list'][] = array('type'=>'website_csscontent'); } $filecontent = file_get_contents($filejs); if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $arrayresult['list'][]=array('type'=>'website_jscontent'); + $arrayresult['list'][] = array('type'=>'website_jscontent'); } $filerobot = file_get_contents($filerobot); if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $arrayresult['list'][]=array('type'=>'website_robotcontent'); + $arrayresult['list'][] = array('type'=>'website_robotcontent'); } $searchdone = 1; } - if (! $error) + if (!$error) { if ($searchdone) { - $arrayresult['code']='OK'; + $arrayresult['code'] = 'OK'; if (empty($arrayresult['list'])) { - $arrayresult['code']='KO'; - $arrayresult['message']=$weblangs->trans("NoRecordFound"); + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = $weblangs->trans("NoRecordFound"); } } else { $error++; - $arrayresult['code']='KO'; - $arrayresult['message']='No supported algorithm found'; + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = 'No supported algorithm found'; } } diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 5e8711e09d1..de51783b7f1 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -184,7 +184,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) else dol_print_error($db); } // Add canonical reference - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; // Add manifest.json on homepage $tplcontent .= 'use_manifest) { print \'\'."\n"; } ?>'."\n"; $tplcontent .= ''."\n"; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 4f9558de8ae..87f11decb5e 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -169,214 +169,214 @@ class modProduct extends DolibarrModules // Exports //-------- - $r=0; + $r = 0; $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label", - 'p.fk_product_type'=>'Type','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy", - 'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.customcode'=>'CustomCode','p.fk_country'=>'IDCountry', + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "Products"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array( + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", + 'p.fk_product_type'=>'Type', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", + 'p.description'=>"Description", 'p.url'=>"PublicUrl", + 'p.customcode'=>'CustomCode', 'p.fk_country'=>'IDCountry', 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.weight_units'=>"WeightUnits", 'p.length'=>"Length", 'p.length_units'=>"LengthUnits", 'p.width'=>"Width", 'p.width_units'=>"WidthUnits", 'p.height'=>"Height", 'p.height_units'=>"HeightUnits", 'p.surface'=>"Surface", 'p.surface_units'=>"SurfaceUnits", 'p.volume'=>"Volume", 'p.volume_units'=>"VolumeUnits", 'p.duration'=>"Duration", 'p.finished' => 'Nature', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', - 'p.datec'=>'DateCreation','p.tms'=>'DateModification' + 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text", - 'p.fk_product_type'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.description'=>"Text",'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text",'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text",'p.note_public'=>"Text", - 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric", + if (!empty($conf->fournisseur->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; + $this->export_TypeFields_array[$r] = array( + 'p.ref'=>"Text", 'p.label'=>"Text", + 'p.fk_product_type'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", + 'p.description'=>"Text", 'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", + 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.duration'=>"Text", 'p.finished' => 'Numeric', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric', - 'p.datec'=>'Date','p.tms'=>'Date' + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', + 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); - $this->export_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'product','p.pmp'=>'product')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'product','p.pmp'=>'product')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; - if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + if (!empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); + $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; + if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Exports product multiprice $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", - 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", + 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; //$this->export_TypeFields_array[$r]=array( // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', // 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", // 'p.datec'=>'Date','p.tms'=>'Date' //); - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", - 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", + 'pr.price_base_type'=>"product", 'pr.price_level'=>"product", 'pr.price'=>"product", 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', 'pr.recuperableonly'=>'product', 'pr.date_price'=>"product"); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { // Exports product multiprice $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 's.nom'=>'ThirdParty', 'pr.price_base_type'=>"PriceBase", - 'pr.price'=>"PriceUnitPriceHT",'pr.price_ttc'=>"PriceUnitPriceTTC", - 'pr.price_min'=>"MinPriceUnitPriceHT",'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", + 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", + 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", 'pr.tva_tx'=>'PriceVATRate', 'pr.default_vat_code'=>'PriceVATCode', 'pr.datec'=>'DateCreation'); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", 's.nom'=>'company', - 'pr.price_base_type'=>"product",'pr.price'=>"product", + 'pr.price_base_type'=>"product", 'pr.price'=>"product", 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', 'pr.default_vat_code'=>'product', 'pr.recuperableonly'=>'product', 'pr.datec'=>"product"); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) { // Exports virtual products $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode",'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', - 'p.weight'=>"Weight",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.customcode'=>'CustomCode', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", - 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array( + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", + 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text",'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text",'p.accountancy_code_buy_intra'=>"Text",'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text",'p.note_public'=>"Text", - 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.customcode'=>'Text', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.datec'=>'Date','p.tms'=>'Date' + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); + $this->export_TypeFields_array[$r] = array( + 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", + 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", + 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); - $this->export_entities_array[$r]=array( - 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_sell_intra'=>'virtualproduct','p.accountancy_code_sell_export'=>'virtualproduct', - 'p.accountancy_code_buy'=>'virtualproduct','p.accountancy_code_buy_intra'=>'virtualproduct','p.accountancy_code_buy_export'=>'virtualproduct', - 'p.note'=>"virtualproduct",'p.length'=>"virtualproduct", - 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', - 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", - 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); + $this->export_entities_array[$r] = array( + 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", + 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', + 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', + 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", + 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', + 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", + 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct" ); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile - $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } // Imports //-------- - $r=0; + $r = 0; // Import list of products $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="Products"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use a different icon from the one defined in import_icon - $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); - $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array( + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "Products"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon + $this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields'); + $this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array( 'p.ref' => "Ref*", 'p.label' => "Label*", 'p.fk_product_type' => "Type*", @@ -576,7 +576,7 @@ class modProduct extends DolibarrModules ) ); - if (! is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); + if (!is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( 'p.fk_unit' => array( 'rule' => 'fetchidfromcodeorlabel', diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 822c6bf699f..e99f94aa154 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -136,216 +136,216 @@ class modService extends DolibarrModules // Exports //-------- - $r=0; + $r = 0; $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("service","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label", - 'p.fk_product_type'=>'Type','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy", - 'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.customcode'=>'CustomCode','p.fk_country'=>'IDCountry', + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("service", "export")); + $this->export_fields_array[$r] = array( + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", + 'p.fk_product_type'=>'Type', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", + 'p.description'=>"Description", 'p.url'=>"PublicUrl", + 'p.customcode'=>'CustomCode', 'p.fk_country'=>'IDCountry', 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', - 'p.weight'=>"Weight",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume", + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.width'=>"Width", 'p.height'=>"Height", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.duration'=>"Duration", 'p.finished' => 'Nature', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', - 'p.datec'=>'DateCreation','p.tms'=>'DateModification' + 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text", - 'p.fk_product_type'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text", - 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", + if (!empty($conf->fournisseur->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; + $this->export_TypeFields_array[$r] = array( + 'p.ref'=>"Text", 'p.label'=>"Text", + 'p.fk_product_type'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", + 'p.description'=>"Text", 'p.url'=>"Text", 'p.accountancy_code_sell'=>"Text", + 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text",'p.note_public'=>"Text", - 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric", + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.duration'=>"Text", 'p.finished' => 'Numeric', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric', - 'p.datec'=>'Date','p.tms'=>'Date' + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', + 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); - $this->export_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'product','p.pmp'=>'product')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'product','p.pmp'=>'product')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; - if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + if (!empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); + $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; + if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) { - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Exports product multiprice $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", - 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", + 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; //$this->export_TypeFields_array[$r]=array( // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', // 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", // 'p.datec'=>'Date','p.tms'=>'Date' //); - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", - 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", + 'pr.price_base_type'=>"product", 'pr.price_level'=>"product", 'pr.price'=>"product", 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', 'pr.recuperableonly'=>'product', 'pr.date_price'=>"product"); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { // Exports product multiprice $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 's.nom'=>'ThirdParty', 'pr.price_base_type'=>"PriceBase", - 'pr.price'=>"PriceUnitPriceHT",'pr.price_ttc'=>"PriceUnitPriceTTC", - 'pr.price_min'=>"MinPriceUnitPriceHT",'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", + 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", + 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", 'pr.tva_tx'=>'PriceVATRate', 'pr.default_vat_code'=>'PriceVATCode', 'pr.datec'=>'DateCreation'); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", 's.nom'=>'company', - 'pr.price_base_type'=>"product",'pr.price'=>"product", + 'pr.price_base_type'=>"product", 'pr.price'=>"product", 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', 'pr.default_vat_code'=>'product', 'pr.recuperableonly'=>'product', 'pr.datec'=>"product"); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) { // Exports virtual products $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode",'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', - 'p.weight'=>"Weight",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.customcode'=>'CustomCode', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", - 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array( + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", + 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text",'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text",'p.accountancy_code_buy_intra'=>"Text",'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text",'p.note_public'=>"Text", - 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.customcode'=>'Text', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.datec'=>'Date','p.tms'=>'Date' + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); + $this->export_TypeFields_array[$r] = array( + 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", + 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", + 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); - $this->export_entities_array[$r]=array( - 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_sell_intra'=>'virtualproduct','p.accountancy_code_sell_export'=>'virtualproduct', - 'p.accountancy_code_buy'=>'virtualproduct','p.accountancy_code_buy_intra'=>'virtualproduct','p.accountancy_code_buy_export'=>'virtualproduct', - 'p.note'=>"virtualproduct",'p.length'=>"virtualproduct", - 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', - 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", - 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); + $this->export_entities_array[$r] = array( + 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", + 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', + 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', + 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", + 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', + 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", + 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct" ); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile - $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } } // Imports //-------- - $r=0; + $r = 0; // Import list of services $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="Products"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use a different icon from the one defined in import_icon - $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); - $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array( + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "Products"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon + $this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields'); + $this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array( 'p.ref' => "Ref*", 'p.label' => "Label*", 'p.fk_product_type' => "Type*", @@ -543,7 +543,7 @@ class modService extends DolibarrModules ) ); - if (! is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); + if (!is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( 'p.fk_unit' => array( 'rule' => 'fetchidfromcodeorlabel', diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 8859ce4ba9d..6c25b5c07b5 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -28,7 +28,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -154,7 +154,7 @@ $langs->load("modulebuilder"); selectarray('type', $type2label, GETPOST('type', 'alpha')); ?> - + - +global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?> - + - + - + - + - + + - +multicompany->enabled) { ?> - +
'; - $html .= '' . $field->label . ' : '; + $html .= ''; + $html .= ''.$field->label.' : '; $html .= $field->content; $html .= "'; - $html .= '' . $field->label . ' :'; + $html .= ''.$field->label.' :'; $html .= "
trans("Size"); ?>
trans("Size"); ?>
@@ -176,36 +176,36 @@ $langs->load("modulebuilder");
trans("Position"); ?>
trans("Position"); ?>
trans("LanguageFile"); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?>
trans("DefaultValue").' ('.$langs->trans("Database").')'; ?>
trans("DefaultValue").' ('.$langs->trans("Database").')'; ?>
trans("Unique"); ?>>
trans("Unique"); ?>>
trans("Required"); ?>>
trans("Required"); ?>>
trans("AlwaysEditable"); ?>>
trans("AlwaysEditable"); ?>>
textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> -
textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
trans("Totalizable"); ?>>
trans("Totalizable"); ?>>
textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?>
trans("AllEntities"); ?>>
trans("AllEntities"); ?>>
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 4dc47bbf031..d0eaaec25f2 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -27,7 +27,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -54,7 +54,7 @@ $langs->load("modulebuilder"); var list = jQuery("#list"); var totalizable = jQuery("#totalizable"); load("modulebuilder"); attributes[$elementtype]['label'][$attrname]; -$type=$extrafields->attributes[$elementtype]['type'][$attrname]; -$size=$extrafields->attributes[$elementtype]['size'][$attrname]; -$computed=$extrafields->attributes[$elementtype]['computed'][$attrname]; -$default=$extrafields->attributes[$elementtype]['default'][$attrname]; -$unique=$extrafields->attributes[$elementtype]['unique'][$attrname]; -$required=$extrafields->attributes[$elementtype]['required'][$attrname]; -$pos=$extrafields->attributes[$elementtype]['pos'][$attrname]; -$alwayseditable=$extrafields->attributes[$elementtype]['alwayseditable'][$attrname]; -$param=$extrafields->attributes[$elementtype]['param'][$attrname]; -$perms=$extrafields->attributes[$elementtype]['perms'][$attrname]; -$langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname]; -$list=$extrafields->attributes[$elementtype]['list'][$attrname]; +$label = $extrafields->attributes[$elementtype]['label'][$attrname]; +$type = $extrafields->attributes[$elementtype]['type'][$attrname]; +$size = $extrafields->attributes[$elementtype]['size'][$attrname]; +$computed = $extrafields->attributes[$elementtype]['computed'][$attrname]; +$default = $extrafields->attributes[$elementtype]['default'][$attrname]; +$unique = $extrafields->attributes[$elementtype]['unique'][$attrname]; +$required = $extrafields->attributes[$elementtype]['required'][$attrname]; +$pos = $extrafields->attributes[$elementtype]['pos'][$attrname]; +$alwayseditable = $extrafields->attributes[$elementtype]['alwayseditable'][$attrname]; +$param = $extrafields->attributes[$elementtype]['param'][$attrname]; +$perms = $extrafields->attributes[$elementtype]['perms'][$attrname]; +$langfile = $extrafields->attributes[$elementtype]['langfile'][$attrname]; +$list = $extrafields->attributes[$elementtype]['list'][$attrname]; $totalizable = $extrafields->attributes[$elementtype]['totalizable'][$attrname]; -$help=$extrafields->attributes[$elementtype]['help'][$attrname]; -$entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname]; -$printable=$extrafields->attributes[$elementtype]['printable'][$attrname]; +$help = $extrafields->attributes[$elementtype]['help'][$attrname]; +$entitycurrentorall = $extrafields->attributes[$elementtype]['entityid'][$attrname]; +$printable = $extrafields->attributes[$elementtype]['printable'][$attrname]; -if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) +if ((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) { $param_chain = ''; foreach ($param['options'] as $key => $value) { - if(strlen($key)) + if (strlen($key)) { $param_chain .= $key.','.$value."\n"; } } } -elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password') || ($type == 'separate')) +elseif (($type == 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password') || ($type == 'separate')) { - $paramlist=array_keys($param['options']); + $paramlist = array_keys($param['options']); $param_chain = $paramlist[0]; } ?> @@ -192,10 +192,10 @@ elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($t - + - +global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?> @@ -257,23 +257,23 @@ else - + - + - + + - +multicompany->enabled) { ?> - +
trans("Type"); ?> array('varchar', 'phone', 'mail', 'url', 'select', 'password', 'text', 'html'), - 'text'=>array('text','html'), - 'html'=>array('text','html'), + 'text'=>array('text', 'html'), + 'html'=>array('text', 'html'), 'password'=>array('password', 'varchar'), 'mail'=>array('varchar', 'phone', 'mail', 'url', 'select'), 'url'=>array('varchar', 'phone', 'mail', 'url', 'select'), @@ -204,12 +204,12 @@ $typewecanchangeinto=array( ); if (in_array($type, array_keys($typewecanchangeinto))) { - $newarray=array(); + $newarray = array(); print '
trans("Position"); ?>
trans("Position"); ?>
trans("LanguageFile"); ?>
trans("LanguageFile"); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
trans("DefaultValue").' ('.$langs->trans("Database").')'; ?>
trans("Unique"); ?>>
trans("Unique"); ?>>
trans("Required"); ?>>
trans("Required"); ?>>
trans("AlwaysEditable"); ?>>
trans("AlwaysEditable"); ?>>
textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> -
textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")); ?>>
textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")); ?>>
textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?>
trans("AllEntities"); ?>>
trans("AllEntities"); ?>>
diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index a59350d8678..b2bb69aa0bf 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -25,7 +25,7 @@ */ // Protection to avoid direct call of template -if (empty($langs) || ! is_object($langs)) +if (empty($langs) || !is_object($langs)) { print "Error, template page can't be called as URL"; exit; @@ -66,7 +66,7 @@ print ''.$langs->trans("AlwaysEditable").''; print ''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''; print ''.$form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")).''; print ''.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).''; -if ($conf->multicompany->enabled){ +if ($conf->multicompany->enabled) { print ''.$langs->trans("Entities").''; } print ' '; @@ -74,16 +74,16 @@ print "\n"; if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) { - foreach($extrafields->attributes[$elementtype]['type'] as $key => $value) + foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value) { // Load language if required - if (! empty($extrafields->attributes[$elementtype]['langfile'][$key])) { + if (!empty($extrafields->attributes[$elementtype]['langfile'][$key])) { $langs->load($extrafields->attributes[$elementtype]['langfile'][$key]); } print ''; print "".$extrafields->attributes[$elementtype]['pos'][$key]."\n"; - print "".$extrafields->attributes[$elementtype]['label'][$key]."\n"; // We don't translate here, we want admin to know what is the key not translated value + print "".$extrafields->attributes[$elementtype]['label'][$key]."\n"; // We don't translate here, we want admin to know what is the key not translated value print "".$langs->trans($extrafields->attributes[$elementtype]['label'][$key])."\n"; print "".$key."\n"; print "".$type2label[$extrafields->attributes[$elementtype]['type'][$key]]."\n"; @@ -95,7 +95,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel print ''.$extrafields->attributes[$elementtype]['list'][$key]."\n"; print ''.$extrafields->attributes[$elementtype]['printable'][$key]."\n"; print ''.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."\n"; - if (! empty($conf->multicompany->enabled)) { + if (!empty($conf->multicompany->enabled)) { print ''; if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) { @@ -103,7 +103,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel } else { global $multicompanylabel_cache; - if (! is_array($multicompanylabel_cache)) $multicompanylabel_cache = array(); + if (!is_array($multicompanylabel_cache)) $multicompanylabel_cache = array(); if (empty($multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]])) { global $mc; $mc->getInfo($extrafields->attributes[$elementtype]['entityid'][$key]); @@ -120,8 +120,8 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel } else { - $colspan=13; - if (! empty($conf->multicompany->enabled)) $colspan++; + $colspan = 13; + if (!empty($conf->multicompany->enabled)) $colspan++; print ''; print ''; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index e6de4520ba4..eca100731ac 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -128,10 +128,10 @@ if ($permission)
select_contacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp'); + $nbofcontacts = $form->select_contacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp'); $newcardbutton = ''; - if (! empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer) + if (!empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer) { $newcardbutton .= ''; } @@ -140,13 +140,13 @@ if ($permission)
element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc; + $tmpobject = $object; + if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc; $formcompany->selectTypeContact($tmpobject, '', 'type', 'external', 'position', 0, 'minwidth100imp'); ?>
 
- "> + ">
@@ -162,11 +162,11 @@ print "
"; // TODO: replace this with direct SQL string to use $db->sort($sortfield, $sortorder) $list = array(); -foreach(array('internal', 'external') as $source) +foreach (array('internal', 'external') as $source) { $tmpobject = $object; - if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) + if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { $tmpobject = $objectsrc; } @@ -200,27 +200,27 @@ foreach(array('internal', 'external') as $source) { $entry->thirdparty = $conf->global->MAIN_INFO_SOCIETE_NOM; } - elseif (! $tab[$i]['socid']) + elseif (!$tab[$i]['socid']) { $entry->thirdparty = ""; } - if ($tab[$i]['source']=='internal') + if ($tab[$i]['source'] == 'internal') { $userstatic->fetch($tab[$i]['id']); $entry->contact = $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); } - elseif ($tab[$i]['source']=='external') + elseif ($tab[$i]['source'] == 'external') { $contactstatic->fetch($tab[$i]['id']); - $entry->contact =$contactstatic->getNomUrl(1, '', 0, '', 0, 0); + $entry->contact = $contactstatic->getNomUrl(1, '', 0, '', 0, 0); } - if ($tab[$i]['source']=='internal') + if ($tab[$i]['source'] == 'internal') { $entry->status = $userstatic->LibStatut($tab[$i]['statuscontact'], 3); } - elseif ($tab[$i]['source']=='external') + elseif ($tab[$i]['source'] == 'external') { $entry->status = $contactstatic->LibStatut($tab[$i]['statuscontact'], 3); } @@ -279,7 +279,7 @@ print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], " print_liste_field_titre($arrayfields['link']['label'], $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder, 'center maxwidthsearch '); print ""; -foreach($list as $entry) +foreach ($list as $entry) { print ''; @@ -314,8 +314,8 @@ print ""; print "\n"; if (is_object($hookmanager)) { $hookmanager->initHooks(array('contacttpl')); - $parameters=array(); - $reshook=$hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); + $parameters = array(); + $reshook = $hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); } print "\n"; diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index 2ef606afa0b..45ca9a29197 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -37,14 +37,14 @@ if (empty($conf) || !is_object($conf)) executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { $params = array(); if (isset($tpl_context)) $params['tpl_context'] = $tpl_context; - $params['cols']=$parameters['colspanvalue']; + $params['cols'] = $parameters['colspanvalue']; print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params } diff --git a/htdocs/core/tpl/extrafields_edit.tpl.php b/htdocs/core/tpl/extrafields_edit.tpl.php index 8a04aa32dea..dbc2b9745cd 100644 --- a/htdocs/core/tpl/extrafields_edit.tpl.php +++ b/htdocs/core/tpl/extrafields_edit.tpl.php @@ -26,7 +26,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -37,12 +37,12 @@ if (empty($conf) || ! is_object($conf)) executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - $params=array(); - $params['cols']=$parameters['colspanvalue']; + $params = array(); + $params['cols'] = $parameters['colspanvalue']; print $object->showOptionals($extrafields, 'edit', $params); } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 510bb888813..5fc268013c6 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -378,7 +378,7 @@ if ($nolinesbefore) { "> global->PRODUCT_USE_UNITS)) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; print $form->selectUnits($line->fk_unit, "units"); @@ -636,7 +636,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { console.log("We are in a price per qty context, we do not call ajax/product"); } else { - global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?> + global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?> if (isNaN(pbq)) { console.log("We use experimental option PRODUIT_CUSTOMER_PRICES_BY_QTY or PRODUIT_CUSTOMER_PRICES_BY_QTY but we are not yet able to get the id of pbq from product combo list, so load of price may be 0 if product has differet prices"); } // Get the HT price for the product and display it diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index 66e1b6fa4cd..7acd977e714 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -59,13 +59,13 @@ class InterfaceLogevents extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) + if (!empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) - $key='MAIN_LOGEVENTS_'.$action; + $key = 'MAIN_LOGEVENTS_'.$action; //dol_syslog("xxxxxxxxxxx".$key); - if (empty($conf->global->$key)) return 0; // Log events not enabled for this action + if (empty($conf->global->$key)) return 0; // Log events not enabled for this action - if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) + if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) $date = dol_now(); @@ -76,18 +76,18 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text="(UserLogged,".$object->login.")"; - $text.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg); - $desc="(UserLogged,".$object->login.")"; - $desc.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg); + $text = "(UserLogged,".$object->login.")"; + $text .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); + $desc = "(UserLogged,".$object->login.")"; + $desc .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); } if ($action == 'USER_LOGIN_FAILED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // Initialisation donnees (date,duree,texte,desc) - $text=$object->trigger_mesg; // Message direct - $desc=$object->trigger_mesg; // Message direct + $text = $object->trigger_mesg; // Message direct + $desc = $object->trigger_mesg; // Message direct } if ($action == 'USER_LOGOUT') { @@ -95,8 +95,8 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text="(UserLogoff,".$object->login.")"; - $desc="(UserLogoff,".$object->login.")"; + $text = "(UserLogoff,".$object->login.")"; + $desc = "(UserLogoff,".$object->login.")"; } if ($action == 'USER_CREATE') { @@ -104,8 +104,8 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("NewUserCreated", $object->login); - $desc=$langs->transnoentities("NewUserCreated", $object->login); + $text = $langs->transnoentities("NewUserCreated", $object->login); + $desc = $langs->transnoentities("NewUserCreated", $object->login); } elseif ($action == 'USER_MODIFY') { @@ -113,8 +113,8 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("EventUserModified", $object->login); - $desc=$langs->transnoentities("EventUserModified", $object->login); + $text = $langs->transnoentities("EventUserModified", $object->login); + $desc = $langs->transnoentities("EventUserModified", $object->login); } elseif ($action == 'USER_NEW_PASSWORD') { @@ -122,8 +122,8 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("NewUserPassword", $object->login); - $desc=$langs->transnoentities("NewUserPassword", $object->login); + $text = $langs->transnoentities("NewUserPassword", $object->login); + $desc = $langs->transnoentities("NewUserPassword", $object->login); } elseif ($action == 'USER_ENABLEDISABLE') { @@ -132,13 +132,13 @@ class InterfaceLogevents extends DolibarrTriggers // Initialisation donnees (date,duree,texte,desc) if ($object->statut == 0) { - $text=$langs->transnoentities("UserEnabled", $object->login); - $desc=$langs->transnoentities("UserEnabled", $object->login); + $text = $langs->transnoentities("UserEnabled", $object->login); + $desc = $langs->transnoentities("UserEnabled", $object->login); } if ($object->statut == 1) { - $text=$langs->transnoentities("UserDisabled", $object->login); - $desc=$langs->transnoentities("UserDisabled", $object->login); + $text = $langs->transnoentities("UserDisabled", $object->login); + $desc = $langs->transnoentities("UserDisabled", $object->login); } } elseif ($action == 'USER_DELETE') @@ -146,8 +146,8 @@ class InterfaceLogevents extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("UserDeleted", $object->login); - $desc=$langs->transnoentities("UserDeleted", $object->login); + $text = $langs->transnoentities("UserDeleted", $object->login); + $desc = $langs->transnoentities("UserDeleted", $object->login); } // Groupes @@ -156,24 +156,24 @@ class InterfaceLogevents extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("NewGroupCreated", $object->name); - $desc=$langs->transnoentities("NewGroupCreated", $object->name); + $text = $langs->transnoentities("NewGroupCreated", $object->name); + $desc = $langs->transnoentities("NewGroupCreated", $object->name); } elseif ($action == 'GROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("GroupModified", $object->name); - $desc=$langs->transnoentities("GroupModified", $object->name); + $text = $langs->transnoentities("GroupModified", $object->name); + $desc = $langs->transnoentities("GroupModified", $object->name); } elseif ($action == 'GROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("GroupDeleted", $object->name); - $desc=$langs->transnoentities("GroupDeleted", $object->name); + $text = $langs->transnoentities("GroupDeleted", $object->name); + $desc = $langs->transnoentities("GroupDeleted", $object->name); } // If not found @@ -186,28 +186,28 @@ class InterfaceLogevents extends DolibarrTriggers */ // Add more information into desc from the context property - if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit']; + if (!empty($desc) && !empty($object->context['audit'])) $desc .= ' - '.$object->context['audit']; // Add entry in event table include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; - $event=new Events($this->db); - $event->type=$action; - $event->dateevent=$date; - $event->label=$text; - $event->description=$desc; - $event->user_agent=$_SERVER["HTTP_USER_AGENT"]; + $event = new Events($this->db); + $event->type = $action; + $event->dateevent = $date; + $event->label = $text; + $event->description = $desc; + $event->user_agent = $_SERVER["HTTP_USER_AGENT"]; - $result=$event->create($user); + $result = $event->create($user); if ($result > 0) { return 1; } else { - $error ="Failed to insert security event: ".$event->error; + $error = "Failed to insert security event: ".$event->error; $this->errors[] = $error; - $this->error=$error; + $this->error = $error; dol_syslog(get_class($this).": ".$error, LOG_ERR); return -1; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 161ebe6cd73..3fe9d63c380 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -71,7 +71,7 @@ class InterfaceActionsAuto extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing + if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing $key = 'MAIN_AGENDA_ACTIONAUTO_'.$action; @@ -82,25 +82,25 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("agenda"); - if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; + if (empty($object->actiontypecode)) $object->actiontypecode = 'AC_OTH_AUTO'; // Actions if ($action == 'COMPANY_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","companies")); + $langs->loadLangs(array("agenda", "other", "companies")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr", $object->name); - $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr", $object->name); - if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")"; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name); + $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name); + if (!empty($object->prefix)) $object->actionmsg .= " (".$object->prefix.")"; - $object->sendtoid=0; - $object->socid=$object->id; + $object->sendtoid = 0; + $object->socid = $object->id; } elseif ($action == 'COMPANY_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR); @@ -110,22 +110,22 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'CONTRACT_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","contracts")); + $langs->loadLangs(array("agenda", "other", "contracts")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'CONTRACT_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","contracts")); + $langs->loadLangs(array("agenda", "other", "contracts")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ContractSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ContractSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -134,22 +134,22 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'PROPAL_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPAL_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ProposalSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -158,82 +158,82 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'PROPAL_CLOSE_SIGNED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPAL_CLASSIFY_BILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPAL_CLOSE_REFUSED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","orders")); + $langs->loadLangs(array("agenda", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_CLOSE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_CLASSIFY_BILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_CANCEL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("OrderSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -242,32 +242,32 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'BILL_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_UNVALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -276,69 +276,69 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'BILL_PAYED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); // Values for this action can't be defined by caller. - $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_CANCEL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'FICHINTER_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); - $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; + $object->sendtoid = 0; + $object->fk_element = 0; + $object->elementtype = ''; } elseif ($action == 'FICHINTER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; + $object->sendtoid = 0; + $object->fk_element = 0; + $object->elementtype = ''; } elseif ($action == 'FICHINTER_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); - $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; + $object->sendtoid = 0; + $object->fk_element = 0; + $object->elementtype = ''; } elseif ($action == 'FICHINTER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("InterventionSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -347,44 +347,44 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'FICHINTER_CLASSIFY_BILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'FICHINTER_DELETE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); - $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; + $object->sendtoid = 0; + $object->fk_element = 0; + $object->elementtype = ''; } elseif ($action == 'SHIPPING_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","sendings")); + $langs->loadLangs(array("agenda", "other", "sendings")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref)); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ShippingValidated", ($object->newref?$object->newref:$object->ref)); + $object->actionmsg = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref)); } // Parameters $object->sendtoid defined by caller @@ -393,12 +393,12 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'SHIPPING_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","sendings")); + $langs->loadLangs(array("agenda", "other", "sendings")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ShippingSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -409,10 +409,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("receptions"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref)); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ReceptionValidated", ($object->newref?$object->newref:$object->ref)); + $object->actionmsg = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref)); } // Parameters $object->sendtoid defined by caller @@ -424,10 +424,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("receptions"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ReceptionSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ReceptionSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -436,22 +436,22 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ProposalSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -460,92 +460,92 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_APPROVE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_REFUSE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_SUBMIT') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_RECEIVE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills","orders")); + $langs->loadLangs(array("agenda", "other", "bills", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("SupplierOrderSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -554,45 +554,45 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills","orders")); + $langs->loadLangs(array("agenda", "other", "bills", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); + $object->actionmsg = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); } - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills","orders")); + $langs->loadLangs(array("agenda", "other", "bills", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -601,244 +601,244 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'BILL_SUPPLIER_PAYED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_CANCELED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } // Members elseif ($action == 'MEMBER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'MEMBER_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); $member = $this->context['member']; - if (! is_object($member)) // This should not happen + if (!is_object($member)) // This should not happen { include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $member = new Adherent($this->db); $member->fetch($this->fk_adherent); } - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); - $object->sendtoid=0; - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; + $object->sendtoid = 0; + if ($object->fk_soc > 0) $object->socid = $object->fk_soc; } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); $member = $this->context['member']; - if (! is_object($member)) // This should not happen + if (!is_object($member)) // This should not happen { include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $member = new Adherent($this->db); $member->fetch($this->fk_adherent); } - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); - $object->sendtoid=0; - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; + $object->sendtoid = 0; + if ($object->fk_soc > 0) $object->socid = $object->fk_soc; } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); - $object->sendtoid=0; - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; + $object->sendtoid = 0; + if ($object->fk_soc > 0) $object->socid = $object->fk_soc; } elseif ($action == 'MEMBER_RESILIATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'MEMBER_DELETE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; - $object->sendtoid=0; + $object->sendtoid = 0; } // Projects elseif ($action == 'PROJECT_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'PROJECT_VALIDATE') + elseif ($action == 'PROJECT_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'PROJECT_MODIFY') + elseif ($action == 'PROJECT_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } // Project tasks - elseif($action == 'TASK_CREATE') + elseif ($action == 'TASK_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'TASK_MODIFY') + elseif ($action == 'TASK_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'TASK_DELETE') + elseif ($action == 'TASK_DELETE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'TICKET_ASSIGNED') + elseif ($action == 'TICKET_ASSIGNED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); if ($object->oldcopy->fk_user_assign > 0) { - $tmpuser=new User($this->db); + $tmpuser = new User($this->db); $tmpuser->fetch($object->oldcopy->fk_user_assign); - $object->actionmsg.="\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs); } else { - $object->actionmsg.="\n".$langs->transnoentities("OldUser").': '.$langs->trans("None"); + $object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$langs->trans("None"); } if ($object->fk_user_assign > 0) { - $tmpuser=new User($this->db); + $tmpuser = new User($this->db); $tmpuser->fetch($object->fk_user_assign); - $object->actionmsg.="\n".$langs->transnoentities("NewUser").': '.$tmpuser->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$tmpuser->getFullName($langs); } else { - $object->actionmsg.="\n".$langs->transnoentities("NewUser").': '.$langs->trans("None"); + $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$langs->trans("None"); } - $object->sendtoid=0; + $object->sendtoid = 0; } // TODO Merge all previous cases into this generic one else // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ... { // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). Key can be set in agenda setup if defined into c_action_trigger // Load translation files required by the page - $langs->loadLangs(array("agenda","other")); + $langs->loadLangs(array("agenda", "other")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr", $object->ref); - if (empty($object->actionmsg)) $object->actionmsg=$langs->transnoentities($action."InDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", $object->ref); + if (empty($object->actionmsg)) $object->actionmsg = $langs->transnoentities($action."InDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } $object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg; @@ -846,21 +846,21 @@ class InterfaceActionsAuto extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // Add entry in event table - $now=dol_now(); + $now = dol_now(); if (isset($_SESSION['listofnames-'.$object->trackid])) { - $attachs=$_SESSION['listofnames-'.$object->trackid]; + $attachs = $_SESSION['listofnames-'.$object->trackid]; if ($attachs && strpos($action, 'SENTBYMAIL')) { - $object->actionmsg=dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs); + $object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs); } } require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $contactforaction=new Contact($this->db); - $societeforaction=new Societe($this->db); + $contactforaction = new Contact($this->db); + $societeforaction = new Societe($this->db); // Set contactforaction if there is only 1 contact. if (is_array($object->sendtoid)) { @@ -874,7 +874,7 @@ class InterfaceActionsAuto extends DolibarrTriggers if ($object->socid > 0) $societeforaction->fetch($object->socid); elseif ($object->fk_soc > 0) $societeforaction->fetch($object->fk_soc); - $projectid = isset($object->fk_project)?$object->fk_project:0; + $projectid = isset($object->fk_project) ? $object->fk_project : 0; if ($object->element == 'project') $projectid = $object->id; $elementid = $object->id; @@ -889,20 +889,20 @@ class InterfaceActionsAuto extends DolibarrTriggers // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); - $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; - $actioncomm->note_private= $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) + $actioncomm->note_private = $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; $actioncomm->punctual = 1; - $actioncomm->percentage = -1; // Not applicable + $actioncomm->percentage = -1; // Not applicable $actioncomm->socid = $societeforaction->id; $actioncomm->contactid = $contactforaction->id; - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label) $actioncomm->email_msgid = $object->email_msgid; $actioncomm->email_from = $object->email_from; @@ -915,28 +915,28 @@ class InterfaceActionsAuto extends DolibarrTriggers // 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 (! in_array($elementtype, array('societe','contact','project'))) + if (!in_array($elementtype, array('societe', 'contact', 'project'))) { $actioncomm->fk_element = $elementid; $actioncomm->elementtype = $elementtype; } - if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) { - $actioncomm->attachedfiles=$object->attachedfiles; + if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles) > 0) { + $actioncomm->attachedfiles = $object->attachedfiles; } - if (property_exists($object, 'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) { - $actioncomm->userassigned=$object->sendtouserid; + if (property_exists($object, 'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid) > 0) { + $actioncomm->userassigned = $object->sendtouserid; } - $ret=$actioncomm->create($user); // User creating action + $ret = $actioncomm->create($user); // User creating action if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) { - if (is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths'])>0) { - foreach($object->attachedfiles['paths'] as $key=>$filespath) { + if (is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) { + foreach ($object->attachedfiles['paths'] as $key=>$filespath) { $srcfile = $filespath; - $destdir = $conf->agenda->dir_output . '/' . $ret; - $destfile = $destdir . '/' . $object->attachedfiles['names'][$key]; + $destdir = $conf->agenda->dir_output.'/'.$ret; + $destfile = $destdir.'/'.$object->attachedfiles['names'][$key]; if (dol_mkdir($destdir) >= 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_copy($srcfile, $destfile); @@ -945,7 +945,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } } - unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. + unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. if ($ret > 0) { @@ -954,8 +954,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } else { - $this->error="Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors); - $this->errors=$actioncomm->errors; + $this->error = "Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors); + $this->errors = $actioncomm->errors; dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR); return -1; diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 3cd49a20649..fd01809bc3b 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -27,27 +27,27 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","donations")); +$langs->loadLangs(array("companies", "donations")); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="d.datedon"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "d.datedon"; -$search_status=(GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_status", 'intcomma') : "-4"; -$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref=GETPOST('search_ref', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_name=GETPOST('search_name', 'alpha'); +$search_status = (GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_status", 'intcomma') : "-4"; +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_name = GETPOST('search_name', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); @@ -79,26 +79,26 @@ $fieldstosearchall = array( * View */ -$form=new Form($db); -if (! empty($conf->projet->enabled)) $projectstatic=new Project($db); +$form = new Form($db); +if (!empty($conf->projet->enabled)) $projectstatic = new Project($db); llxHeader('', $langs->trans("Donations"), 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'); -$donationstatic=new Don($db); +$donationstatic = new Don($db); // Genere requete de liste des dons $sql = "SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,"; -$sql.= " d.amount, d.fk_statut as status,"; -$sql.= " p.rowid as pid, p.ref, p.title, p.public"; -$sql.= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p"; -$sql.= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")"; +$sql .= " d.amount, d.fk_statut as status,"; +$sql .= " p.rowid as pid, p.ref, p.title, p.public"; +$sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p"; +$sql .= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")"; if ($search_status != '' && $search_status != '-4') { $sql .= " AND d.fk_statut IN (".$db->escape($search_status).")"; } if (trim($search_ref) != '') { - $sql.= natural_search('d.ref', $search_ref); + $sql .= natural_search('d.ref', $search_ref); } if (trim($search_all) != '') { @@ -137,17 +137,17 @@ if ($resql) $i = 0; $param = ''; - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($search_status && $search_status != -1) $param .= '&search_status='.urlencode($search_status); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_company) $param .= '&search_company='.urlencode($search_company); if ($search_name) $param .= '&search_name='.urlencode($search_name); if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->don->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); } print '
'."\n"; @@ -163,19 +163,19 @@ if ($resql) if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } print '
'; - print ''."\n"; + print '
'."\n"; // Filters lines print ''; print ''; - if (! empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { print ''; @@ -207,21 +207,21 @@ if ($resql) print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); print ''; print ''; print "\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", $param, "", $sortfield, $sortorder); - if (! empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "d.fk_soc", "", $param, "", $sortfield, $sortorder); } else { print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "d.societe", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder); @@ -236,15 +236,15 @@ if ($resql) $objp = $db->fetch_object($resql); print ''; - $donationstatic->id=$objp->rowid; - $donationstatic->ref=$objp->rowid; - $donationstatic->lastname=$objp->lastname; - $donationstatic->firstname=$objp->firstname; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; + $donationstatic->lastname = $objp->lastname; + $donationstatic->firstname = $objp->firstname; print ""; - if (! empty($conf->global->DONATION_USE_THIRDPARTIES)) { - $company=new Societe($db); - $result=$company->fetch($objp->socid); - if (!empty($objp->socid) && $company->id > 0) { + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { + $company = new Societe($db); + $result = $company->fetch($objp->socid); + if (!empty($objp->socid) && $company->id > 0) { print ""; } else { print ""; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 57311c2e437..11cf2477720 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -814,7 +814,7 @@ class EmailCollector extends CommonObject { //var_dump($regforval[count($regforval)-1]);exit; // Overwrite param $tmpproperty - $object->$tmpproperty = isset($regforval[count($regforval)-1]) ?trim($regforval[count($regforval)-1]) : null; + $object->$tmpproperty = isset($regforval[count($regforval) - 1]) ?trim($regforval[count($regforval) - 1]) : null; } else { @@ -1135,7 +1135,7 @@ class EmailCollector extends CommonObject if (function_exists('imap_mime_header_decode')) { $elements = imap_mime_header_decode($overview[0]->subject); $newstring = ''; - if (! empty($elements)) { + if (!empty($elements)) { $num = count($elements); for ($i = 0; $i < $num; $i++) { $newstring .= ($newstring ? ' ' : '').$elements[$i]->text; @@ -1426,7 +1426,7 @@ class EmailCollector extends CommonObject { //var_dump($regforval[count($regforval)-1]);exit; // Overwrite param $tmpproperty - $nametouseforthirdparty = isset($regforval[count($regforval)-1]) ?trim($regforval[count($regforval)-1]) : null; + $nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ?trim($regforval[count($regforval) - 1]) : null; } else { @@ -1796,10 +1796,10 @@ class EmailCollector extends CommonObject } // Create event specific on hook // this code action is hook..... for support this call - elseif (substr($operation['type'], 0, 4) == 'hook'){ + elseif (substr($operation['type'], 0, 4) == 'hook') { global $hookmanager; - if(!is_object($hookmanager)) + if (!is_object($hookmanager)) $hookmanager->initHooks(array('emailcollectorcard')); $parameters = array( @@ -1807,24 +1807,24 @@ class EmailCollector extends CommonObject 'imapemail'=>$imapemail, 'overview'=>$overview, - 'from' => $from , + 'from' => $from, 'fromtext' => $fromtext, 'actionparam'=> $operation['actionparam'], - 'thirdpartyid' => $thirdpartyid , + 'thirdpartyid' => $thirdpartyid, 'objectid'=> $objectid, 'objectemail'=> $objectemail, 'messagetext'=>$messagetext, 'subject'=>$subject, 'header'=>$header, - ) ; + ); $res = $hookmanager->executeHooks('doCollectOneCollector', $parameters, $this, $operation['type']); - if($res < 0 ) + if ($res < 0) $this->error = $hookmanager->resPrint; } @@ -2047,7 +2047,7 @@ class EmailCollector extends CommonObject // TEXT if ($p->type == 0 && $data) { - if(!empty($params['charset'])) { + if (!empty($params['charset'])) { $data = $this->convertStringEncoding($data, $params['charset']); } // Messages may be split in different parts because of inline attachments, @@ -2065,7 +2065,7 @@ class EmailCollector extends CommonObject // There are no PHP functions to parse embedded messages, // so this just appends the raw source to the main message. elseif ($p->type == 2 && $data) { - if(!empty($params['charset'])) { + if (!empty($params['charset'])) { $data = $this->convertStringEncoding($data, $params['charset']); } $plainmsg .= $data."\n\n"; @@ -2091,14 +2091,14 @@ class EmailCollector extends CommonObject */ protected function convertStringEncoding($string, $fromEncoding, $toEncoding = 'UTF-8') { - if(!$string || $fromEncoding == $toEncoding) { + if (!$string || $fromEncoding == $toEncoding) { return $string; } - $convertedString = function_exists('iconv') ? @iconv($fromEncoding, $toEncoding . '//IGNORE', $string) : null; - if(!$convertedString && extension_loaded('mbstring')) { + $convertedString = function_exists('iconv') ? @iconv($fromEncoding, $toEncoding.'//IGNORE', $string) : null; + if (!$convertedString && extension_loaded('mbstring')) { $convertedString = @mb_convert_encoding($string, $toEncoding, $fromEncoding); } - if(!$convertedString) { + if (!$convertedString) { throw new Exception('Mime string encoding conversion failed'); } return $convertedString; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 4c6b7f46e47..52540901c33 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -287,90 +287,90 @@ class Expedition extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition ("; - $sql.= "ref"; - $sql.= ", entity"; - $sql.= ", ref_customer"; - $sql.= ", ref_int"; - $sql.= ", date_creation"; - $sql.= ", fk_user_author"; - $sql.= ", date_expedition"; - $sql.= ", date_delivery"; - $sql.= ", fk_soc"; - $sql.= ", fk_projet"; - $sql.= ", fk_address"; - $sql.= ", fk_shipping_method"; - $sql.= ", tracking_number"; - $sql.= ", weight"; - $sql.= ", size"; - $sql.= ", width"; - $sql.= ", height"; - $sql.= ", weight_units"; - $sql.= ", size_units"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", model_pdf"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ") VALUES ("; - $sql.= "'(PROV)'"; - $sql.= ", ".$conf->entity; - $sql.= ", ".($this->ref_customer?"'".$this->db->escape($this->ref_customer)."'":"null"); - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".$user->id; - $sql.= ", ".($this->date_expedition>0?"'".$this->db->idate($this->date_expedition)."'":"null"); - $sql.= ", ".($this->date_delivery>0?"'".$this->db->idate($this->date_delivery)."'":"null"); - $sql.= ", ".$this->socid; - $sql.= ", ".$this->fk_project; - $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null"); - $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null"); - $sql.= ", '".$this->db->escape($this->tracking_number)."'"; - $sql.= ", ".$this->weight; - $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth - $sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth - $sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql.= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL'); - $sql.= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL'); - $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ")"; + $sql .= "ref"; + $sql .= ", entity"; + $sql .= ", ref_customer"; + $sql .= ", ref_int"; + $sql .= ", date_creation"; + $sql .= ", fk_user_author"; + $sql .= ", date_expedition"; + $sql .= ", date_delivery"; + $sql .= ", fk_soc"; + $sql .= ", fk_projet"; + $sql .= ", fk_address"; + $sql .= ", fk_shipping_method"; + $sql .= ", tracking_number"; + $sql .= ", weight"; + $sql .= ", size"; + $sql .= ", width"; + $sql .= ", height"; + $sql .= ", weight_units"; + $sql .= ", size_units"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", model_pdf"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ") VALUES ("; + $sql .= "'(PROV)'"; + $sql .= ", ".$conf->entity; + $sql .= ", ".($this->ref_customer ? "'".$this->db->escape($this->ref_customer)."'" : "null"); + $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".$user->id; + $sql .= ", ".($this->date_expedition > 0 ? "'".$this->db->idate($this->date_expedition)."'" : "null"); + $sql .= ", ".($this->date_delivery > 0 ? "'".$this->db->idate($this->date_delivery)."'" : "null"); + $sql .= ", ".$this->socid; + $sql .= ", ".$this->fk_project; + $sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null"); + $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : "null"); + $sql .= ", '".$this->db->escape($this->tracking_number)."'"; + $sql .= ", ".$this->weight; + $sql .= ", ".$this->sizeS; // TODO Should use this->trueDepth + $sql .= ", ".$this->sizeW; // TODO Should use this->trueWidth + $sql .= ", ".$this->sizeH; // TODO Should use this->trueHeight + $sql .= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL'); + $sql .= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL'); + $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null"); + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition"); $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; - $sql.= " SET ref = '(PROV".$this->id.")'"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET ref = '(PROV".$this->id.")'"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::create", LOG_DEBUG); if ($this->db->query($sql)) { // Insert of lines - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { - if (! isset($this->lines[$i]->detail_batch)) + if (!isset($this->lines[$i]->detail_batch)) { // no batch management - if (! $this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) > 0) + if (!$this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) > 0) { $error++; } } else { // with batch management - if (! $this->create_line_batch($this->lines[$i], $this->lines[$i]->array_options) > 0) + if (!$this->create_line_batch($this->lines[$i], $this->lines[$i]->array_options) > 0) { $error++; } } } - if (! $error && $this->id && $this->origin_id) + if (!$error && $this->id && $this->origin_id) { $ret = $this->add_object_linked(); if (!$ret) @@ -535,24 +535,24 @@ class Expedition extends CommonObject if (empty($id) && empty($ref) && empty($ref_ext)) return -1; $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed"; - $sql.= ", e.date_valid"; - $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; - $sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; - $sql.= ", e.fk_shipping_method, e.tracking_number"; - $sql.= ", e.note_private, e.note_public"; - $sql.= ', e.fk_incoterms, e.location_incoterms'; - $sql.= ', i.libelle as label_incoterms'; - $sql.= ', s.libelle as shipping_method'; - $sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_shipment_mode as s ON e.fk_shipping_method = s.rowid'; - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; - if ($id) $sql.= " AND e.rowid=".$id; - if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($notused) $sql.= " AND e.ref_int='".$this->db->escape($notused)."'"; + $sql .= ", e.date_valid"; + $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; + $sql .= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; + $sql .= ", e.fk_shipping_method, e.tracking_number"; + $sql .= ", e.note_private, e.note_public"; + $sql .= ', e.fk_incoterms, e.location_incoterms'; + $sql .= ', i.libelle as label_incoterms'; + $sql .= ', s.libelle as shipping_method'; + $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_shipment_mode as s ON e.fk_shipping_method = s.rowid'; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + if ($id) $sql .= " AND e.rowid=".$id; + if ($ref) $sql .= " AND e.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($notused) $sql .= " AND e.ref_int='".$this->db->escape($notused)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -565,26 +565,26 @@ class Expedition extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref; $this->socid = $obj->socid; - $this->ref_customer = $obj->ref_customer; + $this->ref_customer = $obj->ref_customer; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_valid = $this->db->jdate($obj->date_valid); - $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated - $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO deprecated - $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real - $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed + $this->date_valid = $this->db->jdate($obj->date_valid); + $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated + $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO deprecated + $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real + $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->modelpdf = $obj->model_pdf; $this->shipping_method_id = $obj->fk_shipping_method; - $this->shipping_method = $obj->shipping_method; + $this->shipping_method = $obj->shipping_method; $this->tracking_number = $obj->tracking_number; - $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility + $this->origin = ($obj->origin ? $obj->origin : 'commande'); // For compatibility $this->origin_id = $obj->origin_id; $this->billed = $obj->billed; - $this->fk_project = $obj->fk_project; + $this->fk_project = $obj->fk_project; $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units; @@ -763,7 +763,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref)); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref)); if ($result < 0) { $error++; $this->error = $mouvS->error; @@ -777,7 +777,7 @@ class Expedition extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $error++; $this->error = $mouvS->error; @@ -819,17 +819,17 @@ class Expedition extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expedition/sending/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expedition/sending/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'expedition/sending/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expedition/sending/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($numref); $dirsource = $conf->expedition->dir_output.'/sending/'.$oldref; $dirdest = $conf->expedition->dir_output.'/sending/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); @@ -852,13 +852,13 @@ class Expedition extends CommonObject } // Set new ref and current status - if (! $error) + if (!$error) { $this->ref = $numref; $this->statut = self::STATUS_VALIDATED; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -866,7 +866,7 @@ class Expedition extends CommonObject else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -1173,32 +1173,32 @@ class Expedition extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; - $error=0; - $this->error=''; + $error = 0; + $this->error = ''; $this->db->begin(); // Add a protection to refuse deleting if shipment has at least one delivery - $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment + $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment if (count($this->linkedObjectsIds) > 0) { - $this->error='ErrorThereIsSomeDeliveries'; + $this->error = 'ErrorThereIsSomeDeliveries'; $error++; } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('SHIPPING_DELETE', $user); + $result = $this->call_trigger('SHIPPING_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } } // Stock control - if (! $error && $conf->stock->enabled && + if (!$error && $conf->stock->enabled && (($conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) || ($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE && $this->statut == self::STATUS_CLOSED && $also_update_stock))) { @@ -1387,20 +1387,20 @@ class Expedition extends CommonObject // phpcs:enable global $conf, $mysoc; // TODO: recuperer les champs du document associe a part - $this->lines=array(); + $this->lines = array(); $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type"; - $sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; - $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; - $sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc, cd.rang"; - $sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; - $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; - $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; - $sql.= " WHERE ed.fk_expedition = ".$this->id; - $sql.= " AND ed.fk_origin_line = cd.rowid"; - $sql.= " ORDER BY cd.rang, ed.fk_origin_line"; + $sql .= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; + $sql .= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; + $sql .= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc, cd.rang"; + $sql .= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; + $sql .= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; + $sql .= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; + $sql .= " WHERE ed.fk_expedition = ".$this->id; + $sql .= " AND ed.fk_origin_line = cd.rowid"; + $sql .= " ORDER BY cd.rang, ed.fk_origin_line"; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1461,7 +1461,7 @@ class Expedition extends CommonObject $line->label = $obj->custom_label; $line->description = $obj->description; $line->qty_asked = $obj->qty_asked; - $line->rang = $obj->rang; + $line->rang = $obj->rang; $line->weight = $obj->weight; $line->weight_units = $obj->weight_units; $line->length = $obj->length; @@ -1750,23 +1750,23 @@ class Expedition extends CommonObject $this->origin_id = 1; $this->origin = 'commande'; - $this->note_private = 'Private note'; - $this->note_public = 'Public note'; + $this->note_private = 'Private note'; + $this->note_public = 'Public note'; $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $line=new ExpeditionLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->libelle=$langs->trans("Description")." ".$xnbp; // deprecated - $line->label=$langs->trans("Description")." ".$xnbp; - $line->qty=10; - $line->qty_asked=5; - $line->qty_shipped=4; - $line->fk_product=$this->commande->lines[$xnbp]->fk_product; + $line = new ExpeditionLigne($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->libelle = $langs->trans("Description")." ".$xnbp; // deprecated + $line->label = $langs->trans("Description")." ".$xnbp; + $line->qty = 10; + $line->qty_asked = 5; + $line->qty_shipped = 4; + $line->fk_product = $this->commande->lines[$xnbp]->fk_product; - $this->lines[]=$line; + $this->lines[] = $line; $xnbp++; } } @@ -1820,17 +1820,17 @@ class Expedition extends CommonObject $this->meths = array(); $sql = "SELECT em.rowid, em.code, em.libelle as label"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.active = 1"; - $sql.= " ORDER BY em.libelle ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + $sql .= " WHERE em.active = 1"; + $sql .= " ORDER BY em.libelle ASC"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { - $label=$langs->trans('SendingMethod'.$obj->code); - $this->meths[$obj->rowid] = ($label != 'SendingMethod'.$obj->code?$label:$obj->label); + $label = $langs->trans('SendingMethod'.$obj->code); + $this->meths[$obj->rowid] = ($label != 'SendingMethod'.$obj->code ? $label : $obj->label); } } } @@ -1848,11 +1848,11 @@ class Expedition extends CommonObject global $langs; $this->listmeths = array(); - $i=0; + $i = 0; $sql = "SELECT em.rowid, em.code, em.libelle as label, em.description, em.tracking, em.active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - if ($id!='') $sql.= " WHERE em.rowid=".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + if ($id != '') $sql .= " WHERE em.rowid=".$id; $resql = $this->db->query($sql); if ($resql) @@ -1861,8 +1861,8 @@ class Expedition extends CommonObject { $this->listmeths[$i]['rowid'] = $obj->rowid; $this->listmeths[$i]['code'] = $obj->code; - $label=$langs->trans('SendingMethod'.$obj->code); - $this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code?$label:$obj->label); + $label = $langs->trans('SendingMethod'.$obj->code); + $this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code ? $label : $obj->label); $this->listmeths[$i]['description'] = $obj->description; $this->listmeths[$i]['tracking'] = $obj->tracking; $this->listmeths[$i]['active'] = $obj->active; @@ -2316,16 +2316,16 @@ class Expedition extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("sendings"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'rouget'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->EXPEDITION_ADDON_PDF)) { + } elseif (!empty($conf->global->EXPEDITION_ADDON_PDF)) { $modele = $conf->global->EXPEDITION_ADDON_PDF; } } @@ -2567,10 +2567,10 @@ class ExpeditionLigne extends CommonObjectLine { global $langs, $conf; - $error=0; + $error = 0; // Check parameters - if (empty($this->fk_expedition) || empty($this->fk_origin_line) || ! is_numeric($this->qty)) + if (empty($this->fk_expedition) || empty($this->fk_origin_line) || !is_numeric($this->qty)) { $this->error = 'ErrorMandatoryParametersNotProvided'; return -1; @@ -2589,18 +2589,18 @@ class ExpeditionLigne extends CommonObjectLine } $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet ("; - $sql.= "fk_expedition"; - $sql.= ", fk_entrepot"; - $sql.= ", fk_origin_line"; - $sql.= ", qty"; - $sql.= ", rang"; - $sql.= ") VALUES ("; - $sql.= $this->fk_expedition; - $sql.= ", ".(empty($this->entrepot_id) ? 'NULL' : $this->entrepot_id); - $sql.= ", ".$this->fk_origin_line; - $sql.= ", ".$this->qty; - $sql.= ", ".$ranktouse; - $sql.= ")"; + $sql .= "fk_expedition"; + $sql .= ", fk_entrepot"; + $sql .= ", fk_origin_line"; + $sql .= ", qty"; + $sql .= ", rang"; + $sql .= ") VALUES ("; + $sql .= $this->fk_expedition; + $sql .= ", ".(empty($this->entrepot_id) ? 'NULL' : $this->entrepot_id); + $sql .= ", ".$this->fk_origin_line; + $sql .= ", ".$this->qty; + $sql .= ", ".$ranktouse; + $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 15073c50620..872bd5a0792 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -31,14 +31,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'banks', 'trips')); -$id=GETPOST("id", 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'aZ09'); +$id = GETPOST("id", 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); $amounts = array(); -$accountid=GETPOST('accountid', 'int'); +$accountid = GETPOST('accountid', 'int'); // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) { $socid = $user->socid; @@ -51,7 +51,7 @@ if ($user->socid > 0) if ($action == 'add_payment') { - $error=0; + $error = 0; if ($_POST["cancel"]) { @@ -62,7 +62,7 @@ if ($action == 'add_payment') $expensereport = new ExpenseReport($db); $result = $expensereport->fetch($id, $ref); - if (! $result) + if (!$result) { $error++; setEventMessages($expensereport->error, $expensereport->errors, 'errors'); @@ -70,7 +70,7 @@ if ($action == 'add_payment') $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - if (! ($_POST["fk_typepayment"] > 0)) + if (!($_POST["fk_typepayment"] > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; @@ -80,13 +80,13 @@ if ($action == 'add_payment') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; } - if (! empty($conf->banque->enabled) && ! ($accountid > 0)) + if (!empty($conf->banque->enabled) && !($accountid > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $paymentid = 0; $total = 0; @@ -104,10 +104,10 @@ if ($action == 'add_payment') if (count($amounts) <= 0) { $error++; - $errmsg='ErrorNoPaymentDefined'; + $errmsg = 'ErrorNoPaymentDefined'; } - if (! $error) + if (!$error) { $db->begin(); @@ -115,13 +115,13 @@ if ($action == 'add_payment') $payment = new PaymentExpenseReport($db); $payment->fk_expensereport = $expensereport->id; $payment->datepaid = $datepaid; - $payment->amounts = $amounts; // Tableau de montant + $payment->amounts = $amounts; // Tableau de montant $payment->total = $total; $payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); $payment->note_public = GETPOST("note_public", 'none'); - if (! $error) + if (!$error) { $paymentid = $payment->create($user); if ($paymentid < 0) @@ -131,10 +131,10 @@ if ($action == 'add_payment') } } - if (! $error) + if (!$error) { - $result=$payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); - if (! $result > 0) + $result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); + if (!$result > 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; @@ -152,7 +152,7 @@ if ($action == 'add_payment') } } - if (! $error) + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id; @@ -166,7 +166,7 @@ if ($action == 'add_payment') } } - $action='create'; + $action = 'create'; } @@ -176,7 +176,7 @@ if ($action == 'add_payment') llxHeader(); -$form=new Form($db); +$form = new Form($db); // Form to create expense report payment @@ -188,7 +188,7 @@ if ($action == 'create' || empty($action)) $total = $expensereport->total_ttc; // autofill remainder amount - if (! empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) { print "\n".'
'; print ''; print ''; print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
".$donationstatic->getNomUrl(1)."".$company->getNomUrl(1)."".$objp->societe."