diff --git a/.travis.yml b/.travis.yml index 9fcd300e224..5d15e8843dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -309,7 +309,7 @@ script: set -e # Exclusions are defined in the ruleset.xml file #phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 . - phpcs -s -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . + phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . set +e echo diff --git a/.tx/config b/.tx/config index 0dea31a14d0..0044fb91f49 100644 --- a/.tx/config +++ b/.tx/config @@ -236,6 +236,12 @@ source_file = htdocs/langs/en_US/modulebuilder.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.mrp] +file_filter = htdocs/langs//mrp.lang +source_file = htdocs/langs/en_US/mrp.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.multicurrency] file_filter = htdocs/langs//multicurrency.lang source_file = htdocs/langs/en_US/multicurrency.lang diff --git a/COPYRIGHT b/COPYRIGHT index 43adbde9d24..39fba1007c3 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -34,7 +34,7 @@ Swift Mailer 5.4.2-DEV MIT license Yes Stripe 4.7.0 MIT licence Yes Library for Stripe module JS libraries: -jQuery 3.1.1 MIT License Yes JS library +jQuery 3.3.1 MIT License Yes JS library jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI jQuery select2 4.0.5 GPL and Apache License Yes JS library plugin for sexier multiselect jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups) diff --git a/ChangeLog b/ChangeLog index 7dc7fad28bb..07cd70d64fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,21 +22,51 @@ Following changes may create regressions for some external modules, but were nec FIX: #10381 FIX: #10460 compatibility with MariaDB 10.4 FIX: #10485 +FIX: #10638 +FIX: Accountancy - Adding transaction with multicompany uses all the time 1st entity +FIX: actioncomm export: ORDER BY clause is in wrong export property + event type filter does not work FIX: add fk_unit on addline action +FIX: adding css by page if url is externam +FIX: Bad link in menu manager FIX: better test on fetch +FIX: can't add lines on invoices +FIX: Check for old picture name if the new one was not found +FIX: could not create several superadmin in transversal mode +FIX: creation of menu entry with parent id not int +FIX: creation of new left menu entry FIX: Default language of company is not set +FIX: error on setup of password if pass generators have a .old file. FIX: error report not returned FIX: expedition: reset status on rollback + replace hardcoded status with const +FIX: fetch module / pos source +FIX: fk_default_warehouse missing in group by +FIX: function sendEmailsReminder isn't completely developed, then MAIN_FEATURES_LEVEL must be 2 to "use" it +FIX: if empty error message, we just see "error" displayed +FIX: label of bank account FIX: line edit template: keep fk_parent_line +FIX: Mark credit note as available for credit note in other currency +FIX: missing access security checking with multicompany +FIX: missing entity filter in function "build_filterField()" (export module) +FIX: missing $ismultientitymanaged for previous/next ref FIX: Missing province in export of invoice FIX: must fetch member in current entity +FIX: positive values creating diff on addline rounding +FIX: positive values IN supplier credit notes creating diff on addline rounding FIX: Price in combo list of service does not use the correct price level -FIX: supplier invoice payment total doesnt care about deposit or credit +FIX: project_title for display of getNomUrl() +FIX: same thing here +FIX: Show button POS Ticket only if invoice was generated by POS +FIX: supplier invoice payment total doesn't care about deposit or credit FIX: supplier invoice product stats total ht is line total not invoice total +FIX: The notes was also copied on invoice +FIX: Transaction on leave approval and decrease ko if setup not complete FIX: Translation not loaded by scheduled jobs +FIX: [URGENT] broken feature, "$usercancreate" is for Dolibarr 9 +FIX: we want to be able to reopen fourn credit note +FIX: wrong feature2 when user rights "group_advance" is used FIX: wrong merged conflict FIX: wrong tests on fetch -NEW: Add protection to avoid packaging if files non indexed exists into +NEW: Add protection to avoid packaging if files non indexed exists ***** ChangeLog for 9.0.0 compared to 8.0.0 ***** For Users: diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 296c6cb9b6f..b6f62aede64 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -11,10 +11,8 @@ htdocs/conf.php */nltechno* */htdocs/includes - *.min.css - *.js - + @@ -201,7 +199,7 @@ 0 - + diff --git a/dev/translation/autotranslator.class.php b/dev/translation/autotranslator.class.php index 4da15890045..789bd8173c4 100644 --- a/dev/translation/autotranslator.class.php +++ b/dev/translation/autotranslator.class.php @@ -50,7 +50,7 @@ class autoTranslator * @param string $_apikey Api key * @return void */ - function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey) + public function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey) { // Set enviorment variables @@ -346,5 +346,5 @@ class autoTranslator //print "OK ".join('',$src_texts).' => '.$rep."\n"; return $rep; - } + } } diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index f551cf3e716..e0b8c6f70c2 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -307,11 +307,11 @@ if ($resql) print ''; if (! empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); if (! empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, 'align="left"', $sortfield, $sortorder); + if (! empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); if (! empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']); if (! empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; $accountstatic = new AccountingAccount($db); @@ -403,7 +403,7 @@ if ($resql) } // Action - print ''; + print ''; if ($user->rights->accounting->chartofaccount) { print ''; print img_edit(); diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 9f31fa663ed..36ecf11a4c7 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -532,8 +532,8 @@ if ($id) if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } if ($valuetoshow != '') { - print ''; - if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { + print ''; + if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; } elseif (! empty($tabhelp[$id][$value])) { print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); @@ -662,23 +662,29 @@ if ($id) */ $valuetoshow=ucfirst($fieldlist[$field]); // By defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') - { - $valuetoshow=$langs->trans("Label"); - if ($id != 25) $valuetoshow.="*"; - } - if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='country_id') { $showfield=0; } - if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } + if ($fieldlist[$field]=='code') { + $valuetoshow=$langs->trans("Code"); + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { + $valuetoshow=$langs->trans("Label"); + if ($id != 25) $valuetoshow.="*"; + } + if ($fieldlist[$field]=='country') { + $valuetoshow=$langs->trans("Country"); + } + if ($fieldlist[$field]=='country_id') { + $showfield=0; + } + if ($fieldlist[$field]=='fk_pcg_version') { + $valuetoshow=$langs->trans("Pcg_version"); + } // Affiche nom du champ - if ($showfield) - { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder); + if ($showfield) { + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "", $sortfield, $sortorder, $class.' '); } } - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print ''; @@ -757,7 +763,7 @@ if ($id) $class='tddict'; if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; // Show value for field - if ($showfield) print ''.$valuetoshow.''; + if ($showfield) print ''.$valuetoshow.''; } } @@ -769,17 +775,17 @@ if ($id) $url.='&'; // Active - print ''; + print ''; if ($canbedisabled) print ''.$actl[$obj->active].''; else print $langs->trans("AlwaysActive"); print ""; // Modify link - if ($canbemodified) print ''.img_edit().''; + if ($canbemodified) print ''.img_edit().''; else print ' '; // Delete link - if ($iserasable) print ''.img_delete().''; + if ($iserasable) print ''.img_delete().''; else print ' '; print "\n"; @@ -852,7 +858,7 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context = } } elseif ($fieldlist[$field] == 'type_cdr') { - if ($fieldlist[$field] == 'type_cdr') print ''; + if ($fieldlist[$field] == 'type_cdr') print ''; else print ''; if ($fieldlist[$field] == 'type_cdr') { print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 7cb7d7d27f2..3a55e092d94 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -41,8 +41,7 @@ $rowid=GETPOST('rowid', 'alpha'); $code=GETPOST('code', 'alpha'); // Security access -if (empty($user->rights->accounting->chartofaccount)) -{ +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -468,29 +467,46 @@ if ($id) $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate $class="left"; - if ($fieldlist[$field]=='type') { - if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); - else $valuetoshow=$langs->trans("Type"); + if ($fieldlist[$field]=='type') { + if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") { + $valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); + } else { + $valuetoshow=$langs->trans("Type"); + } } - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') - { + if ($fieldlist[$field]=='code') { + $valuetoshow=$langs->trans("Code"); + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } - if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments"); } - if ($fieldlist[$field]=='country') { + if ($fieldlist[$field]=='libelle_facture') { + $valuetoshow=$langs->trans("LabelOnDocuments"); + } + if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); } - if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); } - if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Comment"); } - if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } + if ($fieldlist[$field]=='accountancy_code') { + $valuetoshow=$langs->trans("AccountancyCode"); + } + if ($fieldlist[$field]=='accountancy_code_sell') { + $valuetoshow=$langs->trans("AccountancyCodeSell"); + } + if ($fieldlist[$field]=='accountancy_code_buy') { + $valuetoshow=$langs->trans("AccountancyCodeBuy"); + } + if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { + $valuetoshow=$langs->trans("Pcg_version"); + } + if ($fieldlist[$field]=='range_account') { + $valuetoshow=$langs->trans("Comment"); + } + if ($fieldlist[$field]=='category_type') { + $valuetoshow=$langs->trans("Calculated"); + } - if ($valuetoshow != '') - { - print ''; + if ($valuetoshow != '') { + print ''; if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); else print $valuetoshow; @@ -591,7 +607,7 @@ if ($id) print ''; print ''; print ''; - print ''; + print ''; if ($filterfound) { $searchpicto=$form->showFilterAndCheckAddButtons(0); @@ -613,38 +629,73 @@ if ($id) $valuetoshow=ucfirst($fieldlist[$field]); // By defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } - if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } - if ($fieldlist[$field]=='taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); - else $valuetoshow=$langs->trans("Amount"); - $align='center'; + if ($fieldlist[$field]=='source') { + $valuetoshow=$langs->trans("Contact"); } - if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') - { + if ($fieldlist[$field]=='price') { + $valuetoshow=$langs->trans("PriceUHT"); + } + if ($fieldlist[$field]=='taux') { + if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") { + $valuetoshow=$langs->trans("Rate"); + } else { + $valuetoshow=$langs->trans("Amount"); + } + $class='center'; + } + if ($fieldlist[$field]=='type') { + $valuetoshow=$langs->trans("Type"); + } + if ($fieldlist[$field]=='code') { + $valuetoshow=$langs->trans("Code"); + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } - if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } - if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; } - if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; } - if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountsparent"); } - if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); } - if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } - if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } - if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Comment"); } - if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } + if ($fieldlist[$field]=='country') { + $valuetoshow=$langs->trans("Country"); + } + if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { + $showfield=0; + } + if ($fieldlist[$field]=='accountancy_code') { + $valuetoshow=$langs->trans("AccountancyCode"); + } + if ($fieldlist[$field]=='accountancy_code_sell') { + $valuetoshow=$langs->trans("AccountancyCodeSell"); + $sortable=0; + } + if ($fieldlist[$field]=='accountancy_code_buy') { + $valuetoshow=$langs->trans("AccountancyCodeBuy"); + $sortable=0; + } + if ($fieldlist[$field]=='fk_pcg_version') { + $valuetoshow=$langs->trans("Pcg_version"); + } + if ($fieldlist[$field]=='account_parent') { + $valuetoshow=$langs->trans("Accountsparent"); + } + if ($fieldlist[$field]=='pcg_type') { + $valuetoshow=$langs->trans("Pcg_type"); + } + if ($fieldlist[$field]=='pcg_subtype') { + $valuetoshow=$langs->trans("Pcg_subtype"); + } + if ($fieldlist[$field]=='type_template') { + $valuetoshow=$langs->trans("TypeOfTemplate"); + } + if ($fieldlist[$field]=='range_account') { + $valuetoshow=$langs->trans("Comment"); + } + if ($fieldlist[$field]=='category_type') { + $valuetoshow=$langs->trans("Calculated"); + } // Affiche nom du champ - if ($showfield) - { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder); + if ($showfield) { + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "", $sortfield, $sortorder, $class.' '); } } - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print getTitleFieldOfList(''); @@ -670,7 +721,7 @@ if ($id) print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -732,7 +783,7 @@ if ($id) $class='tddict'; // Show value for field - if ($showfield) print ''.$valuetoshow.''; + if ($showfield) print ''.$valuetoshow.''; } } @@ -750,7 +801,7 @@ if ($id) $url.='&'; // Active - print ''; + print ''; if ($canbedisabled) print ''.$actl[$obj->active].''; else { @@ -759,13 +810,13 @@ if ($id) print ""; // Modify link - if ($canbemodified) print ''.img_edit().''; + if ($canbemodified) print ''.img_edit().''; else print ' '; // Delete link if ($iserasable) { - print ''; + print ''; if ($user->admin) print ''.img_delete().''; //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin print ''; diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php index 8093a2fa883..ff559332316 100644 --- a/htdocs/accountancy/admin/closure.php +++ b/htdocs/accountancy/admin/closure.php @@ -32,8 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->loadLangs(array("compta","admin","accountancy")); // Security check -if (empty($user->rights->accounting->chartofaccount)) -{ +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -112,7 +111,7 @@ foreach ($list_account_main as $key) { print $form->textwithpicto($label, $htmltext); print ''; // Value - print ''; // Do not force align=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/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 5b39a38657f..4ea9ff9139a 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -156,7 +156,7 @@ foreach ($list_account_main as $key) { print $form->textwithpicto($label, $htmltext); print ''; // Value - print ''; // Do not force align=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 ''; @@ -179,7 +179,7 @@ foreach ($list_account as $key) { $label = $langs->trans($key); print '' . $label . ''; // Value - print ''; // Do not force align=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/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 78fe73322f2..795edda5f4c 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -131,8 +131,8 @@ if ($result) print '' . $langs->trans("Label") . ''; print '' . $langs->trans("DateStart") . ''; print '' . $langs->trans("DateEnd") . ''; - print '' . $langs->trans("NumberOfAccountancyEntries") . ''; - print '' . $langs->trans("NumberOfAccountancyMovements") . ''; + print '' . $langs->trans("NumberOfAccountancyEntries") . ''; + print '' . $langs->trans("NumberOfAccountancyMovements") . ''; print '' . $langs->trans("Statut") . ''; print ''; @@ -147,8 +147,8 @@ if ($result) print '' . $obj->label . ''; print '' . dol_print_date($db->jdate($obj->date_start), 'day') . ''; print '' . dol_print_date($db->jdate($obj->date_end), 'day') . ''; - print '' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . ''; - print '' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . ''; + print '' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . ''; + print '' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . ''; print '' . $fiscalyearstatic->LibStatut($obj->statut, 5) . ''; print ''; $i++; diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 1efebf5c234..c8cf0aa9901 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -132,7 +132,7 @@ if ($result) { print '' . $langs->trans("Accountparent") . ''; print '' . $langs->trans("Pcgtype") . ''; print '' . $langs->trans("Pcgsubtype") . ''; - print '' . $langs->trans("Import") . ''; + print '' . $langs->trans("Import") . ''; print ''; $form = new Form($db); @@ -166,7 +166,7 @@ if ($result) { // Colonne choix ligne a ventiler $checked = ('label' == 'O') ? ' checked' : ''; - print ''; + print ''; print ''; print ''; @@ -174,7 +174,7 @@ if ($result) { $i ++; } - print ' '; + print ' '; print ''; print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 1e623c23860..996aa8500d2 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -430,16 +430,18 @@ if ($id) $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate $class="left"; - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') - { + if ($fieldlist[$field]=='code') { + $valuetoshow=$langs->trans("Code"); + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } - if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); } + if ($fieldlist[$field]=='nature') { + $valuetoshow=$langs->trans("Nature"); + } - if ($valuetoshow != '') - { - print ''; + if ($valuetoshow != '') { + print ''; if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); else print $valuetoshow; @@ -549,17 +551,22 @@ if ($id) */ $valuetoshow=ucfirst($fieldlist[$field]); // By defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } - if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); } + if ($fieldlist[$field]=='code') { + $valuetoshow=$langs->trans("Code"); + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { + $valuetoshow=$langs->trans("Label"); + } + if ($fieldlist[$field]=='nature') { + $valuetoshow=$langs->trans("Nature"); + } // Affiche nom du champ - if ($showfield) - { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder); + if ($showfield) { + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "", $sortfield, $sortorder, $class.' '); } } - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print getTitleFieldOfList(''); @@ -621,7 +628,7 @@ if ($id) $class='tddict'; // Show value for field - if ($showfield) print ''.$valuetoshow.''; + if ($showfield) print ''.$valuetoshow.''; } } @@ -696,11 +703,11 @@ $db->close(); /** * Show fields in insert/edit mode * - * @param array $fieldlist Array of fields - * @param Object $obj If we show a particular record, obj is filled with record fields - * @param string $tabname Name of SQL table - * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered - * @return void + * @param array $fieldlist Array of fields + * @param Object $obj If we show a particular record, obj is filled with record fields + * @param string $tabname Name of SQL table + * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered + * @return void */ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '') { diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index a81aa472ef7..df8ce99fa10 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -307,7 +307,7 @@ if ($result) print ''.$langs->trans('OptionModeProductBuyDesc')."\n"; print "\n"; - print '
'; + print '
'; print "
\n"; @@ -338,7 +338,7 @@ if ($result) print ' '.$langs->trans("or").' '.$form->selectarray('search_current_account_valid', $listofvals, $search_current_account_valid, 1); print ''; print ' '; - print ''; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; @@ -348,14 +348,14 @@ if ($result) 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 ($accounting_product_mode == 'ACCOUNTANCY_SELL') print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, 'align="center"', $sortfield, $sortorder); - if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, 'align="center"', $sortfield, $sortorder); + if ($accounting_product_mode == 'ACCOUNTANCY_SELL') print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); if ($accounting_product_mode == 'ACCOUNTANCY_BUY') $fieldtosortaccount="p.accountancy_code_buy"; else $fieldtosortaccount="p.accountancy_code_sell"; print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); $clickpitco=$form->showCheckAddButtons('checkforselect', 1); - print_liste_field_titre($clickpitco, '', '', '', '', 'align="center"'); + print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center '); print ''; $product_static = new Product($db); @@ -408,10 +408,10 @@ if ($result) } if ($accounting_product_mode == 'ACCOUNTANCY_SELL') - print ''.$product_static->getLibStatut(3, 0).''; + print ''.$product_static->getLibStatut(3, 0).''; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') - print ''.$product_static->getLibStatut(3, 1).''; + print ''.$product_static->getLibStatut(3, 1).''; // Current accounting account print ''; @@ -450,7 +450,7 @@ if ($result) } // Checkbox select - print ''; + print ''; print ''; print ""; $i ++; @@ -485,7 +485,7 @@ if ($result) '; - print '
'; + print '
'; print ''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 4da7865624e..6d2c7644d85 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -248,7 +248,7 @@ if ($action != 'export_csv') print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60" class="center"', $sortfield, $sortorder); print "\n"; $total_debit = 0; @@ -296,7 +296,7 @@ if ($action != 'export_csv') print '' . price($line->debit) . ''; print '' . price($line->credit) . ''; print '' . price($line->credit - $line->debit) . ''; - print '' . $link; + print '' . $link; print ''; print "\n"; diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index 7b9bf25c589..edf7383b595 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -73,19 +73,19 @@ $y = $year_current; print ''; print ''; print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; print ''; $sql = "SELECT bk.numero_compte AS 'compte',"; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 7e3d3a6e68d..b3367ad1b8e 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -604,7 +604,7 @@ if ($action == 'create') print_liste_field_titre("LabelOperation"); print_liste_field_titre("Debit", "", "", "", "", 'class="right"'); print_liste_field_titre("Credit", "", "", "", "", 'class="right"'); - print_liste_field_titre("Action", "", "", "", "", 'width="60" align="center"'); + print_liste_field_titre("Action", "", "", "", "", 'width="60" class="center"'); print "\n"; @@ -644,7 +644,7 @@ if ($action == 'create') print ''; print ''; - print '\n"; print ''; if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder); -if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder); -if (! empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, 'class="center"', $sortfield, $sortorder); -if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, 'align="center"', $sortfield, $sortorder); -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); +if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); +if (! empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); +if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center '); +if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center '); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 33c7deb0cfd..8988491c927 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -286,7 +286,7 @@ print $formaccounting->select_account($search_accountancy_code_end, 'search_acco print ''; print ''; print ''; -print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF']); -print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $param, 'class="right"', $sortfield, $sortorder); -print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); +print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Piece", $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label"); -print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder); -print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder); -print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); -print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); +print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); +print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60"', $sortfield, $sortorder, 'center '); print "\n"; print ''; @@ -364,7 +364,7 @@ while ($i < min($num, $limit)) print ''; print ''; print ''; - print ''; + print ''; // TODO Add a link according to doc_type and fk_doc print ''; + print ''; - print ''; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 9bef7a1c4fc..1a91f2dafbb 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -238,12 +238,12 @@ if ($resql) { print ''; print ''; print ''; - print ''; + print ''; if (empty($obj->lettering_code)) { - print ''; + print ''; } else - print ''; + print ''; print "\n"; } diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index bf2b8d4f948..df1d4317252 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -240,12 +240,12 @@ if ($resql) { print ''; print ''; print ''; - print ''; + print ''; if (empty($obj->lettering_code)) { - print ''; + print ''; } else - print ''; + print ''; print "\n"; } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 010f452755d..73cccdfd721 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -129,7 +129,7 @@ class AccountancyCategory // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -142,7 +142,7 @@ class AccountancyCategory // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -239,7 +239,7 @@ class AccountancyCategory // extends CommonObject * @param string $label Label * @return int <0 if KO, >0 if OK */ - function fetch($id, $code = '', $label = '') + public function fetch($id, $code = '', $label = '') { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -299,7 +299,7 @@ class AccountancyCategory // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -379,7 +379,7 @@ class AccountancyCategory // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -460,7 +460,7 @@ class AccountancyCategory // extends CommonObject return - 1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -509,7 +509,7 @@ class AccountancyCategory // extends CommonObject return - 1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -552,7 +552,7 @@ class AccountancyCategory // extends CommonObject return - 1; } - } + } /** * Function to add an accounting account in an accounting category @@ -617,7 +617,7 @@ class AccountancyCategory // extends CommonObject return 1; } - } + } /** * Function to delete an accounting account from an accounting category @@ -643,7 +643,7 @@ class AccountancyCategory // extends CommonObject } // Commit or rollback - if ($error) { + if ($error) { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR); $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); @@ -651,12 +651,12 @@ class AccountancyCategory // extends CommonObject $this->db->rollback(); return - 1 * $error; - } else { + } else { $this->db->commit(); - return 1; - } - } + return 1; + } + } /** * Function to know all category from accounting account diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 775974edb6c..01f02a8a80a 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2016-2018 Alexandre Spangaro * Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2017 Elarifr. Ari Elbaz - * Copyright (C) 2017 Frédéric France + * Copyright (C) 2017-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -98,18 +98,18 @@ class AccountancyExport global $langs; return array ( - //self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), - self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'), - self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), - self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), - self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), - self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), - self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), - self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), - self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), - self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), - self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), - ); + //self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), + self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'), + self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), + self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), + self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), + self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), + self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), + self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), + self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), + self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), + self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), + ); } /** diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 65852258867..53e824219c5 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -64,10 +64,10 @@ class AccountancySystem * * @param DoliDB $db handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; - } + } /** @@ -77,7 +77,7 @@ class AccountancySystem * @param string $ref ref * @return int <0 if KO, Id of record if OK and found */ - function fetch($rowid = 0, $ref = '') + public function fetch($rowid = 0, $ref = '') { global $conf; @@ -124,7 +124,7 @@ class AccountancySystem * @param User $user making insert * @return int if KO, Id of line if OK */ - function create($user) + public function create($user) { $now = dol_now(); @@ -151,6 +151,6 @@ class AccountancySystem dol_syslog($this->error, LOG_ERR); } - return $result; - } + return $result; + } } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index d889ef37195..f184d30699f 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -138,13 +138,13 @@ class AccountingAccount extends CommonObject * * @param DoliDB $db Database handle */ - function __construct($db) + public function __construct($db) { global $conf; $this->db = $db; $this->next_prev_filter='fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; // Used to add a filter in Form::showrefnav method - } + } /** * Load record in memory @@ -154,7 +154,7 @@ class AccountingAccount extends CommonObject * @param int $limittocurrentchart 1=Do not load record if it is into another accounting system * @return int <0 if KO, 0 if not found, Id of record if OK and found */ - function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) + public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) { global $conf; @@ -216,7 +216,7 @@ class AccountingAccount extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; $error = 0; @@ -317,7 +317,7 @@ class AccountingAccount extends CommonObject $this->db->commit(); return $this->id; } - } + } /** * Update record @@ -325,7 +325,7 @@ class AccountingAccount extends CommonObject * @param User $user Use making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { // Check parameters if (empty($this->pcg_type) || $this->pcg_type == '-1') @@ -368,7 +368,7 @@ class AccountingAccount extends CommonObject * * @return int <0 if KO, >0 if OK */ - function checkUsage() + public function checkUsage() { global $langs; @@ -402,7 +402,7 @@ class AccountingAccount extends CommonObject * @param int $notrigger 0=triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error = 0; @@ -453,9 +453,9 @@ class AccountingAccount extends CommonObject } else { return - 1; } - } + } - /** + /** * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto @@ -466,8 +466,8 @@ class AccountingAccount extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) - { + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) + { global $langs, $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -522,7 +522,7 @@ class AccountingAccount extends CommonObject if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; return $result; - } + } /** * Information on record @@ -530,7 +530,7 @@ class AccountingAccount extends CommonObject * @param int $id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a'; @@ -562,14 +562,14 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Account deactivated * * @param int $id Id * @return int <0 if KO, >0 if OK */ - function account_desactivate($id) + public function account_desactivate($id) { // phpcs:enable $result = $this->checkUsage(); @@ -597,14 +597,14 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Account activated * * @param int $id Id * @return int <0 if KO, >0 if OK */ - function account_activate($id) + public function account_activate($id) { // phpcs:enable $this->db->begin(); @@ -615,15 +615,15 @@ class AccountingAccount extends CommonObject dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) { + if ($result) { $this->db->commit(); return 1; - } else { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return - 1; - } - } + } + } /** @@ -632,12 +632,12 @@ class AccountingAccount extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -645,7 +645,7 @@ class AccountingAccount extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -655,32 +655,32 @@ class AccountingAccount extends CommonObject { $prefix=''; if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); + elseif ($statut == 0) return $langs->trans('Disabled'); } elseif ($mode == 1) { if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); + elseif ($statut == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } } diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index b4ef9781aa2..eb99badd5f3 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -74,10 +74,10 @@ class AccountingJournal extends CommonObject * * @param DoliDB $db Database handle */ - function __construct($db) + public function __construct($db) { - $this->db = $db; - } + $this->db = $db; + } /** * Load an object from database @@ -86,7 +86,7 @@ class AccountingJournal extends CommonObject * @param string $journal_code Journal code * @return int <0 if KO, Id of record if OK and found */ - function fetch($rowid = null, $journal_code = null) + public function fetch($rowid = null, $journal_code = null) { global $conf; @@ -146,7 +146,7 @@ class AccountingJournal extends CommonObject * * @return int <0 if KO, >0 if OK */ - function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { $sql = "SELECT rowid, code, label, nature, active"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; @@ -213,7 +213,7 @@ class AccountingJournal extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0) { global $langs, $conf, $user; @@ -270,12 +270,12 @@ class AccountingJournal extends CommonObject * @param int $mode 0=libelle long, 1=libelle court * @return string Label of type */ - function getLibType($mode = 0) + public function getLibType($mode = 0) { return $this->LibType($this->nature, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return type of an accounting journal * @@ -283,7 +283,7 @@ class AccountingJournal extends CommonObject * @param int $mode 0=libelle long, 1=libelle court * @return string Label of type */ - function LibType($nature, $mode = 0) + public function LibType($nature, $mode = 0) { // phpcs:enable global $langs; @@ -294,20 +294,20 @@ class AccountingJournal extends CommonObject { $prefix=''; if ($nature == 9) return $langs->trans('AccountingJournalType9'); - if ($nature == 5) return $langs->trans('AccountingJournalType5'); - if ($nature == 4) return $langs->trans('AccountingJournalType4'); - if ($nature == 3) return $langs->trans('AccountingJournalType3'); - if ($nature == 2) return $langs->trans('AccountingJournalType2'); - if ($nature == 1) return $langs->trans('AccountingJournalType1'); + elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); + elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); + elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); + elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); + elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); } - if ($mode == 1) + elseif ($mode == 1) { if ($nature == 9) return $langs->trans('AccountingJournalType9'); - if ($nature == 5) return $langs->trans('AccountingJournalType5'); - if ($nature == 4) return $langs->trans('AccountingJournalType4'); - if ($nature == 3) return $langs->trans('AccountingJournalType3'); - if ($nature == 2) return $langs->trans('AccountingJournalType2'); - if ($nature == 1) return $langs->trans('AccountingJournalType1'); + elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); + elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); + elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); + elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); + elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); } } } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index bf3594e967d..03552557f86 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -167,10 +167,10 @@ class BookKeeping extends CommonObject $this->doc_ref = trim($this->doc_ref); } if (isset($this->fk_doc)) { - $this->fk_doc = trim($this->fk_doc); + $this->fk_doc = (int) $this->fk_doc; } if (isset($this->fk_docdet)) { - $this->fk_docdet = trim($this->fk_docdet); + $this->fk_docdet = (int) $this->fk_docdet; } if (isset($this->thirdparty_code)) { $this->thirdparty_code = trim($this->thirdparty_code); @@ -411,7 +411,7 @@ class BookKeeping extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -487,10 +487,10 @@ class BookKeeping extends CommonObject $this->doc_ref = trim($this->doc_ref); } if (isset($this->fk_doc)) { - $this->fk_doc = trim($this->fk_doc); + $this->fk_doc = (int) $this->fk_doc; } if (isset($this->fk_docdet)) { - $this->fk_docdet = trim($this->fk_docdet); + $this->fk_docdet = (int) $this->fk_docdet; } if (isset($this->thirdparty_code)) { $this->thirdparty_code = trim($this->thirdparty_code); @@ -1104,10 +1104,10 @@ class BookKeeping extends CommonObject $this->doc_ref = trim($this->doc_ref); } if (isset($this->fk_doc)) { - $this->fk_doc = trim($this->fk_doc); + $this->fk_doc = (int) $this->fk_doc; } if (isset($this->fk_docdet)) { - $this->fk_docdet = trim($this->fk_docdet); + $this->fk_docdet = (int) $this->fk_docdet; } if (isset($this->thirdparty_code)) { $this->thirdparty_code = trim($this->thirdparty_code); @@ -1308,7 +1308,7 @@ class BookKeeping extends CommonObject * @param string $importkey Import key * @return int Result */ - function deleteByImportkey($importkey) + public function deleteByImportkey($importkey) { $this->db->begin(); @@ -1338,7 +1338,7 @@ class BookKeeping extends CommonObject * @param string $mode Mode * @return int <0 if KO, >0 if OK */ - function deleteByYearAndJournal($delyear = '', $journal = '', $mode = '') + public function deleteByYearAndJournal($delyear = '', $journal = '', $mode = '') { global $conf; @@ -1378,7 +1378,7 @@ class BookKeeping extends CommonObject * @param int $piecenum Piecenum to delete * @return int Result */ - function deleteMvtNum($piecenum) + public function deleteMvtNum($piecenum) { global $conf; @@ -1473,8 +1473,8 @@ class BookKeeping extends CommonObject $this->doc_date = $now; $this->doc_type = ''; $this->doc_ref = ''; - $this->fk_doc = ''; - $this->fk_docdet = ''; + $this->fk_doc = 0; + $this->fk_docdet = 0; $this->thirdparty_code = 'CU001'; $this->subledger_account = '41100001'; $this->subledger_label = 'My customer company'; @@ -1565,7 +1565,7 @@ class BookKeeping extends CommonObject * @param string $mode Mode * @return int <0 if KO, >0 if OK */ - function fetchAllPerMvt($piecenum, $mode = '') + public function fetchAllPerMvt($piecenum, $mode = '') { global $conf; @@ -1618,14 +1618,14 @@ class BookKeeping extends CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Export bookkeping * * @param string $model Model * @return int Result */ - function export_bookkeping($model = 'ebp') + public function export_bookkeping($model = 'ebp') { // phpcs:enable global $conf; @@ -1771,7 +1771,7 @@ class BookKeeping extends CommonObject */ } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of accounts with label by chart of accounts * @@ -1784,7 +1784,7 @@ class BookKeeping extends CommonObject * @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number * @return string String with HTML select */ - function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') + public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { // phpcs:enable global $conf; @@ -1843,14 +1843,14 @@ class BookKeeping extends CommonObject return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Description of a root accounting account * * @param string $account Accounting account * @return string Root account */ - function get_compte_racine($account = null) + public function get_compte_racine($account = null) { // phpcs:enable global $conf; @@ -1884,15 +1884,15 @@ class BookKeeping extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Description of accounting account * * @param string $account Accounting account * @return string Account desc */ - function get_compte_desc($account = null) - { + public function get_compte_desc($account = null) + { // phpcs:enable global $conf; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index dbd0f680db7..f7a53c9e210 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -309,7 +309,9 @@ if ($result) { print ''; print ''; print ''; @@ -323,8 +325,8 @@ if ($result) { //print ''; print ''; print ''; - print ''; - print ''; + print '\n"; @@ -332,17 +334,17 @@ if ($result) { print ''; print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "fd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, fd.rowid", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, fd.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder, 'center '); $clickpicto=$form->showCheckAddButtons(); - print_liste_field_titre($clickpicto, '', '', '', '', 'align="center"'); + print_liste_field_titre($clickpicto, '', '', '', '', '', '', '', 'center '); print "\n"; $facture_static = new Facture($db); @@ -368,7 +370,7 @@ if ($result) { // Ref Invoice print ''; - print ''; + print ''; // Ref Product print ''; - print ''; print ''; print ''; @@ -392,7 +394,7 @@ if ($result) { print ''; print ''; print ''; - print ''; @@ -401,19 +403,19 @@ if ($result) { print ''; print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"'); - print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"'); + print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center '); + print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); $checkpicto=''; if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); - print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); + print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; $facture_static = new Facture($db); @@ -482,7 +484,7 @@ if ($result) { // Ref Invoice print ''; - print ''; + print ''; // Ref Product print ''; // Current account - print ''; // Suggested accounting account - print ''; // Column with checkbox - print ''; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 5dbacd501b9..3a322c07ef3 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -270,7 +270,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("TypeFees", $_SERVER["PHP_SELF"], "f.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); print_liste_field_titre(''); $checkpicto=$form->showCheckAddButtons(); - print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); + print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; $expensereport_static = new ExpenseReport($db); @@ -309,7 +309,7 @@ if ($result) { // Ref Invoice print ''; - print ''; + print ''; print ''; @@ -321,7 +321,7 @@ if ($result) { print ''; - print ''; + print ''; print ''; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 9d28206a91e..a6bec0246a0 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -319,7 +319,7 @@ if ($result) { print ''; print ''; print ''; - print ''; @@ -328,16 +328,16 @@ if ($result) { print ''; print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("TypeFees", $_SERVER["PHP_SELF"], "f.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("IntoAccount", '', '', '', '', '', $sortfield, $sortorder, 'center '); $checkpicto=''; if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); - print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); + print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; @@ -362,7 +362,7 @@ if ($result) { print ''; // Date - print ''; + print ''; // Fees label print ''; // Current account - print ''; // Suggested accounting account - print ''; - print ''; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 0c5ba39bd94..275af10701d 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -994,8 +994,8 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; - print ""; - print ""; + print ""; + print ""; print "\n"; $r = ''; @@ -1044,8 +1044,8 @@ if (empty($action) || $action == 'view') { print $reflabel; print ""; print ""; - print ""; - print ""; + print ""; + print ""; print ""; } } @@ -1126,8 +1126,8 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; - print ""; - print ""; + print ""; + print ""; print ""; } } @@ -1163,8 +1163,8 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; - print ""; - print ""; + print ""; + print ""; print ""; } } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 1c687fb98cc..4af51060b4b 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -328,8 +328,8 @@ if ($result) { // print ''; print ''; print ''; - print ''; - print ''; + print ''; @@ -339,17 +339,17 @@ if ($result) { print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder, 'center '); $checkpicto=$form->showCheckAddButtons(); - print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); + print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; $facturefournisseur_static = new FactureFournisseur($db); @@ -380,7 +380,7 @@ if ($result) { print $objp->invoice_label; print ''; - print ''; + print ''; // Ref product print ''; - print ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index f864824c740..156f98fc6a2 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -392,7 +392,7 @@ if ($result) { print ''; print ''; print ''; - print ''; @@ -402,19 +402,19 @@ if ($result) { print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"'); - print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"'); + print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center '); + print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); $checkpicto=''; if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); - print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); + print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; $facturefourn_static = new FactureFournisseur($db); @@ -475,7 +475,7 @@ if ($result) { print $objp->invoice_label; print ''; - print ''; + print ''; // Ref product print ''; // Current account - print ''; // Suggested accounting account - print ''; // Column with checkbox - print ''; diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index d646a7cfb9b..31f957fcf21 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -32,15 +32,15 @@ abstract class ActionsAdherentCardCommon */ public $db; - var $dirmodule; - var $targetmodule; - var $canvas; - var $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container - var $tpl = array(); + public $tpl = array(); //! Object container - var $object; + public $object; /** * @var string Error code (or message) @@ -59,7 +59,7 @@ abstract class ActionsAdherentCardCommon * @param int $id Object id * @return object Object loaded */ - function getObject($id) + public function getObject($id) { //$ret = $this->getInstanceDao(); @@ -75,7 +75,7 @@ abstract class ActionsAdherentCardCommon //} } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set content of ->tpl array, to use into template * @@ -83,7 +83,7 @@ abstract class ActionsAdherentCardCommon * @param int $id Id * @return string HTML output */ - function assign_values(&$action, $id) + public function assign_values(&$action, $id) { // phpcs:enable global $conf, $langs, $user, $canvas; @@ -245,23 +245,23 @@ abstract class ActionsAdherentCardCommon // phpcs:enable global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->fk_soc = $_POST["fk_soc"]; - $this->object->lastname = $_POST["lastname"]; - $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->email = $_POST["email"]; - $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->fk_soc = $_POST["fk_soc"]; + $this->object->lastname = $_POST["lastname"]; + $this->object->firstname = $_POST["firstname"]; + $this->object->civility_id = $_POST["civility_id"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; + $this->object->town = $_POST["town"]; + $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->email = $_POST["email"]; + $this->object->note = $_POST["note"]; + $this->object->canvas = $_POST["canvas"]; // We set country_id, and country_code label of the chosen country if ($this->object->country_id) @@ -272,8 +272,8 @@ abstract class ActionsAdherentCardCommon { $obj = $this->db->fetch_object($resql); - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } else { diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index 67c1e33dbec..40424540312 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -39,7 +39,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) */ - function __construct($db, $dirmodule, $targetmodule, $canvas, $card) + public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) { $this->db = $db; $this->dirmodule = $dirmodule; @@ -67,7 +67,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -75,7 +75,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon * @param int $id Id * @return void */ - function assign_values(&$action, $id) + public function assign_values(&$action, $id) { // phpcs:enable global $limit, $offset, $sortfield, $sortorder; @@ -122,7 +122,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -132,7 +132,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - function LoadListDatas($limit, $offset, $sortfield, $sortorder) + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) { // phpcs:enable global $conf, $langs; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 66ee5ee16f2..77f3c7200f4 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -223,7 +223,7 @@ class Adherent extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->statut = -1; @@ -234,7 +234,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function sending an email to the current member with the text supplied in parameter. * @@ -251,7 +251,7 @@ class Adherent extends CommonObject * @param string $moreinheader Add more html headers * @return int <0 if KO, >0 if OK */ - function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') + public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') { // phpcs:enable global $conf,$langs; @@ -296,7 +296,7 @@ class Adherent extends CommonObject * @param string $text Text to make substitution to * @return string Value of input text string with substitutions done */ - function makeSubstitution($text) + public function makeSubstitution($text) { global $conf,$langs; @@ -363,7 +363,7 @@ class Adherent extends CommonObject * @param string $morphy Nature of the adherent (physical or moral) * @return string Label */ - function getmorphylib($morphy = '') + public function getmorphylib($morphy = '') { global $langs; if (! $morphy) { $morphy=$this->morphy; } @@ -379,7 +379,7 @@ class Adherent extends CommonObject * @param int $notrigger 1 ne declenche pas les triggers, 0 sinon * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$langs; @@ -505,7 +505,7 @@ class Adherent extends CommonObject * @param string $action Current action for hookmanager * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action = 'update') + public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action = 'update') { global $conf, $langs, $hookmanager; @@ -760,7 +760,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update denormalized last subscription date. * This function is called when we delete a subscription for example. @@ -768,7 +768,7 @@ class Adherent extends CommonObject * @param User $user User making change * @return int <0 if KO, >0 if OK */ - function update_end_date($user) + public function update_end_date($user) { // phpcs:enable $this->db->begin(); @@ -825,7 +825,7 @@ class Adherent extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, 0=nothing to do, >0 if OK */ - function delete($rowid, $user, $notrigger = 0) + public function delete($rowid, $user, $notrigger = 0) { global $conf, $langs; @@ -935,7 +935,7 @@ class Adherent extends CommonObject * @param int $nosyncuser Do not synchronize linked user * @return string If OK return clear password, 0 if no change, < 0 if error */ - function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) + public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) { global $conf, $langs; @@ -1046,7 +1046,7 @@ class Adherent extends CommonObject * @param int $userid Id of user to link to * @return int 1=OK, -1=KO */ - function setUserId($userid) + public function setUserId($userid) { global $conf, $langs; @@ -1080,7 +1080,7 @@ class Adherent extends CommonObject * @param int $thirdpartyid Id of user to link to * @return int 1=OK, -1=KO */ - function setThirdPartyId($thirdpartyid) + public function setThirdPartyId($thirdpartyid) { global $conf, $langs; @@ -1116,14 +1116,14 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Method to load member from its login * * @param string $login login of member * @return void */ - function fetch_login($login) + public function fetch_login($login) { // phpcs:enable global $conf; @@ -1147,7 +1147,7 @@ class Adherent extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Method to load member from its name * @@ -1155,7 +1155,7 @@ class Adherent extends CommonObject * @param string $lastname Lastname * @return void */ - function fetch_name($firstname, $lastname) + public function fetch_name($firstname, $lastname) { // phpcs:enable global $conf; @@ -1191,7 +1191,7 @@ class Adherent extends CommonObject * @param bool $fetch_subscriptions To load member subscriptions * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($rowid, $ref = '', $fk_soc = '', $ref_ext = '', $fetch_optionals = true, $fetch_subscriptions = true) + public function fetch($rowid, $ref = '', $fk_soc = '', $ref_ext = '', $fetch_optionals = true, $fetch_subscriptions = true) { global $langs; @@ -1281,9 +1281,12 @@ class Adherent extends CommonObject $this->public = $obj->public; $this->datec = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); + $this->date_modification= $this->db->jdate($obj->datem); $this->datefin = $this->db->jdate($obj->datefin); $this->datevalid = $this->db->jdate($obj->datev); + $this->date_validation = $this->db->jdate($obj->datev); $this->birth = $this->db->jdate($obj->birthday); $this->note_private = $obj->note_private; @@ -1325,7 +1328,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to get member subscriptions data * first_subscription_date, first_subscription_date_start, first_subscription_date_end, first_subscription_amount @@ -1333,7 +1336,7 @@ class Adherent extends CommonObject * * @return int <0 si KO, >0 si OK */ - function fetch_subscriptions() + public function fetch_subscriptions() { // phpcs:enable global $langs; @@ -1409,7 +1412,7 @@ class Adherent extends CommonObject * @param int $datesubend Date end subscription * @return int rowid of record added, <0 if KO */ - function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0) + public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0) { global $conf,$langs,$user; @@ -1495,7 +1498,7 @@ class Adherent extends CommonObject * @param string $autocreatethirdparty Auto create new thirdparty if member not yet linked to a thirdparty and we request an option that generate invoice. * @return int <0 if KO, >0 if OK */ - function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom = '', $emetteur_banque = '', $autocreatethirdparty = 0) + public function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom = '', $emetteur_banque = '', $autocreatethirdparty = 0) { global $conf, $langs, $user, $mysoc; @@ -1788,7 +1791,7 @@ class Adherent extends CommonObject * @param User $user user adherent qui valide * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function validate($user) + public function validate($user) { global $langs,$conf; @@ -1841,7 +1844,7 @@ class Adherent extends CommonObject * @param User $user User making change * @return int <0 if KO, >0 if OK */ - function resiliate($user) + public function resiliate($user) { global $langs,$conf; @@ -1883,13 +1886,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to add member into external tools mailing-list, spip, etc. * * @return int <0 if KO, >0 if OK */ - function add_to_abo() + public function add_to_abo() { // phpcs:enable global $conf,$langs; @@ -1942,13 +1945,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to delete a member from external tools like mailing-list, spip, etc. * * @return int <0 if KO, >0 if OK */ - function del_to_abo() + public function del_to_abo() { // phpcs:enable global $conf,$langs; @@ -2006,7 +2009,7 @@ class Adherent extends CommonObject * * @return string Translated name of civility (translated with transnoentitiesnoconv) */ - function getCivilityLabel() + public function getCivilityLabel() { global $langs; $langs->load("dict"); @@ -2027,7 +2030,7 @@ class Adherent extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1) { global $conf, $langs; @@ -2118,12 +2121,12 @@ class Adherent extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -2133,7 +2136,7 @@ class Adherent extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - function LibStatut($statut, $need_subscription, $date_end_subscription, $mode = 0) + public function LibStatut($statut, $need_subscription, $date_end_subscription, $mode = 0) { // phpcs:enable global $langs; @@ -2211,13 +2214,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -2247,14 +2250,14 @@ class Adherent extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Objet user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -2346,7 +2349,7 @@ class Adherent extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; @@ -2400,7 +2403,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -2410,7 +2413,7 @@ class Adherent extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -2422,13 +2425,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialise tableau info (tableau des attributs LDAP) * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -2536,7 +2539,7 @@ class Adherent extends CommonObject * @param int $id Id of member to load * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT a.rowid, a.datec as datec,'; $sql.= ' a.datevalid as datev,'; @@ -2592,7 +2595,7 @@ class Adherent extends CommonObject * * @return int Number of EMailings */ - function getNbOfEMailings() + public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; @@ -2774,9 +2777,13 @@ class Adherent extends CommonObject { $adherent->fetch_thirdparty(); + // Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company. + $languagefromcountrycode = getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code); + $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang); + // Send reminder email $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang); + $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); diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 9fd7a9b9d38..65085caf42a 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -89,7 +89,7 @@ class AdherentType extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->statut = 1; @@ -103,7 +103,7 @@ class AdherentType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; @@ -170,7 +170,7 @@ class AdherentType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -238,7 +238,7 @@ class AdherentType extends CommonObject * * @return int > 0 if OK, 0 if not found, < 0 if KO */ - function delete() + public function delete() { global $user; @@ -272,7 +272,7 @@ class AdherentType extends CommonObject * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; @@ -306,13 +306,13 @@ class AdherentType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of members' type * * @return array List of types of members */ - function liste_array() + public function liste_array() { // phpcs:enable global $conf,$langs; @@ -356,7 +356,7 @@ class AdherentType extends CommonObject * 2=Return array of members id only * @return mixed Array of members or -1 on error */ - function listMembersForMemberType($excludefilter = '', $mode = 0) + public function listMembersForMemberType($excludefilter = '', $mode = 0) { global $conf, $user; @@ -404,14 +404,14 @@ class AdherentType extends CommonObject } /** - * Return clicable name (with picto eventually) + * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen length max label - * @param int $notooltip 1=Disable tooltip - * @return string String with URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen length max label + * @param int $notooltip 1=Disable tooltip + * @return string String with URL */ - function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) { global $langs; @@ -434,12 +434,12 @@ class AdherentType extends CommonObject * * @return string Return status of a type of member */ - function getLibStatut() - { - return ''; - } + public function getLibStatut() + { + return ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -449,7 +449,7 @@ class AdherentType extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -461,13 +461,13 @@ class AdherentType extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialize the info array (array of LDAP values) that will be used to call LDAP functions * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -502,7 +502,7 @@ class AdherentType extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $conf, $user, $langs; @@ -530,7 +530,7 @@ class AdherentType extends CommonObject * * @return string Return mail content of type or empty */ - function getMailOnValid() + public function getMailOnValid() { global $conf; @@ -547,7 +547,7 @@ class AdherentType extends CommonObject * * @return string Return mail content of type or empty */ - function getMailOnSubscription() + public function getMailOnSubscription() { global $conf; @@ -565,16 +565,16 @@ class AdherentType extends CommonObject * * @return string Return mail model content of type or empty */ - function getMailOnResiliate() - { - global $conf; + public function getMailOnResiliate() + { + global $conf; - // NOTE mail_resiliate not defined so never used - if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined - { - return $this->mail_resiliate; - } + // NOTE mail_resiliate not defined so never used + if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined + { + return $this->mail_resiliate; + } - return ''; - } + return ''; + } } diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 7468ddb92a9..b9085b1f6b4 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -37,12 +37,12 @@ class AdherentStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -52,7 +52,7 @@ class AdherentStats extends Stats * @param int $socid Id third party * @param int $userid Id user for filter */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $user, $conf; @@ -85,7 +85,7 @@ class AdherentStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of nb each month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -105,7 +105,7 @@ class AdherentStats extends Stats * * @return array Array of nb each year */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -126,7 +126,7 @@ class AdherentStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of amount each month */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { global $user; @@ -147,7 +147,7 @@ class AdherentStats extends Stats * @param int $year Year * @return array Array of average each month */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -168,7 +168,7 @@ class AdherentStats extends Stats * * @return array Array with nb, total amount, average for each year */ - function getAllByYear() + public function getAllByYear() { global $user; diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 7e43e17fd6f..6948bce1e25 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -41,7 +41,7 @@ class Members extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -57,7 +57,7 @@ class Members extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); @@ -91,7 +91,7 @@ class Members extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $sqlfilters = '') { global $db, $conf; @@ -162,7 +162,7 @@ class Members extends DolibarrApi * @param array $request_data Request data * @return int ID of member */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); @@ -187,7 +187,7 @@ class Members extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); @@ -242,7 +242,7 @@ class Members extends DolibarrApi * @param int $id member ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->adherent->supprimer) { throw new RestException(401); @@ -277,7 +277,7 @@ class Members extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $member = array(); foreach (Members::$FIELDS as $field) { @@ -288,15 +288,16 @@ class Members extends DolibarrApi return $member; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); // Remove the subscriptions because they are handled as a subresource. @@ -328,7 +329,7 @@ class Members extends DolibarrApi * * @url GET {id}/subscriptions */ - function getSubscriptions($id) + public function getSubscriptions($id) { $obj_ret = array(); @@ -361,7 +362,7 @@ class Members extends DolibarrApi * * @url POST {id}/subscriptions */ - function createSubscription($id, $start_date, $end_date, $amount, $label = '') + public function createSubscription($id, $start_date, $end_date, $amount, $label = '') { if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { throw new RestException(401); @@ -389,7 +390,7 @@ class Members extends DolibarrApi * * @url GET {id}/categories */ - function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index e6ce4ace151..abfaf84993d 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -37,7 +37,7 @@ class MembersTypes extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -53,7 +53,7 @@ class MembersTypes extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); @@ -86,7 +86,7 @@ class MembersTypes extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -154,7 +154,7 @@ class MembersTypes extends DolibarrApi * @param array $request_data Request data * @return int ID of member type */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->adherent->configurer) { throw new RestException(401); @@ -179,7 +179,7 @@ class MembersTypes extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->adherent->configurer) { throw new RestException(401); @@ -220,7 +220,7 @@ class MembersTypes extends DolibarrApi * @param int $id member type ID * @return array */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->adherent->configurer) { throw new RestException(401); @@ -255,7 +255,7 @@ class MembersTypes extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $membertype = array(); foreach (MembersTypes::$FIELDS as $field) { @@ -266,15 +266,16 @@ class MembersTypes extends DolibarrApi return $membertype; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->array_options); diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 3089f2cfd98..e5173005460 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -40,7 +40,7 @@ class Subscriptions extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -56,7 +56,7 @@ class Subscriptions extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { throw new RestException(401); @@ -85,7 +85,7 @@ class Subscriptions extends DolibarrApi * * @throws RestException */ - function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -151,7 +151,7 @@ class Subscriptions extends DolibarrApi * @param array $request_data Request data * @return int ID of subscription */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { throw new RestException(401); @@ -176,7 +176,7 @@ class Subscriptions extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); @@ -209,7 +209,7 @@ class Subscriptions extends DolibarrApi * @param int $id ID of subscription to delete * @return array */ - function delete($id) + public function delete($id) { // The right to delete a subscription comes with the right to create one. if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { @@ -241,7 +241,7 @@ class Subscriptions extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $subscription = array(); foreach (Subscriptions::$FIELDS as $field) { diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 0d43b9d3f09..52cb8e05bbd 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -32,78 +32,78 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class Subscription extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element='subscription'; - - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='subscription'; + /** + * @var string ID to identify managed object + */ + public $element='subscription'; /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto='payment'; + * @var string Name of table without prefix where object is stored + */ + public $table_element='subscription'; - public $datec; // Date creation - public $datem; // Date modification - public $dateh; // Subscription start date (date subscription) - public $datef; // Subscription end date + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto='payment'; - /** + public $datec; // Date creation + public $datem; // Date modification + public $dateh; // Subscription start date (date subscription) + public $datef; // Subscription end date + + /** * @var int ID */ - public $fk_type; - public $fk_adherent; + public $fk_type; + public $fk_adherent; - public $amount; + public $amount; - /** + /** * @var int ID */ - public $fk_bank; + public $fk_bank; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Function who permitted cretaion of the subscription - * - * @param User $user User that create - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id subscription created if OK - */ - function create($user, $notrigger = false) - { - global $langs; + /** + * Function who permitted cretaion of the subscription + * + * @param User $user User that create + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id subscription created if OK + */ + public function create($user, $notrigger = false) + { + global $langs; - $error = 0; + $error = 0; - $now=dol_now(); + $now=dol_now(); - // Check parameters - if ($this->datef <= $this->dateh) - { - $this->error=$langs->trans("ErrorBadValueForDate"); - return -1; - } - if (empty($this->datec)) $this->datec = $now; + // Check parameters + if ($this->datef <= $this->dateh) + { + $this->error=$langs->trans("ErrorBadValueForDate"); + return -1; + } + if (empty($this->datec)) $this->datec = $now; - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; if ($this->fk_type == null) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; @@ -113,338 +113,338 @@ class Subscription extends CommonObject } else { $type=$this->fk_type; } - $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->idate($this->dateh)."',"; - $sql.= " '".$this->db->idate($this->datef)."',"; - $sql.= " ".$this->amount.","; - $sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')"; + $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; + $sql.= " '".$this->db->idate($this->dateh)."',"; + $sql.= " '".$this->db->idate($this->datef)."',"; + $sql.= " ".$this->amount.","; + $sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')"; - $resql = $this->db->query($sql); - if (! $resql) { - $error++; - $this->errors[] = $this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (! $resql) { + $error++; + $this->errors[] = $this->db->lasterror(); + } - if (! $error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - } + if (! $error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + } - if (! $error && ! $notrigger) - { - // Call triggers - $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (! $error && ! $notrigger) + { + // Call triggers + $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Method to load a subscription - * - * @param int $rowid Id subscription - * @return int <0 if KO, =0 if not found, >0 if OK - */ - function fetch($rowid) - { + /** + * Method to load a subscription + * + * @param int $rowid Id subscription + * @return int <0 if KO, =0 if not found, >0 if OK + */ + public function fetch($rowid) + { $sql ="SELECT rowid, fk_type, fk_adherent, datec,"; - $sql.=" tms,"; - $sql.=" dateadh as dateh,"; - $sql.=" datef,"; - $sql.=" subscription, note, fk_bank"; - $sql.=" FROM ".MAIN_DB_PREFIX."subscription"; - $sql.=" WHERE rowid=".$rowid; + $sql.=" tms,"; + $sql.=" dateadh as dateh,"; + $sql.=" datef,"; + $sql.=" subscription, note, fk_bank"; + $sql.=" FROM ".MAIN_DB_PREFIX."subscription"; + $sql.=" WHERE rowid=".$rowid; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->fk_type = $obj->fk_type; - $this->fk_adherent = $obj->fk_adherent; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->tms); - $this->dateh = $this->db->jdate($obj->dateh); - $this->datef = $this->db->jdate($obj->datef); - $this->amount = $obj->subscription; - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - return 1; - } - else - { - return 0; - } - } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - } + $this->fk_type = $obj->fk_type; + $this->fk_adherent = $obj->fk_adherent; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->tms); + $this->dateh = $this->db->jdate($obj->dateh); + $this->datef = $this->db->jdate($obj->datef); + $this->amount = $obj->subscription; + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + return 1; + } + else + { + return 0; + } + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } - /** - * Update subscription - * - * @param User $user User who updated - * @param int $notrigger 0=Disable triggers - * @return int <0 if KO, >0 if OK - */ - function update($user, $notrigger = 0) - { - $error = 0; + /** + * Update subscription + * + * @param User $user User who updated + * @param int $notrigger 0=Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; - $sql .= " fk_type = ".$this->fk_type.","; - $sql .= " fk_adherent = ".$this->fk_adherent.","; - $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; - $sql .= " subscription = '".price2num($this->amount)."',"; - $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; - $sql .= " datef='".$this->db->idate($this->datef)."',"; - $sql .= " datec='".$this->db->idate($this->datec)."',"; - $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; + $sql .= " fk_type = ".$this->fk_type.","; + $sql .= " fk_adherent = ".$this->fk_adherent.","; + $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; + $sql .= " subscription = '".price2num($this->amount)."',"; + $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; + $sql .= " datef='".$this->db->idate($this->datef)."',"; + $sql .= " datec='".$this->db->idate($this->datec)."',"; + $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); - $result=$member->update_end_date($user); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member=new Adherent($this->db); + $result=$member->fetch($this->fk_adherent); + $result=$member->update_end_date($user); - if (! $error && ! $notrigger) { - // Call triggers - $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } - else - { - $error++; - $this->error=$this->db->lasterror(); - } + if (! $error && ! $notrigger) { + // Call triggers + $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); + if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } + else + { + $error++; + $this->error=$this->db->lasterror(); + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Delete a subscription - * - * @param User $user User that delete - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, 0 if not found, >0 if OK - */ - function delete($user, $notrigger = false) - { - $error = 0; + /** + * Delete a subscription + * + * @param User $user User that delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function delete($user, $notrigger = false) + { + $error = 0; - // It subscription is linked to a bank transaction, we get it - if ($this->fk_bank > 0) - { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountline=new AccountLine($this->db); - $result=$accountline->fetch($this->fk_bank); - } + // It subscription is linked to a bank transaction, we get it + if ($this->fk_bank > 0) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $accountline=new AccountLine($this->db); + $result=$accountline->fetch($this->fk_bank); + } - $this->db->begin(); + $this->db->begin(); - if (! $error) { - if (! $notrigger) { - // Call triggers - $result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } + if (! $error) { + if (! $notrigger) { + // Call triggers + $result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $num=$this->db->affected_rows($resql); - if ($num) - { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); - $result=$member->update_end_date($user); + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->affected_rows($resql); + if ($num) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member=new Adherent($this->db); + $result=$member->fetch($this->fk_adherent); + $result=$member->update_end_date($user); - if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) - { - $result=$accountline->delete($user); // Return false if refused because line is conciliated - if ($result > 0) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$accountline->error; - $this->db->rollback(); - return -1; - } - } - else - { - $this->db->commit(); - return 1; - } - } - else - { - $this->db->commit(); - return 0; - } - } - else - { - $error++; - $this->error=$this->db->lasterror(); - } - } + if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) + { + $result=$accountline->delete($user); // Return false if refused because line is conciliated + if ($result > 0) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$accountline->error; + $this->db->rollback(); + return -1; + } + } + else + { + $this->db->commit(); + return 1; + } + } + else + { + $this->db->commit(); + return 0; + } + } + else + { + $error++; + $this->error=$this->db->lasterror(); + } + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Return clicable name (with picto eventually) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $notooltip 1=Disable tooltip - * @param string $option Page for link ('', 'nolink', ...) - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string Chaine avec URL - */ - function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) - { - global $langs; + * @param string $option Page for link ('', 'nolink', ...) + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine avec URL + */ + public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) + { + global $langs; - $result=''; + $result=''; - $langs->load("members"); + $langs->load("members"); $label=$langs->trans("ShowSubscription").': '.$this->ref; $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkstart = ''; - $linkend = ''; + $linkend = ''; - $picto='payment'; + $picto='payment'; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; - return $result; - } + return $result; + } - /** - * Retourne le libelle du statut d'une adhesion - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label - */ - function getLibStatut($mode = 0) - { - return ''; - } + /** + * Retourne le libelle du statut d'une adhesion + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label + */ + public function getLibStatut($mode = 0) + { + return ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $statut Id statut - * @return string Label - */ - function LibStatut($statut) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @return string Label + */ + public function LibStatut($statut) + { // phpcs:enable - global $langs; - $langs->load("members"); - return ''; - } + global $langs; + $langs->load("members"); + return ''; + } /** * Load information of the subscription object - * + * * @param int $id Id subscription * @return void */ - function info($id) - { - $sql = 'SELECT c.rowid, c.datec,'; - $sql.= ' c.tms as datem'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; - $sql.= ' WHERE c.rowid = '.$id; + public function info($id) + { + $sql = 'SELECT c.rowid, c.datec,'; + $sql.= ' c.tms as datem'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; + $sql.= ' WHERE c.rowid = '.$id; - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + } - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 8828a72df28..bd5f70d0973 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -511,7 +511,7 @@ if (! empty($arrayfields['state.nom']['checked'])) if (! empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Phone pro diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php new file mode 100644 index 00000000000..b7f1f0e6db9 --- /dev/null +++ b/htdocs/admin/bom.php @@ -0,0 +1,560 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/bom.php + * \ingroup bom + * \brief Setup page of module BOM + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'errors', 'mrp', 'other')); + +if (! $user->admin) accessforbidden(); + +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scan_dir', 'alpha'); +$type = 'bom'; + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + +if ($action == 'updateMask') +{ + $maskconstbom=GETPOST('maskconstBom', 'alpha'); + $maskbom=GETPOST('maskBom', 'alpha'); + + if ($maskconstbom) $res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +elseif ($action == 'specimen') +{ + $modele=GETPOST('module', 'alpha'); + + $bom = new BOM($db); + $bom->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($bom, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bom&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } + else + { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +// Activate a model +elseif ($action == 'set') +{ + $ret = addDocumentModel($value, $type, $label, $scandir); +} + +elseif ($action == 'del') +{ + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity); + } +} + +// Set default model +elseif ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "BOM_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->BOM_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + +elseif ($action == 'setmod') +{ + // TODO Check if numbering module chosen can be activated + // by calling method canBeActivated + + dolibarr_set_const($db, "BOM_ADDON", $value, 'chaine', 0, '', $conf->entity); +} + +elseif ($action == 'set_BOM_DRAFT_WATERMARK') +{ + $draft = GETPOST("BOM_DRAFT_WATERMARK"); + $res = dolibarr_set_const($db, "BOM_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +elseif ($action == 'set_BOM_FREE_TEXT') +{ + $freetext = GETPOST("BOM_FREE_TEXT", 'none'); // No alpha here, we want exact string + + $res = dolibarr_set_const($db, "BOM_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} elseif ($action=="setshippableiconinlist") { + // Activate Set Shippable Icon In List + $setshippableiconinlist = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "SHIPPABLE_BOM_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); + if (! $res > 0) $error++; + if (! $error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + + +/* + * View + */ + +$form=new Form($db); + +$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + +llxHeader("", $langs->trans("BOMsSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("BOMsSetup"), $linkback, 'title_setup'); + +$head = bomAdminPrepareHead(); + +dol_fiche_head($head, 'settings', $langs->trans("BOMs"), -1, 'bom'); + +/* + * BOMs Numbering model + */ + +print load_fiche_titre($langs->trans("BOMsNumberingModules"), '', ''); + +print '
' . $langs->trans("Label") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . 'Total' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . 'Total
' . price($line->debit) . '' . price($line->credit) . ''; + print ''; print 'id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">'; print img_edit(); print '  '; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index bc4b815100b..c1716dc18af 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -606,18 +606,18 @@ print "
'; +print ''; print $langs->trans('From') . ': '; print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1); print '
'; @@ -297,7 +297,7 @@ print '
'; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -305,14 +305,14 @@ print '
 '.$line->piece_num.'' . dol_print_date($line->doc_date, 'day') . '' . dol_print_date($line->doc_date, 'day') . ''; @@ -384,9 +384,9 @@ while ($i < min($num, $limit)) $accountingjournal = new AccountingJournal($db); $result = $accountingjournal->fetch('', $line->code_journal); $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); - print '' . $journaltoshow . '' . $journaltoshow . ''; + print ''; print '' . img_edit() . ' '; print '' . img_delete() . ''; print '' . price($obj->debit) . '' . price($obj->credit) . '' . price(round($solde, 2)) . '' . $obj->code_journal . '' . $obj->code_journal . '' . $obj->lettering_code . '' . $obj->lettering_code . '
' . price($obj->debit) . '' . price($obj->credit) . '' . price(round($solde, 2)) . '' . $obj->code_journal . '' . $obj->code_journal . '' . $obj->lettering_code . '' . $obj->lettering_code . '
'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } print ''; $formother->select_year($search_year, 'search_year', 1, 20, 5); print ''; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print "
' . $facture_static->getNomUrl(1) . '' . dol_print_date($db->jdate($objp->datef), 'day') . '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; @@ -391,7 +393,7 @@ if ($result) { print '' . $objp->tva_intra . ''; + print ''; print $codecompta . ' '; print img_edit(); print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 6a7d59a46ce..3d6469f6961 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -376,7 +376,9 @@ if ($result) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } print ''; $formother->select_year($search_year, 'search_year', 1, 20, 5); print ''; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print '
' . $facture_static->getNomUrl(1) . '' . dol_print_date($db->jdate($objp->datef), 'day') . '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; @@ -513,7 +515,7 @@ if ($result) { print '' . $objp->tva_intra . ''; + print ''; print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown")); if ($objp->product_id > 0) { @@ -523,12 +525,12 @@ if ($result) { print ''; + print ''; print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; + print ''; print 'aarowid ? "checked" : "") . '/>'; print ''; @@ -282,15 +282,15 @@ if ($result) { print '
' . $expensereport_static->getNomUrl(1) . '' . dol_print_date($db->jdate($objp->date), 'day') . '' . dol_print_date($db->jdate($objp->date), 'day') . '' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '' . price($objp->total_ht) . '' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '' . $codeCompta . ''; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print '
' . $expensereport_static->getNomUrl(1) . '' . dol_print_date($db->jdate($objp->date), 'day') . '' . dol_print_date($db->jdate($objp->date), 'day') . ''; @@ -386,16 +386,16 @@ if ($result) { print ''; + print ''; print length_accountg(html_entity_decode($objp->code_buy)); print ''; + print ''; print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; + print ''; print 'aarowid ? "checked" : "") . '/>'; print '" . $langs->trans("SubledgerAccount") . "" . $langs->trans("LabelOperation") . "" . $langs->trans("PaymentMode") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $val["type_payment"] . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $reflabel . "" . $val["type_payment"] . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
" . $reflabel . "" . $val["type_payment"] . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
'; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print '
' . dol_print_date($db->jdate($objp->datef), 'day') . '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; @@ -404,7 +404,7 @@ if ($result) { print '' . $objp->tva_intra . ''; + print ''; print $codecompta . ' '; print img_edit(); print ''; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print '
' . dol_print_date($db->jdate($objp->datef), 'day') . '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; @@ -506,7 +506,7 @@ if ($result) { print '' . $objp->tva_intra . ''; + print ''; print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown")); if ($objp->product_id > 0) { @@ -516,12 +516,12 @@ if ($result) { print ''; + print ''; print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; + print ''; print 'aarowid ? "checked" : "") . '/>'; print ''; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''."\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/bom/"); + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file)-4); + + require_once $dir.$file.'.php'; + + $module = new $file($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + + print ''; + + // Show example of numbering model + print ''."\n"; + + print ''; + + $bom=new BOM($db); + $bom->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $bom->type=0; + $nextval=$module->getNextValue($mysoc, $bom); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print "\n"; + } + } + } + closedir($handle); + } + } +} +print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->name."\n"; + print $module->info(); + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + if ($conf->global->BOM_ADDON == $file) + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } + else + { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '

\n"; + + +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) +{ + /* + * Document templates generators + */ + + print load_fiche_titre($langs->trans("BOMsModelModule"), '', ''); + + // Load array def with activated templates + $def = array(); + $sql = "SELECT nom"; + $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; + $sql.= " WHERE type = '".$type."'"; + $sql.= " AND entity = ".$conf->entity; + $resql=$db->query($sql); + if ($resql) + { + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } + } + else + { + dol_print_error($db); + } + + + print "\n"; + print "\n"; + print ''; + print ''; + print '\n"; + print '\n"; + print ''; + print ''; + print "\n"; + + clearstatcache(); + + foreach ($dirmodels as $reldir) + { + foreach (array('','/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/bom".$valdir); + + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + + if ($modulequalified) + { + $var = !$var; + print ''; + + // Active + if (in_array($name, $def)) + { + print ''; + } + else + { + print '"; + } + + // Default + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + //$htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + //$htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1); + + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } + } + + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; + if ($conf->global->BOM_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; + print "
"; + + /* + * Other options + */ + + print load_fiche_titre($langs->trans("OtherOptions"), '', ''); + print ''; + print ''; + print ''; + print ''; + print "\n"; + print "\n"; + + $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); + $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); + $htmltext = ''.$langs->trans("AvailableVariables").':
'; + foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; + $htmltext.='
'; + + print ''; + print ''; + print ''; + print '\n"; + print ''; + + //Use draft Watermark + + print ""; + print ''; + print ""; + print '\n"; + print ''; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; + print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; + $variablename='BOM_FREE_TEXT'; + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) + { + print ''; + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); + } + print '
'; + print ''; + print "
'; + print $form->textwithpicto($langs->trans("WatermarkOnDraftBOMs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; + print '
'; + print ''; + print ''; + print ''; + print "
'; + print '
'; +} + +/* + * Notifications + */ +/* +print load_fiche_titre($langs->trans("Notifications"), '', ''); +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +print '\n"; + +print '
'.$langs->trans("Parameter").' 
'; +print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'
'; +print '
'; +print "
'; +*/ + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 1f3e23e05d6..455175220a8 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -300,7 +300,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print ''.$module->nom."\n"; + print ''.$module->name."\n"; print $module->info(); print ''; diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 9c691c88e88..f4ed611ac03 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -69,7 +69,7 @@ class PrestaShopWebservice * @param string $key Authentification key * @param mixed $debug Debug mode Activated (true) or deactivated (false) */ - function __construct($url, $key, $debug = true) + public function __construct($url, $key, $debug = true) { if (!extension_loaded('curl')) throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library'); @@ -77,7 +77,7 @@ class PrestaShopWebservice $this->key = $key; $this->debug = $debug; $this->version = 'unknown'; - } + } /** * Take the status code and throw an exception if the server didn't return 200 or 201 code diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index b3a9f037e95..8a27072fad1 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -54,7 +54,7 @@ class Dolistore * * @param boolean $debug Enable debug of request on screen */ - function __construct($debug = false) + public function __construct($debug = false) { global $conf, $langs; @@ -77,7 +77,7 @@ class Dolistore * @param array $options Options * @return void */ - function getRemoteData($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) + public function getRemoteData($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) { global $conf, $langs; @@ -163,14 +163,14 @@ class Dolistore } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return tree of Dolistore categories. $this->categories must have been loaded before. * * @param int $parent Id of parent category * @return string */ - function get_categories($parent = 0) + public function get_categories($parent = 0) { // phpcs:enable if (!isset($this->categories)) die('not possible'); @@ -212,13 +212,13 @@ class Dolistore } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of product formated for output * * @return string HTML output */ - function get_products() + public function get_products() { // phpcs:enable global $langs, $conf; @@ -291,44 +291,44 @@ class Dolistore '.$download_link.' '; - } - return $html; - } + } + return $html; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * get previous link * * @param string $text symbol previous * @return string html previous link */ - function get_previous_link($text = '<<') + public function get_previous_link($text = '<<') { // phpcs:enable return ''.$text.''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * get next link * * @param string $text symbol next * @return string html next link */ - function get_next_link($text = '>>') + public function get_next_link($text = '>>') { // phpcs:enable return ''.$text.''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * get previous url * * @return string previous url */ - function get_previous_url() - { + public function get_previous_url() + { // phpcs:enable $param_array = array(); if ($this->start < $this->per_page) { @@ -343,15 +343,15 @@ class Dolistore } $param = http_build_query($param_array); return $this->url."&".$param; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * get next url * * @return string next url */ - function get_next_url() + public function get_next_url() { // phpcs:enable $param_array = array(); @@ -369,7 +369,7 @@ class Dolistore return $this->url."&".$param; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * version compare * @@ -377,7 +377,7 @@ class Dolistore * @param string $v2 version 2 * @return int result of compare */ - function version_compare($v1, $v2) + public function version_compare($v1, $v2) { // phpcs:enable $v1 = explode('.', $v1); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 630e04d2f89..c735362d87f 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -457,10 +457,10 @@ if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouM print load_fiche_titre($langs->trans("ModulesSetup"), $moreinfo, 'title_setup'); // Start to show page -if ($mode=='common') print ''.$langs->trans("ModulesDesc")."
\n"; -if ($mode=='marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; -if ($mode=='deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; -if ($mode=='develop') print ''.$langs->trans("ModulesDevelopDesc")."
\n"; +if ($mode=='common') print ''.$langs->trans("ModulesDesc")."
\n"; +if ($mode=='marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; +if ($mode=='deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; +if ($mode=='develop') print ''.$langs->trans("ModulesDevelopDesc")."
\n"; $head = modules_prepare_head(); diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 5bbd6746573..f532db76ce4 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -81,7 +81,7 @@ if ($action == 'addprinter' && $user->admin) { } if (! $error) { - $result= $printer->AddPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter); + $result= $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter); if ($result > 0) $error++; if (! $error) @@ -107,7 +107,7 @@ if ($action == 'deleteprinter' && $user->admin) { } if (! $error) { - $result= $printer->DeletePrinter($printerid); + $result= $printer->deletePrinter($printerid); if ($result > 0) $error++; if (! $error) @@ -133,7 +133,7 @@ if ($action == 'updateprinter' && $user->admin) { } if (! $error) { - $result= $printer->UpdatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid); + $result= $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid); if ($result > 0) $error++; if (! $error) { @@ -156,7 +156,7 @@ if ($action == 'testprinter' && $user->admin) { if (! $error) { // test - $ret = $printer->SendTestToPrinter($printerid); + $ret = $printer->sendTestToPrinter($printerid); if ($ret == 0) { setEventMessages($langs->trans("TestSentToPrinter", $printername), null); } else { @@ -176,7 +176,7 @@ if ($action == 'updatetemplate' && $user->admin) { } if (! $error) { - $result= $printer->UpdateTemplate($templatename, $template, $templateid); + $result= $printer->updateTemplate($templatename, $template, $templateid); if ($result > 0) $error++; if (! $error) { diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 9d4d5f88bb9..df2d2b09ee6 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -212,7 +212,7 @@ if (is_resource($handle)) { while (($file = readdir($handle))!==false) { - if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i', $file, $reg)) + if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) { // Charging the numbering class $classname = $reg[1]; @@ -398,7 +398,6 @@ print ''.$langs->trans("Action").''; print ''; // Disable clear password in database - print ''; print ''.$langs->trans("DoNotStoreClearPassword").''; print ''; @@ -413,6 +412,8 @@ if (! $conf->global->DATABASE_PWD_ENCRYPTED) print ''.$langs->trans("Activate").''; print ""; } + +// Database conf file encryption if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) { print ''; @@ -494,9 +495,21 @@ print ''; print ''; print ''; +print '
'; - -//print ''; +if (GETPOST('info', 'int') > 0) +{ + if (function_exists('password_hash')) + { + print $langs->trans("Note: The function password_hash exists on your PHP")."
\n"; + } + else + { + print $langs->trans("Note: The function password_hash does not exists on your PHP")."
\n"; + } + print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; + print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; +} print ''; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index f94117ef747..052e11f1ced 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -19,7 +19,7 @@ /** * \file admin/ticket.php * \ingroup ticket - * \brief This file is a module setup page + * \brief Page to setup module ticket */ require '../main.inc.php'; @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; // Load translation files required by the page -$langs->load("ticket"); +$langs->loadLangs(array("admin", "ticket")); // Access control if (!$user->admin) { @@ -91,16 +91,6 @@ if ($action == 'updateMask') { $error++; } - $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha'); - if (!empty($mail_new_ticket)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); if (!empty($mail_intro)) { $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); @@ -121,36 +111,6 @@ if ($action == 'updateMask') { $error++; } - $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - - $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - - $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha'); if (!empty($text_help)) { $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); @@ -163,26 +123,14 @@ if ($action == 'updateMask') { } if ($action == 'setvarother') { - $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } - $param_disable_email = GETPOST('TICKET_DISABLE_ALL_MAILS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_DISABLE_ALL_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - - $param_activate_log_by_email = GETPOST('TICKET_ACTIVATE_LOG_BY_EMAIL', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_ACTIVATE_LOG_BY_EMAIL', $param_activate_log_by_email, 'chaine', 0, '', $conf->entity); + $param_disable_email = GETPOST('TICKET_DISABLE_NOTIFICATION_MAILS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_DISABLE_NOTIFICATION_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } @@ -242,9 +190,7 @@ $head = ticketAdminPrepareHead(); dol_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket"); -print $langs->trans("TicketSetupDictionaries") . ' : ' . dol_buildpath('/admin/dict.php', 2) . '
'; - -print $langs->trans("TicketPublicAccess") . ' : ' . dol_buildpath('/public/ticket/index.php', 2) . ''; +print ''.$langs->trans("TicketSetupDictionaries") . ' : ' . dol_buildpath('/admin/dict.php', 2) . '
'; dol_fiche_end(); @@ -353,80 +299,19 @@ if (!$conf->use_javascript_ajax) { print ''; print ''; } -print load_fiche_titre($langs->trans("TicketParamPublicInterface")); - -print ''; - -// Activate public interface -print ''; -print ''; -print ''; -print ''; - -// Check if email exists -print ''; -print ''; -print ''; -print ''; - -/*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) -{ - // Show logo for module - print ''; - print ''; - print ''; - print ''; -}*/ - -// Show logo for company -print ''; -print ''; -print ''; -print ''; - -print '
' . $langs->trans("TicketsActivatePublicInterface") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_ENABLE_PUBLIC_INTERFACE'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_ENABLE_PUBLIC_INTERFACE", $arrval, $conf->global->TICKET_ENABLE_PUBLIC_INTERFACE); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsActivatePublicInterfaceHelp"), 1, 'help'); -print '
' . $langs->trans("TicketsEmailMustExist") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); -print '
' . $langs->trans("TicketsShowModuleLogo") . ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); - print '
' . $langs->trans("TicketsShowCompanyLogo") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); -print '

'; print load_fiche_titre($langs->trans("TicketParams")); print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + // Activate email notifications -print ''; +/* +print ''; print ''; print ''; // Activate log by email -print ''; +print ''; print ''; print ''; +*/ // Also send to main email address if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; + print ''; print ''; +/* +print ''; print ''; print ''; +*/ -if (!$conf->use_javascript_ajax) { +/*if (!$conf->use_javascript_ajax) { print ''; print ''; -} +}*/ // Auto assign ticket at user who created it -print ''; +print ''; print ''; -print ''; -print ''; +print '
'; +print ''; +print '
'; -// Interface topic -$url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; -print ''; -print ''; -print ''; - -// Texte d'accueil homepage -$public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); -print ''; -print ''; - -// Texte d'aide à la saisie du message -$public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); -print ''; -print ''; - -print ''; -print ''; - -print '
' . $langs->trans("Parameter") . '
' . $langs->trans("TicketsDisableEmail") . '
' . $langs->trans("TicketsDisableEmail") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_DISABLE_ALL_MAILS'); @@ -441,7 +326,7 @@ print '
' . $langs->trans("TicketsLogEnableEmail") . '
' . $langs->trans("TicketsLogEnableEmail") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL'); @@ -454,11 +339,12 @@ print ''; print $form->textwithpicto('', $langs->trans("TicketsLogEnableEmailHelp"), 1, 'help'); print '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); @@ -474,7 +360,8 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) } // Limiter la vue des tickets à ceux assignés à l'utilisateur -print '
' . $langs->trans("TicketsLimitViewAssignedOnly") . '
' . $langs->trans("TicketsLimitViewAssignedOnly") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_LIMIT_VIEW_ASSIGNED_ONLY'); @@ -487,14 +374,15 @@ print ''; print $form->textwithpicto('', $langs->trans("TicketsLimitViewAssignedOnlyHelp"), 1, 'help'); print '
' . $langs->trans("TicketsAutoAssignTicket") . '
' . $langs->trans("TicketsAutoAssignTicket") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); @@ -515,7 +403,7 @@ if (!$conf->use_javascript_ajax) { } // Admin var of module -print load_fiche_titre($langs->trans("TicketParamMail")); +print load_fiche_titre($langs->trans("Notification")); print ''; @@ -533,17 +421,26 @@ if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { print "\n"; } -// Email d'envoi des notifications -print ''; +// Activate log by email +/*print ''; print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_ACTIVATE_LOG_BY_EMAIL", $arrval, $conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL); +} +print ''; print ''; print ''; +*/ + +// @TODO Use module notification instead... // Email de réception des notifications -print ''; +print ''; print ''; print ''; print ''; -// Texte de création d'un ticket -$mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); -print ''; +// Email d'envoi des notifications +print ''; +print ''; print ''; +print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); +print ''; +print ''; // Texte d'introduction $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText'); -print ''; // Texte de signature $mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText'); -print ''; -print ''; -print ''; -print "\n"; +print '
' . $langs->trans("TicketEmailNotificationFrom") . '
' . $langs->trans("TicketsLogEnableEmail") . ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); +print $form->textwithpicto('', $langs->trans("TicketsLogEnableEmailHelp"), 1, 'help'); print '
' . $langs->trans("TicketEmailNotificationTo") . '
' . $langs->trans("TicketEmailNotificationTo") . ''; print ''; @@ -551,21 +448,18 @@ print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1 print '
' . $langs->trans("TicketNewEmailBodyLabel") . ''; -print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); -$doleditor->Create(); -print '
' . $langs->trans("TicketEmailNotificationFrom") . ''; +print ''; -print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); -print '
' . $langs->trans("TicketMessageMailIntroLabelAdmin") . ''; +print '
' . $langs->trans("TicketMessageMailIntroLabelAdmin") . ''; print ''; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); @@ -577,7 +471,7 @@ print '
' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . ''; +print '
' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . ''; print ''; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); @@ -587,58 +481,12 @@ print ''; print $form->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelpAdmin"), 1, 'help'); print '
' . $langs->trans("PublicInterface") . '
'; -// Url public interface -$url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; -print '
' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; -print ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); -print '
' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; -print ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); -print '
' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . ''; -print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); -$doleditor->Create(); -print ''; -print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); -print '
' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . ''; -print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); -$doleditor->Create(); -print ''; -print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); -print '

'; print ''; // End of page diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php new file mode 100644 index 00000000000..939a357999b --- /dev/null +++ b/htdocs/admin/ticket_public.php @@ -0,0 +1,453 @@ + + * Copyright (C) 2016 Christophe Battarel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file admin/ticket_public.php + * \ingroup ticket + * \brief Page to public interface of module Ticket + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; + +// Load translation files required by the page +$langs->loadLangs(array("admin", "ticket")); + +// Access control +if (!$user->admin) { + accessforbidden(); +} + +// Parameters +$value = GETPOST('value', 'alpha'); +$action = GETPOST('action', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scandir', 'alpha'); +$type = 'ticket'; + +if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') +{ + if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); + else dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); +} + +if ($action == 'setvar') { + include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; + + $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha'); + if (!empty($notification_email)) { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + // altairis : differentiate notification email FROM and TO + $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha'); + if (!empty($notification_email_to)) { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha'); + if (!empty($mail_new_ticket)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); + if (!empty($mail_intro)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha'); + if (!empty($text_help)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } +} + +if ($action == 'setvarother') { + $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + $param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + } + + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + } + + $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } +} + + + +/* + * View + */ + +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + +$form = new Form($db); + +$help_url = "FR:Module_Ticket"; +$page_name = "TicketSetup"; +llxHeader('', $langs->trans($page_name), $help_url); + +// Subheader +$linkback = '' . $langs->trans("BackToModuleList") . ''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); + +// Configuration header +$head = ticketAdminPrepareHead(); + +dol_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); + +print ''.$langs->trans("TicketPublicAccess") . ' : ' . dol_buildpath('/public/ticket/index.php', 2) . ''; + +dol_fiche_end(); + + +$enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; +if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) +{ + // Button off, click to enable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml.=''; +} +else +{ + // Button on, click to disable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml.=''; +} +print $enabledisablehtml; +print ''; + +print '

'; + +if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) +{ + + if (!$conf->use_javascript_ajax) { + print '
'; + print ''; + print ''; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + + // Check if email exists + print ''; + print ''; + print ''; + print ''; + + /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + // Show logo for module + print ''; + print ''; + print ''; + print ''; + }*/ + + // Show logo for company + print ''; + print ''; + print ''; + print ''; + + // Also send to main email address + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + print ''; + print ''; + print ''; + print ''; + } + + if (!$conf->use_javascript_ajax) { + print ''; + print ''; + } + + // Auto assign ticket at user who created it + print ''; + print ''; + print ''; + print ''; + + print '
' . $langs->trans("Parameters") . ''; + print ''; + print '
' . $langs->trans("TicketsEmailMustExist") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsShowModuleLogo") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsShowCompanyLogo") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsAutoAssignTicket") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1, 'help'); + print '

'; + + if (!$conf->use_javascript_ajax) { + print '
'; + } + + // Admin var of module + print load_fiche_titre($langs->trans("TicketParamMail")); + + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print "\n"; + + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { + print ''; + print ''; + print "\n"; + } + + // Url public interface + $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; + print ''; + print ''; + print ''; + + // Interface topic + $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; + print ''; + print ''; + print ''; + + // Texte d'accueil homepage + $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); + print ''; + print ''; + + // Texte d'aide à la saisie du message + $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); + print ''; + print ''; + + // Activate email creation to user + print ''; + print ''; + print ''; + print ''; + + // Texte de création d'un ticket + $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); + print ''; + print ''; + + print '
' . $langs->trans("Parameter") . '
' . $langs->trans("TicketCkEditorEmailNotActivated") . '
' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); + print '
' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . ''; + print ''; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . ''; + print ''; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketsDisableCustomerEmail") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); + print '
' . $langs->trans("TicketNewEmailBodyLabel") . ''; + print ''; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); + print '
'; + + print '
'; + + print ''; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 5595f94a950..6c9074226dc 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -37,7 +37,7 @@ class DolibarrApi /** * @var Restler $r Restler object */ - var $r; + public $r; /** * Constructor @@ -46,7 +46,7 @@ class DolibarrApi * @param string $cachedir Cache dir * @param boolean $refreshCache Update cache */ - function __construct($db, $cachedir = '', $refreshCache = false) + public function __construct($db, $cachedir = '', $refreshCache = false) { global $conf, $dolibarr_main_url_root; @@ -87,16 +87,16 @@ class DolibarrApi ); }*/ - + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable // Remove $db object property for object unset($object->db); unset($object->isextrafieldmanaged); @@ -208,6 +208,7 @@ class DolibarrApi return $object; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Check user access to a resource * @@ -222,9 +223,9 @@ class DolibarrApi * @return bool * @throws RestException */ - static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') + protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') { - + // phpcs:enable // Features/modules to check $featuresarray = array($resource); if (preg_match('/&/', $resource)) { @@ -240,16 +241,18 @@ class DolibarrApi } return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select); - } + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Return if a $sqlfilters parameter is valid * * @param string $sqlfilters sqlfilter string * @return boolean True if valid, False if not valid */ - function _checkFilters($sqlfilters) + protected function _checkFilters($sqlfilters) { + // phpcs:enable //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); $tmp=$sqlfilters; @@ -271,14 +274,15 @@ class DolibarrApi return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Function to forge a SQL criteria * * @param array $matches Array of found string by regex search * @return string Forged criteria. Example: "t.field like 'abc%'" */ - static function _forge_criteria_callback($matches) + protected static function _forge_criteria_callback($matches) { // phpcs:enable global $db; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 9c748fb5f03..010bb854f25 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -173,20 +173,20 @@ class DolibarrApiAccess implements iAuthenticate * @example Digest * @example OAuth */ - public function __getWWWAuthenticateString() + public function __getWWWAuthenticateString() { // phpcs:enable return ''; } - /** - * Verify access - * - * @param array $m Properties of method - * - * @access private - * @return bool - */ + /** + * Verify access + * + * @param array $m Properties of method + * + * @access private + * @return bool + */ public static function verifyAccess(array $m) { $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 7473bc5db5e..f4a7084b336 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -43,7 +43,7 @@ class Documents extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -67,7 +67,7 @@ class Documents extends DolibarrApi * * @url GET /download */ - public function index($module_part, $original_file='') + public function index($module_part, $original_file = '') { global $conf, $langs; @@ -82,12 +82,11 @@ class Documents extends DolibarrApi $entity=$conf->entity; $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); - $accessallowed = $check_access['accessallowed']; + $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; - $original_file = $check_access['original_file']; + $original_file = $check_access['original_file']; - if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) - { + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { throw new RestException(401); } if (!$accessallowed) { @@ -127,7 +126,7 @@ class Documents extends DolibarrApi * * @url PUT /builddoc */ - public function builddoc($module_part, $original_file='', $doctemplate='', $langcode='') + public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '') { global $conf, $langs; @@ -153,7 +152,7 @@ class Documents extends DolibarrApi $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; - if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) { + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { throw new RestException(401); } if (!$accessallowed) { @@ -245,7 +244,7 @@ class Documents extends DolibarrApi * * @url GET / */ - function getDocumentsListByElement($modulepart, $id=0, $ref='', $sortfield='', $sortorder='') + public function getDocumentsListByElement($modulepart, $id = 0, $ref = '', $sortfield = '', $sortorder = '') { global $conf; @@ -275,7 +274,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id; } - else if ($modulepart == 'adherent' || $modulepart == 'member') + elseif ($modulepart == 'adherent' || $modulepart == 'member') { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -291,7 +290,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member'); } - else if ($modulepart == 'propal' || $modulepart == 'proposal') + elseif ($modulepart == 'propal' || $modulepart == 'proposal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; @@ -307,7 +306,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); } - else if ($modulepart == 'commande' || $modulepart == 'order') + elseif ($modulepart == 'commande' || $modulepart == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -323,7 +322,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->commande->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'commande'); } - else if ($modulepart == 'shipment' || $modulepart == 'expedition') + elseif ($modulepart == 'shipment' || $modulepart == 'expedition') { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; @@ -339,7 +338,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->expedition->dir_output . "/sending/" . get_exdir(0, 0, 0, 1, $object, 'shipment'); } - else if ($modulepart == 'facture' || $modulepart == 'invoice') + elseif ($modulepart == 'facture' || $modulepart == 'invoice') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -355,7 +354,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); } - else if ($modulepart == 'produit' || $modulepart == 'product') + elseif ($modulepart == 'produit' || $modulepart == 'product') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -371,7 +370,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->product->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'product'); } - else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') + elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -392,7 +391,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.'); } @@ -428,6 +427,7 @@ class Documents extends DolibarrApi * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) {@example '' or 'base64'} * @param int $overwriteifexists Overwrite file if exists (1 by default) + * @return string * * @throws 200 * @throws 400 @@ -437,7 +437,7 @@ class Documents extends DolibarrApi * * @url POST /upload */ - public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) + public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0) { global $db, $conf; @@ -517,7 +517,7 @@ class Documents extends DolibarrApi if($result == 0) { throw new RestException(404, "Object with ref '".$ref."' was not found."); - } + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object.'); @@ -592,6 +592,7 @@ class Documents extends DolibarrApi return dol_basename($destfile); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Validate fields before create or update object * @@ -599,7 +600,9 @@ class Documents extends DolibarrApi * @return array * @throws RestException */ - function _validate_file($data) { + private function _validate_file($data) + { + // phpcs:enable $result = array(); foreach (Documents::$DOCUMENT_FIELDS as $field) { if (!isset($data[$field])) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 43a0aeb9bbb..2bf464f7296 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -29,11 +29,11 @@ class Login /** * Constructor of the class */ - function __construct() + public function __construct() { - global $db; - $this->db = $db; - } + global $db; + $this->db = $db; + } /** * Login @@ -136,5 +136,5 @@ class Login 'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') ) ); - } + } } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 00a84a00555..783ec6540e3 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -38,7 +38,7 @@ class Setup extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -61,7 +61,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -76,7 +76,7 @@ class Setup extends DolibarrApi { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -128,7 +128,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') + public function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') { $list = array(); @@ -195,7 +195,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getCountryByID($id, $lang = '') + public function getCountryByID($id, $lang = '') { $country = new Ccountry($this->db); @@ -228,7 +228,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -273,14 +273,16 @@ class Setup extends DolibarrApi return $list; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->error); @@ -334,7 +336,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') + public function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') { $list = array(); @@ -397,7 +399,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') + public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') { $list = array(); @@ -442,7 +444,7 @@ class Setup extends DolibarrApi return $list; } - + /** * Get the list of currencies. * @@ -458,10 +460,10 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfCurrencies($sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getListOfCurrencies($sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); - //TODO link with multicurrency module + //TODO link with multicurrency module $sql = "SELECT t.code_iso, t.label, t.unicode"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies as t"; $sql.= " WHERE t.active = ".$active; @@ -516,7 +518,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') + public function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') { $list = array(); @@ -595,7 +597,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '') + public function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '') { $list = array(); @@ -659,7 +661,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -720,7 +722,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -780,13 +782,13 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); $sql = "SELECT rowid, code, pos, label, use_default, color, description"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; - $sql.= " WHERE t.active = ".$active; + $sql.= " WHERE t.active = ".$active; // Add sql filters if ($sqlfilters) { @@ -840,13 +842,13 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); $sql = "SELECT rowid, code, pos, label, use_default, description"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t"; - $sql.= " WHERE t.active = ".$active; + $sql.= " WHERE t.active = ".$active; if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; // Add sql filters @@ -898,7 +900,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getCheckIntegrity($target) + public function getCheckIntegrity($target) { global $langs, $conf; diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php index 3ade4ea51b8..3e61b2e6d0a 100644 --- a/htdocs/api/class/api_status.class.php +++ b/htdocs/api/class/api_status.class.php @@ -31,7 +31,7 @@ class Status * * @return array */ - function index() + public function index() { global $conf; diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index aca175b59d2..8e9e31e68b2 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -23,8 +23,6 @@ */ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for Asset @@ -312,7 +310,7 @@ class Asset extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -369,12 +367,12 @@ class Asset extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -382,7 +380,7 @@ class Asset extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -425,7 +423,7 @@ class Asset extends CommonObject * @param int $id Id of order * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql.= ' fk_user_creat, fk_user_modif'; diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 58baf280036..9cc96ae6c44 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -76,7 +76,7 @@ class AssetType extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -89,8 +89,8 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error=0; @@ -157,7 +157,7 @@ class AssetType extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Met a jour en base donnees du type @@ -166,7 +166,7 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -233,7 +233,7 @@ class AssetType extends CommonObject * * @return int >0 if OK, 0 if not found, < 0 if KO */ - function delete() + public function delete() { global $user; @@ -267,7 +267,7 @@ class AssetType extends CommonObject * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; @@ -282,13 +282,13 @@ class AssetType extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->label = $obj->label; - $this->accountancy_code_asset = $obj->accountancy_code_asset; - $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; - $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; - $this->note = $obj->note; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->label = $obj->label; + $this->accountancy_code_asset = $obj->accountancy_code_asset; + $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; + $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; + $this->note = $obj->note; } return 1; @@ -300,13 +300,13 @@ class AssetType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of asset's type * * @return array List of types of members */ - function liste_array() + public function liste_array() { // phpcs:enable global $conf,$langs; @@ -350,7 +350,7 @@ class AssetType extends CommonObject * 2=Return array of asset id only * @return mixed Array of asset or -1 on error */ - function listAssetForAssetType($excludefilter = '', $mode = 0) + public function listAssetForAssetType($excludefilter = '', $mode = 0) { global $conf, $user; @@ -405,7 +405,7 @@ class AssetType extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) { global $langs; @@ -430,8 +430,8 @@ class AssetType extends CommonObject * * @return void */ - function initAsSpecimen() - { + public function initAsSpecimen() + { global $conf, $user, $langs; // Initialize parameters @@ -446,15 +446,15 @@ class AssetType extends CommonObject $this->asset=array( $user->id => $user ); - } + } - /** - * getLibStatut - * - * @return string Return status of a type of asset - */ - function getLibStatut() - { - return ''; - } + /** + * getLibStatut + * + * @return string Return status of a type of asset + */ + public function getLibStatut() + { + return ''; + } } diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 6db5edf4646..376a1d3986a 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -53,7 +53,7 @@ class BlockedLogAuthority public function __construct($db) { $this->db = $db; - } + } /** * Get the blockchain @@ -76,7 +76,7 @@ class BlockedLogAuthority } return $this->blockchain; - } + } /** * Get hash of the block chain to check @@ -87,7 +87,7 @@ class BlockedLogAuthority { return md5($this->signature.$this->blockchain); - } + } /** * Get hash of the block chain to check @@ -99,7 +99,7 @@ class BlockedLogAuthority { return ($hash === $this->getBlockchainHash() ); - } + } /** * Add a new block to the chain @@ -111,7 +111,7 @@ class BlockedLogAuthority { $this->blockchain.=$block; - } + } /** * hash already exist into chain ? @@ -132,7 +132,7 @@ class BlockedLogAuthority else{ return false; } - } + } /** @@ -191,7 +191,7 @@ class BlockedLogAuthority $this->error=$this->db->error(); return -1; } - } + } /** * Create authority in database. @@ -245,7 +245,7 @@ class BlockedLogAuthority $this->db->rollback(); return -1; } - } + } /** * Create authority in database. @@ -283,7 +283,7 @@ class BlockedLogAuthority $this->db->rollback(); return -1; } - } + } /** * For cron to sync to authority. @@ -326,6 +326,6 @@ class BlockedLogAuthority } } - return 1; - } + return 1; + } } diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 9c7baa0634a..ae64665bbfd 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -291,8 +291,7 @@ class BlockedLog } elseif ($this->action == 'MODULE_RESET') { - if ($this->signature == '0000000000') - { + if ($this->signature == '0000000000') { return 'System to track events into unalterable logs were disabled after some recording were done. We saved a special Fingerprint to track the chain as broken.'; } else @@ -387,14 +386,15 @@ class BlockedLog $arrayoffieldstoexclude = array( 'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf','last_main_doc','civility_id','contact','contact_id', 'table_element_line','ismultientitymanaged','isextrafieldmanaged', - 'linkedObjectsIds','linkedObjects','fk_delivery_address', + 'linkedObjectsIds', + 'linkedObjects', + 'fk_delivery_address', 'context', 'projet' // There is already ->fk_project ); // Add more fields to exclude depending on object type - if ($this->element == 'cashcontrol') - { - $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array( + if ($this->element == 'cashcontrol') { + $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array( 'name','lastname','firstname','region','region_id','region_code','state','state_id','state_code','country','country_id','country_code', 'total_ht','total_tva','total_ttc','total_localtax1','total_localtax2', 'barcode_type','barcode_type_code','barcode_type_label','barcode_type_coder','mode_reglement_id','cond_reglement_id','mode_reglement','cond_reglement','shipping_method_id', @@ -727,15 +727,12 @@ class BlockedLog */ public function dolDecodeBlockedData($data, $mode = 0) { - try - { + try { //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $aaa = unserialize($data); //$aaa = unserialize($data); - } - catch(Exception $e) - { + } catch(Exception $e) { //print $e->getErrs); } return $aaa; @@ -1064,14 +1061,14 @@ class BlockedLog } - /** - * Check if module was already used or not for at least one recording. - * - * @param int $ignoresystem Ignore system events for the test - * @return bool - */ - function alreadyUsed($ignoresystem = 0) - { + /** + * Check if module was already used or not for at least one recording. + * + * @param int $ignoresystem Ignore system events for the test + * @return bool + */ + public function alreadyUsed($ignoresystem = 0) + { global $conf; $result = false; @@ -1092,5 +1089,5 @@ class BlockedLog dol_syslog("Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem." is ".$result); return $result; - } + } } diff --git a/htdocs/bom/admin/setup.php b/htdocs/bom/admin/setup.php index dd16ad92b8e..561b44fa262 100644 --- a/htdocs/bom/admin/setup.php +++ b/htdocs/bom/admin/setup.php @@ -44,7 +44,7 @@ require_once '../lib/bom.lib.php'; //require_once "../class/myclass.class.php"; // Translations -$langs->loadLangs(array("admin", "bom@bom")); +$langs->loadLangs(array("admin", "mrp")); // Access control if (! $user->admin) accessforbidden(); @@ -78,11 +78,11 @@ llxHeader('', $langs->trans($page_name)); // Subheader $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom@bom'); +print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom'); // Configuration header $head = bomAdminPrepareHead(); -dol_fiche_head($head, 'settings', '', -1, "bom@bom"); +dol_fiche_head($head, 'settings', '', -1, "bom"); // Setup page goes here echo $langs->trans("BomSetupPage").'

'; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index ea5ba91c715..0054e427996 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -63,7 +63,7 @@ dol_include_once('/bom/class/bom.class.php'); dol_include_once('/bom/lib/bom_bom.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("bom@bom","other")); +$langs->loadLangs(array("mrp","other")); // Get parameters $id = GETPOST('id', 'int'); @@ -88,7 +88,7 @@ $search_all=trim(GETPOST("search_all", 'alpha')); $search=array(); foreach($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); } if (empty($action) && empty($id) && empty($ref)) $action='view'; @@ -115,15 +115,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - $error=0; + $error=0; - $permissiontoadd = $user->rights->bom->write; - $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); + $permissiontoadd = $user->rights->bom->write; + $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = dol_buildpath('/bom/bom_list.php', 1); - if (empty($backtopage)) { - if (empty($id)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/bom/bom_card.php', 1).($id > 0 ? $id : '__ID__'); - } + if (empty($backtopage)) { + if (empty($id)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/bom/bom_card.php', 1).($id > 0 ? $id : '__ID__'); + } $triggermodname = 'BILLOFMATERIALS_BILLOFMATERIALS_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, delete or clone @@ -154,7 +154,7 @@ if (empty($reshook)) $form=new Form($db); $formfile=new FormFile($db); -llxHeader('', 'BillOfMaterials', ''); +llxHeader('', 'NewBOM', ''); // Example : Adding jquery code print ''."\n"; else print ''."\n"; - if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED')) + /*if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED')) { if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print ''."\n"; else print ''."\n"; - } + }*/ if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print ''."\n"; else print ''."\n"; if (! defined('DISABLE_JQUERY_TABLEDND')) print ''."\n"; @@ -1762,8 +1762,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ { foreach($arrayresult as $key => $val) { - //$searchform.=printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth100', 'sall', $val['shortcut'], 'searchleft', img_picto('',$val['img'])); - $searchform.=printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', $val['shortcut'], 'searchleft', img_picto('', $val['img'], '', false, 1, 1)); + $searchform.=printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', $val['shortcut'], 'searchleft'.$key, img_picto('', $val['img'], '', false, 1, 1)); } } diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index 6b1885270c4..c733ed09582 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -122,7 +122,7 @@ print load_fiche_titre($langs->trans("MemberMainOptions"), '', ''); print ''; print ''; print ''; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''; @@ -162,7 +162,7 @@ print ''; // DISPLAY MARGIN RATES print ''; print ''; -print ''; // DISPLAY MARK RATES print ''; print ''; -print ''; print ''; print ''; -print '\n"; $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); @@ -289,13 +289,13 @@ if ($result) print ''; print "\n"; - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "\n"; + print "\n"; print "\n"; } } diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index d418aba780e..4203d591541 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -286,16 +286,16 @@ if ($result) { print $objp->description; } print ''; - print ''; - print ''; - print ''; - print ''; print ''; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index fa264a81920..0e591bc6036 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -307,7 +307,7 @@ if ($result) $invoicestatic->ref=$objp->ref; print $invoicestatic->getNomUrl(1); print "\n"; - print ""; } else { @@ -317,13 +317,13 @@ if ($result) print "\n"; } - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "\n"; + print "\n"; print "\n"; $i++; @@ -352,13 +352,13 @@ if ($result) else print '"; - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "\n"; + print "\n"; print "\n"; print "
'.$langs->trans("Description").''.$langs->trans("Value").''.$langs->trans("Value").''.$langs->trans("Description").'
'.$langs->trans("DisplayMarginRates").''; +print ''; if (! empty($conf->use_javascript_ajax)) { print ajax_constantonoff('DISPLAY_MARGIN_RATES'); @@ -185,7 +185,7 @@ print '
'.$langs->trans("DisplayMarkRates").''; +print ''; if (! empty($conf->use_javascript_ajax)) { print ajax_constantonoff('DISPLAY_MARK_RATES'); @@ -208,7 +208,7 @@ print '
'.$langs->trans("ForceBuyingPriceIfNull").''; +print ''; if (! empty($conf->use_javascript_ajax)) { print ajax_constantonoff('ForceBuyingPriceIfNull'); diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 687a381d790..d88166db424 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -212,13 +212,13 @@ if ($result) else print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, ' align="right"', $sortfield, $sortorder); - print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right '); if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); if (! empty($conf->global->DISPLAY_MARK_RATES)) - print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); print "
".$group_array['htmlname']."".price($pv, null, null, null, null, $rounding)."".price($pa, null, null, null, null, $rounding)."".price($marge, null, null, null, null, $rounding)."".price($pv, null, null, null, null, $rounding)."".price($pa, null, null, null, null, $rounding)."".price($marge, null, null, null, null, $rounding)."".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."
'; + print ''; print price($objp->subprice); print ''; + print ''; print ''; print ''; + print ''; print $objp->qty; print ''; + print ''; print price($objp->total_ht); print '"; + print ""; print dol_print_date($db->jdate($objp->datef), 'day')."".$companystatic->getNomUrl(1, 'margin')."".price($pv, null, null, null, null, $rounding)."".price($pa, null, null, null, null, $rounding)."".price($marge, null, null, null, null, $rounding)."".price($pv, null, null, null, null, $rounding)."".price($pa, null, null, null, null, $rounding)."".price($marge, null, null, null, null, $rounding)."".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."
'; print $langs->trans('TotalMargin')."".price($cumul_vente, null, null, null, null, $rounding)."".price($cumul_achat, null, null, null, null, $rounding)."".price($totalMargin, null, null, null, null, $rounding)."".price($cumul_vente, null, null, null, null, $rounding)."".price($cumul_achat, null, null, null, null, $rounding)."".price($totalMargin, null, null, null, null, $rounding)."".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."
"; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 95686967fd9..7d644931ffc 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -280,7 +280,7 @@ if ($result) $invoicestatic->ref=$objp->ref; print $invoicestatic->getNomUrl(1); print "\n"; - print ""; + print ""; print dol_print_date($db->jdate($objp->datef), 'day').""; } else { @@ -302,13 +302,13 @@ if ($result) print "\n"; //print "".$product_static->getNomUrl(1)."\n"; } - print "".price($pv, null, null, null, null, $rounding)."\n"; - print "".price($pa, null, null, null, null, $rounding)."\n"; - print "".price($marge, null, null, null, null, $rounding)."\n"; + print "".price($pv, null, null, null, null, $rounding)."\n"; + print "".price($pa, null, null, null, null, $rounding)."\n"; + print "".price($marge, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print "\n"; $i++; @@ -330,13 +330,13 @@ if ($result) else print ''; print $langs->trans('TotalMargin').""; - print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; - print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; - print "".price($totalMargin, null, null, null, null, $rounding)."\n"; + print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; + print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; + print "".price($totalMargin, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print "\n"; print ""; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index bb4e8510c5b..78d0716f9bf 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -172,16 +172,16 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&id=".$object->id, '', $sortfield, $sortorder); print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&id=".$object->id, '', $sortfield, $sortorder); print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", "&id=".$object->id, '', $sortfield, $sortorder); - print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&id=".$object->id, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&id=".$object->id, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("BuyingPrice", $_SERVER["PHP_SELF"], "buying_price", "", "&id=".$object->id, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", "&id=".$object->id, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&id=".$object->id, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&id=".$object->id, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("BuyingPrice", $_SERVER["PHP_SELF"], "buying_price", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); if (! empty($conf->global->DISPLAY_MARK_RATES)) - print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&id=".$object->id, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print "\n"; $cumul_achat = 0; @@ -204,17 +204,17 @@ if ($id > 0 || ! empty($ref)) print "\n"; print ''.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($objp->name, 44).''; print "".$objp->code_client."\n"; - print ""; + print ""; print dol_print_date($db->jdate($objp->datef), 'day').""; - print "".price($objp->selling_price, null, null, null, null, $rounding)."\n"; - print "".price($objp->buying_price, null, null, null, null, $rounding)."\n"; - print "".price($objp->qty, null, null, null, null, $rounding)."\n"; - print "".price($objp->marge, null, null, null, null, $rounding)."\n"; + print "".price($objp->selling_price, null, null, null, null, $rounding)."\n"; + print "".price($objp->buying_price, null, null, null, null, $rounding)."\n"; + print "".price($objp->qty, null, null, null, null, $rounding)."\n"; + print "".price($objp->marge, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; - print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; print "\n"; $i++; $cumul_achat += $objp->buying_price; @@ -238,15 +238,15 @@ if ($id > 0 || ! empty($ref)) } print ''; print ''.$langs->trans('TotalMargin').""; - print ''.price($cumul_vente, null, null, null, null, $rounding)."\n"; - print ''.price($cumul_achat, null, null, null, null, $rounding)."\n"; - print ''.price($cumul_qty, null, null, null, null, $rounding)."\n"; - print ''.price($totalMargin, null, null, null, null, $rounding)."\n"; + print ''.price($cumul_vente, null, null, null, null, $rounding)."\n"; + print ''.price($cumul_achat, null, null, null, null, $rounding)."\n"; + print ''.price($cumul_qty, null, null, null, null, $rounding)."\n"; + print ''.price($totalMargin, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print ''.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; - print ' '; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + print ' '; print "\n"; print ""; print ''; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 15fc2bcac0a..a69b98a9ac1 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -178,15 +178,15 @@ if ($socid > 0) print ''; print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder); - print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&socid=".$_REQUEST["socid"], 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("SoldAmount", $_SERVER["PHP_SELF"], "selling_price", "", "&socid=".$_REQUEST["socid"], 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("PurchasedAmount", $_SERVER["PHP_SELF"], "buying_price", "", "&socid=".$_REQUEST["socid"], 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&socid=".$_REQUEST["socid"], 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("SoldAmount", $_SERVER["PHP_SELF"], "selling_price", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("PurchasedAmount", $_SERVER["PHP_SELF"], "buying_price", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$_REQUEST["socid"], 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); if (! empty($conf->global->DISPLAY_MARK_RATES)) - print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$_REQUEST["socid"], 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&socid=".$_REQUEST["socid"], 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); print "\n"; $cumul_achat = 0; @@ -214,16 +214,16 @@ if ($socid > 0) $invoicestatic->ref=$objp->ref; print $invoicestatic->getNomUrl(1); print "\n"; - print ""; + print ""; print dol_print_date($db->jdate($objp->datef), 'day').""; - print "".price($objp->selling_price, null, null, null, null, $rounding)."\n"; - print "".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)."\n"; - print "".$sign.price($objp->marge, null, null, null, null, $rounding)."\n"; + print "".price($objp->selling_price, null, null, null, null, $rounding)."\n"; + print "".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)."\n"; + print "".$sign.price($objp->marge, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; - print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; print "\n"; $i++; $cumul_vente += $objp->selling_price; @@ -248,14 +248,14 @@ if ($socid > 0) // Total print ''; print ''.$langs->trans('TotalMargin').""; - print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; - print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; - print "".price($totalMargin, null, null, null, null, $rounding)."\n"; + print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; + print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; + print "".price($totalMargin, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; - print ' '; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + print ' '; print "\n"; } else diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index 5590a678945..be644a1f2e4 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -114,7 +114,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print '' . $langs->trans("UseAboutPage") . ''; - print ''; + print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MODULEBUILDER_USE_ABOUT'); } else { @@ -128,7 +128,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print '' . $langs->trans("UseDocFolder") . ''; - print ''; + print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MODULEBUILDER_USE_DOCFOLDER'); } else { diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 7e290055d43..b74fb5e2a59 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1766,7 +1766,7 @@ elseif (! empty($module)) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -1812,8 +1812,7 @@ elseif (! empty($module)) print $proptype; print ''; print ''; - if ($proparrayofkeyval) - { + if ($proparrayofkeyval) { print json_encode($proparrayofkeyval); } print ''; @@ -1826,7 +1825,7 @@ elseif (! empty($module)) print ''; print $propindex?'1':''; print ''; - print ''; + print ''; print $propposition; print ''; print ''; diff --git a/htdocs/modulebuilder/template/.editorconfig b/htdocs/modulebuilder/template/.editorconfig index 2df455f0d4f..3c4bd7d679d 100644 --- a/htdocs/modulebuilder/template/.editorconfig +++ b/htdocs/modulebuilder/template/.editorconfig @@ -7,8 +7,13 @@ root = true charset = utf-8 end_of_line = lf insert_final_newline = true + +# PHP PSR-2 Coding Standards +# http://www.php-fig.org/psr/psr-2/ [*.php] -indent_style = tab +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true [*.js] indent_style = tab [*.css] diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index 9143d8bf273..9925374dfac 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -44,201 +44,201 @@ class ActionsMyModule public $errors = array(); - /** - * @var array Hook results. Propagated to $hookmanager->resArray for later reuse - */ - public $results = array(); + /** + * @var array Hook results. Propagated to $hookmanager->resArray for later reuse + */ + public $results = array(); - /** - * @var string String displayed by executeHook() immediately after return - */ - public $resprints; + /** + * @var string String displayed by executeHook() immediately after return + */ + public $resprints; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Execute action - * - * @param array $parameters Array of parameters - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action 'add', 'update', 'view' - * @return int <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. - */ - function getNomUrl($parameters, &$object, &$action) - { - global $db,$langs,$conf,$user; - $this->resprints = ''; - return 0; - } + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function getNomUrl($parameters, &$object, &$action) + { + global $db,$langs,$conf,$user; + $this->resprints = ''; + return 0; + } - /** - * Overloading the doActions function : replacing the parent's function with the one below - * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - public function doActions($parameters, &$object, &$action, $hookmanager) - { - global $conf, $user, $langs; + /** + * Overloading the doActions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function doActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; - $error = 0; // Error counter + $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - // Do what you want here... - // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. - } + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + // Do what you want here... + // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. + } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } - } + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } - /** - * Overloading the doActions function : replacing the parent's function with the one below - * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - public function doMassActions($parameters, &$object, &$action, $hookmanager) - { - global $conf, $user, $langs; + /** + * Overloading the doActions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function doMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; - $error = 0; // Error counter + $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - foreach($parameters['toselect'] as $objectid) - { - // Do action on each object id - } - } + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + foreach($parameters['toselect'] as $objectid) + { + // Do action on each object id + } + } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } - } + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } - /** - * Overloading the addMoreMassActions function : replacing the parent's function with the one below - * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) - { - global $conf, $user, $langs; + /** + * Overloading the addMoreMassActions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; - $error = 0; // Error counter + $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - $this->resprints = ''; - } + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + $this->resprints = ''; + } - if (! $error) { - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } - } + if (! $error) { + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } - /** - * Execute action - * - * @param array $parameters Array of parameters - * @param Object $object Object output on PDF - * @param string $action 'add', 'update', 'view' - * @return int <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. - */ - function beforePDFCreation($parameters, &$object, &$action) - { - global $conf, $user, $langs; - global $hookmanager; + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param Object $object Object output on PDF + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function beforePDFCreation($parameters, &$object, &$action) + { + global $conf, $user, $langs; + global $hookmanager; - $outputlangs=$langs; + $outputlangs=$langs; - $ret=0; $deltemp=array(); - dol_syslog(get_class($this).'::executeHooks action='.$action); + $ret=0; $deltemp=array(); + dol_syslog(get_class($this).'::executeHooks action='.$action); - /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { - } + } - return $ret; - } + return $ret; + } - /** - * Execute action - * - * @param array $parameters Array of parameters - * @param Object $pdfhandler PDF builder handler - * @param string $action 'add', 'update', 'view' - * @return int <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. - */ - function afterPDFCreation($parameters, &$pdfhandler, &$action) - { - global $conf, $user, $langs; - global $hookmanager; + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param Object $pdfhandler PDF builder handler + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function afterPDFCreation($parameters, &$pdfhandler, &$action) + { + global $conf, $user, $langs; + global $hookmanager; - $outputlangs=$langs; + $outputlangs=$langs; - $ret=0; $deltemp=array(); - dol_syslog(get_class($this).'::executeHooks action='.$action); + $ret=0; $deltemp=array(); + dol_syslog(get_class($this).'::executeHooks action='.$action); - /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { - } + } - return $ret; - } + return $ret; + } - /* Add here any other hooked methods... */ + /* Add here any other hooked methods... */ } diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 30896449c93..566fe56affb 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -56,10 +56,10 @@ class MyModuleApi extends DolibarrApi * @url GET / * */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->myobject = new MyObject($this->db); } @@ -70,26 +70,26 @@ class MyModuleApi extends DolibarrApi * * @param int $id ID of myobject * @return array|mixed data without useless information - * + * * @url GET myobjects/{id} * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->myobject->read) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->myobject->read) { + throw new RestException(401); + } $result = $this->myobject->fetch($id); if( ! $result ) { throw new RestException(404, 'MyObject not found'); } - if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->myobject); + return $this->_cleanObjectDatas($this->myobject); } @@ -109,7 +109,7 @@ class MyModuleApi extends DolibarrApi * * @url GET /myobjects/ */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -140,24 +140,21 @@ class MyModuleApi extends DolibarrApi if ($restictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; if ($restictonsocid && $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter - if ($restictonsocid && $search_sale > 0) - { + if ($restictonsocid && $search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { + if (! DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } $sql.= $db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -185,7 +182,7 @@ class MyModuleApi extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No myobject found'); } - return $obj_ret; + return $obj_ret; } /** @@ -196,7 +193,7 @@ class MyModuleApi extends DolibarrApi * * @url POST myobjects/ */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->myobject->create) { throw new RestException(401); @@ -222,7 +219,7 @@ class MyModuleApi extends DolibarrApi * * @url PUT myobjects/{id} */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->myobject->create) { throw new RestException(401); @@ -233,9 +230,9 @@ class MyModuleApi extends DolibarrApi throw new RestException(404, 'MyObject not found'); } - if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { $this->myobject->$field = $value; @@ -255,11 +252,11 @@ class MyModuleApi extends DolibarrApi * * @url DELETE myobject/{id} */ - function delete($id) + public function delete($id) { - if(! DolibarrApiAccess::$user->rights->myobject->delete) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->myobject->delete) { + throw new RestException(401); + } $result = $this->myobject->fetch($id); if( ! $result ) { throw new RestException(404, 'MyObject not found'); @@ -269,7 +266,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( !$this->myobject->delete(DolibarrApiAccess::$user, 0)) + if( !$this->myobject->delete(DolibarrApiAccess::$user, 0)) { throw new RestException(500); } @@ -283,24 +280,26 @@ class MyModuleApi extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - /*unset($object->note); - unset($object->address); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder);*/ + /*unset($object->note); + unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder);*/ - return $object; + return $object; } /** @@ -311,7 +310,7 @@ class MyModuleApi extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $myobject = array(); foreach (MyObjectApi::$FIELDS as $field) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index af96bcebf37..e23177dca11 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -432,19 +432,19 @@ class MyObject extends CommonObject //return $this->deleteCommon($user, $notrigger, 1); } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; @@ -460,10 +460,10 @@ class MyObject extends CommonObject if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkclose=''; @@ -504,7 +504,7 @@ class MyObject extends CommonObject else $result .= $hookmanager->resPrint; return $result; - } + } /** * Return label of the status @@ -673,11 +673,11 @@ class MyObject extends CommonObject /* class MyObjectLine { - // @var int ID - public $id; - // @var mixed Sample line property 1 - public $prop1; - // @var mixed Sample line property 2 - public $prop2; + // @var int ID + public $id; + // @var mixed Sample line property 1 + public $prop1; + // @var mixed Sample line property 2 + public $prop2; } */ diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 66cf8ab05eb..087f102daef 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -186,7 +186,7 @@ class mymodulewidget1 extends ModeleBoxes 'tr' => 'class="left"', 'text' => '' ), - 0 => array( // TR + 1 => array( // TR 'tr' => 'class="left"', 'text' => '' ) @@ -194,18 +194,18 @@ class mymodulewidget1 extends ModeleBoxes ); } - /** - * Method to show box. Called by Dolibarr eatch time it wants to display the box. - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + /** + * Method to show box. Called by Dolibarr eatch time it wants to display the box. + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - // You may make your own code here… - // … or use the parent's class function using the provided head and contents templates - parent::showBox($this->info_box_head, $this->info_box_contents); - } + * @return void + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + // You may make your own code here… + // … or use the parent's class function using the provided head and contents templates + parent::showBox($this->info_box_head, $this->info_box_contents); + } } diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index a62cf3924d6..83644cd1f0e 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -17,46 +17,46 @@ dol_include_once("/mymodule/class/myobject.class.php"); */ class mailing_mailinglist_mymodule_myobject extends MailingTargets { - // CHANGE THIS: Put here a name not already used - var $name='mailinglist_mymodule_myobject'; - // CHANGE THIS: Put here a description of your selector module - var $desc='My object emailing target selector'; - // CHANGE THIS: Set to 1 if selector is available for admin users only - var $require_admin=0; + // CHANGE THIS: Put here a name not already used + public $name='mailinglist_mymodule_myobject'; + // CHANGE THIS: Put here a description of your selector module + public $desc='My object emailing target selector'; + // CHANGE THIS: Set to 1 if selector is available for admin users only + public $require_admin=0; - var $enabled=0; - var $require_module=array(); - var $picto='mymodule@mymodule'; + public $enabled=0; + public $require_module=array(); + public $picto='mymodule@mymodule'; - /** + /** * @var DoliDB Database handler. */ public $db; - /** - * Constructor + /** + * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ - function __construct($db) - { - global $conf; + public function __construct($db) + { + global $conf; - $this->db=$db; - if (is_array($conf->modules)) - { - $this->enabled=in_array('mymodule', $conf->modules)?1:0; - } - } + $this->db=$db; + if (is_array($conf->modules)) + { + $this->enabled=in_array('mymodule', $conf->modules)?1:0; + } + } /** - * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings + * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings * - * @return string Retourne zone select + * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $langs; $langs->load("members"); @@ -71,7 +71,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets $s.=''; foreach($arraystatus as $status) { - $s.=''; + $s.=''; } $s.=''; $s.='
'; @@ -81,122 +81,122 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets /** - * Renvoie url lien vers fiche de la source du destinataire du mailing - * - * @param int $id ID - * @return string Url lien - */ - function url($id) - { - return ''.img_object('', "generic").''; - } + * Renvoie url lien vers fiche de la source du destinataire du mailing + * + * @param int $id ID + * @return string Url lien + */ + public function url($id) + { + return ''.img_object('', "generic").''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * This is the main function that returns the array of emails - * - * @param int $mailing_id Id of emailing - * @return int <0 if error, number of emails added if ok - */ - function add_to_target($mailing_id) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * This is the main function that returns the array of emails + * + * @param int $mailing_id Id of emailing + * @return int <0 if error, number of emails added if ok + */ + public function add_to_target($mailing_id) + { // phpcs:enable - $target = array(); - $j = 0; + $target = array(); + $j = 0; - $sql = " select rowid as id, email, firstname, lastname, plan, partner"; - $sql.= " from ".MAIN_DB_PREFIX."myobject"; - $sql.= " where email IS NOT NULL AND email != ''"; - if (! empty($_POST['filter']) && $_POST['filter'] != 'none') $sql.= " AND status = '".$this->db->escape($_POST['filter'])."'"; - $sql.= " ORDER BY email"; + $sql = " select rowid as id, email, firstname, lastname, plan, partner"; + $sql.= " from ".MAIN_DB_PREFIX."myobject"; + $sql.= " where email IS NOT NULL AND email != ''"; + if (! empty($_POST['filter']) && $_POST['filter'] != 'none') $sql.= " AND status = '".$this->db->escape($_POST['filter'])."'"; + $sql.= " ORDER BY email"; - // Stocke destinataires dans target - $result=$this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; + // Stocke destinataires dans target + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; - dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found"); + dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found"); - $old = ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) - { - $target[$j] = array( - 'email' => $obj->email, - 'name' => $obj->lastname, - 'id' => $obj->id, - 'firstname' => $obj->firstname, - 'other' => $obj->plan.';'.$obj->partner, - 'source_url' => $this->url($obj->id), - 'source_id' => $obj->id, - 'source_type' => 'dolicloud' - ); - $old = $obj->email; - $j++; - } + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) + { + $target[$j] = array( + 'email' => $obj->email, + 'name' => $obj->lastname, + 'id' => $obj->id, + 'firstname' => $obj->firstname, + 'other' => $obj->plan.';'.$obj->partner, + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'dolicloud' + ); + $old = $obj->email; + $j++; + } - $i++; - } - } - else - { - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - return -1; - } + $i++; + } + } + else + { + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } - // You must fill the $target array with record like this - // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0'); - // ... - // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n'); + // You must fill the $target array with record like this + // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0'); + // ... + // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n'); - // Example: $target[0]=array('email'=>'myemail@mydomain.com','name'=>'Doe','firstname'=>'John'); + // Example: $target[0]=array('email'=>'myemail@mydomain.com','name'=>'Doe','firstname'=>'John'); - // ----- Your code end here ----- + // ----- Your code end here ----- - return parent::add_to_target($mailing_id, $target); - } + return parent::add_to_target($mailing_id, $target); + } - /** - * On the main mailing area, there is a box with statistics. - * If you want to add a line in this report you must provide an - * array of SQL request that returns two field: - * One called "label", One called "nb". - * - * @return array - */ - function getSqlArrayForStats() - { - // CHANGE THIS: Optionnal + /** + * On the main mailing area, there is a box with statistics. + * If you want to add a line in this report you must provide an + * array of SQL request that returns two field: + * One called "label", One called "nb". + * + * @return array + */ + public function getSqlArrayForStats() + { + // CHANGE THIS: Optionnal - //var $statssql=array(); - //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; + //var $statssql=array(); + //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; - return array(); - } + return array(); + } - /** - * Return here number of distinct emails returned by your selector. - * For example if this selector is used to extract 500 different - * emails from a text file, this function must return 500. - * - * @param string $filter Filter - * @param string $option Options - * @return int Nb of recipients or -1 if KO - */ - function getNbOfRecipients($filter = 1, $option = '') - { - $a=parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"); + /** + * Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. + * + * @param string $filter Filter + * @param string $option Options + * @return int Nb of recipients or -1 if KO + */ + public function getNbOfRecipients($filter = 1, $option = '') + { + $a=parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"); - if ($a < 0) return -1; - return $a; - } + if ($a < 0) return -1; + return $a; + } } diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index db6dd961c6c..0f350e83226 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2018 Nicolas ZABOURI +/* Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2019 Frédéric France * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -33,314 +34,370 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; */ class modMyModule extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { global $langs,$conf; $this->db = $db; - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'mymodule'; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'mymodule'; - // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' - // It is used to group modules by family in module setup page - $this->family = "other"; - // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '90'; - // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) - //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "other"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '90'; + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); - // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModule is name of module). - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module). - $this->description = "MyModuleDescription"; - // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = "MyModule description (Long)"; + // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModule is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module). + $this->description = "MyModuleDescription"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "MyModule description (Long)"; - $this->editor_name = 'Editor name'; - $this->editor_url = 'https://www.example.com'; + $this->editor_name = 'Editor name'; + $this->editor_url = 'https://www.example.com'; - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = '1.0'; + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = '1.0'; //Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='generic'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto='generic'; - // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) - $this->module_parts = array( - 'triggers' => 1, // Set this to 1 if module has its own trigger directory (core/triggers) - 'login' => 0, // Set this to 1 if module has its own login method file (core/login) - 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) - 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array('/mymodule/css/mymodule.css.php'), // Set this to relative path of css file if module has its own css file - 'js' => array('/mymodule/js/mymodule.js.php'), // Set this to relative path of js file if module must load a js on all pages - 'hooks' => array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>'0'), // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' - 'moduleforexternal' => 0 // Set this to 1 if feature of module are opened to external users - ); + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 1, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 1, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + '/mymodule/css/mymodule.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + '/mymodule/js/mymodule.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' + 'hooks' => array( + 'data' => array( + 'hookcontext1', + 'hookcontext2', + ), + 'entity' => '0', + ), + // Set this to 1 if feature of module are opened to external users + 'moduleforexternal' => 0, + ); - // Data directories to create when module is enabled. - // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir"); - $this->dirs = array("/mymodule/temp"); + // Data directories to create when module is enabled. + // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir"); + $this->dirs = array("/mymodule/temp"); - // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. - $this->config_page_url = array("setup.php@mymodule"); + // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@mymodule"); - // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) - $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) - $this->langfiles = array("mymodule@mymodule"); - //$this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); - //$this->always_enabled = true; // If true, can't be disabled + // Dependencies + // A condition to hide module + $this->hidden = false; + // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->depends = array(); + $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->langfiles = array("mymodule@mymodule"); + //$this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled - // Constants - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) - // ); - $this->const = array( - 1=>array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) - ); + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); + $this->const = array( + 1 => array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + ); - // Some keys to add into the overwriting translation tables - /*$this->overwrite_translation = array( - 'en_US:ParentCompany'=>'Parent company or reseller', - 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' - )*/ + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( + 'en_US:ParentCompany'=>'Parent company or reseller', + 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' + )*/ - if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) - { - $conf->mymodule=new stdClass(); - $conf->mymodule->enabled=0; - } + if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) { + $conf->mymodule=new stdClass(); + $conf->mymodule->enabled=0; + } - // Array to add new pages in new tabs + // Array to add new pages in new tabs $this->tabs = array(); - // Example: - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // // Where objecttype can be - // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) - // 'contact' to add a tab in contact view - // 'contract' to add a tab in contract view - // 'group' to add a tab in group view - // 'intervention' to add a tab in intervention view - // 'invoice' to add a tab in customer invoice view - // 'invoice_supplier' to add a tab in supplier invoice view - // 'member' to add a tab in fundation member view - // 'opensurveypoll' to add a tab in opensurvey poll view - // 'order' to add a tab in customer order view - // 'order_supplier' to add a tab in supplier order view - // 'payment' to add a tab in payment view - // 'payment_supplier' to add a tab in supplier payment view - // 'product' to add a tab in product view - // 'propal' to add a tab in propal view - // 'project' to add a tab in project view - // 'stock' to add a tab in stock view - // 'thirdparty' to add a tab in third party view - // 'user' to add a tab in user view + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view // Dictionaries - $this->dictionaries=array(); + $this->dictionaries=array(); /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@mymodule', - 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor - 'tablib'=>array("Table1","Table2","Table3"), // Label of tables - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields - 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order - 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) - 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) - 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) - 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') - 'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) // Condition to show each dictionary + // List of tables we want to see into dictonnary editor + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), + // Label of tables + 'tablib'=>array("Table1","Table2","Table3"), + // Request to select fields + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + // Sort order + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), + // List of fields (result of select to show dictionary) + 'tabfield'=>array("code,label","code,label","code,label"), + // List of fields (list of fields to edit a record) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), + // List of fields (list of fields for insert) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), + // Name of columns with primary key (try to always name it 'rowid') + 'tabrowid'=>array("rowid","rowid","rowid"), + // Condition to show each dictionary + 'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) ); */ // Boxes/Widgets - // Add here list of php file(s) stored in mymodule/core/boxes that contains class to show a widget. + // Add here list of php file(s) stored in mymodule/core/boxes that contains class to show a widget. $this->boxes = array( - 0=>array('file'=>'mymodulewidget1.php@mymodule','note'=>'Widget provided by MyModule','enabledbydefaulton'=>'Home'), - //1=>array('file'=>'mymodulewidget2.php@mymodule','note'=>'Widget provided by MyModule'), - //2=>array('file'=>'mymodulewidget3.php@mymodule','note'=>'Widget provided by MyModule') + 0 => array( + 'file' => 'mymodulewidget1.php@mymodule', + 'note' => 'Widget provided by MyModule', + 'enabledbydefaulton' => 'Home', + ), + //1=>array('file'=>'mymodulewidget2.php@mymodule','note'=>'Widget provided by MyModule'), + //2=>array('file'=>'mymodulewidget3.php@mymodule','note'=>'Widget provided by MyModule') ); - // Cronjobs (List of cron jobs entries to add when module is enabled) - // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week - $this->cronjobs = array( - 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/mymodule/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) - ); - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) - // ); + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + 0 => array( + 'label' => 'MyJob label', + 'jobtype' => 'method', + 'class' => '/mymodule/class/myobject.class.php', + 'objectname' => 'MyObject', + 'method' => 'doScheduledJob', + 'parameters' => '', + 'comment' => 'Comment', + 'frequency' => 2, + 'unitfrequency' => 3600, + 'status' => 0, + 'test' => '$conf->mymodule->enabled', + 'priority' => 50, + ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) + // ); - // Permissions - $this->rights = array(); // Permission array used by this module + // Permissions + $this->rights = array(); // Permission array used by this module - $r=0; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read myobject of MyModule'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $r=0; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read myobject of MyModule'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update myobject of MyModule'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update myobject of MyModule'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete myobject of MyModule'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete myobject of MyModule'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - // Main menu entries - $this->menu = array(); // List of menus to add - $r=0; + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; - // Add here entries to declare new menus + // Add here entries to declare new menus - /* BEGIN MODULEBUILDER TOPMENU */ - $this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Top menu entry - 'titre'=>'MyModule', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'', - 'url'=>'/mymodule/mymoduleindex.php', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + /* BEGIN MODULEBUILDER TOPMENU */ + $this->menu[$r++]=array( + 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'top', // This is a Top menu entry + 'titre'=>'MyModule', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'', + 'url'=>'/mymodule/mymoduleindex.php', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); - /* END MODULEBUILDER TOPMENU */ + /* END MODULEBUILDER TOPMENU */ - /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT - $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'List MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_list', - 'url'=>'/mymodule/myobject_list.php', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'New MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_new', - 'url'=>'/mymodule/myobject_page.php?action=create', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - END MODULEBUILDER LEFTMENU MYOBJECT */ + /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'List MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject_list', + 'url'=>'/mymodule/myobject_list.php', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'New MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject_new', + 'url'=>'/mymodule/myobject_page.php?action=create', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + END MODULEBUILDER LEFTMENU MYOBJECT */ - // Exports - $r=1; + // Exports + $r=1; - /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ - /* - $langs->load("mymodule@mymodule"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='myobject@mymodule'; - $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; - $r++; */ - /* END MODULEBUILDER EXPORT MYOBJECT */ - } + /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ + /* + $langs->load("mymodule@mymodule"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='myobject@mymodule'; + $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; + $r++; */ + /* END MODULEBUILDER EXPORT MYOBJECT */ + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - $result=$this->_load_tables('/mymodule/sql/'); - if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $result=$this->_load_tables('/mymodule/sql/'); + if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') - // Create extrafields - include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); + // Create extrafields + include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - $sql = array(); + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); - return $this->_remove($sql, $options); - } + return $this->_remove($sql, $options); + } } diff --git a/htdocs/modulebuilder/template/js/mymodule.js.php b/htdocs/modulebuilder/template/js/mymodule.js.php index 6a3447625a5..3e5c0ca31ba 100644 --- a/htdocs/modulebuilder/template/js/mymodule.js.php +++ b/htdocs/modulebuilder/template/js/mymodule.js.php @@ -18,15 +18,15 @@ */ if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); -if (!defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); if (!defined('NOLOGIN')) define('NOLOGIN', 1); if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); /** diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 39aca93a52f..637e9404f67 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -134,14 +134,14 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read) $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'customer',16); print ''; - print ''.price($obj->total_ttc).''; + print ''.price($obj->total_ttc).''; $i++; $total += $obj->total_ttc; } if ($total>0) { - print ''.$langs->trans("Total").''.price($total).""; + print ''.$langs->trans("Total").''.price($total).""; } } else @@ -195,7 +195,7 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read) else if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects",$max); else print $langs->trans("BoxTitleLastModifiedCustomers",$max); print ''; - print ''.$langs->trans("DateModificationShort").''; + print ''.$langs->trans("DateModificationShort").''; print ''; if ($num) { @@ -210,10 +210,10 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read) $companystatic->canvas=$objp->canvas; print ''; print ''.$companystatic->getNomUrl(1,'customer',48).''; - print ''; + print ''; print $companystatic->getLibCustProspStatut(); print ""; - print ''.dol_print_date($db->jdate($objp->tms),'day').""; + print ''.dol_print_date($db->jdate($objp->tms),'day').""; print ''; $i++; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ff815e738fc..a310f4258e9 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -420,7 +420,7 @@ $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print ''; +print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; @@ -448,7 +448,7 @@ $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sort $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print ''."\n"; @@ -516,7 +516,7 @@ while ($i < min($num, $limit)) $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print ''; + print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; @@ -539,7 +539,7 @@ if (isset($totalarray['pos'])) while ($i < $totalarray['nbfield']) { $i++; - if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).''; + if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).''; else { if ($i == 1) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 6a524fa5a99..69c0b07958e 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -429,9 +429,9 @@ class MultiCurrency extends CommonObject * * @return int -1 if KO, 1 if OK, 2 if label found and OK */ - function addRateFromDolibarr($code, $rate) - { - global $db, $user; + public function addRateFromDolibarr($code, $rate) + { + global $db, $user; $currency = new MultiCurrency($db); $currency->code = $code; @@ -455,7 +455,7 @@ class MultiCurrency extends CommonObject } return -1; - } + } /** * Add new entry into llx_multicurrency_rate to historise @@ -463,9 +463,9 @@ class MultiCurrency extends CommonObject * @param double $rate rate value * * @return int <0 if KO, >0 if OK - */ - public function updateRate($rate) - { + */ + public function updateRate($rate) + { return $this->addRate($rate); } @@ -474,8 +474,8 @@ class MultiCurrency extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function getRate() - { + public function getRate() + { $sql = 'SELECT cr.rowid'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr'; $sql.= ' WHERE cr.fk_multicurrency = '.$this->id; @@ -497,8 +497,8 @@ class MultiCurrency extends CommonObject * * @return 0 if not found, >0 if OK */ - public static function getIdFromCode(&$db, $code) - { + public static function getIdFromCode(&$db, $code) + { global $conf; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE code = \''.$db->escape($code).'\' AND entity = '.$conf->entity; @@ -519,8 +519,8 @@ class MultiCurrency extends CommonObject * @return array [0] => id currency * [1] => rate */ - public static function getIdAndTxFromCode(&$db, $code, $date_document = '') - { + public static function getIdAndTxFromCode(&$db, $code, $date_document = '') + { global $conf; $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 5d06cb23faa..a688f12654b 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -34,72 +34,72 @@ require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; */ class Opensurveysondage extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element='opensurvey_sondage'; + /** + * @var string ID to identify managed object + */ + public $element='opensurvey_sondage'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='opensurvey_sondage'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element='opensurvey_sondage'; public $picto = 'opensurvey'; - public $id_sondage; - /** - * @deprecated - * @see description - */ - public $commentaires; + public $id_sondage; + /** + * @deprecated + * @see description + */ + public $commentaires; - /** - * @var string description - */ - public $description; + /** + * @var string description + */ + public $description; - public $mail_admin; - public $nom_admin; + public $mail_admin; + public $nom_admin; - /** - * Id of user author of the poll - * @var int - */ - public $fk_user_creat; + /** + * Id of user author of the poll + * @var int + */ + public $fk_user_creat; - public $titre; - public $date_fin=''; - public $status=1; - public $format; - public $mailsonde; + public $titre; + public $date_fin=''; + public $status=1; + public $format; + public $mailsonde; - public $sujet; + public $sujet; - /** - * Allow comments on this poll - * @var bool - */ - public $allow_comments; + /** + * Allow comments on this poll + * @var bool + */ + public $allow_comments; - /** - * Allow users see others vote - * @var bool - */ - public $allow_spy; + /** + * Allow users see others vote + * @var bool + */ + public $allow_spy; - /** - * Draft status (not used) - */ - const STATUS_DRAFT = 0; - /** - * Validated/Opened status - */ - const STATUS_VALIDATED = 1; - /** - * Closed - */ - const STATUS_CLOSED = 2; + /** + * Draft status (not used) + */ + const STATUS_DRAFT = 0; + /** + * Validated/Opened status + */ + const STATUS_VALIDATED = 1; + /** + * Closed + */ + const STATUS_CLOSED = 2; @@ -108,7 +108,7 @@ class Opensurveysondage extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -117,87 +117,87 @@ class Opensurveysondage extends CommonObject /** * Create object into database * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK + * @param User $user User that creates + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK */ - function create(User $user, $notrigger = 0) + public function create(User $user, $notrigger = 0) { - $error=0; + $error=0; - // Clean parameters - $this->cleanParameters(); + // Clean parameters + $this->cleanParameters(); - // Check parameters - if (! $this->date_fin > 0) - { - $this->error='BadValueForEndDate'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -1; - } + // Check parameters + if (! $this->date_fin > 0) + { + $this->error='BadValueForEndDate'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -1; + } // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage("; - $sql.= "id_sondage,"; - $sql.= "commentaires,"; - $sql.= "fk_user_creat,"; - $sql.= "titre,"; - $sql.= "date_fin,"; - $sql.= "status,"; - $sql.= "format,"; - $sql.= "mailsonde,"; - $sql.= "allow_comments,"; - $sql.= "allow_spy,"; - $sql.= "sujet"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage("; + $sql.= "id_sondage,"; + $sql.= "commentaires,"; + $sql.= "fk_user_creat,"; + $sql.= "titre,"; + $sql.= "date_fin,"; + $sql.= "status,"; + $sql.= "format,"; + $sql.= "mailsonde,"; + $sql.= "allow_comments,"; + $sql.= "allow_spy,"; + $sql.= "sujet"; $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->id_sondage)."',"; - $sql.= " ".(empty($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").","; - $sql.= " ".$user->id.","; - $sql.= " '".$this->db->escape($this->titre)."',"; - $sql.= " '".$this->db->idate($this->date_fin)."',"; - $sql.= " ".$this->status.","; - $sql.= " '".$this->db->escape($this->format)."',"; - $sql.= " ".$this->db->escape($this->mailsonde).","; - $sql.= " ".$this->db->escape($this->allow_comments).","; - $sql.= " ".$this->db->escape($this->allow_spy).","; - $sql.= " '".$this->db->escape($this->sujet)."'"; - $sql.= ")"; + $sql.= "'".$this->db->escape($this->id_sondage)."',"; + $sql.= " ".(empty($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").","; + $sql.= " ".$user->id.","; + $sql.= " '".$this->db->escape($this->titre)."',"; + $sql.= " '".$this->db->idate($this->date_fin)."',"; + $sql.= " ".$this->status.","; + $sql.= " '".$this->db->escape($this->format)."',"; + $sql.= " ".$this->db->escape($this->mailsonde).","; + $sql.= " ".$this->db->escape($this->allow_comments).","; + $sql.= " ".$this->db->escape($this->allow_spy).","; + $sql.= " '".$this->db->escape($this->sujet)."'"; + $sql.= ")"; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::create", LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) + if (! $error) { - if (! $notrigger) - { - global $langs, $conf; + if (! $notrigger) + { + global $langs, $conf; // Call trigger $result=$this->call_trigger('OPENSURVEY_CREATE', $user); if ($result < 0) $error++; // End call triggers - } + } } // Commit or rollback if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); return $this->id; - } + } } @@ -208,27 +208,27 @@ class Opensurveysondage extends CommonObject * @param string $numsurvey Ref of survey (admin or not) * @return int <0 if KO, >0 if OK */ - function fetch($id, $numsurvey = '') + public function fetch($id, $numsurvey = '') { - $sql = "SELECT"; - $sql.= " t.id_sondage,"; - $sql.= " t.commentaires as description,"; - $sql.= " t.mail_admin,"; - $sql.= " t.nom_admin,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.titre,"; - $sql.= " t.date_fin,"; - $sql.= " t.status,"; - $sql.= " t.format,"; - $sql.= " t.mailsonde,"; - $sql.= " t.allow_comments,"; - $sql.= " t.allow_spy,"; - $sql.= " t.sujet,"; - $sql.= " t.tms"; + $sql = "SELECT"; + $sql.= " t.id_sondage,"; + $sql.= " t.commentaires as description,"; + $sql.= " t.mail_admin,"; + $sql.= " t.nom_admin,"; + $sql.= " t.fk_user_creat,"; + $sql.= " t.titre,"; + $sql.= " t.date_fin,"; + $sql.= " t.status,"; + $sql.= " t.format,"; + $sql.= " t.mailsonde,"; + $sql.= " t.allow_comments,"; + $sql.= " t.allow_spy,"; + $sql.= " t.sujet,"; + $sql.= " t.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t"; $sql.= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -236,29 +236,29 @@ class Opensurveysondage extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id_sondage = $obj->id_sondage; - $this->ref = $this->id_sondage; //For compatibility + $this->id_sondage = $obj->id_sondage; + $this->ref = $this->id_sondage; //For compatibility - $this->commentaires = $obj->description; // deprecated - $this->description = $obj->description; - $this->mail_admin = $obj->mail_admin; - $this->nom_admin = $obj->nom_admin; - $this->titre = $obj->titre; - $this->date_fin = $this->db->jdate($obj->date_fin); - $this->status = $obj->status; - $this->format = $obj->format; - $this->mailsonde = $obj->mailsonde; - $this->allow_comments = $obj->allow_comments; - $this->allow_spy = $obj->allow_spy; - $this->sujet = $obj->sujet; - $this->fk_user_creat = $obj->fk_user_creat; + $this->commentaires = $obj->description; // deprecated + $this->description = $obj->description; + $this->mail_admin = $obj->mail_admin; + $this->nom_admin = $obj->nom_admin; + $this->titre = $obj->titre; + $this->date_fin = $this->db->jdate($obj->date_fin); + $this->status = $obj->status; + $this->format = $obj->format; + $this->mailsonde = $obj->mailsonde; + $this->allow_comments = $obj->allow_comments; + $this->allow_spy = $obj->allow_spy; + $this->sujet = $obj->sujet; + $this->fk_user_creat = $obj->fk_user_creat; - $this->date_m = $this->db->jdate($obj->tls); - $ret=1; + $this->date_m = $this->db->jdate($obj->tls); + $ret=1; } else { - $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey); + $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey); $this->error='Fetch no poll found for '.$sondage; dol_syslog($this->error, LOG_ERR); $ret = 0; @@ -268,7 +268,7 @@ class Opensurveysondage extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error="Error ".$this->db->lasterror(); $ret=-1; } @@ -279,73 +279,73 @@ class Opensurveysondage extends CommonObject /** * Update object into database * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { - global $conf, $langs; - $error=0; + global $conf, $langs; + $error=0; - // Clean parameters - $this->cleanParameters(); + // Clean parameters + $this->cleanParameters(); - // Check parameters - // Put here code to add a control on parameters values + // Check parameters + // Put here code to add a control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."opensurvey_sondage SET"; - $sql.= " id_sondage=".(isset($this->id_sondage)?"'".$this->db->escape($this->id_sondage)."'":"null").","; - $sql.= " commentaires=".(isset($this->commentaires)?"'".$this->db->escape($this->commentaires)."'":"null").","; - $sql.= " mail_admin=".(isset($this->mail_admin)?"'".$this->db->escape($this->mail_admin)."'":"null").","; - $sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").","; - $sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").","; - $sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; - $sql.= " status=".(isset($this->status)?"'".$this->db->escape($this->status)."'":"null").","; - $sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").","; - $sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").","; - $sql.= " allow_comments=".$this->db->escape($this->allow_comments).","; - $sql.= " allow_spy=".$this->db->escape($this->allow_spy); + $sql.= " id_sondage=".(isset($this->id_sondage)?"'".$this->db->escape($this->id_sondage)."'":"null").","; + $sql.= " commentaires=".(isset($this->commentaires)?"'".$this->db->escape($this->commentaires)."'":"null").","; + $sql.= " mail_admin=".(isset($this->mail_admin)?"'".$this->db->escape($this->mail_admin)."'":"null").","; + $sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").","; + $sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").","; + $sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; + $sql.= " status=".(isset($this->status)?"'".$this->db->escape($this->status)."'":"null").","; + $sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").","; + $sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").","; + $sql.= " allow_comments=".$this->db->escape($this->allow_comments).","; + $sql.= " allow_spy=".$this->db->escape($this->allow_spy); - $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { - // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // End call triggers - } - } + if (! $error) + { + if (! $notrigger) + { + // Call triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // End call triggers + } + } // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } } /** @@ -356,328 +356,328 @@ class Opensurveysondage extends CommonObject * @param string $numsondage Num sondage admin to delete * @return int <0 if KO, >0 if OK */ - function delete(User $user, $notrigger = 0, $numsondage = '') + public function delete(User $user, $notrigger = 0, $numsondage = '') { - global $conf, $langs; - $error=0; + global $conf, $langs; + $error=0; - if (empty($numsondage)) - { - $numsondage = $this->id_sondage; - } + if (empty($numsondage)) + { + $numsondage = $this->id_sondage; + } - $this->db->begin(); + $this->db->begin(); - if (! $error) - { - if (! $notrigger) - { + if (! $error) + { + if (! $notrigger) + { // Call trigger $result=$this->call_trigger('OPENSURVEY_DELETE', $user); if ($result < 0) $error++; // End call triggers - } - } + } + } - if (! $error) - { + if (! $error) + { - $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); + $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage"; + $sql.= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $result = ''; - $companylink = ''; + $result = ''; + $companylink = ''; - $label = '' . $langs->trans("ShowSurvey") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; - $label.= '' . $langs->trans('Title') . ': ' . $this->title.'
'; + $label = '' . $langs->trans("ShowSurvey") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; + $label.= '' . $langs->trans('Title') . ': ' . $this->title.'
'; - $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id; - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; - $linkclose=''; - if (empty($notooltip)) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowMyObject"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); - $linkstart = ''; - $linkend=''; + $linkstart = ''; + $linkend=''; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; - return $result; - } + return $result; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Return array of lines - * - * @return int <0 if KO, >0 if OK - */ - function fetch_lines() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return array of lines + * + * @return int <0 if KO, >0 if OK + */ + public function fetch_lines() + { // phpcs:enable - $ret=array(); + $ret=array(); - $sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; - $resql=$this->db->query($sql); + $sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql.= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; + $resql=$this->db->query($sql); - if ($resql) - { - $num=$this->db->num_rows($resql); - $i=0; - while ($i < $num) - { - $obj=$this->db->fetch_object($resql); - $tmp=array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); + if ($resql) + { + $num=$this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj=$this->db->fetch_object($resql); + $tmp=array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); - $ret[]=$tmp; - $i++; - } - } - else dol_print_error($this->db); + $ret[]=$tmp; + $i++; + } + } + else dol_print_error($this->db); - $this->lines=$ret; + $this->lines=$ret; - return count($this->lines); - } + return count($this->lines); + } - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - function initAsSpecimen() - { - $this->id=0; + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id=0; - $this->id_sondage=''; - $this->commentaires='Comment of the specimen survey'; - $this->mail_admin=''; - $this->nom_admin=''; - $this->titre='This is a specimen survey'; - $this->date_fin=dol_now()+3600*24*10; - $this->status=1; - $this->format='classic'; - $this->mailsonde=''; - } + $this->id_sondage=''; + $this->commentaires='Comment of the specimen survey'; + $this->mail_admin=''; + $this->nom_admin=''; + $this->titre='This is a specimen survey'; + $this->date_fin=dol_now()+3600*24*10; + $this->status=1; + $this->format='classic'; + $this->mailsonde=''; + } - /** - * Returns all comments for the current opensurvey poll - * - * @return Object[] - */ - public function getComments() - { - $comments = array(); + /** + * Returns all comments for the current opensurvey poll + * + * @return Object[] + */ + public function getComments() + { + $comments = array(); - $sql = 'SELECT id_comment, usercomment, comment'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; - $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; - $sql.= " ORDER BY id_comment"; - $resql = $this->db->query($sql); + $sql = 'SELECT id_comment, usercomment, comment'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; + $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + $sql.= " ORDER BY id_comment"; + $resql = $this->db->query($sql); - if ($resql) - { - $num_rows=$this->db->num_rows($resql); + if ($resql) + { + $num_rows=$this->db->num_rows($resql); - if ($num_rows > 0) - { - while ($obj = $this->db->fetch_object($resql)) - { - $comments[] = $obj; - } - } - } + if ($num_rows > 0) + { + while ($obj = $this->db->fetch_object($resql)) + { + $comments[] = $obj; + } + } + } - return $comments; - } + return $comments; + } - /** - * Adds a comment to the poll - * - * @param string $comment Comment content - * @param string $comment_user Comment author - * @return boolean False in case of the query fails, true if it was successful - */ - public function addComment($comment, $comment_user) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)"; - $sql.= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; - $resql = $this->db->query($sql); + /** + * Adds a comment to the poll + * + * @param string $comment Comment content + * @param string $comment_user Comment author + * @return boolean False in case of the query fails, true if it was successful + */ + public function addComment($comment, $comment_user) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)"; + $sql.= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; + $resql = $this->db->query($sql); - if (!$resql) { - return false; - } + if (!$resql) { + return false; + } - return true; - } + return true; + } - /** - * Deletes a comment of the poll - * - * @param int $id_comment Id of the comment - * @return boolean False in case of the query fails, true if it was successful - */ - public function deleteComment($id_comment) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; - $resql = $this->db->query($sql); + /** + * Deletes a comment of the poll + * + * @param int $id_comment Id of the comment + * @return boolean False in case of the query fails, true if it was successful + */ + public function deleteComment($id_comment) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; + $resql = $this->db->query($sql); - if (!$resql) { - return false; - } + if (!$resql) { + return false; + } - return true; - } + return true; + } - /** - * Cleans all the class variables before doing an update or an insert - * - * @return void - */ - private function cleanParameters() - { - $this->id_sondage = trim($this->id_sondage); - $this->commentaires = trim($this->commentaires); - $this->mail_admin = trim($this->mail_admin); - $this->nom_admin = trim($this->nom_admin); - $this->titre = trim($this->titre); - $this->status = trim($this->status); - $this->format = trim($this->format); - $this->mailsonde = ($this->mailsonde ? 1 : 0); - $this->allow_comments = ($this->allow_comments ? 1 : 0); - $this->allow_spy = ($this->allow_spy ? 1 : 0); - $this->sujet = trim($this->sujet); - } + /** + * Cleans all the class variables before doing an update or an insert + * + * @return void + */ + private function cleanParameters() + { + $this->id_sondage = trim($this->id_sondage); + $this->commentaires = trim($this->commentaires); + $this->mail_admin = trim($this->mail_admin); + $this->nom_admin = trim($this->nom_admin); + $this->titre = trim($this->titre); + $this->status = trim($this->status); + $this->format = trim($this->format); + $this->mailsonde = ($this->mailsonde ? 1 : 0); + $this->allow_comments = ($this->allow_comments ? 1 : 0); + $this->allow_spy = ($this->allow_spy ? 1 : 0); + $this->sujet = trim($this->sujet); + } - /** - * Return status label of Order - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle - */ - function getLibStatut($mode) - { - return $this->LibStatut($this->status, $mode); - } + /** + * Return status label of Order + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + public function getLibStatut($mode) + { + return $this->LibStatut($this->status, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Return label of status - * - * @param int $status Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - function LibStatut($status, $mode) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of status + * + * @param int $status Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode) + { // phpcs:enable - global $langs, $conf; + global $langs, $conf; - //print 'x'.$status.'-'.$billed; - if ($mode == 0) - { - if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); - if ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); - if ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); - } - elseif ($mode == 1) - { - if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); - if ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); - if ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); - } - elseif ($mode == 2) - { - if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1').' '.$langs->trans('Opened'); - if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); - } - elseif ($mode == 3) - { - if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0'); - if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1'); - if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6'); - } - elseif ($mode == 4) - { - if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened').$billedtext, 'statut1').' '.$langs->trans('Opened'); - if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); - } - elseif ($mode == 5) - { - if ($status==self::STATUS_DRAFT) return ''.$langs->trans('Draft').' '.img_picto($langs->trans('Draft'), 'statut0'); - if ($status==self::STATUS_VALIDATED) return ''.$langs->trans('Opened').' '.img_picto($langs->trans('Opened'), 'statut1'); - if ($status==self::STATUS_CLOSED) return ''.$langs->trans('Closed').' '.img_picto($langs->trans('Closed'), 'statut6'); - } - } + //print 'x'.$status.'-'.$billed; + if ($mode == 0) + { + if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); + elseif ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); + elseif ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); + } + elseif ($mode == 1) + { + if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); + elseif ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); + elseif ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); + } + elseif ($mode == 2) + { + if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); + elseif ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1').' '.$langs->trans('Opened'); + elseif ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); + } + elseif ($mode == 3) + { + if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0'); + elseif ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1'); + elseif ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6'); + } + elseif ($mode == 4) + { + if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); + elseif ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened').$billedtext, 'statut1').' '.$langs->trans('Opened'); + elseif ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); + } + elseif ($mode == 5) + { + if ($status==self::STATUS_DRAFT) return ''.$langs->trans('Draft').' '.img_picto($langs->trans('Draft'), 'statut0'); + elseif ($status==self::STATUS_VALIDATED) return ''.$langs->trans('Opened').' '.img_picto($langs->trans('Opened'), 'statut1'); + elseif ($status==self::STATUS_CLOSED) return ''.$langs->trans('Closed').' '.img_picto($langs->trans('Closed'), 'statut6'); + } + } } diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 98f296d5060..461fa942679 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -28,29 +28,29 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class ActionsCardProduct { - var $targetmodule; - var $canvas; - var $card; + public $targetmodule; + public $canvas; + public $card; //! Template container - var $tpl = array(); + public $tpl = array(); // List of fiels for action=list - var $field_list =array(); + public $field_list =array(); public $list_datas = array(); /** - * Constructor - * + * Constructor + * * @param DoliDB $db Database handler * @param string $dirmodule Name of directory of module * @param string $targetmodule Name of directory where canvas is stored * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) - */ - function __construct($db, $dirmodule, $targetmodule, $canvas, $card) - { + */ + public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) + { $this->db = $db; $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; @@ -64,7 +64,7 @@ class ActionsCardProduct } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas (for example into this->tpl to be used by templates) * @@ -73,7 +73,7 @@ class ActionsCardProduct * @param string $ref Ref of object * @return void */ - function assign_values(&$action, $id = 0, $ref = '') + public function assign_values(&$action, $id = 0, $ref = '') { // phpcs:enable global $limit, $offset, $sortfield, $sortorder; @@ -86,8 +86,7 @@ class ActionsCardProduct //parent::assign_values($action); - foreach($this->object as $key => $value) - { + foreach($this->object as $key => $value) { $this->tpl[$key] = $value; } @@ -296,7 +295,7 @@ class ActionsCardProduct } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -306,7 +305,7 @@ class ActionsCardProduct * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - function LoadListDatas($limit, $offset, $sortfield, $sortorder) + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) { // phpcs:enable global $conf, $langs; diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 5f5c78cfbc1..fab5794c82a 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -28,15 +28,15 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class ActionsCardService { - var $targetmodule; - var $canvas; - var $card; + public $targetmodule; + public $canvas; + public $card; //! Template container - var $tpl = array(); + public $tpl = array(); // List of fiels for action=list - var $field_list =array(); + public $field_list =array(); public $list_datas = array(); @@ -48,7 +48,7 @@ class ActionsCardService * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) */ - function __construct($db, $targetmodule, $canvas, $card) + public function __construct($db, $targetmodule, $canvas, $card) { $this->db = $db; $this->targetmodule = $targetmodule; @@ -63,7 +63,7 @@ class ActionsCardService } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas (for example into this->tpl to be used by templates) * @@ -72,7 +72,7 @@ class ActionsCardService * @param string $ref Ref of object * @return void */ - function assign_values(&$action, $id = 0, $ref = '') + public function assign_values(&$action, $id = 0, $ref = '') { // phpcs:enable global $limit, $offset, $sortfield, $sortorder; @@ -274,7 +274,7 @@ class ActionsCardService } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -284,7 +284,7 @@ class ActionsCardService * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - function LoadListDatas($limit, $offset, $sortfield, $sortorder) + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) { // phpcs:enable global $conf; diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c0e0b485d71..756bbde5b29 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -44,7 +44,7 @@ class Products extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -68,14 +68,14 @@ class Products extends DolibarrApi * @throws 403 * @throws 404 */ - function get($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0) + public function get($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0) { if (empty($id) && empty($ref) && empty($ref_ext) && empty($barcode)) { throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode'); } $id = (empty($id)?0:$id); - + if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(403); } @@ -84,7 +84,7 @@ class Products extends DolibarrApi if(! $result ) { throw new RestException(404, 'Product not found'); } - + if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -110,7 +110,7 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @return array Array of product objects */ - function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '') + public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '') { global $db, $conf; @@ -185,7 +185,7 @@ class Products extends DolibarrApi * @param array $request_data Request data * @return int ID of product */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); @@ -215,7 +215,7 @@ class Products extends DolibarrApi * @throws 401 * @throws 404 */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { global $conf; @@ -300,7 +300,7 @@ class Products extends DolibarrApi * @param int $id Product ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); @@ -335,7 +335,7 @@ class Products extends DolibarrApi * * @url GET {id}/categories */ - function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); @@ -365,7 +365,7 @@ class Products extends DolibarrApi * * @url GET {id}/selling_multiprices/per_segment */ - function getCustomerPricesPerSegment($id) + public function getCustomerPricesPerSegment($id) { global $conf; @@ -387,13 +387,13 @@ class Products extends DolibarrApi } return array( - 'multiprices'=>$this->product->multiprices, - 'multiprices_inc_tax'=>$this->product->multiprices_ttc, - 'multiprices_min'=>$this->product->multiprices_min, - 'multiprices_min_inc_tax'=>$this->product->multiprices_min_ttc, - 'multiprices_vat'=>$this->product->multiprices_tva_tx, - 'multiprices_base_type'=>$this->product->multiprices_base_type, - //'multiprices_default_vat_code'=>$this->product->multiprices_default_vat_code + 'multiprices'=>$this->product->multiprices, + 'multiprices_inc_tax'=>$this->product->multiprices_ttc, + 'multiprices_min'=>$this->product->multiprices_min, + 'multiprices_min_inc_tax'=>$this->product->multiprices_min_ttc, + 'multiprices_vat'=>$this->product->multiprices_tva_tx, + 'multiprices_base_type'=>$this->product->multiprices_base_type, + //'multiprices_default_vat_code'=>$this->product->multiprices_default_vat_code ); } @@ -406,7 +406,7 @@ class Products extends DolibarrApi * * @url GET {id}/selling_multiprices/per_customer */ - function getCustomerPricesPerCustomer($id) + public function getCustomerPricesPerCustomer($id) { global $conf; @@ -440,7 +440,7 @@ class Products extends DolibarrApi * * @url GET {id}/selling_multiprices/per_quantity */ - function getCustomerPricesPerQuantity($id) + public function getCustomerPricesPerQuantity($id) { global $conf; @@ -468,15 +468,16 @@ class Products extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->regeximgext); @@ -502,7 +503,7 @@ class Products extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $product = array(); foreach (Products::$FIELDS as $field) { diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 93d239cc207..1bafd063dec 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -45,11 +45,11 @@ class FormProduct /** - * Constructor + * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -69,7 +69,7 @@ class FormProduct * @param array $exclude warehouses ids to exclude * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ - function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '') + public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '') { global $conf, $langs; @@ -210,7 +210,7 @@ class FormProduct * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse * @return string HTML select */ - function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1) + public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1) { global $conf,$langs,$user; @@ -255,7 +255,7 @@ class FormProduct * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - function formSelectWarehouses($page, $selected = '', $htmlname = 'warehouse_id', $addempty = 0) + public function formSelectWarehouses($page, $selected = '', $htmlname = 'warehouse_id', $addempty = 0) { global $langs; if ($htmlname != "none") { @@ -280,7 +280,7 @@ class FormProduct } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a combo box with list of units * pour l'instant on ne definit pas les unites dans la base @@ -291,24 +291,24 @@ class FormProduct * @param int $adddefault Add empty unit called "Default" * @return void */ - function select_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) + public function select_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) { //phpcs:enable print $this->load_measuring_units($name, $measuring_style, $default, $adddefault); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a combo box with list of units * For the moment, units labels are defined in measuring_units_string * - * @param string $name Name of HTML field + * @param string $name Name of HTML field * @param string $measuring_style Unit to show: weight, size, surface, volume * @param string $default Force unit - * @param int $adddefault Add empty unit called "Default" - * @return string + * @param int $adddefault Add empty unit called "Default" + * @return string */ - function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) + public function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) { //phpcs:enable global $langs, $conf, $mysoc, $db; @@ -320,10 +320,16 @@ class FormProduct require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php'; $measuringUnits = new CUnits($db); - $result = $measuringUnits->fetchAll('', '', 0, 0, array( - 't.unit_type' => $measuring_style, - 't.active' => 1 - )); + $result = $measuringUnits->fetchAll( + '', + '', + 0, + 0, + array( + 't.unit_type' => $measuring_style, + 't.active' => 1, + ) + ); if ($result < 0) { dol_print_error($db); return - 1; @@ -332,8 +338,7 @@ class FormProduct if ($adddefault) $return .= ''; - foreach ($measuringUnits->records as $lines) - { + foreach ($measuringUnits->records as $lines) { $return .= '