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/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index b6d526bf8e1..881b5b1a6a4 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -191,6 +191,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday %_datadir/dolibarr/htdocs/hrm +%_datadir/dolibarr/htdocs/ifttt %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 32c6e50018e..74d6bf700bb 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -271,6 +271,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday %_datadir/dolibarr/htdocs/hrm +%_datadir/dolibarr/htdocs/ifttt %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index dbb8e0d1310..181bdb4ded4 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -188,6 +188,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday %_datadir/dolibarr/htdocs/hrm +%_datadir/dolibarr/htdocs/ifttt %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index aa810a737b9..1410e5097cf 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -199,6 +199,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday %_datadir/dolibarr/htdocs/hrm +%_datadir/dolibarr/htdocs/ifttt %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install 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 new file mode 100644 index 00000000000..ff559332316 --- /dev/null +++ b/htdocs/accountancy/admin/closure.php @@ -0,0 +1,136 @@ + + * + * 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/accountancy/admin/closure.php + * \ingroup Advanced accountancy + * \brief Setup page to configure accounting expert module + */ +require '../../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("compta","admin","accountancy")); + +// Security check +if (empty($user->rights->accounting->chartofaccount)) { + accessforbidden(); +} + +$action = GETPOST('action', 'aZ09'); + + +$list_account_main = array ( + 'ACCOUNTING_RESULT_PROFIT', + 'ACCOUNTING_RESULT_LOSS' +); + +/* + * Actions + */ + +if ($action == 'update') { + $error = 0; + + $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); + + if (! empty($defaultjournal)) { + if (! dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } else { + $error ++; + } + + foreach ($list_account_main as $constname) { + $constvalue = GETPOST($constname, 'alpha'); + + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } + + if (! $error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + + +/* + * View + */ + +$form = new Form($db); +$formaccounting = new FormAccounting($db); + +llxHeader(); + +$linkback = ''; +print load_fiche_titre($langs->trans('MenuClosureAccounts'), $linkback, 'title_accountancy'); + +print $langs->trans("DefaultClosureDesc").'
'; +print '
'; + +print '
'; +print ''; +print ''; + +// Define main accounts for closure +print ''; + +foreach ($list_account_main as $key) { + + print ''; + // Param + $label = $langs->trans($key); + $keydesc=$key.'_Desc'; + + $htmltext = $langs->trans($keydesc); + print ''; + // Value + print ''; + print ''; +} + +// Journal +print ''; +print ''; +print ''; + +print "
'; + print $form->textwithpicto($label, $htmltext); + 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 '
' . $langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL") . ''; +$defaultjournal=$conf->global->ACCOUNTING_CLOSURE_DEFAULT_JOURNAL; +print $formaccounting->select_journal($defaultjournal, "ACCOUNTING_CLOSURE_DEFAULT_JOURNAL", 9, 1, 0, 0); +print '
\n"; + +print '
'; + +print '
'; + +// End of page +llxFooter(); +$db->close(); 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/index.php b/htdocs/accountancy/admin/index.php index b3b8a67241b..965b63ba9b9 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2019 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -144,6 +144,18 @@ if ($action == 'setenabledraftexport') { } } +if ($action == 'setenablesubsidiarylist') { + $setenablesubsidiarylist = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); + if (! $res > 0) + $error ++; + if (! $error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View */ @@ -251,6 +263,19 @@ if (! empty($user->admin)) } print ''; + print ''; + print '' . $langs->trans("ACCOUNTANCY_COMBO_FOR_AUX") . ''; + if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + print ''; print '' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . ''; if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { 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/card.php b/htdocs/adherents/card.php index b9a2d15c5cd..9903255e52f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -305,6 +305,7 @@ if (empty($reshook)) $object->skype = trim(GETPOST("skype", 'alpha')); $object->twitter = trim(GETPOST("twitter", 'alpha')); $object->facebook = trim(GETPOST("facebook", 'alpha')); + $object->linkedin = trim(GETPOST("linkedin", 'alpha')); $object->birth = $birthdate; $object->typeid = GETPOST("typeid", 'int'); @@ -450,6 +451,7 @@ if (empty($reshook)) $skype=GETPOST("member_skype", 'alpha'); $twitter=GETPOST("member_twitter", 'alpha'); $facebook=GETPOST("member_facebook", 'alpha'); + $linkedin=GETPOST("member_linkedin", 'alpha'); $email=preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $login=GETPOST("member_login", 'alpha'); $pass=GETPOST("password", 'alpha'); @@ -479,6 +481,7 @@ if (empty($reshook)) $object->skype = $skype; $object->twitter = $twitter; $object->facebook = $facebook; + $object->linkedin = $linkedin; $object->email = $email; $object->login = $login; @@ -1029,6 +1032,12 @@ else print ''; } + // LinkedIn + if (! empty($conf->socialnetworks->enabled)) + { + print ''; + } + // Birthday print "'; - } + if (! empty($conf->socialnetworks->enabled)) + { + print ''; + } + + // LinkedIn + if (! empty($conf->socialnetworks->enabled)) + { + print ''; + } // Birthday 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 '
'.$langs->trans("Facebook").'
'.$langs->trans("LinkedIn").'
".$langs->trans("Birthday")."\n"; print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); @@ -1281,10 +1290,16 @@ else } // Facebook - if (! empty($conf->socialnetworks->enabled)) - { - print '
'.$langs->trans("Facebook").'facebook).'">
'.$langs->trans("Facebook").'facebook).'">
'.$langs->trans("LinkedIn").'linkedin).'">
".$langs->trans("Birthday")."\n"; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 22429de9200..77f3c7200f4 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -137,6 +137,11 @@ class Adherent extends CommonObject */ public $facebook; + /** + * @var string linkedin account + */ + public $linkedin; + /** * @var string Phone number */ @@ -218,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; @@ -229,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. * @@ -246,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; @@ -291,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; @@ -358,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; } @@ -374,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; @@ -500,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; @@ -550,6 +555,7 @@ class Adherent extends CommonObject $sql.= ", skype = '".$this->db->escape($this->skype)."'"; $sql.= ", twitter = '".$this->db->escape($this->twitter)."'"; $sql.= ", facebook = '".$this->db->escape($this->facebook)."'"; + $sql.= ", linkedin = '".$this->db->escape($this->linkedin)."'"; $sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null"); $sql.= ", phone_perso = ".($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql.= ", phone_mobile = ".($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null"); @@ -660,6 +666,7 @@ class Adherent extends CommonObject $luser->skype=$this->skype; $luser->twitter=$this->twitter; $luser->facebook=$this->facebook; + $luser->linkedin=$this->linkedin; $luser->office_phone=$this->phone; $luser->user_mobile=$this->phone_mobile; @@ -701,6 +708,7 @@ class Adherent extends CommonObject $lthirdparty->skype=$this->skype; $lthirdparty->twitter=$this->twitter; $lthirdparty->facebook=$this->facebook; + $lthirdparty->linkedin=$this->linkedin; $lthirdparty->phone=$this->phone; $lthirdparty->state_id=$this->state_id; $lthirdparty->country_id=$this->country_id; @@ -752,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. @@ -760,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(); @@ -817,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; @@ -927,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; @@ -1038,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; @@ -1072,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; @@ -1108,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; @@ -1139,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 * @@ -1147,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; @@ -1183,13 +1191,13 @@ 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; $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql.= " d.note_public,"; - $sql.= " d.email, d.skype, d.twitter, d.facebook, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; + $sql.= " d.email, d.skype, d.twitter, d.facebook, d.linkedin, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql.= " d.datec as datec,"; $sql.= " d.tms as datem,"; @@ -1266,15 +1274,19 @@ class Adherent extends CommonObject $this->skype = $obj->skype; $this->twitter = $obj->twitter; $this->facebook = $obj->facebook; + $this->linkedin = $obj->linkedin; $this->photo = $obj->photo; $this->statut = $obj->statut; $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; @@ -1316,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 @@ -1324,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; @@ -1400,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; @@ -1486,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; @@ -1779,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; @@ -1832,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; @@ -1874,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; @@ -1933,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; @@ -1997,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"); @@ -2018,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; @@ -2109,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 * @@ -2124,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; @@ -2202,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; @@ -2238,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; @@ -2337,7 +2349,7 @@ class Adherent extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; @@ -2362,6 +2374,7 @@ class Adherent extends CommonObject $this->skype = 'skypepseudo'; $this->twitter = 'twitterpseudo'; $this->facebook = 'facebookpseudo'; + $this->linkedin = 'linkedinpseudo'; $this->phone = '0999999999'; $this->phone_perso = '0999999998'; $this->phone_mobile = '0999999997'; @@ -2390,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 * @@ -2400,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; @@ -2412,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; @@ -2469,8 +2482,9 @@ class Adherent extends CommonObject if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; if ($this->skype && ! empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; if ($this->twitter && ! empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter; - if ($this->facebook && ! empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; - if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; + if ($this->facebook && ! empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; + if ($this->linkedin && ! empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin; + if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; @@ -2525,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,'; @@ -2581,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"; @@ -2763,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..6025f2a2985 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) { @@ -294,7 +294,7 @@ class Members extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -328,7 +328,7 @@ class Members extends DolibarrApi * * @url GET {id}/subscriptions */ - function getSubscriptions($id) + public function getSubscriptions($id) { $obj_ret = array(); @@ -361,7 +361,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 +389,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..43fd2635fb4 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) { @@ -272,7 +272,7 @@ class MembersTypes extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); 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 ''; - 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/dict.php b/htdocs/admin/dict.php index 6d46876586a..11134f70194 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -88,7 +88,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,37,0,25,0); +$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,37,0,25,0); // Name of SQL tables of dictionaries $tabname=array(); 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/socialnetworks.php b/htdocs/admin/socialnetworks.php index f723d13d540..8b7c061dc64 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -1,5 +1,6 @@ + * Copyright (C) 2019 Alexandre Spangaro * * 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 @@ -96,7 +97,7 @@ dol_fiche_head($head, 'setup', '', 0, 'user'); print '
'; -$arrayofsocialnetworks=array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook'); +$arrayofsocialnetworks=array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn'); foreach($arrayofsocialnetworks as $snkey => $snlabel) { $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); 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 8db471855d6..19bd61c641b 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; @@ -355,6 +354,22 @@ class Documents extends DolibarrApi $upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); } + else if ($modulepart == 'produit' || $modulepart == 'product') + { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + if (!DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(401); + } + + $object = new Product($this->db); + $result=$object->fetch($id, $ref); + if ( ! $result ) { + throw new RestException(404, 'Product not found'); + } + + $upload_dir = $conf->product->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'product'); + } else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -376,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.'); } @@ -412,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 @@ -421,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; @@ -501,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.'); @@ -576,6 +592,7 @@ class Documents extends DolibarrApi return dol_basename($destfile); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Validate fields before create or update object * @@ -583,7 +600,8 @@ 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..766cf79f7be 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(); @@ -279,7 +279,7 @@ class Setup extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -334,7 +334,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 +397,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 +442,7 @@ class Setup extends DolibarrApi return $list; } - + /** * Get the list of currencies. * @@ -458,10 +458,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 +516,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 +595,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 +659,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 +720,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 +780,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 +840,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 +898,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 new file mode 100644 index 00000000000..561b44fa262 --- /dev/null +++ b/htdocs/bom/admin/setup.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2019 Maxime Kohlhaas + * + * 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 bom/admin/setup.php + * \ingroup bom + * \brief Bom setup page. + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +global $langs, $user; + +// Libraries +require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once '../lib/bom.lib.php'; +//require_once "../class/myclass.class.php"; + +// Translations +$langs->loadLangs(array("admin", "mrp")); + +// Access control +if (! $user->admin) accessforbidden(); + +// Parameters +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + +$arrayofparameters=array( + 'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), + 'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +); + + +/* + * Actions + */ +if ((float) DOL_VERSION >= 6) +{ + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; +} + + +/* + * View + */ + +$page_name = "BomSetup"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = ''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom'); + +// Configuration header +$head = bomAdminPrepareHead(); +dol_fiche_head($head, 'settings', '', -1, "bom"); + +// Setup page goes here +echo $langs->trans("BomSetupPage").'

'; + + +if ($action == 'edit') +{ + print '
'; + print ''; + print ''; + + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + print '
'; + + print '
'; + print ''; + print '
'; + + print '
'; + print '
'; +} +else +{ + if (! empty($arrayofparameters)) + { + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + print '' . $conf->global->$key . '
'; + + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; + } + else + { + print '
'.$langs->trans("NothingToSetup"); + } +} + + +// Page end +dol_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php new file mode 100644 index 00000000000..0054e427996 --- /dev/null +++ b/htdocs/bom/bom_card.php @@ -0,0 +1,471 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 bom_card.php + * \ingroup bom + * \brief Page to create/edit/view bom + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies + + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +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("mrp","other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bomcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new BillOfMaterials($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('bomcard', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$isdraft = (($object->statut == BillOfMaterials::STATUS_DRAFT) ? 1 : 0); +//$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + + +/* + * Actions + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error=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__'); + } + $triggermodname = 'BILLOFMATERIALS_BILLOFMATERIALS_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, delete or clone + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $trigger_name='BILLOFMATERIALS_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_BILLOFMATERIALS_TO'; + $trackid='bom'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + * + * Put here all code to build page + */ + +$form=new Form($db); +$formfile=new FormFile($db); + +llxHeader('', 'NewBOM', ''); + +// Example : Adding jquery code +print ''; + + +// Part to create +if ($action == 'create') +{ + print load_fiche_titre($langs->trans("NewBOM")); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + dol_fiche_end(); + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') +{ + print load_fiche_titre($langs->trans("BillOfMaterials")); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + dol_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals(); + + $head = bomPrepareHead($object); + dol_fiche_head($head, 'card', $langs->trans("NewBOM"), -1, 'bom'); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); + } + + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneBillOfMaterials'), $langs->trans('ConfirmCloneBillOfMaterials', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->bom->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } + } + */ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswithonsecondcolumn'; + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print '
'; + + print '

'; + + dol_fiche_end(); + + + // Buttons for actions + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + // Send + print '' . $langs->trans('SendMail') . ''."\n"; + + // Modify + if ($user->rights->bom->write) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } + + // Clone + if ($user->rights->bom->write) + { + print ''; + } + + /* + if ($user->rights->bom->write) + { + if ($object->status == 1) + { + print ''.$langs->trans("Disable").''."\n"; + } + else + { + print ''.$langs->trans("Enable").''."\n"; + } + } + */ + + if ($user->rights->bom->delete) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + // Documents + /*$objref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->bom->dir_output . '/' . $objref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->bom->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + */ + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright.= $langs->trans("SeeAll"); + $morehtmlright.= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + + print '
'; + } + + //Select mail models is same action as presend + /* + if (GETPOST('modelselected')) $action = 'presend'; + + // Presend form + $modelmail='inventory'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->product->dir_output.'/inventory'; + $trackid = 'stockinv'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + */ +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php new file mode 100644 index 00000000000..b13277cd82b --- /dev/null +++ b/htdocs/bom/bom_document.php @@ -0,0 +1,166 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 bom_document.php + * \ingroup bom + * \brief Tab for documents linked to BillOfMaterials + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +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("mrp","companies","other","mails")); + + +$action=GETPOST('action', 'aZ09'); +$confirm=GETPOST('confirm', 'alpha'); +$id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$ref = GETPOST('ref', 'alpha'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'bom', $id); + +// Get parameters +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; +//if (! $sortfield) $sortfield="position_name"; + +// Initialize technical objects +$object=new BillOfMaterials($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('bomdocument', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('bom'); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/bom/" . dol_sanitizeFileName($object->id); +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/bom/" . dol_sanitizeFileName($object->ref); + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; + + +/* + * View + */ + +$form = new Form($db); + +$title=$langs->trans("BillOfMaterials").' - '.$langs->trans("Files"); +$help_url=''; +//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('', $title, $help_url); + +if ($object->id) +{ + /* + * Show tabs + */ + $head = bomPrepareHead($object); + + dol_fiche_head($head, 'document', $langs->trans("BillOfMaterials"), -1, 'bom'); + + + // Build file list + $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + // Number of files + print ''; + + // Total size + print ''; + + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print '
'; + + dol_fiche_end(); + + $modulepart = 'bom'; + //$permission = $user->rights->bom->create; + $permission = 1; + //$permtoedit = $user->rights->bom->create; + $permtoedit = 1; + $param = '&id=' . $object->id; + + //$relativepathwithnofile='bom/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile='bom/' . dol_sanitizeFileName($object->ref).'/'; + + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + accessforbidden('', 0, 0); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php new file mode 100644 index 00000000000..25fad036b65 --- /dev/null +++ b/htdocs/bom/bom_list.php @@ -0,0 +1,596 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 bom_list.php + * \ingroup bom + * \brief List page for bom + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL',1); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +dol_include_once('/bom/class/bom.class.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp", "other")); + +$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bomlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id', 'int'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +//if (! $sortfield) $sortfield="p.date_fin"; +//if (! $sortorder) $sortorder="DESC"; + +// Initialize technical objects +$object = new BillOfMaterials($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->bom->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('bom'); // Load $extrafields->attributes['bom'] +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (! $sortorder) $sortorder="ASC"; + +// Security check +$socid=0; +if ($user->societe_id > 0) // Protection if external user +{ + //$socid = $user->societe_id; + accessforbidden(); +} +//$result = restrictedArea($user, 'bom', $id, ''); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +} + +// Definition of fields for list +$arrayfields=array(); +foreach($object->fields as $key => $val) +{ + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); +} +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='BillOfMaterials'; + $objectlabel='BillOfMaterials'; + $permtoread = $user->rights->bom->read; + $permtodelete = $user->rights->bom->delete; + $uploaddir = $conf->bom->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + */ + +$form=new Form($db); + +$now=dol_now(); + +//$help_url="EN:Module_BillOfMaterials|FR:Module_BillOfMaterials_FR|ES:Módulo_BillOfMaterials"; +$help_url=''; +$title = $langs->trans('ListOfBOMs'); + + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/', '', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql.=" WHERE 1 = 1"; +foreach($search as $key => $val) +{ + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); +} +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); +*/ + +$sql.=$db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { + $page = 0; + $offset = 0; + } +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; +} +else +{ + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Direct jump if only one record found +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/bom/bom_card.php', 1).'?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +foreach($search as $key => $val) +{ + $param.= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// List of mass actions available +$arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), +); +if ($user->rights->bom->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton=''; +//if ($user->rights->bom->creer) +//{ + $newcardbutton=''.$langs->trans('New').''; + $newcardbutton.= ''; + $newcardbutton.= ''; +//} +//else +//{ +// $newcardbutton=''.$langs->trans('New'); +// $newcardbutton.= ''; +// $newcardbutton.= ''; +//} + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail="SendBillOfMaterialsRef"; +$modelmail="bom"; +$objecttmp=new BillOfMaterials($db); +$trackid='xxxx'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($sall) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
';*/ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine=0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) + { + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + } +} + + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (isset($obj->$key)) $object->$key = $obj->$key; + } + + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { + $cssforfield=''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''; + + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + else print ''; + } + } + print ''; +} + +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; +} + + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&', '&', $param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->bom->read; + $delallowed=$user->rights->bom->create; + + print $formfile->showdocuments('massfilesarea_bom', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php new file mode 100644 index 00000000000..fb0d58509d7 --- /dev/null +++ b/htdocs/bom/bom_note.php @@ -0,0 +1,164 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 bom_note.php + * \ingroup bom + * \brief Car with notes on BillOfMaterials + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +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("mrp","companies")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new BillOfMaterials($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('bomnote','globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('bom'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'bom', $id); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->bom->multidir_output[$object->entity] . "/" . $object->id; + +$permissionnote=1; +//$permissionnote=$user->rights->bom->creer; // Used by the include of actions_setnotes.inc.php + + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + + +/* + * View + */ + +$form = new Form($db); + +//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; +$help_url=''; +llxHeader('', $langs->trans('BillOfMaterials'), $help_url); + +if ($id > 0 || ! empty($ref)) +{ + $object->fetch_thirdparty(); + + $head = bomPrepareHead($object); + + dol_fiche_head($head, 'note', $langs->trans("BillOfMaterials"), -1, 'bom'); + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->bom->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + + + $cssclass="titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '
'; + + dol_fiche_end(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/bom/class/api_bom.class.php b/htdocs/bom/class/api_bom.class.php new file mode 100644 index 00000000000..4bb4f1a96ab --- /dev/null +++ b/htdocs/bom/class/api_bom.class.php @@ -0,0 +1,324 @@ + + * Copyright (C) 2019 Maxime Kohlhaas + * + * 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 . + */ + +use Luracast\Restler\RestException; + +dol_include_once('/bom/class/bom.class.php'); + + + +/** + * \file bom/class/api_bom.class.php + * \ingroup bom + * \brief File for API management of bom. + */ + +/** + * API class for bom bom + * + * @smart-auto-routing false + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class BillOfMaterialsApi extends DolibarrApi +{ + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'name', + ); + + + /** + * @var BillOfMaterials $bom {@type BillOfMaterials} + */ + public $bom; + + /** + * Constructor + * + * @url GET / + * + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->bom = new BillOfMaterials($this->db); + } + + /** + * Get properties of a bom object + * + * Return an array with bom informations + * + * @param int $id ID of bom + * @return array|mixed data without useless information + * + * @url GET boms/{id} + * @throws RestException + */ + public function get($id) + { + if(! DolibarrApiAccess::$user->rights->bom->read) { + throw new RestException(401); + } + + $result = $this->bom->fetch($id); + if( ! $result ) { + throw new RestException(404, 'BillOfMaterials not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->bom); + } + + + /** + * List boms + * + * Get a list of boms + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + * + * @url GET /boms/ + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; + + $obj_ret = array(); + + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + + $restictonsocid = 0; // Set to 1 if there is a field socid in table of object + + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if ($restictonsocid && ! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + + $sql = "SELECT t.rowid"; + if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."bom_mytable as t"; + + if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql.= " WHERE 1 = 1"; + + // Example of use $mode + //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; + //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; + + $tmpobject = new BillOfMaterials($db); + if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('bom').')'; + if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + 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) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); + $bom_static = new BillOfMaterials($db); + if($bom_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($bom_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve bom list'); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No bom found'); + } + return $obj_ret; + } + + /** + * Create bom object + * + * @param array $request_data Request datas + * @return int ID of bom + * + * @url POST boms/ + */ + public function post($request_data = null) + { + if(! DolibarrApiAccess::$user->rights->bom->create) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach($request_data as $field => $value) { + $this->bom->$field = $value; + } + if( ! $this->bom->create(DolibarrApiAccess::$user)) { + throw new RestException(500); + } + return $this->bom->id; + } + + /** + * Update bom + * + * @param int $id Id of bom to update + * @param array $request_data Datas + * @return int + * + * @url PUT boms/{id} + */ + public function put($id, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->bom->create) { + throw new RestException(401); + } + + $result = $this->bom->fetch($id); + if( ! $result ) { + throw new RestException(404, 'BillOfMaterials not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach($request_data as $field => $value) { + $this->bom->$field = $value; + } + + if($this->bom->update($id, DolibarrApiAccess::$user)) + return $this->get($id); + + return false; + } + + /** + * Delete bom + * + * @param int $id BillOfMaterials ID + * @return array + * + * @url DELETE bom/{id} + */ + public function delete($id) + { + if(! DolibarrApiAccess::$user->rights->bom->delete) { + throw new RestException(401); + } + $result = $this->bom->fetch($id); + if( ! $result ) { + throw new RestException(404, 'BillOfMaterials not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if( !$this->bom->delete(DolibarrApiAccess::$user, 0)) + { + throw new RestException(500); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'BillOfMaterials deleted' + ) + ); + } + + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + private function _cleanObjectDatas($object) + { + $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);*/ + + return $object; + } + + /** + * Validate fields before create or update object + * + * @param array $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $bom = array(); + foreach (BillOfMaterialsApi::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $bom[$field] = $data[$field]; + } + return $bom; + } +} diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php new file mode 100644 index 00000000000..606693bbed6 --- /dev/null +++ b/htdocs/bom/class/bom.class.php @@ -0,0 +1,1210 @@ + + * + * 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 class/bom.class.php + * \ingroup bom + * \brief This file is a CRUD class file for BOM (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +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 BOM + */ +class BOM extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'bom'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'bom_bom'; + + /** + * @var int Does bom support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 1; + + /** + * @var int Does bom support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for bom. Must be the part after the 'object_' into object_bom.png + */ + public $picto = 'bom'; + + + public $table_element_line = 'bom_bomline'; + + + /** + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'1',), + 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>62, 'notnull'=>-1,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), + 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',), + 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>50, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'), + 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1',), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'notnull'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Enabled', '-1'=>'Disabled')), + ); + public $rowid; + public $ref; + public $label; + public $description; + public $note_public; + public $note_private; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $import_key; + public $status; + public $fk_product; + public $qty; + // END MODULEBUILDER PROPERTIES + + + + // If this object has a subtable with lines + + /** + * @var int Name of subtable line + */ + //public $table_element_line = 'bomdet'; + + /** + * @var int Field with ID of parent key if this field has a parent + */ + //public $fk_element = 'fk_bom'; + + /** + * @var int Name of subtable class that manage subtable lines + */ + //public $class_element_line = 'BillOfMaterialsline'; + + /** + * @var array Array of child tables (child tables to delete before deleting a record) + */ + //protected $childtables=array('bomdet'); + + /** + * @var BillOfMaterialsLine[] Array of subtable lines + */ + //public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs, $user; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($this->fields['status']['arrayofkeyval'])) + { + foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) + { + $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $hookmanager, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $this->lines=array(); + + // Load lines with object BillOfMaterialsLine + + return count($this->lines)?1:0; + }*/ + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records=array(); + + $sql = 'SELECT'; + $sql .= ' t.rowid'; + // TODO Get all fields + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' WHERE t.entity = '.$conf->entity; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key=='t.rowid') { + $sqlwhere[] = $key . '='. $value; + } + elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } + elseif ($key=='customsql') { + $sqlwhere[] = $value; + } + else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) + { + $record = new self($this->db); + + $record->id = $obj->rowid; + // TODO Get other fields + + //var_dump($record->id); + $records[$record->id] = $record; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //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 + */ + 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; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + + $label = '' . $langs->trans("BillOfMaterials") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = dol_buildpath('/bom/bom_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowBillOfMaterials"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + + /* + $hookmanager->initHooks(array('bomdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $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; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action,$hookmanager; + $hookmanager->initHooks(array('bomdao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + + /** + * Return label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("mrp"); + $this->labelstatus[1] = $langs->trans('Enabled'); + $this->labelstatus[0] = $langs->trans('Disabled'); + } + + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 3) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 4) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 5) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 6) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + $this->date = $this->date_creation; + } + + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + //public function doScheduledJob($param1, $param2, ...) + public function doScheduledJob() + { + global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error=''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} + + +/** + * Class for BillOfMaterialsLine + */ +class BillOfMaterialsLine extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'bomline'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'bom_bomline'; + + /** + * @var int Does bomline support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does bomline support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for bomline. Must be the part after the 'object_' into object_bomline.png + */ + public $picto = 'bomline@bom'; + + + /** + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), + 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'isameasure'=>'1',), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>-1, 'index'=>1,), + 'fk_bom' => array('type'=>'integer:BillOfMaterials:societe/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>-1, 'index'=>1,), + 'rank' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'position'=>40, 'notnull'=>1,), + ); + public $rowid; + public $description; + public $import_key; + public $qty; + public $fk_product; + public $fk_bom; + public $rank; + // END MODULEBUILDER PROPERTIES + + + + // If this object has a subtable with lines + + /** + * @var int Name of subtable line + */ + //public $table_element_line = 'bomlinedet'; + + /** + * @var int Field with ID of parent key if this field has a parent + */ + //public $fk_element = 'fk_bomline'; + + /** + * @var int Name of subtable class that manage subtable lines + */ + //public $class_element_line = 'BillOfMaterialsLineline'; + + /** + * @var array Array of child tables (child tables to delete before deleting a record) + */ + //protected $childtables=array('bomlinedet'); + + /** + * @var BillOfMaterialsLineLine[] Array of subtable lines + */ + //public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs, $user; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($this->fields['status']['arrayofkeyval'])) + { + foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) + { + $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $hookmanager, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $this->lines=array(); + + // Load lines with object BillOfMaterialsLineLine + + return count($this->lines)?1:0; + }*/ + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records=array(); + + $sql = 'SELECT'; + $sql .= ' t.rowid'; + // TODO Get all fields + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' WHERE t.entity = '.$conf->entity; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key=='t.rowid') { + $sqlwhere[] = $key . '='. $value; + } + elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } + elseif ($key=='customsql') { + $sqlwhere[] = $value; + } + else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) + { + $record = new self($this->db); + + $record->id = $obj->rowid; + // TODO Get other fields + + //var_dump($record->id); + $records[$record->id] = $record; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //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 + */ + 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; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + + $label = '' . $langs->trans("BillOfMaterialsLine") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = dol_buildpath('/bom/bomline_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowBillOfMaterialsLine"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + + /* + $hookmanager->initHooks(array('bomlinedao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $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; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action,$hookmanager; + $hookmanager->initHooks(array('bomlinedao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + + /** + * Return label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("mrp"); + $this->labelstatus[1] = $langs->trans('Enabled'); + $this->labelstatus[0] = $langs->trans('Disabled'); + } + + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 3) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 4) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 5) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 6) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + //public function doScheduledJob($param1, $param2, ...) + public function doScheduledJob() + { + global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error=''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php new file mode 100644 index 00000000000..0085d06b69c --- /dev/null +++ b/htdocs/bom/lib/bom.lib.php @@ -0,0 +1,124 @@ + + * + * 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 bom/lib/bom.lib.php + * \ingroup bom + * \brief Library files with common functions for BillOfMaterials + */ + +/** + * Prepare admin pages header + * + * @return array + */ +function bomAdminPrepareHead() +{ + global $langs, $conf; + + $langs->load("mrp"); + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT."/admin/bom.php"; + $head[$h][1] = $langs->trans("Settings"); + $head[$h][2] = 'settings'; + $h++; + + /*$head[$h][0] = dol_buildpath("/bom/admin/about.php", 1); + $head[$h][1] = $langs->trans("About"); + $head[$h][2] = 'about'; + $h++; + */ + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@bom:/bom/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@bom:/bom/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom'); + + return $head; +} + + + + +/** + * Prepare array of tabs for BillOfMaterials + * + * @param BillOfMaterials $object BillOfMaterials + * @return array Array of tabs + */ +function bomPrepareHead($object) +{ + global $db, $langs, $conf; + + $langs->load("mrp"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/bom/bom_card.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) + { + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; + $head[$h][0] = dol_buildpath('/bom/bom_note.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + $head[$h][2] = 'note'; + $h++; + } + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->bom->dir_output . "/bom/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks=Link::count($db, $object->element, $object->id); + $head[$h][0] = dol_buildpath("/bom/bom_document.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + $head[$h][2] = 'document'; + $h++; + + $head[$h][0] = dol_buildpath("/bom/bom_agenda.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Events"); + $head[$h][2] = 'agenda'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@bom:/bom/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@bom:/bom/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom'); + + return $head; +} diff --git a/htdocs/bom/modulebuilder.txt b/htdocs/bom/modulebuilder.txt new file mode 100644 index 00000000000..24ea0d6eac5 --- /dev/null +++ b/htdocs/bom/modulebuilder.txt @@ -0,0 +1,3 @@ +# DO NOT DELETE THIS FILE MANUALLY +# File to flag module built using official module template. +# When this file is present into a module directory, you can edit it with the module builder tool. Use ModuleBuilder if you want to delete module. \ No newline at end of file diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index f66ef8e4d80..eb1342ad119 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -82,7 +82,7 @@ class Bookmark extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -93,7 +93,7 @@ class Bookmark extends CommonObject * @param int $id Bookmark Id Loader * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $conf; @@ -135,7 +135,7 @@ class Bookmark extends CommonObject * * @return int <0 si ko, rowid du bookmark cree si ok */ - function create() + public function create() { global $conf; @@ -192,7 +192,7 @@ class Bookmark extends CommonObject * * @return int <0 if KO, > if OK */ - function update() + public function update() { // Clean parameters $this->url=trim($this->url); @@ -227,7 +227,7 @@ class Bookmark extends CommonObject * @param int $id Id removed bookmark * @return int <0 si ko, >0 si ok */ - function remove($id) + public function remove($id) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; $sql .= " WHERE rowid = ".$id; @@ -268,7 +268,7 @@ class Bookmark 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 contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return ''; } diff --git a/htdocs/cashdesk/class/Auth.class.php b/htdocs/cashdesk/class/Auth.class.php index 26c1bee3d3c..d33081f8e74 100644 --- a/htdocs/cashdesk/class/Auth.class.php +++ b/htdocs/cashdesk/class/Auth.class.php @@ -60,7 +60,7 @@ class Auth * @param string $aPasswd Password * @return void */ - function passwd($aPasswd) + public function passwd($aPasswd) { $this->passwd = $aPasswd; } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 2b670ae5286..434b7ba1d24 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -53,7 +53,7 @@ class Categories extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -70,7 +70,7 @@ class Categories extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); @@ -103,7 +103,7 @@ class Categories extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') { global $db, $conf; @@ -173,7 +173,7 @@ class Categories extends DolibarrApi * @param array $request_data Request data * @return int ID of category */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); @@ -198,7 +198,7 @@ class Categories 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->categorie->creer) { throw new RestException(401); @@ -234,7 +234,7 @@ class Categories extends DolibarrApi * @param int $id Category ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->categorie->supprimer) { throw new RestException(401); @@ -267,7 +267,7 @@ class Categories extends DolibarrApi * @param Categorie $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -324,7 +324,7 @@ class Categories extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $category = array(); foreach (Categories::$FIELDS as $field) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 99433a9b8f0..aed85c9a83c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -107,7 +107,7 @@ class Categorie extends CommonObject 'account' => 'account', // old for bank_account 'bank_account' => 'account', 'project' => 'project', - ); + ); /** * @var array Category tables mapping from type string @@ -221,7 +221,7 @@ class Categorie extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -234,7 +234,7 @@ class Categorie extends CommonObject * @param string $type Type of category ('product', '...') or (0, 1, ...) * @return int <0 if KO, >0 if OK */ - function fetch($id, $label = '', $type = null) + public function fetch($id, $label = '', $type = null) { global $conf; @@ -297,15 +297,15 @@ class Categorie extends CommonObject } /** - * Add category into database + * Add category into database * - * @param User $user Object user - * @return int -1 : SQL error + * @param User $user Object user + * @return int -1 : SQL error * -2 : new ID unknown * -3 : Invalid category * -4 : category already exists */ - function create($user) + public function create($user) { global $conf,$langs,$hookmanager; $langs->load('categories'); @@ -426,7 +426,7 @@ class Categorie extends CommonObject * -1 : SQL error * -2 : invalid category */ - function update(User $user) + public function update(User $user) { global $conf, $langs,$hookmanager; @@ -501,7 +501,7 @@ class Categorie extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 KO >0 OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf,$langs; @@ -580,7 +580,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link an object to the category * @@ -588,7 +588,7 @@ class Categorie extends CommonObject * @param string $type Type of category ('product', ...) * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ - function add_type($obj, $type) + public function add_type($obj, $type) { // phpcs:enable global $user,$langs,$conf; @@ -682,7 +682,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete object from category * @@ -691,7 +691,7 @@ class Categorie extends CommonObject * * @return int 1 if OK, -1 if KO */ - function del_type($obj, $type) + public function del_type($obj, $type) { // phpcs:enable global $user,$langs,$conf; @@ -749,7 +749,7 @@ class Categorie extends CommonObject * @return array|int -1 if KO, array of instance of object if OK * @see containsObject */ - function getObjectsInCateg($type, $onlyids = 0) + public function getObjectsInCateg($type, $onlyids = 0) { $objs = array(); @@ -796,7 +796,7 @@ class Categorie extends CommonObject * @return int Number of occurrences * @see getObjectsInCateg */ - function containsObject($type, $object_id) + public function containsObject($type, $object_id) { $sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type]; $sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $object_id; @@ -821,7 +821,7 @@ class Categorie extends CommonObject * @param int $page Page number * @return array|int Array of categories, 0 if no cat, -1 on error */ - function getListForItem($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getListForItem($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { global $conf; @@ -907,13 +907,13 @@ class Categorie extends CommonObject return $categories; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return childs of a category * * @return array|int <0 KO, array ok */ - function get_filles() + public function get_filles() { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; @@ -974,7 +974,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Rebuilding the category tree as an array * Return an array of table('id','id_mere',...) trie selon arbre et avec: @@ -990,7 +990,7 @@ class Categorie extends CommonObject * * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error */ - function get_full_arbo($type, $markafterid = 0) + public function get_full_arbo($type, $markafterid = 0) { // phpcs:enable global $conf, $langs; @@ -1068,7 +1068,7 @@ class Categorie extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel * @@ -1076,10 +1076,10 @@ class Categorie extends CommonObject * @param int $protection Deep counter to avoid infinite loop * @return void */ - function build_path_from_id_categ($id_categ, $protection = 1000) - { + public function build_path_from_id_categ($id_categ, $protection = 1000) + { // phpcs:enable - dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); + dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); if (! empty($this->cats[$id_categ]['fullpath'])) { @@ -1109,16 +1109,16 @@ class Categorie extends CommonObject // We count number of _ to have level $this->cats[$id_categ]['level']=dol_strlen(preg_replace('/[^_]/i', '', $this->cats[$id_categ]['fullpath'])); - return; - } + return; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display content of $this->cats * * @return void */ - function debug_cats() + public function debug_cats() { // phpcs:enable // Display $this->cats @@ -1135,7 +1135,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns all categories * @@ -1143,7 +1143,7 @@ class Categorie extends CommonObject * @param boolean $parent Just parent categories if true * @return array|int Table of Object Category, -1 on error */ - function get_all_categories($type = null, $parent = false) + public function get_all_categories($type = null, $parent = false) { // phpcs:enable if (! is_numeric($type)) $type = $this->MAP_ID[$type]; @@ -1174,13 +1174,13 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if no category with same label already exists for this cat's parent or root and for this cat's type * * @return integer 1 if already exist, 0 otherwise, -1 if error */ - function already_exists() + public function already_exists() { // phpcs:enable $type=$this->type; @@ -1225,20 +1225,20 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the top level categories (which are not girls) * * @param int $type Type of category (0, 1, ...) * @return array */ - function get_main_categories($type = null) + public function get_main_categories($type = null) { // phpcs:enable return $this->get_all_categories($type, true); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the path of the category, with the names of the categories * separated by $sep (" >> " by default) @@ -1248,7 +1248,7 @@ class Categorie extends CommonObject * @param int $nocolor 0 * @return array */ - function print_all_ways($sep = " >> ", $url = '', $nocolor = 0) + public function print_all_ways($sep = " >> ", $url = '', $nocolor = 0) { // phpcs:enable $ways = array(); @@ -1297,13 +1297,13 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array containing the list of parent categories * * @return int|array <0 KO, array OK */ - function get_meres() + public function get_meres() { // phpcs:enable $parents = array(); @@ -1333,14 +1333,14 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns in a table all possible paths to get to the category * starting with the major categories represented by Tables of categories * * @return array */ - function get_all_ways() + public function get_all_ways() { // phpcs:enable $ways = array(); @@ -1374,9 +1374,9 @@ class Categorie extends CommonObject * @param string|int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...) * @param string $mode 'id'=Get array of category ids, 'object'=Get array of fetched category instances, 'label'=Get array of category * labels, 'id'= Get array of category IDs - * @return array|int Array of category objects or < 0 if KO + * @return Categorie[]|int Array of category objects or < 0 if KO */ - function containing($id, $type, $mode = 'object') + public function containing($id, $type, $mode = 'object') { $cats = array(); @@ -1456,9 +1456,9 @@ class Categorie extends CommonObject * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. * @param boolean $exact Exact string search (true/false) * @param boolean $case Case sensitive (true/false) - * @return array|int Array of category id, -1 if error + * @return Categorie[]|int Array of Categorie, -1 if error */ - function rechercher($id, $nom, $type, $exact = false, $case = false) + public function rechercher($id, $nom, $type, $exact = false, $case = false) { // Deprecation warning if (is_numeric($type)) { @@ -1467,15 +1467,15 @@ class Categorie extends CommonObject $cats = array(); - // For backward compatibility - if (is_numeric($type)) { - // We want to reverse lookup - $map_type = array_flip($this->MAP_ID); - $type = $map_type[$type]; + // For backward compatibility + if (is_numeric($type)) { + // We want to reverse lookup + $map_type = array_flip($this->MAP_ID); + $type = $map_type[$type]; dol_syslog(get_class($this) . "::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); - } + } - // Generation requete recherche + // Generation requete recherche $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie"; $sql .= " WHERE type = " . $this->MAP_ID[$type]; $sql .= " AND entity IN (" . getEntity('category') . ")"; @@ -1521,7 +1521,7 @@ class Categorie extends CommonObject * @param int $maxlength Max length of text * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $maxlength = 0) + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0) { global $langs; @@ -1548,7 +1548,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Deplace fichier uploade sous le nom $files dans le repertoire sdir * @@ -1556,7 +1556,7 @@ class Categorie extends CommonObject * @param string $file Nom du fichier uploade * @return void */ - function add_photo($sdir, $file) + public function add_photo($sdir, $file) { // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1599,7 +1599,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return tableau de toutes les photos de la categorie * @@ -1607,7 +1607,7 @@ class Categorie extends CommonObject * @param int $nbmax Nombre maximum de photos (0=pas de max) * @return array Tableau de photos */ - function liste_photos($dir, $nbmax = 0) + public function liste_photos($dir, $nbmax = 0) { // phpcs:enable include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; @@ -1656,14 +1656,14 @@ class Categorie extends CommonObject return $tabobj; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Efface la photo de la categorie et sa vignette * * @param string $file Path to file * @return void */ - function delete_photo($file) + public function delete_photo($file) { // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1686,14 +1686,14 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load size of image file * * @param string $file Path to file * @return void */ - function get_image_size($file) + public function get_image_size($file) { // phpcs:enable $infoImg = getimagesize($file); // Recuperation des infos de l'image @@ -1708,7 +1708,7 @@ class Categorie extends CommonObject * * @return int <0 if KO, >0 if OK */ - function setMultiLangs($user) + public function setMultiLangs($user) { global $langs; @@ -1789,7 +1789,7 @@ class Categorie extends CommonObject * * @return int <0 if KO, >0 if OK */ - function getMultiLangs() + public function getMultiLangs() { global $langs; @@ -1828,7 +1828,7 @@ class Categorie 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 contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return ''; } @@ -1841,7 +1841,7 @@ class Categorie extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { dol_syslog(get_class($this)."::initAsSpecimen"); @@ -1855,20 +1855,20 @@ class Categorie extends CommonObject $this->type = self::TYPE_PRODUCT; } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'categorie_societe' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'categorie_societe' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); + } } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 596cc20c9e0..b542cf4dd67 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -895,7 +895,7 @@ if ($action == 'create') $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); - print '   '.$langs->trans("AddProject").''; + print '   '.$langs->trans("AddProject").' '; $urloption='?action=create'; $url = dol_buildpath('comm/action/card.php', 2).$urloption; @@ -1293,7 +1293,7 @@ if ($id > 0) $numprojet=$formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0); if ($numprojet==0) { - print '   '.$langs->trans("AddProject").''; + print '   '.$langs->trans("AddProject").' '; } print ''; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 4ac6579592e..fba891a848a 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -480,13 +480,13 @@ class ActionComm extends CommonObject } /** - * Load an object from its id and create a new one in database + * Load an object from its id and create a new one in database * - * @param user $fuser Object user making action - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param user $fuser Object user making action + * @param int $socid Id of thirdparty + * @return int New id of clone */ - function createFromClone($fuser, $socid) + public function createFromClone($fuser, $socid) { global $db, $user, $langs, $conf, $hookmanager; @@ -502,7 +502,7 @@ class ActionComm extends CommonObject // fetch optionals attributes and labels $this->fetch_optionals(); -// $this->fetch_userassigned(); + //$this->fetch_userassigned(); $this->fetchResources(); $this->id=0; @@ -559,14 +559,14 @@ class ActionComm extends CommonObject } /** - * Load object from database + * Load object from database * - * @param int $id Id of action to get - * @param string $ref Ref of action to get - * @param string $ref_ext Ref ext to get - * @return int <0 if KO, >0 if OK + * @param int $id Id of action to get + * @param string $ref Ref of action to get + * @param string $ref_ext Ref ext to get + * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '', $ref_ext = '') + public function fetch($id, $ref = '', $ref_ext = '') { global $langs; @@ -637,11 +637,11 @@ class ActionComm extends CommonObject $this->usermodid = $obj->fk_user_mod; if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning - $this->author->id = $obj->fk_user_author; // deprecated - $this->author->firstname = $obj->firstname; // deprecated - $this->author->lastname = $obj->lastname; // deprecated + $this->author->id = $obj->fk_user_author; // deprecated + $this->author->firstname = $obj->firstname; // deprecated + $this->author->lastname = $obj->lastname; // deprecated if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning - $this->usermod->id = $obj->fk_user_mod; // deprecated + $this->usermod->id = $obj->fk_user_mod; // deprecated $this->userownerid = $obj->fk_user_action; $this->userdoneid = $obj->fk_user_done; @@ -675,13 +675,13 @@ class ActionComm extends CommonObject return $num; } - /** + /** * Initialize $this->userassigned & this->socpeopleassigned array with list of id of user and contact assigned to event * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ - function fetchResources() - { + public function fetchResources() + { $sql ='SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; $sql.=' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; $sql.=' WHERE fk_actioncomm = '.$this->id; @@ -720,13 +720,13 @@ class ActionComm extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialize this->userassigned array with list of id of user assigned to event * * @return int <0 if KO, >0 if OK */ - function fetch_userassigned() + public function fetch_userassigned() { // phpcs:enable $sql ="SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; @@ -761,7 +761,7 @@ class ActionComm extends CommonObject * @param int $notrigger 1 = disable triggers, 0 = enable triggers * @return int <0 if KO, >0 if OK */ - function delete($notrigger = 0) + public function delete($notrigger = 0) { global $user,$langs,$conf; @@ -780,15 +780,15 @@ class ActionComm extends CommonObject } if (! $error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql.= " WHERE fk_actioncomm=".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql.= " WHERE fk_actioncomm=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $res=$this->db->query($sql); - if ($res < 0) { - $this->error=$this->db->lasterror(); - $error++; - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $res=$this->db->query($sql); + if ($res < 0) { + $this->error=$this->db->lasterror(); + $error++; + } } // Removed extrafields @@ -838,7 +838,7 @@ class ActionComm extends CommonObject * @param int $notrigger 1 = disable triggers, 0 = enable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs,$conf,$hookmanager; @@ -986,20 +986,20 @@ class ActionComm extends CommonObject } /** - * Load all objects with filters. - * WARNING: This make a fetch on all records instead of making one request with a join. + * Load all objects with filters. + * WARNING: This make a fetch on all records instead of making one request with a join. * - * @param DoliDb $db Database handler - * @param int $socid Filter by thirdparty - * @param int $fk_element Id of element action is linked to - * @param string $elementtype Type of element action is linked to - * @param string $filter Other filter - * @param string $sortfield Sort on this field - * @param string $sortorder ASC or DESC - * @param string $limit Limit number of answers - * @return array or string Error string if KO, array with actions if OK + * @param DoliDb $db Database handler + * @param int $socid Filter by thirdparty + * @param int $fk_element Id of element action is linked to + * @param string $elementtype Type of element action is linked to + * @param string $filter Other filter + * @param string $sortfield Sort on this field + * @param string $sortorder ASC or DESC + * @param string $limit Limit number of answers + * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) + public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) { global $conf, $langs; @@ -1043,7 +1043,7 @@ class ActionComm extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1051,7 +1051,7 @@ class ActionComm extends CommonObject * @param int $load_state_board Charge indicateurs this->nb de tableau de bord * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $load_state_board = 0) + public function load_board($user, $load_state_board = 0) { // phpcs:enable global $conf, $langs; @@ -1107,12 +1107,12 @@ class ActionComm extends CommonObject /** - * Charge les informations d'ordre info dans l'objet facture + * Charge les informations d'ordre info dans l'objet facture * - * @param int $id Id de la facture a charger - * @return void + * @param int $id Id de la facture a charger + * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT '; $sql.= ' a.id,'; @@ -1157,38 +1157,38 @@ class ActionComm extends CommonObject /** - * Return label of status + * Return label of status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @param int $hidenastatus 1=Show nothing if status is "Not applicable" - * @return string String with status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $hidenastatus 1=Show nothing if status is "Not applicable" + * @return string String with status */ - function getLibStatut($mode, $hidenastatus = 0) + public function getLibStatut($mode, $hidenastatus = 0) { return $this->LibStatut($this->percentage, $mode, $hidenastatus, $this->datep); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return label of action status + * Return label of action status * - * @param int $percent Percent - * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto - * @param int $hidenastatus 1=Show nothing if status is "Not applicable" - * @param int $datestart Date start of event - * @return string Label + * @param int $percent Percent + * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto + * @param int $hidenastatus 1=Show nothing if status is "Not applicable" + * @param int $datestart Date start of event + * @return string Label */ - function LibStatut($percent, $mode, $hidenastatus = 0, $datestart = '') + public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart = '') { // phpcs:enable global $langs; if ($mode == 0) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; - elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; - elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; + if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); + elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; + elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; + elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; } elseif ($mode == 1) { @@ -1244,28 +1244,28 @@ class ActionComm extends CommonObject } /** - * Return URL of event - * Use $this->id, $this->type_code, $this->label and $this->type_label + * Return URL of event + * Use $this->id, $this->type_code, $this->label and $this->type_label * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. - * @param string $classname Force style class on a link - * @param string $option ''=Link to action, 'birthday'=Link to contact - * @param int $overwritepicto 1=Overwrite picto - * @param int $notooltip 1=Disable tooltip - * @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 + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. + * @param string $classname Force style class on a link + * @param string $option ''=Link to action, 'birthday'=Link to contact + * @param int $overwritepicto 1=Overwrite picto + * @param int $notooltip 1=Disable tooltip + * @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, $maxlength = 0, $classname = '', $option = '', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlength = 0, $classname = '', $option = '', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1) { - global $conf, $langs, $user, $hookmanager, $action; + global $conf, $langs, $user, $hookmanager, $action; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id)) - $option = 'nolink'; + if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id)) + $option = 'nolink'; - $label = $this->label; + $label = $this->label; if (empty($label)) $label=$this->libelle; // For backward compatibility $result=''; @@ -1379,7 +1379,7 @@ class ActionComm extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Export events from database into a cal file. * @@ -1390,7 +1390,7 @@ class ActionComm extends CommonObject * @param array $filters Array of filters. Exemple array('notolderthan'=>99, 'year'=>..., 'idfrom'=>..., 'notactiontype'=>'systemauto', 'project'=>123, ...) * @return int <0 if error, nb of events in new file if ok */ - function build_exportfile($format, $type, $cachedelay, $filename, $filters) + public function build_exportfile($format, $type, $cachedelay, $filename, $filters) { // phpcs:enable global $conf,$langs,$dolibarr_main_url_root,$mysoc; @@ -1614,11 +1614,11 @@ class ActionComm extends CommonObject /** * Initialise an instance with random values. * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. + * id must be 0 if object instance is a specimen. * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user; @@ -1651,12 +1651,12 @@ class ActionComm extends CommonObject } /** - * Function used to replace a thirdparty id with another one. + * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) { @@ -1668,9 +1668,9 @@ class ActionComm extends CommonObject } /** - * Is the action delayed? + * Is the action delayed? * - * @return bool + * @return bool */ public function hasDelay() { @@ -1683,10 +1683,10 @@ class ActionComm extends CommonObject /** - * Send reminders by emails - * CAN BE A CRON TASK + * Send reminders by emails + * CAN BE A CRON TASK * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ public function sendEmailsReminder() { @@ -1715,14 +1715,14 @@ class ActionComm extends CommonObject $this->db->begin(); - // TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done + // TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done - // Delete also very old past events (we do not keep more than 1 month record in past) - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; - $this->db->query($sql); + // Delete also very old past events (we do not keep more than 1 month record in past) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; + $this->db->query($sql); - $this->db->commit(); + $this->db->commit(); - return $error; + return $error; } } diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index f157c90f95d..b01e0e6a544 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -178,20 +178,20 @@ class ActionCommReminder 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 * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 6b14bb6e884..b6df9ec7d96 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -44,7 +44,7 @@ class AgendaEvents extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -61,7 +61,7 @@ class AgendaEvents extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insuffisant rights to read an event"); @@ -76,11 +76,11 @@ class AgendaEvents extends DolibarrApi throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if ( ! DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->actioncomm->fetch_optionals(); + $result = $this->actioncomm->fetch_optionals(); $this->actioncomm->fetchObjectLinked(); return $this->_cleanObjectDatas($this->actioncomm); @@ -99,7 +99,7 @@ class AgendaEvents extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.datec:<:'20160101')" * @return array Array of Agenda Events objects */ - function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; @@ -120,13 +120,13 @@ class AgendaEvents extends DolibarrApi $sql = "SELECT t.id as rowid"; if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; // Insert sale filter @@ -141,7 +141,7 @@ class AgendaEvents extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -188,7 +188,7 @@ class AgendaEvents extends DolibarrApi * @param array $request_data Request data * @return int ID of Agenda Event */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); @@ -227,7 +227,7 @@ class AgendaEvents extends DolibarrApi * @return int */ /* - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); @@ -263,25 +263,25 @@ class AgendaEvents extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) { throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); } - $result = $this->actioncomm->fetch($id); + $result = $this->actioncomm->fetch($id); if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); - } + } - if( ! $result ) { + if( ! $result ) { throw new RestException(404, 'Agenda Event not found'); } - if( ! DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->actioncomm->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error); @@ -302,7 +302,7 @@ class AgendaEvents extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $event = array(); foreach (AgendaEvents::$FIELDS as $field) { @@ -319,51 +319,51 @@ class AgendaEvents extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->usermod); - unset($object->libelle); - unset($object->context); - unset($object->canvas); - unset($object->contact); - unset($object->contact_id); - unset($object->thirdparty); - unset($object->user); - unset($object->origin); - unset($object->origin_id); - unset($object->ref_ext); - unset($object->statut); - unset($object->country); - unset($object->country_id); - unset($object->country_code); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); - unset($object->mode_reglement_id); - unset($object->cond_reglement_id); - unset($object->cond_reglement); - unset($object->fk_delivery_address); - unset($object->shipping_method_id); - unset($object->fk_account); - unset($object->total_ht); - unset($object->total_tva); - unset($object->total_localtax1); - unset($object->total_localtax2); - unset($object->total_ttc); - unset($object->fk_incoterms); - unset($object->libelle_incoterms); - unset($object->location_incoterms); - unset($object->name); - unset($object->lastname); - unset($object->firstname); - unset($object->civility_id); - unset($object->contact); - unset($object->societe); + unset($object->usermod); + unset($object->libelle); + unset($object->context); + unset($object->canvas); + unset($object->contact); + unset($object->contact_id); + unset($object->thirdparty); + unset($object->user); + unset($object->origin); + unset($object->origin_id); + unset($object->ref_ext); + unset($object->statut); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->fk_account); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_incoterms); + unset($object->libelle_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->contact); + unset($object->societe); - return $object; + return $object; } } diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index f69030e806c..eb7fb885d8d 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -68,7 +68,7 @@ class CActionComm * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -76,10 +76,10 @@ class CActionComm /** * Load action type from database * - * @param int $id id or code of action type to read - * @return int 1=ok, 0=not found, -1=error + * @param int $id id or code of action type to read + * @return int 1=ok, 0=not found, -1=error */ - function fetch($id) + public function fetch($id) { $sql = "SELECT id, code, type, libelle as label, color, active, picto"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; @@ -118,19 +118,19 @@ class CActionComm } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of event types: array(id=>label) or array(code=>label) * - * @param string|int $active 1 or 0 to filter on event state active or not ('' by default = no filter) - * @param string $idorcode 'id' or 'code' - * @param string $excludetype Type to exclude ('system' or 'systemauto') - * @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" + * @param string|int $active 1 or 0 to filter on event state active or not ('' by default = no filter) + * @param string $idorcode 'id' or 'code' + * @param string $excludetype Type to exclude ('system' or 'systemauto') + * @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" * @param string $morefilter Add more SQL filter - * @param int $shortlabel 1=Get short label instead of long label - * @return mixed Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode. + * @param int $shortlabel 1=Get short label instead of long label + * @return mixed Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode. */ - function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0) + public function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0) { // phpcs:enable global $langs,$conf; @@ -176,7 +176,7 @@ class CActionComm if ($qualified) { - $keyfortrans=''; + $keyfortrans=''; $transcode=''; $code=$obj->code; if ($onlyautoornot > 0 && $code == 'AC_OTH') $code='AC_MANUAL'; @@ -223,7 +223,7 @@ class CActionComm * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only * @return string Label of action type */ - function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0) { global $langs; diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 00efd44a1a7..41fe3c42e90 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -32,12 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/xcal.lib.php'; */ class ICal { - var $file_text; // Text in file - var $cal; // Array to save iCalendar parse data - var $event_count; // Number of Events - var $todo_count; // Number of Todos - var $freebusy_count; // Number of Freebusy - var $last_key; //Help variable save last key (multiline string) + // Text in file + public $file_text; + public $cal; // Array to save iCalendar parse data + public $event_count; // Number of Events + public $todo_count; // Number of Todos + public $freebusy_count; // Number of Freebusy + public $last_key; //Help variable save last key (multiline string) /** @@ -47,14 +48,14 @@ class ICal { } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Read text file, icalender text file + * Read text file, icalender text file * - * @param string $file File - * @return string + * @param string $file File + * @return string */ - function read_file($file) + public function read_file($file) { // phpcs:enable $this->file = $file; @@ -63,31 +64,31 @@ class ICal $tmparray=file($file); if (is_array($tmparray)) { - $file_text = join("", $tmparray); //load file - $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); + $file_text = join("", $tmparray); //load file + $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); } return $file_text; // return all text } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the number of calendar events * * @return int */ - function get_event_count() + public function get_event_count() { // phpcs:enable return $this->event_count; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the number of to do * * @return int */ - function get_todo_count() + public function get_todo_count() { // phpcs:enable return $this->todo_count; @@ -99,7 +100,7 @@ class ICal * @param string $uri Url * @return array|string */ - function parse($uri) + public function parse($uri) { $this->cal = array(); // new empty array @@ -122,7 +123,7 @@ class ICal { // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin list($key, $value) = $this->retun_key_value($text); - //var_dump($text.' -> '.$key.' - '.$value); + //var_dump($text.' -> '.$key.' - '.$value); switch ($text) // search special string { @@ -201,7 +202,7 @@ class ICal return $this->cal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add to $this->ical array one value and key. * @@ -210,7 +211,7 @@ class ICal * @param string $value Value * @return void */ - function add_to_array($type, $key, $value) + public function add_to_array($type, $key, $value) { // phpcs:enable @@ -263,14 +264,14 @@ class ICal $this->last_key = $key; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); * * @param string $text Text * @return array */ - function retun_key_value($text) + public function retun_key_value($text) { // phpcs:enable /* @@ -288,14 +289,14 @@ class ICal return explode(':', $text, 2); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Parse RRULE return array * * @param string $value string * @return array */ - function ical_rrule($value) + public function ical_rrule($value) { // phpcs:enable $result = array(); @@ -308,14 +309,14 @@ class ICal return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS) * * @param string $ical_date String date * @return int */ - function ical_date_to_unix($ical_date) + public function ical_date_to_unix($ical_date) { // phpcs:enable $ical_date = str_replace('T', '', $ical_date); @@ -331,7 +332,7 @@ class ICal return $ntime; // ntime is a GTM time } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return unix date from iCal date format * @@ -339,7 +340,7 @@ class ICal * @param string $value Value * @return array */ - function ical_dt_date($key, $value) + public function ical_dt_date($key, $value) { // phpcs:enable $return_value = array(); @@ -362,13 +363,13 @@ class ICal return array($key,$return_value); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return sorted eventlist as array or false if calendar is empty * * @return array|false */ - function get_sort_event_list() + public function get_sort_event_list() { // phpcs:enable $temp = $this->get_event_list(); @@ -383,7 +384,7 @@ class ICal } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Compare two unix timestamp * @@ -391,67 +392,67 @@ class ICal * @param array $b Operand b * @return integer */ - function ical_dtstart_compare($a, $b) + public function ical_dtstart_compare($a, $b) { // phpcs:enable return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return eventlist array (not sorted eventlist array) * * @return array */ - function get_event_list() + public function get_event_list() { // phpcs:enable return (! empty($this->cal['VEVENT'])?$this->cal['VEVENT']:''); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return eventlist array (not sort eventlist array) * * @return array */ - function get_freebusy_list() + public function get_freebusy_list() { // phpcs:enable return $this->cal['VFREEBUSY']; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return to do array (not sorted todo array) * * @return array */ - function get_todo_list() + public function get_todo_list() { // phpcs:enable return $this->cal['VTODO']; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return base calendar data * * @return array */ - function get_calender_data() + public function get_calender_data() { // phpcs:enable return $this->cal['VCALENDAR']; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array with all data * * @return array */ - function get_all_data() + public function get_all_data() { // phpcs:enable return $this->cal; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 9e319d70f91..cfe6ff817f7 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -378,38 +378,43 @@ if ($object->id > 0) print ''; } - // Relative discounts (Discounts-Drawbacks-Rebates) - print ''; - print '
'; - print $langs->trans("CustomerRelativeDiscountShort"); - print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) - { - print ''.img_edit($langs->trans("Modify")).''; - } - print '
'; - print ''.($object->remise_percent?''.$object->remise_percent.'%':'').''; - print ''; + $isCustomer = ($object->client == 1 || $object->client == 3); - // Absolute discounts (Discounts-Drawbacks-Rebates) - print ''; - print ''; - print ''; + print ''; + + // Absolute discounts (Discounts-Drawbacks-Rebates) + print ''; + print ''; + print ''; } - print '
'; - print $langs->trans("CustomerAbsoluteDiscountShort"); - print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) + // Relative discounts (Discounts-Drawbacks-Rebates) + if ($isCustomer) { - print ''.img_edit($langs->trans("Modify")).''; + print '
'; + print '
'; + print $langs->trans("CustomerRelativeDiscountShort"); + print ''; + if ($user->rights->societe->creer && !$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'.($object->remise_percent?''.$object->remise_percent.'%':'').'
'; + print ''; + print '
'; + print $langs->trans("CustomerAbsoluteDiscountShort"); + print ''; + if ($user->rights->societe->creer && !$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'; + $amount_discount=$object->getAvailableDiscounts(); + if ($amount_discount < 0) dol_print_error($db, $object->error); + if ($amount_discount > 0) print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; + //else print $langs->trans("DiscountNone"); + print '
'; - print ''; - print ''; - $amount_discount=$object->getAvailableDiscounts(); - if ($amount_discount < 0) dol_print_error($db, $object->error); - if ($amount_discount > 0) print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; - //else print $langs->trans("DiscountNone"); - print ''; - print ''; // Max outstanding bill if ($object->client) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 567f968e3d2..b450f5a0872 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -58,20 +58,20 @@ class AdvanceTargetingMailing extends CommonObject */ public $id; - var $name; - var $entity; - var $fk_element; - var $type_element; - var $filtervalue; - var $fk_user_author; - var $datec=''; - var $fk_user_mod; - var $tms=''; + public $name; + public $entity; + public $fk_element; + public $type_element; + public $filtervalue; + public $fk_user_author; + public $datec=''; + public $fk_user_mod; + public $tms=''; - var $select_target_type = array(); - var $type_statuscommprospect=array(); - var $thirdparty_lines; - var $contact_lines; + public $select_target_type = array(); + public $type_statuscommprospect=array(); + public $thirdparty_lines; + public $contact_lines; /** @@ -79,7 +79,7 @@ class AdvanceTargetingMailing extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs; $langs->load('customers'); @@ -108,7 +108,7 @@ class AdvanceTargetingMailing 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; @@ -202,7 +202,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -253,14 +253,14 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch_by_mailing($id = 0) + public function fetch_by_mailing($id = 0) { // phpcs:enable global $langs; @@ -319,7 +319,7 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * @@ -327,7 +327,7 @@ class AdvanceTargetingMailing extends CommonObject * @param string $type_element Type target * @return int <0 if KO, >0 if OK */ - function fetch_by_element($id = 0, $type_element = 'mailing') + public function fetch_by_element($id = 0, $type_element = 'mailing') { // phpcs:enable global $langs; @@ -390,7 +390,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -469,7 +469,7 @@ class AdvanceTargetingMailing 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; @@ -528,7 +528,7 @@ class AdvanceTargetingMailing extends CommonObject * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - function savequery($user, $arrayquery) + public function savequery($user, $arrayquery) { global $langs,$conf; @@ -548,14 +548,14 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - function query_thirdparty($arrayquery) + public function query_thirdparty($arrayquery) { // phpcs:enable global $langs,$conf; @@ -699,7 +699,7 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * @@ -707,7 +707,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $withThirdpartyFilter add contact with tridparty filter * @return int <0 if KO, >0 if OK */ - function query_contact($arrayquery, $withThirdpartyFilter = 0) + public function query_contact($arrayquery, $withThirdpartyFilter = 0) { // phpcs:enable global $langs,$conf; diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 66303647dbc..9048d5a46e2 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -42,7 +42,7 @@ class FormAdvTargetEmailing extends Form * * @param DoliDB $db handler */ - function __construct($db) + public function __construct($db) { global $langs; @@ -56,7 +56,7 @@ class FormAdvTargetEmailing extends Form * @param string $htmlname select field * @return string select field */ - function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') + public function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') { global $conf, $langs; $options_array = array(); @@ -93,7 +93,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array or Code or Label of preselected country * @return string HTML string with select */ - function multiselectCountry($htmlname = 'country_id', $selected_array = array()) + public function multiselectCountry($htmlname = 'country_id', $selected_array = array()) { global $conf, $langs; @@ -154,7 +154,7 @@ class FormAdvTargetEmailing extends Form * @param User $user User action * @return string combo list code */ - function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) + public function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) { global $conf; @@ -195,7 +195,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array selected array * @return string combo list code */ - function multiselectselectLanguage($htmlname = '', $selected_array = array()) + public function multiselectselectLanguage($htmlname = '', $selected_array = array()) { global $conf,$langs; @@ -222,7 +222,7 @@ class FormAdvTargetEmailing extends Form * * @return string HTML combo */ - function advMultiselectarraySelllist($htmlname, $sqlqueryparam = array(), $selected_array = array()) + public function advMultiselectarraySelllist($htmlname, $sqlqueryparam = array(), $selected_array = array()) { $options_array=array(); @@ -291,7 +291,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array Array * @return string HTML combo */ - function multiselectCivility($htmlname = 'civilite_id', $selected_array = array()) + public function multiselectCivility($htmlname = 'civilite_id', $selected_array = array()) { global $conf,$langs,$user; $langs->load("dict"); @@ -341,7 +341,7 @@ class FormAdvTargetEmailing extends Form * @param int $showempty show empty * @return string HTML combo */ - function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) + public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) { global $conf, $langs; @@ -357,7 +357,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array value selected * @return string HTML combo */ - function multiselectCustomerCategories($htmlname = 'cust_cat', $selected_array = array()) + public function multiselectCustomerCategories($htmlname = 'cust_cat', $selected_array = array()) { return $this->multiselectCategories($htmlname, $selected_array, 2); } @@ -369,7 +369,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array value selected * @return string HTML combo */ - function multiselectContactCategories($htmlname = 'contact_cat', $selected_array = array()) + public function multiselectContactCategories($htmlname = 'contact_cat', $selected_array = array()) { return $this->multiselectCategories($htmlname, $selected_array, 4); } diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 580a36425c8..c94c516d27d 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -80,9 +80,9 @@ class Mailing extends CommonObject * Constructor * * @param DoliDb $db Database handler - */ - function __construct($db) - { + */ + public function __construct($db) + { $this->db = $db; // List of language codes for status @@ -96,7 +96,7 @@ class Mailing extends CommonObject $this->statut_dest[1] = 'MailingStatusSent'; $this->statut_dest[2] = 'MailingStatusRead'; $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore - } + } /** * Create an EMailing @@ -104,7 +104,7 @@ class Mailing extends CommonObject * @param User $user Object of user making creation * @return int -1 if error, Id of created object if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -163,7 +163,7 @@ class Mailing extends CommonObject * @param User $user Object of user making change * @return int < 0 if KO, > 0 if OK */ - function update($user) + public function update($user) { $sql = "UPDATE ".MAIN_DB_PREFIX."mailing "; $sql .= " SET titre = '".$this->db->escape($this->titre)."'"; @@ -195,7 +195,7 @@ class Mailing extends CommonObject * @param int $rowid Id of emailing * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { global $conf; @@ -218,34 +218,34 @@ class Mailing extends CommonObject { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->statut = $obj->statut; - $this->nbemail = $obj->nbemail; - $this->titre = $obj->titre; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->statut = $obj->statut; + $this->nbemail = $obj->nbemail; + $this->titre = $obj->titre; - $this->sujet = $obj->sujet; + $this->sujet = $obj->sujet; if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401))) { - $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401); + $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401); }else { - $this->body = $obj->body; + $this->body = $obj->body; } - $this->bgcolor = $obj->bgcolor; - $this->bgimage = $obj->bgimage; + $this->bgcolor = $obj->bgcolor; + $this->bgimage = $obj->bgimage; - $this->email_from = $obj->email_from; - $this->email_replyto = $obj->email_replyto; - $this->email_errorsto = $obj->email_errorsto; + $this->email_from = $obj->email_from; + $this->email_replyto = $obj->email_replyto; + $this->email_errorsto = $obj->email_errorsto; - $this->user_creat = $obj->fk_user_creat; - $this->user_valid = $obj->fk_user_valid; + $this->user_creat = $obj->fk_user_creat; + $this->user_valid = $obj->fk_user_valid; - $this->date_creat = $this->db->jdate($obj->date_creat); - $this->date_valid = $this->db->jdate($obj->date_valid); - $this->date_envoi = $this->db->jdate($obj->date_envoi); + $this->date_creat = $this->db->jdate($obj->date_creat); + $this->date_valid = $this->db->jdate($obj->date_valid); + $this->date_envoi = $this->db->jdate($obj->date_envoi); - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); return 1; } @@ -271,7 +271,7 @@ class Mailing extends CommonObject * @param int $option2 Not used * @return int New id of clone */ - function createFromClone($fromid, $option1, $option2) + public function createFromClone($fromid, $option1, $option2) { global $user,$langs; @@ -394,7 +394,7 @@ class Mailing extends CommonObject * @param User $user Objet user qui valide * @return int <0 if KO, >0 if OK */ - function valid($user) + public function valid($user) { $now=dol_now(); @@ -421,7 +421,7 @@ class Mailing extends CommonObject * @param int $rowid id du mailing a supprimer * @return int 1 en cas de succes */ - function delete($rowid) + public function delete($rowid) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing"; $sql.= " WHERE rowid = ".$rowid; @@ -439,13 +439,13 @@ class Mailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete targets emailing * * @return int 1 if OK, 0 if error */ - function delete_targets() + public function delete_targets() { // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; @@ -465,14 +465,14 @@ class Mailing extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Change status of each recipient * * @param User $user Objet user qui valide * @return int <0 if KO, >0 if OK */ - function reset_targets_status($user) + public function reset_targets_status($user) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; @@ -499,7 +499,7 @@ class Mailing extends CommonObject * @param string $mode Mode ('alreadysent' = Sent success or error, 'alreadysentok' = Sent success, 'alreadysentko' = Sent error) * @return int Nb of target with status */ - function countNbOfTargets($mode) + public function countNbOfTargets($mode) { $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql.= " WHERE fk_mailing = ".$this->id; @@ -537,7 +537,7 @@ class Mailing 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, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -608,12 +608,12 @@ class Mailing extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -621,7 +621,7 @@ class Mailing 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, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -634,30 +634,30 @@ class Mailing extends CommonObject elseif ($mode == 2) { if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); } elseif ($mode == 3) { if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - if ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + elseif ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); + elseif ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); + elseif ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); } elseif ($mode == 4) { if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); } elseif ($mode == 5) { if ($statut == 0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - if ($statut == 1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - if ($statut == 2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - if ($statut == 3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + elseif ($statut == 1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); + elseif ($statut == 2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); + elseif ($statut == 3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); } } @@ -687,37 +687,37 @@ class Mailing extends CommonObject elseif ($mode == 2) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } elseif ($mode == 3) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } elseif ($mode == 4) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } elseif ($mode == 5) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } elseif ($mode == 6) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } } } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index ac64f65381c..46bc16dfa8c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1590,7 +1590,7 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").' '; print ''; } print '' . "\n"; @@ -1677,7 +1677,7 @@ if ($action == 'create') print ''; print '' . $langs->trans("Project") . ''; $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">' . $langs->trans("AddProject") . ' '; print ''; print ''; } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index c72c54294ae..33122986187 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -29,8 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; */ class Proposals extends DolibarrApi { - - /** + /** * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( @@ -45,7 +44,7 @@ class Proposals extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -63,7 +62,7 @@ class Proposals extends DolibarrApi * * @throws RestException */ - function get($id, $contact_list = 1) + public function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); @@ -97,7 +96,7 @@ class Proposals extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" * @return array Array of order objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -182,8 +181,8 @@ class Proposals extends DolibarrApi * @param array $request_data Request data * @return int ID of proposal */ - function post($request_data = null) - { + public function post($request_data = null) + { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401, "Insuffisant rights"); } @@ -205,7 +204,7 @@ class Proposals extends DolibarrApi } return $this->propal->id; - } + } /** * Get lines of a commercial proposal @@ -216,7 +215,7 @@ class Proposals extends DolibarrApi * * @return int */ - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); @@ -248,9 +247,9 @@ class Proposals extends DolibarrApi * * @return int */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } @@ -259,12 +258,11 @@ class Proposals extends DolibarrApi throw new RestException(404, 'Commercial Proposal not found'); } - if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) - { + if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + $request_data = (object) $request_data; $updateRes = $this->propal->addline( $request_data->desc, @@ -313,7 +311,7 @@ class Proposals extends DolibarrApi * * @return object */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -336,30 +334,30 @@ class Proposals extends DolibarrApi throw new RestException(404, 'Proposal line not found'); } - $updateRes = $this->propal->updateline( - $lineid, - isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, - isset($request_data->qty)?$request_data->qty:$propalline->qty, - isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, - isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, - isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, - isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, - isset($request_data->desc)?$request_data->desc:$propalline->desc, - 'HT', - isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, - isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, - isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, - 0, - isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, - isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, - isset($request_data->label)?$request_data->label:$propalline->label, - isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, - isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, - isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, - isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, - isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, - isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice - ); + $updateRes = $this->propal->updateline( + $lineid, + isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, + isset($request_data->qty)?$request_data->qty:$propalline->qty, + isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, + isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, + isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, + isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, + isset($request_data->desc)?$request_data->desc:$propalline->desc, + 'HT', + isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, + isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, + isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, + 0, + isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, + isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, + isset($request_data->label)?$request_data->label:$propalline->label, + isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, + isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, + isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, + isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, + isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, + isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice + ); if ($updateRes > 0) { $result = $this->get($id); @@ -382,7 +380,7 @@ class Proposals extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -422,7 +420,7 @@ class Proposals extends DolibarrApi * @throws 401 * @throws 404 */ - function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type) { if(!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -464,7 +462,7 @@ class Proposals extends DolibarrApi * @throws 404 * @throws 500 */ - function deleteContact($id, $rowid) + public function deleteContact($id, $rowid) { if(!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -497,21 +495,21 @@ class Proposals extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->propal->$field = $value; } @@ -546,7 +544,7 @@ class Proposals extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->propal->supprimer) { throw new RestException(401); @@ -581,7 +579,7 @@ class Proposals extends DolibarrApi * * @return array */ - function settodraft($id) + public function settodraft($id) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -637,9 +635,9 @@ class Proposals extends DolibarrApi * @throws 500 * * @return array - */ - function validate($id, $notrigger = 0) - { + */ + public function validate($id, $notrigger = 0) + { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } @@ -672,7 +670,7 @@ class Proposals extends DolibarrApi $this->propal->fetchObjectLinked(); return $this->_cleanObjectDatas($this->propal); - } + } /** * Close (Accept or refuse) a quote / commercial proposal @@ -686,7 +684,7 @@ class Proposals extends DolibarrApi * * @return array */ - function close($id, $status, $note_private = '', $notrigger = 0) + public function close($id, $status, $note_private = '', $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -731,7 +729,7 @@ class Proposals extends DolibarrApi * * @return array */ - function setinvoiced($id) + public function setinvoiced($id) { if (! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -772,7 +770,7 @@ class Proposals extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $propal = array(); foreach (Proposals::$FIELDS as $field) { @@ -790,7 +788,7 @@ class Proposals extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f660fd3c533..304eccf9bb7 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -239,7 +239,7 @@ class Propal extends CommonObject * @param int $socid Id third party * @param int $propalid Id proposal */ - function __construct($db, $socid = "", $propalid = 0) + public function __construct($db, $socid = "", $propalid = 0) { global $conf,$langs; @@ -254,7 +254,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add line into array products * $this->thirdparty should be loaded @@ -267,7 +267,7 @@ class Propal extends CommonObject * TODO Replace calls to this function by generation objet Ligne * inserted into table $this->products */ - function add_product($idproduct, $qty, $remise_percent = 0) + public function add_product($idproduct, $qty, $remise_percent = 0) { // phpcs:enable global $conf, $mysoc; @@ -316,14 +316,14 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adding line of fixed discount in the proposal in DB * * @param int $idremise Id of fixed discount * @return int >0 if OK, <0 if KO */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -434,7 +434,7 @@ class Propal extends CommonObject * @return int >0 if OK, <0 if KO * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $fk_remise_except = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $fk_remise_except = 0) { global $mysoc, $conf, $langs; @@ -663,11 +663,11 @@ class Propal extends CommonObject * @param int $notrigger disable line update trigger * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { global $mysoc; -dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, + dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, type=$type, date_start=$date_start, date_end=$date_end"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -827,7 +827,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - function deleteline($lineid) + public function deleteline($lineid) { global $user; @@ -869,7 +869,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$hookmanager; $error=0; @@ -1193,7 +1193,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert into DB a proposal object completely defined by its data members (ex, results from copy). * @@ -1201,7 +1201,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @return int Id of the new object if ok, <0 if ko * @see create */ - function create_from($user) + public function create_from($user) { // phpcs:enable // i love this function because $this->products is not used in create function... @@ -1216,7 +1216,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$conf,$hookmanager; @@ -1345,7 +1345,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param string $ref Ref of proposal * @return int >0 if OK, <0 if KO */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; @@ -1357,7 +1357,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise $sql.= ", p.date_livraison as date_livraison"; $sql.= ", p.model_pdf, p.last_main_doc, p.ref_client, p.extraparams"; $sql.= ", p.note_private, p.note_public"; - $sql.= ", p.fk_projet, p.fk_statut"; + $sql.= ", p.fk_projet as fk_project, p.fk_statut"; $sql.= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture"; $sql.= ", p.fk_delivery_address"; $sql.= ", p.fk_availability"; @@ -1412,7 +1412,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total; $this->socid = $obj->fk_soc; - $this->fk_project = $obj->fk_projet; + $this->fk_project = $obj->fk_project; $this->modelpdf = $obj->model_pdf; $this->last_main_doc = $obj->last_main_doc; $this->note = $obj->note_private; // TODO deprecated @@ -1509,7 +1509,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @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; @@ -1597,14 +1597,14 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ - function fetch_lines($only_product = 0) + public function fetch_lines($only_product = 0) { // phpcs:enable $this->lines=array(); @@ -1723,7 +1723,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, 0=Nothing done, >=0 if OK */ - function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1838,7 +1838,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define proposal date * @@ -1847,7 +1847,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_date($user, $date, $notrigger = 0) + public function set_date($user, $date, $notrigger = 0) { // phpcs:enable if (empty($date)) @@ -1907,7 +1907,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define end validity date * @@ -1916,7 +1916,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_echeance($user, $date_fin_validite, $notrigger = 0) + public function set_echeance($user, $date_fin_validite, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer)) @@ -1969,7 +1969,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set delivery date * @@ -1978,7 +1978,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_date_livraison($user, $date_livraison, $notrigger = 0) + public function set_date_livraison($user, $date_livraison, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer)) @@ -2031,7 +2031,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set delivery * @@ -2040,7 +2040,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_availability($user, $id, $notrigger = 0) + public function set_availability($user, $id, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) @@ -2102,7 +2102,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set source of demand * @@ -2111,7 +2111,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_demand_reason($user, $id, $notrigger = 0) + public function set_demand_reason($user, $id, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) @@ -2175,7 +2175,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set customer reference number * @@ -2184,7 +2184,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_ref_client($user, $ref_client, $notrigger = 0) + public function set_ref_client($user, $ref_client, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer)) @@ -2240,7 +2240,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an overall discount on the proposal * @@ -2249,7 +2249,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_remise_percent($user, $remise, $notrigger = 0) + public function set_remise_percent($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2307,7 +2307,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an absolute overall discount on the proposal * @@ -2316,7 +2316,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2385,7 +2385,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function reopen($user, $statut, $note = '', $notrigger = 0) + public function reopen($user, $statut, $note = '', $notrigger = 0) { $this->statut = $statut; @@ -2446,7 +2446,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function cloture($user, $statut, $note = "", $notrigger = 0) + public function cloture($user, $statut, $note = "", $notrigger = 0) { global $langs,$conf; @@ -2549,7 +2549,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - function classifyBilled(User $user, $notrigger = 0) + public function classifyBilled(User $user, $notrigger = 0) { $error=0; @@ -2597,7 +2597,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -2605,7 +2605,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_draft($user, $notrigger = 0) + public function set_draft($user, $notrigger = 0) { // phpcs:enable $error=0; @@ -2656,7 +2656,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of proposal (eventually filtered on user) into an array * @@ -2670,7 +2670,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') { // phpcs:enable global $user; @@ -2739,19 +2739,19 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * * @return array Array of invoices */ - function getInvoiceArrayList() + public function getInvoiceArrayList() { return $this->InvoiceArrayList($this->id); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array with id and ref of related invoices * * @param int $id Id propal * @return array Array of invoices id */ - function InvoiceArrayList($id) + public function InvoiceArrayList($id) { // phpcs:enable $ga = array(); @@ -2838,7 +2838,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int 1 if ok, otherwise if error */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2962,7 +2962,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @return int >0 if OK, <0 if KO * @deprecated use set_availability */ - function availability($availability_id, $notrigger = 0) + public function availability($availability_id, $notrigger = 0) { global $user; @@ -3024,7 +3024,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Change source demand * @@ -3033,7 +3033,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @return int >0 si ok, <0 si ko * @deprecated use set_demand_reason */ - function demand_reason($demand_reason_id, $notrigger = 0) + public function demand_reason($demand_reason_id, $notrigger = 0) { // phpcs:enable global $user; @@ -3103,7 +3103,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $id Proposal id * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, "; $sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; @@ -3158,12 +3158,12 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @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 */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status (draft, validated, ...) * @@ -3171,7 +3171,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @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 */ - function LibStatut($statut, $mode = 1) + public function LibStatut($statut, $mode = 1) { // phpcs:enable global $conf; @@ -3210,7 +3210,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -3218,7 +3218,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $mode "opened" for proposal to close, "signed" for proposal to invoice * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $mode) + public function load_board($user, $mode) { // phpcs:enable global $conf, $langs; @@ -3300,7 +3300,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $langs; @@ -3386,13 +3386,13 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // 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 $user; @@ -3438,7 +3438,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param Societe $soc Object thirdparty * @return string Reference libre pour la propale */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf,$langs; $langs->load("propal"); @@ -3500,7 +3500,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @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 = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user; @@ -3574,7 +3574,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -3754,7 +3754,7 @@ class PropaleLigne extends CommonObjectLine * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db= $db; } @@ -3765,7 +3765,7 @@ class PropaleLigne extends CommonObjectLine * @param int $rowid Propal line id * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; @@ -3859,7 +3859,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0) + public function insert($notrigger = 0) { global $conf,$user; @@ -4002,7 +4002,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function delete(User $user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf; @@ -4056,7 +4056,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function update($notrigger = 0) + public function update($notrigger = 0) { global $conf,$user; @@ -4178,14 +4178,14 @@ class PropaleLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 6fd9d36f54b..808411100f9 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -40,12 +40,12 @@ class PropaleStats 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; /** @@ -56,7 +56,7 @@ class PropaleStats extends Stats * @param int $userid Id user for filter (creation user) * @param string $mode Option ('customer', 'supplier') */ - function __construct($db, $socid = 0, $userid = 0, $mode = 'customer') + public function __construct($db, $socid = 0, $userid = 0, $mode = 'customer') { global $user, $conf; @@ -106,7 +106,7 @@ class PropaleStats 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 with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -128,7 +128,7 @@ class PropaleStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -149,7 +149,7 @@ class PropaleStats 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 with amount by month */ - function getAmountByMonth($year, $format) + public function getAmountByMonth($year, $format) { global $user; @@ -171,7 +171,7 @@ class PropaleStats extends Stats * @param int $year year for stats * @return array array with number by month */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -191,7 +191,7 @@ class PropaleStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; @@ -213,7 +213,7 @@ class PropaleStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAllByProduct($year) + public function getAllByProduct($year) { global $user; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 67c347a97d5..0b3179bd239 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -564,7 +564,7 @@ if ($resql) if (! empty($arrayfields['country.code_iso']['checked'])) { print ''; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; } // Company type diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index ddb3901051e..a2d373f339a 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -106,7 +106,7 @@ if ($socid > 0) $head = societe_prepare_head($object); - $isCustomer = $object->client == 1 || $object->client == 3; + $isCustomer = ($object->client == 1 || $object->client == 3); $isSupplier = $object->fournisseur == 1; print '
'; @@ -122,7 +122,7 @@ if ($socid > 0) print '
'; - if(! $isCustomer && ! $isSupplier) { + if (! $isCustomer && ! $isSupplier) { print '

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

'; dol_fiche_end(); @@ -137,13 +137,13 @@ if ($socid > 0) print ''; - if($isCustomer) { + if ($isCustomer) { // Customer discount print '"; } - if($isSupplier) { + if ($isSupplier) { // Supplier discount print '"; @@ -156,21 +156,28 @@ if ($socid > 0) print '
'; - if($isCustomer && ! $isSupplier) { - print ''; - } - - if(! $isCustomer && $isSupplier) { - print ''; - } + /*if (! ($isCustomer && $isSupplier)) + { + if ($isCustomer && ! $isSupplier) { + print ''; + } + if (! $isCustomer && $isSupplier) { + print ''; + } + }*/ print '
'; print $langs->trans("CustomerRelativeDiscount").''.price2num($object->remise_percent)."%
'; print $langs->trans("SupplierRelativeDiscount").''.price2num($object->remise_supplier_percent)."%
'; - if($isCustomer && $isSupplier) { + if ($isCustomer || $isSupplier) + { // Discount type - print ''; - print ''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 45c10a3aedd..6afee20b371 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1636,7 +1636,7 @@ if ($action == 'create' && $user->rights->commande->creer) }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").' '; print ''; } print '' . "\n"; @@ -1727,7 +1727,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; print ''; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 95fe3f55d0d..2bd942a3c34 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -44,10 +44,10 @@ class Orders extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->commande = new Commande($this->db); } @@ -62,7 +62,7 @@ class Orders extends DolibarrApi * * @throws RestException */ - function get($id, $contact_list = 1) + public function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); @@ -100,7 +100,7 @@ class Orders extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -185,11 +185,11 @@ class Orders extends DolibarrApi * @param array $request_data Request data * @return int ID of order */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401, "Insuffisant rights"); - } + } // Check mandatory fields $result = $this->_validate($request_data); @@ -220,7 +220,7 @@ class Orders extends DolibarrApi * * @return int */ - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); @@ -252,7 +252,7 @@ class Orders extends DolibarrApi * * @return int */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -299,7 +299,7 @@ class Orders extends DolibarrApi if ($updateRes > 0) { return $updateRes; } else { - throw new RestException(400, $this->commande->error); + throw new RestException(400, $this->commande->error); } } @@ -314,7 +314,7 @@ class Orders extends DolibarrApi * * @return object */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -375,7 +375,7 @@ class Orders extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -399,7 +399,7 @@ class Orders extends DolibarrApi throw new RestException(405, $this->commande->error); } } - + /** * Add a contact type of given order * @@ -413,7 +413,7 @@ class Orders extends DolibarrApi * @throws 401 * @throws 404 */ - function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type) { if(!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -455,7 +455,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 500 */ - function deleteContact($id, $rowid) + public function deleteContact($id, $rowid) { if(!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -488,7 +488,7 @@ class Orders extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -529,7 +529,7 @@ class Orders extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->commande->supprimer) { throw new RestException(401); @@ -577,7 +577,7 @@ class Orders extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -629,7 +629,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 405 */ - function reopen($id) + public function reopen($id) { if(! DolibarrApiAccess::$user->rights->commande->creer) { @@ -667,7 +667,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 405 */ - function setinvoiced($id) + public function setinvoiced($id) { if(! DolibarrApiAccess::$user->rights->commande->creer) { @@ -710,7 +710,7 @@ class Orders extends DolibarrApi * * @return int */ - function close($id, $notrigger = 0) + public function close($id, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -756,7 +756,7 @@ class Orders extends DolibarrApi * * @return array */ - function settodraft($id, $idwarehouse = -1) + public function settodraft($id, $idwarehouse = -1) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -807,7 +807,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 405 */ - function createOrderFromProposal($proposalid) + public function createOrderFromProposal($proposalid) { require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; @@ -844,7 +844,7 @@ class Orders extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -866,7 +866,7 @@ class Orders extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $commande = array(); foreach (Orders::$FIELDS as $field) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 26151fd8b72..9b55957b0f0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -203,12 +203,12 @@ class Commande extends CommonOrder public $multicurrency_total_ttc; public $oldcopy; - + //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) public $module_source; //! key of pos source ('0', '1', ...) public $pos_source; - + /** * ERR Not enough stock */ @@ -243,7 +243,7 @@ class Commande extends CommonOrder * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -260,7 +260,7 @@ class Commande extends CommonOrder * @param Societe $soc Object thirdparty * @return string Order free reference */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $langs, $conf; $langs->load("order"); @@ -318,7 +318,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if OK, 0=Nothing done, >0 if KO */ - function valid($user, $idwarehouse = 0, $notrigger = 0) + public function valid($user, $idwarehouse = 0, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -471,7 +471,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -479,8 +479,8 @@ class Commande extends CommonOrder * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) * @return int <0 if KO, >0 if OK */ - function set_draft($user, $idwarehouse = -1) - { + public function set_draft($user, $idwarehouse = -1) + { //phpcs:enable global $conf,$langs; @@ -551,10 +551,10 @@ class Commande extends CommonOrder $this->db->rollback(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag the order as validated (opened) * Function used when order is reopend after being closed. @@ -562,7 +562,7 @@ class Commande extends CommonOrder * @param User $user Object user that change status * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - function set_reopen($user) + public function set_reopen($user) { // phpcs:enable $error=0; @@ -622,7 +622,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function cloture($user, $notrigger = 0) + public function cloture($user, $notrigger = 0) { global $conf; @@ -682,7 +682,7 @@ class Commande extends CommonOrder * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function cancel($idwarehouse = -1) + public function cancel($idwarehouse = -1) { global $conf,$user,$langs; @@ -763,7 +763,7 @@ class Commande extends CommonOrder * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$langs; $error=0; @@ -892,7 +892,7 @@ class Commande extends CommonOrder $vatrate = $line->tva_tx; if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; - $result = $this->addline( + $result = $this->addline( $line->desc, $line->subprice, $line->qty, @@ -1067,7 +1067,7 @@ class Commande extends CommonOrder * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$hookmanager; @@ -1152,7 +1152,7 @@ class Commande extends CommonOrder * @param User $user User making creation * @return int <0 if KO, 0 if nothing done, 1 if OK */ - function createFromProposal($object, User $user) + public function createFromProposal($object, User $user) { global $conf, $hookmanager; @@ -1309,7 +1309,7 @@ class Commande extends CommonOrder * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0) { global $mysoc, $conf, $langs, $user; @@ -1523,22 +1523,22 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add line into array * $this->client must be loaded * - * @param int $idproduct Product Id - * @param float $qty Quantity - * @param float $remise_percent Product discount relative - * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - * @return void + * @param int $idproduct Product Id + * @param float $qty Quantity + * @param float $remise_percent Product discount relative + * @param int $date_start Start date of the line + * @param int $date_end End date of the line + * @return void * * TODO Remplacer les appels a cette fonction par generation objet Ligne * insere dans tableau $this->products */ - function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') + public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') { // phpcs:enable global $conf, $mysoc; @@ -1583,7 +1583,6 @@ class Commande extends CommonOrder $line->product_desc=$prod->description; $line->fk_unit=$prod->fk_unit; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Save the start and end date of the line in the object if ($date_start) { $line->date_start = $date_start; } if ($date_end) { $line->date_end = $date_end; } @@ -1623,7 +1622,7 @@ class Commande extends CommonOrder * @param string $ref_int Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ - function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') { // Check parameters @@ -1719,7 +1718,7 @@ class Commande extends CommonOrder $this->fk_delivery_address = $obj->fk_delivery_address; $this->module_source = $obj->module_source; $this->pos_source = $obj->pos_source; - + //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; @@ -1769,14 +1768,14 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adding line of fixed discount in the order in DB * * @param int $idremise Id de la remise fixe * @return int >0 si ok, <0 si ko */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -1848,14 +1847,14 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ - function fetch_lines($only_product = 0) + public function fetch_lines($only_product = 0) { // phpcs:enable $this->lines=array(); @@ -1971,7 +1970,7 @@ class Commande extends CommonOrder * * @return int <0 if KO, Nbr of product lines if OK */ - function getNbOfProductsLines() + public function getNbOfProductsLines() { $nb=0; foreach($this->lines as $line) @@ -1986,7 +1985,7 @@ class Commande extends CommonOrder * * @return int <0 if KO, Nbr of service lines if OK */ - function getNbOfServicesLines() + public function getNbOfServicesLines() { $nb=0; foreach($this->lines as $line) @@ -1997,11 +1996,11 @@ class Commande extends CommonOrder } /** - * Count numbe rof shipments for this order + * Count number of shipments for this order * * @return int <0 if KO, Nb of shipment found if OK */ - function getNbOfShipments() + public function getNbOfShipments() { $nb = 0; @@ -2037,7 +2036,7 @@ class Commande extends CommonOrder * @param int $filtre_statut Filter on shipment status * @return int <0 if KO, Nb of lines found if OK */ - function loadExpeditions($filtre_statut = -1) + public function loadExpeditions($filtre_statut = -1) { $this->expeditions = array(); @@ -2077,7 +2076,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns a array with expeditions lines number * @@ -2085,7 +2084,7 @@ class Commande extends CommonOrder * * TODO deprecate, move to Shipping class */ - function nb_expedition() + public function nb_expedition() { // phpcs:enable $sql = 'SELECT count(*)'; @@ -2104,7 +2103,7 @@ class Commande extends CommonOrder else dol_print_error($this->db); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a array with the pending stock by product * @@ -2113,7 +2112,7 @@ class Commande extends CommonOrder * * TODO FONCTION NON FINIE A FINIR */ - function stock_array($filtre_statut = self::STATUS_CANCELED) + public function stock_array($filtre_statut = self::STATUS_CANCELED) { // phpcs:enable $this->stocks = array(); @@ -2153,7 +2152,7 @@ class Commande extends CommonOrder * @param int $lineid Id of line to delete * @return int >0 if OK, 0 if nothing to do, <0 if KO */ - function deleteline($user = null, $lineid = 0) + public function deleteline($user = null, $lineid = 0) { if ($this->statut == self::STATUS_DRAFT) { @@ -2222,7 +2221,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Applique une remise relative * @@ -2231,7 +2230,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_remise($user, $remise, $notrigger = 0) + public function set_remise($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2290,7 +2289,7 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Applique une remise absolue * @@ -2299,7 +2298,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2358,7 +2357,7 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the order date * @@ -2367,7 +2366,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_date($user, $date, $notrigger = 0) + public function set_date($user, $date, $notrigger = 0) { // phpcs:enable if ($user->rights->commande->creer) @@ -2424,7 +2423,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the planned delivery date * @@ -2433,7 +2432,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - function set_date_livraison($user, $date_livraison, $notrigger = 0) + public function set_date_livraison($user, $date_livraison, $notrigger = 0) { // phpcs:enable if ($user->rights->commande->creer) @@ -2490,7 +2489,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of orders (eventuelly filtered on a user) into an array * @@ -2504,7 +2503,7 @@ class Commande extends CommonOrder * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') { // phpcs:enable global $user; @@ -2572,7 +2571,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int >0 if OK, <0 if KO */ - function availability($availability_id, $notrigger = 0) + public function availability($availability_id, $notrigger = 0) { global $user; @@ -2635,7 +2634,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update order demand_reason * @@ -2643,7 +2642,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int >0 if ok, <0 if ko */ - function demand_reason($demand_reason_id, $notrigger = 0) + public function demand_reason($demand_reason_id, $notrigger = 0) { // phpcs:enable global $user; @@ -2707,7 +2706,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set customer ref * @@ -2716,7 +2715,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_ref_client($user, $ref_client, $notrigger = 0) + public function set_ref_client($user, $ref_client, $notrigger = 0) { // phpcs:enable if ($user->rights->commande->creer) @@ -2779,7 +2778,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function classifyBilled(User $user, $notrigger = 0) + public function classifyBilled(User $user, $notrigger = 0) { $error = 0; @@ -2835,7 +2834,7 @@ class Commande extends CommonOrder * * @return int <0 if ko, >0 if ok */ - function classifyUnBilled() + public function classifyUnBilled() { global $conf, $user, $langs; $error = 0; @@ -2914,7 +2913,7 @@ class Commande extends CommonOrder * @param int $notrigger disable line update trigger * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { global $conf, $mysoc, $langs, $user; @@ -3104,7 +3103,7 @@ class Commande extends CommonOrder * @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; @@ -3199,7 +3198,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -3321,14 +3320,14 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -3387,7 +3386,7 @@ class Commande extends CommonOrder * * @return string Label */ - function getLabelSource() + public function getLabelSource() { global $langs; @@ -3403,12 +3402,12 @@ class Commande extends CommonOrder * @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 */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $this->billed, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of status * @@ -3418,7 +3417,7 @@ class Commande extends CommonOrder * @param int $donotshowbilled Do not show billed status after order status * @return string Label of status */ - function LibStatut($statut, $billed, $mode, $donotshowbilled = 0) + public function LibStatut($statut, $billed, $mode, $donotshowbilled = 0) { // phpcs:enable global $langs, $conf; @@ -3430,72 +3429,72 @@ class Commande extends CommonOrder if ($mode == 0) { if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled'); - if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft'); - if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft'); + elseif ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); } elseif ($mode == 1) { if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort'); - if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort'); - if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort'); + elseif ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); } elseif ($mode == 2) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5').' '.$langs->trans('StatusOrderCanceledShort'); - if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraftShort'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'), 'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'), 'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBillShort'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDeliveredShort'); + elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraftShort'); + elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'), 'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'), 'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBillShort'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDeliveredShort'); } elseif ($mode == 3) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3'); - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0'); + elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); } elseif ($mode == 4) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5').' '.$langs->trans('StatusOrderCanceled'); - if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraft'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3').' '.$langs->trans('StatusOrderSent').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBill'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraft'); + elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3').' '.$langs->trans('StatusOrderSent').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBill'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDelivered'); } elseif ($mode == 5) { if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); + elseif ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); } elseif ($mode == 6) { if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceled').' '.img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); + elseif ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); } } @@ -3511,7 +3510,7 @@ class Commande extends CommonOrder * @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 = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user; @@ -3588,7 +3587,7 @@ class Commande extends CommonOrder * @param int $id Id of order * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, date_creation as datec, tms as datem,'; $sql.= ' date_valid as datev,'; @@ -3646,7 +3645,7 @@ class Commande extends CommonOrder * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $langs; @@ -3728,13 +3727,13 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 si ko, >0 si ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -3776,7 +3775,7 @@ class Commande extends CommonOrder * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -3880,7 +3879,7 @@ class OrderLine extends CommonOrderLine public $table_element='commandedet'; - var $oldline; + public $oldline; /** * Id of parent order @@ -3897,38 +3896,37 @@ class OrderLine extends CommonOrderLine public $commande_id; // From llx_commandedet - var $fk_parent_line; - var $fk_facture; + public $fk_parent_line; + public $fk_facture; /** * @var string Order lines label */ public $label; - var $fk_remise_except; - var $rang = 0; - var $fk_fournprice; + public $fk_remise_except; + public $rang = 0; + public $fk_fournprice; /** * Buy price without taxes * @var float */ - var $pa_ht; - var $marge_tx; - var $marque_tx; + public $pa_ht; + public $marge_tx; + public $marque_tx; /** * @deprecated * @see remise_percent, fk_remise_except */ - var $remise; + public $remise; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Start and end date of the line - var $date_start; - var $date_end; + public $date_start; + public $date_end; - var $skip_update_total; // Skip update price total for special lines + public $skip_update_total; // Skip update price total for special lines /** @@ -3936,10 +3934,10 @@ class OrderLine extends CommonOrderLine * * @param DoliDB $db handler d'acces base de donnee */ - function __construct($db) - { - $this->db= $db; - } + public function __construct($db) + { + $this->db= $db; + } /** * Load line order @@ -3947,7 +3945,7 @@ class OrderLine extends CommonOrderLine * @param int $rowid Id line order * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,'; $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,'; @@ -4032,7 +4030,7 @@ class OrderLine extends CommonOrderLine * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 si ko, >0 si ok */ - function delete(User $user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf, $langs; @@ -4093,7 +4091,7 @@ class OrderLine extends CommonOrderLine * @param int $notrigger 1 = disable triggers * @return int <0 if KO, >0 if OK */ - function insert($user = null, $notrigger = 0) + public function insert($user = null, $notrigger = 0) { global $langs, $conf; @@ -4238,7 +4236,7 @@ class OrderLine extends CommonOrderLine * @param int $notrigger 1 = disable triggers * @return int <0 si ko, >0 si ok */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf,$langs; @@ -4365,14 +4363,14 @@ class OrderLine extends CommonOrderLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 7c1dd201d23..15f0c628ce7 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -34,17 +34,17 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class CommandeStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -55,7 +55,7 @@ class CommandeStats extends Stats * @param string $mode Option ('customer', 'supplier') * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -74,7 +74,7 @@ class CommandeStats extends Stats $this->field_line='total_ht'; $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled } - if ($mode == 'supplier') + elseif ($mode == 'supplier') { $object=new CommandeFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; @@ -101,7 +101,7 @@ class CommandeStats 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 with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -123,7 +123,7 @@ class CommandeStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -144,7 +144,7 @@ class CommandeStats 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 with amount by month */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { global $user; @@ -166,7 +166,7 @@ class CommandeStats extends Stats * @param int $year year for stats * @return array array with number by month */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -186,7 +186,7 @@ class CommandeStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; @@ -206,7 +206,7 @@ class CommandeStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAllByProduct($year) + public function getAllByProduct($year) { global $user; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 95483513c72..c20abf44fe2 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -622,7 +622,7 @@ if ($resql) if (! empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 1c7a0c977a8..bd0e43b8461 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -235,7 +235,7 @@ class Account extends CommonObject * * @param DoliDB $db Database handler */ - function __construct(DoliDB $db) + public function __construct(DoliDB $db) { global $langs; @@ -290,7 +290,7 @@ class Account extends CommonObject * * @return int 1 if need to be concialiated, < 0 otherwise. */ - function canBeConciliated() + public function canBeConciliated() { global $conf; @@ -301,7 +301,7 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a link between bank line record and its source * @@ -312,7 +312,7 @@ class Account extends CommonObject * @param string $type Type of link ('payment', 'company', 'member', ...) * @return int <0 if KO, id line if OK */ - function add_url_line($line_id, $url_id, $url, $label, $type) + public function add_url_line($line_id, $url_id, $url, $label, $type) { // phpcs:enable $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; @@ -342,7 +342,7 @@ class Account extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * TODO Move this into AccountLine * Return array with links from llx_bank_url @@ -352,7 +352,7 @@ class Account extends CommonObject * @param string $type To search using type * @return array|int Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error */ - function get_url($fk_bank = '', $url_id = '', $type = '') + public function get_url($fk_bank = '', $url_id = '', $type = '') { // phpcs:enable $lines = array(); @@ -417,7 +417,7 @@ class Account extends CommonObject * @param int $datev Date value * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null) + public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null) { // Deprecation warning if (is_numeric($oper)) { @@ -525,7 +525,7 @@ class Account extends CommonObject * @param int $notrigger 1=Disable triggers * @return int < 0 if KO, > 0 if OK */ - function create(User $user, $notrigger = 0) + public function create(User $user, $notrigger = 0) { global $langs,$conf, $hookmanager; @@ -690,7 +690,7 @@ class Account extends CommonObject * @param int $notrigger 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 $langs,$conf, $hookmanager; @@ -793,14 +793,14 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update BBAN (RIB) account fields * * @param User $user Object user making update * @return int <0 if KO, >0 if OK */ - function update_bban(User $user = null) + public function update_bban(User $user = null) { // phpcs:enable global $conf,$langs; @@ -860,7 +860,7 @@ class Account extends CommonObject * @param string $ref Ref of bank account to get * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; @@ -1008,7 +1008,7 @@ class Account extends CommonObject * @param User $user User deleting * @return int <0 if KO, >0 if OK */ - function delete(User $user = null) + public function delete(User $user = null) { global $conf; @@ -1076,12 +1076,12 @@ class Account 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 */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->clos, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of given object status * @@ -1089,7 +1089,7 @@ class Account 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 */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -1120,13 +1120,13 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi si un compte peut etre supprimer ou non (sans mouvements) * * @return boolean vrai si peut etre supprime, faux sinon */ - function can_be_deleted() + public function can_be_deleted() { // phpcs:enable $can_be_deleted=false; @@ -1152,7 +1152,7 @@ class Account extends CommonObject * * @return string Error string */ - function error() + public function error() { return $this->error; } @@ -1163,7 +1163,7 @@ class Account extends CommonObject * @param int $option 1=Exclude future operation date (this is to exclude input made in advance and have real account sold) * @return int Current sold (value date <= today) */ - function solde($option = 0) + public function solde($option = 0) { $solde=0; @@ -1189,7 +1189,7 @@ class Account extends CommonObject return price2num($solde, 'MU'); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1197,7 +1197,7 @@ class Account extends CommonObject * @param int $filteraccountid To get info for a particular account id * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board(User $user, $filteraccountid = 0) + public function load_board(User $user, $filteraccountid = 0) { // phpcs:enable global $conf, $langs; @@ -1246,13 +1246,13 @@ class Account extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * @param int $filteraccountid To get info for a particular account id * @return int <0 if ko, >0 if ok */ - function load_state_board($filteraccountid = 0) + public function load_state_board($filteraccountid = 0) { // phpcs:enable global $user; @@ -1329,7 +1329,7 @@ class Account extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs, $user; @@ -1396,7 +1396,7 @@ class Account extends CommonObject * * @return int 1 if correct, <=0 if wrong */ - function verif() + public function verif() { require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; @@ -1430,7 +1430,7 @@ class Account extends CommonObject * * @return string country code */ - function getCountryCode() + public function getCountryCode() { global $mysoc; @@ -1467,7 +1467,7 @@ class Account extends CommonObject * 1=Need 2 fields for bank code: Bank, Desk (France, Spain, ...) + Account number and key * 2=Need 1 field for bank code: Bank only (Sort code for Great Britain, BSB for Australia) + Account number */ - function useDetailedBBAN() + public function useDetailedBBAN() { $country_code=$this->getCountryCode(); @@ -1481,7 +1481,7 @@ class Account extends CommonObject * * @return int 1 = mandatory / 0 = Not mandatory */ - function needIBAN() + public function needIBAN() { $country_code=$this->getCountryCode(); @@ -1531,7 +1531,7 @@ class Account extends CommonObject * @param int $id Id of object to load * @return void */ - function info($id) + public function info($id) { } @@ -1631,7 +1631,7 @@ class Account extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->specimen = 1; $this->ref = 'MBA'; @@ -1752,7 +1752,7 @@ class AccountLine extends CommonObject * * @param DoliDB $db Database handler */ - function __construct(DoliDB $db) + public function __construct(DoliDB $db) { $this->db = $db; } @@ -1765,7 +1765,7 @@ class AccountLine extends CommonObject * @param string $num External num to load (ex: num of transaction for paypal fee) * @return int <0 if KO, 0 if OK but not found, >0 if OK and found */ - function fetch($rowid, $ref = '', $num = '') + public function fetch($rowid, $ref = '', $num = '') { global $conf; @@ -1887,7 +1887,7 @@ class AccountLine extends CommonObject * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - function delete(User $user = null) + public function delete(User $user = null) { $nbko=0; @@ -1930,14 +1930,14 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete bank line records * * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - function delete_urls(User $user = null) + public function delete_urls(User $user = null) { // phpcs:enable $nbko=0; @@ -1976,7 +1976,7 @@ class AccountLine extends CommonObject * @param int $notrigger 0=Disable all triggers * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { $this->db->begin(); @@ -2002,7 +2002,7 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update conciliation field * @@ -2011,7 +2011,7 @@ class AccountLine extends CommonObject * @param int $conciliated 1=Set transaction to conciliated, 0=Keep transaction non conciliated * @return int <0 if KO, >0 if OK */ - function update_conciliation(User $user, $cat, $conciliated = 1) + public function update_conciliation(User $user, $cat, $conciliated = 1) { // phpcs:enable global $conf,$langs; @@ -2067,7 +2067,7 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase/decrease value date of a rowid * @@ -2075,7 +2075,7 @@ class AccountLine extends CommonObject * @param int $sign 1 or -1 * @return int >0 if OK, 0 if KO */ - function datev_change($rowid, $sign = 1) + public function datev_change($rowid, $sign = 1) { // phpcs:enable $sql = "SELECT datev FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; @@ -2107,34 +2107,34 @@ class AccountLine extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase value date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - function datev_next($id) + public function datev_next($id) { // phpcs:enable return $this->datev_change($id, 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Decrease value date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - function datev_previous($id) + public function datev_previous($id) { // phpcs:enable return $this->datev_change($id, -1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase/decrease operation date of a rowid * @@ -2142,7 +2142,7 @@ class AccountLine extends CommonObject * @param int $sign 1 or -1 * @return int >0 if OK, 0 if KO */ - function dateo_change($rowid, $sign = 1) + public function dateo_change($rowid, $sign = 1) { // phpcs:enable $sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; @@ -2174,27 +2174,27 @@ class AccountLine extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase operation date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - function dateo_next($id) + public function dateo_next($id) { // phpcs:enable return $this->dateo_change($id, 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Decrease operation date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - function dateo_previous($id) + public function dateo_previous($id) { // phpcs:enable return $this->dateo_change($id, -1); @@ -2207,7 +2207,7 @@ class AccountLine extends CommonObject * @param int $id Id of object to load * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT b.rowid, b.datec, b.tms as datem,'; $sql.= ' b.fk_user_author, b.fk_user_rappro'; @@ -2257,7 +2257,7 @@ class AccountLine extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0) { global $langs; @@ -2298,12 +2298,12 @@ class AccountLine extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - 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 * @@ -2311,7 +2311,7 @@ class AccountLine 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 Libelle du statut */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index feaaccaa50f..04692fb4e44 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -43,7 +43,7 @@ class BankAccounts extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -61,11 +61,11 @@ class BankAccounts 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 = '') { $list = array(); - if(! DolibarrApiAccess::$user->rights->banque->lire) { + if (! DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); } @@ -121,7 +121,7 @@ class BankAccounts extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if (! DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); @@ -142,7 +142,7 @@ class BankAccounts extends DolibarrApi * @param array $request_data Request data * @return int ID of account */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); @@ -173,7 +173,7 @@ class BankAccounts extends DolibarrApi * @param array $request_data data * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); @@ -196,7 +196,7 @@ class BankAccounts extends DolibarrApi } else { - throw new RestException(500, $account->error); + throw new RestException(500, $account->error); } } @@ -206,7 +206,7 @@ class BankAccounts extends DolibarrApi * @param int $id ID of account * @return array */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); @@ -237,7 +237,7 @@ class BankAccounts extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $account = array(); foreach (BankAccounts::$FIELDS as $field) { @@ -254,7 +254,7 @@ class BankAccounts extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -273,7 +273,7 @@ class BankAccounts extends DolibarrApi * * @url GET {id}/lines */ - function getLines($id) + public function getLines($id) { $list = array(); @@ -325,7 +325,7 @@ class BankAccounts extends DolibarrApi * * @url POST {id}/lines */ - function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') + public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') { if (! DolibarrApiAccess::$user->rights->banque->modifier) { throw new RestException(401); @@ -337,8 +337,16 @@ class BankAccounts extends DolibarrApi throw new RestException(404, 'account not found'); } - $result = $account->addline($date, $type, $label, $amount, $cheque_number, $category, - DolibarrApiAccess::$user, $cheque_writer, $cheque_bank); + $result = $account->addline( + $date, + $type, + $label, + $amount, + $cheque_number, + $category, + DolibarrApiAccess::$user, + $cheque_writer, $cheque_bank + ); if ($result < 0) { throw new RestException(503, 'Error when adding line to account: ' . $account->error); } @@ -358,7 +366,7 @@ class BankAccounts extends DolibarrApi * * @url POST {id}/lines/{line_id}/links */ - function addLink($id, $line_id, $url_id, $url, $label, $type) + public function addLink($id, $line_id, $url_id, $url, $label, $type) { if (! DolibarrApiAccess::$user->rights->banque->modifier) { throw new RestException(401); diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 06de0a00bc1..5a7ac205fe5 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -99,7 +99,7 @@ class PaymentVarious extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->element = 'payment_various'; @@ -113,7 +113,7 @@ class PaymentVarious extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -184,7 +184,7 @@ class PaymentVarious extends CommonObject * @param User $user User that load * @return int <0 if KO, >0 if OK */ - function fetch($id, $user = null) + public function fetch($id, $user = null) { global $langs; $sql = "SELECT"; @@ -258,7 +258,7 @@ class PaymentVarious extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { global $conf, $langs; @@ -292,7 +292,7 @@ class PaymentVarious extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -316,7 +316,7 @@ class PaymentVarious extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf,$langs; @@ -482,14 +482,14 @@ class PaymentVarious extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between payment various and line generate into llx_bank * * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank; @@ -513,12 +513,12 @@ class PaymentVarious 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 * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -526,7 +526,7 @@ class PaymentVarious 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 * @return string Libelle */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -575,7 +575,7 @@ class PaymentVarious extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $save_lastsearch_value = -1, $notooltip = 0) { global $db, $conf, $langs, $hookmanager; global $langs; @@ -644,8 +644,8 @@ class PaymentVarious extends CommonObject * @param int $id Id of record * @return void */ - function info($id) - { + public function info($id) + { $sql = 'SELECT v.rowid, v.datec, v.fk_user_author'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; $sql.= ' WHERE v.rowid = '.$id; diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 518b505efc5..ae1360ff633 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -83,7 +83,7 @@ class Deplacement extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -98,7 +98,7 @@ class Deplacement extends CommonObject * @param User $user User that creates * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf; @@ -183,7 +183,7 @@ class Deplacement extends CommonObject * @param User $user User making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { global $langs; @@ -245,9 +245,9 @@ class Deplacement extends CommonObject * @param string $ref Ref of record * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { - $sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet, extraparams"; + $sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet as fk_project, extraparams"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement"; $sql.= " WHERE entity IN (".getEntity('deplacement').")"; if ($ref) $sql.= " AND ref ='".$this->db->escape($ref)."'"; @@ -269,7 +269,7 @@ class Deplacement extends CommonObject $this->statut = $obj->fk_statut; $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; - $this->fk_project = $obj->fk_projet; + $this->fk_project = $obj->fk_project; $this->extraparams = (array) json_decode($obj->extraparams, true); @@ -288,7 +288,7 @@ class Deplacement extends CommonObject * @param int $id Id of record to delete * @return int <0 if KO, >0 if OK */ - function delete($id) + public function delete($id) { $this->db->begin(); @@ -316,12 +316,12 @@ class Deplacement 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 * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -329,7 +329,7 @@ class Deplacement 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 * @return string Libelle */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -345,26 +345,26 @@ class Deplacement extends CommonObject elseif ($mode == 2) { if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts_short[$statut]); - if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); - if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); + elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); + elseif ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); } elseif ($mode == 3) { if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); + elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); } elseif ($mode == 4) { if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); } elseif ($mode == 5) { if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - if ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); + elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); } } @@ -374,7 +374,7 @@ class Deplacement extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0) { global $langs; @@ -400,7 +400,7 @@ class Deplacement extends CommonObject * @param int $active Active or not * @return array */ - function listOfTypes($active = 1) + public function listOfTypes($active = 1) { global $langs; @@ -437,7 +437,7 @@ class Deplacement extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, c.datec, c.fk_user_author, c.fk_user_modif,'; $sql.= ' c.tms'; diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index 2580e264ee8..e6f3fb7828d 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -35,12 +35,12 @@ class DeplacementStats 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; /** * Constructor @@ -50,7 +50,7 @@ class DeplacementStats extends Stats * @param mixed $userid Id user for filter or array of user ids * @return void */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $conf; @@ -78,7 +78,7 @@ class DeplacementStats extends Stats * * @return array Array of values */ - function getNbByYear() + public function getNbByYear() { $sql = "SELECT YEAR(dated) as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -96,7 +96,7 @@ class DeplacementStats 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 values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { $sql = "SELECT MONTH(dated) as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -118,7 +118,7 @@ class DeplacementStats 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 values */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { $sql = "SELECT date_format(dated,'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -138,7 +138,7 @@ class DeplacementStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { $sql = "SELECT date_format(dated,'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -155,14 +155,14 @@ class DeplacementStats extends Stats * * @return array Array of values */ - function getAllByYear() - { - $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + public function getAllByYear() + { + $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6b633f99309..0f1b420f66e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2617,8 +2617,8 @@ if ($action == 'create') } if (!empty($soc->id)) $absolute_discount = $soc->getAvailableDiscounts(); - $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc)?$objectsrc->note_public:null)); - $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null)); + $note_public = $object->getDefaultCreateValueFor('note_public', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_public:null)); + $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_private:null)); if (! empty($conf->use_javascript_ajax)) { @@ -2696,7 +2696,7 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").' '; print ''; } print '' . "\n"; @@ -3092,7 +3092,7 @@ if ($action == 'create') $langs->load('projects'); print ''; } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 7da45f33920..6c4c94fc2ce 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -43,10 +43,10 @@ class Invoices extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->invoice = new Facture($this->db); } @@ -61,7 +61,7 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function get($id, $contact_list = 1) + public function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); @@ -105,7 +105,7 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') { global $db, $conf; @@ -204,7 +204,7 @@ class Invoices extends DolibarrApi * @param array $request_data Request datas * @return int ID of invoice */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401, "Insuffisant rights"); @@ -247,29 +247,29 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function createInvoiceFromOrder($orderid) + public function createInvoiceFromOrder($orderid) { require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; - if(! DolibarrApiAccess::$user->rights->commande->lire) { + if (! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - if(empty($orderid)) { + if (empty($orderid)) { throw new RestException(400, 'Order ID is mandatory'); } $order = new Commande($this->db); $result = $order->fetch($orderid); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'Order not found'); } $result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user); - if( $result < 0) { + if ( $result < 0) { throw new RestException(405, $this->invoice->error); } $this->invoice->fetchObjectLinked(); @@ -285,7 +285,7 @@ class Invoices extends DolibarrApi * * @return int */ - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); @@ -323,7 +323,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -386,7 +386,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type) { if(!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -428,7 +428,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function deleteContact($id, $rowid) + public function deleteContact($id, $rowid) { if(!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -468,7 +468,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->facture->creer) { @@ -506,7 +506,7 @@ class Invoices 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->facture->creer) { throw new RestException(401); @@ -547,7 +547,7 @@ class Invoices extends DolibarrApi * @param int $id Invoice ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->facture->supprimer) { throw new RestException(401); @@ -597,7 +597,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 400 */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -681,23 +681,23 @@ class Invoices extends DolibarrApi * @throws 500 * */ - function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) + public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); + throw new RestException(401); } $result = $this->invoice->fetch($id); if( ! $result ) { - throw new RestException(404, 'Invoice not found'); + throw new RestException(404, 'Invoice not found'); } if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->add_contact($fk_socpeople, $type_contact, $source, $notrigger); if ($result < 0) { - throw new RestException(500, 'Error : '.$this->invoice->error); + throw new RestException(500, 'Error : '.$this->invoice->error); } $result = $this->invoice->fetch($id); @@ -731,7 +731,7 @@ class Invoices extends DolibarrApi * @throws 500 * */ - function settodraft($id, $idwarehouse = -1) + public function settodraft($id, $idwarehouse = -1) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -783,7 +783,7 @@ class Invoices extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -834,7 +834,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function settopaid($id, $close_code = '', $close_note = '') + public function settopaid($id, $close_code = '', $close_note = '') { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -885,7 +885,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function settounpaid($id) + public function settounpaid($id) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -934,24 +934,24 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function markAsCreditAvailable($id) + public function markAsCreditAvailable($id) { if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); + throw new RestException(401); } $result = $this->invoice->fetch($id); if( ! $result ) { - throw new RestException(404, 'Invoice not found'); + throw new RestException(404, 'Invoice not found'); } if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch_thirdparty(); if( ! $result ) { - throw new RestException(404, 'Thirdparty not found'); + throw new RestException(404, 'Thirdparty not found'); } if (! $this->invoice->paye) // protection against multiple submit @@ -1053,7 +1053,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function useDiscount($id, $discountid) + public function useDiscount($id, $discountid) { if(! DolibarrApiAccess::$user->rights->facture->creer) { @@ -1099,7 +1099,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function useCreditNote($id, $discountid) + public function useCreditNote($id, $discountid) { require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; @@ -1144,7 +1144,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function getPayments($id) + public function getPayments($id) { if(! DolibarrApiAccess::$user->rights->facture->lire) { @@ -1192,7 +1192,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1257,10 +1257,10 @@ class Invoices extends DolibarrApi $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = $paiementid; + $paiement->paiementid = $paiementid; $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); $paiement->num_paiement = $num_paiement; - $paiement->note = $comment; + $paiement->note = $comment; $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices if ($paiement_id < 0) @@ -1312,7 +1312,7 @@ class Invoices extends DolibarrApi * @throws 403 * @throws 404 */ - function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1423,7 +1423,7 @@ class Invoices extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -1446,7 +1446,7 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $invoice = array(); foreach (Invoices::$FIELDS as $field) { diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 488fdaf21e8..9e36ceb646d 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Frédéric France @@ -103,7 +103,7 @@ class FactureRec extends CommonInvoice * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -115,7 +115,7 @@ class FactureRec extends CommonInvoice * @param int $facid Id of source invoice * @return int <0 if KO, id of invoice created if OK */ - function create($user, $facid) + public function create($user, $facid) { global $conf; @@ -225,7 +225,7 @@ class FactureRec extends CommonInvoice $tva_tx = $facsrc->lines[$i]->tva_tx; if (! empty($facsrc->lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; - $result_insert = $this->addline( + $result_insert = $this->addline( $facsrc->lines[$i]->desc, $facsrc->lines[$i]->subprice, $facsrc->lines[$i]->qty, @@ -312,6 +312,59 @@ class FactureRec extends CommonInvoice } + /** + * Update a line to invoice_rec. + * + * @param User $user User + * @param int $notrigger No trigger + * @return int <0 if KO, Id of line if OK + */ + public function update(User $user, $notrigger = 0) + { + global $conf; + + $error = 0; + + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; + $sql.= " fk_soc = ".$this->fk_soc; + // TODO Add missing fields + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILLREC_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } + /** * Load object and lines * @@ -321,7 +374,7 @@ class FactureRec extends CommonInvoice * @param int $ref_int Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ - function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') { $sql = 'SELECT f.rowid, f.entity, f.titre, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; @@ -449,19 +502,19 @@ class FactureRec extends CommonInvoice * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Recupere les lignes de factures predefinies dans this->lines * * @return int 1 if OK, < 0 if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->lines=array(); @@ -573,7 +626,7 @@ class FactureRec extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function delete(User $user, $notrigger = 0, $idwarehouse = -1) + public function delete(User $user, $notrigger = 0, $idwarehouse = -1) { $rowid=$this->id; @@ -644,7 +697,7 @@ class FactureRec extends CommonInvoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0) { global $mysoc; @@ -826,7 +879,7 @@ class FactureRec extends CommonInvoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @return int <0 if KO, Id of line if OK */ - function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0) + public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0) { global $mysoc; @@ -962,7 +1015,7 @@ class FactureRec extends CommonInvoice * * @return int|false false if KO, timestamp if OK */ - function getNextDate() + public function getNextDate() { if (empty($this->date_when)) return false; return dol_time_plus_duree($this->date_when, $this->frequency, $this->unit_frequency); @@ -973,7 +1026,7 @@ class FactureRec extends CommonInvoice * * @return boolean False by default, True if maximum number of generation is reached */ - function isMaxNbGenReached() + public function isMaxNbGenReached() { $ret = false; if ($this->nb_gen_max > 0 && ($this->nb_gen_done >= $this->nb_gen_max)) $ret = true; @@ -986,7 +1039,7 @@ class FactureRec extends CommonInvoice * @param string $ret Default value to output * @return boolean False by default, True if maximum number of generation is reached */ - function strikeIfMaxNbGenReached($ret) + public function strikeIfMaxNbGenReached($ret) { // Special case to strike the date return ($this->isMaxNbGenReached()?'':'').$ret.($this->isMaxNbGenReached()?'':''); @@ -1002,7 +1055,7 @@ class FactureRec extends CommonInvoice * @param int $forcevalidation 1=Force validation of invoice whatever is template auto_validate flag. * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0) + public function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0) { global $conf, $langs, $db, $user, $hookmanager; @@ -1031,7 +1084,7 @@ class FactureRec extends CommonInvoice $parameters = array( 'restrictioninvoiceid' => $restrictioninvoiceid, 'forcevalidation' => $forcevalidation, - ); + ); $reshook = $hookmanager->executeHooks('beforeCreationOfRecurringInvoices', $parameters, $sql); // note that $sql might be modified by hooks $resql = $db->query($sql); @@ -1132,7 +1185,7 @@ class FactureRec extends CommonInvoice 'invoiceidgenerated' => $invoiceidgenerated, 'facturerec' => $facturerec, // it's an object which PHP passes by "reference", so modifiable by hooks. 'this' => $this, // it's an object which PHP passes by "reference", so modifiable by hooks. - ); + ); $reshook = $hookmanager->executeHooks('afterCreationOfRecurringInvoice', $parameters, $facture); // note: $facture can be modified by hooks (warning: $facture can be null) $i++; @@ -1159,7 +1212,7 @@ class FactureRec extends CommonInvoice * @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 = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) { global $langs; @@ -1210,13 +1263,13 @@ class FactureRec extends CommonInvoice * @param integer $alreadypaid Not used on recurring invoices * @return string Label of status */ - function getLibStatut($mode = 0, $alreadypaid = -1) + public function getLibStatut($mode = 0, $alreadypaid = -1) { return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, $alreadypaid, empty($this->type)?0:$this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1227,7 +1280,7 @@ class FactureRec extends CommonInvoice * @param int $type Type invoice * @return string Label of status */ - function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0) + public function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0) { // phpcs:enable global $langs; @@ -1328,7 +1381,7 @@ class FactureRec extends CommonInvoice * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $user,$langs,$conf; @@ -1477,36 +1530,32 @@ class FactureRec extends CommonInvoice * Update frequency and unit * * @param int $frequency value of frequency - * @param string $unit unit of frequency (d, m, y) + * @param string $unit unit of frequency (d, m, y) * @return int <0 if KO, >0 if OK */ - function setFrequencyAndUnit($frequency, $unit) + public function setFrequencyAndUnit($frequency, $unit) { - if (! $this->table_element) - { + if (! $this->table_element) { dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); return -1; } - if (!empty($frequency) && empty($unit)) - { + if (!empty($frequency) && empty($unit)) { dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR); return -2; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET frequency = '.($frequency?$this->db->escape($frequency):'null'); - if (!empty($unit)) - { + if (!empty($unit)) { $sql.= ', unit_frequency = \''.$this->db->escape($unit).'\''; } $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->frequency = $frequency; - if (!empty($unit)) $this->unit_frequency = $unit; + if (!empty($unit)) $this->unit_frequency = $unit; return 1; } else @@ -1523,7 +1572,7 @@ class FactureRec extends CommonInvoice * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done * @return int <0 if KO, >0 if OK */ - function setNextDate($date, $increment_nb_gen_done = 0) + public function setNextDate($date, $increment_nb_gen_done = 0) { if (! $this->table_element) { @@ -1555,7 +1604,7 @@ class FactureRec extends CommonInvoice * @param int $nb number of maximum period * @return int <0 if KO, >0 if OK */ - function setMaxPeriod($nb) + public function setMaxPeriod($nb) { if (! $this->table_element) { @@ -1588,7 +1637,7 @@ class FactureRec extends CommonInvoice * @param int $validate 0 to create in draft, 1 to create and validate invoice * @return int <0 if KO, >0 if OK */ - function setAutoValidate($validate) + public function setAutoValidate($validate) { if (! $this->table_element) { @@ -1619,7 +1668,7 @@ class FactureRec extends CommonInvoice * @param int $validate 0 no document, 1 to generate document * @return int <0 if KO, >0 if OK */ - function setGeneratePdf($validate) + public function setGeneratePdf($validate) { if (! $this->table_element) { @@ -1645,12 +1694,12 @@ class FactureRec extends CommonInvoice } /** - * Update the model for documents + * Update the model for documents * - * @param string $model model of document generator - * @return int <0 if KO, >0 if OK + * @param string $model model of document generator + * @return int <0 if KO, >0 if OK */ - function setModelPdf($model) + public function setModelPdf($model) { if (! $this->table_element) { @@ -1694,8 +1743,8 @@ class FactureLigneRec extends CommonInvoiceLine */ public $table_element='facturedet_rec'; - var $date_start_fill; - var $date_end_fill; + public $date_start_fill; + public $date_end_fill; /** @@ -1705,7 +1754,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function delete(User $user, $notrigger = false) + public function delete(User $user, $notrigger = false) { $error=0; @@ -1748,7 +1797,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $rowid Id of invoice * @return int 1 if OK, < 0 if KO */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; @@ -1823,10 +1872,12 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $notrigger No trigger * @return int <0 if KO, Id of line if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; + $error = 0; + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; @@ -1848,8 +1899,7 @@ class FactureLigneRec extends CommonInvoiceLine $sql.= ", info_bits='".price2num($this->info_bits)."'"; $sql.= ", date_start_fill=".(int) $this->date_start_fill; $sql.= ", date_end_fill=".(int) $this->date_end_fill; - if (empty($this->skip_update_total)) - { + if (empty($this->skip_update_total)) { $sql.= ", total_ht=".price2num($this->total_ht); $sql.= ", total_tva=".price2num($this->total_tva); $sql.= ", total_localtax1=".price2num($this->total_localtax1); @@ -1864,8 +1914,8 @@ class FactureLigneRec extends CommonInvoiceLine dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { + if ($resql) + { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -1878,7 +1928,7 @@ class FactureLigneRec extends CommonInvoiceLine if (! $error && ! $notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILL_REC_UPDATE', $user); + $result=$this->call_trigger('LINEBILLREC_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -1886,14 +1936,14 @@ class FactureLigneRec extends CommonInvoiceLine } // End call triggers } - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -2; - } + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -2; + } } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 47e91459b8e..5e2db021f83 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -274,7 +274,7 @@ class Facture extends CommonInvoice * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -289,7 +289,7 @@ class Facture extends CommonInvoice * @param int $forceduedate 1=Do not recalculate due date from payment condition but force it with value * @return int <0 if KO, >0 if OK */ - function create(User $user, $notrigger = 0, $forceduedate = 0) + public function create(User $user, $notrigger = 0, $forceduedate = 0) { global $langs,$conf,$mysoc,$hookmanager; $error=0; @@ -854,7 +854,7 @@ class Facture extends CommonInvoice * @param int $invertdetail Reverse sign of amounts for lines * @return int <0 if KO, >0 if OK */ - function createFromCurrent(User $user, $invertdetail = 0) + public function createFromCurrent(User $user, $invertdetail = 0) { global $conf; @@ -945,7 +945,7 @@ class Facture extends CommonInvoice * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$hookmanager, $conf; @@ -1054,7 +1054,7 @@ class Facture extends CommonInvoice * @param User $user Object user * @return int <0 if KO, 0 if nothing done, 1 if OK */ - function createFromOrder($object, User $user) + public function createFromOrder($object, User $user) { global $hookmanager; @@ -1159,30 +1159,6 @@ class Facture extends CommonInvoice else return -1; } - /** - * Return link to download file from a direct external access - * - * @param int $withpicto Add download picto into link - * @return string HTML link to file - */ - function getDirectExternalLink($withpicto = 0) - { - global $dolibarr_main_url_root; - - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - - // TODO Read into ecmfile table to get entry and hash exists (PS: If not found, add it) - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($this->db); - //$result = $ecmfile->get(); - - $hashp='todo'; - return ''.$this->ref.''; - } - /** * Return clicable link of object (with eventually picto) * @@ -1196,7 +1172,7 @@ class Facture extends CommonInvoice * @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 = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user, $form; @@ -1304,7 +1280,7 @@ class Facture extends CommonInvoice * @param bool $fetch_situation Fetch the previous and next situation in $tab_previous_situation_invoice and $tab_next_situation_invoice * @return int >0 if OK, <0 if KO, 0 if not found */ - function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_situation = false) + public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_situation = false) { global $conf; @@ -1455,13 +1431,13 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load all detailed lines into this->lines * * @return int 1 if OK, < 0 if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->lines=array(); @@ -1571,7 +1547,7 @@ class Facture extends CommonInvoice * * @return void */ - function fetchPreviousNextSituationInvoice() + public function fetchPreviousNextSituationInvoice() { global $conf; @@ -1611,7 +1587,7 @@ class Facture extends CommonInvoice * @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; @@ -1716,14 +1692,14 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount) * * @param int $idremise Id of absolute discount * @return int >0 if OK, <0 if KO */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -1818,7 +1794,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set customer ref * @@ -1826,7 +1802,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_ref_client($ref_client, $notrigger = 0) + public function set_ref_client($ref_client, $notrigger = 0) { // phpcs:enable global $user; @@ -1891,7 +1867,7 @@ class Facture extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, 0=Refused, >0 if OK */ - function delete($user, $notrigger = 0, $idwarehouse = -1) + public function delete($user, $notrigger = 0, $idwarehouse = -1) { global $langs,$conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2055,7 +2031,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1 * ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 @@ -2065,7 +2041,7 @@ class Facture extends CommonInvoice * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) * @return int <0 if KO, >0 if OK */ - function set_paid($user, $close_code = '', $close_note = '') + public function set_paid($user, $close_code = '', $close_note = '') { // phpcs:enable $error=0; @@ -2115,7 +2091,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED * Fonction utilisee quand un paiement prelevement est refuse, @@ -2124,7 +2100,7 @@ class Facture extends CommonInvoice * @param User $user Object user that change status * @return int <0 if KO, >0 if OK */ - function set_unpaid($user) + public function set_unpaid($user) { // phpcs:enable $error=0; @@ -2164,7 +2140,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because @@ -2175,7 +2151,7 @@ class Facture extends CommonInvoice * @param string $close_note Comment * @return int <0 if KO, >0 if OK */ - function set_canceled($user, $close_code = '', $close_note = '') + public function set_canceled($user, $close_code = '', $close_note = '') { // phpcs:enable @@ -2238,7 +2214,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK */ - function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) + public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2495,7 +2471,7 @@ class Facture extends CommonInvoice * @param Translate $langs Translate object * @return bool false if KO, true if OK */ - function updatePriceNextInvoice(&$langs) + public function updatePriceNextInvoice(&$langs) { foreach ($this->tab_next_situation_invoice as $next_invoice) { @@ -2528,7 +2504,7 @@ class Facture extends CommonInvoice return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -2536,7 +2512,7 @@ class Facture extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function set_draft($user, $idwarehouse = -1) + public function set_draft($user, $idwarehouse = -1) { // phpcs:enable global $conf,$langs; @@ -2656,7 +2632,7 @@ class Facture extends CommonInvoice * @param double $pu_ht_devise Unit price in currency * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0) { // Deprecation warning if ($label) { @@ -2886,7 +2862,7 @@ class Facture extends CommonInvoice * @param int $notrigger disable line update trigger * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { global $conf,$user; // Deprecation warning @@ -3077,7 +3053,7 @@ class Facture extends CommonInvoice * @param float $situation_percent progress percentage need to be test * @return false if KO, true if OK */ - function checkProgressLine($idline, $situation_percent) + public function checkProgressLine($idline, $situation_percent) { $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd INNER JOIN '.MAIN_DB_PREFIX.'facture f ON (fd.fk_facture = f.rowid) @@ -3097,7 +3073,7 @@ class Facture extends CommonInvoice else return $situation_percent < $obj->situation_percent; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update invoice line with percentage * @@ -3105,7 +3081,7 @@ class Facture extends CommonInvoice * @param int $percent Percentage * @return void */ - function update_percent($line, $percent) + public function update_percent($line, $percent) { // phpcs:enable global $mysoc,$user; @@ -3135,7 +3111,7 @@ class Facture extends CommonInvoice * @param int $rowid Id of line to delete * @return int <0 if KO, >0 if OK */ - function deleteline($rowid) + public function deleteline($rowid) { global $user; @@ -3195,7 +3171,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set percent discount * @@ -3204,7 +3180,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_remise($user, $remise, $notrigger = 0) + public function set_remise($user, $remise, $notrigger = 0) { // phpcs:enable // Clean parameters @@ -3261,7 +3237,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set absolute discount * @@ -3270,7 +3246,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable if (empty($remise)) $remise=0; @@ -3337,7 +3313,7 @@ class Facture extends CommonInvoice * @param string $mode 'next' for next value or 'last' for last value * @return string free ref or last ref */ - function getNextNumRef($soc, $mode = 'next') + public function getNextNumRef($soc, $mode = 'next') { global $conf, $langs; $langs->load("bills"); @@ -3426,7 +3402,7 @@ class Facture extends CommonInvoice * @param int $id Id of object to load * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; $sql.= ' fk_user_author, fk_user_valid'; @@ -3465,7 +3441,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of invoices (eventually filtered on a user) into an array * @@ -3479,7 +3455,7 @@ class Facture extends CommonInvoice * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') { // phpcs:enable global $conf,$user; @@ -3541,7 +3517,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of invoices qualified to be replaced by another invoice. * Invoices matching the following rules are returned: @@ -3550,7 +3526,7 @@ class Facture extends CommonInvoice * @param int $socid Id thirdparty * @return array Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) */ - function list_replacable_invoices($socid = 0) + public function list_replacable_invoices($socid = 0) { // phpcs:enable global $conf; @@ -3591,7 +3567,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of invoices qualified to be corrected by a credit note. * Invoices matching the following rules are returned: @@ -3600,7 +3576,7 @@ class Facture extends CommonInvoice * @param int $socid Id thirdparty * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) */ - function list_qualified_avoir_invoices($socid = 0) + public function list_qualified_avoir_invoices($socid = 0) { // phpcs:enable global $conf; @@ -3666,7 +3642,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a withdrawal request for a standing order. * Use the remain to pay excluding all existing open direct debit requests. @@ -3675,7 +3651,7 @@ class Facture extends CommonInvoice * @param float $amount Amount we request direct debit for * @return int <0 if KO, >0 if OK */ - function demande_prelevement($fuser, $amount = 0) + public function demande_prelevement($fuser, $amount = 0) { // phpcs:enable @@ -3778,7 +3754,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Supprime une demande de prelevement * @@ -3786,7 +3762,7 @@ class Facture extends CommonInvoice * @param int $did id de la demande a supprimer * @return int <0 if OK, >0 if KO */ - function demande_prelevement_delete($fuser, $did) + public function demande_prelevement_delete($fuser, $did) { // phpcs:enable $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; @@ -3805,14 +3781,14 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -3877,7 +3853,7 @@ class Facture extends CommonInvoice * * @return array Liste des id contacts facturation */ - function getIdBillingContact() + public function getIdBillingContact() { return $this->getIdContact('external', 'BILLING'); } @@ -3887,7 +3863,7 @@ class Facture extends CommonInvoice * * @return array Liste des id contacts livraison */ - function getIdShippingContact() + public function getIdShippingContact() { return $this->getIdContact('external', 'SHIPPING'); } @@ -3901,7 +3877,7 @@ class Facture extends CommonInvoice * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $langs; @@ -4052,13 +4028,13 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -4101,7 +4077,7 @@ class Facture extends CommonInvoice * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -4147,7 +4123,7 @@ class Facture extends CommonInvoice * * @return int >= 1 if OK, -1 if error */ - function newCycle() + public function newCycle() { $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; $sql.= " WHERE f.entity in (".getEntity('invoice', 0).")"; @@ -4170,25 +4146,25 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Checks if the invoice is the first of a cycle * * @return boolean */ - function is_first() + public function is_first() { // phpcs:enable return ($this->situation_counter == 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array containing the previous situations as Facture objects * * @return mixed -1 if error, array of previous situations */ - function get_prev_sits() + public function get_prev_sits() { // phpcs:enable global $conf; @@ -4222,7 +4198,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function setFinal(User $user, $notrigger = 0) + public function setFinal(User $user, $notrigger = 0) { $error=0; @@ -4263,14 +4239,14 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Checks if the invoice is the last in its cycle * * @return bool Last of the cycle status * */ - function is_last_in_cycle() + public function is_last_in_cycle() { // phpcs:enable global $conf; @@ -4427,7 +4403,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $rowid id of invoice line to get * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; @@ -4519,7 +4495,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) + public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) { global $langs,$user,$conf; @@ -4736,7 +4712,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = '', $notrigger = 0) + public function update($user = '', $notrigger = 0) { global $user,$conf; @@ -4870,7 +4846,7 @@ class FactureLigne extends CommonInvoiceLine * * @return int <0 if KO, >0 if OK */ - function delete() + public function delete() { global $user; @@ -4901,14 +4877,14 @@ class FactureLigne extends CommonInvoiceLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); @@ -4943,7 +4919,7 @@ class FactureLigne extends CommonInvoiceLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns situation_percent of the previous line. * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. @@ -4952,7 +4928,7 @@ class FactureLigne extends CommonInvoiceLine * @param bool $include_credit_note Include credit note or not * @return int >= 0 */ - function get_prev_progress($invoiceid, $include_credit_note = true) + public function get_prev_progress($invoiceid, $include_credit_note = true) { // phpcs:enable if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 65a8808bac7..91d3e4476ff 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -32,17 +32,17 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class FactureStats extends Stats { - var $socid; - var $userid; + public $socid; + public $userid; /** * @var string Name of table without prefix where object is stored */ public $table_element; - - var $from; - var $field; - var $where; + + public $from; + public $field; + public $where; /** @@ -53,7 +53,7 @@ class FactureStats extends Stats * @param string $mode Option ('customer', 'supplier') * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -100,7 +100,7 @@ class FactureStats 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 values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -123,7 +123,7 @@ class FactureStats extends Stats * * @return array Array with number by year */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -145,7 +145,7 @@ class FactureStats 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 with amount by month */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { global $user; @@ -168,7 +168,7 @@ class FactureStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -188,7 +188,7 @@ class FactureStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; @@ -208,7 +208,7 @@ class FactureStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAllByProduct($year) + public function getAllByProduct($year) { global $user; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 3d4f0881de2..707b6586b83 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -69,7 +69,7 @@ class PaymentTerm // extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -82,7 +82,7 @@ class PaymentTerm // 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; @@ -173,7 +173,7 @@ class PaymentTerm // extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -229,7 +229,7 @@ class PaymentTerm // extends CommonObject * * @return int <0 if KO, >0 if OK */ - function getDefaultId() + public function getDefaultId() { global $langs; @@ -262,13 +262,13 @@ class PaymentTerm // extends CommonObject /** - * Update database + * Update database * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK + * @param User $user User that modify + * @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; @@ -345,7 +345,7 @@ class PaymentTerm // 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; @@ -391,12 +391,12 @@ class PaymentTerm // extends CommonObject /** - * Load an object from its id and create a new one in database + * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * @return int New id of clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -425,10 +425,6 @@ class PaymentTerm // extends CommonObject $error++; } - //if (! $error) - //{ - //} - unset($object->context['createfromclone']); // End @@ -445,15 +441,15 @@ class PaymentTerm // extends CommonObject } - /** + /** * Initialise an instance with random values. * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() - { + */ + public function initAsSpecimen() + { $this->id=0; $this->code=''; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 1e21952c2d1..4c7cc6a9c93 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1390,7 +1390,7 @@ else print '
'.$langs->trans('DiscountType').' '; - print ' '; + print '
'.$langs->trans('DiscountType').''; + if ($isCustomer) { + print ' '; + } + if ($isSupplier) { + print ' '; + } print '
' . $langs->trans("Project") . ''; $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">' . $langs->trans("AddProject") . ' '; print '
'; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '
' . $langs->trans('Project') . ''; $numprojet = $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1); - print '   id.($fac_rec?'&fac_rec='.$fac_rec:'')).'">' . $langs->trans("AddProject") . ''; + print '   id.($fac_rec?'&fac_rec='.$fac_rec:'')).'">' . $langs->trans("AddProject") . ' '; print '
'; print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 3363caddeef..600c4f7b57a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -759,7 +759,7 @@ if ($resql) if (! empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 686e72c46a7..b0178bd09e1 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -75,7 +75,7 @@ class Localtax extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -87,7 +87,7 @@ class Localtax extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -163,7 +163,7 @@ class Localtax extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf, $langs; @@ -228,7 +228,7 @@ class Localtax extends CommonObject * @param int $id Object id * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -292,7 +292,7 @@ class Localtax extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { // Call trigger $result=$this->call_trigger('LOCALTAX_DELETE', $user); @@ -322,7 +322,7 @@ class Localtax extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -345,7 +345,7 @@ class Localtax extends CommonObject * @param int $year Year * @return int ??? */ - function solde($year = 0) + public function solde($year = 0) { $reglee = $this->localtax_sum_reglee($year); @@ -358,14 +358,14 @@ class Localtax extends CommonObject return $solde; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Total de la localtax des factures emises par la societe. * * @param int $year Year * @return int ??? */ - function localtax_sum_collectee($year = 0) + public function localtax_sum_collectee($year = 0) { // phpcs:enable $sql = "SELECT sum(f.localtax) as amount"; @@ -398,14 +398,14 @@ class Localtax extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * localtax payed * * @param int $year Year * @return int ??? */ - function localtax_sum_payee($year = 0) + public function localtax_sum_payee($year = 0) { // phpcs:enable @@ -440,7 +440,7 @@ class Localtax extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * localtax payed * Total de la localtax payed @@ -448,7 +448,7 @@ class Localtax extends CommonObject * @param int $year Year * @return int ??? */ - function localtax_sum_reglee($year = 0) + public function localtax_sum_reglee($year = 0) { // phpcs:enable @@ -489,7 +489,7 @@ class Localtax extends CommonObject * @param User $user Object user that insert * @return int <0 if KO, rowid in localtax table if OK */ - function addPayment($user) + public function addPayment($user) { global $conf,$langs; @@ -596,21 +596,20 @@ class Localtax extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update the link betwen localtax payment and the line into llx_bank * * @param int $id Id bank account * @return int <0 if KO, >0 if OK */ - function update_fk_bank($id) + public function update_fk_bank($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.$id; $sql.= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); - if ($result) - { + if ($result) { return 1; } else @@ -628,7 +627,7 @@ class Localtax extends CommonObject * @param string $option Sur quoi pointe le lien * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '') + public function getNomUrl($withpicto = 0, $option = '') { global $langs; @@ -652,12 +651,12 @@ class Localtax 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 Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -665,7 +664,7 @@ class Localtax 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 Libelle du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index ee69d8d89f3..f84a805caef 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -771,11 +771,6 @@ else print '
'; -/*if ($user->societe_id == 0 && count($accounts) == 1 && $action == 'new' && $user->rights->banque->cheque) -{ - print ''.$langs->trans('NewCheckReceipt').''; -}*/ - if ($user->societe_id == 0 && ! empty($object->id) && $object->statut == 0 && $user->rights->banque->cheque) { print ''.$langs->trans('Validate').''; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 2c4180c3858..15b006d2cc6 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -70,12 +70,12 @@ class RemiseCheque extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { $this->db = $db; $this->next_id = 0; $this->previous_id = 0; - } + } /** * Load record @@ -84,8 +84,8 @@ class RemiseCheque extends CommonObject * @param string $ref Ref record * @return int <0 if KO, > 0 if OK */ - function fetch($id, $ref = '') - { + public function fetch($id, $ref = '') + { global $conf; $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.ref, bc.statut, bc.nbcheque, bc.ref_ext"; @@ -131,7 +131,7 @@ class RemiseCheque extends CommonObject $this->error=$this->db->lasterror(); return -1; } - } + } /** * Create a receipt to send cheques @@ -142,8 +142,8 @@ class RemiseCheque extends CommonObject * @param array $toRemise array with cheques to remise * @return int <0 if KO, >0 if OK */ - function create($user, $account_id, $limit, $toRemise) - { + public function create($user, $account_id, $limit, $toRemise) + { global $conf; $this->errno = 0; @@ -299,8 +299,8 @@ class RemiseCheque extends CommonObject * @param User $user Utilisateur qui effectue l'operation * @return int */ - function delete($user = '') - { + public function delete($user = '') + { global $conf; $this->errno = 0; @@ -353,8 +353,8 @@ class RemiseCheque extends CommonObject * @param User $user User * @return int <0 if KO, >0 if OK */ - function validate($user) - { + public function validate($user) + { global $langs,$conf; $this->errno = 0; @@ -416,8 +416,8 @@ class RemiseCheque extends CommonObject * @param string $mode 'next' for next value or 'last' for last value * @return string free ref or last ref */ - function getNextNumRef($mode = 'next') - { + public function getNextNumRef($mode = 'next') + { global $conf, $db, $langs, $mysoc; $langs->load("bills"); @@ -492,18 +492,18 @@ class RemiseCheque extends CommonObject print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); return ""; } - } + } - // 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; @@ -547,17 +547,17 @@ class RemiseCheque extends CommonObject $this->error=$this->db->error(); return -1; } - } + } - // 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 $user; @@ -588,7 +588,7 @@ class RemiseCheque extends CommonObject $this->error=$this->db->error(); return -1; } - } + } /** @@ -598,8 +598,8 @@ class RemiseCheque extends CommonObject * @param Translate $outputlangs Object langs * @return int <0 if KO, >0 if OK */ - function generatePdf($model, $outputlangs) - { + public function generatePdf($model, $outputlangs) + { global $langs,$conf; if (empty($model)) $model='blochet'; @@ -675,15 +675,15 @@ class RemiseCheque extends CommonObject $this->error=$langs->trans("ErrorFileDoesNotExists", $dir.$file); return -1; } - } + } /** * Mets a jour le montant total * * @return int 0 en cas de succes */ - function updateAmount() - { + public function updateAmount() + { global $conf; $this->errno = 0; @@ -735,7 +735,7 @@ class RemiseCheque extends CommonObject } return $this->errno; - } + } /** * Insere la remise en base @@ -743,8 +743,8 @@ class RemiseCheque extends CommonObject * @param int $account_id Compte bancaire concerne * @return int */ - function removeCheck($account_id) - { + public function removeCheck($account_id) + { $this->errno = 0; if ($this->id > 0) @@ -766,7 +766,7 @@ class RemiseCheque extends CommonObject } } return 0; - } + } /** * Check return management @@ -776,8 +776,8 @@ class RemiseCheque extends CommonObject * @param date $rejection_date Date to use on the negative payment * @return int Id of negative payment line created */ - function rejectCheck($bank_id, $rejection_date) - { + public function rejectCheck($bank_id, $rejection_date) + { global $db, $user; $payment = new Paiement($db); @@ -866,14 +866,14 @@ class RemiseCheque extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge les proprietes ref_previous et ref_next * * @return int <0 if KO, 0 if OK */ - function load_previous_next_id() - { + public function load_previous_next_id() + { // phpcs:enable global $conf; @@ -909,7 +909,7 @@ class RemiseCheque extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the creation date * @@ -917,7 +917,7 @@ class RemiseCheque extends CommonObject * @param int $date Date creation * @return int <0 if KO, >0 if OK */ - function set_date($user, $date) + public function set_date($user, $date) { // phpcs:enable if ($user->rights->banque->cheque) @@ -945,7 +945,7 @@ class RemiseCheque extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the ref of bordereau * @@ -953,8 +953,8 @@ class RemiseCheque extends CommonObject * @param int $ref ref of bordereau * @return int <0 if KO, >0 if OK */ - function set_number($user, $ref) - { + public function set_number($user, $ref) + { // phpcs:enable if ($user->rights->banque->cheque) { @@ -988,8 +988,8 @@ class RemiseCheque extends CommonObject * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') - { + public function initAsSpecimen($option = '') + { global $user,$langs,$conf; $now=dol_now(); @@ -1001,7 +1001,7 @@ class RemiseCheque extends CommonObject $this->ref = 'SPECIMEN'; $this->specimen=1; $this->date_bordereau = $nownotime; - } + } /** * Return clicable name (with picto eventually) @@ -1013,8 +1013,8 @@ class RemiseCheque 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($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { global $conf, $langs; $result=''; @@ -1056,7 +1056,7 @@ class RemiseCheque extends CommonObject $result .= $linkend; return $result; - } + } /** * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) @@ -1064,12 +1064,12 @@ class RemiseCheque 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 Libelle */ - function getLibStatut($mode = 0) - { - return $this->LibStatut($this->statut, $mode); - } + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->statut, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1077,46 +1077,46 @@ class RemiseCheque 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 Libelle du statut */ - function LibStatut($status, $mode = 0) - { + public function LibStatut($status, $mode = 0) + { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage $langs->load('compta'); if ($mode == 0) { if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); + elseif ($status == 1) return $langs->trans('Validated'); } elseif ($mode == 1) { if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); + elseif ($status == 1) return $langs->trans('Validated'); } elseif ($mode == 2) { if ($status == 0) return img_picto($langs->trans('ToValidate'), 'statut0').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); + elseif ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); } elseif ($mode == 3) { if ($status == 0) return img_picto($langs->trans('ToValidate'), 'statut0'); - if ($status == 1) return img_picto($langs->trans('Validated'), 'statut4'); + elseif ($status == 1) return img_picto($langs->trans('Validated'), 'statut4'); } elseif ($mode == 4) { if ($status == 0) return img_picto($langs->trans('ToValidate'), 'statut0').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); + elseif ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); } elseif ($mode == 5) { if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'), 'statut0'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); + elseif ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); } elseif ($mode == 6) { if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'), 'statut0'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); + elseif ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); } return $langs->trans('Unknown'); - } + } } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 7307b3e1601..13b04854b9c 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -225,7 +225,7 @@ class Paiement extends CommonObject * @param Societe $thirdparty Thirdparty * @return int id of created payment, < 0 if error */ - function create($user, $closepaidinvoices = 0, $thirdparty = null) + public function create($user, $closepaidinvoices = 0, $thirdparty = null) { global $conf, $langs; @@ -497,7 +497,7 @@ class Paiement extends CommonObject * @param int $notrigger No trigger * @return int <0 si ko, >0 si ok */ - function delete($notrigger = 0) + public function delete($notrigger = 0) { global $conf, $user, $langs; @@ -607,7 +607,7 @@ class Paiement extends CommonObject * @param int $notrigger No trigger * @return int <0 if KO, bank_line_id if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0) { global $conf,$langs,$user; @@ -730,9 +730,8 @@ class Paiement extends CommonObject } // Add link 'WithdrawalPayment' in bank_url - if (! $error && $label == '(WithdrawalPayment)') - { - $result=$acc->add_url_line( + if (! $error && $label == '(WithdrawalPayment)') { + $result=$acc->add_url_line( $bank_line_id, $this->id_prelevement, DOL_URL_ROOT.'/compta/prelevement/card.php?id=', @@ -776,14 +775,14 @@ class Paiement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour du lien entre le paiement et la ligne generee dans llx_bank * * @param int $id_bank Id compte bancaire * @return int <0 if KO, >0 if OK */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank; @@ -801,16 +800,16 @@ class Paiement extends CommonObject dol_syslog(get_class($this).'::update_fk_bank '.$this->error); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Updates the payment date * * @param int $date New date * @return int <0 if KO, 0 if OK */ - function update_date($date) + public function update_date($date) { // phpcs:enable $error=0; @@ -868,18 +867,17 @@ class Paiement extends CommonObject return -1; //no date given or already validated } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Updates the payment number * * @param string $num New num * @return int <0 if KO, 0 if OK */ - function update_num($num) + public function update_num($num) { // phpcs:enable - if(!empty($num) && $this->statut!=1) - { + if(!empty($num) && $this->statut!=1) { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql.= " SET num_paiement = '".$this->db->escape($num)."'"; $sql.= " WHERE rowid = ".$this->id; @@ -906,8 +904,8 @@ class Paiement extends CommonObject * @param User $user User making validation * @return int <0 if KO, >0 if OK */ - function valide(User $user = null) - { + public function valide(User $user = null) + { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.$this->id; dol_syslog(get_class($this).'::valide', LOG_DEBUG); @@ -922,7 +920,7 @@ class Paiement extends CommonObject dol_syslog(get_class($this).'::valide '.$this->error); return -1; } - } + } /** * Reject payment @@ -930,8 +928,8 @@ class Paiement extends CommonObject * @param User $user User making reject * @return int <0 if KO, >0 if OK */ - function reject(User $user = null) - { + public function reject(User $user = null) + { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 2 WHERE rowid = '.$this->id; dol_syslog(get_class($this).'::reject', LOG_DEBUG); @@ -946,7 +944,7 @@ class Paiement extends CommonObject dol_syslog(get_class($this).'::reject '.$this->error); return -1; } - } + } /** * Information sur l'objet @@ -954,8 +952,8 @@ class Paiement extends CommonObject * @param int $id id du paiement dont il faut afficher les infos * @return void */ - function info($id) - { + public function info($id) + { $sql = 'SELECT p.rowid, p.datec, p.fk_user_creat, p.fk_user_modif, p.tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p'; $sql.= ' WHERE p.rowid = '.$id; @@ -990,7 +988,7 @@ class Paiement extends CommonObject { dol_print_error($this->db); } - } + } /** * Retourne la liste des factures sur lesquels porte le paiement @@ -998,8 +996,8 @@ class Paiement extends CommonObject * @param string $filter Critere de filtre * @return array Tableau des id de factures */ - function getBillsArray($filter = '') - { + public function getBillsArray($filter = '') + { $sql = 'SELECT fk_facture'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' WHERE pf.fk_facture = f.rowid AND fk_paiement = '.$this->id; @@ -1026,7 +1024,7 @@ class Paiement extends CommonObject dol_syslog(get_class($this).'::getBillsArray Error '.$this->error.' -', LOG_DEBUG); return -1; } - } + } /** * Return next reference of customer invoice not already used (or last reference) @@ -1036,7 +1034,7 @@ class Paiement extends CommonObject * @param string $mode 'next' for next value or 'last' for last value * @return string free ref or last ref */ - function getNextNumRef($soc, $mode = 'next') + public function getNextNumRef($soc, $mode = 'next') { global $conf, $db, $langs; $langs->load("bills"); @@ -1119,7 +1117,7 @@ class Paiement extends CommonObject * * @return string 'dolibarr' if standard comportment or paid in main currency, 'customer' if payment received from multicurrency inputs */ - function getWay() + public function getWay() { global $conf; @@ -1147,7 +1145,7 @@ class Paiement extends CommonObject * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $user,$langs,$conf; @@ -1173,7 +1171,7 @@ class Paiement extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) { global $conf, $langs; @@ -1231,12 +1229,12 @@ class Paiement 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 Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1244,7 +1242,7 @@ class Paiement 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 Libelle du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage @@ -1288,14 +1286,14 @@ class Paiement extends CommonObject return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the third party of object, from id into this->thirdparty * * @param int $force_thirdparty_id Force thirdparty id * @return int <0 if KO, >0 if OK */ - function fetch_thirdparty($force_thirdparty_id = 0) + public function fetch_thirdparty($force_thirdparty_id = 0) { // phpcs:enable include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 16c7c2f3f52..142dd1b0e1e 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -81,7 +81,7 @@ class BonPrelevement extends CommonObject * @param DoliDB $db Database handler * @param string $filename Filename of withdraw receipt */ - function __construct($db, $filename = '') + public function __construct($db, $filename = '') { global $conf,$langs; @@ -112,7 +112,7 @@ class BonPrelevement extends CommonObject $this->fetched = 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add invoice to withdrawal * @@ -126,7 +126,7 @@ class BonPrelevement extends CommonObject * @param string $number_key number key of account number * @return int >0 if OK, <0 if KO */ - function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) + public function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) { // phpcs:enable $result = 0; @@ -184,7 +184,7 @@ class BonPrelevement extends CommonObject * @param string $number_key number key of account number * @return int >0 if OK, <0 if KO */ - function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) + public function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) { $result = -1; $concat = 0; @@ -258,7 +258,7 @@ class BonPrelevement extends CommonObject * @param int $error Id of error * @return string Error string */ - function getErrorString($error) + public function getErrorString($error) { global $langs; @@ -276,7 +276,7 @@ class BonPrelevement extends CommonObject * @param string $ref Ref of direct debit * @return int >0 if OK, <0 if KO */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { global $conf; @@ -300,20 +300,20 @@ class BonPrelevement extends CommonObject { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->amount = $obj->amount; - $this->note = $obj->note; - $this->datec = $this->db->jdate($obj->dc); + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->amount = $obj->amount; + $this->note = $obj->note; + $this->datec = $this->db->jdate($obj->dc); - $this->date_trans = $this->db->jdate($obj->date_trans); - $this->method_trans = $obj->method_trans; - $this->user_trans = $obj->fk_user_trans; + $this->date_trans = $this->db->jdate($obj->date_trans); + $this->method_trans = $obj->method_trans; + $this->user_trans = $obj->fk_user_trans; - $this->date_credit = $this->db->jdate($obj->date_credit); - $this->user_credit = $obj->fk_user_credit; + $this->date_credit = $this->db->jdate($obj->date_credit); + $this->user_credit = $obj->fk_user_credit; - $this->statut = $obj->statut; + $this->statut = $obj->statut; $this->fetched = 1; @@ -331,13 +331,13 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set credite and set status of linked invoices. Still used ?? * * @return int <0 if KO, >=0 if OK */ - function set_credite() + public function set_credite() { // phpcs:enable global $user,$conf; @@ -410,7 +410,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set direct debit order to "credited" status. * @@ -418,7 +418,7 @@ class BonPrelevement extends CommonObject * @param int $date date of action * @return int >0 if OK, <0 if KO */ - function set_infocredit($user, $date) + public function set_infocredit($user, $date) { // phpcs:enable global $conf,$langs; @@ -557,7 +557,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set withdrawal to transmited status * @@ -566,7 +566,7 @@ class BonPrelevement extends CommonObject * @param string $method method of transmision to bank * @return int >0 if OK, <0 if KO */ - function set_infotrans($user, $date, $method) + public function set_infotrans($user, $date, $method) { // phpcs:enable global $conf,$langs; @@ -683,13 +683,13 @@ class BonPrelevement extends CommonObject return $arr; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns amount of withdrawal * * @return double Total amount */ - function SommeAPrelever() + public function SommeAPrelever() { // phpcs:enable global $conf; @@ -722,7 +722,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get number of invoices to withdrawal * TODO delete params banque and agence when not necesary @@ -731,7 +731,7 @@ class BonPrelevement extends CommonObject * @param int $agence dolibarr mysoc agence * @return int 0 if OK, <0 if KO */ - function delete($user = null) + public function delete($user = null) { $this->db->begin(); @@ -1178,7 +1178,7 @@ class BonPrelevement extends CommonObject * @param string $option link target * @return string URL of target */ - function getNomUrl($withpicto = 0, $option = '') + public function getNomUrl($withpicto = 0, $option = '') { global $langs; @@ -1200,14 +1200,14 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a notification def by id * * @param int $rowid id of notification * @return int 0 if OK, <0 if KO */ - function DeleteNotificationById($rowid) + public function DeleteNotificationById($rowid) { // phpcs:enable $result = 0; @@ -1225,7 +1225,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a notification * @@ -1233,7 +1233,7 @@ class BonPrelevement extends CommonObject * @param string $action notification action * @return int >0 if OK, <0 if KO */ - function DeleteNotification($user, $action) + public function DeleteNotification($user, $action) { // phpcs:enable $result = 0; @@ -1251,7 +1251,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a notification * @@ -1260,7 +1260,7 @@ class BonPrelevement extends CommonObject * @param string $action notification action * @return int 0 if OK, <0 if KO */ - function AddNotification($db, $user, $action) + public function AddNotification($db, $user, $action) { // phpcs:enable $result = 0; @@ -1299,7 +1299,7 @@ class BonPrelevement extends CommonObject * @param string $executiondate Date to execute transfer * @return int 0 if OK, <0 if KO */ - function generate($format = 'ALL', $executiondate = '') + public function generate($format = 'ALL', $executiondate = '') { global $conf,$langs,$mysoc; @@ -1478,7 +1478,7 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write recipient of request (customer) * @@ -1493,7 +1493,7 @@ class BonPrelevement extends CommonObject * @param string $rib_dom rib domiciliation * @return void */ - function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom = '') + public function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom = '') { // phpcs:enable fputs($this->file, "06"); @@ -1559,14 +1559,14 @@ class BonPrelevement extends CommonObject * @param string $row_drum Id of customer bank account (rib.rowid) * @return string RUM number */ - static function buildRumNumber($row_code_client, $row_datec, $row_drum) + public static function buildRumNumber($row_code_client, $row_datec, $row_drum) { global $langs; $pre = $langs->trans('RUM').'-'; return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write recipient of request (customer) * @@ -1588,7 +1588,7 @@ class BonPrelevement extends CommonObject * @param string $row_drum rib.rowid used to generate rum * @return string Return string with SEPA part DrctDbtTxInf */ - function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum) + public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum) { // phpcs:enable global $conf; @@ -1646,13 +1646,13 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write sender of request (me) * * @return void */ - function EnregEmetteur() + public function EnregEmetteur() { // phpcs:enable fputs($this->file, "03"); @@ -1713,7 +1713,7 @@ class BonPrelevement extends CommonObject fputs($this->file, "\n"); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write sender of request (me). * Note: The tag PmtInf is opened here but closed into caller @@ -1726,7 +1726,7 @@ class BonPrelevement extends CommonObject * @param string $format FRST or RCUR or ALL * @return string String with SEPA Sender */ - function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST') + public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST') { // phpcs:enable // SEPA INITIALISATION @@ -1836,14 +1836,14 @@ class BonPrelevement extends CommonObject return $XML_SEPA_INFO; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write end * * @param int $total total amount * @return void */ - function EnregTotal($total) + public function EnregTotal($total) { // phpcs:enable fputs($this->file, "08"); @@ -1905,12 +1905,12 @@ class BonPrelevement extends CommonObject * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return status label for a status * @@ -1918,7 +1918,7 @@ class BonPrelevement 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 */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable if (empty($this->labelstatut)) @@ -1937,32 +1937,32 @@ class BonPrelevement extends CommonObject elseif ($mode == 2) { if ($statut==0) return img_picto($this->labelstatut[$statut], 'statut1').' '.$this->labelstatut[$statut]; - if ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; - if ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; + elseif ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; + elseif ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; } elseif ($mode == 3) { if ($statut==0) return img_picto($this->labelstatut[$statut], 'statut1'); - if ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3'); - if ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6'); + elseif ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3'); + elseif ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6'); } elseif ($mode == 4) { if ($statut==0) return img_picto($this->labelstatut[$statut], 'statut1').' '.$this->labelstatut[$statut]; - if ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; - if ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; + elseif ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; + elseif ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; } elseif ($mode == 5) { if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut1'); - if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); - if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); + elseif ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); + elseif ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); } elseif ($mode == 6) { if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut1'); - if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); - if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); + elseif ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); + elseif ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); } } } diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 6f9d50ceb07..e76cc9d184d 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -41,7 +41,7 @@ class LignePrelevement */ public $db; - var $statuts = array(); + public $statuts = array(); /** @@ -50,7 +50,7 @@ class LignePrelevement * @param DoliDb $db Database handler * @param User $user Objet user */ - function __construct($db, $user) + public function __construct($db, $user) { global $conf,$langs; @@ -71,7 +71,7 @@ class LignePrelevement * @param int $rowid id de la facture a recuperer * @return integer */ - function fetch($rowid) + public function fetch($rowid) { global $conf; @@ -117,18 +117,18 @@ class LignePrelevement return $result; } -/** + /** * Return status label of object * * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return status label for a status * @@ -136,7 +136,7 @@ class LignePrelevement * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -148,20 +148,20 @@ class LignePrelevement elseif ($mode == 1) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); // Waiting - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); // Credited - if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); // Refused + elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); // Credited + elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); // Refused } elseif ($mode == 2) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); } elseif ($mode == 3) { if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - if ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - if ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + elseif ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + elseif ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); } } diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index f0df56fbec1..27dfe40a74f 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -47,7 +47,7 @@ class RejetPrelevement * @param DoliDb $db Database handler * @param User $user Objet user */ - function __construct($db, $user) + public function __construct($db, $user) { global $langs; @@ -82,7 +82,7 @@ class RejetPrelevement * @param int $facturation Facturation * @return void */ - function create($user, $id, $motif, $date_rejet, $bonid, $facturation = 0) + public function create($user, $id, $motif, $date_rejet, $bonid, $facturation = 0) { global $langs,$conf; @@ -198,14 +198,14 @@ class RejetPrelevement } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Send email to all users that has asked the withdraw request * * @param Facture $fac Invoice object * @return void */ - function _send_email($fac) + private function _send_email($fac) { // phpcs:enable global $langs; @@ -334,7 +334,7 @@ class RejetPrelevement * @param int $rowid id of invoice to retrieve * @return int */ - function fetch($rowid) + public function fetch($rowid) { $sql = "SELECT pr.date_rejet as dr, motif, afacturer"; diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index aad1d9d6e91..40cec40ecad 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -31,681 +31,681 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ class PaymentSalary extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element='payment_salary'; + /** + * @var string ID to identify managed object + */ + public $element='payment_salary'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='payment_salary'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element='payment_salary'; - /** - * @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 String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto='payment'; - public $tms; + public $tms; - /** - * @var int User ID - */ - public $fk_user; + /** + * @var int User ID + */ + public $fk_user; - public $datep; - public $datev; - public $amount; + public $datep; + public $datev; + public $amount; - /** + /** * @var int ID */ - public $fk_project; + public $fk_project; - public $type_payment; - public $num_payment; + public $type_payment; + public $num_payment; - /** + /** * @var string salary payments label */ public $label; - public $datesp; - public $dateep; + public $datesp; + public $dateep; - /** + /** * @var int ID */ - public $fk_bank; + public $fk_bank; - /** + /** * @var int ID */ - public $fk_user_author; + public $fk_user_author; - /** + /** * @var int ID */ - public $fk_user_modif; + public $fk_user_modif; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - $this->element = 'payment_salary'; - $this->table_element = 'payment_salary'; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + $this->element = 'payment_salary'; + $this->table_element = 'payment_salary'; + } - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; - $error=0; + $error=0; - // Clean parameters - $this->fk_user=trim($this->fk_user); - $this->amount=trim($this->amount); - $this->label=trim($this->label); - $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_author=trim($this->fk_user_author); - $this->fk_user_modif=trim($this->fk_user_modif); + // Clean parameters + $this->fk_user=trim($this->fk_user); + $this->amount=trim($this->amount); + $this->label=trim($this->label); + $this->note=trim($this->note); + $this->fk_bank=trim($this->fk_bank); + $this->fk_user_author=trim($this->fk_user_author); + $this->fk_user_modif=trim($this->fk_user_modif); - // Check parameters - if (empty($this->fk_user) || $this->fk_user < 0) - { - $this->error='ErrorBadParameter'; - return -1; - } + // Check parameters + if (empty($this->fk_user) || $this->fk_user < 0) + { + $this->error='ErrorBadParameter'; + return -1; + } - $this->db->begin(); + $this->db->begin(); - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; - $sql.= " tms='".$this->db->idate($this->tms)."',"; - $sql.= " fk_user=".$this->fk_user.","; - $sql.= " datep='".$this->db->idate($this->datep)."',"; - $sql.= " datev='".$this->db->idate($this->datev)."',"; - $sql.= " amount=".price2num($this->amount).","; - $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; - $sql.= " fk_typepayment=".$this->fk_typepayment."',"; - $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " datesp='".$this->db->idate($this->datesp)."',"; - $sql.= " dateep='".$this->db->idate($this->dateep)."',"; - $sql.= " note='".$this->db->escape($this->note)."',"; - $sql.= " fk_bank=".($this->fk_bank > 0 ? "'".$this->db->escape($this->fk_bank)."'":"null").","; - $sql.= " fk_user_author=".$this->fk_user_author.","; - $sql.= " fk_user_modif=".$this->fk_user_modif; + $sql.= " tms='".$this->db->idate($this->tms)."',"; + $sql.= " fk_user=".$this->fk_user.","; + $sql.= " datep='".$this->db->idate($this->datep)."',"; + $sql.= " datev='".$this->db->idate($this->datev)."',"; + $sql.= " amount=".price2num($this->amount).","; + $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; + $sql.= " fk_typepayment=".$this->fk_typepayment."',"; + $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; + $sql.= " label='".$this->db->escape($this->label)."',"; + $sql.= " datesp='".$this->db->idate($this->datesp)."',"; + $sql.= " dateep='".$this->db->idate($this->dateep)."',"; + $sql.= " note='".$this->db->escape($this->note)."',"; + $sql.= " fk_bank=".($this->fk_bank > 0 ? "'".$this->db->escape($this->fk_bank)."'":"null").","; + $sql.= " fk_user_author=".$this->fk_user_author.","; + $sql.= " fk_user_modif=".$this->fk_user_modif; - $sql.= " WHERE rowid=".$this->id; + $sql.= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } - if (! $notrigger) - { + if (! $notrigger) + { // Call trigger $result=$this->call_trigger('PAYMENT_SALARY_MODIFY', $user); if ($result < 0) $error++; // End call triggers - } + } - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - } + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from database - * - * @param int $id id object - * @param User $user User that load - * @return int <0 if KO, >0 if OK - */ - function fetch($id, $user = null) - { - global $langs; - $sql = "SELECT"; - $sql.= " s.rowid,"; + /** + * Load object in memory from database + * + * @param int $id id object + * @param User $user User that load + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $user = null) + { + global $langs; + $sql = "SELECT"; + $sql.= " s.rowid,"; - $sql.= " s.tms,"; - $sql.= " s.fk_user,"; - $sql.= " s.datep,"; - $sql.= " s.datev,"; - $sql.= " s.amount,"; - $sql.= " s.fk_projet as fk_project,"; - $sql.= " s.fk_typepayment,"; - $sql.= " s.num_payment,"; - $sql.= " s.label,"; - $sql.= " s.datesp,"; - $sql.= " s.dateep,"; - $sql.= " s.note,"; - $sql.= " s.fk_bank,"; - $sql.= " s.fk_user_author,"; - $sql.= " s.fk_user_modif,"; - $sql.= " b.fk_account,"; - $sql.= " b.fk_type,"; - $sql.= " b.rappro"; + $sql.= " s.tms,"; + $sql.= " s.fk_user,"; + $sql.= " s.datep,"; + $sql.= " s.datev,"; + $sql.= " s.amount,"; + $sql.= " s.fk_projet as fk_project,"; + $sql.= " s.fk_typepayment,"; + $sql.= " s.num_payment,"; + $sql.= " s.label,"; + $sql.= " s.datesp,"; + $sql.= " s.dateep,"; + $sql.= " s.note,"; + $sql.= " s.fk_bank,"; + $sql.= " s.fk_user_author,"; + $sql.= " s.fk_user_modif,"; + $sql.= " b.fk_account,"; + $sql.= " b.fk_type,"; + $sql.= " b.rappro"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; - $sql.= " WHERE s.rowid = ".$id; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; + $sql.= " WHERE s.rowid = ".$id; - 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->tms = $this->db->jdate($obj->tms); - $this->fk_user = $obj->fk_user; - $this->datep = $this->db->jdate($obj->datep); - $this->datev = $this->db->jdate($obj->datev); - $this->amount = $obj->amount; - $this->fk_project = $obj->fk_project; - $this->type_payement = $obj->fk_typepayment; - $this->num_payment = $obj->num_payment; - $this->label = $obj->label; - $this->datesp = $this->db->jdate($obj->datesp); - $this->dateep = $this->db->jdate($obj->dateep); - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_modif = $obj->fk_user_modif; - $this->fk_account = $obj->fk_account; - $this->fk_type = $obj->fk_type; - $this->rappro = $obj->rappro; - } - $this->db->free($resql); + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); + $this->fk_user = $obj->fk_user; + $this->datep = $this->db->jdate($obj->datep); + $this->datev = $this->db->jdate($obj->datev); + $this->amount = $obj->amount; + $this->fk_project = $obj->fk_project; + $this->type_payement = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->label = $obj->label; + $this->datesp = $this->db->jdate($obj->datesp); + $this->dateep = $this->db->jdate($obj->dateep); + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_modif = $obj->fk_user_modif; + $this->fk_account = $obj->fk_account; + $this->fk_type = $obj->fk_type; + $this->rappro = $obj->rappro; + } + $this->db->free($resql); - return 1; - } - else - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK - */ - function delete($user) - { - global $conf, $langs; + /** + * Delete object in database + * + * @param User $user User that delete + * @return int <0 if KO, >0 if OK + */ + public function delete($user) + { + global $conf, $langs; - $error=0; + $error=0; - // Call trigger - $result=$this->call_trigger('PAYMENT_SALARY_DELETE', $user); - if ($result < 0) return -1; - // End call triggers + // Call trigger + $result=$this->call_trigger('PAYMENT_SALARY_DELETE', $user); + if ($result < 0) return -1; + // End call triggers - $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; - $sql.= " WHERE rowid=".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; + $sql.= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } - return 1; - } + return 1; + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - function initAsSpecimen() - { - $this->id=0; + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + $this->id=0; - $this->tms=''; - $this->fk_user=''; - $this->datep=''; - $this->datev=''; - $this->amount=''; - $this->label=''; - $this->datesp=''; - $this->dateep=''; - $this->note=''; - $this->fk_bank=''; - $this->fk_user_author=''; - $this->fk_user_modif=''; - } + $this->tms=''; + $this->fk_user=''; + $this->datep=''; + $this->datev=''; + $this->amount=''; + $this->label=''; + $this->datesp=''; + $this->dateep=''; + $this->note=''; + $this->fk_bank=''; + $this->fk_user_author=''; + $this->fk_user_modif=''; + } - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - function create($user) - { - global $conf,$langs; + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf,$langs; - $error=0; - $now=dol_now(); + $error=0; + $now=dol_now(); - // Clean parameters - $this->amount=price2num(trim($this->amount)); - $this->label=trim($this->label); - $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_author=trim($this->fk_user_author); - $this->fk_user_modif=trim($this->fk_user_modif); + // Clean parameters + $this->amount=price2num(trim($this->amount)); + $this->label=trim($this->label); + $this->note=trim($this->note); + $this->fk_bank=trim($this->fk_bank); + $this->fk_user_author=trim($this->fk_user_author); + $this->fk_user_modif=trim($this->fk_user_modif); - // Check parameters - if (! $this->label) - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); - return -3; - } - if ($this->fk_user < 0 || $this->fk_user == '') - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); - return -4; - } - if ($this->amount < 0 || $this->amount == '') - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - return -5; - } - if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -6; - } - if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -7; - } + // Check parameters + if (! $this->label) + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + return -3; + } + if ($this->fk_user < 0 || $this->fk_user == '') + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); + return -4; + } + if ($this->amount < 0 || $this->amount == '') + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + return -5; + } + if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + return -6; + } + if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + return -7; + } - $this->db->begin(); + $this->db->begin(); - // Insert into llx_payment_salary - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; - $sql.= ", datep"; - $sql.= ", datev"; - $sql.= ", amount"; - $sql.= ", fk_projet"; - $sql.= ", salary"; - $sql.= ", fk_typepayment"; - $sql.= ", num_payment"; - if ($this->note) $sql.= ", note"; - $sql.= ", label"; - $sql.= ", datesp"; - $sql.= ", dateep"; - $sql.= ", fk_user_author"; - $sql.= ", datec"; - $sql.= ", fk_bank"; - $sql.= ", entity"; - $sql.= ") "; - $sql.= " VALUES ("; - $sql.= "'".$this->db->escape($this->fk_user)."'"; - $sql.= ", '".$this->db->idate($this->datep)."'"; - $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", ".$this->amount; - $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0); - $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); - $sql.= ", ".$this->db->escape($this->type_payment); - $sql.= ", '".$this->db->escape($this->num_payment)."'"; - if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->db->idate($this->datesp)."'"; - $sql.= ", '".$this->db->idate($this->dateep)."'"; - $sql.= ", '".$this->db->escape($user->id)."'"; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", NULL"; - $sql.= ", ".$conf->entity; - $sql.= ")"; + // Insert into llx_payment_salary + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; + $sql.= ", datep"; + $sql.= ", datev"; + $sql.= ", amount"; + $sql.= ", fk_projet"; + $sql.= ", salary"; + $sql.= ", fk_typepayment"; + $sql.= ", num_payment"; + if ($this->note) $sql.= ", note"; + $sql.= ", label"; + $sql.= ", datesp"; + $sql.= ", dateep"; + $sql.= ", fk_user_author"; + $sql.= ", datec"; + $sql.= ", fk_bank"; + $sql.= ", entity"; + $sql.= ") "; + $sql.= " VALUES ("; + $sql.= "'".$this->db->escape($this->fk_user)."'"; + $sql.= ", '".$this->db->idate($this->datep)."'"; + $sql.= ", '".$this->db->idate($this->datev)."'"; + $sql.= ", ".$this->amount; + $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0); + $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); + $sql.= ", ".$this->db->escape($this->type_payment); + $sql.= ", '".$this->db->escape($this->num_payment)."'"; + if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; + $sql.= ", '".$this->db->escape($this->label)."'"; + $sql.= ", '".$this->db->idate($this->datesp)."'"; + $sql.= ", '".$this->db->idate($this->dateep)."'"; + $sql.= ", '".$this->db->escape($user->id)."'"; + $sql.= ", '".$this->db->idate($now)."'"; + $sql.= ", NULL"; + $sql.= ", ".$conf->entity; + $sql.= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); - if ($this->id > 0) - { - if (! empty($conf->banque->enabled) && ! empty($this->amount)) - { - // Insert into llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if ($this->id > 0) + { + if (! empty($conf->banque->enabled) && ! empty($this->amount)) + { + // Insert into llx_bank + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acc = new Account($this->db); - $result=$acc->fetch($this->accountid); - if ($result <= 0) dol_print_error($this->db); + $acc = new Account($this->db); + $result=$acc->fetch($this->accountid); + if ($result <= 0) dol_print_error($this->db); - // Insert payment into llx_bank - // Add link 'payment_salary' in bank_url between payment and bank transaction - $bank_line_id = $acc->addline( - $this->datep, - $this->type_payment, - $this->label, - -abs($this->amount), - $this->num_payment, - '', - $user, - '', - '', - '', - $this->datev - ); + // Insert payment into llx_bank + // Add link 'payment_salary' in bank_url between payment and bank transaction + $bank_line_id = $acc->addline( + $this->datep, + $this->type_payment, + $this->label, + -abs($this->amount), + $this->num_payment, + '', + $user, + '', + '', + '', + $this->datev + ); - // Update fk_bank into llx_paiement. - // So we know the payment which has generate the banking ecriture - if ($bank_line_id > 0) - { - $this->update_fk_bank($bank_line_id); - } - else - { - $this->error=$acc->error; - $error++; - } + // Update fk_bank into llx_paiement. + // So we know the payment which has generate the banking ecriture + if ($bank_line_id > 0) + { + $this->update_fk_bank($bank_line_id); + } + else + { + $this->error=$acc->error; + $error++; + } - if (! $error) - { - // Add link 'payment_salary' in bank_url between payment and bank transaction - $url=DOL_URL_ROOT.'/compta/salaries/card.php?id='; + if (! $error) + { + // Add link 'payment_salary' in bank_url between payment and bank transaction + $url=DOL_URL_ROOT.'/compta/salaries/card.php?id='; - $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); - if ($result <= 0) - { - $this->error=$acc->error; - $error++; - } - } + $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); + if ($result <= 0) + { + $this->error=$acc->error; + $error++; + } + } - $fuser=new User($this->db); - $fuser->fetch($this->fk_user); + $fuser=new User($this->db); + $fuser->fetch($this->fk_user); - // Add link 'user' in bank_url between operation and bank transaction - $result=$acc->add_url_line( - $bank_line_id, - $this->fk_user, - DOL_URL_ROOT.'/user/card.php?id=', - $fuser->getFullName($langs), - // $langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'), - 'user' - ); + // Add link 'user' in bank_url between operation and bank transaction + $result=$acc->add_url_line( + $bank_line_id, + $this->fk_user, + DOL_URL_ROOT.'/user/card.php?id=', + $fuser->getFullName($langs), + // $langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'), + 'user' + ); - if ($result <= 0) - { - $this->error=$acc->error; - $error++; - } - } + if ($result <= 0) + { + $this->error=$acc->error; + $error++; + } + } - // Call trigger - $result=$this->call_trigger('PAYMENT_SALARY_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } - else $error++; + // Call trigger + $result=$this->call_trigger('PAYMENT_SALARY_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } + else $error++; - if (! $error) - { - $this->db->commit(); - return $this->id; - } - else - { - $this->db->rollback(); - return -2; - } - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Update link between payment salary and line generate into llx_bank - * - * @param int $id_bank Id bank account - * @return int <0 if KO, >0 if OK - */ - function update_fk_bank($id_bank) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Update link between payment salary and line generate into llx_bank + * + * @param int $id_bank Id bank account + * @return int <0 if KO, >0 if OK + */ + public function update_fk_bank($id_bank) + { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; - $sql.= ' WHERE rowid = '.$this->id; - $result = $this->db->query($sql); - if ($result) - { - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } - } + $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; + $sql.= ' WHERE rowid = '.$this->id; + $result = $this->db->query($sql); + if ($result) + { + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } - /** - * Send name clicable (with possibly the picto) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param string $option link option + /** + * Send name clicable (with possibly the picto) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param string $option link option * @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 Chaine with URL - */ - 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; + * @return string Chaine 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; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $result = ''; + $result = ''; - $label = '' . $langs->trans("ShowSalaryPayment") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = '' . $langs->trans("ShowSalaryPayment") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; - $url = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$this->id; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; - } + 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'; + } - $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:'').'"'; + $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:'').'"'; - /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ - } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + /* + $hookmanager->initHooks(array('myobjectdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + 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; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $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; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; - $hookmanager->initHooks(array('salarypayment')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + global $action,$hookmanager; + $hookmanager->initHooks(array('salarypayment')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * Information on record - * - * @param int $id Id of record - * @return void - */ - function info($id) - { - $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; - $sql.= ' WHERE ps.rowid = '.$id; + /** + * Information on record + * + * @param int $id Id of record + * @return void + */ + public function info($id) + { + $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; + $sql.= ' WHERE ps.rowid = '.$id; - dol_syslog(get_class($this).'::info', LOG_DEBUG); - $result = $this->db->query($sql); + dol_syslog(get_class($this).'::info', LOG_DEBUG); + $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - $this->date_creation = $this->db->jdate($obj->datec); - } - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + $this->date_creation = $this->db->jdate($obj->datec); + } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } - /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) - * - * @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 = 0) - { - return $this->LibStatut($this->statut, $mode); - } + /** + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @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 = 0) + { + return $this->LibStatut($this->statut, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $status 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 Libelle du statut - */ - function LibStatut($status, $mode = 0) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status 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 Libelle du statut + */ + public function LibStatut($status, $mode = 0) + { // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - $langs->load('compta'); - /*if ($mode == 0) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 1) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 2) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 5) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 6) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - }*/ - return ''; - } + $langs->load('compta'); + /*if ($mode == 0) + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 1) + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 2) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 3) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 4) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 5) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 6) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + }*/ + return ''; + } } diff --git a/htdocs/compta/salaries/class/salariesstats.class.php b/htdocs/compta/salaries/class/salariesstats.class.php index c1249abedac..0287f4978df 100644 --- a/htdocs/compta/salaries/class/salariesstats.class.php +++ b/htdocs/compta/salaries/class/salariesstats.class.php @@ -29,138 +29,137 @@ include_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php */ class SalariesStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param int $socid Id third party - * @param mixed $userid Id user for filter or array of user ids - * @return void - */ - function __construct($db, $socid = 0, $userid = 0) - { - global $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param int $socid Id third party + * @param mixed $userid Id user for filter or array of user ids + * @return void + */ + public function __construct($db, $socid = 0, $userid = 0) + { + global $conf; - $this->db = $db; - $this->socid = $socid; - $this->userid = $userid; + $this->db = $db; + $this->socid = $socid; + $this->userid = $userid; - $object=new PaymentSalary($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element; - $this->field='amount'; + $object=new PaymentSalary($this->db); + $this->from = MAIN_DB_PREFIX.$object->table_element; + $this->field='amount'; - $this->where.= " entity = ".$conf->entity; - if ($this->socid) - { - $this->where.=" AND fk_soc = ".$this->socid; - } - if (is_array($this->userid) && count($this->userid) > 0) $this->where.=' AND fk_user IN ('.join(',', $this->userid).')'; - elseif ($this->userid > 0) $this->where.=' AND fk_user = '.$this->userid; - } + $this->where.= " entity = ".$conf->entity; + if ($this->socid) { + $this->where.=" AND fk_soc = ".$this->socid; + } + if (is_array($this->userid) && count($this->userid) > 0) $this->where.=' AND fk_user IN ('.join(',', $this->userid).')'; + elseif ($this->userid > 0) $this->where.=' AND fk_user = '.$this->userid; + } - /** - * Return the number of salary by year - * - * @return array Array of values - */ - function getNbByYear() - { - $sql = "SELECT YEAR(datep) as dm, count(*)"; - $sql.= " FROM ".$this->from; - $sql.= " GROUP BY dm DESC"; - $sql.= " WHERE ".$this->where; + /** + * Return the number of salary by year + * + * @return array Array of values + */ + public function getNbByYear() + { + $sql = "SELECT YEAR(datep) as dm, count(*)"; + $sql.= " FROM ".$this->from; + $sql.= " GROUP BY dm DESC"; + $sql.= " WHERE ".$this->where; - return $this->_getNbByYear($sql); - } + return $this->_getNbByYear($sql); + } - /** - * Return the number of salary by month, for a given year - * - * @param string $year Year to scan - * @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 values - */ - function getNbByMonth($year, $format = 0) - { - $sql = "SELECT MONTH(datep) as dm, count(*)"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE YEAR(datep) = ".$year; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + /** + * Return the number of salary by month, for a given year + * + * @param string $year Year to scan + * @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 values + */ + public function getNbByMonth($year, $format = 0) + { + $sql = "SELECT MONTH(datep) as dm, count(*)"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE YEAR(datep) = ".$year; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; + $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); - //var_dump($res);print '
'; - return $res; - } + $res=$this->_getNbByMonth($year, $sql, $format); + //var_dump($res);print '
'; + return $res; + } - /** - * Return amount of salaries by month for a given year - * - * @param int $year Year to scan - * @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 values - */ - function getAmountByMonth($year, $format = 0) - { - $sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + /** + * Return amount of salaries by month for a given year + * + * @param int $year Year to scan + * @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 values + */ + public function getAmountByMonth($year, $format = 0) + { + $sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; + $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); - //var_dump($res);print '
'; - return $res; - } + $res=$this->_getAmountByMonth($year, $sql, $format); + //var_dump($res);print '
'; + return $res; + } - /** - * Return average amount - * - * @param int $year Year to scan - * @return array Array of values - */ - function getAverageByMonth($year) - { - $sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + /** + * Return average amount + * + * @param int $year Year to scan + * @return array Array of values + */ + public function getAverageByMonth($year) + { + $sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; + $sql.= $this->db->order('dm', 'DESC'); - return $this->_getAverageByMonth($year, $sql); - } + return $this->_getAverageByMonth($year, $sql); + } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - $sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + $sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; + $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 49cf2ec4560..1cb304fe519 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -404,7 +404,7 @@ class Cchargesociales * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -438,12 +438,12 @@ class Cchargesociales * @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 status donne * @@ -451,7 +451,7 @@ class Cchargesociales * @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 = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 8600e21b2ea..41c9555ccfc 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -81,7 +81,7 @@ class ChargeSociales extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -93,7 +93,7 @@ class ChargeSociales extends CommonObject * @param string $ref Ref * @return int <0 KO >0 OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { $sql = "SELECT cs.rowid, cs.date_ech"; $sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; @@ -152,7 +152,7 @@ class ChargeSociales extends CommonObject * * @return boolean True or false */ - function check() + public function check() { $newamount=price2num($this->amount, 'MT'); @@ -172,7 +172,7 @@ class ChargeSociales extends CommonObject * @param User $user User making creation * @return int <0 if KO, id if OK */ - function create($user) + public function create($user) { global $conf; $error=0; @@ -182,8 +182,7 @@ class ChargeSociales extends CommonObject // Nettoyage parametres $newamount=price2num($this->amount, 'MT'); - if (!$this->check()) - { + if (!$this->check()) { $this->error="ErrorBadParameter"; return -2; } @@ -206,8 +205,7 @@ class ChargeSociales extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); //dol_syslog("ChargesSociales::create this->id=".$this->id); @@ -238,7 +236,7 @@ class ChargeSociales extends CommonObject * @param User $user Object user making delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { $error=0; @@ -309,7 +307,7 @@ class ChargeSociales extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { $error=0; $this->db->begin(); @@ -365,7 +363,7 @@ class ChargeSociales extends CommonObject * @param int $year Year * @return number */ - function solde($year = 0) + public function solde($year = 0) { global $conf; @@ -399,14 +397,14 @@ class ChargeSociales extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag social contribution as payed completely * * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ - function set_paid($user) + public function set_paid($user) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; @@ -417,14 +415,14 @@ class ChargeSociales extends CommonObject else return -1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove tag payed on social contribution * * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ - function set_unpaid($user) + public function set_unpaid($user) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; @@ -442,12 +440,12 @@ class ChargeSociales extends CommonObject * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ - function getLibStatut($mode = 0, $alreadypaid = -1) + public function getLibStatut($mode = 0, $alreadypaid = -1) { return $this->LibStatut($this->paye, $mode, $alreadypaid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -456,7 +454,7 @@ class ChargeSociales extends CommonObject * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ - function LibStatut($statut, $mode = 0, $alreadypaid = -1) + public function LibStatut($statut, $mode = 0, $alreadypaid = -1) { // phpcs:enable global $langs; @@ -467,37 +465,37 @@ class ChargeSociales extends CommonObject if ($mode == 0 || $mode == 1) { if ($statut == 0) return $langs->trans("Unpaid"); - if ($statut == 1) return $langs->trans("Paid"); + elseif ($statut == 1) return $langs->trans("Paid"); } elseif ($mode == 2) { if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); } elseif ($mode == 3) { if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); + elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); } elseif ($mode == 4) { if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); } elseif ($mode == 5) { if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + elseif ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } elseif ($mode == 6) { if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + elseif ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } else return "Error, mode/status not found"; @@ -514,7 +512,7 @@ class ChargeSociales 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 link */ - function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user, $form; @@ -574,7 +572,7 @@ class ChargeSociales extends CommonObject * * @return int Amount of payment already done, <0 if KO */ - function getSommePaiement() + public function getSommePaiement() { $table='paiementcharge'; $field='fk_charge'; @@ -585,8 +583,7 @@ class ChargeSociales extends CommonObject dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { + if ($resql) { $amount=0; $obj = $this->db->fetch_object($resql); @@ -607,7 +604,7 @@ class ChargeSociales extends CommonObject * @param int $id Id of social contribution * @return int <0 if KO, >0 if OK */ - function info($id) + public function info($id) { $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; $sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; @@ -663,7 +660,7 @@ class ChargeSociales extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { // Initialize parameters $this->id=0; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 4969b8f9b79..0fe747d0a86 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -91,7 +91,7 @@ class PaymentSocialContribution extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -104,7 +104,7 @@ class PaymentSocialContribution extends CommonObject * @param int $closepaidcontrib 1=Also close payed contributions to paid, 0=Do nothing more * @return int <0 if KO, id of payment if OK */ - function create($user, $closepaidcontrib = 0) + public function create($user, $closepaidcontrib = 0) { global $conf, $langs; @@ -221,7 +221,7 @@ class PaymentSocialContribution extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -292,7 +292,7 @@ class PaymentSocialContribution 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 PaymentSocialContribution 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; @@ -409,10 +409,10 @@ class PaymentSocialContribution extends CommonObject if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -422,8 +422,8 @@ class PaymentSocialContribution extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback if ($error) @@ -451,7 +451,7 @@ class PaymentSocialContribution extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -510,7 +510,7 @@ class PaymentSocialContribution extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -540,7 +540,7 @@ class PaymentSocialContribution extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $conf; @@ -624,14 +624,14 @@ class PaymentSocialContribution extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -656,12 +656,12 @@ class PaymentSocialContribution 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 Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -669,7 +669,7 @@ class PaymentSocialContribution 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 Libelle du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage @@ -720,7 +720,7 @@ class PaymentSocialContribution extends CommonObject * @param int $maxlen Longueur max libelle * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; @@ -729,16 +729,15 @@ class PaymentSocialContribution extends CommonObject if (empty($this->ref)) $this->ref=$this->lib; $label = $langs->trans("ShowPayment").': '.$this->ref; - if (!empty($this->id)) - { - $link = ''; - $linkend=''; + if (!empty($this->id)) { + $link = ''; + $linkend=''; if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; - } + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; + } - return $result; - } + return $result; + } } diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index c66e19ea5f2..b1f99275c93 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -81,7 +81,7 @@ class Tva extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -93,7 +93,7 @@ class Tva extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -173,7 +173,7 @@ class Tva extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; @@ -241,7 +241,7 @@ class Tva extends CommonObject * @param User $user User that load * @return int <0 if KO, >0 if OK */ - function fetch($id, $user = null) + public function fetch($id, $user = null) { global $langs; $sql = "SELECT"; @@ -309,7 +309,7 @@ class Tva extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { global $conf, $langs; @@ -343,7 +343,7 @@ class Tva extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -365,7 +365,7 @@ class Tva extends CommonObject * @param int $year Year * @return double Amount */ - function solde($year = 0) + public function solde($year = 0) { $reglee = $this->tva_sum_reglee($year); @@ -378,14 +378,14 @@ class Tva extends CommonObject return $solde; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Total of the VAT from invoices emitted by the thirdparty. * * @param int $year Year * @return double Amount */ - function tva_sum_collectee($year = 0) + public function tva_sum_collectee($year = 0) { // phpcs:enable @@ -419,14 +419,14 @@ class Tva extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * VAT payed * * @param int $year Year * @return double Amount */ - function tva_sum_payee($year = 0) + public function tva_sum_payee($year = 0) { // phpcs:enable @@ -461,14 +461,14 @@ class Tva extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Total of the VAT payed * * @param int $year Year * @return double Amount */ - function tva_sum_reglee($year = 0) + public function tva_sum_reglee($year = 0) { // phpcs:enable @@ -510,7 +510,7 @@ class Tva extends CommonObject * @param User $user Object user that insert * @return int <0 if KO, rowid in tva table if OK */ - function addPayment($user) + public function addPayment($user) { global $conf,$langs; @@ -654,14 +654,14 @@ class Tva extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between payment tva and line generate into llx_bank * * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank; @@ -687,7 +687,7 @@ class Tva extends CommonObject * @param string $morecss More CSS * @return string Chaine with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '') { global $langs, $conf; @@ -733,7 +733,7 @@ class Tva extends CommonObject * * @return int Amount of payment already done, <0 if KO */ - function getSommePaiement() + public function getSommePaiement() { $table='paiementcharge'; $field='fk_charge'; @@ -766,7 +766,7 @@ class Tva extends CommonObject * @param int $id Id of vat payment * @return int <0 if KO, >0 if OK */ - function info($id) + public function info($id) { $sql = "SELECT t.rowid, t.tms, t.fk_user_modif, t.datec, t.fk_user_creat"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; @@ -813,12 +813,12 @@ class Tva 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 Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -826,7 +826,7 @@ class Tva 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 Libelle du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index b78b279122b..9dafaa58f05 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -32,15 +32,15 @@ abstract class ActionsContactCardCommon */ 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) @@ -60,7 +60,7 @@ abstract class ActionsContactCardCommon * @param int $id Object id * @return object Object loaded */ - function getObject($id) + public function getObject($id) { /*$ret = $this->getInstanceDao(); @@ -76,7 +76,7 @@ abstract class ActionsContactCardCommon //} } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set content of ->tpl array, to use into template * @@ -84,7 +84,7 @@ abstract class ActionsContactCardCommon * @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; @@ -315,9 +315,9 @@ abstract class ActionsContactCardCommon { dol_print_error($this->db); } - $this->object->country_id = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $this->object->country_id = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; } } } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index eee24315dab..4bc23beb2d3 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -37,9 +37,9 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param string $targetmodule Name of directory of module 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; @@ -66,7 +66,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -74,7 +74,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param int $id Id * @return void */ - function assign_values(&$action, $id) + public function assign_values(&$action, $id) { // phpcs:enable global $limit, $offset, $sortfield, $sortorder; @@ -121,7 +121,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -131,13 +131,13 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @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; + global $conf, $langs; //$this->getFieldList(); $this->list_datas = array(); - } + } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 70558efcb9b..dff432690be 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -189,6 +189,7 @@ if (empty($reshook)) $object->skype = GETPOST("skype", 'alpha'); $object->twitter = GETPOST("twitter", 'alpha'); $object->facebook = GETPOST("facebook", 'alpha'); + $object->linkedin = GETPOST("linkedin", 'alpha'); $object->email = GETPOST("email", 'alpha'); $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); @@ -362,6 +363,7 @@ if (empty($reshook)) $object->skype = GETPOST("skype", 'alpha'); $object->twitter = GETPOST("twitter", 'alpha'); $object->facebook = GETPOST("facebook", 'alpha'); + $object->linkedin = GETPOST("linkedin", 'alpha'); $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); @@ -698,6 +700,12 @@ else print '
'; print ''; } + // LinkedIn + if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + { + print ''; + print ''; + } } // Visibility @@ -979,11 +987,17 @@ else print ''; } // Facebook - if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - { - print ''; - print ''; - } + if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + { + print ''; + print ''; + } + // LinkedIn + if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + { + print ''; + print ''; + } } // Visibility diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 67b3900ec06..73f27f8ec1c 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -143,19 +143,19 @@ class Contact extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->statut = 1; // By default, status is enabled } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -200,7 +200,7 @@ class Contact extends CommonObject * @param User $user Object user that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -273,7 +273,7 @@ class Contact extends CommonObject } } - if (! $error) + if (! $error) { // Call trigger $result=$this->call_trigger('CONTACT_CREATE', $user); @@ -313,7 +313,7 @@ class Contact extends CommonObject * @param int $nosyncuser No sync linked user (external users and contacts are linked) * @return int <0 if KO, >0 if OK */ - function update($id, $user = null, $notrigger = 0, $action = 'update', $nosyncuser = 0) + public function update($id, $user = null, $notrigger = 0, $action = 'update', $nosyncuser = 0) { global $conf, $langs, $hookmanager; @@ -359,6 +359,7 @@ class Contact extends CommonObject $sql .= ", skype='".$this->db->escape($this->skype)."'"; $sql .= ", twitter='".$this->db->escape($this->twitter)."'"; $sql .= ", facebook='".$this->db->escape($this->facebook)."'"; + $sql .= ", linkedin='".$this->db->escape($this->linkedin)."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); @@ -455,6 +456,11 @@ class Contact extends CommonObject $tmpobj->facebook = $this->facebook; $usermustbemodified++; } + if ($tmpobj->linkedin != $this->linkedin) + { + $tmpobj->linkedin = $this->linkedin; + $usermustbemodified++; + } if ($usermustbemodified) { $result=$tmpobj->update($user, 0, 1, 1, 1); @@ -491,7 +497,7 @@ class Contact 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 * @@ -501,7 +507,7 @@ class Contact 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; @@ -513,13 +519,13 @@ class Contact 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; @@ -588,7 +594,7 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update field alert birthday * @@ -597,7 +603,7 @@ class Contact extends CommonObject * @param int $notrigger 0=no, 1=yes * @return int <0 if KO, >=0 if OK */ - function update_perso($id, $user = null, $notrigger = 0) + public function update_perso($id, $user = null, $notrigger = 0) { // phpcs:enable $error=0; @@ -686,7 +692,7 @@ class Contact extends CommonObject * @param string $email Email * @return int -1 if KO, 0 if OK but not found, 1 if OK */ - function fetch($id, $user = null, $ref_ext = '', $email = '') + public function fetch($id, $user = null, $ref_ext = '', $email = '') { global $langs; @@ -705,7 +711,7 @@ class Contact extends CommonObject $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement,"; $sql.= " c.birthday,"; - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook,"; + $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook, c.linkedin,"; $sql.= " c.photo,"; $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; $sql.= " c.import_key,"; @@ -779,6 +785,7 @@ class Contact extends CommonObject $this->skype = $obj->skype; $this->twitter = $obj->twitter; $this->facebook = $obj->facebook; + $this->linkedin = $obj->linkedin; $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; @@ -869,7 +876,7 @@ class Contact extends CommonObject * * @return void */ - function setGenderFromCivility() + public function setGenderFromCivility() { unset($this->gender); if (in_array($this->civility_id, array('MR'))) { @@ -879,7 +886,7 @@ class Contact extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load number of elements the contact is used as a link for * ref_facturation @@ -889,7 +896,7 @@ class Contact extends CommonObject * * @return int <0 if KO, >=0 if OK */ - function load_ref_elements() + public function load_ref_elements() { // phpcs:enable // Compte les elements pour lesquels il est contact @@ -931,7 +938,7 @@ class Contact extends CommonObject * @param int $notrigger Disable all trigger * @return int <0 if KO, >0 if OK */ - function delete($notrigger = 0) + public function delete($notrigger = 0) { global $conf, $langs, $user; @@ -1045,7 +1052,7 @@ class Contact extends CommonObject * @param int $id Id du contact a charger * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, c.datec as datec, c.fk_user_creat,"; $sql.= " c.tms as tms, c.fk_user_modif"; @@ -1090,7 +1097,7 @@ class Contact 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, ".MAIN_DB_PREFIX."mailing as m"; @@ -1125,7 +1132,7 @@ class Contact extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $moreparam = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $moreparam = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs, $hookmanager; @@ -1203,7 +1210,7 @@ class Contact extends CommonObject * * @return string Translated name of civility */ - function getCivilityLabel() + public function getCivilityLabel() { global $langs; $langs->load("dict"); @@ -1219,12 +1226,12 @@ class Contact 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 contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1232,7 +1239,7 @@ class Contact 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 Libelle */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1270,14 +1277,14 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label of Public or Private * * @param int $statut Type (0 = public, 1 = private) * @return string Label translated */ - function LibPubPriv($statut) + public function LibPubPriv($statut) { // phpcs:enable global $langs; @@ -1293,14 +1300,13 @@ class Contact extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { // Get first id of existing company and save it into $socid $socid = 0; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe ORDER BY rowid LIMIT 1"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); if ($obj) $socid=$obj->rowid; } @@ -1337,7 +1343,7 @@ class Contact extends CommonObject * @param int $statut Status to set * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - function setstatus($statut) + public function setstatus($statut) { global $conf,$langs,$user; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index aa27e43ee71..4419c087a3c 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 Josep Lluís Amador * * 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 @@ -68,9 +69,11 @@ $search_phone_pro=GETPOST("search_phone_pro", 'alpha'); $search_phone_mobile=GETPOST("search_phone_mobile", 'alpha'); $search_fax=GETPOST("search_fax", 'alpha'); $search_email=GETPOST("search_email", 'alpha'); +$search_no_email=GETPOST("search_no_email", 'int'); $search_skype=GETPOST("search_skype", 'alpha'); $search_twitter=GETPOST("search_twitter", 'alpha'); $search_facebook=GETPOST("search_facebook", 'alpha'); +$search_linkedin=GETPOST("search_linkedin", 'alpha'); $search_priv=GETPOST("search_priv", 'alpha'); $search_categ=GETPOST("search_categ", 'int'); $search_categ_thirdparty=GETPOST("search_categ_thirdparty", 'int'); @@ -159,10 +162,12 @@ $arrayfields=array( 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1), 'p.fax'=>array('label'=>"Fax", 'checked'=>0), 'p.email'=>array('label'=>"EMail", 'checked'=>1), + 'p.no_email'=>array('label'=>"No_Email", 'checked'=>0, 'enabled'=>(! empty($conf->mailing->enabled))), 'p.jabberid'=>array('label'=>"Jabber", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.twitter'=>array('label'=>"Twitter", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.facebook'=>array('label'=>"Facebook", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), + 'p.linkedin'=>array('label'=>"LinkedIn", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.thirdparty'=>array('label'=>"ThirdParty", 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200), 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), @@ -222,9 +227,11 @@ if (empty($reshook)) $search_phone_mobile=""; $search_fax=""; $search_email=""; + $search_no_email=-1; $search_skype=""; $search_twitter=""; $search_facebook=""; + $search_linkedin=""; $search_priv=""; $search_status=-1; $search_categ=''; @@ -258,7 +265,7 @@ $contactstatic=new Contact($db); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); $sql = "SELECT s.rowid as socid, s.nom as name,"; -$sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.skype,"; +$sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email, p.skype,"; $sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql.= " co.code as country_code"; // Add fields from extrafields @@ -321,10 +328,12 @@ if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax); if (strlen($search_skype)) $sql.= natural_search('p.skype', $search_skype); if (strlen($search_twitter)) $sql.= natural_search('p.twitter', $search_twitter); if (strlen($search_facebook)) $sql.= natural_search('p.facebook', $search_facebook); +if (strlen($search_linkedin)) $sql.= natural_search('p.linkedin', $search_linkedin); if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip); if (strlen($search_town)) $sql.= natural_search("p.town", $search_town); +if ($search_no_email != '' && $search_no_email >= 0) $sql.= " AND p.no_email = ".$db->escape($search_no_email); if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql.= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type @@ -422,6 +431,7 @@ if ($search_phone_perso != '') $param.='&search_phone_perso='.urlencode($sea if ($search_phone_mobile != '') $param.='&search_phone_mobile='.urlencode($search_phone_mobile); if ($search_fax != '') $param.='&search_fax='.urlencode($search_fax); if ($search_email != '') $param.='&search_email='.urlencode($search_email); +if ($search_no_email != '') $param.='&search_no_email='.urlencode($search_no_email); if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv); if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); @@ -574,7 +584,7 @@ if (! empty($arrayfields['p.town']['checked'])) if (! empty($arrayfields['country.code_iso']['checked'])) { print ''; } if (! empty($arrayfields['p.phone']['checked'])) @@ -607,6 +617,12 @@ if (! empty($arrayfields['p.email']['checked'])) print ''; print ''; } +if (! empty($arrayfields['p.no_email']['checked'])) +{ + print ''; +} if (! empty($arrayfields['p.skype']['checked'])) { print ''; } +if (! empty($arrayfields['p.linkedin']['checked'])) +{ + print ''; +} if (! empty($arrayfields['p.thirdparty']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } - + // No EMail + if (! empty($arrayfields['p.no_email']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Skype if (! empty($arrayfields['p.skype']['checked'])) { @@ -859,12 +888,18 @@ while ($i < min($num, $limit)) if (! $i) $totalarray['nbfield']++; } // Facebook - if (! empty($arrayfields['p.facebook']['checked'])) - { - if (! empty($conf->socialnetworks->enabled)) { print ''; } - if (! $i) $totalarray['nbfield']++; - } - // Company + if (! empty($arrayfields['p.facebook']['checked'])) + { + if (! empty($conf->socialnetworks->enabled)) { print ''; } + if (! $i) $totalarray['nbfield']++; + } + // LinkedIn + if (! empty($arrayfields['p.linkedin']['checked'])) + { + if (! empty($conf->socialnetworks->enabled)) { print ''; } + if (! $i) $totalarray['nbfield']++; + } + // Company if (! empty($arrayfields['p.thirdparty']['checked'])) { print ''; } print ''."\n"; @@ -1254,7 +1254,7 @@ if ($action == 'create') print '"; } @@ -1562,12 +1562,12 @@ else print ''; print ''; - print ''; + print ''; print ''; if (!empty($conf->multicurrency->enabled)) { print ''; } - print ''; + print ''; if ($conf->global->PRODUCT_USE_UNITS) print ''; print ''; if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''; @@ -1614,7 +1614,7 @@ else print '\n"; } // TVA - print ''; // Price @@ -1624,7 +1624,7 @@ else print ''; } // Quantite - print ''; + print ''; // Unit if($conf->global->PRODUCT_USE_UNITS) print ''; // Remise @@ -1638,7 +1638,7 @@ else } // Margin - if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''; + if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''; // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) print ''; print ''; - print ''; + print ''; if ($conf->global->PRODUCT_USE_UNITS) { print ''; } - print ''; @@ -1930,7 +1930,7 @@ else if (! empty($objp->comment)) print "  -  ".$objp->comment; print ''; - print ''; + print ''; print ''; print '
'; - print $langs->trans('RIB'); + print $langs->trans('BankAccount'); print ''; if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).''; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '
facebook).'">
linkedin).'">
twitter).'">
facebook).'">
facebook).'">
linkedin).'">
'; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; + print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email); + print ''; @@ -625,6 +641,12 @@ if (! empty($arrayfields['p.facebook']['checked'])) print ''; print ''; + print ''; + print ''; @@ -696,9 +718,11 @@ if (! empty($arrayfields['p.phone_perso']['checked'])) print_liste_field if (! empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); +if (! empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['p.skype']['checked'])) print_liste_field_titre($arrayfields['p.skype']['label'], $_SERVER["PHP_SELF"], "p.skype", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.twitter']['checked'])) print_liste_field_titre($arrayfields['p.twitter']['label'], $_SERVER["PHP_SELF"], "p.twitter", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.facebook']['checked'])) print_liste_field_titre($arrayfields['p.facebook']['label'], $_SERVER["PHP_SELF"], "p.facebook", $begin, $param, '', $sortfield, $sortorder); +if (! empty($arrayfields['p.linkedin']['checked'])) print_liste_field_titre($arrayfields['p.linkedin']['label'], $_SERVER["PHP_SELF"], "p.linkedin", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.thirdparty']['checked'])) print_liste_field_titre($arrayfields['p.thirdparty']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.priv']['checked'])) print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center '); // Extra fields @@ -839,7 +863,12 @@ while ($i < min($num, $limit)) print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18).''.yn($obj->no_email).''.dol_print_socialnetworks($obj->facebook, $obj->rowid, $obj->socid, 'facebook').''.dol_print_socialnetworks($obj->facebook, $obj->rowid, $obj->socid, 'facebook').''.dol_print_socialnetworks($obj->linkedin, $obj->rowid, $obj->socid, 'linkedin').''; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 799c06564df..aeb7671bba2 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1212,7 +1212,7 @@ if ($action == 'create') { print ''; print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300'); - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").' '; print '
'.$langs->trans("Project").''; $formproject->select_projects(($soc->id>0?$soc->id:-1), $projectid, "projectid", 0, 0, 1, 1); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">' . $langs->trans("AddProject") . ' '; print "
'.$langs->trans("ServiceNb", $cursorline).''.$langs->trans("VAT").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("PriceUHTCurrency").''.$langs->trans("Qty").''.$langs->trans("Qty").''.$langs->trans("Unit").''.$langs->trans("ReductionShort").''.$langs->trans("BuyingPrice").''.img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description)."'; + print ''; print vatrate($objp->tva_tx.($objp->vat_src_code?(' ('.$objp->vat_src_code.')'):''), '%', $objp->info_bits); print ''.price($objp->multicurrency_subprice).''.$objp->qty.''.$objp->qty.''.$langs->trans($object->lines[$cursorline-1]->getLabelOfUnit()).''.price($objp->pa_ht).''.price($objp->pa_ht).''; @@ -1750,7 +1750,7 @@ else print $form->load_tva("eltva_tx", $objp->tva_tx.($objp->vat_src_code?(' ('.$objp->vat_src_code.')'):''), $mysoc, $object->thirdparty, $objp->fk_product, $objp->info_bits, $objp->product_type, 0, 1); print ''; @@ -1764,7 +1764,7 @@ else if ($objp->fk_product) print ''; print ''; + print ''; print ''; print '
'; print '
  
'; diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index b93c9db55d5..6f4a2041670 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -35,9 +35,9 @@ class Contracts extends DolibarrApi */ static $FIELDS = array( 'socid', - 'date_contrat', - 'commercial_signature_id', - 'commercial_suivi_id' + 'date_contrat', + 'commercial_signature_id', + 'commercial_suivi_id' ); /** @@ -48,10 +48,10 @@ class Contracts extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->contract = new Contrat($this->db); } @@ -65,23 +65,23 @@ class Contracts extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->contrat->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->contrat->lire) { + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->contract->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->contract); + return $this->_cleanObjectDatas($this->contract); } @@ -99,9 +99,9 @@ class Contracts extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of contract objects * - * @throws RestException + * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -136,7 +136,7 @@ class Contracts extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -175,7 +175,7 @@ class Contracts extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No contract found'); } - return $obj_ret; + return $obj_ret; } /** @@ -184,7 +184,7 @@ class Contracts extends DolibarrApi * @param array $request_data Request data * @return int ID of contrat */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,7 +218,7 @@ class Contracts extends DolibarrApi * * @return array */ - function getLines($id) + public function getLines($id) { if (! DolibarrApiAccess::$user->rights->contrat->lire) { throw new RestException(401); @@ -229,8 +229,8 @@ class Contracts extends DolibarrApi throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->contract->getLinesArray(); $result = array(); @@ -250,21 +250,21 @@ class Contracts extends DolibarrApi * * @return int|bool */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + $request_data = (object) $request_data; $updateRes = $this->contract->addline( $request_data->desc, $request_data->subprice, @@ -274,16 +274,16 @@ class Contracts extends DolibarrApi $request_data->localtax2_tx, $request_data->fk_product, $request_data->remise_percent, - $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real - $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real + $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real + $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real $request_data->HT, - $request_data->subprice_excl_tax, - $request_data->info_bits, + $request_data->subprice_excl_tax, + $request_data->info_bits, $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->array_options, - $request_data->fk_unit, - $request_data->rang + $request_data->pa_ht, + $request_data->array_options, + $request_data->fk_unit, + $request_data->rang ); if ($updateRes > 0) { @@ -303,20 +303,20 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contrat not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $request_data = (object) $request_data; @@ -328,12 +328,12 @@ class Contracts extends DolibarrApi $request_data->remise_percent, $request_data->date_ouveture_prevue, $request_data->date_fin_validite, - $request_data->tva_tx, + $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->date_ouverture, $request_data->date_cloture, - 'HT', + 'HT', $request_data->info_bits, $request_data->fk_fourn_price, $request_data->pa_ht, @@ -363,30 +363,30 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) + public function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) { - if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contrat not found'); + } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); + $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; + return false; } /** @@ -401,32 +401,32 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function unactivateLine($id, $lineid, $datestart, $comment = null) + public function unactivateLine($id, $lineid, $datestart, $comment = null) { - if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + if (! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contrat not found'); + } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $request_data = (object) $request_data; + $request_data = (object) $request_data; - $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); + $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; + return false; } /** @@ -442,19 +442,19 @@ class Contracts extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contrat not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of object @@ -465,7 +465,7 @@ class Contracts extends DolibarrApi } else { - throw new RestException(405, $this->contract->error); + throw new RestException(405, $this->contract->error); } } @@ -477,20 +477,20 @@ class Contracts extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contrat not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->contract->$field = $value; @@ -502,7 +502,7 @@ class Contracts extends DolibarrApi } else { - throw new RestException(500, $this->contract->error); + throw new RestException(500, $this->contract->error); } } @@ -513,19 +513,19 @@ class Contracts extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->contrat->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contract not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if (! $this->contract->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete contract : '.$this->contract->error); @@ -555,27 +555,27 @@ class Contracts extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contract not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); - } + $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); + } return array( 'success' => array( @@ -601,34 +601,34 @@ class Contracts extends DolibarrApi * "notrigger": 0 * } */ - function close($id, $notrigger = 0) + public function close($id, $notrigger = 0) { - if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contract not found'); - } + if (! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contract not found'); + } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already close'); - } - if ($result < 0) { - throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); - } + $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already close'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' + ) + ); } @@ -639,7 +639,7 @@ class Contracts extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -666,7 +666,7 @@ class Contracts extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $contrat = array(); foreach (Contracts::$FIELDS as $field) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 6e907699f22..8c83c342ab4 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -188,7 +188,7 @@ class Contrat extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -199,7 +199,7 @@ class Contrat extends CommonObject * @param Societe $soc Thirdparty object * @return string free reference for contract */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $db, $langs, $conf; $langs->load("contracts"); @@ -250,7 +250,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -261,7 +261,7 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - function active_line($user, $line_id, $date, $date_end = '', $comment = '') + public function active_line($user, $line_id, $date, $date_end = '', $comment = '') { // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); @@ -274,7 +274,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * @@ -284,7 +284,7 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - function close_line($user, $line_id, $date_end, $comment = '') + public function close_line($user, $line_id, $date_end, $comment = '') { // phpcs:enable $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); @@ -307,7 +307,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @see closeAll */ - function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') + public function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') { if (empty($date_start)) $date_start = dol_now(); @@ -363,7 +363,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @see activateAll */ - function closeAll(User $user, $notrigger = 0, $comment = '') + public function closeAll(User $user, $notrigger = 0, $comment = '') { $this->db->begin(); @@ -419,7 +419,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function validate(User $user, $force_number = '', $notrigger = 0) + public function validate(User $user, $force_number = '', $notrigger = 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; @@ -547,7 +547,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, >0 if OK */ - function reopen($user, $notrigger = 0) + public function reopen($user, $notrigger = 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; @@ -614,14 +614,14 @@ class Contrat extends CommonObject * @param string $ref_supplier Supplier ref * @return int <0 if KO, 0 if not found, Id of contract if OK */ - function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') + public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') { $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; $sql.= " ref_supplier, ref_customer,"; $sql.= " ref_ext,"; $sql.= " fk_user_mise_en_service, date_contrat as datecontrat,"; $sql.= " fk_user_author, fin_validite, date_cloture,"; - $sql.= " fk_projet,"; + $sql.= " fk_projet as fk_project,"; $sql.= " fk_commercial_signature, fk_commercial_suivi,"; $sql.= " note_private, note_public, model_pdf, extraparams"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; @@ -665,20 +665,20 @@ class Contrat extends CommonObject $this->user_author_id = $obj->fk_user_author; - $this->commercial_signature_id = $obj->fk_commercial_signature; + $this->commercial_signature_id = $obj->fk_commercial_signature; $this->commercial_suivi_id = $obj->fk_commercial_suivi; $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->modelpdf = $obj->model_pdf; - $this->fk_projet = $obj->fk_projet; // deprecated - $this->fk_project = $obj->fk_projet; + $this->fk_projet = $obj->fk_project; // deprecated + $this->fk_project = $obj->fk_project; $this->socid = $obj->fk_soc; $this->fk_soc = $obj->fk_soc; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->db->free($resql); @@ -711,14 +711,14 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines array into this->lines. * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed * * @return ContratLigne[] Return array of contract lines */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->nbofserviceswait=0; @@ -768,7 +768,7 @@ class Contrat extends CommonObject while ($i < $num) { - $objp = $this->db->fetch_object($result); + $objp = $this->db->fetch_object($result); $line = new ContratLigne($this->db); $line->id = $objp->rowid; @@ -829,7 +829,7 @@ class Contrat extends CommonObject // fetch optionals attributes and labels $line->fetch_optionals(); - $this->lines[$pos] = $line; + $this->lines[$pos] = $line; $this->lines_id_index_mapper[$line->id] = $pos; //dol_syslog("1 ".$line->desc); @@ -869,7 +869,7 @@ class Contrat extends CommonObject * @param User $user User that create * @return int <0 if KO, id of contract if OK */ - function create($user) + public function create($user) { global $conf,$langs,$mysoc; @@ -1088,7 +1088,7 @@ class Contrat extends CommonObject * @param User $user Utilisateur qui supprime * @return int < 0 si erreur, > 0 si ok */ - function delete($user) + public function delete($user) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -1242,7 +1242,7 @@ class Contrat extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -1360,7 +1360,7 @@ class Contrat extends CommonObject * @param string $rang Position * @return int <0 if KO, >0 if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) { global $user, $langs, $conf, $mysoc; $error=0; @@ -1570,7 +1570,7 @@ class Contrat extends CommonObject * @param string $fk_unit Code of the unit to use. Null to use the default one * @return int < 0 si erreur, > 0 si ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null) { global $user, $conf, $langs, $mysoc; @@ -1647,21 +1647,21 @@ class Contrat extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'"; - $sql.= ",price_ht='" . price2num($price)."'"; - $sql.= ",subprice='" . price2num($subprice)."'"; - $sql.= ",remise='" . price2num($remise)."'"; + $sql.= ",price_ht='".price2num($price)."'"; + $sql.= ",subprice='".price2num($subprice)."'"; + $sql.= ",remise='".price2num($remise)."'"; $sql.= ",remise_percent='".price2num($remise_percent)."'"; $sql.= ",qty='".$qty."'"; - $sql.= ",tva_tx='". price2num($tvatx)."'"; - $sql.= ",localtax1_tx='". price2num($localtax1tx)."'"; - $sql.= ",localtax2_tx='". price2num($localtax2tx)."'"; + $sql.= ",tva_tx='".price2num($tvatx)."'"; + $sql.= ",localtax1_tx='".price2num($localtax1tx)."'"; + $sql.= ",localtax2_tx='".price2num($localtax2tx)."'"; $sql.= ",localtax1_type='".$localtax1_type."'"; $sql.= ",localtax2_type='".$localtax2_type."'"; - $sql.= ", total_ht='". price2num($total_ht)."'"; - $sql.= ", total_tva='". price2num($total_tva)."'"; + $sql.= ", total_ht='".price2num($total_ht)."'"; + $sql.= ", total_tva='".price2num($total_tva)."'"; $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql.= ", total_ttc='". price2num($total_ttc)."'"; + $sql.= ", total_ttc='".price2num($total_ttc)."'"; $sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); $sql.= ", buy_price_ht='".price2num($pa_ht)."'"; if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } @@ -1733,7 +1733,7 @@ class Contrat extends CommonObject * @param User $user User that delete * @return int >0 if OK, <0 if KO */ - function deleteline($idline, User $user) + public function deleteline($idline, User $user) { global $conf, $langs; @@ -1792,7 +1792,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update statut of contract according to services * @@ -1800,7 +1800,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @deprecated This function will never be used. Status of a contract is status of its lines. */ - function update_statut($user) + public function update_statut($user) { // phpcs:enable dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); @@ -1811,11 +1811,11 @@ class Contrat extends CommonObject // Load $this->lines array // $this->fetch_lines(); -// $newstatut=1; -// foreach($this->lines as $key => $contractline) -// { -// // if ($contractline) // Loop on each service -// } + // $newstatut=1; + // foreach($this->lines as $key => $contractline) + // { + // // if ($contractline) // Loop on each service + // } return 1; } @@ -1827,12 +1827,12 @@ class Contrat extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @return string Label */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi label of a given contrat status * @@ -1840,7 +1840,7 @@ class Contrat extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @return string Label */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1872,8 +1872,7 @@ class Contrat extends CommonObject elseif ($mode == 4 || $mode == 6 || $mode == 7) { $text=''; - if ($mode == 4) - { + if ($mode == 4) { $text =''; $text.=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed); $text.=' '.$langs->trans("Services"); @@ -1909,7 +1908,7 @@ class Contrat 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($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user; @@ -1973,7 +1972,7 @@ class Contrat extends CommonObject * @param int $id id du contrat a charger * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, c.ref, c.datec, c.date_cloture,"; $sql.= " c.tms as date_modification,"; @@ -2015,14 +2014,14 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of line rowid * * @param int $statut Status of lines to get * @return array Array of line's rowid */ - function array_detail($statut = -1) + public function array_detail($statut = -1) { // phpcs:enable $tab=array(); @@ -2059,7 +2058,7 @@ class Contrat extends CommonObject * @param string $option 'all' or 'others' * @return array Array of contracts id */ - function getListOfContracts($option = 'all') + public function getListOfContracts($option = 'all') { $tab=array(); @@ -2092,7 +2091,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2100,7 +2099,7 @@ class Contrat extends CommonObject * @param string $mode "inactive" pour services a activer, "expired" pour services expires * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $mode) + public function load_board($user, $mode) { // phpcs:enable global $conf, $langs; @@ -2172,13 +2171,13 @@ class Contrat 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 si ko, >0 si ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -2223,7 +2222,7 @@ class Contrat extends CommonObject * * @return array Liste des id contacts facturation */ - function getIdBillingContact() + public function getIdBillingContact() { return $this->getIdContact('external', 'BILLING'); } @@ -2233,7 +2232,7 @@ class Contrat extends CommonObject * * @return array Liste des id contacts prestation */ - function getIdServiceContact() + public function getIdServiceContact() { return $this->getIdContact('external', 'SERVICE'); } @@ -2245,9 +2244,9 @@ class Contrat extends CommonObject * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() - { + */ + public function initAsSpecimen() + { global $user,$langs,$conf; // Load array of products prodids @@ -2319,7 +2318,7 @@ class Contrat extends CommonObject * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -2382,7 +2381,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int New id of clone */ - function createFromClone($socid = 0, $notrigger = 0) + public function createFromClone($socid = 0, $notrigger = 0) { global $db, $user, $langs, $conf, $hookmanager, $extrafields; @@ -2631,7 +2630,7 @@ class ContratLigne extends CommonObjectLine * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -2643,12 +2642,12 @@ class ContratLigne extends CommonObjectLine * @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) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $mode, ((! empty($this->date_fin_validite))?($this->date_fin_validite < dol_now()?1:0):-1)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a contract line status * @@ -2658,7 +2657,7 @@ class ContratLigne extends CommonObjectLine * @param string $moreatt More attribute * @return string Libelle */ - static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') + public static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') { // phpcs:enable global $langs; @@ -2720,7 +2719,7 @@ class ContratLigne extends CommonObjectLine * @param int $maxlength Max length * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlength = 0) + public function getNomUrl($withpicto = 0, $maxlength = 0) { global $langs; @@ -2741,13 +2740,13 @@ class ContratLigne extends CommonObjectLine } /** - * Load object in memory from database + * Load object in memory from database * - * @param int $id Id object - * @param string $ref Ref of contract - * @return int <0 if KO, >0 if OK + * @param int $id Id object + * @param string $ref Ref of contract + * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { // Check parameters @@ -2879,7 +2878,7 @@ class ContratLigne extends CommonObjectLine * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs, $mysoc; @@ -3070,14 +3069,14 @@ class ContratLigne extends CommonObjectLine } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base des champs total_xxx de ligne * Used by migration process * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); @@ -3188,7 +3187,7 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -3198,7 +3197,7 @@ class ContratLigne extends CommonObjectLine * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - function active_line($user, $date, $date_end = '', $comment = '') + public function active_line($user, $date, $date_end = '', $comment = '') { // phpcs:enable global $langs, $conf; @@ -3247,7 +3246,7 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * @@ -3257,7 +3256,7 @@ class ContratLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function close_line($user, $date_end, $comment = '', $notrigger = 0) + public function close_line($user, $date_end, $comment = '', $notrigger = 0) { // phpcs:enable global $langs, $conf; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 05135f39aeb..10c2e2915b9 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -197,7 +197,7 @@ foreach($listofstatus as $status) } if (! empty($conf->use_javascript_ajax)) { - print '
'; + print '
'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); @@ -331,9 +331,9 @@ if ($result) print ''; print ''; - print ''; + print ''; //print ''; - print ''; + print ''; print "\n"; while ($i < $num) @@ -352,7 +352,7 @@ if ($result) $staticcompany->name=$obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; - print ''; + print ''; //print ''; print ''; print ''; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index fb2422b7762..d27460e4b6a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -498,14 +498,14 @@ if (! empty($arrayfields['state.nom']['checked'])) // Country if (! empty($arrayfields['country.code_iso']['checked'])) { - print ''; } // Company type if (! empty($arrayfields['typent.code']['checked'])) { - print ''; } @@ -547,7 +547,7 @@ if (! empty($arrayfields['c.tms']['checked'])) // First end date if (! empty($arrayfields['lower_planned_end_date']['checked'])) { - print ''; } -print ''; @@ -576,27 +576,32 @@ if (! empty($arrayfields['s.email']['checked'])) print_liste_field_t if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); +if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); -if (! empty($arrayfields['c.date_contrat']['checked'])) print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat", "", "$param", 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['c.date_contrat']['checked'])) print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat", "", "$param", '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['lower_planned_end_date']['checked'])) print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['status']['checked'])) -{ +if (! empty($arrayfields['c.datec']['checked'])) { + print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (! empty($arrayfields['c.tms']['checked'])){ + print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (! empty($arrayfields['lower_planned_end_date']['checked'])) { + print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (! empty($arrayfields['status']['checked'])) { print_liste_field_titre($staticcontratligne->LibStatut(0, 3), '', '', '', '', 'width="16"'); print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0), '', '', '', '', 'width="16"'); print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1), '', '', '', '', 'width="16"'); print_liste_field_titre($staticcontratligne->LibStatut(5, 3), '', '', '', '', 'width="16"'); } -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"; while ($i < min($num, $limit)) @@ -608,8 +613,7 @@ while ($i < min($num, $limit)) $contracttmp->ref_customer=$obj->ref_customer; $contracttmp->ref_supplier=$obj->ref_supplier; - if ($obj->socid > 0) - { + if ($obj->socid > 0) { $result=$socstatic->fetch($obj->socid); } @@ -619,8 +623,7 @@ while ($i < min($num, $limit)) print ''; @@ -690,7 +693,7 @@ while ($i < min($num, $limit)) // Type ent if (! empty($arrayfields['typent.code']['checked'])) { - print ''; @@ -705,8 +708,8 @@ while ($i < min($num, $limit)) $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); if ($listsalesrepresentatives < 0) dol_print_error($db); $nbofsalesrepresentative=count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 3) // We print only number - { + if ($nbofsalesrepresentative > 3) { + // We print only number print ''; print $nbofsalesrepresentative; print ''; @@ -743,7 +746,7 @@ while ($i < min($num, $limit)) // Date if (! empty($arrayfields['c.date_contrat']['checked'])) { - print ''; + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; @@ -754,7 +757,7 @@ while ($i < min($num, $limit)) // Date creation if (! empty($arrayfields['c.datec']['checked'])) { - print ''; if (! $i) $totalarray['nbfield']++; @@ -762,7 +765,7 @@ while ($i < min($num, $limit)) // Date modification if (! empty($arrayfields['c.tms']['checked'])) { - print ''; if (! $i) $totalarray['nbfield']++; @@ -770,7 +773,7 @@ while ($i < min($num, $limit)) // Date lower end date if (! empty($arrayfields['lower_planned_end_date']['checked'])) { - print ''; if (! $i) $totalarray['nbfield']++; @@ -778,13 +781,13 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['status']['checked'])) { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } // Action column - print ''; $texte.= ''; - + // Parametrage du prefix des avoirs $texte.= ''; $texte.= ''; @@ -129,7 +129,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -153,7 +153,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices * @param string $mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object, $mode = 'next') + public function getNextValue($objsoc, $object, $mode = 'next') { global $db,$conf; @@ -182,18 +182,18 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $numFinal=get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, $object->date); return $numFinal; - } + } /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value */ - function getNumRef($objsoc, $objforref, $mode = 'next') - { - return $this->getNextValue($objsoc, $objforref, $mode); - } + public function getNumRef($objsoc, $objforref, $mode = 'next') + { + return $this->getNextValue($objsoc, $objforref, $mode); + } } diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index 593d4f9d51a..6949ae3924f 100644 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -40,7 +40,7 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models * @@ -48,7 +48,7 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of numbers */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -77,7 +77,7 @@ abstract class ModeleNumRefSuppliersInvoices * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -86,7 +86,7 @@ abstract class ModeleNumRefSuppliersInvoices * * @return string Description Text */ - function info() + public function info() { global $langs; $langs->load("invoices"); @@ -97,7 +97,7 @@ abstract class ModeleNumRefSuppliersInvoices * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("invoices"); @@ -108,7 +108,7 @@ abstract class ModeleNumRefSuppliersInvoices * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -120,18 +120,18 @@ abstract class ModeleNumRefSuppliersInvoices * @param string $mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object, $mode) - { + public function getNextValue($objsoc, $object, $mode) + { global $langs; return $langs->trans("NotAvailable"); - } + } /** Returns version of the model numbering * * @return string Value */ - function getVersion() - { + public function getVersion() + { global $langs; $langs->load("admin"); @@ -140,5 +140,5 @@ abstract class ModeleNumRefSuppliersInvoices if ($this->version == 'dolibarr') return DOL_VERSION; if ($this->version) return $this->version; return $langs->trans("NotAvailable"); - } + } } diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 2d2164ebeb1..7e3f7c68c88 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -117,8 +117,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $conf, $langs, $mysoc; // Load translation files required by the page @@ -180,10 +180,10 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->localtax2=array(); $this->atleastoneratenotnull=0; $this->atleastonediscount=0; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -195,8 +195,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes; @@ -608,9 +608,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); return 0; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -621,7 +621,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -832,7 +832,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -932,17 +932,17 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * - * @param PDF $pdf Object PDF - * @param FactureFournisseur $object Object invoice - * @param int $posy Position y in PDF - * @param Translate $outputlangs Object langs for output - * @return int <0 if KO, >0 if OK + * @param PDF $pdf Object PDF + * @param FactureFournisseur $object Object invoice + * @param int $posy Position y in PDF + * @param Translate $outputlangs Object langs for output + * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -1028,13 +1028,13 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Show top header of page. * - * @param PDF $pdf Object PDF - * @param FactureFournisseur $object Object to show - * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output - * @return void + * @param PDF $pdf Object PDF + * @param FactureFournisseur $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs, $conf, $mysoc; @@ -1238,19 +1238,19 @@ class pdf_canelle extends ModelePDFSuppliersInvoices return $top_shift; } - /** - * Show footer of page. Need this->emetteur object + /** + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param FactureFournisseur $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text - */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + * @param PDF $pdf PDF + * @param FactureFournisseur $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } } diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index 4fb3f4b2e9d..6f0cb59ca89 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -60,7 +60,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders /** * Constructor */ - function __construct() + public function __construct() { global $conf; @@ -72,7 +72,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -84,7 +84,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -96,7 +96,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -132,7 +132,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * @param Object $object Object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = 0, $object = '') { global $db,$conf; @@ -163,7 +163,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la reference de commande suivante non utilisee * @@ -171,7 +171,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * @param Object $object Object * @return string Texte descripif */ - function commande_get_num($objsoc = 0, $object = '') + public function commande_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 556ca56d2db..320c33dce7d 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -61,7 +61,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * * @return string Texte descripif */ - function info() + public function info() { global $db, $conf, $langs; @@ -102,7 +102,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -125,7 +125,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * @param Object $object Object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = 0, $object = '') { global $db,$conf; @@ -146,7 +146,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la reference de commande suivante non utilisee * @@ -154,7 +154,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * @param Object $object Object * @return string Texte descripif */ - function commande_get_num($objsoc = 0, $object = '') + public function commande_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index b462814f624..e7cba73672d 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -43,7 +43,7 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models * @@ -51,7 +51,7 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -82,7 +82,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -91,7 +91,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return string Description Text */ - function info() + public function info() { global $langs; $langs->load("orders"); @@ -102,7 +102,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("orders"); @@ -113,7 +113,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -122,7 +122,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return string Valeur */ - function getNextValue() + public function getNextValue() { global $langs; return $langs->trans("NotAvailable"); @@ -132,7 +132,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index a95440ad42f..0cc9d4f6af3 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -120,7 +120,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -197,7 +197,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -209,7 +209,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes; @@ -708,7 +708,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -718,13 +718,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -734,7 +734,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Translate $outputlangs Langs object * @return integer */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -789,7 +789,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders return $posy; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -800,7 +800,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1017,7 +1017,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1126,7 +1126,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs, $conf, $mysoc; @@ -1363,15 +1363,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param CommandeFournisseur $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param PDF $pdf PDF + * @param CommandeFournisseur $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 87b4791524e..cb52a14f721 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -117,7 +117,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -176,7 +176,7 @@ class pdf_standard extends ModelePDFSuppliersPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -188,7 +188,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; @@ -517,7 +517,7 @@ class pdf_standard extends ModelePDFSuppliersPayments } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -527,7 +527,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_cheque(&$pdf, $object, $posy, $outputlangs) + private function _tableau_cheque(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -590,7 +590,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf,$mysoc; @@ -631,7 +631,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs, $conf, $mysoc; @@ -810,7 +810,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php index a947573dd1a..c1f6e003d6d 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -59,7 +59,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -99,7 +99,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -122,7 +122,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -143,7 +143,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -151,7 +151,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index 5ab0909e720..e071f8d5505 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -60,7 +60,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +72,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -155,7 +155,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -163,7 +163,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * @param string $objforref Object for number to search * @return string Next free value */ - function payment_get_num($objsoc, $objforref) + public function payment_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php index f8afdeea063..a3f7495efb5 100644 --- a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php +++ b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php @@ -28,7 +28,7 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models * @@ -36,7 +36,7 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of numbers */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -68,7 +68,7 @@ abstract class ModeleNumRefSupplierPayments * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -78,7 +78,7 @@ abstract class ModeleNumRefSupplierPayments * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -90,7 +90,7 @@ abstract class ModeleNumRefSupplierPayments * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -102,7 +102,7 @@ abstract class ModeleNumRefSupplierPayments * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -114,7 +114,7 @@ abstract class ModeleNumRefSupplierPayments * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -125,15 +125,15 @@ abstract class ModeleNumRefSupplierPayments * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; return $langs->trans("NotAvailable"); } } diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 27163ac32db..d2dffce83c4 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -62,7 +62,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -107,7 +107,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf, $langs; @@ -221,7 +221,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -233,7 +233,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index faad9b8d66a..e5759d9ff6d 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -193,7 +193,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->atleastonediscount=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -205,7 +205,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; @@ -704,7 +704,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -714,13 +714,13 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -730,7 +730,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -888,7 +888,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -899,7 +899,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1174,7 +1174,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1283,7 +1283,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs; @@ -1491,16 +1491,16 @@ class pdf_aurore extends ModelePDFSupplierProposal return $top_shift; } - /** - * Show footer of page. Need this->emetteur object + /** + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text - */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index 7e80c009388..21c2a68e629 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -62,7 +62,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -86,7 +86,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -124,7 +124,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * @param Propal $supplier_proposal Object commercial proposal * @return string Next value */ - function getNextValue($objsoc, $supplier_proposal) + public function getNextValue($objsoc, $supplier_proposal) { global $db,$conf; @@ -165,7 +165,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * @param Object $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php index 5ae686f3542..f8cd365d5a7 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php @@ -62,7 +62,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -102,7 +102,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -125,7 +125,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal * @param Propal $supplier_proposal Object supplier_proposal * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $supplier_proposal) + public function getNextValue($objsoc, $supplier_proposal) { global $db,$conf; diff --git a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php index 8b09d011da4..a7c12a9aeed 100644 --- a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php +++ b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php @@ -42,7 +42,7 @@ abstract class ModelePDFSupplierProposal extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -50,7 +50,7 @@ abstract class ModelePDFSupplierProposal extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -81,7 +81,7 @@ abstract class ModeleNumRefSupplierProposal * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -91,7 +91,7 @@ abstract class ModeleNumRefSupplierProposal * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("supplier_proposal"); @@ -103,7 +103,7 @@ abstract class ModeleNumRefSupplierProposal * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("supplier_proposal"); @@ -116,7 +116,7 @@ abstract class ModeleNumRefSupplierProposal * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ abstract class ModeleNumRefSupplierProposal * @param Propal $propal Object commercial proposal * @return string Valeur */ - function getNextValue($objsoc, $propal) + public function getNextValue($objsoc, $propal) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ abstract class ModeleNumRefSupplierProposal * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index b58c327e1bc..80e95037d24 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -59,7 +59,7 @@ class doc_generic_user_odt extends ModelePDFUser * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -104,7 +104,7 @@ class doc_generic_user_odt extends ModelePDFUser * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf, $langs; @@ -203,9 +203,9 @@ class doc_generic_user_odt extends ModelePDFUser return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * * @param User $object Object source to build document * @param Translate $outputlangs Lang output object @@ -215,7 +215,7 @@ class doc_generic_user_odt extends ModelePDFUser * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; @@ -330,7 +330,7 @@ class doc_generic_user_odt extends ModelePDFUser // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->user->dir_temp, @@ -439,7 +439,7 @@ class doc_generic_user_odt extends ModelePDFUser return -1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * get substitution array for object * @@ -448,7 +448,7 @@ class doc_generic_user_odt extends ModelePDFUser * @param string $array_key key for array * @return array array of substitutions */ - function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') { // phpcs:enable $array_other = array(); diff --git a/htdocs/core/modules/user/modules_user.class.php b/htdocs/core/modules/user/modules_user.class.php index 7add1cf99d1..bdd04f1c097 100644 --- a/htdocs/core/modules/user/modules_user.class.php +++ b/htdocs/core/modules/user/modules_user.class.php @@ -44,7 +44,7 @@ abstract class ModelePDFUser extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -52,7 +52,7 @@ abstract class ModelePDFUser extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 2dfd2cfcfee..0840f40a868 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -62,7 +62,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -107,7 +107,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -206,7 +206,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -218,7 +218,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; @@ -353,7 +353,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->user->dir_temp, @@ -527,6 +527,6 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup } } - return -1; - } + return -1; + } } diff --git a/htdocs/core/modules/usergroup/modules_usergroup.class.php b/htdocs/core/modules/usergroup/modules_usergroup.class.php index 2bd717624d7..6259366aeed 100644 --- a/htdocs/core/modules/usergroup/modules_usergroup.class.php +++ b/htdocs/core/modules/usergroup/modules_usergroup.class.php @@ -38,30 +38,30 @@ */ abstract class ModelePDFUserGroup extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error=''; - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return list of active generation modules - * + * @var string Error code (or message) + */ + public $error=''; + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * * @param DoliDB $db Database handler * @param integer $maxfilenamelength Max length of value to show * @return array List of templates - */ - static function liste_modeles($db, $maxfilenamelength = 0) - { + */ + public static function liste_modeles($db, $maxfilenamelength = 0) + { // phpcs:enable - global $conf; + global $conf; - $type = 'group'; - $list = array(); + $type = 'group'; + $list = array(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $list = getListOfModels($db, $type, $maxfilenamelength); - return $list; - } + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $list = getListOfModels($db, $type, $maxfilenamelength); + return $list; + } } diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index ac7ee20139a..493c7b65295 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2012-2017 Regis Houssin - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,7 +96,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel if (! empty($conf->multicompany->enabled)) { print ''; } - print '\n"; print ""; } diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index 3071257839e..f94c96f0da1 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -21,8 +21,9 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $align=$extrafields->getAlignFlag($key, $extrafieldsobjectkey); print ''; - $tmpkey='options_'.$key; + print ' data-key="'.$key.'"'; + print '>'; + $tmpkey='options_'.$key; if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')) && !is_numeric($obj->$tmpkey)) { $datenotinstring = $obj->$tmpkey; diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index 5bf73d94bd2..bfae5faa944 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -22,7 +22,7 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $sortonfield = "ef.".$key; if (! empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield=''; if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') print ''; - else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; + else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n"; } } } diff --git a/htdocs/core/triggers/dolibarrtriggers.class.php b/htdocs/core/triggers/dolibarrtriggers.class.php index a66eb12c78e..19518b60e6c 100644 --- a/htdocs/core/triggers/dolibarrtriggers.class.php +++ b/htdocs/core/triggers/dolibarrtriggers.class.php @@ -134,16 +134,16 @@ abstract class DolibarrTriggers } } - /** - * Function called when a Dolibarrr business event is done. - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) - * - * @param string $action Event action code - * @param Object $object Object - * @param User $user Object user - * @param Translate $langs Object langs - * @param conf $conf Object conf - * @return int <0 if KO, 0 if no triggered ran, >0 if OK - */ - abstract function runTrigger($action, $object, User $user, Translate $langs, Conf $conf); + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public abstract function runTrigger($action, $object, User $user, Translate $langs, Conf $conf); } diff --git a/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php b/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php new file mode 100644 index 00000000000..c7ce8f121fc --- /dev/null +++ b/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php @@ -0,0 +1,147 @@ + + * 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 htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php + * \ingroup core + * \brief File of trigger for IFTTT module + */ +require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; + + +/** + * Class of triggers for IFTTT module + */ +class InterfaceIFTTT extends DolibarrTriggers +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "ifttt"; + $this->description = "Triggers of the module IFTTT"; + $this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version + $this->picto = 'ifttt'; + } + + /** + * Return name of trigger file + * + * @return string Name of trigger file + */ + public function getName() + { + return $this->name; + } + + /** + * Return description of trigger file + * + * @return string Description of trigger file + */ + public function getDesc() + { + return $this->description; + } + + /** + * Return version of trigger file + * + * @return string Version of trigger file + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') { + return $langs->trans("Development"); + } elseif ($this->version == 'experimental') { + return $langs->trans("Experimental"); + } elseif ($this->version == 'dolibarr') { + return DOL_VERSION; + } elseif ($this->version) { + return $this->version; + } else { + return $langs->trans("Unknown"); + } + } + + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) + { + $ok = 0; + + if (empty($conf->ifttt->enabled)) return 0; // Module not active, we do nothing + + switch ($action) { + case 'THIRDPARTY_CREATED': + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + + // See https://platform.ifttt.com/docs/api_reference#realtime-api + + $arrayofdata=array(); + $arrayofdata['user_id']=$conf->global->IFTTT_USER_ID; + $arrayofdata['trigger_identity']=$conf->global->IFTTT_TRIGGER_IDENTITY; + $arrayofdata['name']='testabcdef'; + $arrayofdata['email']='testemailabcdef'; + + $url = 'https://realtime.ifttt.com/v1/notifications'; + + $addheaders=array( + 'IFTTT-Service-Key'=>'123', + 'Accept'=>'application/json', + 'Accept-Charset'=>'utf-8', + 'Accept-Encoding'=>'gzip, deflate', + 'Content-Type'=>'application/json', + 'X-Request-ID'=>getRandomPassword(true, null) + ); + + $result = getURLContent($url, 'POSTALREADYFORMATED', '', 1, $addheaders); + + $ok = 1; + break; + } + + return $ok; + } +} diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 8570eaba8d1..ec195030448 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -96,7 +96,7 @@ class InterfaceNotification extends DolibarrTriggers * * @return array Array of events managed by notification module */ - function getListOfManagedEvents() + public function getListOfManagedEvents() { global $conf; diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index f8f5595887d..c8a31a70e40 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -109,6 +109,8 @@ class InterfaceTicketEmail extends DolibarrTriggers { $ok = 0; + if (empty($conf->ticket->enabled)) return 0; // Module not active, we do nothing + switch ($action) { case 'TICKET_ASSIGNED': dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index eaff511a779..1f22e7b910c 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -108,7 +108,7 @@ class Cronjob extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -121,7 +121,7 @@ class Cronjob 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; @@ -302,7 +302,7 @@ class Cronjob extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -393,7 +393,7 @@ class Cronjob extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * @@ -406,7 +406,7 @@ class Cronjob extends CommonObject * @param int $processing Processing or not * @return int <0 if KO, >0 if OK */ - function fetch_all($sortorder = 'DESC', $sortfield = 't.rowid', $limit = 0, $offset = 0, $status = 1, $filter = '', $processing = -1) + public function fetch_all($sortorder = 'DESC', $sortfield = 't.rowid', $limit = 0, $offset = 0, $status = 1, $filter = '', $processing = -1) { // phpcs:enable global $langs; @@ -541,7 +541,7 @@ class Cronjob 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; @@ -691,37 +691,21 @@ class Cronjob 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) { $error=0; $this->db->begin(); -// if (! $error) -// { -// if (! $notrigger) -// { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. + $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob"; + $sql.= " WHERE rowid=".$this->id; - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers -// } -// } - -// if (! $error) -// { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob"; - $sql.= " WHERE rowid=".$this->id; - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } -// } + 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) @@ -749,7 +733,7 @@ class Cronjob extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -805,7 +789,7 @@ class Cronjob extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; $this->ref=0; @@ -852,7 +836,7 @@ class Cronjob 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; @@ -909,7 +893,7 @@ class Cronjob extends CommonObject * * @return int */ - function info() + public function info() { $sql = "SELECT"; $sql.= " f.rowid, f.datec, f.tms, f.fk_user_mod, f.fk_user_author"; @@ -941,7 +925,7 @@ class Cronjob extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Run a job. * Once job is finished, status and nb of run is updated. @@ -950,10 +934,12 @@ class Cronjob extends CommonObject * @param string $userlogin User login * @return int <0 if KO, >0 if OK */ - function run_jobs($userlogin) + public function run_jobs($userlogin) { // phpcs:enable - global $langs, $conf; + global $langs, $conf, $hookmanager; + + $hookmanager->initHooks(array('cron')); $now=dol_now(); $error = 0; @@ -1125,8 +1111,7 @@ class Cronjob extends CommonObject } } - if($this->jobtype == 'function') - { + if ($this->jobtype == 'function') { //load lib $libpath = '/' . strtolower($this->module_name) . '/lib/' . $this->libname; $ret = dol_include_once($libpath); @@ -1217,7 +1202,7 @@ class Cronjob extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reprogram a job * @@ -1225,7 +1210,7 @@ class Cronjob extends CommonObject * @param timestamp $now Date returned by dol_now() * @return int <0 if KO, >0 if OK */ - function reprogram_jobs($userlogin, $now) + public function reprogram_jobs($userlogin, $now) { // phpcs:enable dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG); @@ -1301,12 +1286,12 @@ class Cronjob 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, $this->processing); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1315,7 +1300,7 @@ class Cronjob extends CommonObject * @param int $processing 0=Not running, 1=Running * @return string Label of status */ - function LibStatut($status, $mode = 0, $processing = 0) + public function LibStatut($status, $mode = 0, $processing = 0) { // phpcs:enable global $langs; @@ -1349,12 +1334,12 @@ class Cronjob extends CommonObject if ($status == 1) return img_picto($langs->trans('Enabled').$moretext, 'statut'.($processing?'1':'4'), 'class="pictostatus"').' '.$langs->trans('Enabled').$moretext; elseif ($status == 0) return img_picto($langs->trans('Disabled').$moretext, 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled').$moretext; } - elseif ($mode == 5) - { - if ($status == 1) return $langs->trans('Enabled').$moretext.' '.img_picto($langs->trans('Enabled').$moretext, 'statut'.($processing?'1':'4'), 'class="pictostatus"'); - elseif ($status == 0) return $langs->trans('Disabled').$moretext.' '.img_picto($langs->trans('Disabled').$moretext, 'statut5', 'class="pictostatus"'); - } - } + elseif ($mode == 5) + { + if ($status == 1) return $langs->trans('Enabled').$moretext.' '.img_picto($langs->trans('Enabled').$moretext, 'statut'.($processing?'1':'4'), 'class="pictostatus"'); + elseif ($status == 0) return $langs->trans('Disabled').$moretext.' '.img_picto($langs->trans('Disabled').$moretext, 'statut5', 'class="pictostatus"'); + } + } } @@ -1423,7 +1408,7 @@ class Cronjobline * Constructor * */ - function __construct() + public function __construct() { return 1; } diff --git a/htdocs/datapolicy/class/actions_datapolicy.class.php b/htdocs/datapolicy/class/actions_datapolicy.class.php index 7362542e8d6..e336e8d6df6 100644 --- a/htdocs/datapolicy/class/actions_datapolicy.class.php +++ b/htdocs/datapolicy/class/actions_datapolicy.class.php @@ -72,7 +72,7 @@ class ActionsDatapolicy * =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) + public function getNomUrl($parameters, &$object, &$action) { global $db, $langs, $conf, $user; $this->resprints = ''; @@ -300,7 +300,7 @@ class ActionsDatapolicy * =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) + public function beforePDFCreation($parameters, &$object, &$action) { global $conf, $user, $langs; global $hookmanager; @@ -329,7 +329,7 @@ class ActionsDatapolicy * @param HookManager $hookmanager Hook manager * @return void */ - function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) + public function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) { global $conf, $user, $langs; $langs->load('datapolicy@datapolicy'); @@ -388,7 +388,7 @@ class ActionsDatapolicy * @param HookManager $hookmanager Hook manager * @return void */ - function printCommonFooter($parameters, &$object, &$action, $hookmanager) + public function printCommonFooter($parameters, &$object, &$action, $hookmanager) { global $conf, $user, $langs; diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index b3cb0ce3cd9..ea720e0586f 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -35,7 +35,7 @@ Class DataPolicy * * @return number */ - function getAllContactNotInformed() + public function getAllContactNotInformed() { global $langs, $conf, $db, $user; @@ -71,7 +71,7 @@ Class DataPolicy * * @return number */ - function getAllCompaniesNotInformed() + public function getAllCompaniesNotInformed() { global $langs, $conf, $db, $user; @@ -106,7 +106,7 @@ Class DataPolicy * * @return number */ - function getAllAdherentsNotInformed() + public function getAllAdherentsNotInformed() { global $langs, $conf, $db, $user; @@ -142,73 +142,73 @@ Class DataPolicy * @param mixed $contact Contact * @return void */ - function sendMailDataPolicyContact($contact) + public function sendMailDataPolicyContact($contact) { - global $langs, $conf, $db, $user; + global $langs, $conf, $db, $user; - $error = 0; + $error = 0; - $from = $user->getFullName($langs) . ' <' . $user->email . '>'; + $from = $user->getFullName($langs) . ' <' . $user->email . '>'; - $sendto = $contact->email; - $code= md5($contact->email); - if (!empty($contact->default_lang)) { - $l = $contact->default_lang; - } else { - $l = $langs->defaultlang; - } - $s = "DATAPOLICIESSUBJECT_" . $l; - $ma = "DATAPOLICIESCONTENT_" . $l; - $la = 'TXTLINKDATAPOLICIESACCEPT_' . $l; - $lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; + $sendto = $contact->email; + $code= md5($contact->email); + if (!empty($contact->default_lang)) { + $l = $contact->default_lang; + } else { + $l = $langs->defaultlang; + } + $s = "DATAPOLICIESSUBJECT_" . $l; + $ma = "DATAPOLICIESCONTENT_" . $l; + $la = 'TXTLINKDATAPOLICIESACCEPT_' . $l; + $lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; - $subject = $conf->global->$s; - $message = $conf->global->$ma; - $linka = $conf->global->$la; - $linkr = $conf->global->$lr; - $sendtocc = $sendtobcc = ''; - $filepath = $mimetype = $filename = array(); - $deliveryreceipt = 0; + $subject = $conf->global->$s; + $message = $conf->global->$ma; + $linka = $conf->global->$la; + $linkr = $conf->global->$lr; + $sendtocc = $sendtobcc = ''; + $filepath = $mimetype = $filename = array(); + $deliveryreceipt = 0; - $substitutionarray = array( - '__LINKACCEPT__' => ''.$linka.'', - '__LINKREFUSED__' => ''.$linkr.'', - '__FIRSTNAME__' => $contact->firstname, - '__NAME__' => $contact->lastname, - '__CIVILITY__' => $contact->civility, - ); - $subject = make_substitutions($subject, $substitutionarray); - $message = make_substitutions($message, $substitutionarray); + $substitutionarray = array( + '__LINKACCEPT__' => ''.$linka.'', + '__LINKREFUSED__' => ''.$linkr.'', + '__FIRSTNAME__' => $contact->firstname, + '__NAME__' => $contact->lastname, + '__CIVILITY__' => $contact->civility, + ); + $subject = make_substitutions($subject, $substitutionarray); + $message = make_substitutions($message, $substitutionarray); - $actiontypecode = 'AC_EMAIL'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; - if ($message) { - if ($sendtocc) - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg = dol_concatdesc($actionmsg, $message); - } + $actiontypecode = 'AC_EMAIL'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; + if ($message) { + if ($sendtocc) + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); + } - // Send mail - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); + // Send mail + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); - if ($mailfile->error) { - $resultmasssend .= '
' . $mailfile->error . '
'; - } else { - $result4 = $mailfile->sendfile(); - if (!$error) { + if ($mailfile->error) { + $resultmasssend .= '
' . $mailfile->error . '
'; + } else { + $result4 = $mailfile->sendfile(); + if (!$error) { - $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; - $contact->array_options['options_datapolicy_send'] = date('Y-m-d', time()); - $contact->update($contact->id); - } else { - dol_print_error($db); - } - } - setEventMessage($resultmasssend); + $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; + $contact->array_options['options_datapolicy_send'] = date('Y-m-d', time()); + $contact->update($contact->id); + } else { + dol_print_error($db); + } + } + setEventMessage($resultmasssend); } /** @@ -217,46 +217,48 @@ Class DataPolicy * @param Societe $societe Object societe * @return void */ - function sendMailDataPolicyCompany($societe) + public function sendMailDataPolicyCompany($societe) { - global $langs, $conf, $db, $user; + global $langs, $conf, $db, $user; - $error = 0; + $error = 0; - $from = $user->getFullName($langs) . ' <' . $user->email . '>'; + $from = $user->getFullName($langs) . ' <' . $user->email . '>'; - $sendto = $societe->email; + $sendto = $societe->email; - $code= md5($societe->email); - if (!empty($societe->default_lang)) { - $l = $societe->default_lang; - } else { - $l = $langs->defaultlang; - } - $s = "DATAPOLICIESSUBJECT_" . $l; - $ma = "DATAPOLICIESCONTENT_" . $l; - $la = 'TXTLINKDATAPOLICIESACCEPT_' . $l; - $lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; + $code= md5($societe->email); + if (!empty($societe->default_lang)) { + $l = $societe->default_lang; + } else { + $l = $langs->defaultlang; + } + $s = "DATAPOLICIESSUBJECT_" . $l; + $ma = "DATAPOLICIESCONTENT_" . $l; + $la = 'TXTLINKDATAPOLICIESACCEPT_' . $l; + $lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; - $subject = $conf->global->$s; - $message = $conf->global->$ma; - $linka = $conf->global->$la; - $linkr = $conf->global->$lr; - $sendtocc = $sendtobcc = ''; - $filepath = $mimetype = $filename = array(); - $deliveryreceipt = 0; + $subject = $conf->global->$s; + $message = $conf->global->$ma; + $linka = $conf->global->$la; + $linkr = $conf->global->$lr; + $sendtocc = $sendtobcc = ''; + $filepath = $mimetype = $filename = array(); + $deliveryreceipt = 0; - $substitutionarray = array( + $substitutionarray = array( '__LINKACCEPT__' => ''.$linka.'', '__LINKREFUSED__' => ''.$linkr.'', - ); - $subject = make_substitutions($subject, $substitutionarray); - $message = make_substitutions($message, $substitutionarray); + ); + $subject = make_substitutions($subject, $substitutionarray); + $message = make_substitutions($message, $substitutionarray); - $actiontypecode = 'AC_EMAIL'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; - if ($message) { - if ($sendtocc) { + $actiontypecode = 'AC_EMAIL'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; + if ($message) + { + if ($sendtocc) + { $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); } $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); @@ -264,23 +266,23 @@ Class DataPolicy $actionmsg .= dol_concatdesc($actionmsg, $message); } - // Send mail - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); - if ($mailfile->error) { - $resultmasssend .= '
' . $mailfile->error . '
'; - } else { - $result4 = $mailfile->sendfile(); + // Send mail + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); + if ($mailfile->error) { + $resultmasssend .= '
' . $mailfile->error . '
'; + } else { + $result4 = $mailfile->sendfile(); - if (!$error) { - $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; - $societe->array_options['options_datapolicy_send'] = date('Y-m-d', time()); - $societe->update($societe->id); - } else { - dol_print_error($db); - } - } - setEventMessage($resultmasssend); + if (!$error) { + $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; + $societe->array_options['options_datapolicy_send'] = date('Y-m-d', time()); + $societe->update($societe->id); + } else { + dol_print_error($db); + } + } + setEventMessage($resultmasssend); } /** @@ -289,7 +291,7 @@ Class DataPolicy * @param Adherent $adherent Member * @return void */ - function sendMailDataPolicyAdherent($adherent) + public function sendMailDataPolicyAdherent($adherent) { global $langs, $conf, $db, $user; diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index 226fdf48c94..eea023951e3 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -41,7 +41,7 @@ class CdavLib * @param DoliDB $db Database handler * @param Translate $langs translation */ - function __construct($user, $db, $langs) + public function __construct($user, $db, $langs) { $this->user = $user; $this->db = $db; @@ -245,15 +245,15 @@ class CdavLib return $caldata; } - /** - * getFullCalendarObjects - * - * @param int $calendarId Calendar id - * @param int $bCalendarData Add calendar data - * @return array|string[][] - */ - public function getFullCalendarObjects($calendarId, $bCalendarData) - { + /** + * getFullCalendarObjects + * + * @param int $calendarId Calendar id + * @param int $bCalendarData Add calendar data + * @return array|string[][] + */ + public function getFullCalendarObjects($calendarId, $bCalendarData) + { $calid = ($calendarId*1); $calevents = array(); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 40d0616ad37..02a35deb70d 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -154,7 +154,7 @@ if ($action == 'add') if (! $error) { - $object->fk_soc = GETPOST("fk_soc", 'int'); + $object->socid = GETPOST("socid", 'int'); $object->firstname = GETPOST("firstname", 'alpha'); $object->lastname = GETPOST("lastname", 'alpha'); $object->societe = GETPOST("societe", 'alpha'); @@ -164,7 +164,7 @@ if ($action == 'add') $object->town = GETPOST("town", 'alpha'); $object->country_id = GETPOST('country_id', 'int'); $object->email = GETPOST('email', 'alpha'); - $object->date = $donation_date; + $object->date = $donation_date; $object->note_private = GETPOST("note_private", 'none'); $object->note_public = GETPOST("note_public", 'none'); $object->public = GETPOST("public", 'alpha'); @@ -372,7 +372,7 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").' '; print ''; } print '
' . "\n"; @@ -531,10 +531,10 @@ if (! empty($id) && $action == 'edit') print ""; print "\n"; -if ( $object->fk_soc && ! empty($conf->societe->enabled) && ! empty($conf->global->DONATION_USE_THIRDPARTIES) ) { +if ( $object->socid && ! empty($conf->societe->enabled) && ! empty($conf->global->DONATION_USE_THIRDPARTIES) ) { $company=new Societe($db); - $result=$company->fetch($object->fk_soc); + $result=$company->fetch($object->socid); print ''; } else { @@ -693,10 +693,10 @@ if (! empty($id) && $action != 'edit') print yn($object->public); print ''; -if ($object->fk_soc) { +if ($object->socid) { $company=new Societe($db); - $result=$company->fetch($object->fk_soc); + $result=$company->fetch($object->socid); print ''; } else { diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 6e38b67d2f1..06ddd5616c0 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -44,10 +44,10 @@ class Donations extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->don = new Don($this->db); } @@ -61,7 +61,7 @@ class Donations extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->don->lire) { throw new RestException(401); @@ -72,7 +72,7 @@ class Donations extends DolibarrApi throw new RestException(404, 'Donation not found'); } - if( ! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { + if( ! DolibarrApi::_checkAccessToResource('don', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -99,7 +99,7 @@ class Donations extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -115,7 +115,7 @@ class Donations extends DolibarrApi $sql.= ' WHERE t.entity IN ('.getEntity('don').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($thirdparty_ids) $sql.= " AND t.fk_soc = ".$thirdparty_ids." "; - + // Add sql filters if ($sqlfilters) { @@ -140,7 +140,7 @@ class Donations extends DolibarrApi dol_syslog("API Rest request"); $result = $db->query($sql); - + if ($result) { $num = $db->num_rows($result); @@ -164,7 +164,7 @@ class Donations extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No donation found'); } - + return $obj_ret; } @@ -174,15 +174,15 @@ class Donations extends DolibarrApi * @param array $request_data Request data * @return int ID of order */ - function post($request_data = null) + public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->don->creer) { + if (! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->don->$field = $value; } /*if (isset($request_data["lines"])) { @@ -208,7 +208,7 @@ class Donations extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); @@ -222,7 +222,7 @@ class Donations extends DolibarrApi if (! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->don->$field = $value; } @@ -243,7 +243,7 @@ class Donations extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->don->supprimer) { throw new RestException(401); @@ -291,7 +291,7 @@ class Donations extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); @@ -332,7 +332,7 @@ class Donations extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -354,7 +354,7 @@ class Donations extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $don = array(); foreach (Orders::$FIELDS as $field) { diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index f6c2ff1847c..de360d8cc3b 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Thibault FOUCART + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,7 +104,7 @@ class Don extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -115,12 +116,12 @@ class Don extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -128,7 +129,7 @@ class Don 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 Libelle du statut */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable if (empty($this->labelstatut) || empty($this->labelstatutshort)) @@ -198,7 +199,7 @@ class Don extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $conf, $user,$langs; @@ -257,7 +258,7 @@ class Don extends CommonObject * @param int $minimum Minimum * @return int 0 if KO, >0 if OK */ - function check($minimum = 0) + public function check($minimum = 0) { global $langs; $langs->load('main'); @@ -350,7 +351,7 @@ class Don extends CommonObject * @return int <0 if KO, id of created donation if OK * TODO add numbering module for Ref */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -395,7 +396,7 @@ class Don extends CommonObject $sql.= ", ".$conf->entity; $sql.= ", ".price2num($this->amount); $sql.= ", ".($this->modepaymentid?$this->modepaymentid:"null"); - $sql.= ", '".$this->db->escape($this->fk_soc)."'"; + $sql.= ", '".$this->db->escape($this->socid)."'"; $sql.= ", '".$this->db->escape($this->firstname)."'"; $sql.= ", '".$this->db->escape($this->lastname)."'"; $sql.= ", '".$this->db->escape($this->societe)."'"; @@ -429,7 +430,7 @@ class Don extends CommonObject // End call triggers } } - else + else { $this->error = $this->db->lasterror(); $this->errno = $this->db->lasterrno(); @@ -473,7 +474,7 @@ class Don extends CommonObject * @param int $notrigger Disable triggers * @return int >0 if OK, <0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs, $conf; @@ -564,7 +565,7 @@ class Don extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, 0 if not possible, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $user, $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -639,12 +640,12 @@ class Don extends CommonObject * @param string $ref Ref of donation to load * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; $sql = "SELECT d.rowid, d.datec, d.date_valid, d.tms as datem, d.datedon,"; - $sql.= " d.fk_soc,d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, "; + $sql.= " d.fk_soc as socid,d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, "; $sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, d.email, d.phone, "; $sql.= " d.phone_mobile, d.fk_projet as fk_project, d.model_pdf,"; $sql.= " p.ref as project_ref,"; @@ -672,40 +673,42 @@ class Don extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->datec = $this->db->jdate($obj->datec); - $this->date_valid = $this->db->jdate($obj->date_valid); - $this->datem = $this->db->jdate($obj->datem); - $this->date = $this->db->jdate($obj->datedon); - $this->fk_soc = $obj->fk_soc; - $this->firstname = $obj->firstname; - $this->lastname = $obj->lastname; - $this->societe = $obj->societe; - $this->statut = $obj->fk_statut; - $this->address = $obj->address; - $this->town = $obj->town; - $this->zip = $obj->zip; - $this->town = $obj->town; - $this->country_id = $obj->fk_country; - $this->country_code = $obj->country_code; - $this->country = $obj->country; - $this->country_olddata= $obj->country_olddata; // deprecated - $this->email = $obj->email; - $this->phone = $obj->phone; - $this->phone_mobile = $obj->phone_mobile; - $this->project = $obj->project_ref; - $this->fk_projet = $obj->fk_project; // deprecated - $this->fk_project = $obj->fk_project; - $this->public = $obj->public; - $this->modepaymentid = $obj->fk_payment; - $this->modepaymentcode = $obj->payment_code; - $this->modepayment = $obj->payment_label; - $this->paid = $obj->paid; - $this->amount = $obj->amount; - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->modelpdf = $obj->model_pdf; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->date_creation = $this->db->jdate($obj->datec); + $this->datec = $this->db->jdate($obj->datec); + $this->date_validation = $this->db->jdate($obj->date_valid); + $this->date_valid = $this->db->jdate($obj->date_valid); + $this->date_modification = $this->db->jdate($obj->datem); + $this->datem = $this->db->jdate($obj->datem); + $this->date = $this->db->jdate($obj->datedon); + $this->socid = $obj->socid; + $this->firstname = $obj->firstname; + $this->lastname = $obj->lastname; + $this->societe = $obj->societe; + $this->statut = $obj->fk_statut; + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->town; + $this->country_id = $obj->fk_country; + $this->country_code = $obj->country_code; + $this->country = $obj->country; + $this->country_olddata = $obj->country_olddata; // deprecated + $this->email = $obj->email; + $this->phone = $obj->phone; + $this->phone_mobile = $obj->phone_mobile; + $this->project = $obj->project_ref; + $this->fk_projet = $obj->fk_project; // deprecated + $this->fk_project = $obj->fk_project; + $this->public = $obj->public; + $this->mode_reglement_id = $obj->fk_payment; + $this->mode_reglement_code= $obj->payment_code; + $this->mode_reglement = $obj->payment_label; + $this->paid = $obj->paid; + $this->amount = $obj->amount; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->modelpdf = $obj->model_pdf; // Retreive all extrafield // fetch optionals attributes and labels @@ -727,12 +730,12 @@ class Don extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function setValid($user, $notrigger = 0) + public function setValid($user, $notrigger = 0) { return $this->valid_promesse($this->id, $user->id, $notrigger); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Validate a promise of donation * @@ -741,7 +744,7 @@ class Don extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function valid_promesse($id, $userid, $notrigger = 0) + public function valid_promesse($id, $userid, $notrigger = 0) { // phpcs:enable global $langs, $user; @@ -784,7 +787,7 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the donation as paid, the donation was received * @@ -792,7 +795,7 @@ class Don extends CommonObject * @param int $modepayment mode of payment * @return int <0 if KO, >0 if OK */ - function set_paid($id, $modepayment = 0) + public function set_paid($id, $modepayment = 0) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; @@ -821,14 +824,14 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set donation to status cancelled * * @param int $id id of donation * @return int <0 if KO, >0 if OK */ - function set_cancel($id) + public function set_cancel($id) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = -1 WHERE rowid = ".$id; @@ -852,14 +855,14 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Sum of donations * * @param string $param 1=promesses de dons validees , 2=xxx, 3=encaisses * @return int Summ of donations */ - function sum_donations($param) + public function sum_donations($param) { // phpcs:enable global $conf; @@ -881,13 +884,13 @@ class Don extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb pour le tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -924,7 +927,7 @@ class Don extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $notooltip = 0) { global $langs; @@ -948,7 +951,7 @@ class Don extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT d.rowid, d.datec, d.fk_user_author, d.fk_user_valid,'; $sql.= ' d.tms'; diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 2418f1babfd..bf6a61bb248 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -39,12 +39,12 @@ class DonationStats 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; /** @@ -55,7 +55,7 @@ class DonationStats extends Stats * @param string $mode Option (not used) * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -77,13 +77,13 @@ class DonationStats extends Stats } /** - * Return shipment number by month for a year + * Return shipment number by month for a year * - * @param int $year Year to scan - * @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 with number by month + * @param int $year Year to scan + * @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 with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -104,7 +104,7 @@ class DonationStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -117,21 +117,21 @@ class DonationStats extends Stats return $this->_getNbByYear($sql); } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - global $user; + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + global $user; - $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index deec339c1cc..ac35e3f5c44 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -88,7 +88,7 @@ class PaymentDonation extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -101,7 +101,7 @@ class PaymentDonation extends CommonObject * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, id of payment if OK */ - function create($user, $notrigger = false) + public function create($user, $notrigger = false) { global $conf, $langs; @@ -193,7 +193,7 @@ class PaymentDonation extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -264,7 +264,7 @@ class PaymentDonation extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -344,7 +344,7 @@ class PaymentDonation 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; @@ -411,7 +411,7 @@ class PaymentDonation extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -467,12 +467,12 @@ class PaymentDonation extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -480,13 +480,13 @@ class PaymentDonation 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 Libelle du statut */ - function LibStatut($statut, $mode = 0) - { + public function LibStatut($statut, $mode = 0) + { // phpcs:enable global $langs; - return ''; - } + return ''; + } /** @@ -496,7 +496,7 @@ class PaymentDonation extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -526,7 +526,7 @@ class PaymentDonation extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $conf; @@ -597,14 +597,14 @@ class PaymentDonation extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Update link between the donation payment and the generated line in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -629,7 +629,7 @@ class PaymentDonation extends CommonObject * @param int $maxlen Longueur max libelle * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 1d2b7f34ba6..d0f4f3e6567 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -105,7 +105,7 @@ class EcmDirectory // extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; return 1; @@ -118,7 +118,7 @@ class EcmDirectory // extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -230,7 +230,7 @@ class EcmDirectory // extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -288,7 +288,7 @@ class EcmDirectory // extends CommonObject * @param string $value '+' or '-' or new number * @return int <0 if KO, >0 if OK */ - function changeNbOfFiles($value) + public function changeNbOfFiles($value) { // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; @@ -320,7 +320,7 @@ class EcmDirectory // extends CommonObject * @param int $id Id of object * @return int <0 if KO, 0 if not found, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -375,7 +375,7 @@ class EcmDirectory // extends CommonObject * @param int $deletedirrecursive 1=Agree to delete content recursiveley (otherwise an error will be returned when trying to delete) * @return int <0 if KO, >0 if OK */ - function delete($user, $mode = 'all', $deletedirrecursive = 0) + public function delete($user, $mode = 'all', $deletedirrecursive = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -448,7 +448,7 @@ class EcmDirectory // extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -468,7 +468,7 @@ class EcmDirectory // extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0) { global $langs; @@ -501,7 +501,7 @@ class EcmDirectory // extends CommonObject * @param int $force Force reload of full arbo even if already loaded * @return string Relative physical path */ - function getRelativePath($force = 0) + public function getRelativePath($force = 0) { $this->get_full_arbo($force); @@ -535,13 +535,13 @@ class EcmDirectory // extends CommonObject return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load this->motherof that is array(id_son=>id_parent, ...) * * @return int <0 if KO, >0 if OK */ - function load_motherof() + public function load_motherof() { // phpcs:enable global $conf; @@ -579,12 +579,12 @@ class EcmDirectory // 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 * @@ -592,7 +592,7 @@ class EcmDirectory // 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, 5=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; @@ -600,7 +600,7 @@ class EcmDirectory // extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: @@ -620,7 +620,7 @@ class EcmDirectory // extends CommonObject * @param int $force Force reload of full arbo even if already loaded in cache $this->cats * @return array Tableau de array */ - function get_full_arbo($force = 0) + public function get_full_arbo($force = 0) { // phpcs:enable global $conf; @@ -701,7 +701,7 @@ class EcmDirectory // extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define properties fullpath, fullrelativename, fulllabel of a directory of array this->cats and all its childs. * Separator between directories is always '/', whatever is OS. @@ -710,7 +710,7 @@ class EcmDirectory // extends CommonObject * @param int $protection Deep counter to avoid infinite loop * @return void */ - function build_path_from_id_categ($id_categ, $protection = 0) + public function build_path_from_id_categ($id_categ, $protection = 0) { // phpcs:enable // Define fullpath @@ -750,7 +750,7 @@ class EcmDirectory // extends CommonObject * @param int $all 0=refresh record using this->id , 1=refresh record using this->entity * @return int -1 if KO, Nb of files in directory if OK */ - function refreshcachenboffile($all = 0) + public function refreshcachenboffile($all = 0) { global $conf; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -787,7 +787,7 @@ class EcmDirectory // extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Call trigger based on this instance * @@ -799,7 +799,7 @@ class EcmDirectory // extends CommonObject * @param User $user Object user * @return int Result of run_triggers */ - function call_trigger($trigger_name, $user) + public function call_trigger($trigger_name, $user) { // phpcs:enable global $langs,$conf; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 3b229f48c1c..4f4c8dfea61 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -28,8 +28,6 @@ // Put here all includes required by your class file 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 to manage ECM files @@ -766,7 +764,7 @@ class EcmFiles extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -815,12 +813,12 @@ class EcmFiles 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 * @@ -828,7 +826,7 @@ class EcmFiles 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, 5=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; diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index 7877b85b0a5..c210d0ae2d4 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -27,15 +27,15 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; */ class FormEcm { - /** + /** * @var DoliDB Database handler. */ public $db; - - /** - * @var string Error code (or message) - */ - public $error=''; + + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -43,7 +43,7 @@ class FormEcm * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -57,7 +57,7 @@ class FormEcm * @param string $module Module ('ecm', 'medias', ...) * @return string String with HTML select */ - function selectAllSections($selected = 0, $select_name = '', $module = 'ecm') + public function selectAllSections($selected = 0, $select_name = '', $module = 'ecm') { global $conf, $langs; $langs->load("ecm"); @@ -70,7 +70,7 @@ class FormEcm $cat = new EcmDirectory($this->db); $cate_arbo = $cat->get_full_arbo(); } - if ($module == 'medias') + elseif ($module == 'medias') { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $path = $conf->medias->multidir_output[$conf->entity]; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 7a4744d789f..e0f745dabec 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -99,22 +99,22 @@ class EmailCollector extends CommonObject 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'comment'=>"IMAP password"), 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'), - //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), - //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), + //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), + //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), - 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), + 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), - //'date_validation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), - //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active')) + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), + //'date_validation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), + //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active')) ); @@ -305,14 +305,16 @@ class EmailCollector extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - /*public function fetchLines() - { - $this->lines=array(); + /* + public function fetchLines() + { + $this->lines=array(); - // Load lines with object EmailCollectorLine + // Load lines with object EmailCollectorLine - return count($this->lines)?1:0; - }*/ + return count($this->lines)?1:0; + } + */ /** * Fetch all account and load objects into an array @@ -407,7 +409,7 @@ class EmailCollector 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, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -549,7 +551,7 @@ class EmailCollector extends CommonObject */ public function info($id) { - $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql.= ' fk_user_creat, fk_user_modif'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql.= ' WHERE t.rowid = '.$id; @@ -673,7 +675,7 @@ class EmailCollector extends CommonObject * * @return string */ - function getConnectStringIMAP() + public function getConnectStringIMAP() { // Connect to IMAP $flags ='/service=imap'; // IMAP diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index 6eec6190b71..11ccfbc858e 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -32,298 +32,298 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; */ class EmailCollectorAction extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'emailcollectoraction'; + /** + * @var string ID to identify managed object + */ + public $element = 'emailcollectoraction'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'emailcollector_emailcollectoraction'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'emailcollector_emailcollectoraction'; - /** - * @var int Does emailcollectoraction support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - */ - public $ismultientitymanaged = 0; + /** + * @var int Does emailcollectoraction support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; - /** - * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 0; + /** + * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; - /** - * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png - */ - public $picto = 'emailcollectoraction@emailcollector'; + /** + * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png + */ + public $picto = 'emailcollectoraction@emailcollector'; - /** - * 'type' if the field format. - * 'label' the translation key. - * 'enabled' is a condition when the field must be managed. - * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). - * 'default' is a default value for creation (can still be replaced by the global setup of default values) - * 'index' if we want an index in database. - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). - * 'position' is the sort order of field. - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. - * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'css' is the CSS style to use on field. For example: 'maxwidth200' - * 'help' is a string visible as a tooltip on field - * 'comment' is not used. You can store here any text of your choice. It is not used by application. - * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record - * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") - */ + /** + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ - // BEGIN MODULEBUILDER PROPERTIES - /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. - */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'fk_emailcollector' => array('type'=>'integer', 'label'=>'Id of emailcollector', 'foreignkey'=>'emailcollector.rowid'), - 'type' => array('type'=>'varchar(128)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1), - 'actionparam' => array('type'=>'varchar(255)', 'label'=>'ParamForAction', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>-1), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), - 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',), - 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), - 'position' => array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>1, 'position'=>600, 'default'=>'0',), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled')), - ); - public $rowid; - public $fk_emailcollector; - public $type; - public $actionparam; - public $date_creation; - public $tms; - public $fk_user_creat; - public $fk_user_modif; - public $position; - public $import_key; - public $status; - // END MODULEBUILDER PROPERTIES + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'fk_emailcollector' => array('type'=>'integer', 'label'=>'Id of emailcollector', 'foreignkey'=>'emailcollector.rowid'), + 'type' => array('type'=>'varchar(128)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1), + 'actionparam' => array('type'=>'varchar(255)', 'label'=>'ParamForAction', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>-1), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), + 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',), + 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), + 'position' => array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>1, 'position'=>600, 'default'=>'0',), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled')), + ); + public $rowid; + public $fk_emailcollector; + public $type; + public $actionparam; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $position; + public $import_key; + public $status; + // END MODULEBUILDER PROPERTIES - // If this object has a subtable with lines + // If this object has a subtable with lines - /** - * @var int Name of subtable line - */ - //public $table_element_line = 'emailcollectoractiondet'; + // /** + // * @var int Name of subtable line + // */ + //public $table_element_line = 'emailcollectoractiondet'; - /** - * @var int Field with ID of parent key if this field has a parent - */ - //public $fk_element = 'fk_emailcollectoraction'; + // /** + // * @var int Field with ID of parent key if this field has a parent + // */ + //public $fk_element = 'fk_emailcollectoraction'; - /** - * @var int Name of subtable class that manage subtable lines - */ - //public $class_element_line = 'EmailcollectorActionline'; + // /** + // * @var int Name of subtable class that manage subtable lines + // */ + //public $class_element_line = 'EmailcollectorActionline'; - /** - * @var array Array of child tables (child tables to delete before deleting a record) - */ - //protected $childtables=array('emailcollectoractiondet'); + // /** + // * @var array Array of child tables (child tables to delete before deleting a record) + // */ + //protected $childtables=array('emailcollectoractiondet'); - /** - * @var EmailcollectorActionLine[] Array of subtable lines - */ - //public $lines = array(); + // /** + // * @var EmailcollectorActionLine[] Array of subtable lines + // */ + //public $lines = array(); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct(DoliDB $db) - { - global $conf, $langs, $user; + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs, $user; - $this->db = $db; + $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; - // Unset fields that are disabled - foreach($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { - unset($this->fields[$key]); - } - } + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } - // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) - { - if (is_array($this->fields['status']['arrayofkeyval'])) - { - foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) - { - $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); - } - } - } - } + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($this->fields['status']['arrayofkeyval'])) + { + foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) + { + $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = false) - { - global $langs; - if (empty($this->type)) - { - $langs->load("errors"); - $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); - return -1; - } + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + global $langs; + if (empty($this->type)) + { + $langs->load("errors"); + $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + return -1; + } - return $this->createCommon($user, $notrigger); - } + return $this->createCommon($user, $notrigger); + } - /** - * Clone and object into another one - * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO - */ - public function createFromClone(User $user, $fromid) - { - global $langs, $hookmanager, $extrafields; - $error = 0; + /** + * Clone and object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $hookmanager, $extrafields; + $error = 0; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $object = new self($this->db); + $object = new self($this->db); - $this->db->begin(); + $this->db->begin(); - // Load source object - $object->fetchCommon($fromid); - // Reset some properties - unset($object->id); - unset($object->fk_user_creat); - unset($object->import_key); + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... - // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { - $extrafields->fetch_name_optionals_label($this->element); - foreach($object->array_options as $key => $option) - { - $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) - { - //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; - unset($object->array_options[$key]); - } - } - } + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } - // Create clone - $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); - if ($result < 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - } + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } - unset($object->context['createfromclone']); + unset($object->context['createfromclone']); - // End - if (!$error) { - $this->db->commit(); - return $object; - } else { - $this->db->rollback(); - return -1; - } - } + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetch($id, $ref = null) - { - $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); - return $result; - } + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - /*public function fetchLines() - { - $this->lines=array(); + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $this->lines=array(); - // Load lines with object EmailcollectorActionLine + // Load lines with object EmailcollectorActionLine - return count($this->lines)?1:0; - }*/ + return count($this->lines)?1:0; + }*/ - /** - * Update object into database - * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = false) - { - return $this->updateCommon($user, $notrigger); - } + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } - /** - * Delete object in database - * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - return $this->deleteCommon($user, $notrigger); - } + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } - /** - * 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', ...) + /** + * 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 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; @@ -340,10 +340,10 @@ class EmailCollectorAction 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=''; @@ -366,152 +366,152 @@ class EmailCollectorAction extends CommonObject } 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; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $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; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; - $hookmanager->initHooks(array('emailcollectoractiondao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + global $action,$hookmanager; + $hookmanager->initHooks(array('emailcollectoractiondao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * Return label of the status - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } + /** + * Return label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return the status - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - if (empty($this->labelstatus)) - { - global $langs; - //$langs->load("emailcollector"); - $this->labelstatus[1] = $langs->trans('Enabled'); - $this->labelstatus[0] = $langs->trans('Disabled'); - } + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("emailcollector"); + $this->labelstatus[1] = $langs->trans('Enabled'); + $this->labelstatus[0] = $langs->trans('Disabled'); + } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - } + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 3) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 4) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 5) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 6) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + } - /** - * Charge les informations d'ordre info dans l'objet commande - * - * @param int $id Id of order - * @return void - */ - public function info($id) - { - $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } + /** + * Charge les informations d'ordre info dans l'objet commande + * + * @param int $id Id of order + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } - if ($obj->fk_user_valid) - { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } - if ($obj->fk_user_cloture) - { - $cluser = new User($this->db); - $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; - } + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - public function initAsSpecimen() - { - $this->initAsSpecimenCommon(); - } + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index e0556bf865b..d46dfb1c9ae 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -296,7 +296,7 @@ class EmailCollectorFilter 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, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 4886d5c5086..c386327bea6 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -960,7 +960,7 @@ if ($action == 'create') print ''; print ''; print ''; } diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 3352927f7c9..73923105c7d 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -46,10 +46,10 @@ class Shipments extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->shipment = new Expedition($this->db); } @@ -60,26 +60,26 @@ class Shipments extends DolibarrApi * * @param int $id ID of shipment * @return array|mixed data without useless information - * + * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->expedition->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expedition->lire) { + throw new RestException(401); + } $result = $this->shipment->fetch($id); if( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->shipment->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->shipment); + return $this->_cleanObjectDatas($this->shipment); } @@ -97,9 +97,9 @@ class Shipments extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of shipment objects * - * @throws RestException + * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -134,7 +134,7 @@ class Shipments extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -173,7 +173,7 @@ class Shipments extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No shipment found'); } - return $obj_ret; + return $obj_ret; } /** @@ -182,7 +182,7 @@ class Shipments extends DolibarrApi * @param array $request_data Request data * @return int ID of shipment */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,7 +218,7 @@ class Shipments extends DolibarrApi * @return int */ /* - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->expedition->lire) { throw new RestException(401); @@ -252,7 +252,7 @@ class Shipments extends DolibarrApi * @return int */ /* - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -315,7 +315,7 @@ class Shipments extends DolibarrApi * @return object */ /* - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -376,32 +376,32 @@ class Shipments extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->expedition->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expedition->creer) { + throw new RestException(401); + } - $result = $this->shipment->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Shipment not found'); - } + $result = $this->shipment->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Shipment not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - // TODO Check the lineid $lineid is a line of ojbect + // TODO Check the lineid $lineid is a line of ojbect - $request_data = (object) $request_data; - $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); - if ($updateRes > 0) { - return $this->get($id); - } - else - { - throw new RestException(405, $this->shipment->error); - } + $request_data = (object) $request_data; + $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); + if ($updateRes > 0) { + return $this->get($id); + } + else + { + throw new RestException(405, $this->shipment->error); + } } /** @@ -412,7 +412,7 @@ class Shipments extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -423,9 +423,9 @@ class Shipments extends DolibarrApi throw new RestException(404, 'Shipment not found'); } - if (! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->shipment->$field = $value; @@ -437,7 +437,7 @@ class Shipments extends DolibarrApi } else { - throw new RestException(500, $this->shipment->error); + throw new RestException(500, $this->shipment->error); } } @@ -448,19 +448,19 @@ class Shipments extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->shipment->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->shipment->fetch($id); if( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->shipment->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting shipment : '.$this->shipment->error); @@ -493,26 +493,26 @@ class Shipments extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->shipment->fetch($id); if ( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if ( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->shipment->valid(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error); + $result = $this->shipment->valid(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error); } $result = $this->shipment->fetch($id); if ( ! $result ) { @@ -542,7 +542,8 @@ class Shipments extends DolibarrApi * @throws 404 * @throws 405 */ -/* function setinvoiced($id) + /* + public function setinvoiced($id) { if(! DolibarrApiAccess::$user->rights->expedition->creer) { @@ -562,7 +563,7 @@ class Shipments extends DolibarrApi } return $result; } -*/ + */ /** @@ -579,7 +580,7 @@ class Shipments extends DolibarrApi * @throws 405 */ /* - function createShipmentFromOrder($orderid) + public function createShipmentFromOrder($orderid) { require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; @@ -607,7 +608,7 @@ class Shipments extends DolibarrApi $this->shipment->fetchObjectLinked(); return $this->_cleanObjectDatas($this->shipment); } - */ + */ /** * Clean sensible object datas @@ -615,7 +616,7 @@ class Shipments extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -633,15 +634,15 @@ class Shipments extends DolibarrApi { foreach ($object->lines as $line) { - unset($line->tva_tx); - unset($line->vat_src_code); - unset($line->total_ht); - unset($line->total_ttc); - unset($line->total_tva); - unset($line->total_localtax1); - unset($line->total_localtax2); - unset($line->remise_percent); - } + unset($line->tva_tx); + unset($line->vat_src_code); + unset($line->total_ht); + unset($line->total_ttc); + unset($line->total_tva); + unset($line->total_localtax1); + unset($line->total_localtax2); + unset($line->remise_percent); + } } return $object; @@ -654,7 +655,7 @@ class Shipments extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $shipment = array(); foreach (Shipments::$FIELDS as $field) { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 1ac9294d1f5..1f61accee80 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -171,7 +171,7 @@ class Expedition extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -207,7 +207,7 @@ class Expedition extends CommonObject * @param Societe $soc Thirdparty object * @return string Free reference for contract */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $langs, $conf; $langs->load("sendings"); @@ -264,7 +264,7 @@ class Expedition extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si erreur, id expedition creee si ok */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $hookmanager; @@ -434,7 +434,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a expedition line * @@ -444,7 +444,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, line_id if OK */ - function create_line($entrepot_id, $origin_line_id, $qty, $array_options = 0) + public function create_line($entrepot_id, $origin_line_id, $qty, $array_options = 0) { //phpcs:enable $expeditionline = new ExpeditionLigne($this->db); @@ -462,7 +462,7 @@ class Expedition extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create the detail (eat-by date) of the expedition line * @@ -470,7 +470,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function create_line_batch($line_ext, $array_options = 0) + public function create_line_batch($line_ext, $array_options = 0) { // phpcs:enable $error = 0; @@ -520,14 +520,14 @@ class Expedition extends CommonObject * @param string $ref_int Internal reference of other object * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') { global $conf; // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet, e.billed"; + $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed"; $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; $sql.= ", e.fk_shipping_method, e.tracking_number"; @@ -575,7 +575,7 @@ class Expedition extends CommonObject $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility $this->origin_id = $obj->origin_id; $this->billed = $obj->billed; - $this->fk_project = $obj->fk_projet; + $this->fk_project = $obj->fk_project; $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units; @@ -646,7 +646,7 @@ class Expedition extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if OK, >0 if KO */ - function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { global $conf, $langs; @@ -862,14 +862,14 @@ class Expedition extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a delivery receipt from a shipment * * @param User $user User * @return int <0 if KO, >=0 if OK */ - function create_delivery($user) + public function create_delivery($user) { // phpcs:enable global $conf; @@ -908,7 +908,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function addline($entrepot_id, $id, $qty, $array_options = 0) + public function addline($entrepot_id, $id, $qty, $array_options = 0) { global $conf, $langs; @@ -971,7 +971,7 @@ class Expedition extends CommonObject $this->lines[$num] = $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a shipment line with batch record * @@ -979,7 +979,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function addline_batch($dbatch, $array_options = 0) + public function addline_batch($dbatch, $array_options = 0) { // phpcs:enable global $conf,$langs; @@ -1048,7 +1048,7 @@ class Expedition 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; $error=0; @@ -1152,7 +1152,7 @@ class Expedition extends CommonObject * * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO */ - function delete() + public function delete() { global $conf, $langs, $user; @@ -1360,13 +1360,13 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines * * @return int >0 if OK, Otherwise if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable global $conf, $mysoc; @@ -1548,7 +1548,7 @@ class Expedition extends CommonObject * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - function deleteline($user, $lineid) + public function deleteline($user, $lineid) { global $user; @@ -1593,7 +1593,7 @@ class Expedition 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 = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $langs; @@ -1643,12 +1643,12 @@ class Expedition 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 * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1656,7 +1656,7 @@ class Expedition 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 * @return string Label of status */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1700,7 +1700,7 @@ class Expedition extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $langs; @@ -1772,7 +1772,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the planned delivery date * @@ -1780,7 +1780,7 @@ class Expedition extends CommonObject * @param timestamp $date_livraison Date de livraison * @return int <0 if KO, >0 if OK */ - function set_date_livraison($user, $date_livraison) + public function set_date_livraison($user, $date_livraison) { // phpcs:enable if ($user->rights->expedition->creer) @@ -1808,13 +1808,13 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch deliveries method and return an array. Load array this->meths(rowid=>label). * * @return void */ - function fetch_delivery_methods() + public function fetch_delivery_methods() { // phpcs:enable global $langs; @@ -1836,14 +1836,14 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch all deliveries method and return an array. Load array this->listmeths. * * @param id $id only this carrier, all if none * @return void */ - function list_delivery_methods($id = '') + public function list_delivery_methods($id = '') { // phpcs:enable global $langs; @@ -1872,7 +1872,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update/create delivery method. * @@ -1880,7 +1880,7 @@ class Expedition extends CommonObject * * @return void */ - function update_delivery_method($id = '') + public function update_delivery_method($id = '') { // phpcs:enable if ($id=='') @@ -1902,7 +1902,7 @@ class Expedition extends CommonObject if ($resql < 0) dol_print_error($this->db, ''); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate delivery method. * @@ -1910,7 +1910,7 @@ class Expedition extends CommonObject * * @return void */ - function activ_delivery_method($id) + public function activ_delivery_method($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; @@ -1919,7 +1919,7 @@ class Expedition extends CommonObject $resql = $this->db->query($sql); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * DesActivate delivery method. * @@ -1927,7 +1927,7 @@ class Expedition extends CommonObject * * @return void */ - function disable_delivery_method($id) + public function disable_delivery_method($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; @@ -1943,7 +1943,7 @@ class Expedition extends CommonObject * @param string $value Value * @return void */ - function getUrlTrackingStatus($value = '') + public function getUrlTrackingStatus($value = '') { if (! empty($this->shipping_method_id)) { @@ -1977,7 +1977,7 @@ class Expedition extends CommonObject * * @return int <0 if KO, >0 if OK */ - function setClosed() + public function setClosed() { global $conf,$langs,$user; @@ -2123,13 +2123,13 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) * * @return int <0 if ko, >0 if ok */ - function set_billed() + public function set_billed() { // phpcs:enable global $user; @@ -2174,7 +2174,7 @@ class Expedition extends CommonObject * * @return int <0 if KO, 0 if already open, >0 if OK */ - function reOpen() + public function reOpen() { global $conf,$langs,$user; @@ -2273,14 +2273,13 @@ class Expedition extends CommonObject } } - if (! $error) - { + if (! $error) { // Call trigger $result=$this->call_trigger('SHIPPING_REOPEN', $user); if ($result < 0) { $error++; } - } + } } else { $error++; $this->errors[]=$this->db->lasterror(); @@ -2510,7 +2509,7 @@ class ExpeditionLigne extends CommonObjectLine * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } @@ -2521,7 +2520,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $rowid Id line order * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT ed.rowid, ed.fk_expedition, ed.fk_entrepot, ed.fk_origin_line, ed.qty, ed.rang'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as ed'; @@ -2556,7 +2555,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $notrigger 1 = disable triggers * @return int <0 if KO, line id >0 if OK */ - function insert($user = null, $notrigger = 0) + public function insert($user = null, $notrigger = 0) { global $langs, $conf; @@ -2638,7 +2637,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int >0 if OK, <0 if KO */ - function delete($user = null, $notrigger = 0) + public function delete($user = null, $notrigger = 0) { global $conf; @@ -2715,7 +2714,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $notrigger 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; diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index e15e766c439..1cc0f277af6 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -35,21 +35,21 @@ class ExpeditionLineBatch extends CommonObject private static $_table_element='expeditiondet_batch'; //!< Name of table without prefix where object is stored - var $sellby; - var $eatby; - var $batch; - var $qty; - var $dluo_qty; // deprecated, use qty - var $entrepot_id; - var $fk_origin_stock; - var $fk_expeditiondet; + public $sellby; + public $eatby; + public $batch; + public $qty; + public $dluo_qty; // deprecated, use qty + public $entrepot_id; + public $fk_origin_stock; + public $fk_expeditiondet; /** * Constructor * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -60,7 +60,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $id_stockdluo Rowid in product_batch table * @return int -1 if KO, 1 if OK */ - function fetchFromStock($id_stockdluo) + public function fetchFromStock($id_stockdluo) { $sql = "SELECT"; $sql.= " pb.batch,"; @@ -104,7 +104,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $id_line_expdet rowid of expedtiondet record * @return int <0 if KO, Id of record (>0) if OK */ - function create($id_line_expdet) + public function create($id_line_expdet) { $error = 0; @@ -155,7 +155,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $id_expedition rowid of shipment * @return int -1 if KO, 1 if OK */ - static function deletefromexp($db, $id_expedition) + public static function deletefromexp($db, $id_expedition) { $id_expedition = (int) $id_expedition; @@ -181,7 +181,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $fk_product If provided, load also detailed information of lot * @return int|array -1 if KO, array of ExpeditionLineBatch if OK */ - static function fetchAll($db, $id_line_expdet, $fk_product = 0) + public static function fetchAll($db, $id_line_expdet, $fk_product = 0) { $sql="SELECT"; $sql.= " eb.rowid,"; diff --git a/htdocs/expedition/class/expeditionstats.class.php b/htdocs/expedition/class/expeditionstats.class.php index e1bb3c0b219..d6ac5e2242a 100644 --- a/htdocs/expedition/class/expeditionstats.class.php +++ b/htdocs/expedition/class/expeditionstats.class.php @@ -34,17 +34,17 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class ExpeditionStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -55,7 +55,7 @@ class ExpeditionStats extends Stats * @param string $mode Option (not used) * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -88,7 +88,7 @@ class ExpeditionStats 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 with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -110,7 +110,7 @@ class ExpeditionStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -129,7 +129,7 @@ class ExpeditionStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index a490089325d..be7bcfa50ef 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -357,7 +357,7 @@ if ($resql) if (! empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 02e1021a141..35ce9f9a4a2 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -45,7 +45,7 @@ class ExpenseReports extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -59,26 +59,26 @@ class ExpenseReports extends DolibarrApi * * @param int $id ID of Expense Report * @return array|mixed Data without useless information - * + * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->expensereport->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expensereport->lire) { + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'Expense report not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->expensereport->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->expensereport); + return $this->_cleanObjectDatas($this->expensereport); } /** @@ -94,7 +94,7 @@ class ExpenseReports extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of Expense Report objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; @@ -115,7 +115,7 @@ class ExpenseReports extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -152,7 +152,7 @@ class ExpenseReports extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No Expense Report found'); } - return $obj_ret; + return $obj_ret; } /** @@ -161,7 +161,7 @@ class ExpenseReports extends DolibarrApi * @param array $request_data Request data * @return int ID of Expense Report */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401, "Insuffisant rights"); @@ -195,8 +195,8 @@ class ExpenseReports extends DolibarrApi * * @return int */ -/* - function getLines($id) + /* + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->expensereport->lire) { throw new RestException(401); @@ -217,7 +217,7 @@ class ExpenseReports extends DolibarrApi } return $result; } -*/ + */ /** * Add a line to given Expense Report @@ -229,22 +229,22 @@ class ExpenseReports extends DolibarrApi * * @return int */ -/* - function postLine($id, $request_data = null) + /* + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + $request_data = (object) $request_data; $updateRes = $this->expensereport->addline( $request_data->desc, $request_data->subprice, @@ -279,7 +279,7 @@ class ExpenseReports extends DolibarrApi } return false; } -*/ + */ /** * Update a line to given Expense Report @@ -293,22 +293,22 @@ class ExpenseReports extends DolibarrApi * @return object */ /* - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } - $result = $this->expensereport->fetch($id); - if( ! $result ) { - throw new RestException(404, 'expensereport not found'); - } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->expensereport->updateline( + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->expensereport->updateline( $lineid, $request_data->desc, $request_data->subprice, @@ -330,16 +330,16 @@ class ExpenseReports extends DolibarrApi $request_data->special_code, $request_data->array_options, $request_data->fk_unit - ); + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } - return false; + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; } - */ + */ /** * Delete a line of given Expense Report @@ -352,19 +352,19 @@ class ExpenseReports extends DolibarrApi * @return int */ /* - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of ojbect @@ -385,7 +385,7 @@ class ExpenseReports extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401); @@ -407,11 +407,11 @@ class ExpenseReports extends DolibarrApi if ($this->expensereport->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); - } - else - { - throw new RestException(500, $this->expensereport->error); - } + } + else + { + throw new RestException(500, $this->expensereport->error); + } } /** @@ -421,19 +421,19 @@ class ExpenseReports extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->expensereport->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'Expense Report not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->expensereport->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Expense Report : '.$this->expensereport->error); @@ -463,19 +463,19 @@ class ExpenseReports extends DolibarrApi * } */ /* - function validate($id, $idwarehouse=0) + public function validate($id, $idwarehouse=0) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->expensereport->valid(DolibarrApiAccess::$user, $idwarehouse)) { throw new RestException(500, 'Error when validate expensereport'); @@ -495,17 +495,17 @@ class ExpenseReports extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); - return $object; + return $object; } /** @@ -515,7 +515,7 @@ class ExpenseReports extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $expensereport = array(); foreach (ExpenseReports::$FIELDS as $field) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 8dc0cbcdcf8..bbada0e22f7 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -44,62 +44,62 @@ class ExpenseReport extends CommonObject */ public $table_element='expensereport'; - var $table_element_line = 'expensereport_det'; - var $fk_element = 'fk_expensereport'; - var $picto = 'trip'; + public $table_element_line = 'expensereport_det'; + public $fk_element = 'fk_expensereport'; + public $picto = 'trip'; - var $lines=array(); + public $lines=array(); public $date_debut; public $date_fin; - var $status; - var $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied - var $fk_c_paiement; - var $paid; + public $status; + public $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied + public $fk_c_paiement; + public $paid; - var $user_author_infos; - var $user_validator_infos; + public $user_author_infos; + public $user_validator_infos; - var $fk_typepayment; - var $num_payment; - var $code_paiement; - var $code_statut; + public $fk_typepayment; + public $num_payment; + public $code_paiement; + public $code_statut; // ACTIONS // Create - var $date_create; - var $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. + public $date_create; + public $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. // Update - var $date_modif; - var $fk_user_modif; + public $date_modif; + public $fk_user_modif; // Refus - var $date_refuse; - var $detail_refuse; - var $fk_user_refuse; + public $date_refuse; + public $detail_refuse; + public $fk_user_refuse; // Annulation - var $date_cancel; - var $detail_cancel; - var $fk_user_cancel; + public $date_cancel; + public $detail_cancel; + public $fk_user_cancel; - var $fk_user_validator; // User that is defined to approve + public $fk_user_validator; // User that is defined to approve // Validation - var $date_valid; // User making validation - var $fk_user_valid; - var $user_valid_infos; + public $date_valid; // User making validation + public $fk_user_valid; + public $user_valid_infos; // Approve - var $date_approve; - var $fk_user_approve; // User that has approved + public $date_approve; + public $fk_user_approve; // User that has approved // Paiement - var $user_paid_infos; + public $user_paid_infos; /* END ACTIONS @@ -137,7 +137,7 @@ class ExpenseReport extends CommonObject * * @param DoliDB $db Handler acces base de donnees */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->total_ht = 0; @@ -155,10 +155,10 @@ class ExpenseReport extends CommonObject * Create object in database * * @param User $user User that create - * @param int $notrigger Disable triggers + * @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; @@ -307,7 +307,7 @@ class ExpenseReport extends CommonObject * @param int $fk_user_author Id of new user * @return int New id of clone */ - function createFromClone($fk_user_author) + public function createFromClone($fk_user_author) { global $user,$hookmanager; @@ -377,7 +377,7 @@ class ExpenseReport extends CommonObject * @param User $userofexpensereport New user we want to have the expense report on. * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0, $userofexpensereport = null) + public function update($user, $notrigger = 0, $userofexpensereport = null) { global $langs; @@ -447,7 +447,7 @@ class ExpenseReport extends CommonObject * @param string $ref Ref {@name ref} * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; @@ -545,7 +545,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the expense report as paid * @@ -554,7 +554,7 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function set_paid($id, $fuser, $notrigger = 0) + public function set_paid($id, $fuser, $notrigger = 0) { // phpcs:enable $error = 0; @@ -613,12 +613,12 @@ class ExpenseReport 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 * @return string Label */ - 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 /** * Returns the label of a statut * @@ -626,7 +626,7 @@ class ExpenseReport 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 */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -660,7 +660,7 @@ class ExpenseReport extends CommonObject * @param int $id Id of object * @return void */ - function info($id) + public function info($id) { global $conf; @@ -684,16 +684,16 @@ class ExpenseReport extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->date_validation = $this->db->jdate($obj->datev); - $this->date_approbation = $this->db->jdate($obj->datea); + $this->date_validation = $this->db->jdate($obj->datev); + $this->date_approbation = $this->db->jdate($obj->datea); $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; if ($obj->fk_user_creation) { @@ -737,7 +737,7 @@ class ExpenseReport extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -767,8 +767,7 @@ class ExpenseReport extends CommonObject $this->note_public='SPECIMEN'; $nbp = 5; $xnbp = 0; - while ($xnbp < $nbp) - { + while ($xnbp < $nbp) { $line=new ExpenseReportLine($this->db); $line->comments=$langs->trans("Comment")." ".$xnbp; $line->date=($now-3600*(1+$xnbp)); @@ -793,7 +792,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * fetch_line_by_project * @@ -801,7 +800,7 @@ class ExpenseReport extends CommonObject * @param User $user User * @return int <0 if KO, >0 if OK */ - function fetch_line_by_project($projectid, $user = '') + public function fetch_line_by_project($projectid, $user = '') { // phpcs:enable global $conf,$db,$langs; @@ -906,7 +905,7 @@ class ExpenseReport extends CommonObject * @param int $id Id of expense report * @return int <0 if KO, >0 if OK */ - function recalculer($id) + public function recalculer($id) { $sql = 'SELECT tt.total_ht, tt.total_ttc, tt.total_tva'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as tt'; @@ -950,13 +949,13 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * fetch_lines * * @return int <0 if OK, >0 if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->lines=array(); @@ -1038,7 +1037,7 @@ class ExpenseReport extends CommonObject * @param User $fuser User that delete * @return int <0 if KO, >0 if OK */ - function delete(User $fuser = null) + public function delete(User $fuser = null) { global $user,$langs,$conf; @@ -1078,7 +1077,7 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function setValidate($fuser, $notrigger = 0) + public function setValidate($fuser, $notrigger = 0) { global $conf,$langs,$user; @@ -1195,14 +1194,14 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * set_save_from_refuse * * @param User $fuser User * @return int <0 if KO, >0 if OK */ - function set_save_from_refuse($fuser) + public function set_save_from_refuse($fuser) { // phpcs:enable global $conf,$langs; @@ -1249,16 +1248,15 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function setApproved($fuser, $notrigger = 0) + public function setApproved($fuser, $notrigger = 0) { $now=dol_now(); - $error = 0; + $error = 0; // date approval $this->date_approve = $now; - if ($this->fk_statut != 5) - { - $this->db->begin(); + if ($this->fk_statut != 5) { + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 5, fk_user_approve = ".$fuser->id.","; @@ -1309,10 +1307,10 @@ class ExpenseReport extends CommonObject * * @param User $fuser User * @param Details $details Details - * @param int $notrigger Disable triggers + * @param int $notrigger Disable triggers * @return int */ - function setDeny($fuser, $details, $notrigger = 0) + public function setDeny($fuser, $details, $notrigger = 0) { $now = dol_now(); $error = 0; @@ -1369,7 +1367,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * set_unpaid * @@ -1377,7 +1375,7 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function set_unpaid($fuser, $notrigger = 0) + public function set_unpaid($fuser, $notrigger = 0) { // phpcs:enable $error = 0; @@ -1430,7 +1428,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * set_cancel * @@ -1439,7 +1437,7 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function set_cancel($fuser, $detail, $notrigger = 0) + public function set_cancel($fuser, $detail, $notrigger = 0) { // phpcs:enable $error = 0; @@ -1499,7 +1497,7 @@ class ExpenseReport extends CommonObject * * @return string free ref */ - function getNextNumRef() + public function getNextNumRef() { global $langs, $conf; $langs->load("trips"); @@ -1559,7 +1557,7 @@ class ExpenseReport 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, $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) { global $langs, $conf; @@ -1615,7 +1613,7 @@ class ExpenseReport extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total of an expense report when you add a line. * @@ -1623,7 +1621,7 @@ class ExpenseReport extends CommonObject * @param string $ligne_total_tva Amount of all taxes * @return void */ - function update_totaux_add($ligne_total_ht, $ligne_total_tva) + public function update_totaux_add($ligne_total_ht, $ligne_total_tva) { // phpcs:enable $this->total_ht = $this->total_ht + $ligne_total_ht; @@ -1645,7 +1643,7 @@ class ExpenseReport extends CommonObject endif; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total of an expense report when you delete a line. * @@ -1653,7 +1651,7 @@ class ExpenseReport extends CommonObject * @param string $ligne_total_tva Amount of all taxes * @return void */ - function update_totaux_del($ligne_total_ht, $ligne_total_tva) + public function update_totaux_del($ligne_total_ht, $ligne_total_tva) { // phpcs:enable $this->total_ht = $this->total_ht - $ligne_total_ht; @@ -1689,7 +1687,7 @@ class ExpenseReport extends CommonObject * @param int $type Type line * @return int <0 if KO, >0 if OK */ - function addline($qty = 0, $up = 0, $fk_c_type_fees = 0, $vatrate = 0, $date = '', $comments = '', $fk_project = 0, $fk_c_exp_tax_cat = 0, $type = 0) + public function addline($qty = 0, $up = 0, $fk_c_type_fees = 0, $vatrate = 0, $date = '', $comments = '', $fk_project = 0, $fk_c_exp_tax_cat = 0, $type = 0) { global $conf,$langs,$mysoc; @@ -1783,7 +1781,7 @@ class ExpenseReport extends CommonObject * @param string $seller seller, but actually he is unknown * @return true or false */ - function checkRules($type = 0, $seller = '') + public function checkRules($type = 0, $seller = '') { global $user,$conf,$db,$langs; @@ -1852,7 +1850,7 @@ class ExpenseReport extends CommonObject * * @return boolean true=applied, false=not applied */ - function applyOffset() + public function applyOffset() { global $conf; @@ -1900,7 +1898,7 @@ class ExpenseReport extends CommonObject * * @return bool */ - function offsetAlreadyGiven() + public function offsetAlreadyGiven() { $sql = 'SELECT e.rowid FROM '.MAIN_DB_PREFIX.'expensereport e'; $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'expensereport_det d ON (e.rowid = d.fk_expensereport)'; @@ -1939,7 +1937,7 @@ class ExpenseReport extends CommonObject * @param int $fk_c_exp_tax_cat id of category of car * @return int <0 if KO, >0 if OK */ - function updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $expensereport_id, $fk_c_exp_tax_cat = 0) + public function updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $expensereport_id, $fk_c_exp_tax_cat = 0) { global $user, $mysoc; @@ -2046,7 +2044,7 @@ class ExpenseReport extends CommonObject * @param User $fuser User * @return int <0 if KO, >0 if OK */ - function deleteline($rowid, $fuser = '') + public function deleteline($rowid, $fuser = '') { $this->db->begin(); @@ -2068,7 +2066,7 @@ class ExpenseReport extends CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * periode_existe * @@ -2077,7 +2075,7 @@ class ExpenseReport extends CommonObject * @param Date $date_fin End date * @return int <0 if KO, >0 if OK */ - function periode_existe($fuser, $date_debut, $date_fin) + public function periode_existe($fuser, $date_debut, $date_fin) { // phpcs:enable $sql = "SELECT rowid, date_debut, date_fin"; @@ -2086,8 +2084,7 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::periode_existe sql=".$sql); $result = $this->db->query($sql); - if($result) - { + if ($result) { $num_lignes = $this->db->num_rows($result); $i = 0; if ($num_lignes>0) @@ -2126,14 +2123,14 @@ class ExpenseReport extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of people with permission to validate expense reports. * Search for permission "approve expense report" * * @return array Array of user ids */ - function fetch_users_approver_expensereport() + public function fetch_users_approver_expensereport() { // phpcs:enable $users_validator=array(); @@ -2207,7 +2204,7 @@ class ExpenseReport extends CommonObject * @param int $active Active or not * @return array */ - function listOfTypes($active = 1) + public function listOfTypes($active = 1) { global $langs; $ret=array(); @@ -2234,13 +2231,13 @@ class ExpenseReport extends CommonObject return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb pour le tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -2253,10 +2250,8 @@ class ExpenseReport extends CommonObject $sql.= " AND ex.entity IN (".getEntity('expensereport').")"; $resql=$this->db->query($sql); - if ($resql) - { - while ($obj=$this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj=$this->db->fetch_object($resql)) { $this->nb["expensereports"]=$obj->nb; } $this->db->free($resql); @@ -2270,7 +2265,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2278,16 +2273,16 @@ class ExpenseReport extends CommonObject * @param string $option 'topay' or 'toapprove' * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $option = 'topay') + public function load_board($user, $option = 'topay') { // phpcs:enable global $conf, $langs; if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe - $now=dol_now(); + $now=dol_now(); - $userchildids = $user->getAllChildIds(1); + $userchildids = $user->getAllChildIds(1); $sql = "SELECT ex.rowid, ex.date_valid"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; @@ -2484,17 +2479,17 @@ class ExpenseReportLine public $projet_ref; public $projet_title; - var $vatrate; - var $total_ht; - var $total_tva; - var $total_ttc; + public $vatrate; + public $total_ht; + public $total_tva; + public $total_ttc; /** * Constructor * * @param DoliDB $db Handlet database */ - function __construct($db) + public function __construct($db) { $this->db= $db; } @@ -2505,7 +2500,7 @@ class ExpenseReportLine * @param int $rowid Id of object to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet, fde.date,'; $sql.= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; @@ -2557,7 +2552,7 @@ class ExpenseReportLine * @param bool $fromaddline false=keep default behavior, true=exclude the update_price() of parent object * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0, $fromaddline = false) + public function insert($notrigger = 0, $fromaddline = false) { global $langs,$user,$conf; @@ -2679,7 +2674,7 @@ class ExpenseReportLine * @param User $fuser User * @return int <0 if KO, >0 if OK */ - function update($fuser) + public function update($fuser) { global $fuser,$langs,$conf; @@ -2758,7 +2753,6 @@ class ExpenseReportLine } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Retourne la liste deroulante des differents etats d'une note de frais. * Les valeurs de la liste sont les id de la table c_expensereport_statuts @@ -2771,7 +2765,6 @@ class ExpenseReportLine */ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) { - // phpcs:enable global $db, $langs; $tmpep=new ExpenseReport($db); @@ -2796,7 +2789,6 @@ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $u print ''; } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return list of types of notes with select value = id * @@ -2808,7 +2800,6 @@ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $u */ function select_type_fees_id($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) { - // phpcs:enable global $db,$langs,$user; $langs->load("trips"); diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 0eec447d997..082e3ce016e 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -50,7 +50,7 @@ class ExpenseReportStats extends Stats * @param int $userid Id user for filter * @return void */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $conf, $user; @@ -89,7 +89,7 @@ class ExpenseReportStats extends Stats * * @return array Array of values */ - function getNbByYear() + public function getNbByYear() { $sql = "SELECT YEAR(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -107,7 +107,7 @@ class ExpenseReportStats 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 values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { $sql = "SELECT MONTH(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -129,7 +129,7 @@ class ExpenseReportStats 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 values */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -149,7 +149,7 @@ class ExpenseReportStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -166,7 +166,7 @@ class ExpenseReportStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql.= " FROM ".$this->from; @@ -174,6 +174,6 @@ class ExpenseReportStats extends Stats $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 655c148069e..f731638ea1d 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -92,7 +92,7 @@ class PaymentExpenseReport extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -104,7 +104,7 @@ class PaymentExpenseReport extends CommonObject * @param User $user User making payment * @return int <0 if KO, id of payment if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -113,8 +113,7 @@ class PaymentExpenseReport extends CommonObject $now=dol_now(); // Validate parameters - if (! $this->datepaid) - { + if (! $this->datepaid) { $this->error='ErrorBadValueForParameterCreatePaymentExpenseReport'; return -1; } @@ -184,10 +183,10 @@ class PaymentExpenseReport extends CommonObject /** * Load object in memory from database * - * @param int $id Id object + * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -258,7 +257,7 @@ class PaymentExpenseReport 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) { // phpcs:enable global $conf, $langs; @@ -266,7 +265,7 @@ class PaymentExpenseReport extends CommonObject // Clean parameters - if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); + if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); if (isset($this->amount)) $this->amount=trim($this->amount); if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); @@ -341,11 +340,11 @@ class PaymentExpenseReport extends CommonObject /** * Delete object in database * - * @param User $user User that delete + * @param User $user User that delete * @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) { // phpcs:enable global $conf, $langs; @@ -370,13 +369,16 @@ class PaymentExpenseReport extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (! $resql) { + $error++; + $this->errors[]="Error ".$this->db->lasterror(); + } } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -386,8 +388,8 @@ class PaymentExpenseReport extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback if ($error) @@ -415,7 +417,7 @@ class PaymentExpenseReport extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -444,11 +446,6 @@ class PaymentExpenseReport extends CommonObject $error++; } - if (! $error) - { - - } - unset($object->context['createfromclone']); // End @@ -471,12 +468,12 @@ class PaymentExpenseReport extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -484,13 +481,13 @@ class PaymentExpenseReport 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 Libelle du statut */ - function LibStatut($statut, $mode = 0) - { + public function LibStatut($statut, $mode = 0) + { // phpcs:enable - global $langs; + global $langs; - return ''; - } + return ''; + } /** @@ -500,7 +497,7 @@ class PaymentExpenseReport extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -530,7 +527,7 @@ class PaymentExpenseReport extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $langs,$conf; @@ -631,14 +628,14 @@ class PaymentExpenseReport extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between the expense report payment and the generated line in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -659,11 +656,11 @@ class PaymentExpenseReport extends CommonObject /** * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen Longueur max libelle - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen Longueur max libelle + * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; @@ -691,8 +688,8 @@ class PaymentExpenseReport extends CommonObject * @param int $id Payment id * @return void */ - function info($id) - { + public function info($id) + { $sql = 'SELECT e.rowid, e.datec, e.fk_user_creat, e.fk_user_modif, e.tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as e'; $sql.= ' WHERE e.rowid = '.$id; @@ -718,7 +715,7 @@ class PaymentExpenseReport extends CommonObject $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; } - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } $this->db->free($result); @@ -727,5 +724,5 @@ class PaymentExpenseReport extends CommonObject { dol_print_error($this->db); } - } + } } diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index a964f5f373a..7ce39a43354 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -35,28 +35,28 @@ class Export */ public $db; - var $array_export_code=array(); // Tableau de "idmodule_numlot" - var $array_export_module=array(); // Tableau de "nom de modules" - var $array_export_label=array(); // Tableau de "libelle de lots" - var $array_export_sql_start=array(); // Tableau des "requetes sql" - var $array_export_sql_end=array(); // Tableau des "requetes sql" - var $array_export_sql_order=array(); // Tableau des "requetes sql" + public $array_export_code=array(); // Tableau de "idmodule_numlot" + public $array_export_module=array(); // Tableau de "nom de modules" + public $array_export_label=array(); // Tableau de "libelle de lots" + public $array_export_sql_start=array(); // Tableau des "requetes sql" + public $array_export_sql_end=array(); // Tableau des "requetes sql" + public $array_export_sql_order=array(); // Tableau des "requetes sql" - var $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter - var $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre - var $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer - var $array_export_entities=array(); // Tableau des listes de champ+alias a exporter - var $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export - var $array_export_special=array(); // Tableau des operations speciales sur champ - var $array_export_examplevalues=array(); // array with examples + public $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter + public $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre + public $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer + public $array_export_entities=array(); // Tableau des listes de champ+alias a exporter + public $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export + public $array_export_special=array(); // Tableau des operations speciales sur champ + public $array_export_examplevalues=array(); // array with examples - // To store export modules - var $hexa; - var $hexafiltervalue; - var $datatoexport; - var $model_name; + // To store export modules + public $hexa; + public $hexafiltervalue; + public $datatoexport; + public $model_name; - var $sqlusedforexport; + public $sqlusedforexport; /** @@ -64,13 +64,13 @@ class Export * * @param DoliDB $db Database handler */ - function __construct($db) - { - $this->db=$db; - } + public function __construct($db) + { + $this->db=$db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load an exportable dataset * @@ -78,12 +78,12 @@ class Export * @param string $filter Load a particular dataset only * @return int <0 if KO, >0 if OK */ - function load_arrays($user, $filter = '') - { + public function load_arrays($user, $filter = '') + { // phpcs:enable - global $langs,$conf,$mysoc; + global $langs,$conf,$mysoc; - dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter); + dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter); $i=0; @@ -206,10 +206,10 @@ class Export } return 1; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the sql export request. * Arrays this->array_export_xxx are already loaded for required datatoexport @@ -219,8 +219,8 @@ class Export * @param array $array_filterValue Filter records on array of value for fields * @return string SQL String. Example "select s.rowid as r_rowid, s.status as s_status from ..." */ - function build_sql($indice, $array_selected, $array_filterValue) - { + public function build_sql($indice, $array_selected, $array_filterValue) + { // phpcs:enable // Build the sql request $sql=$this->array_export_sql_start[$indice]; @@ -273,7 +273,7 @@ class Export return $sql; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the conditionnal string from filter the query * @@ -282,8 +282,8 @@ class Export * @param string $ValueField Value of the field for filter. Must not be '' * @return string sql string of then field ex : "field='xxx'>" */ - function build_filterQuery($TypeField, $NameField, $ValueField) - { + public function build_filterQuery($TypeField, $NameField, $ValueField) + { // phpcs:enable //print $TypeField." ".$NameField." ".$ValueField; $InfoFieldList = explode(":", $TypeField); @@ -352,23 +352,23 @@ class Export } /** - * conditionDate + * conditionDate * * @param string $Field Field operand 1 * @param string $Value Value operand 2 * @param string $Sens Comparison operator * @return string */ - function conditionDate($Field, $Value, $Sens) - { + public function conditionDate($Field, $Value, $Sens) + { // TODO date_format is forbidden, not performant and not portable. Use instead BETWEEN if (strlen($Value)==4) $Condition=" date_format(".$Field.",'%Y') ".$Sens." '".$Value."'"; elseif (strlen($Value)==6) $Condition=" date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'"; else $Condition=" date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value; return $Condition; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build an input field used to filter the query * @@ -377,8 +377,8 @@ class Export * @param string $ValueField Initial value of the field to filter * @return string html string of the input field ex : "" */ - function build_filterField($TypeField, $NameField, $ValueField) - { + public function build_filterField($TypeField, $NameField, $ValueField) + { // phpcs:enable global $conf,$langs; @@ -488,16 +488,16 @@ class Export } return $szFilterField; - } + } - /** - * Build an input field used to filter the query - * - * @param string $TypeField Type of Field to filter - * @return string html string of the input field ex : "" - */ - function genDocFilter($TypeField) - { + /** + * Build an input field used to filter the query + * + * @param string $TypeField Type of Field to filter + * @return string html string of the input field ex : "" + */ + public function genDocFilter($TypeField) + { global $langs; $szMsg=''; @@ -523,7 +523,7 @@ class Export return $szMsg; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build export file. * File is built into directory $conf->export->dir_temp.'/'.$user->id @@ -537,8 +537,8 @@ class Export * @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays) * @return int <0 if KO, >0 if OK */ - function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') - { + public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') + { // phpcs:enable global $conf,$langs; @@ -698,7 +698,7 @@ class Export * @param User $user Object user that save * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf; @@ -741,11 +741,11 @@ class Export /** * Load an export profil from database * - * @param int $id Id of profil to load - * @return int <0 if KO, >0 if OK + * @param int $id Id of profil to load + * @return int <0 if KO, >0 if OK */ - function fetch($id) - { + public function fetch($id) + { $sql = 'SELECT em.rowid, em.label, em.type, em.field, em.filter'; $sql.= ' FROM '.MAIN_DB_PREFIX.'export_model as em'; $sql.= ' WHERE em.rowid = '.$id; @@ -757,12 +757,12 @@ class Export $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; - $this->model_name = $obj->label; - $this->datatoexport = $obj->type; + $this->id = $obj->rowid; + $this->model_name = $obj->label; + $this->datatoexport = $obj->type; - $this->hexa = $obj->field; - $this->hexafiltervalue = $obj->filter; + $this->hexa = $obj->field; + $this->hexafiltervalue = $obj->filter; return 1; } @@ -787,7 +787,7 @@ class Export * @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; @@ -835,15 +835,15 @@ class Export } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output list all export models * TODO Move this into a class htmlxxx.class.php * * @return void */ - function list_export_model() - { + public function list_export_model() + { // phpcs:enable global $conf, $langs; @@ -886,9 +886,8 @@ class Export $i++; } - } - else { - dol_print_error($this->db); - } - } + } else { + dol_print_error($this->db); + } + } } diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 942ec66b002..4b81697be66 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -428,9 +428,6 @@ if ($step == 1 || ! $datatoexport) { llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones'); - /* - * Affichage onglets - */ $h = 0; $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=1'; @@ -438,20 +435,13 @@ if ($step == 1 || ! $datatoexport) $hselected=$h; $h++; - /* - $head[$h][0] = ''; - $head[$h][1] = $langs->trans("Step")." 2"; - $h++; - */ - dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -1); - print '
'.$langs->trans("LastContracts", 5).''.$langs->trans("DateModification").''.$langs->trans("DateModification").''.$langs->trans("Status").''.$langs->trans("Services").''.$langs->trans("Services").'
'.dol_print_date($db->jdate($obj->tms), 'dayhour').''.dol_print_date($db->jdate($obj->tms), 'dayhour').''.$staticcontrat->LibStatut($obj->statut,2).''.($obj->nb_initial>0 ? $obj->nb_initial.$staticcontratligne->LibStatut(0, 3):'').''.($obj->nb_running>0 ? $obj->nb_running.$staticcontratligne->LibStatut(4, 3, 0):'').''; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); + print ''; + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; + print ''; print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); print ''; + print ''; $arrayofoperators=array('0'=>'','='=>'=','<='=>'<=','>='=>'>='); print $form->selectarray('search_op2df', $arrayofoperators, $search_op2df, 0); print '
'; @@ -561,7 +561,7 @@ if (! empty($arrayfields['status']['checked'])) { print '
'; +print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print '
'; print $contracttmp->getNomUrl(1); if ($obj->nb_late) print img_warning($langs->trans("Late")); - if (!empty($obj->note_private) || !empty($obj->note_public)) - { + if (!empty($obj->note_private) || !empty($obj->note_public)) { print ' '; print ''.img_picto($langs->trans("ViewPrivateNote"), 'note').''; print ''; @@ -681,7 +684,7 @@ while ($i < min($num, $limit)) // Country if (! empty($arrayfields['country.code_iso']['checked'])) { - print ''; + print ''; $tmparray=getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''; + print ''; if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzuser').''.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzuser').''; + print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; + print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; + print ''; print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser'); print ''.($obj->nb_initial>0?$obj->nb_initial:'').''.($obj->nb_running>0?$obj->nb_running:'').''.($obj->nb_expired>0?$obj->nb_expired:'').''.($obj->nb_closed>0 ?$obj->nb_closed:'').''.($obj->nb_initial>0?$obj->nb_initial:'').''.($obj->nb_running>0?$obj->nb_running:'').''.($obj->nb_expired>0?$obj->nb_expired:'').''.($obj->nb_closed>0 ?$obj->nb_closed:'').''; + 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; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index f2d827b87cb..9a719bdf2a4 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -376,26 +376,26 @@ print ''; if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, "", $sortfield, $sortorder); if (! empty($arrayfields['p.description']['checked'])) print_liste_field_titre($arrayfields['p.description']['label'], $_SERVER["PHP_SELF"], "p.description", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['cd.qty']['checked'])) print_liste_field_titre($arrayfields['cd.qty']['label'], $_SERVER["PHP_SELF"], "cd.qty", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['cd.total_ht']['checked'])) print_liste_field_titre($arrayfields['cd.total_ht']['label'], $_SERVER["PHP_SELF"], "cd.total_ht", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['cd.total_tva']['checked'])) print_liste_field_titre($arrayfields['cd.total_tva']['label'], $_SERVER["PHP_SELF"], "cd.total_tva", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['cd.tva_tx']['checked'])) print_liste_field_titre($arrayfields['cd.tva_tx']['label'], $_SERVER["PHP_SELF"], "cd.tva_tx", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['cd.subprice']['checked'])) print_liste_field_titre($arrayfields['cd.subprice']['label'], $_SERVER["PHP_SELF"], "cd.subprice", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); +if (! empty($arrayfields['cd.qty']['checked'])) print_liste_field_titre($arrayfields['cd.qty']['label'], $_SERVER["PHP_SELF"], "cd.qty", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (! empty($arrayfields['cd.total_ht']['checked'])) print_liste_field_titre($arrayfields['cd.total_ht']['label'], $_SERVER["PHP_SELF"], "cd.total_ht", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (! empty($arrayfields['cd.total_tva']['checked'])) print_liste_field_titre($arrayfields['cd.total_tva']['label'], $_SERVER["PHP_SELF"], "cd.total_tva", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (! empty($arrayfields['cd.tva_tx']['checked'])) print_liste_field_titre($arrayfields['cd.tva_tx']['label'], $_SERVER["PHP_SELF"], "cd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (! empty($arrayfields['cd.subprice']['checked'])) print_liste_field_titre($arrayfields['cd.subprice']['label'], $_SERVER["PHP_SELF"], "cd.subprice", "", $param, '', $sortfield, $sortorder, 'center nowrap '); if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture_prevue", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['cd.date_ouverture']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['cd.date_fin_validite']['checked'])) print_liste_field_titre($arrayfields['cd.date_fin_validite']['label'], $_SERVER["PHP_SELF"], "cd.date_fin_validite", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['cd.date_cloture']['checked'])) print_liste_field_titre($arrayfields['cd.date_cloture']['label'], $_SERVER["PHP_SELF"], "cd.date_cloture", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture_prevue", "", $param, '', $sortfield, $sortorder, 'center '); +if (! empty($arrayfields['cd.date_ouverture']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture", "", $param, '', $sortfield, $sortorder, 'center '); +if (! empty($arrayfields['cd.date_fin_validite']['checked'])) print_liste_field_titre($arrayfields['cd.date_fin_validite']['label'], $_SERVER["PHP_SELF"], "cd.date_fin_validite", "", $param, '', $sortfield, $sortorder, 'center '); +if (! empty($arrayfields['cd.date_cloture']['checked'])) print_liste_field_titre($arrayfields['cd.date_cloture']['label'], $_SERVER["PHP_SELF"], "cd.date_cloture", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['cd.datec']['checked'])) print_liste_field_titre($arrayfields['cd.datec']['label'], $_SERVER["PHP_SELF"], "cd.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['cd.tms']['checked'])) print_liste_field_titre($arrayfields['cd.tms']['label'], $_SERVER["PHP_SELF"], "cd.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); +if (! empty($arrayfields['cd.datec']['checked'])) print_liste_field_titre($arrayfields['cd.datec']['label'], $_SERVER["PHP_SELF"], "cd.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (! empty($arrayfields['cd.tms']['checked'])) print_liste_field_titre($arrayfields['cd.tms']['label'], $_SERVER["PHP_SELF"], "cd.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "cd.statut,c.statut", "", $param, '', $sortfield, $sortorder, 'right '); -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"; print ''; @@ -451,7 +451,7 @@ if (! empty($arrayfields['s.nom']['checked'])) if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) { - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } // End date if (! empty($arrayfields['cd.date_fin_validite']['checked'])) { - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } @@ -682,7 +682,7 @@ while ($i < min($num, $limit)) // Date creation if (! empty($arrayfields['cd.datec']['checked'])) { - print ''; if (! $i) $totalarray['nbfield']++; @@ -690,7 +690,7 @@ while ($i < min($num, $limit)) // Date modification if (! empty($arrayfields['cd.tms']['checked'])) { - print ''; if (! $i) $totalarray['nbfield']++; @@ -711,7 +711,7 @@ while ($i < min($num, $limit)) if (! $i) $totalarray['nbfield']++; } // Action column - print ' - + '; //print $url.' sortfield='.$sortfield.' sortorder='.$sortorder; - print_liste_field_titre('Documents2', $url, "name", "", $param, 'class="left"', $sortfield, $sortorder); - print_liste_field_titre('Size', $url, "size", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre('Date', $url, "date", "", $param, 'class="center"', $sortfield, $sortorder); - if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print_liste_field_titre('', $url, "", "", $param, 'class="center"'); // Preview + print_liste_field_titre('Documents2', $url, "name", "", $param, '', $sortfield, $sortorder, ' left'); + print_liste_field_titre('Size', $url, "size", "", $param, '', $sortfield, $sortorder, ' right'); + print_liste_field_titre('Date', $url, "date", "", $param, '', $sortfield, $sortorder, ' center'); + if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print_liste_field_titre('', $url, "", "", $param, '', $sortfield, $sortorder, ' center'); // Preview print_liste_field_titre(''); print_liste_field_titre(''); if (! $disablemove) print_liste_field_titre(''); @@ -1397,7 +1406,7 @@ class FormFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show list of documents in a directory * @@ -1416,7 +1425,7 @@ class FormFile * @return int <0 if KO, nb of files shown if OK * @see list_of_documents */ - function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0) + public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0) { // phpcs:enable global $user, $conf, $langs, $form; @@ -1555,21 +1564,13 @@ class FormFile $id=0; $ref=''; $label=''; // To show ref or specific information according to view to show (defined by $module) - if ($modulepart == 'company') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices - elseif ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'supplier_proposal') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'order') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'order_supplier') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'contract') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'product') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'project') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');} - elseif ($modulepart == 'fichinter') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');} - elseif ($modulepart == 'user') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:'');} - elseif ($modulepart == 'expensereport') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');} - elseif ($modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:'');} + if ($modulepart == 'company' || $modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } + elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices + elseif ($modulepart == 'user' || $modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } + elseif (in_array($modulepart, array('invoice', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'project', 'fichinter', 'expensereport'))) + { + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); + } if (! $id && ! $ref) continue; $found=0; diff --git a/htdocs/core/class/html.formintervention.class.php b/htdocs/core/class/html.formintervention.class.php index 3d0a84b074c..83405f9725b 100644 --- a/htdocs/core/class/html.formintervention.class.php +++ b/htdocs/core/class/html.formintervention.class.php @@ -49,7 +49,7 @@ class FormIntervention } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a combo list with contracts qualified for a third party * @@ -60,7 +60,7 @@ class FormIntervention * @param int $showempty Show empty line * @return int Nbre of project if OK, <0 if KO */ - function select_interventions($socid = -1, $selected = '', $htmlname = 'interventionid', $maxlength = 16, $showempty = 1) + public function select_interventions($socid = -1, $selected = '', $htmlname = 'interventionid', $maxlength = 16, $showempty = 1) { // phpcs:enable global $db,$user,$conf,$langs; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 1159c74dc8d..b643f1dfcb9 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -121,7 +121,7 @@ class FormMail extends Form * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -151,13 +151,13 @@ class FormMail extends Form $this->withfckeditor=-1; // -1 = Auto } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Clear list of attached files in send mail form (also stored in session) * * @return void */ - function clear_attached_files() + public function clear_attached_files() { // phpcs:enable global $conf,$user; @@ -174,7 +174,7 @@ class FormMail extends Form unset($_SESSION["listofmimes".$keytoavoidconflict]); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a file into the list of attached files (stored in SECTION array) * @@ -183,7 +183,7 @@ class FormMail extends Form * @param string $type Mime type (can be dol_mimetype($file)) * @return void */ - function add_attached_files($path, $file = '', $type = '') + public function add_attached_files($path, $file = '', $type = '') { // phpcs:enable $listofpaths=array(); @@ -208,14 +208,14 @@ class FormMail extends Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a file from the list of attached files (stored in SECTION array) * * @param string $keytodelete Key in file array (0, 1, 2, ...) * @return void */ - function remove_attached_files($keytodelete) + public function remove_attached_files($keytodelete) { // phpcs:enable $listofpaths=array(); @@ -238,13 +238,13 @@ class FormMail extends Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of attached files (stored in SECTION array) * * @return array array('paths'=> ,'names'=>, 'mimes'=> ) */ - function get_attached_files() + public function get_attached_files() { // phpcs:enable $listofpaths=array(); @@ -258,7 +258,7 @@ class FormMail extends Form return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -268,13 +268,13 @@ class FormMail extends Form * @param string $removefileaction Name of action when removing file attachments * @return void */ - function show_form($addfileaction = 'addfile', $removefileaction = 'removefile') + public function show_form($addfileaction = 'addfile', $removefileaction = 'removefile') { // phpcs:enable print $this->get_form($addfileaction, $removefileaction); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -285,7 +285,7 @@ class FormMail extends Form * @param string $removefileaction Name of action when removing file attachments * @return string Form to show */ - function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') + public function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') { // phpcs:enable global $conf, $langs, $user, $hookmanager, $form; @@ -1130,24 +1130,23 @@ class FormMail extends Form } /** - * Return templates of email with type = $type_template or type = 'all'. - * This search into table c_email_templates. Used by the get_form function. + * Return templates of email with type = $type_template or type = 'all'. + * This search into table c_email_templates. Used by the get_form function. * - * @param DoliDB $db Database handler - * @param string $type_template Get message for model/type=$type_template, type='all' also included. - * @param string $user Get template public or limited to this user - * @param Translate $outputlangs Output lang object - * @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found) - * @param int $active 1=Only active template, 0=Only disabled, -1=All - * @param string $label Label of template - * @return ModelMail|integer One instance of ModelMail or -1 if error + * @param DoliDB $db Database handler + * @param string $type_template Get message for model/type=$type_template, type='all' also included. + * @param string $user Get template public or limited to this user + * @param Translate $outputlangs Output lang object + * @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found) + * @param int $active 1=Only active template, 0=Only disabled, -1=All + * @param string $label Label of template + * @return ModelMail|integer One instance of ModelMail or -1 if error */ public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '') { - $ret = new ModelMail(); + $ret = new ModelMail(); - if ($id == -2 && empty($label)) - { + if ($id == -2 && empty($label)) { $this->error = 'LabelIsMandatoryWhenIdIs-2'; return -1; } @@ -1320,7 +1319,7 @@ class FormMail extends Form * @return void * @see getCommonSubstitutionArray */ - function setSubstitFromObject($object, $outputlangs) + public function setSubstitFromObject($object, $outputlangs) { global $conf, $user; @@ -1377,7 +1376,7 @@ class FormMail extends Form * @param Object $object Object if applicable * @return array Array of substitution values for emails. */ - static function getAvailableSubstitKey($mode = 'formemail', $object = null) + public static function getAvailableSubstitKey($mode = 'formemail', $object = null) { global $conf, $langs; diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 95c2c057b40..caf4bf8a504 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -27,33 +27,33 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; */ class FormMailing extends Form { - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); - /** - * Output a select with destinaries status - * - * @param string $selectedid The selected id - * @param string $htmlname Name of controm - * @param integer $show_empty Show empty option - * @return string HTML select - */ + /** + * Output a select with destinaries status + * + * @param string $selectedid The selected id + * @param string $htmlname Name of controm + * @param integer $show_empty Show empty option + * @return string HTML select + */ public function selectDestinariesStatus($selectedid = '', $htmlname = 'dest_status', $show_empty = 0) { - global $langs; - $langs->load("mails"); + global $langs; + $langs->load("mails"); - require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; - $mailing = new Mailing($this->db); + require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; + $mailing = new Mailing($this->db); - $options = array(); + $options = array(); - if ($show_empty) { - $options[-2] = ''; // Note -1 is used for error - } + if ($show_empty) { + $options[-2] = ''; // Note -1 is used for error + } $options = $options + $mailing->statut_dest; diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 5aecb6efc71..f022d2c3791 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -44,7 +44,7 @@ class FormMargin * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -59,7 +59,7 @@ class FormMargin * @param boolean $force_price True of not * @return array Array with info */ - function getMarginInfosArray($object, $force_price = false) + public function getMarginInfosArray($object, $force_price = false) { global $conf, $db; @@ -191,7 +191,7 @@ class FormMargin * @param boolean $force_price Force price * @return void */ - function displayMarginInfos($object, $force_price = false) + public function displayMarginInfos($object, $force_price = false) { global $langs, $conf, $user; diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index 9783d6f50a8..9c1d847f16e 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -31,13 +31,13 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; class FormOrder extends Form { - /** - * Return combo list of differents status of a orders + /** + * Return combo list of differents status of a orders * - * @param string $selected Preselected value - * @param int $short Use short labels - * @param string $hmlname Name of HTML select element - * @return void + * @param string $selected Preselected value + * @param int $short Use short labels + * @param string $hmlname Name of HTML select element + * @return void */ public function selectSupplierOrderStatus($selected = '', $short = 0, $hmlname = 'order_status') { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 97beb2464ad..1bb59077bec 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -50,13 +50,13 @@ class FormOther * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML select list of export models * @@ -67,7 +67,7 @@ class FormOther * @param int $fk_user Utilisateur créant le modèle * @return void */ - function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null) + public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null) { // phpcs:enable $sql = "SELECT rowid, label"; @@ -109,7 +109,7 @@ class FormOther } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of export models * @@ -119,7 +119,7 @@ class FormOther * @param int $useempty Affiche valeur vide dans liste * @return void */ - function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0) + public function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0) { // phpcs:enable $sql = "SELECT rowid, label"; @@ -160,7 +160,7 @@ class FormOther } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of ecotaxes with label * @@ -168,7 +168,7 @@ class FormOther * @param string $htmlname Name of combo list * @return integer */ - function select_ecotaxes($selected = '', $htmlname = 'ecotaxe_id') + public function select_ecotaxes($selected = '', $htmlname = 'ecotaxe_id') { // phpcs:enable global $langs; @@ -218,7 +218,7 @@ class FormOther } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of revenue stamp for country * @@ -227,7 +227,7 @@ class FormOther * @param string $country_code Country Code * @return string HTML select list */ - function select_revenue_stamp($selected = '', $htmlname = 'revenuestamp', $country_code = '') + public function select_revenue_stamp($selected = '', $htmlname = 'revenuestamp', $country_code = '') { // phpcs:enable global $langs; @@ -277,7 +277,7 @@ class FormOther } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select list to select a percent * @@ -290,7 +290,7 @@ class FormOther * @param int $showempty Add also an empty line * @return string HTML select string */ - function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0) + public function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0) { // phpcs:enable $return = '"; - } - else - { + } else { print $langs->trans("DictionaryEmpty"); } } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 765f7d00d79..9ef1098901c 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -45,12 +45,12 @@ class FormProjets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a combo list with projects qualified for a third party / user * @@ -71,8 +71,8 @@ class FormProjets * @param int $htmlid Html id to use instead of htmlname * @return string Return html content */ - function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '') - { + public function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '') + { // phpcs:enable global $langs,$conf,$form; @@ -90,13 +90,13 @@ class FormProjets $selected_input_value=$project->ref; } $urloption='socid='.$socid.'&htmlname='.$htmlname.'&discardclosed='.$discard_closed; -$out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array( -// 'update' => array( -// 'projectid' => 'id' -// ) - )); + $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array( + // 'update' => array( + // 'projectid' => 'id' + // ) + )); - $out.=''; + $out.=''; } else { @@ -119,7 +119,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec else return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array with projects qualified for a third party * @@ -140,8 +140,8 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec * @param string $morecss More CSS * @return int Nb of project if OK, <0 if KO */ - function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500') - { + public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500') + { // phpcs:enable global $user,$conf,$langs; @@ -303,11 +303,11 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec } /** - * Output a combo list with tasks qualified for a third party + * Output a combo list with tasks qualified for a third party * - * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) - * @param int $selected Id task preselected - * @param string $htmlname Name of HTML select + * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) + * @param int $selected Id task preselected + * @param string $htmlname Name of HTML select * @param int $maxlength Maximum length of label * @param int $option_only Return only html options lines without the select tag * @param string $show_empty Add an empty line ('1' or string to show for empty line) @@ -320,7 +320,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec * @param User $usertofilter User object to use for filtering * @return int Nbr of project if OK, <0 if KO */ - function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) + public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) { global $user,$conf,$langs; @@ -477,7 +477,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build a HTML select list of element of same thirdparty to suggest to link them to project * @@ -488,7 +488,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec * @param string $projectkey Equivalent key to fk_projet for actual table_element * @return int|string The HTML select list of element or '' if nothing or -1 if KO */ - function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2, $projectkey = "fk_projet") + public function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2, $projectkey = "fk_projet") { // phpcs:enable global $conf, $langs; @@ -618,7 +618,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec * @param string $morecss Add more css * @return int|string The HTML select list of element or '' if nothing or -1 if KO */ - function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '') + public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '') { global $conf, $langs; diff --git a/htdocs/core/class/html.formpropal.class.php b/htdocs/core/class/html.formpropal.class.php index 1f4fad0829c..e9f78638742 100644 --- a/htdocs/core/class/html.formpropal.class.php +++ b/htdocs/core/class/html.formpropal.class.php @@ -27,26 +27,26 @@ */ class FormPropal { - /** + /** * @var DoliDB Database handler. */ public $db; - - /** - * @var string Error code (or message) - */ - public $error=''; + + /** + * @var string Error code (or message) + */ + public $error=''; - /** - * 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; + } /** * Return combo list of differents status of a proposal @@ -60,14 +60,13 @@ class FormPropal * @param string $htmlname Name of select field * @return void */ - function selectProposalStatus($selected = '', $short = 0, $excludedraft = 0, $showempty = 1, $mode = 'customer', $htmlname = 'propal_statut') + public function selectProposalStatus($selected = '', $short = 0, $excludedraft = 0, $showempty = 1, $mode = 'customer', $htmlname = 'propal_statut') { global $langs; $prefix=''; $listofstatus=array(); - if ($mode == 'supplier') - { + if ($mode == 'supplier') { $prefix='SupplierProposalStatus'; $langs->load("supplier_proposal"); @@ -78,9 +77,7 @@ class FormPropal 3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'), 4=>array('id'=>4, 'code'=>'PR_CLOSED') ); - } - else - { + } else { $prefix="PropalStatus"; $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst"; @@ -114,11 +111,11 @@ class FormPropal { if ($excludedraft) { - if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT') - { - $i++; - continue; - } + if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT') + { + $i++; + continue; + } } if ($selected != '' && $selected == $obj['id']) { @@ -134,7 +131,7 @@ class FormPropal print $langs->trans($prefix.$key.($short?'Short':'')); } else - { + { $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed'); if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']]; diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index df6e09da59e..5269f4fdcad 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -76,7 +76,7 @@ class FormSms * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -92,7 +92,7 @@ class FormSms $this->withbodyreadonly=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show the form to input an sms. * @@ -100,7 +100,7 @@ class FormSms * @param int $showform Show form tags and submit button (recommanded is to use with value 0) * @return void */ - function show_form($morecss = 'titlefield', $showform = 1) + public function show_form($morecss = 'titlefield', $showform = 1) { // phpcs:enable global $conf, $langs, $user, $form; diff --git a/htdocs/core/class/html.formsocialcontrib.class.php b/htdocs/core/class/html.formsocialcontrib.class.php index c797fb77dbb..74a511ebdd5 100644 --- a/htdocs/core/class/html.formsocialcontrib.class.php +++ b/htdocs/core/class/html.formsocialcontrib.class.php @@ -48,7 +48,7 @@ class FormSocialContrib $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of social contributions. * Use mysoc->country_id or mysoc->country_code so they must be defined. @@ -61,7 +61,7 @@ class FormSocialContrib * @param string $morecss Add more CSS on select * @return void */ - function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1, $morecss = 'minwidth300') + public function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1, $morecss = 'minwidth300') { // phpcs:enable global $conf,$db,$langs,$user,$mysoc; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 4b03886a714..cdbf35dc32b 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2016 Christophe Battarel +/* Copyright (C) 2013-2015 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -291,17 +292,17 @@ class FormTicket // Type print ''; // Severity print ''; - // Category - print ''; // Notify thirdparty at creation @@ -532,7 +533,7 @@ class FormTicket * @param string $morecss More CSS * @return void */ - public function selectAnalyticCodesTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '') + public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '') { global $langs, $user; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 9ab430733e0..3cefeaef99c 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -40,7 +40,7 @@ class FormWebsite * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -54,9 +54,9 @@ class FormWebsite * @param int $useempty Show empty value or not * @return string Html component */ - function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0) + public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0) { - $out=''; + $out=''; $sql = "SELECT rowid, ref"; $sql.= " FROM ".MAIN_DB_PREFIX."website"; @@ -107,16 +107,16 @@ class FormWebsite * @param string $moreattrib More attributes on HTML select tag * @return void */ - function selectTypeOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') + public function selectTypeOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') { - global $langs, $conf, $user; + global $langs, $conf, $user; - $langs->load("admin"); + $langs->load("admin"); - $sql = "SELECT rowid, code, label, entity"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; - $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; - $sql.= " ORDER BY label"; + $sql = "SELECT rowid, code, label, entity"; + $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; + $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; + $sql.= " ORDER BY label"; dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG); $result = $this->db->query($sql); @@ -170,7 +170,7 @@ class FormWebsite * @param string $moreattrib More attributes on HTML select tag * @return void */ - function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') + public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') { global $langs, $conf, $user; diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index ddee9453e08..1138e3a69ad 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -27,15 +27,15 @@ */ class InfoBox { - /** - * Name of positions 0=Home, 1=... - * - * @return string[] Array with list of zones - */ - static function getListOfPagesForBoxes() - { - return array(0=>'Home'); - } + /** + * Name of positions 0=Home, 1=... + * + * @return string[] Array with list of zones + */ + public static function getListOfPagesForBoxes() + { + return array(0=>'Home'); + } /** * Return array of boxes qualified for area and user @@ -48,7 +48,7 @@ class InfoBox * @param int $includehidden Include also hidden boxes * @return array Array of boxes */ - static function listBoxes($db, $mode, $zone, $user = null, $excludelist = array(), $includehidden = 1) + public static function listBoxes($db, $mode, $zone, $user = null, $excludelist = array(), $includehidden = 1) { global $conf; @@ -68,10 +68,10 @@ class InfoBox $sql.= " ORDER BY b.box_order"; } else // available - { + { $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; + $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; } dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); @@ -97,17 +97,17 @@ class InfoBox { $boxname=preg_replace('/\.php$/i', '', $obj->file); $relsourcefile = "/core/boxes/".$boxname.".php"; - } + } - //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'
'; + //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'
'; - // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then + // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then // the "enabled" condition for modules forbidden for external users and the depends condition can be done. // Goal is to avoid making a "new" done for each boxes returned by select. dol_include_once($relsourcefile); if (class_exists($boxname)) { - $box=new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. + $box=new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. //$box=new stdClass(); // box properties @@ -117,9 +117,9 @@ class InfoBox $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); $box->sourcefile= $relsourcefile; - $box->class = $boxname; + $box->class = $boxname; - if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database + if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database { if (is_numeric($box->box_order)) { @@ -138,19 +138,19 @@ class InfoBox { foreach($box->depends as $moduleelem) { - $arrayelem=explode('|', $moduleelem); - $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) - foreach($arrayelem as $module) - { - $tmpmodule=preg_replace('/@[^@]+/', '', $module); - if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; - //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'
'; - } - if (empty($tmpenabled)) // We found at least one module required that is disabled - { - $enabled=0; - break; - } + $arrayelem=explode('|', $moduleelem); + $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) + foreach($arrayelem as $module) + { + $tmpmodule=preg_replace('/@[^@]+/', '', $module); + if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; + //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'
'; + } + if (empty($tmpenabled)) // We found at least one module required that is disabled + { + $enabled=0; + break; + } } } //print '=>'.$boxname.'-enabled='.$enabled.'
'; @@ -160,16 +160,16 @@ class InfoBox else unset($box); } else - { - dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING); - } + { + dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING); + } } $j++; } } else - { - dol_syslog($db->lasterror(), LOG_ERR); + { + dol_syslog($db->lasterror(), LOG_ERR); return array('error'=>$db->lasterror()); } @@ -186,7 +186,7 @@ class InfoBox * @param int $userid Id of user * @return int <0 if KO, 0=Nothing done, > 0 if OK */ - static function saveboxorder($db, $zone, $boxorder, $userid = 0) + public static function saveboxorder($db, $zone, $boxorder, $userid = 0) { global $conf; diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 82b146489e9..ec0c2571ec8 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -36,24 +36,24 @@ class Interfaces */ public $db; - var $dir; // Directory with all core and external triggers files + public $dir; // Directory with all core and external triggers files /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + * @var string[] Error codes (or messages) + */ + public $errors = array(); /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function called when a Dolibarr business event occurs * This function call all qualified triggers. @@ -65,15 +65,15 @@ class Interfaces * @param Conf $conf Objet conf * @return int Nb of triggers ran if no error, -Nb of triggers with errors otherwise. */ - function run_triggers($action, $object, $user, $langs, $conf) + public function run_triggers($action, $object, $user, $langs, $conf) { // phpcs:enable // Check parameters if (! is_object($object) || ! is_object($conf)) // Error { - $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); + $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); - $this->errors[]=$this->error; + $this->errors[]=$this->error; return -1; } if (! is_object($langs)) // Warning @@ -93,10 +93,10 @@ class Interfaces $files = array(); $modules = array(); $orders = array(); - $i=0; + $i=0; - $dirtriggers=array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); + $dirtriggers=array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); foreach($dirtriggers as $reldir) { $dir=dol_buildpath($reldir, 0); @@ -113,9 +113,9 @@ class Interfaces { if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) { - $part1=$reg[1]; - $part2=$reg[2]; - $part3=$reg[3]; + $part1=$reg[1]; + $part2=$reg[2]; + $part3=$reg[3]; $nbfile++; @@ -177,22 +177,22 @@ class Interfaces $objMod = new $modName($this->db); if ($objMod) { - $result=0; + $result=0; - if (method_exists($objMod, 'runTrigger')) // New method to implement - { - //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); - $result=$objMod->runTrigger($action, $object, $user, $langs, $conf); - } - elseif (method_exists($objMod, 'run_trigger')) // Deprecated method - { - dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); - $result=$objMod->run_trigger($action, $object, $user, $langs, $conf); - } - else - { - dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); - } + if (method_exists($objMod, 'runTrigger')) // New method to implement + { + //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); + $result=$objMod->runTrigger($action, $object, $user, $langs, $conf); + } + elseif (method_exists($objMod, 'run_trigger')) // Deprecated method + { + dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); + $result=$objMod->run_trigger($action, $object, $user, $langs, $conf); + } + else + { + dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); + } if ($result > 0) { @@ -217,7 +217,7 @@ class Interfaces } } else - { + { dol_syslog(get_class($this)."::run_triggers action=".$action." Failed to instantiate trigger for file '".$files[$key]."'", LOG_ERR); } } @@ -238,10 +238,10 @@ class Interfaces * Return list of triggers. Function used by admin page htdoc/admin/triggers. * List is sorted by trigger filename so by priority to run. * - * @param array $forcedirtriggers null=All default directories. This parameter is used by modulebuilder module only. + * @param array $forcedirtriggers null=All default directories. This parameter is used by modulebuilder module only. * @return array Array list of triggers */ - function getTriggersList($forcedirtriggers = null) + public function getTriggersList($forcedirtriggers = null) { global $conf, $langs, $db; @@ -256,7 +256,7 @@ class Interfaces $dirtriggers=array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']); if (is_array($forcedirtriggers)) { - $dirtriggers=$forcedirtriggers; + $dirtriggers=$forcedirtriggers; } foreach($dirtriggers as $reldir) @@ -276,9 +276,9 @@ class Interfaces { if (preg_match('/\.back$/', $file)) continue; - $part1=$reg[1]; - $part2=$reg[2]; - $part3=$reg[3]; + $part1=$reg[1]; + $part2=$reg[2]; + $part3=$reg[3]; $modName = 'Interface'.ucfirst($reg[3]); //print "file=$file"; print "modName=$modName"; exit; @@ -319,8 +319,8 @@ class Interfaces if (! class_exists($modName)) { - print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."
\n"; - continue; + print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."
\n"; + continue; } $objMod = new $modName($db); @@ -342,7 +342,7 @@ class Interfaces $triggers[$j]['module']=strtolower($module); } - // We set info of modules + // We set info of modules $triggers[$j]['picto'] = $objMod->picto?img_object('', $objMod->picto):img_object('', 'generic'); $triggers[$j]['file'] = $files[$key]; $triggers[$j]['fullpath'] = $fullpath[$key]; diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 1e23d2a071c..c00f4003d5d 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -42,78 +42,78 @@ class Ldap /** * Tableau des serveurs (IP addresses ou nom d'hotes) */ - var $server=array(); + public $server=array(); /** * Base DN (e.g. "dc=foo,dc=com") */ - var $dn; + public $dn; /** * type de serveur, actuellement OpenLdap et Active Directory */ - var $serverType; + public $serverType; /** * Version du protocole ldap */ - var $domain; + public $domain; /** * User administrateur Ldap * Active Directory ne supporte pas les connexions anonymes */ - var $searchUser; + public $searchUser; /** * Mot de passe de l'administrateur * Active Directory ne supporte pas les connexions anonymes */ - var $searchPassword; + public $searchPassword; /** * DN des utilisateurs */ - var $people; + public $people; /** * DN des groupes */ - var $groups; + public $groups; /** * Code erreur retourne par le serveur Ldap */ - var $ldapErrorCode; + public $ldapErrorCode; /** * Message texte de l'erreur */ - var $ldapErrorText; + public $ldapErrorText; //Fetch user - var $name; - var $firstname; - var $login; - var $phone; - var $skype; - var $fax; - var $mail; - var $mobile; + public $name; + public $firstname; + public $login; + public $phone; + public $skype; + public $fax; + public $mail; + public $mobile; - var $uacf; - var $pwdlastset; + public $uacf; + public $pwdlastset; - var $ldapcharset='UTF-8'; // LDAP should be UTF-8 encoded + public $ldapcharset='UTF-8'; // LDAP should be UTF-8 encoded /** * The internal LDAP connection handle */ - var $connection; + public $connection; /** * Result of any connections etc. */ - var $result; + public $result; /** * Constructor */ - function __construct() + public function __construct() { global $conf; @@ -149,7 +149,7 @@ class Ldap // Connection handling methods ------------------------------------------- - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Connect and bind * Use this->server, this->serverPort, this->ldapProtocolVersion, this->serverType, this->searchUser, this->searchPassword @@ -157,7 +157,7 @@ class Ldap * * @return int <0 if KO, 1 if bind anonymous, 2 if bind auth */ - function connect_bind() + public function connect_bind() { // phpcs:enable global $langs, $conf; @@ -290,7 +290,7 @@ class Ldap * * @return boolean true or false */ - function close() + public function close() { if ($this->connection && ! @ldap_close($this->connection)) { @@ -308,7 +308,7 @@ class Ldap * * @return boolean true or false */ - function bind() + public function bind() { if (! $this->result=@ldap_bind($this->connection)) { @@ -333,7 +333,7 @@ class Ldap * @param string $pass Password * @return boolean true or false */ - function bindauth($bindDn, $pass) + public function bindauth($bindDn, $pass) { if (! $this->result = @ldap_bind($this->connection, $bindDn, $pass)) { @@ -353,7 +353,7 @@ class Ldap * * @return boolean true or false */ - function unbind() + public function unbind() { if (!$this->result=@ldap_unbind($this->connection)) { @@ -369,7 +369,7 @@ class Ldap * * @return string version */ - function getVersion() + public function getVersion() { $version = 0; $version = @ldap_get_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $version); @@ -379,9 +379,9 @@ class Ldap /** * Change ldap protocol version to use. * - * @return boolean version + * @return boolean version */ - function setVersion() + public function setVersion() { // LDAP_OPT_PROTOCOL_VERSION est une constante qui vaut 17 $ldapsetversion = ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion); @@ -391,9 +391,9 @@ class Ldap /** * changement du referrals. * - * @return boolean referrals + * @return boolean referrals */ - function setReferrals() + public function setReferrals() { // LDAP_OPT_REFERRALS est une constante qui vaut ? $ldapreferrals = ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); @@ -410,7 +410,7 @@ class Ldap * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ - function add($dn, $info, $user) + public function add($dn, $info, $user) { global $conf; @@ -464,7 +464,7 @@ class Ldap * @param User $user Objet user that modify * @return int <0 if KO, >0 if OK */ - function modify($dn, $info, $user) + public function modify($dn, $info, $user) { global $conf; @@ -518,7 +518,7 @@ class Ldap * @param bool $deleteoldrdn If true the old RDN value(s) is removed, else the old RDN value(s) is retained as non-distinguished values of the entry. * @return int <0 if KO, >0 if OK */ - function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true) + public function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true) { global $conf; @@ -559,7 +559,7 @@ class Ldap /** * Modify a LDAP entry (to use if dn != olddn) - * Ldap object connect and bind must have been done + * Ldap object connect and bind must have been done * * @param string $dn DN entry key * @param array $info Attributes array @@ -569,7 +569,7 @@ class Ldap * @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb) (for ldap_rename) * @return int <0 if KO, >0 if OK */ - function update($dn, $info, $user, $olddn, $newrdn = false, $newparent = false) + public function update($dn, $info, $user, $olddn, $newrdn = false, $newparent = false) { global $conf; @@ -629,7 +629,7 @@ class Ldap * @param string $dn DN entry key * @return int <0 if KO, >0 if OK */ - function delete($dn) + public function delete($dn) { global $conf; @@ -656,7 +656,7 @@ class Ldap return -1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build a LDAP message * @@ -664,7 +664,7 @@ class Ldap * @param array $info Attributes array * @return string Content of file */ - function dump_content($dn, $info) + public function dump_content($dn, $info) { // phpcs:enable $content=''; @@ -707,7 +707,7 @@ class Ldap * @param array $info Attributes array * @return int <0 if KO, >0 if OK */ - function dump($dn, $info) + public function dump($dn, $info) { global $conf; @@ -741,7 +741,7 @@ class Ldap * @param int $timeout Timeout in second (default 1s) * @return boolean true or false */ - function serverPing($host, $port = 389, $timeout = 1) + public function serverPing($host, $port = 389, $timeout = 1) { // Replace ldaps:// by ssl:// if (preg_match('/^ldaps:\/\/([^\/]+)\/?$/', $host, $regs)) { @@ -771,7 +771,7 @@ class Ldap * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ - function addAttribute($dn, $info, $user) + public function addAttribute($dn, $info, $user) { global $conf; @@ -823,7 +823,7 @@ class Ldap * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ - function updateAttribute($dn, $info, $user) + public function updateAttribute($dn, $info, $user) { global $conf; @@ -875,7 +875,7 @@ class Ldap * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ - function deleteAttribute($dn, $info, $user) + public function deleteAttribute($dn, $info, $user) { global $conf; @@ -925,7 +925,7 @@ class Ldap * @param string $filter Filter * @return int|array <0 or false if KO, array if OK */ - function getAttribute($dn, $filter) + public function getAttribute($dn, $filter) { // Check parameters if (! $this->connection) @@ -970,7 +970,7 @@ class Ldap * @param string $attribute Attributes * @return void */ - function getAttributeValues($filterrecord, $attribute) + public function getAttributeValues($filterrecord, $attribute) { $attributes=array(); $attributes[0] = $attribute; @@ -1015,7 +1015,7 @@ class Ldap * @param array $attributeAsArray Array of fields wanted as an array not a string * @return array Array of [id_record][ldap_field]=value */ - function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array()) + public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array()) { $fulllist=array(); @@ -1123,7 +1123,7 @@ class Ldap * @param string $hex Hex value * @return string Little endian */ - function littleEndian($hex) + public function littleEndian($hex) { for ($x=dol_strlen($hex)-2; $x >= 0; $x=$x-2) { $result .= substr($hex, $x, 2); @@ -1139,7 +1139,7 @@ class Ldap * @param string $ldapUser Login de l'utilisateur * @return string Sid */ - function getObjectSid($ldapUser) + public function getObjectSid($ldapUser) { $criteria = '('.$this->getUserIdentifier().'='.$ldapUser.')'; $justthese = array("objectsid"); @@ -1198,7 +1198,7 @@ class Ldap * @param string $binsid Binary SID * @return string Textual SID */ - function binSIDtoText($binsid) + public function binSIDtoText($binsid) { $hex_sid=bin2hex($binsid); $rev = hexdec(substr($hex_sid, 0, 2)); // Get revision-part of SID @@ -1224,7 +1224,7 @@ class Ldap * @param string $filter Search filter (ex: (sn=nom_personne) ) * @return array|int Array with answers (key lowercased - value) */ - function search($checkDn, $filter) + public function search($checkDn, $filter) { dol_syslog(get_class($this)."::search checkDn=".$checkDn." filter=".$filter); @@ -1260,7 +1260,7 @@ class Ldap * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) * @return int >0 if OK, <0 if KO */ - function fetch($user, $filter) + public function fetch($user, $filter) { // Perform the search and get the entry handles @@ -1353,7 +1353,7 @@ class Ldap * * @return string Login */ - function getUserIdentifier() + public function getUserIdentifier() { if ($this->serverType == "activedirectory") { return $this->attr_sambalogin; @@ -1368,7 +1368,7 @@ class Ldap * @param string $uacf UACF * @return void */ - function parseUACF($uacf) + public function parseUACF($uacf) { //All flags array $flags = array( @@ -1414,7 +1414,7 @@ class Ldap * @param string $samtype SamType * @return string Sam string */ - function parseSAT($samtype) + public function parseSAT($samtype) { $stypes = array( 805306368 => "NORMAL_ACCOUNT", @@ -1438,14 +1438,14 @@ class Ldap return($retval); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Convertit le temps ActiveDirectory en Unix timestamp * * @param string $value AD time to convert * @return integer Unix timestamp */ - function convert_time($value) + public function convert_time($value) { // phpcs:enable $dateLargeInt=$value; // nano secondes depuis 1601 !!!! @@ -1478,7 +1478,7 @@ class Ldap * @param string $pagecodeto Page code for result string * @return string Converted string */ - function convFromOutputCharset($str, $pagecodeto = 'UTF-8') + public function convFromOutputCharset($str, $pagecodeto = 'UTF-8') { global $conf; if ($pagecodeto == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') $str=utf8_decode($str); @@ -1493,7 +1493,7 @@ class Ldap * @param string $keygroup Key of group * @return int gid number */ - function getNextGroupGid($keygroup = 'LDAP_KEY_GROUPS') + public function getNextGroupGid($keygroup = 'LDAP_KEY_GROUPS') { global $conf; diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index d796891e632..283b296b3e3 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -150,11 +150,11 @@ class Link extends CommonObject } /** - * Update parameters of third party + * Update parameters of third party * - * @param User $user User executing update - * @param int $call_trigger 0=no, 1=yes - * @return int <0 if KO, >=0 if OK + * @param User $user User executing update + * @param int $call_trigger 0=no, 1=yes + * @return int <0 if KO, >=0 if OK */ public function update($user = '', $call_trigger = 1) { diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 07fab4e74ea..204efbf0ae7 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -28,14 +28,14 @@ */ class Menu { - var $liste; + public $liste; /** - * Constructor + * Constructor */ - function __construct() + public function __construct() { - $this->liste = array(); + $this->liste = array(); } /** @@ -43,7 +43,7 @@ class Menu * * @return void */ - function clear() + public function clear() { $this->liste = array(); } @@ -65,15 +65,15 @@ class Menu * @param string $prefix Prefix to title (image or picto) * @return void */ - function add($url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '', $prefix = '') + public function add($url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '', $prefix = '') { - $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname, 'prefix'=>$prefix); + $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname, 'prefix'=>$prefix); } /** * Insert a menu entry into this->liste * - * @param int $idafter Array key after which inserting new entry + * @param int $idafter Array key after which inserting new entry * @param string $url Url to follow on click * @param string $titre Label of menu to add * @param integer $level Level of menu to add @@ -88,7 +88,7 @@ class Menu * @param string $prefix Prefix to title (image or picto) * @return void */ - function insert($idafter, $url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '', $prefix = '') + public function insert($idafter, $url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '', $prefix = '') { $array_start = array_slice($this->liste, 0, ($idafter+1)); $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname, 'prefix'=>$prefix)); @@ -96,13 +96,13 @@ class Menu $this->liste=array_merge($array_start, $array_new, $array_end); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a menu entry from this->liste * * @return void */ - function remove_last() + public function remove_last() { // phpcs:enable if (count($this->liste) > 1) { @@ -115,7 +115,7 @@ class Menu * * @return int Number of visible (gray or not) menu entries */ - function getNbOfVisibleMenuEntries() + public function getNbOfVisibleMenuEntries() { $nb=0; foreach($this->liste as $val) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 16c1f54ee31..d1d7534af23 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -91,7 +91,7 @@ class Menubase * @param DoliDB $db Database handler * @param string $menu_handler Menu handler */ - function __construct($db, $menu_handler = '') + public function __construct($db, $menu_handler = '') { $this->db = $db; $this->menu_handler = $menu_handler; @@ -105,7 +105,7 @@ class Menubase * @param User $user User that create * @return int <0 if KO, Id of record if OK */ - function create($user = null) + public function create($user = null) { global $conf, $langs; @@ -245,7 +245,7 @@ class Menubase * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -310,7 +310,7 @@ class Menubase * @param User $user User that load * @return int <0 if KO, >0 if OK */ - function fetch($id, $user = null) + public function fetch($id, $user = null) { global $langs; @@ -384,7 +384,7 @@ class Menubase * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { global $conf, $langs; @@ -410,7 +410,7 @@ class Menubase * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -443,7 +443,7 @@ class Menubase * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @return array Return array with menu entries for top menu */ - function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) + public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) { global $langs, $user, $conf; // To export to dol_eval function global $mainmenu,$leftmenu; // To export to dol_eval function @@ -472,7 +472,7 @@ class Menubase * @param array $tabMenu Array with menu entries already loaded * @return Menu Menu array for particular mainmenu value or full tabArray */ - function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) + public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) { global $langs, $user, $conf; // To export to dol_eval function global $mainmenu,$leftmenu; // To export to dol_eval function @@ -480,16 +480,16 @@ class Menubase $mainmenu=$mymainmenu; // To export to dol_eval function $leftmenu=$myleftmenu; // To export to dol_eval function - // Detect what is top mainmenu id + // Detect what is top mainmenu id $menutopid=''; foreach($tabMenu as $key => $val) { - // Define menutopid of mainmenu - if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu) - { - $menutopid=$val['rowid']; - break; - } + // Define menutopid of mainmenu + if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu) + { + $menutopid=$val['rowid']; + break; + } } // We initialize newmenu with first already found menu entries @@ -561,7 +561,7 @@ class Menubase * @param array $tabMenu Array to store new entries found (in most cases, it's empty, but may be alreay filled) * @return int >0 if OK, <0 if KO */ - function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) + public function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) { global $langs, $user, $conf; // To export to dol_eval function global $mainmenu, $leftmenu; // To export to dol_eval function @@ -577,10 +577,10 @@ class Menubase if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)"; if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)"; $sql.= " ORDER BY m.position, m.rowid"; - //print $sql; + //print $sql; - //$tmp1=microtime(true); - //print '>>> 1 0
'; + //$tmp1=microtime(true); + //print '>>> 1 0
'; dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)."", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -647,8 +647,8 @@ class Menubase $title = $langs->trans($menu['titre']); } } - //$tmp4=microtime(true); - //print '>>> 3 '.($tmp4 - $tmp3).'
'; + //$tmp4=microtime(true); + //print '>>> 3 '.($tmp4 - $tmp3).'
'; // We complete tabMenu $tabMenu[$b]['rowid'] = $menu['rowid']; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 772b3db29e3..a599137109d 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -90,7 +90,7 @@ class Notify * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -105,7 +105,7 @@ class Notify * @param Object $object Object the notification is about * @return string Message */ - function confirmMessage($action, $socid, $object) + public function confirmMessage($action, $socid, $object) { global $langs; $langs->load("mails"); @@ -146,7 +146,7 @@ class Notify * @param array $scope Scope where to search * @return array|int <0 if KO, array of notifications to send if OK */ - function getNotificationsArray($notifcode, $socid = 0, $object = null, $userid = 0, $scope = array('thirdparty', 'user', 'global')) + public function getNotificationsArray($notifcode, $socid = 0, $object = null, $userid = 0, $scope = array('thirdparty', 'user', 'global')) { global $conf, $user; @@ -309,7 +309,7 @@ class Notify * @param array $mimefilename_list List of attached file name in message * @return int <0 if KO, or number of changes if OK */ - function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array()) + public function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array()) { global $user,$conf,$langs,$mysoc; global $hookmanager; @@ -530,7 +530,7 @@ class Notify if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; } - $mailfile = new CMailFile( + $mailfile = new CMailFile( $subject, $sendto, $replyto, @@ -542,7 +542,7 @@ class Notify '', 0, -1 - ); + ); if ($mailfile->sendfile()) { @@ -758,7 +758,7 @@ class Notify if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; } - $mailfile = new CMailFile( + $mailfile = new CMailFile( $subject, $sendto, $replyto, diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 32838f0deb2..2612aa5057b 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -26,18 +26,18 @@ */ class SimpleOpenID { - var $openid_url_identity; - var $URLs = array(); - var $error = array(); - var $fields = array( - 'required' => array(), - 'optional' => array(), + public $openid_url_identity; + public $URLs = array(); + public $error = array(); + public $fields = array( + 'required' => array(), + 'optional' => array(), ); /** * Constructor */ - function __construct() + public function __construct() { if (!function_exists('curl_exec')) { @@ -45,66 +45,66 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOpenIDServer * * @param string $a Server * @return void */ - function SetOpenIDServer($a) + public function SetOpenIDServer($a) { // phpcs:enable $this->URLs['openid_server'] = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOpenIDServer * * @param string $a Server * @return void */ - function SetTrustRoot($a) + public function SetTrustRoot($a) { // phpcs:enable $this->URLs['trust_root'] = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOpenIDServer * * @param string $a Server * @return void */ - function SetCancelURL($a) + public function SetCancelURL($a) { // phpcs:enable $this->URLs['cancel'] = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetApprovedURL * * @param string $a Server * @return void */ - function SetApprovedURL($a) + public function SetApprovedURL($a) { // phpcs:enable $this->URLs['approved'] = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetRequiredFields * * @param string $a Server * @return void */ - function SetRequiredFields($a) + public function SetRequiredFields($a) { // phpcs:enable if (is_array($a)) { @@ -114,14 +114,14 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOptionalFields * * @param string $a Server * @return void */ - function SetOptionalFields($a) + public function SetOptionalFields($a) { // phpcs:enable if (is_array($a)) { @@ -131,14 +131,14 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetIdentity * * @param string $a Server * @return void */ - function SetIdentity($a) + public function SetIdentity($a) { // phpcs:enable // Set Identity URL @@ -162,33 +162,33 @@ class SimpleOpenID $this->openid_url_identity = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * GetIdentity * * @return string */ - function GetIdentity() + public function GetIdentity() { // phpcs:enable // Get Identity return $this->openid_url_identity; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOpenIDServer * * @return void */ - function GetError() + public function GetError() { // phpcs:enable $e = $this->error; return array('code'=>$e[0],'description'=>$e[1]); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * ErrorStore * @@ -196,7 +196,7 @@ class SimpleOpenID * @param string $desc Description * @return void */ - function ErrorStore($code, $desc = null) + public function ErrorStore($code, $desc = null) { // phpcs:enable $errs['OPENID_NOSERVERSFOUND'] = 'Cannot find OpenID Server TAG on Identity page.'; @@ -206,13 +206,13 @@ class SimpleOpenID $this->error = array($code,$desc); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * IsError * * @return boolean */ - function IsError() + public function IsError() { // phpcs:enable if (count($this->error) > 0) @@ -231,7 +231,7 @@ class SimpleOpenID * @param string $response Server * @return void */ - function splitResponse($response) + public function splitResponse($response) { $r = array(); $response = explode("\n", $response); @@ -245,14 +245,14 @@ class SimpleOpenID return $r; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * OpenID_Standarize * * @param string $openid_identity Server * @return string */ - function OpenID_Standarize($openid_identity = null) + public function OpenID_Standarize($openid_identity = null) { // phpcs:enable if ($openid_identity === null) @@ -279,7 +279,7 @@ class SimpleOpenID * @param array $arr An array * @return false|string false if KO, string of url if OK */ - function array2url($arr) + public function array2url($arr) { // converts associated array to URL Query String if (!is_array($arr)){ @@ -292,7 +292,7 @@ class SimpleOpenID return $query; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * FSOCK_Request * @@ -301,7 +301,7 @@ class SimpleOpenID * @param string $params Params * @return boolean|unknown */ - function FSOCK_Request($url, $method = "GET", $params = "") + public function FSOCK_Request($url, $method = "GET", $params = "") { // phpcs:enable $fp = fsockopen("ssl://www.myopenid.com", 443, $errno, $errstr, 3); // Connection timeout is 3 seconds @@ -326,7 +326,7 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * CURL_Request * @@ -335,7 +335,7 @@ class SimpleOpenID * @param string $params Params * @return string */ - function CURL_Request($url, $method = "GET", $params = "") + public function CURL_Request($url, $method = "GET", $params = "") { // phpcs:enable // Remember, SSL MUST BE SUPPORTED @@ -359,14 +359,14 @@ class SimpleOpenID return $response; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * HTML2OpenIDServer * * @param string $content Content * @return array Array of servers */ - function HTML2OpenIDServer($content) + public function HTML2OpenIDServer($content) { // phpcs:enable $get = array(); @@ -387,20 +387,20 @@ class SimpleOpenID } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get openid server * * @param string $url Url to found endpoint * @return string Endpoint */ - function GetOpenIDServer($url = '') + public function GetOpenIDServer($url = '') { // phpcs:enable global $conf; - include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; $response = getURLContent($url); @@ -417,13 +417,13 @@ class SimpleOpenID return $servers[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * GetRedirectURL * * @return string */ - function GetRedirectURL() + public function GetRedirectURL() { // phpcs:enable $params = array(); @@ -443,13 +443,13 @@ class SimpleOpenID return $this->URLs['openid_server'] . "?". $this->array2url($params); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Redirect * * @return void */ - function Redirect() + public function Redirect() { // phpcs:enable $redirect_to = $this->GetRedirectURL(); @@ -465,19 +465,19 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * ValidateWithServer * * @return boolean */ - function ValidateWithServer() + public function ValidateWithServer() { // phpcs:enable $params = array( - 'openid.assoc_handle' => urlencode($_GET['openid_assoc_handle']), - 'openid.signed' => urlencode($_GET['openid_signed']), - 'openid.sig' => urlencode($_GET['openid_sig']) + 'openid.assoc_handle' => urlencode($_GET['openid_assoc_handle']), + 'openid.signed' => urlencode($_GET['openid_signed']), + 'openid.sig' => urlencode($_GET['openid_sig']) ); // Send only required parameters to confirm validity $arr_signed = explode(",", str_replace('sreg.', 'sreg_', $_GET['openid_signed'])); @@ -518,36 +518,36 @@ class SimpleOpenID * @param string $url Url of endpoint to request * @return string First endpoint OpenID server found. False if it failed to found. */ - function sendDiscoveryRequestToGetXRDS($url = '') + public function sendDiscoveryRequestToGetXRDS($url = '') { - global $conf; + global $conf; - include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; - dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); + dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); - $addheaders=array('Accept: application/xrds+xml'); + $addheaders=array('Accept: application/xrds+xml'); $response = getURLContent($url, 'GET', '', 1, $addheaders); - /* response should like this: - - - - - http://specs.openid.net/auth/2.0/server - http://openid.net/srv/ax/1.0 - ... - https://www.google.com/accounts/o8/ud - - - - */ - $content=$response['content']; + /* response should like this: + + + + + http://specs.openid.net/auth/2.0/server + http://openid.net/srv/ax/1.0 + ... + https://www.google.com/accounts/o8/ud + + + + */ + $content=$response['content']; $server=''; if (preg_match('/'.preg_quote('', '/').'(.*)'.preg_quote('', '/').'/is', $content, $reg)) { - $server=$reg[1]; + $server=$reg[1]; } if (empty($server)) @@ -557,9 +557,9 @@ class SimpleOpenID } else { - dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); - $this->SetOpenIDServer($server); - return $server; - } + dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); + $this->SetOpenIDServer($server); + return $server; + } } } diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 7683137767b..1dcd7ef64e5 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -32,9 +32,9 @@ class RssParser public $db; /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; private $_format=''; private $_urlRSS; @@ -61,7 +61,7 @@ class RssParser */ public function __construct($db) { - $this->db = $db; + $this->db = $db; } /** @@ -252,28 +252,28 @@ class RssParser if ($str !== false) { - // Convert $str into xml - if (! empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) - { - //print 'xx'.LIBXML_NOCDATA; - libxml_use_internal_errors(false); - $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA); - } - else - { - $xmlparser=xml_parser_create(''); - if (!is_resource($xmlparser)) { - $this->error="ErrorFailedToCreateParser"; return -1; - } + // Convert $str into xml + if (! empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) + { + //print 'xx'.LIBXML_NOCDATA; + libxml_use_internal_errors(false); + $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA); + } + else + { + $xmlparser=xml_parser_create(''); + if (!is_resource($xmlparser)) { + $this->error="ErrorFailedToCreateParser"; return -1; + } - xml_set_object($xmlparser, $this); - xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element'); - xml_set_character_data_handler($xmlparser, 'feed_cdata'); - $status = xml_parse($xmlparser, $str); - xml_parser_free($xmlparser); - $rss=$this; - //var_dump($rss->_format);exit; - } + xml_set_object($xmlparser, $this); + xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element'); + xml_set_character_data_handler($xmlparser, 'feed_cdata'); + $status = xml_parse($xmlparser, $str); + xml_parser_free($xmlparser); + $rss=$this; + //var_dump($rss->_format);exit; + } } // If $rss loaded @@ -287,16 +287,16 @@ class RssParser $fp = fopen($newpathofdestfile, 'w'); if ($fp) { - fwrite($fp, $str); - fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; - @chmod($newpathofdestfile, octdec($newmask)); + fwrite($fp, $str); + fclose($fp); + if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; + @chmod($newpathofdestfile, octdec($newmask)); - $this->_lastfetchdate=$nowgmt; + $this->_lastfetchdate=$nowgmt; } else { - print 'Error, failed to open file '.$newpathofdestfile.' for write'; + print 'Error, failed to open file '.$newpathofdestfile.' for write'; } } @@ -435,13 +435,13 @@ class RssParser // Add record to result array $this->_rssarray[$i] = array( - 'link'=>$itemLink, - 'title'=>$itemTitle, - 'description'=>$itemDescription, - 'pubDate'=>$itemPubDate, - 'category'=>$itemCategory, - 'id'=>$itemId, - 'author'=>$itemAuthor); + 'link'=>$itemLink, + 'title'=>$itemTitle, + 'description'=>$itemDescription, + 'pubDate'=>$itemPubDate, + 'category'=>$itemCategory, + 'id'=>$itemId, + 'author'=>$itemAuthor); //var_dump($this->_rssarray); $i++; @@ -461,7 +461,7 @@ class RssParser - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Triggered when opened tag is found * @@ -470,7 +470,7 @@ class RssParser * @param array $attrs Attributes of tags * @return void */ - function feed_start_element($p, $element, &$attrs) + public function feed_start_element($p, $element, &$attrs) { // phpcs:enable $el = $element = strtolower($element); @@ -581,7 +581,7 @@ class RssParser } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Triggered when CDATA is found * @@ -589,7 +589,7 @@ class RssParser * @param string $text Tag * @return void */ - function feed_cdata($p, $text) + public function feed_cdata($p, $text) { // phpcs:enable if ($this->_format == 'atom' and $this->incontent) @@ -603,7 +603,7 @@ class RssParser } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Triggered when closed tag is found * @@ -611,7 +611,7 @@ class RssParser * @param string $el Tag * @return void */ - function feed_end_element($p, $el) + public function feed_end_element($p, $el) { // phpcs:enable $el = strtolower($el); @@ -666,7 +666,7 @@ class RssParser * @param string $str2 Str2 * @return string String cancatenated */ - function concat(&$str1, $str2 = "") + public function concat(&$str1, $str2 = "") { if (!isset($str1) ) { $str1=""; @@ -674,14 +674,14 @@ class RssParser $str1 .= $str2; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Enter description here ... * * @param string $text Text * @return void */ - function append_content($text) + public function append_content($text) { // phpcs:enable if ( $this->initem ) { @@ -699,7 +699,7 @@ class RssParser * @param string $text Text * @return void */ - function append($el, $text) + public function append($el, $text) { if (!$el) { return; diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 695464f536f..ff6d8315a2f 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -45,109 +45,109 @@ */ class SMTPs { - /** - * Host Name or IP of SMTP Server to use - */ - var $_smtpsHost = 'localhost'; + /** + * Host Name or IP of SMTP Server to use + */ + private $_smtpsHost = 'localhost'; - /** - * SMTP Server Port definition. 25 is default value - * This can be defined via a INI file or via a setter method - */ - var $_smtpsPort = '25'; + /** + * SMTP Server Port definition. 25 is default value + * This can be defined via a INI file or via a setter method + */ + private $_smtpsPort = '25'; - /** - * Secure SMTP Server access ID - * This can be defined via a INI file or via a setter method - */ - var $_smtpsID = null; + /** + * Secure SMTP Server access ID + * This can be defined via a INI file or via a setter method + */ + private $_smtpsID = null; - /** - * Secure SMTP Server access Password - * This can be defined via a INI file or via a setter method - */ - var $_smtpsPW = null; + /** + * Secure SMTP Server access Password + * This can be defined via a INI file or via a setter method + */ + private $_smtpsPW = null; - /** - * Who sent the Message - * This can be defined via a INI file or via a setter method - */ - var $_msgFrom = null; + /** + * Who sent the Message + * This can be defined via a INI file or via a setter method + */ + private $_msgFrom = null; - /** - * Where are replies and errors to be sent to - * This can be defined via a INI file or via a setter method - */ - var $_msgReplyTo = null; + /** + * Where are replies and errors to be sent to + * This can be defined via a INI file or via a setter method + */ + private $_msgReplyTo = null; - /** - * Who will the Message be sent to; TO, CC, BCC - * Multi-diminsional array containg addresses the message will - * be sent TO, CC or BCC - */ - var $_msgRecipients = null; + /** + * Who will the Message be sent to; TO, CC, BCC + * Multi-diminsional array containg addresses the message will + * be sent TO, CC or BCC + */ + private $_msgRecipients = null; - /** - * Message Subject - */ - var $_msgSubject = null; + /** + * Message Subject + */ + private $_msgSubject = null; - /** - * Message Content - */ - var $_msgContent = null; + /** + * Message Content + */ + private $_msgContent = null; - /** - * Custom X-Headers - */ - var $_msgXheader = null; + /** + * Custom X-Headers + */ + private $_msgXheader = null; - /** - * Character set - * Defaulted to 'iso-8859-1' - */ - var $_smtpsCharSet = 'iso-8859-1'; + /** + * Character set + * Defaulted to 'iso-8859-1' + */ + private $_smtpsCharSet = 'iso-8859-1'; - /** - * Message Sensitivity - * Defaults to ZERO - None - */ - var $_msgSensitivity = 0; + /** + * Message Sensitivity + * Defaults to ZERO - None + */ + private $_msgSensitivity = 0; - /** - * Message Sensitivity - */ - var $_arySensitivity = array ( false, + /** + * Message Sensitivity + */ + private $_arySensitivity = array ( false, 'Personal', 'Private', 'Company Confidential' ); - /** - * Message Sensitivity - * Defaults to 3 - Normal - */ - var $_msgPriority = 3; + /** + * Message Sensitivity + * Defaults to 3 - Normal + */ + private $_msgPriority = 3; - /** - * Message Priority - */ - var $_aryPriority = array ( 'Bulk', + /** + * Message Priority + */ + private $_aryPriority = array ( 'Bulk', 'Highest', 'High', 'Normal', 'Low', 'Lowest' ); - /** - * Content-Transfer-Encoding - * Defaulted to 0 - 7bit - */ - var $_smtpsTransEncodeType = 0; + /** + * Content-Transfer-Encoding + * Defaulted to 0 - 7bit + */ + private $_smtpsTransEncodeType = 0; - /** - * Content-Transfer-Encoding - */ - var $_smtpsTransEncodeTypes = array( '7bit', // Simple 7-bit ASCII + /** + * Content-Transfer-Encoding + */ + private $_smtpsTransEncodeTypes = array( '7bit', // Simple 7-bit ASCII '8bit', // 8-bit coding with line termination characters 'base64', // 3 octets encoded into 4 sextets with offset 'binary', // Arbitrary binary stream @@ -155,78 +155,78 @@ class SMTPs 'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH" 'uuencode' ); // UUENCODE encoding - /** - * Content-Transfer-Encoding - * Defaulted to '7bit' - */ - var $_smtpsTransEncode = '7bit'; + /** + * Content-Transfer-Encoding + * Defaulted to '7bit' + */ + private $_smtpsTransEncode = '7bit'; - /** - * Boundary String for MIME seperation - */ - var $_smtpsBoundary = null; + /** + * Boundary String for MIME seperation + */ + private $_smtpsBoundary = null; - /** - * Related Boundary - */ - var $_smtpsRelatedBoundary = null; + /** + * Related Boundary + */ + private $_smtpsRelatedBoundary = null; - /** - * Alternative Boundary - */ - var $_smtpsAlternativeBoundary = null; + /** + * Alternative Boundary + */ + private $_smtpsAlternativeBoundary = null; - /** - * Determines the method inwhich the message are to be sent. - * - 'sockets' [0] - conect via network to SMTP server - default - * - 'pipe [1] - use UNIX path to EXE - * - 'phpmail [2] - use the PHP built-in mail function - * NOTE: Only 'sockets' is implemented - */ - var $_transportType = 0; + /** + * Determines the method inwhich the message are to be sent. + * - 'sockets' [0] - conect via network to SMTP server - default + * - 'pipe [1] - use UNIX path to EXE + * - 'phpmail [2] - use the PHP built-in mail function + * NOTE: Only 'sockets' is implemented + */ + private $_transportType = 0; - /** - * If '$_transportType' is set to '1', then this variable is used - * to define the UNIX file system path to the sendmail execuable - */ - var $_mailPath = '/usr/lib/sendmail'; + /** + * If '$_transportType' is set to '1', then this variable is used + * to define the UNIX file system path to the sendmail execuable + */ + private $_mailPath = '/usr/lib/sendmail'; - /** - * Sets the SMTP server timeout in seconds. - */ - var $_smtpTimeout = 10; + /** + * Sets the SMTP server timeout in seconds. + */ + private $_smtpTimeout = 10; - /** - * Determines whether to calculate message MD5 checksum. - */ - var $_smtpMD5 = false; + /** + * Determines whether to calculate message MD5 checksum. + */ + private $_smtpMD5 = false; - /** - * Class error codes and messages - */ - var $_smtpsErrors = null; + /** + * Class error codes and messages + */ + private $_smtpsErrors = null; - /** - * Defines log level - * 0 - no logging - * 1 - connectivity logging - * 2 - message generation logging - * 3 - detail logging - */ - var $_log_level = 0; + /** + * Defines log level + * 0 - no logging + * 1 - connectivity logging + * 2 - message generation logging + * 3 - detail logging + */ + private $_log_level = 0; - /** - * Place Class in" debug" mode - */ - var $_debug = false; + /** + * Place Class in" debug" mode + */ + private $_debug = false; - // @CHANGE LDR - var $log = ''; - var $_errorsTo = ''; - var $_deliveryReceipt = 0; - var $_trackId = ''; - var $_moreInHeader = ''; + // @CHANGE LDR + public $log = ''; + private $_errorsTo = ''; + private $_deliveryReceipt = 0; + private $_trackId = ''; + private $_moreInHeader = ''; /** @@ -235,20 +235,20 @@ class SMTPs * @param int $_val Value * @return void */ - function setDeliveryReceipt($_val = 0) - { - $this->_deliveryReceipt = $_val; - } + public function setDeliveryReceipt($_val = 0) + { + $this->_deliveryReceipt = $_val; + } /** * get delivery receipt * * @return int Delivery receipt */ - function getDeliveryReceipt() - { - return $this->_deliveryReceipt; - } + public function getDeliveryReceipt() + { + return $this->_deliveryReceipt; + } /** * Set trackid @@ -256,10 +256,10 @@ class SMTPs * @param string $_val Value * @return void */ - function setTrackId($_val = '') - { - $this->_trackId = $_val; - } + public function setTrackId($_val = '') + { + $this->_trackId = $_val; + } /** * Set moreInHeader @@ -267,30 +267,30 @@ class SMTPs * @param string $_val Value * @return void */ - function setMoreInHeader($_val = '') - { - $this->_moreinheader = $_val; - } + public function setMoreInHeader($_val = '') + { + $this->_moreinheader = $_val; + } - /** + /** * get trackid * * @return string Track id */ - function getTrackId() - { - return $this->_trackId; - } + public function getTrackId() + { + return $this->_trackId; + } - /** - * get moreInHeader - * - * @return string moreInHeader - */ - function getMoreInHeader() - { - return $this->_moreinheader; - } + /** + * get moreInHeader + * + * @return string moreInHeader + */ + public function getMoreInHeader() + { + return $this->_moreinheader; + } /** * Set errors to @@ -298,11 +298,11 @@ class SMTPs * @param string $_strErrorsTo Errors to * @return void */ - function setErrorsTo($_strErrorsTo) - { - if ( $_strErrorsTo ) - $this->_errorsTo = $this->_strip_email($_strErrorsTo); - } + public function setErrorsTo($_strErrorsTo) + { + if ( $_strErrorsTo ) + $this->_errorsTo = $this->_strip_email($_strErrorsTo); + } /** * Get errors to @@ -310,1524 +310,1524 @@ class SMTPs * @param boolean $_part Variant * @return string Errors to */ - function getErrorsTo($_part = true) - { - $_retValue = ''; + public function getErrorsTo($_part = true) + { + $_retValue = ''; - if ( $_part === true ) - $_retValue = $this->_errorsTo; - else - $_retValue = $this->_errorsTo[$_part]; + if ( $_part === true ) + $_retValue = $this->_errorsTo; + else + $_retValue = $this->_errorsTo[$_part]; - return $_retValue; - } + return $_retValue; + } - /** - * Set debug - * - * @param boolean $_vDebug Value for debug - * @return void - */ - function setDebug($_vDebug = false) - { - $this->_debug = $_vDebug; - } + /** + * Set debug + * + * @param boolean $_vDebug Value for debug + * @return void + */ + public function setDebug($_vDebug = false) + { + $this->_debug = $_vDebug; + } - /** - * build RECIPIENT List, all addresses who will recieve this message - * - * @return void - */ - function buildRCPTlist() - { - // Pull TO list - $_aryToList = $this->getTO(); - } + /** + * build RECIPIENT List, all addresses who will recieve this message + * + * @return void + */ + public function buildRCPTlist() + { + // Pull TO list + $_aryToList = $this->getTO(); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Attempt a connection to mail server - * - * @return mixed $_retVal Boolean indicating success or failure on connection - */ - function _server_connect() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Attempt a connection to mail server + * + * @return mixed $_retVal Boolean indicating success or failure on connection + */ + private function _server_connect() + { // phpcs:enable - // Default return value - $_retVal = true; + // Default return value + $_retVal = true; - // We have to make sure the HOST given is valid - // This is done here because '@fsockopen' will not give me this - // information if it failes to connect because it can't find the HOST - $host=$this->getHost(); - $usetls = preg_match('@tls://@i', $host); + // We have to make sure the HOST given is valid + // This is done here because '@fsockopen' will not give me this + // information if it failes to connect because it can't find the HOST + $host=$this->getHost(); + $usetls = preg_match('@tls://@i', $host); - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix + $host=preg_replace('@tcp://@i', '', $host); // Remove prefix + $host=preg_replace('@ssl://@i', '', $host); // Remove prefix + $host=preg_replace('@tls://@i', '', $host); // Remove prefix - // @CHANGE LDR - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + // @CHANGE LDR + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if ( (! is_ip($host)) && ((gethostbyname($host)) == $host)) - { - $this->_setErr(99, $host . ' is either offline or is an invalid host name.'); - $_retVal = false; - } - else - { - //See if we can connect to the SMTP server + if ( (! is_ip($host)) && ((gethostbyname($host)) == $host)) + { + $this->_setErr(99, $host . ' is either offline or is an invalid host name.'); + $_retVal = false; + } + else + { + //See if we can connect to the SMTP server if ($this->socket = @fsockopen( - preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain - $this->getPort(), // which Port number to use - $this->errno, // actual system level error - $this->errstr, // and any text that goes with the error - $this->_smtpTimeout // timeout for reading/writing data over the socket - )) { - // Fix from PHP SMTP class by 'Chris Ryan' - // Sometimes the SMTP server takes a little longer to respond - // so we will give it a longer timeout for the first read - // Windows still does not have support for this timeout function - if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0); + preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain + $this->getPort(), // which Port number to use + $this->errno, // actual system level error + $this->errstr, // and any text that goes with the error + $this->_smtpTimeout // timeout for reading/writing data over the socket + )) { + // Fix from PHP SMTP class by 'Chris Ryan' + // Sometimes the SMTP server takes a little longer to respond + // so we will give it a longer timeout for the first read + // Windows still does not have support for this timeout function + if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0); - // Check response from Server - if ( $_retVal = $this->server_parse($this->socket, "220") ) - $_retVal = $this->socket; - } - // This connection attempt failed. - else - { - // @CHANGE LDR - if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); - $this->_setErr($this->errno, $this->errstr); - $_retVal = false; - } - } + // Check response from Server + if ( $_retVal = $this->server_parse($this->socket, "220") ) + $_retVal = $this->socket; + } + // This connection attempt failed. + else + { + // @CHANGE LDR + if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); + $this->_setErr($this->errno, $this->errstr); + $_retVal = false; + } + } - return $_retVal; - } + return $_retVal; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Attempt mail server authentication for a secure connection - * - * @return boolean|null $_retVal Boolean indicating success or failure of authentication - */ - function _server_authenticate() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Attempt mail server authentication for a secure connection + * + * @return boolean|null $_retVal Boolean indicating success or failure of authentication + */ + private function _server_authenticate() + { // phpcs:enable - global $conf; + global $conf; - // Send the RFC2554 specified EHLO. - // This improvment as provided by 'SirSir' to - // accomodate both SMTP AND ESMTP capable servers - $host=$this->getHost(); - $usetls = preg_match('@tls://@i', $host); + // Send the RFC2554 specified EHLO. + // This improvment as provided by 'SirSir' to + // accomodate both SMTP AND ESMTP capable servers + $host=$this->getHost(); + $usetls = preg_match('@tls://@i', $host); - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix + $host=preg_replace('@tcp://@i', '', $host); // Remove prefix + $host=preg_replace('@ssl://@i', '', $host); // Remove prefix + $host=preg_replace('@tls://@i', '', $host); // Remove prefix - if ($usetls) $host='tls://'.$host; + if ($usetls) $host='tls://'.$host; - $hosth = $host; + $hosth = $host; - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) - { - // If the from to is 'aaa ', we will keep 'ccc.com' - $hosth = $this->getFrom('addr'); - $hosth = preg_replace('/^.*.*$/', '', $hosth); - $hosth = preg_replace('/.*@/', '', $hosth); - } + if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) + { + // If the from to is 'aaa ', we will keep 'ccc.com' + $hosth = $this->getFrom('addr'); + $hosth = preg_replace('/^.*.*$/', '', $hosth); + $hosth = preg_replace('/.*@/', '', $hosth); + } - if ( $_retVal = $this->socket_send_str('EHLO ' . $hosth, '250') ) - { - if ($usetls) - { - /* - The following dialog illustrates how a client and server can start a TLS STARTTLS session - S: - C: - S: 220 mail.imc.org SMTP service ready - C: EHLO mail.ietf.org - S: 250-mail.imc.org offers a warm hug of welcome - S: 250 STARTTLS - C: STARTTLS - S: 220 Go ahead - C: - C & S: - C & S: + if ( $_retVal = $this->socket_send_str('EHLO ' . $hosth, '250') ) + { + if ($usetls) + { + /* + The following dialog illustrates how a client and server can start a TLS STARTTLS session + S: + C: + S: 220 mail.imc.org SMTP service ready + C: EHLO mail.ietf.org + S: 250-mail.imc.org offers a warm hug of welcome + S: 250 STARTTLS + C: STARTTLS + S: 220 Go ahead + C: + C & S: + C & S: // Second pass EHLO C: EHLO client-domain.com S: 250-server-domain.com S: 250 AUTH LOGIN - C: socket_send_str('STARTTLS', 220)) - { - $this->_setErr(131, 'STARTTLS connection is not supported.'); - return $_retVal; - } + C: socket_send_str('STARTTLS', 220)) + { + $this->_setErr(131, 'STARTTLS connection is not supported.'); + return $_retVal; + } - // Before 5.6.7: - // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_SSLv2_CLIENT|STREAM_CRYPTO_METHOD_SSLv3_CLIENT - // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT - // PHP >= 5.6.7: - // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT - // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT + // Before 5.6.7: + // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_SSLv2_CLIENT|STREAM_CRYPTO_METHOD_SSLv3_CLIENT + // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT + // PHP >= 5.6.7: + // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT + // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT - $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; - if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { - $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; - $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; - } + $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; + if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { + $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; + $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; + } - if (!stream_socket_enable_crypto($this->socket, true, $crypto_method)) - { - $this->_setErr(132, 'STARTTLS connection failed.'); - return $_retVal; - } - // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time - // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. - if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250')) - { - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); - return $_retVal; - } - } - // Send Authentication to Server - // Check for errors along the way - $this->socket_send_str('AUTH LOGIN', '334'); + if (!stream_socket_enable_crypto($this->socket, true, $crypto_method)) + { + $this->_setErr(132, 'STARTTLS connection failed.'); + return $_retVal; + } + // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time + // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. + if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250')) + { + $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); + return $_retVal; + } + } + // Send Authentication to Server + // Check for errors along the way + $this->socket_send_str('AUTH LOGIN', '334'); - // User name will not return any error, server will take anything we give it. - $this->socket_send_str(base64_encode($this->_smtpsID), '334'); + // User name will not return any error, server will take anything we give it. + $this->socket_send_str(base64_encode($this->_smtpsID), '334'); - // The error here just means the ID/password combo doesn't work. - // There is not a method to determine which is the problem, ID or password - if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) - $this->_setErr(130, 'Invalid Authentication Credentials.'); - } - else - { - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); - } + // The error here just means the ID/password combo doesn't work. + // There is not a method to determine which is the problem, ID or password + if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) + $this->_setErr(130, 'Invalid Authentication Credentials.'); + } + else + { + $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); + } - return $_retVal; - } + return $_retVal; + } - /** - * Now send the message - * - * @param boolean $_bolTestMsg whether to run this method in 'Test' mode. - * @param boolean $_bolDebug whether to log all communication between this Class and the Mail Server. - * @return boolean|null void - * $_strMsg If this is run in 'Test' mode, the actual message structure will be returned - */ - function sendMsg($_bolTestMsg = false, $_bolDebug = false) - { - global $conf; + /** + * Now send the message + * + * @param boolean $_bolTestMsg whether to run this method in 'Test' mode. + * @param boolean $_bolDebug whether to log all communication between this Class and the Mail Server. + * @return boolean|null void + * $_strMsg If this is run in 'Test' mode, the actual message structure will be returned + */ + public function sendMsg($_bolTestMsg = false, $_bolDebug = false) + { + global $conf; - /** - * Default return value - */ - $_retVal = false; + /** + * Default return value + */ + $_retVal = false; - // Connect to Server - if ( $this->socket = $this->_server_connect() ) - { - // If a User ID *and* a password is given, assume Authentication is desired - if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) ) - { - // Send the RFC2554 specified EHLO. - $_retVal = $this->_server_authenticate(); - } + // Connect to Server + if ( $this->socket = $this->_server_connect() ) + { + // If a User ID *and* a password is given, assume Authentication is desired + if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) ) + { + // Send the RFC2554 specified EHLO. + $_retVal = $this->_server_authenticate(); + } - // This is a "normal" SMTP Server "handshack" - else - { - // Send the RFC821 specified HELO. - $host=$this->getHost(); - $usetls = preg_match('@tls://@i', $host); + // This is a "normal" SMTP Server "handshack" + else + { + // Send the RFC821 specified HELO. + $host=$this->getHost(); + $usetls = preg_match('@tls://@i', $host); - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix + $host=preg_replace('@tcp://@i', '', $host); // Remove prefix + $host=preg_replace('@ssl://@i', '', $host); // Remove prefix + $host=preg_replace('@tls://@i', '', $host); // Remove prefix - $hosth = $host; + $hosth = $host; - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) - { - // If the from to is 'aaa ', we will keep 'ccc.com' - $hosth = $this->getFrom('addr'); - $hosth = preg_replace('/^.*.*$/', '', $hosth); - $hosth = preg_replace('/.*@/', '', $hosth); - } + if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) + { + // If the from to is 'aaa ', we will keep 'ccc.com' + $hosth = $this->getFrom('addr'); + $hosth = preg_replace('/^.*.*$/', '', $hosth); + $hosth = preg_replace('/.*@/', '', $hosth); + } - $_retVal = $this->socket_send_str('HELO ' . $hosth, '250'); - } + $_retVal = $this->socket_send_str('HELO ' . $hosth, '250'); + } - // Well, did we get to the server? - if ( $_retVal ) - { - // From this point onward most server response codes should be 250 - // Specify who the mail is from.... - // This has to be the raw email address, strip the "name" off - $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250'); + // Well, did we get to the server? + if ( $_retVal ) + { + // From this point onward most server response codes should be 250 + // Specify who the mail is from.... + // This has to be the raw email address, strip the "name" off + $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250'); - // 'RCPT TO:' must be given a single address, so this has to loop - // through the list of addresses, regardless of TO, CC or BCC - // and send it out "single file" - foreach ($this->get_RCPT_list() as $_address) - { - /* Note: - * BCC email addresses must be listed in the RCPT TO command list, + // 'RCPT TO:' must be given a single address, so this has to loop + // through the list of addresses, regardless of TO, CC or BCC + // and send it out "single file" + foreach ($this->get_RCPT_list() as $_address) + { + /* Note: + * BCC email addresses must be listed in the RCPT TO command list, * but the BCC header should not be printed under the DATA command. - * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server - */ + * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server + */ - /* - * TODO - * After each 'RCPT TO:' is sent, we need to make sure it was kosher, - * if not, the whole message will fail - * If any email address fails, we will need to RESET the connection, - * mark the last address as "bad" and start the address loop over again. - * If any address fails, the entire message fails. - */ - $this->socket_send_str('RCPT TO: <' . $_address . '>', '250'); - } + /* + * TODO + * After each 'RCPT TO:' is sent, we need to make sure it was kosher, + * if not, the whole message will fail + * If any email address fails, we will need to RESET the connection, + * mark the last address as "bad" and start the address loop over again. + * If any address fails, the entire message fails. + */ + $this->socket_send_str('RCPT TO: <' . $_address . '>', '250'); + } - // Tell the server we are ready to start sending data - // with any custom headers... - // This is the last response code we look for until the end of the message. - $this->socket_send_str('DATA', '354'); + // Tell the server we are ready to start sending data + // with any custom headers... + // This is the last response code we look for until the end of the message. + $this->socket_send_str('DATA', '354'); - // Now we are ready for the message... - // Ok, all the ingredients are mixed in let's cook this puppy... - $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250'); + // Now we are ready for the message... + // Ok, all the ingredients are mixed in let's cook this puppy... + $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250'); - // Now tell the server we are done and close the socket... - fputs($this->socket, 'QUIT'); - fclose($this->socket); - } - } + // Now tell the server we are done and close the socket... + fputs($this->socket, 'QUIT'); + fclose($this->socket); + } + } - return $_retVal; - } + return $_retVal; + } - // ============================================================= - // ** Setter & Getter methods + // ============================================================= + // ** Setter & Getter methods - // ** Basic System configuration + // ** Basic System configuration - /** - * setConfig() is used to populate select class properties from either - * a user defined INI file or the systems 'php.ini' file - * - * If a user defined INI is to be used, the files complete path is passed - * as the method single parameter. The INI can define any class and/or - * user properties. Only properties defined within this file will be setter - * and/or orverwritten - * - * If the systems 'php.ini' file is to be used, the method is called without - * parameters. In this case, only HOST, PORT and FROM properties will be set - * as they are the only properties that are defined within the 'php.ini'. - * - * If secure SMTP is to be used, the user ID and Password can be defined with - * the user INI file, but the properties are not defined with the systems - * 'php.ini'file, they must be defined via their setter methods - * - * This method can be called twice, if desired. Once without a parameter to - * load the properties as defined within the systems 'php.ini' file, and a - * second time, with a path to a user INI file for other properties to be - * defined. - * - * @param mixed $_strConfigPath path to config file or VOID - * @return boolean - */ - function setConfig($_strConfigPath = null) - { - /** - * Returns constructed SELECT Object string or boolean upon failure - * Default value is set at true - */ - $_retVal = true; + /** + * setConfig() is used to populate select class properties from either + * a user defined INI file or the systems 'php.ini' file + * + * If a user defined INI is to be used, the files complete path is passed + * as the method single parameter. The INI can define any class and/or + * user properties. Only properties defined within this file will be setter + * and/or orverwritten + * + * If the systems 'php.ini' file is to be used, the method is called without + * parameters. In this case, only HOST, PORT and FROM properties will be set + * as they are the only properties that are defined within the 'php.ini'. + * + * If secure SMTP is to be used, the user ID and Password can be defined with + * the user INI file, but the properties are not defined with the systems + * 'php.ini'file, they must be defined via their setter methods + * + * This method can be called twice, if desired. Once without a parameter to + * load the properties as defined within the systems 'php.ini' file, and a + * second time, with a path to a user INI file for other properties to be + * defined. + * + * @param mixed $_strConfigPath path to config file or VOID + * @return boolean + */ + public function setConfig($_strConfigPath = null) + { + /** + * Returns constructed SELECT Object string or boolean upon failure + * Default value is set at true + */ + $_retVal = true; - // if we have a path... - if ( ! empty($_strConfigPath) ) - { - // If the path is not valid, this will NOT generate an error, - // it will simply return false. - if ( ! @include $_strConfigPath) - { - $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.'); - $_retVal = false; - } - } + // if we have a path... + if ( ! empty($_strConfigPath) ) + { + // If the path is not valid, this will NOT generate an error, + // it will simply return false. + if ( ! @include $_strConfigPath) + { + $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.'); + $_retVal = false; + } + } - // Read the Systems php.ini file - else - { - // Set these properties ONLY if they are set in the php.ini file. - // Otherwise the default values will be used. - if ( $_host = ini_get('SMTPs') ) - $this->setHost($_host); + // Read the Systems php.ini file + else + { + // Set these properties ONLY if they are set in the php.ini file. + // Otherwise the default values will be used. + if ( $_host = ini_get('SMTPs') ) + $this->setHost($_host); - if ( $_port = ini_get('smtp_port') ) - $this->setPort($_port); + if ( $_port = ini_get('smtp_port') ) + $this->setPort($_port); - if ( $_from = ini_get('sendmail_from') ) - $this->setFrom($_from); - } + if ( $_from = ini_get('sendmail_from') ) + $this->setFrom($_from); + } - // Send back what we have - return $_retVal; - } + // Send back what we have + return $_retVal; + } - /** - * Determines the method inwhich the messages are to be sent. - * - 'sockets' [0] - conect via network to SMTP server - * - 'pipe [1] - use UNIX path to EXE - * - 'phpmail [2] - use the PHP built-in mail function - * - * @param int $_type Interger value representing Mail Transport Type - * @return void - */ - function setTransportType($_type = 0) - { - if ( ( is_numeric($_type) ) && - ( ( $_type >= 0 ) && ( $_type <= 3 ) ) ) - $this->_transportType = $_type; - } + /** + * Determines the method inwhich the messages are to be sent. + * - 'sockets' [0] - conect via network to SMTP server + * - 'pipe [1] - use UNIX path to EXE + * - 'phpmail [2] - use the PHP built-in mail function + * + * @param int $_type Interger value representing Mail Transport Type + * @return void + */ + public function setTransportType($_type = 0) + { + if ((is_numeric($_type)) && (($_type >= 0) && ($_type <= 3))) { + $this->_transportType = $_type; + } + } - /** - * Return the method inwhich the message is to be sent. - * - 'sockets' [0] - conect via network to SMTP server - * - 'pipe [1] - use UNIX path to EXE - * - 'phpmail [2] - use the PHP built-in mail function - * - * @return int $_strHost Host Name or IP of the Mail Server to use - */ - function getTransportType() - { - return $this->_transportType; - } + /** + * Return the method inwhich the message is to be sent. + * - 'sockets' [0] - conect via network to SMTP server + * - 'pipe [1] - use UNIX path to EXE + * - 'phpmail [2] - use the PHP built-in mail function + * + * @return int $_strHost Host Name or IP of the Mail Server to use + */ + public function getTransportType() + { + return $this->_transportType; + } - /** - * Path to the sendmail execuable - * - * @param string $_path Path to the sendmail execuable - * @return boolean - * - */ - function setMailPath($_path) - { - // This feature is not yet implemented - return true; + /** + * Path to the sendmail execuable + * + * @param string $_path Path to the sendmail execuable + * @return boolean + * + */ + public function setMailPath($_path) + { + // This feature is not yet implemented + return true; - //if ( $_path ) $this->_mailPath = $_path; - } + //if ( $_path ) $this->_mailPath = $_path; + } - /** - * Defines the Host Name or IP of the Mail Server to use. - * This is defaulted to 'localhost' - * This is used only with 'socket' based mail transmission - * - * @param string $_strHost Host Name or IP of the Mail Server to use - * @return void - */ - function setHost($_strHost) - { - if ( $_strHost ) - $this->_smtpsHost = $_strHost; - } + /** + * Defines the Host Name or IP of the Mail Server to use. + * This is defaulted to 'localhost' + * This is used only with 'socket' based mail transmission + * + * @param string $_strHost Host Name or IP of the Mail Server to use + * @return void + */ + public function setHost($_strHost) + { + if ( $_strHost ) + $this->_smtpsHost = $_strHost; + } - /** - * Retrieves the Host Name or IP of the Mail Server to use - * This is used only with 'socket' based mail transmission - * - * @return string $_strHost Host Name or IP of the Mail Server to use - */ - function getHost() - { - return $this->_smtpsHost; - } + /** + * Retrieves the Host Name or IP of the Mail Server to use + * This is used only with 'socket' based mail transmission + * + * @return string $_strHost Host Name or IP of the Mail Server to use + */ + public function getHost() + { + return $this->_smtpsHost; + } - /** - * Defines the Port Number of the Mail Server to use - * This is defaulted to '25' - * This is used only with 'socket' based mail transmission - * - * @param int $_intPort Port Number of the Mail Server to use - * @return void - */ - function setPort($_intPort) - { - if ( ( is_numeric($_intPort) ) && - ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) - $this->_smtpsPort = $_intPort; - } + /** + * Defines the Port Number of the Mail Server to use + * This is defaulted to '25' + * This is used only with 'socket' based mail transmission + * + * @param int $_intPort Port Number of the Mail Server to use + * @return void + */ + public function setPort($_intPort) + { + if ( ( is_numeric($_intPort) ) && + ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) + $this->_smtpsPort = $_intPort; + } - /** - * Retrieves the Port Number of the Mail Server to use - * This is used only with 'socket' based mail transmission - * - * @return string Port Number of the Mail Server to use - */ - function getPort() - { - return $this->_smtpsPort; - } + /** + * Retrieves the Port Number of the Mail Server to use + * This is used only with 'socket' based mail transmission + * + * @return string Port Number of the Mail Server to use + */ + public function getPort() + { + return $this->_smtpsPort; + } - /** - * User Name for authentication on Mail Server - * - * @param string $_strID User Name for authentication on Mail Server - * @return void - */ - function setID($_strID) - { - $this->_smtpsID = $_strID; - } + /** + * User Name for authentication on Mail Server + * + * @param string $_strID User Name for authentication on Mail Server + * @return void + */ + public function setID($_strID) + { + $this->_smtpsID = $_strID; + } - /** - * Retrieves the User Name for authentication on Mail Server - * - * @return string User Name for authentication on Mail Server - */ - function getID() - { - return $this->_smtpsID; - } + /** + * Retrieves the User Name for authentication on Mail Server + * + * @return string User Name for authentication on Mail Server + */ + public function getID() + { + return $this->_smtpsID; + } - /** - * User Password for authentication on Mail Server - * - * @param string $_strPW User Password for authentication on Mail Server - * @return void - */ - function setPW($_strPW) - { - $this->_smtpsPW = $_strPW; - } + /** + * User Password for authentication on Mail Server + * + * @param string $_strPW User Password for authentication on Mail Server + * @return void + */ + public function setPW($_strPW) + { + $this->_smtpsPW = $_strPW; + } - /** - * Retrieves the User Password for authentication on Mail Server - * - * @return string User Password for authentication on Mail Server - */ - function getPW() - { - return $this->_smtpsPW; - } + /** + * Retrieves the User Password for authentication on Mail Server + * + * @return string User Password for authentication on Mail Server + */ + public function getPW() + { + return $this->_smtpsPW; + } - /** - * Character set used for current message - * Character set is defaulted to 'iso-8859-1'; - * - * @param string $_strCharSet Character set used for current message - * @return void - */ - function setCharSet($_strCharSet) - { - if ( $_strCharSet ) - $this->_smtpsCharSet = $_strCharSet; - } + /** + * Character set used for current message + * Character set is defaulted to 'iso-8859-1'; + * + * @param string $_strCharSet Character set used for current message + * @return void + */ + public function setCharSet($_strCharSet) + { + if ( $_strCharSet ) + $this->_smtpsCharSet = $_strCharSet; + } - /** - * Retrieves the Character set used for current message - * - * @return string $_smtpsCharSet Character set used for current message - */ - function getCharSet() - { - return $this->_smtpsCharSet; - } + /** + * Retrieves the Character set used for current message + * + * @return string $_smtpsCharSet Character set used for current message + */ + public function getCharSet() + { + return $this->_smtpsCharSet; + } - /** - * Content-Transfer-Encoding, Defaulted to '7bit' - * This can be changed for 2byte characers sets - * Known Encode Types - * - 7bit Simple 7-bit ASCII - * - 8bit 8-bit coding with line termination characters - * - base64 3 octets encoded into 4 sextets with offset - * - binary Arbitrary binary stream - * - mac-binhex40 Macintosh binary to hex encoding - * - quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH" - * - uuencode UUENCODE encoding - * - * @param string $_strTransEncode Content-Transfer-Encoding - * @return void - */ - function setTransEncode($_strTransEncode) - { - if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) - $this->_smtpsTransEncode = $_strTransEncode; - } + /** + * Content-Transfer-Encoding, Defaulted to '7bit' + * This can be changed for 2byte characers sets + * Known Encode Types + * - 7bit Simple 7-bit ASCII + * - 8bit 8-bit coding with line termination characters + * - base64 3 octets encoded into 4 sextets with offset + * - binary Arbitrary binary stream + * - mac-binhex40 Macintosh binary to hex encoding + * - quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH" + * - uuencode UUENCODE encoding + * + * @param string $_strTransEncode Content-Transfer-Encoding + * @return void + */ + public function setTransEncode($_strTransEncode) + { + if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) + $this->_smtpsTransEncode = $_strTransEncode; + } - /** - * Retrieves the Content-Transfer-Encoding - * - * @return string $_smtpsTransEncode Content-Transfer-Encoding - */ - function getTransEncode() - { - return $this->_smtpsTransEncode; - } + /** + * Retrieves the Content-Transfer-Encoding + * + * @return string $_smtpsTransEncode Content-Transfer-Encoding + */ + public function getTransEncode() + { + return $this->_smtpsTransEncode; + } - /** - * Content-Transfer-Encoding, Defaulted to '0' [ZERO] - * This can be changed for 2byte characers sets - * Known Encode Types - * - [0] 7bit Simple 7-bit ASCII - * - [1] 8bit 8-bit coding with line termination characters - * - [2] base64 3 octets encoded into 4 sextets with offset - * - [3] binary Arbitrary binary stream - * - [4] mac-binhex40 Macintosh binary to hex encoding - * - [5] quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH" - * - [6] uuencode UUENCODE encoding - * - * @param string $_strTransEncodeType Content-Transfer-Encoding - * @return void - * - */ - function setTransEncodeType($_strTransEncodeType) - { - if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) - $this->_smtpsTransEncodeType = $_strTransEncodeType; - } + /** + * Content-Transfer-Encoding, Defaulted to '0' [ZERO] + * This can be changed for 2byte characers sets + * Known Encode Types + * - [0] 7bit Simple 7-bit ASCII + * - [1] 8bit 8-bit coding with line termination characters + * - [2] base64 3 octets encoded into 4 sextets with offset + * - [3] binary Arbitrary binary stream + * - [4] mac-binhex40 Macintosh binary to hex encoding + * - [5] quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH" + * - [6] uuencode UUENCODE encoding + * + * @param string $_strTransEncodeType Content-Transfer-Encoding + * @return void + * + */ + public function setTransEncodeType($_strTransEncodeType) + { + if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) + $this->_smtpsTransEncodeType = $_strTransEncodeType; + } - /** - * Retrieves the Content-Transfer-Encoding - * - * @return string Content-Transfer-Encoding - */ - function getTransEncodeType() - { - return $this->_smtpsTransEncodeTypes[$this->_smtpsTransEncodeType]; - } + /** + * Retrieves the Content-Transfer-Encoding + * + * @return string Content-Transfer-Encoding + */ + public function getTransEncodeType() + { + return $this->_smtpsTransEncodeTypes[$this->_smtpsTransEncodeType]; + } - // ** Message Construction + // ** Message Construction - /** - * FROM Address from which mail will be sent - * - * @param string $_strFrom Address from which mail will be sent - * @return void - */ - function setFrom($_strFrom) - { - if ( $_strFrom ) - $this->_msgFrom = $this->_strip_email($_strFrom); - } + /** + * FROM Address from which mail will be sent + * + * @param string $_strFrom Address from which mail will be sent + * @return void + */ + public function setFrom($_strFrom) + { + if ( $_strFrom ) + $this->_msgFrom = $this->_strip_email($_strFrom); + } - /** - * Retrieves the Address from which mail will be sent - * - * @param boolean $_part To "strip" 'Real name' from address - * @return string Address from which mail will be sent - */ - function getFrom($_part = true) - { - $_retValue = ''; + /** + * Retrieves the Address from which mail will be sent + * + * @param boolean $_part To "strip" 'Real name' from address + * @return string Address from which mail will be sent + */ + public function getFrom($_part = true) + { + $_retValue = ''; - if ( $_part === true ) - $_retValue = $this->_msgFrom; - else - $_retValue = $this->_msgFrom[$_part]; + if ( $_part === true ) + $_retValue = $this->_msgFrom; + else + $_retValue = $this->_msgFrom[$_part]; - return $_retValue; - } + return $_retValue; + } - /** - * Reply-To Address from which mail will be the reply-to - * - * @param string $_strReplyTo Address from which mail will be the reply-to - * @return void - */ - function setReplyTo($_strReplyTo) - { - if ( $_strReplyTo ) - $this->_msgReplyTo = $this->_strip_email($_strReplyTo); - } + /** + * Reply-To Address from which mail will be the reply-to + * + * @param string $_strReplyTo Address from which mail will be the reply-to + * @return void + */ + public function setReplyTo($_strReplyTo) + { + if ( $_strReplyTo ) + $this->_msgReplyTo = $this->_strip_email($_strReplyTo); + } - /** - * Retrieves the Address from which mail will be the reply-to - * - * @param boolean $_part To "strip" 'Real name' from address - * @return string Address from which mail will be the reply-to - */ - function getReplyTo($_part = true) - { - $_retValue = ''; + /** + * Retrieves the Address from which mail will be the reply-to + * + * @param boolean $_part To "strip" 'Real name' from address + * @return string Address from which mail will be the reply-to + */ + public function getReplyTo($_part = true) + { + $_retValue = ''; - if ( $_part === true ) - $_retValue = $this->_msgReplyTo; - else - $_retValue = $this->_msgReplyTo[$_part]; + if ( $_part === true ) + $_retValue = $this->_msgReplyTo; + else + $_retValue = $this->_msgReplyTo[$_part]; - return $_retValue; - } + return $_retValue; + } - /** - * Inserts given addresses into structured format. - * This method takes a list of given addresses, via an array - * or a COMMA delimted string, and inserts them into a highly - * structured array. This array is designed to remove duplicate - * addresses and to sort them by Domain. - * - * @param string $_type TO, CC, or BCC lists to add addrresses into - * @param mixed $_addrList Array or COMMA delimited string of addresses - * @return void - * - */ - function _buildAddrList($_type, $_addrList) - { - // Pull existing list - $aryHost = $this->_msgRecipients; + /** + * Inserts given addresses into structured format. + * This method takes a list of given addresses, via an array + * or a COMMA delimted string, and inserts them into a highly + * structured array. This array is designed to remove duplicate + * addresses and to sort them by Domain. + * + * @param string $_type TO, CC, or BCC lists to add addrresses into + * @param mixed $_addrList Array or COMMA delimited string of addresses + * @return void + * + */ + private function _buildAddrList($_type, $_addrList) + { + // Pull existing list + $aryHost = $this->_msgRecipients; - // Only run this if we have something - if ( !empty($_addrList)) - { - // $_addrList can be a STRING or an array - if ( is_string($_addrList) ) - { - // This could be a COMMA delimited string - if ( strstr($_addrList, ',') ) - // "explode "list" into an array - $_addrList = explode(',', $_addrList); + // Only run this if we have something + if ( !empty($_addrList)) + { + // $_addrList can be a STRING or an array + if ( is_string($_addrList) ) + { + // This could be a COMMA delimited string + if ( strstr($_addrList, ',') ) + // "explode "list" into an array + $_addrList = explode(',', $_addrList); - // Stick it in an array - else - $_addrList = array($_addrList); - } + // Stick it in an array + else + $_addrList = array($_addrList); + } - // take the array of addresses and split them further - foreach ($_addrList as $_strAddr) - { - // Strip off the end '>' - $_strAddr = str_replace('>', '', $_strAddr); + // take the array of addresses and split them further + foreach ($_addrList as $_strAddr) + { + // Strip off the end '>' + $_strAddr = str_replace('>', '', $_strAddr); - // Seperate "Real Name" from eMail address - $_tmpaddr = null; - $_tmpaddr = explode('<', $_strAddr); + // Seperate "Real Name" from eMail address + $_tmpaddr = null; + $_tmpaddr = explode('<', $_strAddr); - // We have a "Real Name" and eMail address - if ( count($_tmpaddr) == 2 ) - { - $_tmpHost = explode('@', $_tmpaddr[1]); - $_tmpaddr[0] = trim($_tmpaddr[0], ' ">'); - $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0]; - } - // We only have an eMail address - else - { - // Strip off the beggining '<' - $_strAddr = str_replace('<', '', $_strAddr); + // We have a "Real Name" and eMail address + if ( count($_tmpaddr) == 2 ) + { + $_tmpHost = explode('@', $_tmpaddr[1]); + $_tmpaddr[0] = trim($_tmpaddr[0], ' ">'); + $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0]; + } + // We only have an eMail address + else + { + // Strip off the beggining '<' + $_strAddr = str_replace('<', '', $_strAddr); - $_tmpHost = explode('@', $_strAddr); - $_tmpHost[0] = trim($_tmpHost[0]); - $_tmpHost[1] = trim($_tmpHost[1]); + $_tmpHost = explode('@', $_strAddr); + $_tmpHost[0] = trim($_tmpHost[0]); + $_tmpHost[1] = trim($_tmpHost[1]); - $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = ''; - } - } - } - // replace list - $this->_msgRecipients = $aryHost; - } + $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = ''; + } + } + } + // replace list + $this->_msgRecipients = $aryHost; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Returns an array of the various parts of an email address - * This assumes a well formed address: - * - "Real name" - * - "Real Name" is optional - * - if "Real Name" does not exist, the angle brackets are optional - * This will split an email address into 4 or 5 parts. - * - $_aryEmail[org] = orignal string - * - $_aryEmail[real] = "real name" - if there is one - * - $_aryEmail[addr] = address part "username@domain.tld" - * - $_aryEmail[host] = "domain.tld" - * - $_aryEmail[user] = "userName" - * - * @param string $_strAddr Email address - * @return array An array of the various parts of an email address - */ - function _strip_email($_strAddr) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns an array of the various parts of an email address + * This assumes a well formed address: + * - "Real name" + * - "Real Name" is optional + * - if "Real Name" does not exist, the angle brackets are optional + * This will split an email address into 4 or 5 parts. + * - $_aryEmail[org] = orignal string + * - $_aryEmail[real] = "real name" - if there is one + * - $_aryEmail[addr] = address part "username@domain.tld" + * - $_aryEmail[host] = "domain.tld" + * - $_aryEmail[user] = "userName" + * + * @param string $_strAddr Email address + * @return array An array of the various parts of an email address + */ + private function _strip_email($_strAddr) + { // phpcs:enable - // Keep the orginal - $_aryEmail['org'] = $_strAddr; + // Keep the orginal + $_aryEmail['org'] = $_strAddr; - // Set entire string to Lower Case - $_strAddr = strtolower($_strAddr); + // Set entire string to Lower Case + $_strAddr = strtolower($_strAddr); - // Drop "stuff' off the end - $_strAddr = trim($_strAddr, ' ">'); + // Drop "stuff' off the end + $_strAddr = trim($_strAddr, ' ">'); - // Seperate "Real Name" from eMail address, if we have one - $_tmpAry = explode('<', $_strAddr); + // Seperate "Real Name" from eMail address, if we have one + $_tmpAry = explode('<', $_strAddr); - // Do we have a "Real name" - if ( count($_tmpAry) == 2 ) - { - // We may not really have a "Real Name" - if ( $_tmpAry[0]) - $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); + // Do we have a "Real name" + if ( count($_tmpAry) == 2 ) + { + // We may not really have a "Real Name" + if ( $_tmpAry[0]) + $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); - $_aryEmail['addr'] = $_tmpAry[1]; - } - else - $_aryEmail['addr'] = $_tmpAry[0]; + $_aryEmail['addr'] = $_tmpAry[1]; + } + else + $_aryEmail['addr'] = $_tmpAry[0]; - // Pull User Name and Host.tld apart - list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']); + // Pull User Name and Host.tld apart + list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']); - // Put the brackets back around the address - $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>'; + // Put the brackets back around the address + $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>'; - return $_aryEmail; - } + return $_aryEmail; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Returns an array of bares addresses for use with 'RCPT TO:' - * This is a "build as you go" method. Each time this method is called - * the underlaying array is destroyed and reconstructed. - * - * @return array Returns an array of bares addresses - */ - function get_RCPT_list() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns an array of bares addresses for use with 'RCPT TO:' + * This is a "build as you go" method. Each time this method is called + * the underlaying array is destroyed and reconstructed. + * + * @return array Returns an array of bares addresses + */ + public function get_RCPT_list() + { // phpcs:enable - /** - * An array of bares addresses for use with 'RCPT TO:' - */ - $_RCPT_list=array(); + /** + * An array of bares addresses for use with 'RCPT TO:' + */ + $_RCPT_list=array(); - // walk down Recipients array and pull just email addresses - foreach ($this->_msgRecipients as $_host => $_list) - { - foreach ($_list as $_subList) - { - foreach ($_subList as $_name => $_addr) - { - // build RCPT list - $_RCPT_list[] = $_name . '@' . $_host; - } - } - } + // walk down Recipients array and pull just email addresses + foreach ($this->_msgRecipients as $_host => $_list) + { + foreach ($_list as $_subList) + { + foreach ($_subList as $_name => $_addr) + { + // build RCPT list + $_RCPT_list[] = $_name . '@' . $_host; + } + } + } - return $_RCPT_list; - } + return $_RCPT_list; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Returns an array of addresses for a specific type; TO, CC or BCC - * - * @param string $_which Which collection of addresses to return ('to', 'cc', 'bcc') - * @return string|false Array of emaill address - */ - function get_email_list($_which = null) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns an array of addresses for a specific type; TO, CC or BCC + * + * @param string $_which Which collection of addresses to return ('to', 'cc', 'bcc') + * @return string|false Array of emaill address + */ + public function get_email_list($_which = null) + { // phpcs:enable - // We need to know which address segment to pull - if ( $_which ) - { - // Make sure we have addresses to process - if ( $this->_msgRecipients ) - { - $_RCPT_list=array(); - // walk down Recipients array and pull just email addresses - foreach ($this->_msgRecipients as $_host => $_list) - { - if ( $this->_msgRecipients[$_host][$_which] ) - { - foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName) - { - if ( $_realName ) // @CHANGE LDR - { - $_realName = '"' . $_realName . '"'; - $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; - } - else - { - $_RCPT_list[] = $_addr . '@' . $_host; - } - } - } - } + // We need to know which address segment to pull + if ( $_which ) + { + // Make sure we have addresses to process + if ( $this->_msgRecipients ) + { + $_RCPT_list=array(); + // walk down Recipients array and pull just email addresses + foreach ($this->_msgRecipients as $_host => $_list) + { + if ( $this->_msgRecipients[$_host][$_which] ) + { + foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName) + { + if ( $_realName ) // @CHANGE LDR + { + $_realName = '"' . $_realName . '"'; + $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; + } + else + { + $_RCPT_list[] = $_addr . '@' . $_host; + } + } + } + } - return implode(', ', $_RCPT_list); - } - else - { - $this->_setErr(101, 'No eMail Address for message to be sent to.'); - return false; - } - } - else - { - $this->_setErr(102, 'eMail type not defined.'); - return false; - } - } + return implode(', ', $_RCPT_list); + } + else + { + $this->_setErr(101, 'No eMail Address for message to be sent to.'); + return false; + } + } + else + { + $this->_setErr(102, 'eMail type not defined.'); + return false; + } + } - /** - * TO Address[es] inwhich to send mail to - * - * @param string $_addrTo TO Address[es] inwhich to send mail to - * @return void - */ - function setTO($_addrTo) - { - if ( $_addrTo ) - $this->_buildAddrList('to', $_addrTo); - } + /** + * TO Address[es] inwhich to send mail to + * + * @param string $_addrTo TO Address[es] inwhich to send mail to + * @return void + */ + public function setTO($_addrTo) + { + if ( $_addrTo ) + $this->_buildAddrList('to', $_addrTo); + } - /** - * Retrieves the TO Address[es] inwhich to send mail to - * - * @return string TO Address[es] inwhich to send mail to - */ - function getTo() - { - return $this->get_email_list('to'); - } + /** + * Retrieves the TO Address[es] inwhich to send mail to + * + * @return string TO Address[es] inwhich to send mail to + */ + public function getTo() + { + return $this->get_email_list('to'); + } - /** - * CC Address[es] inwhich to send mail to - * - * @param string $_strCC CC Address[es] inwhich to send mail to - * @return void - */ - function setCC($_strCC) - { - if ( $_strCC ) - $this->_buildAddrList('cc', $_strCC); - } + /** + * CC Address[es] inwhich to send mail to + * + * @param string $_strCC CC Address[es] inwhich to send mail to + * @return void + */ + public function setCC($_strCC) + { + if ( $_strCC ) + $this->_buildAddrList('cc', $_strCC); + } - /** - * Retrieves the CC Address[es] inwhich to send mail to - * - * @return string CC Address[es] inwhich to send mail to - */ - function getCC() - { - return $this->get_email_list('cc'); - } + /** + * Retrieves the CC Address[es] inwhich to send mail to + * + * @return string CC Address[es] inwhich to send mail to + */ + public function getCC() + { + return $this->get_email_list('cc'); + } - /** - * BCC Address[es] inwhich to send mail to - * - * @param string $_strBCC Recipients BCC Address[es] inwhich to send mail to - * @return void - */ - function setBCC($_strBCC) - { - if ( $_strBCC ) - $this->_buildAddrList('bcc', $_strBCC); - } + /** + * BCC Address[es] inwhich to send mail to + * + * @param string $_strBCC Recipients BCC Address[es] inwhich to send mail to + * @return void + */ + public function setBCC($_strBCC) + { + if ( $_strBCC ) + $this->_buildAddrList('bcc', $_strBCC); + } - /** - * Retrieves the BCC Address[es] inwhich to send mail to - * - * @return string BCC Address[es] inwhich to send mail to - */ - function getBCC() - { - return $this->get_email_list('bcc'); - } + /** + * Retrieves the BCC Address[es] inwhich to send mail to + * + * @return string BCC Address[es] inwhich to send mail to + */ + public function getBCC() + { + return $this->get_email_list('bcc'); + } - /** - * Message Subject - * - * @param string $_strSubject Message Subject - * @return void - */ - function setSubject($_strSubject = '') - { - if ( $_strSubject ) - $this->_msgSubject = $_strSubject; - } + /** + * Message Subject + * + * @param string $_strSubject Message Subject + * @return void + */ + public function setSubject($_strSubject = '') + { + if ( $_strSubject ) + $this->_msgSubject = $_strSubject; + } - /** - * Retrieves the Message Subject - * - * @return string Message Subject - */ - function getSubject() - { - return $this->_msgSubject; - } + /** + * Retrieves the Message Subject + * + * @return string Message Subject + */ + public function getSubject() + { + return $this->_msgSubject; + } - /** - * Constructes and returns message header - * - * @return string Complete message header - */ - function getHeader() - { - global $conf; + /** + * Constructes and returns message header + * + * @return string Complete message header + */ + public function getHeader() + { + global $conf; - $_header = 'From: ' . $this->getFrom('org') . "\r\n" - . 'To: ' . $this->getTO() . "\r\n"; + $_header = 'From: ' . $this->getFrom('org') . "\r\n" + . 'To: ' . $this->getTO() . "\r\n"; - if ( $this->getCC() ) - $_header .= 'Cc: ' . $this->getCC() . "\r\n"; + if ( $this->getCC() ) + $_header .= 'Cc: ' . $this->getCC() . "\r\n"; - /* Note: - * BCC email addresses must be listed in the RCPT TO command list, - * but the BCC header should not be printed under the DATA command. - * So it is included into the function sendMsg() but not here. - * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server - */ - /* - if ( $this->getBCC() ) - $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; + /* Note: + * BCC email addresses must be listed in the RCPT TO command list, + * but the BCC header should not be printed under the DATA command. + * So it is included into the function sendMsg() but not here. + * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server + */ + /* + if ( $this->getBCC() ) + $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; */ - $host=$this->getHost(); - $usetls = preg_match('@tls://@i', $host); - - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix - - $host=dol_getprefix('email'); - - //NOTE: Message-ID should probably contain the username of the user who sent the msg - $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; - $_header .= 'Date: ' . date("r") . "\r\n"; - - $trackid = $this->getTrackId(); - if ($trackid) - { - // References is kept in response and Message-ID is returned into In-Reply-To: - $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; - $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; - $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n"; - } - else - { - $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; - } - if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; - if ( $this->getMoreInHeader() ) - $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; - - //$_header .= - // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" - // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; - - if ( $this->getSensitivity() ) - $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; - - if ( $this->_msgPriority != 3 ) - $_header .= $this->getPriority(); - - - // @CHANGE LDR - if ( $this->getDeliveryReceipt() ) - $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; - if ( $this->getErrorsTo() ) - $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; - if ( $this->getReplyTo() ) - $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; - - $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; - $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; - $_header .= 'Mime-Version: 1.0' . "\r\n"; - - - return $_header; - } - - /** - * Message Content - * - * @param string $strContent Message Content - * @param string $strType Type - * @return void - */ - function setBodyContent($strContent, $strType = 'plain') - { - //if ( $strContent ) - //{ - if ( $strType == 'html' ) - $strMimeType = 'text/html'; - else - $strMimeType = 'text/plain'; - - // Make RFC821 Compliant, replace bare linefeeds - $strContent = preg_replace("/(?]*>/", " ", $strContent); - $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); - $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n")); - } - - // Make RFC2045 Compliant - //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content - $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. - - $this->_msgContent[$strType] = array(); - - $this->_msgContent[$strType]['mimeType'] = $strMimeType; - $this->_msgContent[$strType]['data'] = $strContent; - $this->_msgContent[$strType]['dataText'] = $strContentAltText; - - if ( $this->getMD5flag() ) - $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); - //} - } - - /** - * Retrieves the Message Content - * - * @return string Message Content - */ - function getBodyContent() - { - global $conf; - - // Generate a new Boundary string - $this->_setBoundary(); - - // What type[s] of content do we have - $_types = array_keys($this->_msgContent); - - // How many content types do we have - $keyCount = count($_types); - - // If we have ZERO, we have a problem - if( $keyCount === 0 ) - die("Sorry, no content"); - - // If we have ONE, we can use the simple format - elseif( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) - { - $_msgData = $this->_msgContent; - $_msgData = $_msgData[$_types[0]]; - - $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n" - . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n" - . 'Content-Disposition: inline' . "\r\n" - . 'Content-Description: Message' . "\r\n"; - - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; - - $content .= "\r\n" - . $_msgData['data'] . "\r\n"; - } - - // If we have more than ONE, we use the multi-part format - elseif( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) - { - // Since this is an actual multi-part message - // We need to define a content message Boundary - // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this. - - //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n"; - $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n"; - - // . "\r\n" - // . 'This is a multi-part message in MIME format.' . "\r\n"; - $content .= "Content-Transfer-Encoding: 8bit\r\n"; - $content .= "\r\n"; - - $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; - - if (key_exists('image', $this->_msgContent)) // If inline image found - { - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; - $content .= "\r\n"; - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; - } - - - // $this->_msgContent must be sorted with key 'text' or 'html' first then 'image' then 'attachment' - - - // Loop through message content array - foreach ($this->_msgContent as $type => $_content) - { - if ( $type == 'attachment' ) - { - // loop through all attachments - foreach ($_content as $_file => $_data) - { - $content .= "--" . $this->_getBoundary('mixed') . "\r\n" - . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n" - . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n" - . 'Content-Transfer-Encoding: base64' . "\r\n" - . 'Content-Description: ' . $_data['fileName'] ."\r\n"; - - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; - - $content .= "\r\n" . $_data['data'] . "\r\n\r\n"; - } - } - // @CHANGE LDR - elseif ( $type == 'image' ) - { - // loop through all images - foreach ($_content as $_image => $_data) - { - $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image - - $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n" - . 'Content-Transfer-Encoding: base64' . "\r\n" - . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n" - . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n"; - - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; - - $content .= "\r\n" - . $_data['data'] . "\r\n"; - } - - // always end related and end alternative after inline images - $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; - $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; - $content.= "\r\n"; - } - else - { - if (key_exists('image', $this->_msgContent)) - { - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; - $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; - $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; - $content.= "\r\n"; - $content.= "--" . $this->_getBoundary('related') . "\r\n"; - } - - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part - { - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; - $content .= "\r\n"; - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; - - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; - $content.= "\r\n". $_content['dataText'] . "\r\n"; - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; - } - - $content .= 'Content-Type: ' . $_content['mimeType'] . '; ' - // . 'charset="' . $this->getCharSet() . '"'; - . 'charset=' . $this->getCharSet() . ''; - - // $content .= ( $type == 'html') ? '; name="HTML Part"' : ''; - $content .= "\r\n"; - // $content .= 'Content-Transfer-Encoding: '; - // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType(); - // $content .= "\r\n" - // . 'Content-Disposition: inline' . "\r\n" - // . 'Content-Description: ' . $type . ' message' . "\r\n"; - - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; - - $content .= "\r\n" . $_content['data'] . "\r\n"; - - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part - { - $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; - } - - $content .= "\r\n"; - } - } - - // Close message boundries - // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ; - $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ; - } - - return $content; - } - - /** - * File attachments are added to the content array as sub-arrays, - * allowing for multiple attachments for each outbound email - * - * @param string $strContent File data to attach to message - * @param string $strFileName File Name to give to attachment - * @param string $strMimeType File Mime Type of attachment - * @return void - */ - function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown') - { - if ( $strContent ) - { - $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 - - $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType; - $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName; - $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; - - if ( $this->getMD5flag() ) - $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); - } - } - - - // @CHANGE LDR - - /** - * Image attachments are added to the content array as sub-arrays, - * allowing for multiple images for each outbound email - * - * @param string $strContent Image data to attach to message - * @param string $strImageName Image Name to give to attachment - * @param string $strMimeType Image Mime Type of attachment - * @param string $strImageCid CID - * @return void - */ - function setImageInline($strContent, $strImageName = 'unknown', $strMimeType = 'unknown', $strImageCid = 'unknown') - { - if ($strContent) - { - $this->_msgContent['image'][$strImageName]['mimeType'] = $strMimeType; - $this->_msgContent['image'][$strImageName]['imageName'] = $strImageName; - $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid; - $this->_msgContent['image'][$strImageName]['data'] = $strContent; - - if ( $this->getMD5flag() ) - $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); - } - } - // END @CHANGE LDR - - - /** - * Message Content Sensitivity - * Message Sensitivity values: - * - [0] None - default - * - [1] Personal - * - [2] Private - * - [3] Company Confidential - * - * @param integer $_value Message Sensitivity - * @return void - */ - function setSensitivity($_value = 0) - { - if ( ( is_numeric($_value) ) && - ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) - $this->_msgSensitivity = $_value; - } - - /** - * Returns Message Content Sensitivity string - * Message Sensitivity values: - * - [0] None - default - * - [1] Personal - * - [2] Private - * - [3] Company Confidential - * - * @return void - */ - function getSensitivity() - { - return $this->_arySensitivity[$this->_msgSensitivity]; - } - - /** - * Message Content Priority - * Message Priority values: - * - [0] 'Bulk' - * - [1] 'Highest' - * - [2] 'High' - * - [3] 'Normal' - default - * - [4] 'Low' - * - [5] 'Lowest' - * - * @param integer $_value Message Priority - * @return void - */ - function setPriority($_value = 3) - { - if ( ( is_numeric($_value) ) && - ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) - $this->_msgPriority = $_value; - } - - /** - * Message Content Priority - * Message Priority values: - * - [0] 'Bulk' - * - [1] 'Highest' - * - [2] 'High' - * - [3] 'Normal' - default - * - [4] 'Low' - * - [5] 'Lowest' - * - * @return string - */ - function getPriority() - { - return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" - . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" - . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n"; - } - - /** - * Set flag which determines whether to calculate message MD5 checksum. - * - * @param string $_flag Message Priority - * @return void - */ - function setMD5flag($_flag = false) - { - $this->_smtpMD5 = $_flag; - } - - /** - * Gets flag which determines whether to calculate message MD5 checksum. - * - * @return boolean Message Priority - */ - function getMD5flag() - { - return $this->_smtpMD5; - } - - /** - * Message X-Header Content - * This is a simple "insert". Whatever is given will be placed - * "as is" into the Xheader array. - * - * @param string $strXdata Message X-Header Content - * @return void - */ - function setXheader($strXdata) - { - if ( $strXdata ) - $this->_msgXheader[] = $strXdata; - } - - /** - * Retrieves the Message X-Header Content - * - * @return string[] $_msgContent Message X-Header Content - */ - function getXheader() - { - return $this->_msgXheader; - } - - /** - * Generates Random string for MIME message Boundary - * - * @return void - */ - function _setBoundary() - { - $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; - $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); - $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); - } - - /** - * Retrieves the MIME message Boundary - * - * @param string $type Type of boundary - * @return string $_smtpsBoundary MIME message Boundary - */ - function _getBoundary($type = 'mixed') - { - if ($type == 'mixed') return $this->_smtpsBoundary; - elseif ($type == 'related') return $this->_smtpsRelatedBoundary; - elseif ($type == 'alternative') return $this->_smtpsAlternativeBoundary; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * This function has been modified as provided by SirSir to allow multiline responses when - * using SMTP Extensions - * - * @param Handler $socket Socket handler - * @param string $response Response. Example: "550 5.7.1 https://support.google.com/a/answer/6140680#invalidcred j21sm814390wre.3" - * @return boolean True or false - */ - function server_parse($socket, $response) - { + $host=$this->getHost(); + $usetls = preg_match('@tls://@i', $host); + + $host=preg_replace('@tcp://@i', '', $host); // Remove prefix + $host=preg_replace('@ssl://@i', '', $host); // Remove prefix + $host=preg_replace('@tls://@i', '', $host); // Remove prefix + + $host=dol_getprefix('email'); + + //NOTE: Message-ID should probably contain the username of the user who sent the msg + $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; + $_header .= 'Date: ' . date("r") . "\r\n"; + + $trackid = $this->getTrackId(); + if ($trackid) + { + // References is kept in response and Message-ID is returned into In-Reply-To: + $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; + $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; + $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n"; + } + else + { + $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; + } + if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; + if ( $this->getMoreInHeader() ) + $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; + + //$_header .= + // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" + // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; + + if ( $this->getSensitivity() ) + $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; + + if ( $this->_msgPriority != 3 ) + $_header .= $this->getPriority(); + + + // @CHANGE LDR + if ( $this->getDeliveryReceipt() ) + $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; + if ( $this->getErrorsTo() ) + $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; + if ( $this->getReplyTo() ) + $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; + + $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; + $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; + $_header .= 'Mime-Version: 1.0' . "\r\n"; + + + return $_header; + } + + /** + * Message Content + * + * @param string $strContent Message Content + * @param string $strType Type + * @return void + */ + public function setBodyContent($strContent, $strType = 'plain') + { + //if ( $strContent ) + //{ + if ( $strType == 'html' ) + $strMimeType = 'text/html'; + else + $strMimeType = 'text/plain'; + + // Make RFC821 Compliant, replace bare linefeeds + $strContent = preg_replace("/(?]*>/", " ", $strContent); + $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); + $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n")); + } + + // Make RFC2045 Compliant + //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content + $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. + + $this->_msgContent[$strType] = array(); + + $this->_msgContent[$strType]['mimeType'] = $strMimeType; + $this->_msgContent[$strType]['data'] = $strContent; + $this->_msgContent[$strType]['dataText'] = $strContentAltText; + + if ( $this->getMD5flag() ) + $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); + //} + } + + /** + * Retrieves the Message Content + * + * @return string Message Content + */ + public function getBodyContent() + { + global $conf; + + // Generate a new Boundary string + $this->_setBoundary(); + + // What type[s] of content do we have + $_types = array_keys($this->_msgContent); + + // How many content types do we have + $keyCount = count($_types); + + // If we have ZERO, we have a problem + if( $keyCount === 0 ) + die("Sorry, no content"); + + // If we have ONE, we can use the simple format + elseif( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) + { + $_msgData = $this->_msgContent; + $_msgData = $_msgData[$_types[0]]; + + $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n" + . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n" + . 'Content-Disposition: inline' . "\r\n" + . 'Content-Description: Message' . "\r\n"; + + if ( $this->getMD5flag() ) + $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; + + $content .= "\r\n" + . $_msgData['data'] . "\r\n"; + } + + // If we have more than ONE, we use the multi-part format + elseif( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) + { + // Since this is an actual multi-part message + // We need to define a content message Boundary + // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this. + + //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n"; + $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n"; + + // . "\r\n" + // . 'This is a multi-part message in MIME format.' . "\r\n"; + $content .= "Content-Transfer-Encoding: 8bit\r\n"; + $content .= "\r\n"; + + $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; + + if (key_exists('image', $this->_msgContent)) // If inline image found + { + $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; + $content .= "\r\n"; + $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; + } + + + // $this->_msgContent must be sorted with key 'text' or 'html' first then 'image' then 'attachment' + + + // Loop through message content array + foreach ($this->_msgContent as $type => $_content) + { + if ( $type == 'attachment' ) + { + // loop through all attachments + foreach ($_content as $_file => $_data) + { + $content .= "--" . $this->_getBoundary('mixed') . "\r\n" + . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n" + . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n" + . 'Content-Transfer-Encoding: base64' . "\r\n" + . 'Content-Description: ' . $_data['fileName'] ."\r\n"; + + if ( $this->getMD5flag() ) + $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; + + $content .= "\r\n" . $_data['data'] . "\r\n\r\n"; + } + } + // @CHANGE LDR + elseif ( $type == 'image' ) + { + // loop through all images + foreach ($_content as $_image => $_data) + { + $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image + + $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n" + . 'Content-Transfer-Encoding: base64' . "\r\n" + . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n" + . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n"; + + if ( $this->getMD5flag() ) + $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; + + $content .= "\r\n" + . $_data['data'] . "\r\n"; + } + + // always end related and end alternative after inline images + $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; + $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; + $content.= "\r\n"; + } + else + { + if (key_exists('image', $this->_msgContent)) + { + $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; + $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message + $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; + $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; + $content.= "\r\n"; + $content.= "--" . $this->_getBoundary('related') . "\r\n"; + } + + if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part + { + $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; + $content .= "\r\n"; + $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; + + $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; + $content.= "\r\n". $_content['dataText'] . "\r\n"; + $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; + } + + $content .= 'Content-Type: ' . $_content['mimeType'] . '; ' + // . 'charset="' . $this->getCharSet() . '"'; + . 'charset=' . $this->getCharSet() . ''; + + // $content .= ( $type == 'html') ? '; name="HTML Part"' : ''; + $content .= "\r\n"; + // $content .= 'Content-Transfer-Encoding: '; + // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType(); + // $content .= "\r\n" + // . 'Content-Disposition: inline' . "\r\n" + // . 'Content-Description: ' . $type . ' message' . "\r\n"; + + if ( $this->getMD5flag() ) + $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; + + $content .= "\r\n" . $_content['data'] . "\r\n"; + + if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part + { + $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; + } + + $content .= "\r\n"; + } + } + + // Close message boundries + // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ; + $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ; + } + + return $content; + } + + /** + * File attachments are added to the content array as sub-arrays, + * allowing for multiple attachments for each outbound email + * + * @param string $strContent File data to attach to message + * @param string $strFileName File Name to give to attachment + * @param string $strMimeType File Mime Type of attachment + * @return void + */ + public function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown') + { + if ( $strContent ) + { + $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 + + $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType; + $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName; + $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; + + if ( $this->getMD5flag() ) + $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); + } + } + + + // @CHANGE LDR + + /** + * Image attachments are added to the content array as sub-arrays, + * allowing for multiple images for each outbound email + * + * @param string $strContent Image data to attach to message + * @param string $strImageName Image Name to give to attachment + * @param string $strMimeType Image Mime Type of attachment + * @param string $strImageCid CID + * @return void + */ + public function setImageInline($strContent, $strImageName = 'unknown', $strMimeType = 'unknown', $strImageCid = 'unknown') + { + if ($strContent) + { + $this->_msgContent['image'][$strImageName]['mimeType'] = $strMimeType; + $this->_msgContent['image'][$strImageName]['imageName'] = $strImageName; + $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid; + $this->_msgContent['image'][$strImageName]['data'] = $strContent; + + if ( $this->getMD5flag() ) + $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); + } + } + // END @CHANGE LDR + + + /** + * Message Content Sensitivity + * Message Sensitivity values: + * - [0] None - default + * - [1] Personal + * - [2] Private + * - [3] Company Confidential + * + * @param integer $_value Message Sensitivity + * @return void + */ + public function setSensitivity($_value = 0) + { + if ( ( is_numeric($_value) ) && + ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) + $this->_msgSensitivity = $_value; + } + + /** + * Returns Message Content Sensitivity string + * Message Sensitivity values: + * - [0] None - default + * - [1] Personal + * - [2] Private + * - [3] Company Confidential + * + * @return void + */ + public function getSensitivity() + { + return $this->_arySensitivity[$this->_msgSensitivity]; + } + + /** + * Message Content Priority + * Message Priority values: + * - [0] 'Bulk' + * - [1] 'Highest' + * - [2] 'High' + * - [3] 'Normal' - default + * - [4] 'Low' + * - [5] 'Lowest' + * + * @param integer $_value Message Priority + * @return void + */ + public function setPriority($_value = 3) + { + if ( ( is_numeric($_value) ) && + ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) + $this->_msgPriority = $_value; + } + + /** + * Message Content Priority + * Message Priority values: + * - [0] 'Bulk' + * - [1] 'Highest' + * - [2] 'High' + * - [3] 'Normal' - default + * - [4] 'Low' + * - [5] 'Lowest' + * + * @return string + */ + public function getPriority() + { + return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" + . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" + . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n"; + } + + /** + * Set flag which determines whether to calculate message MD5 checksum. + * + * @param string $_flag Message Priority + * @return void + */ + public function setMD5flag($_flag = false) + { + $this->_smtpMD5 = $_flag; + } + + /** + * Gets flag which determines whether to calculate message MD5 checksum. + * + * @return boolean Message Priority + */ + public function getMD5flag() + { + return $this->_smtpMD5; + } + + /** + * Message X-Header Content + * This is a simple "insert". Whatever is given will be placed + * "as is" into the Xheader array. + * + * @param string $strXdata Message X-Header Content + * @return void + */ + public function setXheader($strXdata) + { + if ( $strXdata ) + $this->_msgXheader[] = $strXdata; + } + + /** + * Retrieves the Message X-Header Content + * + * @return string[] $_msgContent Message X-Header Content + */ + public function getXheader() + { + return $this->_msgXheader; + } + + /** + * Generates Random string for MIME message Boundary + * + * @return void + */ + private function _setBoundary() + { + $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; + $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); + $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); + } + + /** + * Retrieves the MIME message Boundary + * + * @param string $type Type of boundary + * @return string $_smtpsBoundary MIME message Boundary + */ + private function _getBoundary($type = 'mixed') + { + if ($type == 'mixed') return $this->_smtpsBoundary; + elseif ($type == 'related') return $this->_smtpsRelatedBoundary; + elseif ($type == 'alternative') return $this->_smtpsAlternativeBoundary; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * This function has been modified as provided by SirSir to allow multiline responses when + * using SMTP Extensions + * + * @param Handler $socket Socket handler + * @param string $response Response. Example: "550 5.7.1 https://support.google.com/a/answer/6140680#invalidcred j21sm814390wre.3" + * @return boolean True or false + */ + public function server_parse($socket, $response) + { // phpcs:enable - /** - * Returns constructed SELECT Object string or boolean upon failure - * Default value is set at true - */ - $_retVal = true; + /** + * Returns constructed SELECT Object string or boolean upon failure + * Default value is set at true + */ + $_retVal = true; - $server_response = ''; + $server_response = ''; // avoid infinite loop $limit=0; - while (substr($server_response, 3, 1) != ' ' && $limit<100) - { - if (! ($server_response = fgets($socket, 256))) - { - $this->_setErr(121, "Couldn't get mail server response codes"); - $_retVal = false; - break; - } + while (substr($server_response, 3, 1) != ' ' && $limit<100) + { + if (! ($server_response = fgets($socket, 256))) + { + $this->_setErr(121, "Couldn't get mail server response codes"); + $_retVal = false; + break; + } $limit++; - } + } - if (! (substr($server_response, 0, 3) == $response)) - { - $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response"); - $_retVal = false; - } + if (! (substr($server_response, 0, 3) == $response)) + { + $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response"); + $_retVal = false; + } - return $_retVal; - } + return $_retVal; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Send str - * - * @param string $_strSend String to send - * @param string $_returnCode Return code - * @param string $CRLF CRLF - * @return boolean|null True or false - */ - function socket_send_str($_strSend, $_returnCode = null, $CRLF = "\r\n") - { - // phpcs:enable - if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log - fputs($this->socket, $_strSend . $CRLF); - if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF; - - if ( $_returnCode ) - return $this->server_parse($this->socket, $_returnCode); - } - - // ============================================================= - // ** Error handling methods - - /** - * Defines errors codes and messages for Class - * - * @param int $_errNum Error Code Number - * @param string $_errMsg Error Message - * @return void + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Send str + * + * @param string $_strSend String to send + * @param string $_returnCode Return code + * @param string $CRLF CRLF + * @return boolean|null True or false */ - function _setErr($_errNum, $_errMsg) + public function socket_send_str($_strSend, $_returnCode = null, $CRLF = "\r\n") + { + // phpcs:enable + if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log + fputs($this->socket, $_strSend . $CRLF); + if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF; + + if ( $_returnCode ) + return $this->server_parse($this->socket, $_returnCode); + } + + // ============================================================= + // ** Error handling methods + + /** + * Defines errors codes and messages for Class + * + * @param int $_errNum Error Code Number + * @param string $_errMsg Error Message + * @return void + */ + private function _setErr($_errNum, $_errMsg) { $this->_smtpsErrors[] = array( 'num' => $_errNum, @@ -1835,25 +1835,25 @@ class SMTPs ); } - /** - * Returns errors codes and messages for Class - * - * @return string $_errMsg Error Message - */ - function getErrors() - { - $_errMsg = array(); + /** + * Returns errors codes and messages for Class + * + * @return string $_errMsg Error Message + */ + public function getErrors() + { + $_errMsg = array(); - if (is_array($this->_smtpsErrors)) - { - foreach ($this->_smtpsErrors as $_err => $_info) - { - $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg']; - } - } + if (is_array($this->_smtpsErrors)) + { + foreach ($this->_smtpsErrors as $_err => $_info) + { + $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg']; + } + } - return implode("\n", $_errMsg); - } + return implode("\n", $_errMsg); + } } diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index bbdebab81b0..b35e9947644 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -42,7 +42,7 @@ abstract class 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 values */ - function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) + public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) { global $conf,$user,$langs; @@ -136,7 +136,7 @@ abstract class 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 values */ - function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) + public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) { global $conf,$user,$langs; @@ -228,8 +228,8 @@ abstract class Stats * @param int $startyear End year * @return array Array of values */ - function getAverageByMonthWithPrevYear($endyear, $startyear) - { + public function getAverageByMonthWithPrevYear($endyear, $startyear) + { if ($startyear > $endyear) return -1; $datay=array(); @@ -264,9 +264,9 @@ abstract class Stats * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @return array Array of values */ - function getAllByProductEntry($year, $cachedelay = 0) - { - global $conf,$user,$langs; + public function getAllByProductEntry($year, $cachedelay = 0) + { + global $conf,$user,$langs; $datay=array(); @@ -333,14 +333,16 @@ abstract class Stats // Here we have low level of shared code called by XxxStats.class.php - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** * Return nb of elements by year * * @param string $sql SQL request * @return array */ - function _getNbByYear($sql) - { + protected function _getNbByYear($sql) + { + // phpcs:enable $result = array(); dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); @@ -363,14 +365,16 @@ abstract class Stats return $result; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Return nb of elements, total amount and avg amount each year * * @param string $sql SQL request * @return array Array with nb, total amount, average for each year */ - function _getAllByYear($sql) + protected function _getAllByYear($sql) { + // phpcs:enable $result = array(); dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); @@ -405,6 +409,7 @@ abstract class Stats return $result; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Renvoie le nombre de proposition par mois pour une annee donnee * @@ -412,9 +417,10 @@ abstract class Stats * @param string $sql SQL * @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, $sql, $format = 0) - { + */ + protected function _getNbByMonth($year, $sql, $format = 0) + { + // phpcs:enable global $langs; $result=array(); @@ -462,6 +468,7 @@ abstract class Stats } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Renvoie le nombre d'element par mois pour une annee donnee * @@ -470,8 +477,9 @@ abstract class 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 */ - function _getAmountByMonth($year, $sql, $format = 0) - { + protected function _getAmountByMonth($year, $sql, $format = 0) + { + // phpcs:enable global $langs; $result=array(); @@ -514,18 +522,20 @@ abstract class Stats } return $data; - } + } - /** - * Renvoie le montant moyen par mois pour une annee donnee - * - * @param int $year Year - * @param string $sql SQL - * @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 - */ - function _getAverageByMonth($year, $sql, $format = 0) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Renvoie le montant moyen par mois pour une annee donnee + * + * @param int $year Year + * @param string $sql SQL + * @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 + */ + protected function _getAverageByMonth($year, $sql, $format = 0) + { + // phpcs:enable global $langs; $result=array(); @@ -567,18 +577,20 @@ abstract class Stats } return $data; - } + } - /** - * Return number or total of product refs - * - * @param string $sql SQL - * @param int $limit Limit - * @return array - */ - function _getAllByProduct($sql, $limit = 10) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Return number or total of product refs + * + * @param string $sql SQL + * @param int $limit Limit + * @return array + */ + protected function _getAllByProduct($sql, $limit = 10) + { + // phpcs:enable global $langs; $result=array(); @@ -592,16 +604,16 @@ abstract class Stats $i = 0; $other=0; while ($i < $num) { - $row = $this->db->fetch_row($resql); + $row = $this->db->fetch_row($resql); if ($i < $limit || $num == $limit) $result[$i] = array($row[0],$row[1]); // Ref of product, nb else $other += $row[1]; $i++; - } + } if ($num > $limit) $result[$i] = array($langs->transnoentitiesnoconv("Other"),$other); $this->db->free($resql); } else dol_print_error($this->db); return $result; - } + } } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index bc104bb2b79..e0865a640e4 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -48,7 +48,7 @@ class Translate * @param string $dir Force directory that contains /langs subdirectory (value is sometimes '..' like into install/* pages or support/* pages). Use '' by default. * @param Conf $conf Object with Dolibarr configuration */ - function __construct($dir, $conf) + public function __construct($dir, $conf) { if (! empty($conf->file->character_set_client)) $this->charset_output=$conf->file->character_set_client; // If charset output is forced if ($dir) $this->dir=array($dir); @@ -62,7 +62,7 @@ class Translate * @param string $srclang Language to use. If '' or 'auto', we use browser lang. * @return void */ - function setDefaultLang($srclang = 'en_US') + public function setDefaultLang($srclang = 'en_US') { global $conf; @@ -132,7 +132,7 @@ class Translate * @param int $mode 0=Long language code, 1=Short language code (en, fr, es, ...) * @return string Language code used (en_US, en_AU, fr_FR, ...) */ - function getDefaultLang($mode = 0) + public function getDefaultLang($mode = 0) { if (empty($mode)) return $this->defaultlang; else return substr($this->defaultlang, 0, 2); @@ -145,7 +145,7 @@ class Translate * @param array $domains Array of lang files to load * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK */ - function loadLangs($domains) + public function loadLangs($domains) { foreach($domains as $domain) { @@ -173,7 +173,7 @@ class Translate * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK * @see loadLangs */ - function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0) + public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0) { global $conf,$db; @@ -399,7 +399,7 @@ class Translate * @param Database $db Database handler * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK */ - function loadFromDatabase($db) + public function loadFromDatabase($db) { global $conf; @@ -537,8 +537,8 @@ class Translate * @param string $key Key to translate * @return string Translated string (translated with transnoentitiesnoconv) */ - private function getTradFromKey($key) - { + private function getTradFromKey($key) + { global $conf, $db; if (! is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly. @@ -577,7 +577,7 @@ class Translate }*/ return $newstr; - } + } /** @@ -593,9 +593,9 @@ class Translate * @param string $param4 chaine de param4 * @param int $maxsize Max length of text * @return string Translated string (encoded into HTML entities and UTF8) - */ - function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $maxsize = 0) - { + */ + public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $maxsize = 0) + { global $conf; if (! empty($this->tab_translate[$key])) // Translation is available @@ -638,7 +638,7 @@ class Translate //if ($key[0] == '$') { return dol_eval($key,1); } return $this->getTradFromKey($key); } - } + } /** @@ -655,7 +655,7 @@ class Translate * @param string $param5 chaine de param5 * @return string Translated string (encoded into UTF8) */ - function transnoentities($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $param5 = '') + public function transnoentities($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $param5 = '') { return $this->convToOutputCharset($this->transnoentitiesnoconv($key, $param1, $param2, $param3, $param4, $param5)); } @@ -676,7 +676,7 @@ class Translate * @param string $param5 chaine de param5 * @return string Translated string */ - function transnoentitiesnoconv($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $param5 = '') + public function transnoentitiesnoconv($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $param5 = '') { global $conf; @@ -719,7 +719,7 @@ class Translate * @param string $countrycode country code (FR, ...) * @return string translated string */ - function transcountry($str, $countrycode) + public function transcountry($str, $countrycode) { if ($this->tab_translate["$str$countrycode"]) return $this->trans("$str$countrycode"); else return $this->trans($str); @@ -733,7 +733,7 @@ class Translate * @param string $countrycode country code (FR, ...) * @return string translated string */ - function transcountrynoentities($str, $countrycode) + public function transcountrynoentities($str, $countrycode) { if ($this->tab_translate["$str$countrycode"]) return $this->transnoentities("$str$countrycode"); else return $this->transnoentities($str); @@ -747,7 +747,7 @@ class Translate * @param string $pagecodefrom Page code of src string * @return string Converted string */ - function convToOutputCharset($str, $pagecodefrom = 'UTF-8') + public function convToOutputCharset($str, $pagecodefrom = 'UTF-8') { if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str=utf8_encode($str); if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str=utf8_decode(str_replace('€', chr(128), $str)); @@ -755,7 +755,7 @@ class Translate } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of all available languages * @@ -764,8 +764,8 @@ class Translate * @param int $usecode 1=Show code instead of country name for language variant, 2=Show only code * @return array List of languages */ - function get_available_languages($langdir = DOL_DOCUMENT_ROOT, $maxlength = 0, $usecode = 0) - { + public function get_available_languages($langdir = DOL_DOCUMENT_ROOT, $maxlength = 0, $usecode = 0) + { // phpcs:enable global $conf; @@ -793,10 +793,10 @@ class Translate } } return $langs_available; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if a filename $filename exists for current language (or alternate language) * @@ -804,8 +804,8 @@ class Translate * @param integer $searchalt Search also alernate language file * @return boolean true if exists and readable */ - function file_exists($filename, $searchalt = 0) - { + public function file_exists($filename, $searchalt = 0) + { // phpcs:enable // Test si fichier dans repertoire de la langue foreach($this->dir as $searchdir) @@ -822,7 +822,7 @@ class Translate } return false; - } + } /** @@ -836,8 +836,8 @@ class Translate * 10 if setDefaultLang was en_US => ten * 123 if setDefaultLang was fr_FR => cent vingt trois */ - function getLabelFromNumber($number, $isamount = 0) - { + public function getLabelFromNumber($number, $isamount = 0) + { global $conf; $newnumber=$number; @@ -861,7 +861,7 @@ class Translate } return $newnumber; - } + } /** @@ -879,8 +879,8 @@ class Translate * @return string Label in UTF8 (but without entities) * @see dol_getIdFromCode */ - function getLabelFromKey($db, $key, $tablename, $fieldkey, $fieldlabel, $keyforselect = '', $filteronentity = 0) - { + public function getLabelFromKey($db, $key, $tablename, $fieldkey, $fieldlabel, $keyforselect = '', $filteronentity = 0) + { // If key empty if ($key == '') return ''; @@ -919,7 +919,7 @@ class Translate $this->error=$db->lasterror(); return -1; } - } + } /** @@ -931,7 +931,7 @@ class Translate * @deprecated Use method price to output a price * @see price() */ - function getCurrencyAmount($currency_code, $amount) + public function getCurrencyAmount($currency_code, $amount) { $symbol=$this->getCurrencySymbol($currency_code); @@ -947,8 +947,8 @@ class Translate * @param integer $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency. * @return string Currency symbol encoded into UTF8 */ - function getCurrencySymbol($currency_code, $forceloadall = 0) - { + public function getCurrencySymbol($currency_code, $forceloadall = 0) + { $currency_sign = ''; // By default return iso code if (function_exists("mb_convert_encoding")) @@ -965,7 +965,7 @@ class Translate } return ($currency_sign?$currency_sign:$currency_code); - } + } /** * Load into the cache this->cache_currencies, all currencies @@ -1021,23 +1021,23 @@ class Translate } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return an array with content of all loaded translation keys (found into this->tab_translate) so * we get a substitution array we can use for substitutions (for mail or ODT generation for example) * * @return array Array of translation keys lang_key => string_translation_loaded */ - function get_translations_for_substitutions() - { + public function get_translations_for_substitutions() + { // phpcs:enable - $substitutionarray = array(); + $substitutionarray = array(); - foreach($this->tab_translate as $code => $label) { - $substitutionarray['lang_'.$code] = $label; - $substitutionarray['__('.$code.')__'] = $label; - } + foreach($this->tab_translate as $code => $label) { + $substitutionarray['lang_'.$code] = $label; + $substitutionarray['__('.$code.')__'] = $label; + } - return $substitutionarray; - } + return $substitutionarray; + } } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 6cacf353ca1..a5a3bd8aca9 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -32,15 +32,15 @@ class Utils */ public $db; - var $output; // Used by Cron method to return message - var $result; // Used by Cron method to return data + public $output; // Used by Cron method to return message + public $result; // Used by Cron method to return data /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -53,7 +53,7 @@ class Utils * @param string $choice Choice of purge mode ('tempfiles', '' or 'tempfilesold' to purge temp older than 24h, 'allfiles', 'logfile') * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function purgeFiles($choice = 'tempfilesold') + public function purgeFiles($choice = 'tempfilesold') { global $conf, $langs, $dolibarr_main_data_root; @@ -182,7 +182,7 @@ class Utils * @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0) + public function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0) { global $db, $conf, $langs, $dolibarr_main_data_root; global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass; @@ -501,7 +501,7 @@ class Utils * @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method * @return array array('result'=>...,'output'=>...,'error'=>...). result = 0 means OK. */ - function executeCLI($command, $outputfile, $execmethod = 0) + public function executeCLI($command, $outputfile, $execmethod = 0) { global $conf, $langs; @@ -570,7 +570,7 @@ class Utils * @param string $module Module name * @return int <0 if KO, >0 if OK */ - function generateDoc($module) + public function generateDoc($module) { global $conf, $langs; global $dirins; @@ -737,7 +737,7 @@ class Utils * * @return int 0 if OK, < 0 if KO */ - function compressSyslogs() + public function compressSyslogs() { global $conf; @@ -843,7 +843,7 @@ class Utils $this->output = 'Archive log files (keeping last SYSLOG_FILE_SAVES='.$nbSaves.' files) done.'; return 0; - } + } /** Backup the db OR just a table without mysqldump binary, with PHP only (does not require any exec permission) * Author: David Walsh (http://davidwalsh.name/backup-mysql-database-php) @@ -855,7 +855,7 @@ class Utils * @param string $tables Table name or '*' for all * @return int <0 if KO, >0 if OK */ - function backupTables($outputfile, $tables = '*') + public function backupTables($outputfile, $tables = '*') { global $db, $langs; global $errormsg; diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index cf19b43145d..fc240a88dcc 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -84,21 +84,21 @@ function dol_quoted_printable_encode($input, $line_max = 76) */ class vCard { - var $properties; - var $filename; + public $properties; + public $filename; //var $encoding="UTF-8"; - var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; + public $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; /** - * mise en forme du numero de telephone + * mise en forme du numero de telephone * - * @param int $number numero de telephone - * @param string $type Type - * @return void + * @param int $number numero de telephone + * @param string $type Type + * @return void */ - function setPhoneNumber($number, $type = "") + public function setPhoneNumber($number, $type = "") { // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE" $key = "TEL"; @@ -115,7 +115,7 @@ class vCard * @param string $photo Photo * @return void */ - function setPhoto($type, $photo) + public function setPhoto($type, $photo) { // $type = "GIF" | "JPEG" $this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo); @@ -127,7 +127,7 @@ class vCard * @param string $name Name * @return void */ - function setFormattedName($name) + public function setFormattedName($name) { $this->properties["FN;CHARSET=".$this->encoding] = encode($name); } @@ -142,7 +142,7 @@ class vCard * @param string $suffix Suffix * @return void */ - function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "") + public function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "") { $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); $this->filename = "$first%20$family.vcf"; @@ -155,7 +155,7 @@ class vCard * @param timestamp $date Date * @return void */ - function setBirthday($date) + public function setBirthday($date) { // $date format is YYYY-MM-DD - RFC 2425 and RFC 2426 $this->properties["BDAY"] = dol_print_date($date, 'dayrfc'); @@ -174,7 +174,7 @@ class vCard * @param string $type Type * @return void */ - function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") { // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" $key = "ADR"; @@ -189,19 +189,19 @@ class vCard } /** - * mise en forme du label + * mise en forme du label * - * @param string $postoffice Postoffice - * @param string $extended Extended - * @param string $street Street - * @param string $city City - * @param string $region Region - * @param string $zip Zip - * @param string $country Country - * @param string $type Type - * @return void + * @param string $postoffice Postoffice + * @param string $extended Extended + * @param string $street Street + * @param string $city City + * @param string $region Region + * @param string $zip Zip + * @param string $country Country + * @param string $type Type + * @return void */ - function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") { $label = ""; if ($postoffice!="") $label.= "$postoffice\r\n"; @@ -222,7 +222,7 @@ class vCard * @param string $type Vcard type * @return void */ - function setEmail($address, $type = "internet,pref") + public function setEmail($address, $type = "internet,pref") { $this->properties["EMAIL;TYPE=".$type] = $address; } @@ -233,7 +233,7 @@ class vCard * @param string $note Note * @return void */ - function setNote($note) + public function setNote($note) { $this->properties["NOTE;CHARSET=".$this->encoding] = encode($note); } @@ -244,19 +244,19 @@ class vCard * @param string $title Title * @return void */ - function setTitle($title) + public function setTitle($title) { $this->properties["TITLE;CHARSET=".$this->encoding] = encode($title); } /** - * mise en forme de la societe + * mise en forme de la societe * - * @param string $org Org - * @return void + * @param string $org Org + * @return void */ - function setOrg($org) + public function setOrg($org) { $this->properties["ORG;CHARSET=".$this->encoding] = encode($org); } @@ -268,7 +268,7 @@ class vCard * @param string $prodid Prodid * @return void */ - function setProdId($prodid) + public function setProdId($prodid) { $this->properties["PRODID;CHARSET=".$this->encoding] = encode($prodid); } @@ -280,7 +280,7 @@ class vCard * @param string $uid Uid * @return void */ - function setUID($uid) + public function setUID($uid) { $this->properties["UID;CHARSET=".$this->encoding] = encode($uid); } @@ -293,7 +293,7 @@ class vCard * @param string $type Type * @return void */ - function setURL($url, $type = "") + public function setURL($url, $type = "") { // $type may be WORK | HOME $key = "URL"; @@ -306,7 +306,7 @@ class vCard * * @return string */ - function getVCard() + public function getVCard() { $text = "BEGIN:VCARD\r\n"; $text.= "VERSION:3.0\r\n"; @@ -326,7 +326,7 @@ class vCard * * @return string Filename */ - function getFileName() + public function getFileName() { return $this->filename; } diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index e62692b233a..75a6fa14ec1 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -33,16 +33,16 @@ interface Database * @param string $resko resultat si test non egal * @return string SQL string */ - function ifsql($test, $resok, $resko); + public function ifsql($test, $resok, $resko); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return array Array */ - function fetch_row($resultset); + public function fetch_row($resultset); // phpcs:enable /** @@ -52,23 +52,23 @@ interface Database * @param int $param Date TMS to convert * @return string Date in a string YYYYMMDDHHMMSS */ - function idate($param); + public function idate($param); /** * Return last error code * * @return string lasterrno */ - function lasterrno(); + public function lasterrno(); /** * Start transaction * * @return int 1 if transaction successfuly opened or already opened, 0 if error */ - function begin(); + public function begin(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -80,7 +80,7 @@ interface Database * @param string $owner Username of database owner * @return resource resource defined if OK, null if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = ''); + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = ''); // phpcs:enable /** @@ -88,7 +88,7 @@ interface Database * * @return array Version array */ - function getVersionArray(); + public function getVersionArray(); /** * Convert a SQL request in Mysql syntax to native syntax @@ -97,9 +97,9 @@ interface Database * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'ddl'); + public static function convertSQLFromMysql($line, $type = 'ddl'); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * @@ -107,7 +107,7 @@ interface Database * @return int Nombre de lignes * @see num_rows */ - function affected_rows($resultset); + public function affected_rows($resultset); // phpcs:enable /** @@ -115,9 +115,9 @@ interface Database * * @return string Error text */ - function error(); + public function error(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -125,7 +125,7 @@ interface Database * @param string $table Nmae of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = ''); + public function DDLListTables($database, $table = ''); // phpcs:enable /** @@ -133,7 +133,7 @@ interface Database * * @return string Last query */ - function lastquery(); + public function lastquery(); /** * Define sort criteria of request @@ -142,7 +142,7 @@ interface Database * @param string $sortorder Sort order * @return string String to provide syntax of a sort sql string */ - function order($sortfield = null, $sortorder = null); + public function order($sortfield = null, $sortorder = null); /** * Decrypt sensitive data in database @@ -150,16 +150,16 @@ interface Database * @param string $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value); + public function decrypt($value); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return array Array */ - function fetch_array($resultset); + public function fetch_array($resultset); // phpcs:enable /** @@ -167,7 +167,7 @@ interface Database * * @return string lasterror */ - function lasterror(); + public function lasterror(); /** * Escape a string to insert data @@ -175,9 +175,9 @@ interface Database * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode); + public function escape($stringtoencode); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -185,7 +185,7 @@ interface Database * @param string $fieldid Field name * @return int Id of row */ - function last_insert_id($tab, $fieldid = 'rowid'); + public function last_insert_id($tab, $fieldid = 'rowid'); // phpcs:enable /** @@ -193,7 +193,7 @@ interface Database * * @return string Full path of restore program */ - function getPathOfRestore(); + public function getPathOfRestore(); /** * Annulation d'une transaction et retour aux anciennes valeurs @@ -201,7 +201,7 @@ interface Database * @param string $log Add more log to default log line * @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur */ - function rollback($log = ''); + public function rollback($log = ''); /** * Execute a SQL request and return the resultset @@ -212,7 +212,7 @@ interface Database * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return resource Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto'); + public function query($query, $usesavepoint = 0, $type = 'auto'); /** * Connexion to server @@ -225,7 +225,7 @@ interface Database * @return resource Database access handler * @see close */ - function connect($host, $login, $passwd, $name, $port = 0); + public function connect($host, $login, $passwd, $name, $port = 0); /** * Define limits and offset of request @@ -234,7 +234,7 @@ interface Database * @param int $offset Numero of line from where starting fetch * @return string String with SQL syntax to add a limit and offset */ - function plimit($limit = 0, $offset = 0); + public function plimit($limit = 0, $offset = 0); /** * Return value of server parameters @@ -242,7 +242,7 @@ interface Database * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = ''); + public function getServerParametersValues($filter = ''); /** * Return value of server status @@ -250,16 +250,16 @@ interface Database * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = ''); + public function getServerStatusValues($filter = ''); /** * Return collation used in database * * @return string Collation value */ - function getDefaultCollationDatabase(); + public function getDefaultCollationDatabase(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -267,7 +267,7 @@ interface Database * @return int Nb of lines * @see affected_rows */ - function num_rows($resultset); + public function num_rows($resultset); // phpcs:enable /** @@ -275,23 +275,23 @@ interface Database * * @return string Full path of dump program */ - function getPathOfDump(); + public function getPathOfDump(); /** * Return version of database client driver * * @return string Version string */ - function getDriverInfo(); + public function getDriverInfo(); /** * Return generic error code of last operation. * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno(); + public function errno(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -304,17 +304,17 @@ interface Database * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null); + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table); + public function DDLDropTable($table); // phpcs:enable /** @@ -322,9 +322,9 @@ interface Database * * @return array List of Charset */ - function getListOfCharacterSet(); + public function getListOfCharacterSet(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -334,10 +334,10 @@ interface Database * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = ""); + public function DDLAddField($table, $field_name, $field_desc, $field_position = ""); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -345,10 +345,10 @@ interface Database * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name); + public function DDLDropField($table, $field_name); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -357,7 +357,7 @@ interface Database * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc); + public function DDLUpdateField($table, $field_name, $field_desc); // phpcs:enable /** @@ -365,9 +365,9 @@ interface Database * * @return array List of Collation */ - function getListOfCollation(); + public function getListOfCollation(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -375,7 +375,7 @@ interface Database * @param string $field Optionnel : Name of field if we want description of field * @return resource Resource */ - function DDLDescTable($table, $field = ""); + public function DDLDescTable($table, $field = ""); // phpcs:enable /** @@ -383,16 +383,16 @@ interface Database * * @return string Version string */ - function getVersion(); + public function getVersion(); /** * Return charset used to store data in database * * @return string Charset */ - function getDefaultCharacterSetDatabase(); + public function getDefaultCharacterSetDatabase(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user and privileges to connect to database (even if database does not exists yet) * @@ -400,13 +400,13 @@ interface Database * @param string $dolibarr_main_db_user Nom user a creer * @param string $dolibarr_main_db_pass Mot de passe user a creer * @param string $dolibarr_main_db_name Database name where user must be granted - * @return int <0 if KO, >=0 if OK - */ - function DDLCreateUser( - $dolibarr_main_db_host, - $dolibarr_main_db_user, - $dolibarr_main_db_pass, - $dolibarr_main_db_name + * @return int <0 if KO, >=0 if OK + */ + public function DDLCreateUser( + $dolibarr_main_db_host, + $dolibarr_main_db_user, + $dolibarr_main_db_pass, + $dolibarr_main_db_name ); // phpcs:enable @@ -419,7 +419,7 @@ interface Database * @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ * @return int|string Date TMS or '' */ - function jdate($string, $gm = false); + public function jdate($string, $gm = false); /** * Encrypt sensitive data in database @@ -429,7 +429,7 @@ interface Database * @param int $withQuotes Return string with quotes * @return string XXX(field) or XXX('value') or field or 'value' */ - function encrypt($fieldorvalue, $withQuotes = 0); + public function encrypt($fieldorvalue, $withQuotes = 0); /** * Validate a database transaction @@ -437,25 +437,25 @@ interface Database * @param string $log Add more log to default log line * @return int 1 if validation is OK or transaction level no started, 0 if ERROR */ - function commit($log = ''); + public function commit($log = ''); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * * @param string $table Name of table - * @return array Array with inforation on table - */ - function DDLInfoTable($table); + * @return array Array with inforation on table + */ + public function DDLInfoTable($table); // phpcs:enable - /** + /** * Free last resultset used. * * @param resource $resultset Fre cursor * @return void */ - function free($resultset = null); + public function free($resultset = null); /** * Close database connexion @@ -463,41 +463,41 @@ interface Database * @return boolean True if disconnect successfull, false otherwise * @see connect */ - function close(); + public function close(); /** * Return last query in error * * @return string lastqueryerror */ - function lastqueryerror(); + public function lastqueryerror(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId(); + public function DDLGetConnectId(); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param resource $resultset Curseur de la requete voulue * @return Object Object result line or false if KO or end of cursor */ - function fetch_object($resultset); + public function fetch_object($resultset); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * * @param string $database Name of database * @return boolean true if OK, false if KO */ - function select_db($database); + public function select_db($database); // phpcs:enable } diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index ae61e35489d..575cf2256ef 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -75,7 +75,7 @@ abstract class DoliDB implements Database * @param string $resko resultat si test non egal * @return string SQL string */ - function ifsql($test, $resok, $resko) + public function ifsql($test, $resok, $resko) { return 'IF('.$test.','.$resok.','.$resko.')'; } @@ -87,7 +87,7 @@ abstract class DoliDB implements Database * @param int $param Date TMS to convert * @return string Date in a string YYYY-MM-DD HH:MM:SS */ - function idate($param) + public function idate($param) { // TODO GMT $param should be gmt, so we should add tzouptut to 'gmt' return dol_print_date($param, "%Y-%m-%d %H:%M:%S"); @@ -98,7 +98,7 @@ abstract class DoliDB implements Database * * @return string lasterrno */ - function lasterrno() + public function lasterrno() { return $this->lasterrno; } @@ -108,7 +108,7 @@ abstract class DoliDB implements Database * * @return int 1 if transaction successfuly opened or already opened, 0 if error */ - function begin() + public function begin() { if (! $this->transaction_opened) { @@ -135,7 +135,7 @@ abstract class DoliDB implements Database * @param string $log Add more log to default log line * @return int 1 if validation is OK or transaction level no started, 0 if ERROR */ - function commit($log = '') + public function commit($log = '') { dol_syslog('', 0, -1); if ($this->transaction_opened<=1) @@ -165,7 +165,7 @@ abstract class DoliDB implements Database * @param string $log Add more log to default log line * @return resource|int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur */ - function rollback($log = '') + public function rollback($log = '') { dol_syslog('', 0, -1); if ($this->transaction_opened<=1) @@ -189,7 +189,7 @@ abstract class DoliDB implements Database * @param int $offset Numero of line from where starting fetch * @return string String with SQL syntax to add a limit and offset */ - function plimit($limit = 0, $offset = 0) + public function plimit($limit = 0, $offset = 0) { global $conf; if (empty($limit)) return ""; @@ -203,7 +203,7 @@ abstract class DoliDB implements Database * * @return array Version array */ - function getVersionArray() + public function getVersionArray() { return preg_split("/[\.,-]/", $this->getVersion()); } @@ -213,7 +213,7 @@ abstract class DoliDB implements Database * * @return string Last query */ - function lastquery() + public function lastquery() { return $this->lastquery; } @@ -225,7 +225,7 @@ abstract class DoliDB implements Database * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'; * @return string String to provide syntax of a sort sql string */ - function order($sortfield = null, $sortorder = null) + public function order($sortfield = null, $sortorder = null) { if (! empty($sortfield)) { @@ -264,7 +264,7 @@ abstract class DoliDB implements Database * * @return string Last error */ - function lasterror() + public function lasterror() { return $this->lasterror; } @@ -278,7 +278,7 @@ abstract class DoliDB implements Database * @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ * @return int|string Date TMS or '' */ - function jdate($string, $gm = false) + public function jdate($string, $gm = false) { // TODO GMT must set param gm to true by default if ($string==0 || $string=="0000-00-00 00:00:00") return ''; @@ -293,7 +293,7 @@ abstract class DoliDB implements Database * * @return string lastqueryerror */ - function lastqueryerror() + public function lastqueryerror() { return $this->lastqueryerror; } diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index a49ef7f6294..4c95098813d 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -36,9 +36,9 @@ class DoliDBMssql extends DoliDB //! Database label const LABEL='MSSQL'; //! Charset used to force charset when creating database - var $forcecharset='latin1'; // Can't be static as it may be forced with a dynamic value + public $forcecharset='latin1'; // Can't be static as it may be forced with a dynamic value //! Collate used to force collate when creating database - var $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value + public $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value //! Version min database const VERSIONMIN='2000'; /** @var resource Resultset of last query */ @@ -55,7 +55,7 @@ class DoliDBMssql extends DoliDB * @param string $name Nom de la database * @param int $port Port of database server */ - function __construct($type, $host, $user, $pass, $name = '', $port = 0) + public function __construct($type, $host, $user, $pass, $name = '', $port = 0) { global $langs; @@ -134,19 +134,19 @@ class DoliDBMssql extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'ddl') + public static function convertSQLFromMysql($line, $type = 'ddl') { return $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * * @param string $database Name of database * @return boolean true if OK, false if KO */ - function select_db($database) + public function select_db($database) { // phpcs:enable return @mssql_select_db($database, $this->db); @@ -163,7 +163,7 @@ class DoliDBMssql extends DoliDB * @return false|resource|true Database access handler * @see close */ - function connect($host, $login, $passwd, $name, $port = 0) + public function connect($host, $login, $passwd, $name, $port = 0) { dol_syslog(get_class($this)."::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name"); $newhost=$host; @@ -191,7 +191,7 @@ class DoliDBMssql extends DoliDB * * @return string Version string */ - function getVersion() + public function getVersion() { $resql=$this->query("SELECT @@VERSION"); if ($resql) @@ -207,7 +207,7 @@ class DoliDBMssql extends DoliDB * * @return string Version string */ - function getDriverInfo() + public function getDriverInfo() { return 'php mssql driver'; } @@ -218,7 +218,7 @@ class DoliDBMssql extends DoliDB * @return bool True if disconnect successfull, false otherwise * @see connect */ - function close() + public function close() { if ($this->db) { @@ -235,7 +235,7 @@ class DoliDBMssql extends DoliDB * * @return bool true if transaction successfuly opened or already opened, false if error */ - function begin() + public function begin() { $res=mssql_query('select @@TRANCOUNT'); @@ -263,7 +263,7 @@ class DoliDBMssql extends DoliDB * @param string $log Add more log to default log line * @return bool true if validation is OK or transaction level no started, false if ERROR */ - function commit($log = '') + public function commit($log = '') { $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); @@ -296,7 +296,7 @@ class DoliDBMssql extends DoliDB * @param string $log Add more log to default log line * @return bool true si annulation ok ou transaction non ouverte, false en cas d'erreur */ - function rollback($log = '') + public function rollback($log = '') { $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); @@ -324,7 +324,7 @@ class DoliDBMssql extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return false|resource|true Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto') + public function query($query, $usesavepoint = 0, $type = 'auto') { $query = trim($query); @@ -368,11 +368,11 @@ class DoliDBMssql extends DoliDB } else { - if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+PRIMARY\h+KEY\h+(\w+?)\h*\((.+)\)/is', $query, $matches)) - { + if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+PRIMARY\h+KEY\h+(\w+?)\h*\((.+)\)/is', $query, $matches)) + { $original_query=$query; $query="ALTER TABLE [".$matches[1]."] ADD CONSTRAINT [".$matches[2]."] PRIMARY KEY CLUSTERED (".$matches[3].")"; - } + } } } @@ -459,14 +459,14 @@ class DoliDBMssql extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param resource $resultset Curseur de la requete voulue * @return object|false Object result line or false if KO or end of cursor */ - function fetch_object($resultset) + public function fetch_object($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -474,14 +474,14 @@ class DoliDBMssql extends DoliDB return mssql_fetch_object($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return array|false Array or false if KO or end of cursor */ - function fetch_array($resultset) + public function fetch_array($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -490,14 +490,14 @@ class DoliDBMssql extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return array|false Array or false if KO or end of cursor */ - function fetch_row($resultset) + public function fetch_row($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -505,7 +505,7 @@ class DoliDBMssql extends DoliDB return @mssql_fetch_row($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -513,7 +513,7 @@ class DoliDBMssql extends DoliDB * @return int Nb of lines * @see affected_rows */ - function num_rows($resultset) + public function num_rows($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -521,7 +521,7 @@ class DoliDBMssql extends DoliDB return mssql_num_rows($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * @@ -529,7 +529,7 @@ class DoliDBMssql extends DoliDB * @return int Nombre de lignes * @see num_rows */ - function affected_rows($resultset) + public function affected_rows($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -548,7 +548,7 @@ class DoliDBMssql extends DoliDB * @param resource $resultset Curseur de la requete voulue * @return bool */ - function free($resultset = null) + public function free($resultset = null) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_resource($resultset)) { $resultset=$this->_results; } @@ -562,7 +562,7 @@ class DoliDBMssql extends DoliDB * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode) + public function escape($stringtoencode) { return addslashes($stringtoencode); } @@ -575,7 +575,7 @@ class DoliDBMssql extends DoliDB * @param string $param Date TMS to convert * @return string Date in a string YYYY-MM-DD HH:MM:SS */ - function idate($param) + public function idate($param) { return dol_print_date($param, "%Y-%m-%d %H:%M:%S"); } @@ -585,7 +585,7 @@ class DoliDBMssql extends DoliDB * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno() + public function errno() { if (! $this->connected) { @@ -638,7 +638,7 @@ class DoliDBMssql extends DoliDB * * @return string Error text */ - function error() + public function error() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide pour mssql_get_last_message. @@ -649,7 +649,7 @@ class DoliDBMssql extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -657,7 +657,7 @@ class DoliDBMssql extends DoliDB * @param string $fieldid Field name * @return int Id of row or -1 on error */ - function last_insert_id($tab, $fieldid = 'rowid') + public function last_insert_id($tab, $fieldid = 'rowid') { // phpcs:enable $res = $this->query("SELECT @@IDENTITY as id"); @@ -679,7 +679,7 @@ class DoliDBMssql extends DoliDB * @param int $withQuotes Return string with quotes * @return string XXX(field) or XXX('value') or field or 'value' */ - function encrypt($fieldorvalue, $withQuotes = 0) + public function encrypt($fieldorvalue, $withQuotes = 0) { global $conf; @@ -699,7 +699,7 @@ class DoliDBMssql extends DoliDB * @param string $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value) + public function decrypt($value) { global $conf; @@ -714,13 +714,13 @@ class DoliDBMssql extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId() + public function DDLGetConnectId() { // phpcs:enable $resql=$this->query('SELECT CONNECTION_ID()'); @@ -732,7 +732,7 @@ class DoliDBMssql extends DoliDB else return '?'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -744,7 +744,7 @@ class DoliDBMssql extends DoliDB * @param string $owner Username of database owner * @return false|resource|true resource defined if OK, false if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') { // phpcs:enable /*if (empty($charset)) $charset=$this->forcecharset; @@ -770,7 +770,7 @@ class DoliDBMssql extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -778,21 +778,21 @@ class DoliDBMssql extends DoliDB * @param string $table Nmae of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = '') + public function DDLListTables($database, $table = '') { // phpcs:enable $this->_results = mssql_list_tables($database, $this->db); return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * * @param string $table Name of table * @return array Tableau des informations des champs de la table */ - function DDLInfoTable($table) + public function DDLInfoTable($table) { // phpcs:enable @@ -804,7 +804,7 @@ class DoliDBMssql extends DoliDB return $infotables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -817,7 +817,7 @@ class DoliDBMssql extends DoliDB * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) { // phpcs:enable // FIXME: $fulltext_keys parameter is unused @@ -885,14 +885,14 @@ class DoliDBMssql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table) + public function DDLDropTable($table) { // phpcs:enable $sql = "DROP TABLE ".$table; @@ -903,7 +903,7 @@ class DoliDBMssql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -911,7 +911,7 @@ class DoliDBMssql extends DoliDB * @param string $field Optionnel : Name of field if we want description of field * @return false|resource|true Resource */ - function DDLDescTable($table, $field = "") + public function DDLDescTable($table, $field = "") { // phpcs:enable $sql="DESC ".$table." ".$field; @@ -921,7 +921,7 @@ class DoliDBMssql extends DoliDB return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -931,7 +931,7 @@ class DoliDBMssql extends DoliDB * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = "") + public function DDLAddField($table, $field_name, $field_desc, $field_position = "") { // phpcs:enable // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra @@ -959,7 +959,7 @@ class DoliDBMssql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -968,7 +968,7 @@ class DoliDBMssql extends DoliDB * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc) + public function DDLUpdateField($table, $field_name, $field_desc) { // phpcs:enable $sql = "ALTER TABLE ".$table; @@ -984,7 +984,7 @@ class DoliDBMssql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -992,7 +992,7 @@ class DoliDBMssql extends DoliDB * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name) + public function DDLDropField($table, $field_name) { // phpcs:enable $sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; @@ -1005,7 +1005,7 @@ class DoliDBMssql extends DoliDB else return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user and privileges to connect to database (even if database does not exists yet) * @@ -1015,7 +1015,7 @@ class DoliDBMssql extends DoliDB * @param string $dolibarr_main_db_name Database name where user must be granted * @return int <0 if KO, >=0 if OK */ - function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) + public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) { // phpcs:enable $sql = "CREATE LOGIN ".$this->EscapeFieldName($dolibarr_main_db_user)." WITH PASSWORD='$dolibarr_main_db_pass'"; @@ -1059,7 +1059,7 @@ class DoliDBMssql extends DoliDB * * @return string Charset */ - function getDefaultCharacterSetDatabase() + public function getDefaultCharacterSetDatabase() { // FIXME: Dummy method // TODO: Implement @@ -1072,7 +1072,7 @@ class DoliDBMssql extends DoliDB * * @return array List of Charset */ - function getListOfCharacterSet() + public function getListOfCharacterSet() { // FIXME: Dummy method // TODO: Implement @@ -1085,7 +1085,7 @@ class DoliDBMssql extends DoliDB * * @return string Collation value */ - function getDefaultCollationDatabase() + public function getDefaultCollationDatabase() { $resql=$this->query("SELECT SERVERPROPERTY('collation')"); if (!$resql) @@ -1101,7 +1101,7 @@ class DoliDBMssql extends DoliDB * * @return array Liste of Collation */ - function getListOfCollation() + public function getListOfCollation() { // FIXME: Dummy method // TODO: Implement @@ -1114,7 +1114,7 @@ class DoliDBMssql extends DoliDB * * @return string Full path of dump program */ - function getPathOfDump() + public function getPathOfDump() { // FIXME: Dummy method // TODO: Implement @@ -1127,7 +1127,7 @@ class DoliDBMssql extends DoliDB * * @return string Full path of restore program */ - function getPathOfRestore() + public function getPathOfRestore() { // FIXME: Dummy method // TODO: Implement @@ -1141,7 +1141,7 @@ class DoliDBMssql extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = '') + public function getServerParametersValues($filter = '') { // FIXME: Dummy method // TODO: Implement @@ -1157,7 +1157,7 @@ class DoliDBMssql extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = '') + public function getServerStatusValues($filter = '') { // FIXME: Dummy method // TODO: Implement @@ -1166,21 +1166,21 @@ class DoliDBMssql extends DoliDB return array(); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Escape a field name according to escape's syntax * * @param string $fieldname Field's name to escape * @return string field's name escaped */ - function EscapeFieldName($fieldname) + public function EscapeFieldName($fieldname) { // phpcs:enable return "[".$fieldname."]"; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get information on field * @@ -1188,7 +1188,7 @@ class DoliDBMssql extends DoliDB * @param mixed $fields String for one field or array of string for multiple field * @return false|object */ - function GetFieldInformation($table, $fields) + public function GetFieldInformation($table, $fields) { // phpcs:enable $sql="SELECT * from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='".$this->escape($table)."' AND COLUMN_NAME"; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 48a768bd365..6c3bfd2362f 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -54,7 +54,7 @@ class DoliDBMysqli extends DoliDB * @param string $name Nom de la database * @param int $port Port of database server */ - function __construct($type, $host, $user, $pass, $name = '', $port = 0) + public function __construct($type, $host, $user, $pass, $name = '', $port = 0) { global $conf,$langs; @@ -162,19 +162,19 @@ class DoliDBMysqli extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'ddl') + public static function convertSQLFromMysql($line, $type = 'ddl') { return $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * * @param string $database Name of database * @return boolean true if OK, false if KO */ - function select_db($database) + public function select_db($database) { // phpcs:enable dol_syslog(get_class($this)."::select_db database=".$database, LOG_DEBUG); @@ -193,22 +193,22 @@ class DoliDBMysqli extends DoliDB * @return mysqli Database access object * @see close */ - function connect($host, $login, $passwd, $name, $port = 0) - { + public function connect($host, $login, $passwd, $name, $port = 0) + { dol_syslog(get_class($this) . "::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name", LOG_DEBUG); // Can also be // mysqli::init(); mysql::options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0'); mysqli::options(MYSQLI_OPT_CONNECT_TIMEOUT, 5); // return mysqli::real_connect($host, $user, $pass, $db, $port); return new mysqli($host, $login, $passwd, $name, $port); - } + } /** * Return version of database server * * @return string Version string */ - function getVersion() + public function getVersion() { return $this->db->server_info; } @@ -218,10 +218,10 @@ class DoliDBMysqli extends DoliDB * * @return string Version string */ - function getDriverInfo() - { - return $this->db->client_info; - } + public function getDriverInfo() + { + return $this->db->client_info; + } /** @@ -230,7 +230,7 @@ class DoliDBMysqli extends DoliDB * @return bool True if disconnect successfull, false otherwise * @see connect */ - function close() + public function close() { if ($this->db) { @@ -250,7 +250,7 @@ class DoliDBMysqli extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return bool|mysqli_result Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto') + public function query($query, $usesavepoint = 0, $type = 'auto') { global $conf; @@ -287,14 +287,14 @@ class DoliDBMysqli extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param mysqli_result $resultset Curseur de la requete voulue * @return object|null Object result line or null if KO or end of cursor */ - function fetch_object($resultset) + public function fetch_object($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -303,14 +303,14 @@ class DoliDBMysqli extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param mysqli_result $resultset Resultset of request * @return array|null Array or null if KO or end of cursor */ - function fetch_array($resultset) + public function fetch_array($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -318,14 +318,14 @@ class DoliDBMysqli extends DoliDB return $resultset->fetch_array(); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param mysqli_result $resultset Resultset of request * @return array|null|0 Array or null if KO or end of cursor or 0 if resultset is bool */ - function fetch_row($resultset) + public function fetch_row($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -341,7 +341,7 @@ class DoliDBMysqli extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -349,7 +349,7 @@ class DoliDBMysqli extends DoliDB * @return int Nb of lines * @see affected_rows */ - function num_rows($resultset) + public function num_rows($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -357,7 +357,7 @@ class DoliDBMysqli extends DoliDB return $resultset->num_rows; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * @@ -365,7 +365,7 @@ class DoliDBMysqli extends DoliDB * @return int Nombre de lignes * @see num_rows */ - function affected_rows($resultset) + public function affected_rows($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -382,7 +382,7 @@ class DoliDBMysqli extends DoliDB * @param mysqli_result $resultset Curseur de la requete voulue * @return void */ - function free($resultset = null) + public function free($resultset = null) { // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } @@ -396,7 +396,7 @@ class DoliDBMysqli extends DoliDB * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode) + public function escape($stringtoencode) { return $this->db->real_escape_string($stringtoencode); } @@ -406,7 +406,7 @@ class DoliDBMysqli extends DoliDB * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno() + public function errno() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide. @@ -457,7 +457,7 @@ class DoliDBMysqli extends DoliDB * * @return string Error text */ - function error() + public function error() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide pour mysqli_error. @@ -468,7 +468,7 @@ class DoliDBMysqli extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -476,7 +476,7 @@ class DoliDBMysqli extends DoliDB * @param string $fieldid Field name * @return int|string Id of row */ - function last_insert_id($tab, $fieldid = 'rowid') + public function last_insert_id($tab, $fieldid = 'rowid') { // phpcs:enable return $this->db->insert_id; @@ -491,7 +491,7 @@ class DoliDBMysqli extends DoliDB * @return string XXX(field) or XXX('value') or field or 'value' * */ - function encrypt($fieldorvalue, $withQuotes = 0) + public function encrypt($fieldorvalue, $withQuotes = 0) { global $conf; @@ -524,7 +524,7 @@ class DoliDBMysqli extends DoliDB * @param string $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value) + public function decrypt($value) { global $conf; @@ -552,13 +552,13 @@ class DoliDBMysqli extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId() + public function DDLGetConnectId() { // phpcs:enable $resql=$this->query('SELECT CONNECTION_ID()'); @@ -570,7 +570,7 @@ class DoliDBMysqli extends DoliDB else return '?'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -582,7 +582,7 @@ class DoliDBMysqli extends DoliDB * @param string $owner Username of database owner * @return bool|mysqli_result resource defined if OK, null if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') { // phpcs:enable if (empty($charset)) $charset=$this->forcecharset; @@ -604,7 +604,7 @@ class DoliDBMysqli extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -612,7 +612,7 @@ class DoliDBMysqli extends DoliDB * @param string $table Nmae of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = '') + public function DDLListTables($database, $table = '') { // phpcs:enable $listtables=array(); @@ -632,14 +632,14 @@ class DoliDBMysqli extends DoliDB return $listtables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * * @param string $table Name of table * @return array Tableau des informations des champs de la table */ - function DDLInfoTable($table) + public function DDLInfoTable($table) { // phpcs:enable $infotables=array(); @@ -658,7 +658,7 @@ class DoliDBMysqli extends DoliDB return $infotables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -671,7 +671,7 @@ class DoliDBMysqli extends DoliDB * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) { // phpcs:enable // FIXME: $fulltext_keys parameter is unused @@ -742,14 +742,14 @@ class DoliDBMysqli extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table) + public function DDLDropTable($table) { // phpcs:enable $sql = "DROP TABLE ".$table; @@ -760,7 +760,7 @@ class DoliDBMysqli extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -768,7 +768,7 @@ class DoliDBMysqli extends DoliDB * @param string $field Optionnel : Name of field if we want description of field * @return bool|mysqli_result Resultset x (x->Field, x->Type, ...) */ - function DDLDescTable($table, $field = "") + public function DDLDescTable($table, $field = "") { // phpcs:enable $sql="DESC ".$table." ".$field; @@ -778,7 +778,7 @@ class DoliDBMysqli extends DoliDB return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -788,7 +788,7 @@ class DoliDBMysqli extends DoliDB * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = "") + public function DDLAddField($table, $field_name, $field_desc, $field_position = "") { // phpcs:enable // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra @@ -830,7 +830,7 @@ class DoliDBMysqli extends DoliDB return -1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -839,7 +839,7 @@ class DoliDBMysqli extends DoliDB * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc) + public function DDLUpdateField($table, $field_name, $field_desc) { // phpcs:enable $sql = "ALTER TABLE ".$table; @@ -877,7 +877,7 @@ class DoliDBMysqli extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -885,7 +885,7 @@ class DoliDBMysqli extends DoliDB * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name) + public function DDLDropField($table, $field_name) { // phpcs:enable $sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; @@ -898,7 +898,7 @@ class DoliDBMysqli extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user and privileges to connect to database (even if database does not exists yet) * @@ -908,7 +908,7 @@ class DoliDBMysqli extends DoliDB * @param string $dolibarr_main_db_name Database name where user must be granted * @return int <0 if KO, >=0 if OK */ - function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) + public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) { // phpcs:enable $sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'"; @@ -953,7 +953,7 @@ class DoliDBMysqli extends DoliDB * @return string Charset * @see getDefaultCollationDatabase */ - function getDefaultCharacterSetDatabase() + public function getDefaultCharacterSetDatabase() { $resql=$this->query('SHOW VARIABLES LIKE \'character_set_database\''); if (!$resql) @@ -972,7 +972,7 @@ class DoliDBMysqli extends DoliDB * * @return array|null List of Charset */ - function getListOfCharacterSet() + public function getListOfCharacterSet() { $resql=$this->query('SHOW CHARSET'); $liste = array(); @@ -999,7 +999,7 @@ class DoliDBMysqli extends DoliDB * @return string Collation value * @see getDefaultCharacterSetDatabase */ - function getDefaultCollationDatabase() + public function getDefaultCollationDatabase() { $resql=$this->query('SHOW VARIABLES LIKE \'collation_database\''); if (!$resql) @@ -1018,7 +1018,7 @@ class DoliDBMysqli extends DoliDB * * @return array|null Liste of Collation */ - function getListOfCollation() + public function getListOfCollation() { $resql=$this->query('SHOW COLLATION'); $liste = array(); @@ -1043,7 +1043,7 @@ class DoliDBMysqli extends DoliDB * * @return string Full path of dump program */ - function getPathOfDump() + public function getPathOfDump() { $fullpathofdump='/pathtomysqldump/mysqldump'; @@ -1062,7 +1062,7 @@ class DoliDBMysqli extends DoliDB * * @return string Full path of restore program */ - function getPathOfRestore() + public function getPathOfRestore() { $fullpathofimport='/pathtomysql/mysql'; @@ -1082,7 +1082,7 @@ class DoliDBMysqli extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = '') + public function getServerParametersValues($filter = '') { $result=array(); @@ -1103,7 +1103,7 @@ class DoliDBMysqli extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = '') + public function getServerStatusValues($filter = '') { $result=array(); diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 1145be1849b..6e72d9c435a 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -40,9 +40,9 @@ class DoliDBPgsql extends DoliDB //! Database label const LABEL='PostgreSQL'; // Label of manager //! Charset - var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value + public $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value //! Collate used to force collate when creating database - var $forcecollate=''; // Can't be static as it may be forced with a dynamic value + public $forcecollate=''; // Can't be static as it may be forced with a dynamic value //! Version min database const VERSIONMIN='9.0.0'; // Version min database /** @var resource Resultset of last query */ @@ -62,7 +62,7 @@ class DoliDBPgsql extends DoliDB * @param string $name Nom de la database * @param int $port Port of database server */ - function __construct($type, $host, $user, $pass, $name = '', $port = 0) + public function __construct($type, $host, $user, $pass, $name = '', $port = 0) { global $conf,$langs; @@ -150,7 +150,7 @@ class DoliDBPgsql extends DoliDB * @param bool $unescapeslashquot Unescape slash quote with quote quote * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'auto', $unescapeslashquot = false) + public static function convertSQLFromMysql($line, $type = 'auto', $unescapeslashquot = false) { global $conf; @@ -368,7 +368,7 @@ class DoliDBPgsql extends DoliDB return $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * Ici postgresql n'a aucune fonction equivalente de mysql_select_db @@ -377,7 +377,7 @@ class DoliDBPgsql extends DoliDB * @param string $database Name of database * @return bool true if OK, false if KO */ - function select_db($database) + public function select_db($database) { // phpcs:enable if ($database == $this->database_name) { @@ -398,7 +398,7 @@ class DoliDBPgsql extends DoliDB * @return false|resource Database access handler * @see close */ - function connect($host, $login, $passwd, $name, $port = 0) + public function connect($host, $login, $passwd, $name, $port = 0) { // use pg_pconnect() instead of pg_connect() if you want to use persistent connection costing 1ms, instead of 30ms for non persistent @@ -446,7 +446,7 @@ class DoliDBPgsql extends DoliDB * * @return string Version string */ - function getVersion() + public function getVersion() { $resql=$this->query('SHOW server_version'); if ($resql) @@ -462,7 +462,7 @@ class DoliDBPgsql extends DoliDB * * @return string Version string */ - function getDriverInfo() + public function getDriverInfo() { return 'pgsql php driver'; } @@ -473,7 +473,7 @@ class DoliDBPgsql extends DoliDB * @return boolean True if disconnect successfull, false otherwise * @see connect */ - function close() + public function close() { if ($this->db) { @@ -492,7 +492,7 @@ class DoliDBPgsql extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return false|resource Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto') + public function query($query, $usesavepoint = 0, $type = 'auto') { global $conf; @@ -554,14 +554,14 @@ class DoliDBPgsql extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param resource $resultset Curseur de la requete voulue * @return false|object Object result line or false if KO or end of cursor */ - function fetch_object($resultset) + public function fetch_object($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -569,14 +569,14 @@ class DoliDBPgsql extends DoliDB return pg_fetch_object($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return false|array Array */ - function fetch_array($resultset) + public function fetch_array($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -584,14 +584,14 @@ class DoliDBPgsql extends DoliDB return pg_fetch_array($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return false|array Array */ - function fetch_row($resultset) + public function fetch_row($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -599,7 +599,7 @@ class DoliDBPgsql extends DoliDB return pg_fetch_row($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -607,7 +607,7 @@ class DoliDBPgsql extends DoliDB * @return int Nb of lines, -1 on error * @see affected_rows */ - function num_rows($resultset) + public function num_rows($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -615,7 +615,7 @@ class DoliDBPgsql extends DoliDB return pg_num_rows($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * @@ -623,7 +623,7 @@ class DoliDBPgsql extends DoliDB * @return int Nb of lines * @see num_rows */ - function affected_rows($resultset) + public function affected_rows($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -640,7 +640,7 @@ class DoliDBPgsql extends DoliDB * @param resource $resultset Result set of request * @return void */ - function free($resultset = null) + public function free($resultset = null) { // If resultset not provided, we take the last used by connexion if (! is_resource($resultset)) { $resultset=$this->_results; } @@ -656,7 +656,7 @@ class DoliDBPgsql extends DoliDB * @param int $offset Numero of line from where starting fetch * @return string String with SQL syntax to add a limit and offset */ - function plimit($limit = 0, $offset = 0) + public function plimit($limit = 0, $offset = 0) { global $conf; if (empty($limit)) return ""; @@ -672,7 +672,7 @@ class DoliDBPgsql extends DoliDB * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode) + public function escape($stringtoencode) { return pg_escape_string($stringtoencode); } @@ -684,7 +684,7 @@ class DoliDBPgsql extends DoliDB * @param string $param Date TMS to convert * @return string Date in a string YYYY-MM-DD HH:MM:SS */ - function idate($param) + public function idate($param) { return dol_print_date($param, "%Y-%m-%d %H:%M:%S"); } @@ -697,7 +697,7 @@ class DoliDBPgsql extends DoliDB * @param string $resko resultat si test non egal * @return string chaine formate SQL */ - function ifsql($test, $resok, $resko) + public function ifsql($test, $resok, $resko) { return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; } @@ -707,7 +707,7 @@ class DoliDBPgsql extends DoliDB * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno() + public function errno() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide. @@ -773,12 +773,12 @@ class DoliDBPgsql extends DoliDB * * @return string Error text */ - function error() + public function error() { return pg_last_error($this->db); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -786,7 +786,7 @@ class DoliDBPgsql extends DoliDB * @param string $fieldid Field name * @return string Id of row */ - function last_insert_id($tab, $fieldid = 'rowid') + public function last_insert_id($tab, $fieldid = 'rowid') { // phpcs:enable //$result = pg_query($this->db,"SELECT MAX(".$fieldid.") FROM ".$tab); @@ -809,7 +809,7 @@ class DoliDBPgsql extends DoliDB * @param int $withQuotes Return string with quotes * @return string XXX(field) or XXX('value') or field or 'value' */ - function encrypt($fieldorvalue, $withQuotes = 0) + public function encrypt($fieldorvalue, $withQuotes = 0) { global $conf; @@ -830,7 +830,7 @@ class DoliDBPgsql extends DoliDB * @param int $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value) + public function decrypt($value) { global $conf; @@ -845,13 +845,13 @@ class DoliDBPgsql extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId() + public function DDLGetConnectId() { // phpcs:enable return '?'; @@ -859,7 +859,7 @@ class DoliDBPgsql extends DoliDB - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -871,7 +871,7 @@ class DoliDBPgsql extends DoliDB * @param string $owner Username of database owner * @return false|resource resource defined if OK, null if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') { // phpcs:enable if (empty($charset)) $charset=$this->forcecharset; @@ -886,7 +886,7 @@ class DoliDBPgsql extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -894,7 +894,7 @@ class DoliDBPgsql extends DoliDB * @param string $table Name of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = '') + public function DDLListTables($database, $table = '') { // phpcs:enable $listtables=array(); @@ -912,7 +912,7 @@ class DoliDBPgsql extends DoliDB return $listtables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * @@ -920,7 +920,7 @@ class DoliDBPgsql extends DoliDB * @return array Tableau des informations des champs de la table * */ - function DDLInfoTable($table) + public function DDLInfoTable($table) { // phpcs:enable $infotables=array(); @@ -954,7 +954,7 @@ class DoliDBPgsql extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -967,7 +967,7 @@ class DoliDBPgsql extends DoliDB * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) { // phpcs:enable // FIXME: $fulltext_keys parameter is unused @@ -1035,14 +1035,14 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table) + public function DDLDropTable($table) { // phpcs:enable $sql = "DROP TABLE ".$table; @@ -1053,7 +1053,7 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user to connect to database * @@ -1063,7 +1063,7 @@ class DoliDBPgsql extends DoliDB * @param string $dolibarr_main_db_name Database name where user must be granted * @return int <0 if KO, >=0 if OK */ - function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) + public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) { // phpcs:enable // Note: using ' on user does not works with pgsql @@ -1079,7 +1079,7 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -1087,7 +1087,7 @@ class DoliDBPgsql extends DoliDB * @param string $field Optionnel : Name of field if we want description of field * @return false|resource Resultset x (x->attname) */ - function DDLDescTable($table, $field = "") + public function DDLDescTable($table, $field = "") { // phpcs:enable $sql ="SELECT attname FROM pg_attribute, pg_type WHERE typname = '".$table."' AND attrelid = typrelid"; @@ -1099,7 +1099,7 @@ class DoliDBPgsql extends DoliDB return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -1109,7 +1109,7 @@ class DoliDBPgsql extends DoliDB * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = "") + public function DDLAddField($table, $field_name, $field_desc, $field_position = "") { // phpcs:enable // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra @@ -1140,7 +1140,7 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -1149,7 +1149,7 @@ class DoliDBPgsql extends DoliDB * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc) + public function DDLUpdateField($table, $field_name, $field_desc) { // phpcs:enable $sql = "ALTER TABLE ".$table; @@ -1185,7 +1185,7 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -1193,7 +1193,7 @@ class DoliDBPgsql extends DoliDB * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name) + public function DDLDropField($table, $field_name) { // phpcs:enable $sql= "ALTER TABLE ".$table." DROP COLUMN ".$field_name; @@ -1211,7 +1211,7 @@ class DoliDBPgsql extends DoliDB * * @return string Charset */ - function getDefaultCharacterSetDatabase() + public function getDefaultCharacterSetDatabase() { $resql=$this->query('SHOW SERVER_ENCODING'); if ($resql) @@ -1227,7 +1227,7 @@ class DoliDBPgsql extends DoliDB * * @return array List of Charset */ - function getListOfCharacterSet() + public function getListOfCharacterSet() { $resql=$this->query('SHOW SERVER_ENCODING'); $liste = array(); @@ -1252,7 +1252,7 @@ class DoliDBPgsql extends DoliDB * * @return string Collation value */ - function getDefaultCollationDatabase() + public function getDefaultCollationDatabase() { $resql=$this->query('SHOW LC_COLLATE'); if ($resql) @@ -1268,7 +1268,7 @@ class DoliDBPgsql extends DoliDB * * @return array Liste of Collation */ - function getListOfCollation() + public function getListOfCollation() { $resql=$this->query('SHOW LC_COLLATE'); $liste = array(); @@ -1292,7 +1292,7 @@ class DoliDBPgsql extends DoliDB * * @return string Full path of dump program */ - function getPathOfDump() + public function getPathOfDump() { $fullpathofdump='/pathtopgdump/pg_dump'; @@ -1320,7 +1320,7 @@ class DoliDBPgsql extends DoliDB * * @return string Full path of restore program */ - function getPathOfRestore() + public function getPathOfRestore() { //$tool='pg_restore'; $tool='psql'; @@ -1352,7 +1352,7 @@ class DoliDBPgsql extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = '') + public function getServerParametersValues($filter = '') { $result=array(); @@ -1373,7 +1373,7 @@ class DoliDBPgsql extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = '') + public function getServerStatusValues($filter = '') { /* This is to return current running requests. $sql='SELECT datname,procpid,current_query FROM pg_stat_activity ORDER BY procpid'; diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 1ff024d6c6f..5ed0a05ee2a 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -38,8 +38,8 @@ class DoliDBSqlite3 extends DoliDB const LABEL='Sqlite3'; //! Version min database const VERSIONMIN='3.0.0'; - /** @var SQLite3Result Resultset of last query */ - private $_results; + /** @var SQLite3Result Resultset of last query */ + private $_results; const WEEK_MONDAY_FIRST=1; const WEEK_YEAR = 2; @@ -47,17 +47,17 @@ class DoliDBSqlite3 extends DoliDB /** - * Constructor. - * This create an opened connexion to a database server and eventually to a database + * Constructor. + * This create an opened connexion to a database server and eventually to a database * - * @param string $type Type of database (mysql, pgsql...) - * @param string $host Address of database server - * @param string $user Nom de l'utilisateur autorise - * @param string $pass Mot de passe - * @param string $name Nom de la database - * @param int $port Port of database server + * @param string $type Type of database (mysql, pgsql...) + * @param string $host Address of database server + * @param string $user Nom de l'utilisateur autorise + * @param string $pass Mot de passe + * @param string $name Nom de la database + * @param int $port Port of database server */ - function __construct($type, $host, $user, $pass, $name = '', $port = 0) + public function __construct($type, $host, $user, $pass, $name = '', $port = 0) { global $conf; @@ -134,7 +134,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'ddl') + public static function convertSQLFromMysql($line, $type = 'ddl') { // Removed empty line if this is a comment line for SVN tagging if (preg_match('/^--\s\$Id/i', $line)) { @@ -295,14 +295,14 @@ class DoliDBSqlite3 extends DoliDB return $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * * @param string $database Name of database * @return boolean true if OK, false if KO */ - function select_db($database) + public function select_db($database) { // phpcs:enable dol_syslog(get_class($this)."::select_db database=".$database, LOG_DEBUG); @@ -323,7 +323,7 @@ class DoliDBSqlite3 extends DoliDB * @return SQLite3 Database access handler * @see close */ - function connect($host, $login, $passwd, $name, $port = 0) + public function connect($host, $login, $passwd, $name, $port = 0) { global $main_data_dir; @@ -356,7 +356,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Version string */ - function getVersion() + public function getVersion() { $tmp=$this->db->version(); return $tmp['versionString']; @@ -367,7 +367,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Version string */ - function getDriverInfo() + public function getDriverInfo() { return 'sqlite3 php driver'; } @@ -379,7 +379,7 @@ class DoliDBSqlite3 extends DoliDB * @return bool True if disconnect successfull, false otherwise * @see connect */ - function close() + public function close() { if ($this->db) { @@ -401,7 +401,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return SQLite3Result Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto') + public function query($query, $usesavepoint = 0, $type = 'auto') { $ret=null; $query = trim($query); @@ -490,14 +490,14 @@ class DoliDBSqlite3 extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param SQLite3Result $resultset Curseur de la requete voulue * @return false|object Object result line or false if KO or end of cursor */ - function fetch_object($resultset) + public function fetch_object($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -511,14 +511,14 @@ class DoliDBSqlite3 extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param SQLite3Result $resultset Resultset of request * @return false|array Array or false if KO or end of cursor */ - function fetch_array($resultset) + public function fetch_array($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -528,14 +528,14 @@ class DoliDBSqlite3 extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param SQLite3Result $resultset Resultset of request * @return false|array Array or false if KO or end of cursor */ - function fetch_row($resultset) + public function fetch_row($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -551,7 +551,7 @@ class DoliDBSqlite3 extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -559,7 +559,7 @@ class DoliDBSqlite3 extends DoliDB * @return int Nb of lines * @see affected_rows */ - function num_rows($resultset) + public function num_rows($resultset) { // phpcs:enable // FIXME: SQLite3Result does not have a queryString member @@ -572,7 +572,7 @@ class DoliDBSqlite3 extends DoliDB return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -580,7 +580,7 @@ class DoliDBSqlite3 extends DoliDB * @return int Nb of lines * @see affected_rows */ - function affected_rows($resultset) + public function affected_rows($resultset) { // phpcs:enable // FIXME: SQLite3Result does not have a queryString member @@ -602,7 +602,7 @@ class DoliDBSqlite3 extends DoliDB * @param SQLite3Result $resultset Curseur de la requete voulue * @return void */ - function free($resultset = null) + public function free($resultset = null) { // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } @@ -616,7 +616,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode) + public function escape($stringtoencode) { return Sqlite3::escapeString($stringtoencode); } @@ -626,7 +626,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno() + public function errno() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide. @@ -691,7 +691,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Error text */ - function error() + public function error() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide pour sqlite_error. @@ -702,7 +702,7 @@ class DoliDBSqlite3 extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -710,7 +710,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $fieldid Field name * @return int Id of row */ - function last_insert_id($tab, $fieldid = 'rowid') + public function last_insert_id($tab, $fieldid = 'rowid') { // phpcs:enable return $this->db->lastInsertRowId(); @@ -724,7 +724,7 @@ class DoliDBSqlite3 extends DoliDB * @param int $withQuotes Return string with quotes * @return string XXX(field) or XXX('value') or field or 'value' */ - function encrypt($fieldorvalue, $withQuotes = 0) + public function encrypt($fieldorvalue, $withQuotes = 0) { global $conf; @@ -757,7 +757,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value) + public function decrypt($value) { global $conf; @@ -785,20 +785,20 @@ class DoliDBSqlite3 extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId() + public function DDLGetConnectId() { // phpcs:enable return '?'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -810,7 +810,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $owner Username of database owner * @return SQLite3Result resource defined if OK, null if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') { // phpcs:enable if (empty($charset)) $charset=$this->forcecharset; @@ -832,7 +832,7 @@ class DoliDBSqlite3 extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -840,7 +840,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $table Name of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = '') + public function DDLListTables($database, $table = '') { // phpcs:enable $listtables=array(); @@ -860,7 +860,7 @@ class DoliDBSqlite3 extends DoliDB return $listtables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * @@ -868,7 +868,7 @@ class DoliDBSqlite3 extends DoliDB * @return array Tableau des informations des champs de la table * TODO modify for sqlite */ - function DDLInfoTable($table) + public function DDLInfoTable($table) { // phpcs:enable $infotables=array(); @@ -887,7 +887,7 @@ class DoliDBSqlite3 extends DoliDB return $infotables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -900,7 +900,7 @@ class DoliDBSqlite3 extends DoliDB * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) { // phpcs:enable // FIXME: $fulltext_keys parameter is unused @@ -967,14 +967,14 @@ class DoliDBSqlite3 extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table) + public function DDLDropTable($table) { // phpcs:enable $sql = "DROP TABLE ".$table; @@ -985,7 +985,7 @@ class DoliDBSqlite3 extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -993,7 +993,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $field Optionnel : Name of field if we want description of field * @return SQLite3Result Resource */ - function DDLDescTable($table, $field = "") + public function DDLDescTable($table, $field = "") { // phpcs:enable $sql="DESC ".$table." ".$field; @@ -1003,7 +1003,7 @@ class DoliDBSqlite3 extends DoliDB return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -1013,7 +1013,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = "") + public function DDLAddField($table, $field_name, $field_desc, $field_position = "") { // phpcs:enable // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra @@ -1048,7 +1048,7 @@ class DoliDBSqlite3 extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -1057,7 +1057,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc) + public function DDLUpdateField($table, $field_name, $field_desc) { // phpcs:enable $sql = "ALTER TABLE ".$table; @@ -1072,7 +1072,7 @@ class DoliDBSqlite3 extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -1080,7 +1080,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name) + public function DDLDropField($table, $field_name) { // phpcs:enable $sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; @@ -1094,7 +1094,7 @@ class DoliDBSqlite3 extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user and privileges to connect to database (even if database does not exists yet) * @@ -1104,7 +1104,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $dolibarr_main_db_name Database name where user must be granted * @return int <0 if KO, >=0 if OK */ - function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) + public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) { // phpcs:enable $sql = "INSERT INTO user "; @@ -1147,7 +1147,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Charset */ - function getDefaultCharacterSetDatabase() + public function getDefaultCharacterSetDatabase() { return 'UTF-8'; } @@ -1157,7 +1157,7 @@ class DoliDBSqlite3 extends DoliDB * * @return array List of Charset */ - function getListOfCharacterSet() + public function getListOfCharacterSet() { $liste = array(); $i=0; @@ -1171,7 +1171,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Collation value */ - function getDefaultCollationDatabase() + public function getDefaultCollationDatabase() { return 'UTF-8'; } @@ -1181,7 +1181,7 @@ class DoliDBSqlite3 extends DoliDB * * @return array List of Collation */ - function getListOfCollation() + public function getListOfCollation() { $liste = array(); $i=0; @@ -1195,7 +1195,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Full path of dump program */ - function getPathOfDump() + public function getPathOfDump() { // FIXME: not for SQLite $fullpathofdump='/pathtomysqldump/mysqldump'; @@ -1215,7 +1215,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Full path of restore program */ - function getPathOfRestore() + public function getPathOfRestore() { // FIXME: not for SQLite $fullpathofimport='/pathtomysql/mysql'; @@ -1236,7 +1236,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = '') + public function getServerParametersValues($filter = '') { $result=array(); static $pragmas; @@ -1247,7 +1247,7 @@ class DoliDBSqlite3 extends DoliDB $pragmas = array( 'application_id', 'auto_vacuum', 'automatic_index', 'busy_timeout', 'cache_size', 'cache_spill', 'case_sensitive_like', 'checkpoint_fullsync', 'collation_list', - 'compile_options', 'data_version', /*'database_list',*/ + 'compile_options', 'data_version', /*'database_list',*/ 'defer_foreign_keys', 'encoding', 'foreign_key_check', 'freelist_count', 'full_column_names', 'fullsync', 'ingore_check_constraints', 'integrity_check', 'journal_mode', 'journal_size_limit', 'legacy_file_format', 'locking_mode', @@ -1285,7 +1285,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = '') + public function getServerStatusValues($filter = '') { $result=array(); /* diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index cfa05289f4b..fd13eb2fd26 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -21,13 +21,13 @@ * \brief File that include javascript functions (included if option use_javascript activated) */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','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('NOREQUIRESOC')) define('NOREQUIRESOC', '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'); session_cache_limiter('public'); @@ -159,4 +159,3 @@ print ' } }); });'."\n"; - diff --git a/htdocs/core/js/lib_gravatar.js.php b/htdocs/core/js/lib_gravatar.js.php index dad6482460a..e1e900b6d00 100644 --- a/htdocs/core/js/lib_gravatar.js.php +++ b/htdocs/core/js/lib_gravatar.js.php @@ -22,16 +22,16 @@ * JQuery (providing object $) library must be loaded before this file. */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations -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('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Not disabled cause need to do translations +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'); session_cache_limiter('public'); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 5b909c6e148..07a47090792 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -24,13 +24,13 @@ * JQuery (providing object $) and JQuery-UI (providing $datepicker) libraries must be loaded before this file. */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','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('NOREQUIRESOC')) define('NOREQUIRESOC', '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'); session_cache_limiter('public'); diff --git a/htdocs/core/js/timepicker.js.php b/htdocs/core/js/timepicker.js.php index 38c450b8e23..6acabbaf421 100644 --- a/htdocs/core/js/timepicker.js.php +++ b/htdocs/core/js/timepicker.js.php @@ -21,13 +21,13 @@ * \brief File that include javascript functions for timepicker */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','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('NOREQUIRESOC')) define('NOREQUIRESOC', '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'); session_cache_limiter('public'); diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index d7d8ee5a5ee..690eb8ec7b9 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -377,7 +377,7 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = // select2 disabled for smartphones with standard browser. // TODO With select2 v4, it seems ok, except that responsive style on table become crazy when scrolling at end of array) - if (! empty($conf->browser->layout) && $conf->browser->layout == 'phone') return ''; + if (! empty($conf->browser->layout) && $conf->browser->layout == 'phone' && ! empty($conf->global->MAIN_DISALLOW_SELECT2_WITH_SMARTPHONE)) return ''; if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; if (empty($conf->use_javascript_ajax)) return ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c541808399d..36cdf2c7686 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1065,7 +1065,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = * @param array $links Array of tabs. Currently initialized by calling a function xxx_admin_prepare_head * @param string $active Active tab name (document', 'info', 'ldap', ....) * @param string $title Title - * @param int $notab -1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required. + * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using dol_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title @@ -1083,7 +1083,7 @@ function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0 * @param array $links Array of tabs * @param string $active Active tab name * @param string $title Title - * @param int $notab -1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required. + * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using dol_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title @@ -1232,7 +1232,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab $out.="\n"; - if (! $notab || $notab == -1) $out.="\n".'
'."\n"; + if (! $notab || $notab == -1 || $notab == -2) $out.="\n".'
'."\n"; $parameters=array('tabname' => $active, 'out' => $out); $reshook=$hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead" @@ -2980,8 +2980,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) if (empty($srconly) && in_array($pictowithoutext, array( 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', - 'note', 'sign-out', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', - 'jabber','skype','twitter','facebook' + 'note', 'sign-out', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', + 'jabber','skype','twitter','facebook','linkedin' ) )) { $fa='fa'; @@ -3053,12 +3053,10 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = 'fa-mail-forward'; $facolor = '#555'; } - elseif ($pictowithoutext == '1uparrow') { - $fakey = 'fa-caret-up'; - $marginleftonlyshort = 1; - } - elseif ($pictowithoutext == '1downarrow') { - $fakey = 'fa-caret-down'; + elseif (in_array($pictowithoutext, array('1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected'))) { + $convertarray=array('1uparrow'=>'caret-up', '1downarrow'=>'caret-down', '1leftarrow'=>'caret-left', '1rightarrow'=>'caret-right', '1uparrow_selected'=>'caret-up', '1downarrow_selected'=>'caret-down', '1leftarrow_selected'=>'caret-left', '1rightarrow_selected'=>'caret-right'); + $fakey = 'fa-'.$convertarray[$pictowithoutext]; + if (preg_match('/selected/', $pictowithoutext)) $facolor = '#888'; $marginleftonlyshort = 1; } elseif ($pictowithoutext == 'sign-out') { @@ -3081,7 +3079,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithoutext == 'jabber') { $fakey = 'fa-comment-o'; } - elseif ($pictowithoutext == 'skype') { + elseif (in_array($pictowithoutext, array('skype', 'twitter', 'facebook', 'linkedin'))) { $fakey = 'fa-'.$pictowithoutext; if (! empty($conf->global->MAIN_USE_FONT_AWESOME_5)) $fa = 'fab'; } @@ -6833,7 +6831,8 @@ function picto_from_langcode($codelang, $moreatt = '') } /** - * Return default language from country code + * Return default language from country code. + * Return null if not found. * * @param string $countrycode Country code like 'US', 'FR', 'CA', ... * @return string Value of locale like 'en_US', 'fr_FR', ... @@ -6842,6 +6841,8 @@ function getLanguageCodeFromCountryCode($countrycode) { global $mysoc; + if (empty($countrycode)) return null; + if (strtoupper($countrycode) == 'MQ') return 'fr_CA'; if (strtoupper($countrycode) == 'SE') return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country if (strtoupper($countrycode) == 'CH') diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 69da66fa99c..9a78e7a3dbf 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -78,6 +78,11 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = curl_setopt($ch, CURLOPT_POST, 1); // POST curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields } + elseif ($postorget == 'POSTALREADYFORMATED') + { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); // HTTP request is 'POST' but param string is taken as it is + curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string + } elseif ($postorget == 'PUT') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index f58d1b44dbf..4a8f61915b5 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -214,7 +214,7 @@ if (! function_exists('json_decode')) * @param bool $assoc False return an object, true return an array * @return mixed Object or Array */ - function json_decode($json, $assoc=false) + function json_decode($json, $assoc = false) { return dol_json_decode($json, $assoc); } @@ -229,7 +229,7 @@ if (! function_exists('json_decode')) * @return mixed Object or Array or false on error * @see json_decode() */ -function dol_json_decode($json, $assoc=false) +function dol_json_decode($json, $assoc = false) { dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); @@ -242,8 +242,8 @@ function dol_json_decode($json, $assoc=false) if (! $comment) { if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; - else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; - else if ($json[$i] == ':') $out.= ' => '; + elseif (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; + elseif ($json[$i] == ':') $out.= ' => '; else $out.=$json[$i]; } else $out.= $json[$i]; @@ -282,8 +282,8 @@ function dol_json_decode($json, $assoc=false) /** * Return text according to type * - * @param string $val Value to decode - * @return string Formated value + * @param string $val Value to decode + * @return string Formated value */ function _unval($val) { @@ -292,7 +292,7 @@ function _unval($val) // single, escaped unicode character $utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2])); $utf8 = utf162utf8($utf16); - $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i',$utf8,$val); + $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i', $utf8, $val); } return $val; } @@ -310,7 +310,7 @@ function _unval($val) function utf162utf8($utf16) { // oh please oh please oh please oh please oh please - if(function_exists('mb_convert_encoding')) { + if (function_exists('mb_convert_encoding')) { return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index b5c0ee813c9..fd51506bd01 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -257,7 +257,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 54, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2463__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 55, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2464__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_export', 2451__+MAX_llx_menu__, '/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'ExportOptions', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2464__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_export', 2451__+MAX_llx_menu__, '/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'ExportOptions', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2465__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_closure', 2451__+MAX_llx_menu__, '/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuClosureAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__); -- Accounting period insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin" && $conf->global->MAIN_FEATURES_LEVEL > 0', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2451__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'FiscalPeriod', 1, 'admin', '', '', 2, 80, __ENTITY__); -- Binding diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index 6495aced16d..74ecba32db5 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -32,15 +32,15 @@ class MenuManager * @var DoliDB Database handler. */ public $db; - - var $type_user; // Put 0 for internal users, 1 for external users - var $atarget=""; // To store default target to use onto links - var $name="auguria"; - var $menu_array; - var $menu_array_after; + public $type_user; // Put 0 for internal users, 1 for external users + public $atarget=""; // To store default target to use onto links + public $name="auguria"; - var $tabMenu; + public $menu_array; + public $menu_array_after; + + public $tabMenu; /** @@ -49,7 +49,7 @@ class MenuManager * @param DoliDB $db Database handler * @param int $type_user Type of user */ - function __construct($db, $type_user) + public function __construct($db, $type_user) { $this->type_user=$type_user; $this->db=$db; @@ -63,7 +63,7 @@ class MenuManager * @param string $forceleftmenu To force leftmenu to load * @return void */ - function loadMenu($forcemainmenu = '', $forceleftmenu = '') + public function loadMenu($forcemainmenu = '', $forceleftmenu = '') { global $conf, $user, $langs; @@ -123,7 +123,7 @@ class MenuManager * @param array $moredata An array with more data to output * @return int 0 or nb of top menu entries if $mode = 'topnb' */ - function showmenu($mode, $moredata = null) + public function showmenu($mode, $moredata = null) { global $conf, $langs, $user; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 1c20a019eae..4aa3b3732f3 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -143,6 +143,25 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '', 30, $id, $idsel, $classname); } + // MRP + $tmpentry = array( + 'enabled'=>(! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled)), + 'perms'=>(! empty($user->rights->bom->read) || ! empty($user->rights->mrp->read)), + 'module'=>'bom|mrp', + ); + $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); + if ($showmode) + { + $classname=""; + if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } + else $classname = 'class="tmenu"'; + $idsel='products'; + + $chaine=$langs->trans("TMenuMRP"); + + $menu->add('/bom/bom_list.php?mainmenu=mrp&leftmenu=', $chaine, 0, $showmode, $atarget, "bom", '', 30, $id, $idsel, $classname); + } + // Projects $tmpentry=array('enabled'=>(! empty($conf->projet->enabled)), 'perms'=>(! empty($user->rights->projet->lire)), @@ -1058,6 +1077,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 55); $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 60); + $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_closure', 70); // Fiscal year if ($conf->global->MAIN_FEATURES_LEVEL > 1) { @@ -1443,6 +1463,22 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } } + /* + * Menu PRODUCTS-SERVICES MRP + */ + if ($mainmenu == 'mrp') + { + // BOM + if (! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled)) + { + $langs->load("mrp"); + + $newmenu->add("", $langs->trans("BOM"), 0, $user->rights->service->lire, '', $mainmenu, 'service'); + $newmenu->add("/bom/bom_card.php?leftmenu=bom&action=create", $langs->trans("NewBOM"), 1, $user->rights->bom->write); + $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read); + } + } + /* * Menu PROJECTS */ diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 61394df6126..2dea6a53c5d 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -32,14 +32,14 @@ class MenuManager */ public $db; - var $type_user; // Put 0 for internal users, 1 for external users - var $atarget=""; // To store default target to use onto links - var $name="eldy"; + public $type_user; // Put 0 for internal users, 1 for external users + public $atarget=""; // To store default target to use onto links + public $name="eldy"; - var $menu_array; - var $menu_array_after; + public $menu_array; + public $menu_array_after; - var $tabMenu; + public $tabMenu; /** @@ -48,7 +48,7 @@ class MenuManager * @param DoliDB $db Database handler * @param int $type_user Type of user */ - function __construct($db, $type_user) + public function __construct($db, $type_user) { $this->type_user=$type_user; $this->db=$db; @@ -62,7 +62,7 @@ class MenuManager * @param string $forceleftmenu To force leftmenu to load * @return void */ - function loadMenu($forcemainmenu = '', $forceleftmenu = '') + public function loadMenu($forcemainmenu = '', $forceleftmenu = '') { // On sauve en session le menu principal choisi if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; @@ -123,7 +123,7 @@ class MenuManager * @param array $moredata An array with more data to output * @return int 0 or nb of top menu entries if $mode = 'topnb' */ - function showmenu($mode, $moredata = null) + public function showmenu($mode, $moredata = null) { global $conf, $langs, $user; diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 643de2ebd71..c0ddb924a31 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -30,11 +30,11 @@ class MenuManager */ public $db; - var $type_user=0; // Put 0 for internal users, 1 for external users - var $atarget=""; // To store default target to use onto links + public $type_user=0; // Put 0 for internal users, 1 for external users + public $atarget=""; // To store default target to use onto links - var $menu; - var $menu_array_after; + public $menu; + public $menu_array_after; /** @@ -43,7 +43,7 @@ class MenuManager * @param DoliDB $db Database handler * @param int $type_user Type of user */ - function __construct($db, $type_user) + public function __construct($db, $type_user) { $this->type_user=$type_user; $this->db=$db; @@ -55,7 +55,7 @@ class MenuManager * * @return void */ - function loadMenu() + public function loadMenu() { } @@ -67,7 +67,7 @@ class MenuManager * @param array $moredata An array with more data to output * @return int 0 or nb of top menu entries if $mode = 'topnb' */ - function showmenu($mode, $moredata = null) + public function showmenu($mode, $moredata = null) { global $user,$conf,$langs,$dolibarr_main_db_name; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 76033d4c0cb..8544cdb2416 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2018 Josep Lluís Amador + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -334,7 +335,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin; @@ -369,6 +370,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // We need constructor into function unActivateModule into admin.lib.php + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Enables a module. * Inserts all informations into database @@ -381,47 +383,57 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int 1 if OK, 0 if KO */ - function _init($array_sql, $options = '') + protected function _init($array_sql, $options = '') { + // phpcs:enable global $conf; $err=0; $this->db->begin(); // Insert activation module constant - if (! $err) { $err+=$this->_active(); + if (! $err) { + $err+=$this->_active(); } // Insert new pages for tabs (into llx_const) - if (! $err) { $err+=$this->insert_tabs(); + if (! $err) { + $err+=$this->insert_tabs(); } // Insert activation of module's parts - if (! $err) { $err+=$this->insert_module_parts(); + if (! $err) { + $err+=$this->insert_module_parts(); } // Insert constant defined by modules (into llx_const) - if (! $err && ! preg_match('/newboxdefonly/', $options)) { $err+=$this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade + if (! $err && ! preg_match('/newboxdefonly/', $options)) { + $err+=$this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade } // Insert boxes def into llx_boxes_def and boxes setup (into llx_boxes) - if (! $err && ! preg_match('/noboxes/', $options)) { $err+=$this->insert_boxes($options); + if (! $err && ! preg_match('/noboxes/', $options)) { + $err+=$this->insert_boxes($options); } // Insert cron job entries (entry in llx_cronjobs) - if (! $err) { $err+=$this->insert_cronjobs(); + if (! $err) { + $err+=$this->insert_cronjobs(); } // Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user. - if (! $err) { $err+=$this->insert_permissions(1, null, 1); + if (! $err) { + $err+=$this->insert_permissions(1, null, 1); } // Insert specific menus entries into database - if (! $err) { $err+=$this->insert_menus(); + if (! $err) { + $err+=$this->insert_menus(); } // Create module's directories - if (! $err) { $err+=$this->create_dirs(); + if (! $err) { + $err+=$this->create_dirs(); } // Execute addons requests @@ -466,6 +478,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Disable function. Deletes the module constants and boxes from the database. * @@ -474,46 +487,56 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int 1 if OK, 0 if KO */ - function _remove($array_sql, $options = '') + protected function _remove($array_sql, $options = '') { + // phpcs:enable $err=0; $this->db->begin(); // Remove activation module line (constant MAIN_MODULE_MYMODULE in llx_const) - if (! $err) { $err+=$this->_unactive(); + if (! $err) { + $err+=$this->_unactive(); } // Remove activation of module's new tabs (MAIN_MODULE_MYMODULE_TABS_XXX in llx_const) - if (! $err) { $err+=$this->delete_tabs(); + if (! $err) { + $err+=$this->delete_tabs(); } // Remove activation of module's parts (MAIN_MODULE_MYMODULE_XXX in llx_const) - if (! $err) { $err+=$this->delete_module_parts(); + if (! $err) { + $err+=$this->delete_module_parts(); } // Remove constants defined by modules - if (! $err) { $err+=$this->delete_const(); + if (! $err) { + $err+=$this->delete_const(); } // Remove list of module's available boxes (entry in llx_boxes) - if (! $err && ! preg_match('/(newboxdefonly|noboxes)/', $options)) { $err+=$this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only + if (! $err && ! preg_match('/(newboxdefonly|noboxes)/', $options)) { + $err+=$this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only } // Remove list of module's cron job entries (entry in llx_cronjobs) - if (! $err) { $err+=$this->delete_cronjobs(); + if (! $err) { + $err+=$this->delete_cronjobs(); } // Remove module's permissions from list of available permissions (entries in llx_rights_def) - if (! $err) { $err+=$this->delete_permissions(); + if (! $err) { + $err+=$this->delete_permissions(); } // Remove module's menus (entries in llx_menu) - if (! $err) { $err+=$this->delete_menus(); + if (! $err) { + $err+=$this->delete_menus(); } // Remove module's directories - if (! $err) { $err+=$this->delete_dirs(); + if (! $err) { + $err+=$this->delete_dirs(); } // Run complementary sql requests @@ -549,7 +572,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated module name */ - function getName() + public function getName() { global $langs; $langs->load("admin"); @@ -585,7 +608,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated module description */ - function getDesc() + public function getDesc() { global $langs; $langs->load("admin"); @@ -621,7 +644,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Long description of a module from README.md of from property. */ - function getDescLong() + public function getDescLong() { global $langs; $langs->load("admin"); @@ -639,11 +662,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; $content = dolMd2Html( - $content, 'parsedown', + $content, + 'parsedown', array( - 'doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1), - 'img/'=>dol_buildpath(strtolower($this->name).'/img/', 1), - 'images/'=>dol_buildpath(strtolower($this->name).'/imgages/', 1), + 'doc/' => dol_buildpath(strtolower($this->name).'/doc/', 1), + 'img/' => dol_buildpath(strtolower($this->name).'/img/', 1), + 'images/' => dol_buildpath(strtolower($this->name).'/imgages/', 1), ) ); } @@ -652,8 +676,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $content = nl2br($content); } } - else // Mostly for internal modules + else { + // Mostly for internal modules if (! empty($this->descriptionlong)) { if (is_array($this->langfiles)) { foreach($this->langfiles as $val) @@ -675,7 +700,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Path of file if a README file was found. */ - function getDescLongReadmeFound() + public function getDescLongReadmeFound() { global $langs; @@ -710,7 +735,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Content of ChangeLog */ - function getChangeLog() + public function getChangeLog() { global $langs; $langs->load("admin"); @@ -755,7 +780,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Publisher name */ - function getPublisher() + public function getPublisher() { return $this->editor_name; } @@ -765,7 +790,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Publisher url */ - function getPublisherUrl() + public function getPublisherUrl() { return $this->editor_url; } @@ -778,7 +803,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param int $translated 1=Special version keys are translated, 0=Special version keys are not translated * @return string Module version */ - function getVersion($translated = 1) + public function getVersion($translated = 1) { global $langs; $langs->load("admin"); @@ -786,14 +811,20 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $ret=''; $newversion=preg_replace('/_deprecated/', '', $this->version); - if ($newversion == 'experimental') { $ret=($translated?$langs->transnoentitiesnoconv("VersionExperimental"):$newversion); - } elseif ($newversion == 'development') { $ret=($translated?$langs->transnoentitiesnoconv("VersionDevelopment"):$newversion); - } elseif ($newversion == 'dolibarr') { $ret=DOL_VERSION; - } elseif ($newversion) { $ret=$newversion; - } else { $ret=($translated?$langs->transnoentitiesnoconv("VersionUnknown"):'unknown'); + if ($newversion == 'experimental') { + $ret=($translated?$langs->transnoentitiesnoconv("VersionExperimental"):$newversion); + } elseif ($newversion == 'development') { + $ret=($translated?$langs->transnoentitiesnoconv("VersionDevelopment"):$newversion); + } elseif ($newversion == 'dolibarr') { + $ret=DOL_VERSION; + } elseif ($newversion) { + $ret=$newversion; + } else { + $ret=($translated?$langs->transnoentitiesnoconv("VersionUnknown"):'unknown'); } - if (preg_match('/_deprecated/', $this->version)) { $ret.=($translated?' ('.$langs->transnoentitiesnoconv("Deprecated").')':$this->version); + if (preg_match('/_deprecated/', $this->version)) { + $ret.=($translated?' ('.$langs->transnoentitiesnoconv("Deprecated").')':$this->version); } return $ret; } @@ -804,15 +835,19 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string 'core', 'external' or 'unknown' */ - function isCoreOrExternalModule() + public function isCoreOrExternalModule() { - if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { return 'core'; + if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { + return 'core'; } - if (! empty($this->version) && ! in_array($this->version, array('experimental','development'))) { return 'external'; + if (! empty($this->version) && ! in_array($this->version, array('experimental','development'))) { + return 'external'; } - if (! empty($this->editor_name) || ! empty($this->editor_url)) { return 'external'; + if (! empty($this->editor_name) || ! empty($this->editor_url)) { + return 'external'; } - if ($this->numero >= 100000) { return 'external'; + if ($this->numero >= 100000) { + return 'external'; } return 'unknown'; } @@ -823,7 +858,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string[] Language files list */ - function getLangFilesArray() + public function getLangFilesArray() { return $this->langfiles; } @@ -835,7 +870,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated databaset label */ - function getExportDatasetLabel($r) + public function getExportDatasetLabel($r) { global $langs; @@ -859,7 +894,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated dataset label */ - function getImportDatasetLabel($r) + public function getImportDatasetLabel($r) { global $langs; @@ -882,7 +917,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return timestamp Date of last activation */ - function getLastActivationDate() + public function getLastActivationDate() { global $conf; @@ -892,11 +927,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $err++; - } else - { + if (! $resql) { + $err++; + } else { $obj=$this->db->fetch_object($resql); - if ($obj) { return $this->db->jdate($obj->tms); + if ($obj) { + return $this->db->jdate($obj->tms); } } @@ -909,7 +945,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return array Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation) */ - function getLastActivationInfo() + public function getLastActivationInfo() { global $conf; @@ -919,15 +955,16 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $err++; - } else - { + if (! $resql) { + $err++; + } else { $obj=$this->db->fetch_object($resql); $tmp=array(); if ($obj->note) { $tmp=json_decode($obj->note, true); } - if ($obj) { return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); + if ($obj) { + return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); } } @@ -940,7 +977,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function _active() + protected function _active() { global $conf, $user; @@ -955,7 +992,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $err++; + if (! $resql) { + $err++; } $note=json_encode(array('authorid'=>(is_object($user)?$user->id:0), 'ip'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']))); @@ -980,7 +1018,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function _unactive() + protected function _unactive() { global $conf; @@ -1000,7 +1038,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create tables and keys required by module. * Files module.sql and module.key.sql with create table and create keys @@ -1010,7 +1048,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param string $reldir Relative directory where to scan files * @return int <=0 if KO, >0 if OK */ - function _load_tables($reldir) + protected function _load_tables($reldir) { // phpcs:enable global $conf; @@ -1018,7 +1056,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $error=0; $dirfound=0; - if (empty($reldir)) { return 1; + if (empty($reldir)) { + return 1; } include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; @@ -1119,7 +1158,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds boxes * @@ -1127,7 +1166,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function insert_boxes($option = '') + public function insert_boxes($option = '') { // phpcs:enable include_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; @@ -1219,13 +1258,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes boxes * * @return int Error count (0 if OK) */ - function delete_boxes() + public function delete_boxes() { // phpcs:enable global $conf; @@ -1292,13 +1331,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds cronjobs * * @return int Error count (0 if OK) */ - function insert_cronjobs() + public function insert_cronjobs() { // phpcs:enable include_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; @@ -1332,13 +1371,17 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // Search if cron entry already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; $sql.= " WHERE module_name = '".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."'"; - if ($class) { $sql.= " AND classesname = '".$this->db->escape($class)."'"; + if ($class) { + $sql.= " AND classesname = '".$this->db->escape($class)."'"; } - if ($objectname) { $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; + if ($objectname) { + $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; } - if ($method) { $sql.= " AND methodename = '".$this->db->escape($method)."'"; + if ($method) { + $sql.= " AND methodename = '".$this->db->escape($method)."'"; } - if ($command) { $sql.= " AND command = '".$this->db->escape($command)."'"; + if ($command) { + $sql.= " AND command = '".$this->db->escape($command)."'"; } $sql.= " AND entity = ".$entity; // Must be exact entity @@ -1410,13 +1453,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes boxes * * @return int Error count (0 if OK) */ - function delete_cronjobs() + public function delete_cronjobs() { // phpcs:enable global $conf; @@ -1441,13 +1484,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes tabs * * @return int Error count (0 if OK) */ - function delete_tabs() + public function delete_tabs() { // phpcs:enable global $conf; @@ -1467,13 +1510,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds tabs * * @return int Error count (0 if ok) */ - function insert_tabs() + public function insert_tabs() { // phpcs:enable global $conf; @@ -1533,13 +1576,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds constants * * @return int Error count (0 if OK) */ - function insert_const() + public function insert_const() { // phpcs:enable global $conf; @@ -1605,13 +1648,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes constants tagged 'deleteonunactive' * * @return int <0 if KO, 0 if OK */ - function delete_const() + public function delete_const() { // phpcs:enable global $conf; @@ -1641,7 +1684,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds access rights * @@ -1650,7 +1693,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int Error count (0 if OK) */ - function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) + public function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) { // phpcs:enable global $conf,$user; @@ -1680,7 +1723,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $r_def = $this->rights[$key][3]; $r_perms = $this->rights[$key][4]; $r_subperms = isset($this->rights[$key][5])?$this->rights[$key][5]:''; - $r_modul = empty($this->rights_class)?strtolower($this->name):$this->rights_class; + $r_modul = empty($this->rights_class)?strtolower($this->name):$this->rights_class; if (empty($r_type)) { $r_type='w'; } @@ -1788,13 +1831,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes access rights * * @return int Error count (0 if OK) */ - function delete_permissions() + public function delete_permissions() { // phpcs:enable global $conf; @@ -1814,13 +1857,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds menu entries * * @return int Error count (0 if OK) */ - function insert_menus() + public function insert_menus() { // phpcs:enable global $user; @@ -1918,13 +1961,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes menu entries * * @return int Error count (0 if OK) */ - function delete_menus() + public function delete_menus() { // phpcs:enable global $conf; @@ -1948,13 +1991,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Creates directories * * @return int Error count (0 if OK) */ - function create_dirs() + public function create_dirs() { // phpcs:enable global $langs, $conf; @@ -2008,7 +2051,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds directories definitions * @@ -2017,7 +2060,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function insert_dirs($name, $dir) + public function insert_dirs($name, $dir) { // phpcs:enable global $conf; @@ -2052,13 +2095,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes directories * * @return int Error count (0 if OK) */ - function delete_dirs() + public function delete_dirs() { // phpcs:enable global $conf; @@ -2078,13 +2121,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds generic parts * * @return int Error count (0 if OK) */ - function insert_module_parts() + public function insert_module_parts() { // phpcs:enable global $conf; @@ -2155,13 +2198,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes generic parts * * @return int Error count (0 if OK) */ - function delete_module_parts() + public function delete_module_parts() { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/action/modules_action.php b/htdocs/core/modules/action/modules_action.php index 4b090b9b56f..104e1e37ae9 100644 --- a/htdocs/core/modules/action/modules_action.php +++ b/htdocs/core/modules/action/modules_action.php @@ -33,7 +33,7 @@ abstract class ModeleAction extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -41,7 +41,7 @@ abstract class ModeleAction extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index eaf71d9f8af..52b70caf47f 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -71,7 +71,7 @@ class CommActionRapport * @param int $month Month * @param int $year Year */ - function __construct($db, $month, $year) + public function __construct($db, $month, $year) { global $conf, $langs; @@ -99,16 +99,16 @@ class CommActionRapport $this->subject=$langs->transnoentitiesnoconv("ActionsReport").' '.$this->year."-".$this->month; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Write the object to document file to disk * * @param int $socid Thirdparty id * @param int $catid Cat id * @param Translate $outputlangs Lang object for output language * @return int 1=OK, 0=KO - */ - function write_file($socid = 0, $catid = 0, $outputlangs = '') + */ + public function write_file($socid = 0, $catid = 0, $outputlangs = '') { // phpcs:enable global $user,$conf,$langs,$hookmanager; @@ -210,7 +210,7 @@ class CommActionRapport * @param Translate $outputlangs Object langs * @return int 1 */ - function _pages(&$pdf, $outputlangs) + private function _pages(&$pdf, $outputlangs) { global $conf; @@ -335,7 +335,7 @@ class CommActionRapport * @param int $pagenb Page nb * @return integer */ - function _pagehead(&$pdf, $outputlangs, $pagenb) + private function _pagehead(&$pdf, $outputlangs, $pagenb) { global $conf,$langs; diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 98f86e9a596..53a38eb70ed 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -50,7 +50,7 @@ class pdf_ban extends ModeleBankAccountDoc * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -90,7 +90,7 @@ class pdf_ban extends ModeleBankAccountDoc } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -98,7 +98,7 @@ class pdf_ban extends ModeleBankAccountDoc * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs) + public function write_file($object, $outputlangs) { // phpcs:enable global $conf, $hookmanager, $langs, $user; @@ -288,7 +288,7 @@ class pdf_ban extends ModeleBankAccountDoc * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -304,7 +304,7 @@ class pdf_ban extends ModeleBankAccountDoc * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -390,7 +390,7 @@ class pdf_ban extends ModeleBankAccountDoc * @param int $hidefreetext 1=Hide free text * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index f61758abf92..bbd5858192c 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -52,7 +52,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -92,7 +92,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -105,7 +105,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param null|array $moreparams More parameters * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { // phpcs:enable global $conf, $hookmanager, $langs, $user, $mysoc; @@ -435,7 +435,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -443,7 +443,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -453,7 +453,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf, $mysoc; @@ -480,7 +480,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show area for the customer to sign * @@ -490,7 +490,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _signature_area(&$pdf, $object, $posy, $outputlangs) + private function _signature_area(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -531,7 +531,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -623,7 +623,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param int $hidefreetext 1=Hide free text * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/bank/modules_bank.php b/htdocs/core/modules/bank/modules_bank.php index 8cdf2ba7ebe..f965e29ccce 100644 --- a/htdocs/core/modules/bank/modules_bank.php +++ b/htdocs/core/modules/bank/modules_bank.php @@ -37,7 +37,7 @@ abstract class ModeleBankAccountDoc extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -45,7 +45,7 @@ abstract class ModeleBankAccountDoc extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php index cfbe51b0579..19744177e40 100644 --- a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php @@ -49,7 +49,7 @@ class modPhpbarcode extends ModeleBarCode * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -60,7 +60,7 @@ class modPhpbarcode extends ModeleBarCode * * @return string Texte descripif */ - function info() + public function info() { global $langs; @@ -76,7 +76,7 @@ class modPhpbarcode extends ModeleBarCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs; @@ -90,7 +90,7 @@ class modPhpbarcode extends ModeleBarCode * @param string $encoding Encoding norm * @return int >0 if supported, 0 if not */ - function encodingIsSupported($encoding) + public function encodingIsSupported($encoding) { global $genbarcode_loc; //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit; @@ -100,8 +100,7 @@ class modPhpbarcode extends ModeleBarCode if ($encoding == 'ISBN') $supported=1; // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not // activated on Windows) - if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) - { + if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) { if ($encoding == 'EAN8') $supported=1; if ($encoding == 'UPC') $supported=1; if ($encoding == 'C39') $supported=1; @@ -120,7 +119,7 @@ class modPhpbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error * @return int <0 if KO, >0 if OK */ - function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $_GET,$_SERVER; global $conf; @@ -161,7 +160,7 @@ class modPhpbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error * @return int <0 if KO, >0 if OK */ - function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $conf,$filebarcode; diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php index f6eff1e2c5d..17793a5dfd4 100644 --- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php @@ -49,7 +49,7 @@ class modTcpdfbarcode extends ModeleBarCode * * @return string Text with description */ - function info() + public function info() { global $langs; @@ -61,7 +61,7 @@ class modTcpdfbarcode extends ModeleBarCode * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -72,7 +72,7 @@ class modTcpdfbarcode extends ModeleBarCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs; @@ -85,7 +85,7 @@ class modTcpdfbarcode extends ModeleBarCode * @param string $encoding Encoding norm * @return int >0 if supported, 0 if not */ - function encodingIsSupported($encoding) + public function encodingIsSupported($encoding) { $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); if (empty($tcpdfEncoding)) { @@ -105,7 +105,7 @@ class modTcpdfbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error (not used with this engine) * @return int <0 if KO, >0 if OK */ - function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $_GET; @@ -152,7 +152,7 @@ class modTcpdfbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error (not used with this engine) * @return int <0 if KO, >0 if OK */ - function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $conf,$_GET; diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 239a1683fad..936e7b87be4 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -61,7 +61,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 0; $this->code_modifiable = 1; @@ -77,7 +77,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Description of module */ - function info($langs) + public function info($langs) { global $conf, $mc; global $form; @@ -119,7 +119,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Product $objproduct Object product * @return string Return string example */ - function getExample($langs, $objproduct = 0) + public function getExample($langs, $objproduct = 0) { $examplebarcode = $this->getNextValue($objproduct, ''); if (! $examplebarcode) @@ -142,7 +142,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param string $type Type of barcode (EAN, ISBN, ...) * @return string Value if OK, '' if module not configured, <0 if KO */ - function getNextValue($objproduct = null, $type = '') + public function getNextValue($objproduct = null, $type = '') { global $db,$conf; @@ -184,7 +184,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $thirdparty_type, $type) + public function verif($db, &$code, $product, $thirdparty_type, $type) { global $conf; @@ -235,7 +235,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if a code is used (by other element) * @@ -244,7 +244,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Product $product Objet product * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $product) + public function verif_dispo($db, $code, $product) { // phpcs:enable $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product"; @@ -269,7 +269,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if a barcode value match syntax * @@ -277,7 +277,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param string $typefortest Type of barcode (ISBN, EAN, ...) * @return int 0 if OK, <0 if KO */ - function verif_syntax($codefortest, $typefortest) + public function verif_syntax($codefortest, $typefortest) { // phpcs:enable global $conf; @@ -296,15 +296,15 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode $newcodefortest=$codefortest; - // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test - if (in_array($typefortest, array('EAN13','ISBN'))) // We remove the CRC char not included into mask - { - if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) - { - if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12); - dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); - } - } + // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test + if (in_array($typefortest, array('EAN13','ISBN'))) // We remove the CRC char not included into mask + { + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) + { + if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12); + dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); + } + } $result=check_value($mask, $newcodefortest); if (is_string($result)) diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index 7e0eba53571..6a205b57d8c 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -29,21 +29,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; */ abstract class ModeleBarCode { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - /** - * Return if a model can be used or not - * - * @return boolean true if model can be used - */ - function isEnabled() - { - return true; - } + /** + * Return if a model can be used or not + * + * @return boolean true if model can be used + */ + public function isEnabled() + { + return true; + } } @@ -52,17 +52,17 @@ abstract class ModeleBarCode */ abstract class ModeleNumRefBarCode { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Return default description of numbering model * * @param Translate $langs Object langs * @return string Descriptive text */ - function info($langs) + public function info($langs) { $langs->load("bills"); return $langs->trans("NoDescription"); @@ -73,7 +73,7 @@ abstract class ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Model name */ - function getNom($langs) + public function getNom($langs) { return empty($this->name)?$this->nom:$this->name; } @@ -83,7 +83,7 @@ abstract class ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Example */ - function getExample($langs) + public function getExample($langs) { $langs->load("bills"); return $langs->trans("NoExample"); @@ -96,17 +96,17 @@ abstract class ModeleNumRefBarCode * @param string $type Type of barcode (EAN, ISBN, ...) * @return string Value */ - function getNextValue($objproduct, $type = '') + public function getNextValue($objproduct, $type = '') { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); } - /** Return version of module + /** Return version of module * * @return string Version */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -126,7 +126,7 @@ abstract class ModeleNumRefBarCode * @param int $type -1=Nothing, 0=Product, 1=Service * @return string HTML translated description */ - function getToolTip($langs, $soc, $type) + public function getToolTip($langs, $soc, $type) { global $conf; diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php new file mode 100644 index 00000000000..e37ce3d9840 --- /dev/null +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -0,0 +1,145 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/mod_bom_advanced.php + * \ingroup bom + * \brief Fichier contenant la classe du modele de numerotation de reference de bom advanced + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php'; + + +/** + * Class to manage customer Bom numbering rules advanced + */ +class mod_bom_advanced extends ModeleNumRefboms +{ + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var string Error message + */ + public $error = ''; + + /** + * @var string name + */ + public $name='advanced'; + + + /** + * Renvoi la description du modele de numerotation + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs; + + $langs->load("bills"); + + $form = new Form($this->db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '
'; + print ''; $arrayofoperators=array('<'=>'<','>'=>'>'); print $form->selectarray('filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1); print ' '; @@ -461,7 +461,7 @@ if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) } if (! empty($arrayfields['cd.date_ouverture']['checked'])) { - print ''; + print ''; $arrayofoperators=array('<'=>'<','>'=>'>'); print $form->selectarray('filter_op1', $arrayofoperators, $filter_op1, 1); print ' '; @@ -471,7 +471,7 @@ if (! empty($arrayfields['cd.date_ouverture']['checked'])) } if (! empty($arrayfields['cd.date_fin_validite']['checked'])) { - print ''; + print ''; $arrayofoperators=array('<'=>'<','>'=>'>'); print $form->selectarray('filter_op2', $arrayofoperators, $filter_op2, 1); print ' '; @@ -481,7 +481,7 @@ if (! empty($arrayfields['cd.date_fin_validite']['checked'])) } if (! empty($arrayfields['cd.date_cloture']['checked'])) { - print ''; + print ''; $arrayofoperators=array('<'=>'<','>'=>'>'); print $form->selectarray('filter_opcloture', $arrayofoperators, $filter_opcloture, 1); print ' '; @@ -639,7 +639,7 @@ while ($i < min($num, $limit)) // Start date if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) { - print ''; + print ''; print ($obj->date_ouverture_prevue?dol_print_date($db->jdate($obj->date_ouverture_prevue), 'dayhour'):' '); if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) print ' '.img_picto($langs->trans("Late"), "warning"); @@ -649,13 +649,13 @@ while ($i < min($num, $limit)) } if (! empty($arrayfields['cd.date_ouverture']['checked'])) { - print ''.($obj->date_ouverture?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour'):' ').''.($obj->date_ouverture?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour'):' ').''.($obj->date_fin_validite?dol_print_date($db->jdate($obj->date_fin_validite), 'dayhour'):' '); + print ''.($obj->date_fin_validite?dol_print_date($db->jdate($obj->date_fin_validite), 'dayhour'):' '); if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) { $warning_delay=$conf->contrat->services->expires->warning_delay / 3600 / 24; @@ -669,7 +669,7 @@ while ($i < min($num, $limit)) // Close date (real end date) if (! empty($arrayfields['cd.date_cloture']['checked'])) { - print ''.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').''.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').''; + print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; + print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); 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; diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index d63df9f87b9..520eeaabece 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -50,7 +50,7 @@ foreach($linkedObjectBlock as $key => $objectlink) trans("Contract"); ?> getNomUrl(1); ?> date_contrat, 'day'); ?>date_contrat, 'day'); ?> info_box_head, $this->info_box_contents); @@ -257,5 +257,5 @@ class box_actions extends ModeleBoxes else print $out; return ''; - } + } } diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 44ca6cbf9e3..300040639a8 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -30,21 +30,21 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_activity extends ModeleBoxes { - var $boxcode="activity"; - var $boximg="object_bill"; - var $boxlabel='BoxGlobalActivity'; - var $depends = array("facture"); + public $boxcode="activity"; + public $boximg="object_bill"; + public $boxlabel='BoxGlobalActivity'; + public $depends = array("facture"); /** * @var DoliDB Database handler. */ public $db; - var $param; - var $enabled = 1; + public $param; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_activity extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $conf, $user; @@ -74,7 +74,7 @@ class box_activity extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -450,16 +450,16 @@ class box_activity extends ModeleBoxes } - /** - * Method to show 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 string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show 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 string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 08d10e7c6d5..52f8c0f4a77 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -28,20 +28,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_bookmarks extends ModeleBoxes { - var $boxcode="bookmarks"; - var $boximg="object_bookmark"; - var $boxlabel="BoxMyLastBookmarks"; - var $depends = array("bookmark"); + public $boxcode="bookmarks"; + public $boximg="object_bookmark"; + public $boxlabel="BoxMyLastBookmarks"; + public $depends = array("bookmark"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -50,7 +50,7 @@ class box_bookmarks extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -65,7 +65,7 @@ class box_bookmarks extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -149,16 +149,16 @@ class box_bookmarks extends ModeleBoxes } } - /** - * Method to show 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 string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show 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 string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 87378de74b3..ea2a7814f14 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_clients extends ModeleBoxes { - var $boxcode="lastcustomers"; - var $boximg="object_company"; - var $boxlabel="BoxLastCustomers"; - var $depends = array("societe"); + public $boxcode="lastcustomers"; + public $boximg="object_company"; + public $boxlabel="BoxLastCustomers"; + public $depends = array("societe"); /** * @var DoliDB Database handler. */ public $db; - var $enabled = 1; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,7 +54,7 @@ class box_clients extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -72,7 +72,7 @@ class box_clients extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -175,7 +175,7 @@ class box_clients extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 3769a39faaf..8575e739946 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_commandes extends ModeleBoxes { - var $boxcode="lastcustomerorders"; - var $boximg="object_order"; - var $boxlabel="BoxLastCustomerOrders"; - var $depends = array("commande"); + public $boxcode="lastcustomerorders"; + public $boximg="object_order"; + public $boxlabel="BoxLastCustomerOrders"; + public $depends = array("commande"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,7 +54,7 @@ class box_commandes extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -69,7 +69,7 @@ class box_commandes extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -198,7 +198,7 @@ class box_commandes extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 7fafcb3bd10..525562d308d 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -33,21 +33,21 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class box_comptes extends ModeleBoxes { - var $boxcode="currentaccounts"; - var $boximg="object_bill"; - var $boxlabel="BoxCurrentAccounts"; - var $depends = array("banque"); // Box active if module banque active + public $boxcode="currentaccounts"; + public $boximg="object_bill"; + public $boxlabel="BoxCurrentAccounts"; + public $depends = array("banque"); // Box active if module banque active - /** + /** * @var DoliDB Database handler. */ public $db; - var $param; - var $enabled = 1; + public $param; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,7 +56,7 @@ class box_comptes extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -75,7 +75,7 @@ class box_comptes extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -176,16 +176,16 @@ class box_comptes extends ModeleBoxes } } - /** - * Method to show 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 string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show 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 string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 8fdd5483975..45886e00be7 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -34,20 +34,20 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; */ class box_contacts extends ModeleBoxes { - var $boxcode="lastcontacts"; - var $boximg="object_contact"; - var $boxlabel="BoxLastContacts"; - var $depends = array("societe"); + public $boxcode="lastcontacts"; + public $boximg="object_contact"; + public $boxlabel="BoxLastContacts"; + public $depends = array("societe"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,7 +56,7 @@ class box_contacts extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -71,7 +71,7 @@ class box_contacts extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -185,7 +185,7 @@ class box_contacts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index a58081dffcf..57adf1c06cb 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_contracts extends ModeleBoxes { - var $boxcode="lastcontracts"; - var $boximg="object_contract"; - var $boxlabel="BoxLastContracts"; - var $depends = array("contrat"); // conf->contrat->enabled + public $boxcode="lastcontracts"; + public $boximg="object_contract"; + public $boxlabel="BoxLastContracts"; + public $depends = array("contrat"); // conf->contrat->enabled /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_contracts extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -68,7 +68,7 @@ class box_contracts extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -189,7 +189,7 @@ class box_contracts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 38f865279e3..f879523e9e0 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -34,20 +34,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_external_rss extends ModeleBoxes { - var $boxcode="lastrssinfos"; - var $boximg="object_rss"; - var $boxlabel="BoxLastRssInfos"; - var $depends = array("externalrss"); + public $boxcode="lastrssinfos"; + public $boximg="object_rss"; + public $boxlabel="BoxLastRssInfos"; + public $depends = array("externalrss"); /** * @var DoliDB Database handler. */ public $db; - var $paramdef; // Params of box definition (not user params) + public $paramdef; // Params of box definition (not user params) - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,7 +56,7 @@ class box_external_rss extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { $this->db=$db; $this->paramdef=$param; @@ -69,7 +69,7 @@ class box_external_rss extends ModeleBoxes * @param int $cachedelay Delay we accept for cache file * @return void */ - function loadBox($max = 5, $cachedelay = 3600) + public function loadBox($max = 5, $cachedelay = 3600) { global $user, $langs, $conf; $langs->load("boxes"); @@ -195,7 +195,7 @@ class box_external_rss extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index c78837cc3ac..42c21f0708b 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures extends ModeleBoxes { - var $boxcode="lastcustomerbills"; - var $boximg="object_bill"; - var $boxlabel="BoxLastCustomerBills"; - var $depends = array("facture"); + public $boxcode="lastcustomerbills"; + public $boximg="object_bill"; + public $boxlabel="BoxLastCustomerBills"; + public $depends = array("facture"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,7 +52,7 @@ class box_factures extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -67,7 +67,7 @@ class box_factures extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -209,7 +209,7 @@ class box_factures extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 1f3c0a4c7df..3dc8011fd7f 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn extends ModeleBoxes { - var $boxcode="lastsupplierbills"; - var $boximg="object_bill"; - var $boxlabel="BoxLastSupplierBills"; - var $depends = array("facture","fournisseur"); + public $boxcode="lastsupplierbills"; + public $boximg="object_bill"; + public $boxlabel="BoxLastSupplierBills"; + public $depends = array("facture","fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_factures_fourn extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -68,7 +68,7 @@ class box_factures_fourn extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -214,7 +214,7 @@ class box_factures_fourn extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index b6fea0f450a..3c1b486b50d 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn_imp extends ModeleBoxes { - var $boxcode = "oldestunpaidsupplierbills"; - var $boximg = "object_bill"; - var $boxlabel = "BoxOldestUnpaidSupplierBills"; - var $depends = array("facture","fournisseur"); + public $boxcode = "oldestunpaidsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidSupplierBills"; + public $depends = array("facture","fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,7 +52,7 @@ class box_factures_fourn_imp extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -67,7 +67,7 @@ class box_factures_fourn_imp extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -201,7 +201,7 @@ class box_factures_fourn_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index d76477dc356..fd85f136f96 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -33,20 +33,20 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; */ class box_factures_imp extends ModeleBoxes { - var $boxcode="oldestunpaidcustomerbills"; - var $boximg="object_bill"; - var $boxlabel="BoxOldestUnpaidCustomerBills"; - var $depends = array("facture"); + public $boxcode="oldestunpaidcustomerbills"; + public $boximg="object_bill"; + public $boxlabel="BoxOldestUnpaidCustomerBills"; + public $depends = array("facture"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,7 +55,7 @@ class box_factures_imp extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -70,7 +70,7 @@ class box_factures_imp extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -207,7 +207,7 @@ class box_factures_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 8dcd81c1aab..0debc76c507 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_ficheinter extends ModeleBoxes { - var $boxcode="ficheinter"; - var $boximg="object_intervention"; - var $boxlabel="BoxFicheInter"; - var $depends = array("ficheinter"); // conf->contrat->enabled + public $boxcode="ficheinter"; + public $boximg="object_intervention"; + public $boxlabel="BoxFicheInter"; + public $depends = array("ficheinter"); // conf->contrat->enabled /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_ficheinter extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -68,7 +68,7 @@ class box_ficheinter extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 10) + public function loadBox($max = 10) { global $user, $langs, $db, $conf; @@ -176,7 +176,7 @@ class box_ficheinter extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 7cbefce2e32..01f62bc38c9 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_fournisseurs extends ModeleBoxes { - var $boxcode="lastsuppliers"; - var $boximg="object_company"; - var $boxlabel="BoxLastSuppliers"; - var $depends = array("fournisseur"); + public $boxcode="lastsuppliers"; + public $boximg="object_company"; + public $boxlabel="BoxLastSuppliers"; + public $depends = array("fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_fournisseurs extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -68,7 +68,7 @@ class box_fournisseurs extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; $langs->load("boxes"); @@ -160,7 +160,7 @@ class box_fournisseurs extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 5d8b9f736f5..ea973caf773 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -33,20 +33,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_goodcustomers extends ModeleBoxes { - var $boxcode="goodcustomers"; - var $boximg="object_company"; - var $boxlabel="BoxGoodCustomers"; - var $depends = array("societe"); + public $boxcode="goodcustomers"; + public $boximg="object_company"; + public $boxlabel="BoxGoodCustomers"; + public $depends = array("societe"); /** * @var DoliDB Database handler. */ public $db; - var $enabled = 1; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,7 +55,7 @@ class box_goodcustomers extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -74,7 +74,7 @@ class box_goodcustomers extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -171,7 +171,7 @@ class box_goodcustomers extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index e663c408281..4323661370c 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_permonth extends ModeleBoxes { - var $boxcode="invoicespermonth"; - var $boximg="object_bill"; - var $boxlabel="BoxCustomersInvoicesPerMonth"; - var $depends = array("facture"); + public $boxcode="invoicespermonth"; + public $boximg="object_bill"; + public $boxlabel="BoxCustomersInvoicesPerMonth"; + public $depends = array("facture"); /** * @var DoliDB Database handler. */ public $db; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -48,7 +48,7 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -76,14 +76,14 @@ class box_graph_invoices_permonth extends ModeleBoxes $text = $langs->trans("BoxCustomersInvoicesPerMonth", $max); $this->info_box_head = array( - 'text' => $text, - 'limit'=> dol_strlen($text), - 'graph'=> 1, - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'text' => $text, + 'limit'=> dol_strlen($text), + 'graph'=> 1, + 'sublink'=>'', + 'subtext'=>$langs->trans("Filter"), + 'subpicto'=>'filter.png', + 'subclass'=>'linkobject boxfilter', + 'target'=>'none' // Set '' to get target="_blank" ); $dir=''; // We don't need a path because image file will not be saved into disk @@ -275,7 +275,7 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index b8f020b4db7..bba5185c94a 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_supplier_permonth extends ModeleBoxes { - var $boxcode="invoicessupplierpermonth"; - var $boximg="object_bill"; - var $boxlabel="BoxSuppliersInvoicesPerMonth"; - var $depends = array("fournisseur"); + public $boxcode="invoicessupplierpermonth"; + public $boximg="object_bill"; + public $boxlabel="BoxSuppliersInvoicesPerMonth"; + public $depends = array("fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -48,7 +48,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -277,7 +277,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 98329df8379..b06558393aa 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_permonth extends ModeleBoxes { - var $boxcode="orderspermonth"; - var $boximg="object_order"; - var $boxlabel="BoxCustomersOrdersPerMonth"; - var $depends = array("commande"); + public $boxcode="orderspermonth"; + public $boximg="object_order"; + public $boxlabel="BoxCustomersOrdersPerMonth"; + public $depends = array("commande"); /** * @var DoliDB Database handler. */ public $db; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -48,7 +48,7 @@ class box_graph_orders_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_orders_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -273,14 +273,14 @@ class box_graph_orders_permonth extends ModeleBoxes } /** - * Method to show box + * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + * @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 string + * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index c3cdbcef412..9cb11aed7c1 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -48,7 +48,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -279,7 +279,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index e5ecb232ac1..d1c85cb2044 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -29,20 +29,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; */ class box_graph_product_distribution extends ModeleBoxes { - var $boxcode="productdistribution"; - var $boximg="object_product"; - var $boxlabel="BoxProductDistribution"; - var $depends = array("product|service","facture|propal|commande"); + public $boxcode="productdistribution"; + public $boximg="object_product"; + public $boxlabel="BoxProductDistribution"; + public $depends = array("product|service","facture|propal|commande"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -51,7 +51,7 @@ class box_graph_product_distribution extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user, $conf; @@ -70,7 +70,7 @@ class box_graph_product_distribution extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -416,7 +416,7 @@ class box_graph_product_distribution extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index b27229107e0..b21381473c2 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_propales_permonth extends ModeleBoxes { - var $boxcode="propalpermonth"; - var $boximg="object_propal"; - var $boxlabel="BoxProposalsPerMonth"; - var $depends = array("propal"); + public $boxcode="propalpermonth"; + public $boximg="object_propal"; + public $boxlabel="BoxProposalsPerMonth"; + public $depends = array("propal"); /** * @var DoliDB Database handler. */ public $db; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -48,7 +48,7 @@ class box_graph_propales_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_propales_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -283,7 +283,7 @@ class box_graph_propales_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index a0e0d55ebb1..e9f00049e04 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -195,7 +195,7 @@ class box_last_modified_ticket extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 45a4b5e8f02..352a10db682 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -192,7 +192,7 @@ class box_last_ticket extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 0536a2c34a0..8a5b90ae9d5 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -30,21 +30,21 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_lastlogin extends ModeleBoxes { - var $boxcode="lastlogin"; - var $boximg="object_user"; - var $boxlabel='BoxLoginInformation'; - var $depends = array("user"); + public $boxcode="lastlogin"; + public $boximg="object_user"; + public $boxlabel='BoxLoginInformation'; + public $depends = array("user"); /** * @var DoliDB Database handler. */ public $db; - - var $param; - var $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_lastlogin extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $conf; @@ -66,7 +66,7 @@ class box_lastlogin extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -75,7 +75,7 @@ class box_lastlogin extends ModeleBoxes 'text' => $textHead, 'limit'=> dol_strlen($textHead), ); - + $line=0; $this->info_box_contents[$line][0] = array( 'td' => '', @@ -86,7 +86,7 @@ class box_lastlogin extends ModeleBoxes 'text' => $user->getNomUrl(-1), 'asis' => 1 ); - + $line=1; $this->info_box_contents[$line][0] = array( 'td' => '', @@ -102,14 +102,14 @@ class box_lastlogin extends ModeleBoxes /** - * Method to show box + * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + * @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 + * @return void */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index e6ddca4ac1e..c0c82677d4e 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -32,21 +32,21 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_members extends ModeleBoxes { - var $boxcode="lastmembers"; - var $boximg="object_user"; - var $boxlabel="BoxLastMembers"; - var $depends = array("adherent"); + public $boxcode="lastmembers"; + public $boximg="object_user"; + public $boxlabel="BoxLastMembers"; + public $depends = array("adherent"); /** * @var DoliDB Database handler. */ public $db; - var $param; - var $enabled = 1; + public $param; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,7 +55,7 @@ class box_members extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -74,7 +74,7 @@ class box_members extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -178,7 +178,7 @@ class box_members extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index a44992832d9..38f9a73f57f 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -33,20 +33,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits extends ModeleBoxes { - var $boxcode="lastproducts"; - var $boximg="object_product"; - var $boxlabel="BoxLastProducts"; - var $depends = array("produit"); + public $boxcode="lastproducts"; + public $boximg="object_product"; + public $boxlabel="BoxLastProducts"; + public $depends = array("produit"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,7 +55,7 @@ class box_produits extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $conf, $user; @@ -73,7 +73,7 @@ class box_produits extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf, $hookmanager; @@ -218,16 +218,16 @@ class box_produits extends ModeleBoxes } } - /** - * Method to show 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 string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show 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 string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index e041c0ab197..d1381870338 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -35,20 +35,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits_alerte_stock extends ModeleBoxes { - var $boxcode="productsalertstock"; - var $boximg="object_product"; - var $boxlabel="BoxProductsAlertStock"; - var $depends = array("produit"); + public $boxcode="productsalertstock"; + public $boximg="object_product"; + public $boxlabel="BoxProductsAlertStock"; + public $depends = array("produit"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,7 +57,7 @@ class box_produits_alerte_stock extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf,$user; @@ -75,7 +75,7 @@ class box_produits_alerte_stock extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf, $hookmanager; @@ -241,7 +241,7 @@ class box_produits_alerte_stock extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index f08586ba9b0..86e092de7c3 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_project extends ModeleBoxes { - var $boxcode="project"; - var $boximg="object_projectpub"; - var $boxlabel; - //var $depends = array("projet"); + public $boxcode="project"; + public $boximg="object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); - /** + /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor @@ -51,7 +51,7 @@ class box_project extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $user, $langs; @@ -64,49 +64,45 @@ class box_project extends ModeleBoxes $this->hidden=! ($user->rights->projet->lire); } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - function loadBox($max = 5) - { - global $conf, $user, $langs, $db; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs, $db; - $this->max=$max; + $this->max=$max; - $totalMnt = 0; - $totalnb = 0; - $totalnbTask=0; + $totalMnt = 0; + $totalnb = 0; + $totalnbTask=0; - $textHead = $langs->trans("OpenedProjects"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $textHead = $langs->trans("OpenedProjects"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); - // list the summary of the orders - if ($user->rights->projet->lire) { + // list the summary of the orders + if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic = new Project($this->db); + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); - $socid=$user->societe_id; + $socid=0; + //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId=''; - if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId=''; + if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - if($user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=p.fk_soc"; - $sql.= " WHERE p.entity IN (".getEntity('project').')'; - if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " WHERE p.fk_statut = 1"; // Only open projects + if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql.= " ORDER BY p.datec DESC"; - //$sql.= $db->plimit($max, 0); + //$sql.= $db->plimit($max, 0); $result = $db->query($sql); @@ -124,7 +120,7 @@ class box_project extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => '', 'text' => $projectstatic->getNomUrl(1), - 'asis' => 1 + 'asis' => 1 ); $this->info_box_contents[$i][] = array( @@ -132,42 +128,42 @@ class box_project extends ModeleBoxes 'text' => $objp->title, ); - $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; - $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql.= " WHERE p.entity IN (".getEntity('project').')'; - $sql.=" AND p.rowid = ".$objp->rowid; - $resultTask = $db->query($sql); - if ($resultTask) { - $objTask = $db->fetch_object($resultTask); + $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; + $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; + $sql.= " WHERE p.entity IN (".getEntity('project').')'; + $sql.=" AND p.rowid = ".$objp->rowid; + $resultTask = $db->query($sql); + if ($resultTask) { + $objTask = $db->fetch_object($resultTask); $this->info_box_contents[$i][] = array( 'td' => 'class="right"', 'text' => $objTask->nb." ".$langs->trans("Tasks"), ); - if ($objTask->nb > 0) + if ($objTask->nb > 0) $this->info_box_contents[$i][] = array( 'td' => 'class="right"', 'text' => round($objTask->totprogress/$objTask->nb, 0)."%", ); - else - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - $totalnbTask += $objTask->nb; - } else { - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - } + else + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + $totalnbTask += $objTask->nb; + } else { + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + } - $i++; - } - if ($max < $num) - { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); - $i++; - } - } - } + $i++; + } + if ($max < $num) + { + $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $i++; + } + } + } - // Add the sum à the bottom of the boxes + // Add the sum à the bottom of the boxes $this->info_box_contents[$i][] = array( 'td' => '', 'text' => $langs->trans("Total")." ".$textHead, @@ -185,18 +181,18 @@ class box_project extends ModeleBoxes 'td' => '', 'text' => " ", ); - } + } - /** - * Method to show 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 string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show 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 string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 9176cb9f013..6bf6a2c2166 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_propales extends ModeleBoxes { - var $boxcode="lastpropals"; - var $boximg="object_propal"; - var $boxlabel="BoxLastProposals"; - var $depends = array("propal"); // conf->propal->enabled + public $boxcode="lastpropals"; + public $boximg="object_propal"; + public $boxlabel="BoxLastProposals"; + public $depends = array("propal"); // conf->propal->enabled /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,7 +54,7 @@ class box_propales extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -69,7 +69,7 @@ class box_propales extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -181,14 +181,14 @@ class box_propales extends ModeleBoxes } /** - * Method to show box + * Method to show box * - * @param array $head Array with properties of box title + * @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 string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index ab82dc7a490..7f5cc566f42 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -34,20 +34,20 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; */ class box_prospect extends ModeleBoxes { - var $boxcode="lastprospects"; - var $boximg="object_company"; - var $boxlabel="BoxLastProspects"; - var $depends = array("societe"); + public $boxcode="lastprospects"; + public $boximg="object_company"; + public $boxlabel="BoxLastProspects"; + public $depends = array("societe"); /** * @var DoliDB Database handler. */ public $db; - var $enabled = 1; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,7 +56,7 @@ class box_prospect extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -74,7 +74,7 @@ class box_prospect extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -177,7 +177,7 @@ class box_prospect extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 00193fc427e..68959b15056 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_services_contracts extends ModeleBoxes { - var $boxcode="lastproductsincontract"; - var $boximg="object_product"; - var $boxlabel="BoxLastProductsInContract"; - var $depends = array("service","contrat"); + public $boxcode="lastproductsincontract"; + public $boximg="object_product"; + public $boxlabel="BoxLastProductsInContract"; + public $depends = array("service","contrat"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,7 +54,7 @@ class box_services_contracts extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -69,7 +69,7 @@ class box_services_contracts extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -249,8 +249,8 @@ class box_services_contracts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 0c5d1a01632..738d6af078f 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_services_expired extends ModeleBoxes { - var $boxcode="expiredservices"; // id of box - var $boximg="object_contract"; - var $boxlabel="BoxOldestExpiredServices"; - var $depends = array("contrat"); // conf->propal->enabled + public $boxcode="expiredservices"; // id of box + public $boximg="object_contract"; + public $boxlabel="BoxOldestExpiredServices"; + public $depends = array("contrat"); // conf->propal->enabled /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,7 +52,7 @@ class box_services_expired extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -67,7 +67,7 @@ class box_services_expired extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -189,14 +189,14 @@ class box_services_expired extends ModeleBoxes } /** - * Method to show box + * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + * @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 string + * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index f9a47fe8c83..34316cd1ad1 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -31,19 +31,19 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_supplier_orders extends ModeleBoxes { - var $boxcode = "latestsupplierorders"; - var $boximg = "object_order"; - var $boxlabel="BoxLatestSupplierOrders"; - var $depends = array("fournisseur"); + public $boxcode = "latestsupplierorders"; + public $boximg = "object_order"; + public $boxlabel="BoxLatestSupplierOrders"; + public $depends = array("fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,7 +52,7 @@ class box_supplier_orders extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -67,7 +67,7 @@ class box_supplier_orders extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; $langs->load("boxes"); @@ -177,14 +177,14 @@ class box_supplier_orders extends ModeleBoxes } /** - * Method to show box + * Method to show 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 string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + * @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 string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 181de1f8696..d07792dc991 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -54,7 +54,7 @@ class box_task extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $user, $langs; @@ -73,7 +73,7 @@ class box_task extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -150,7 +150,7 @@ class box_task extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 4e715014992..79d4f17d8ee 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -115,7 +115,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { $this->db=$db; } @@ -125,7 +125,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * * @return string Error message */ - function error() + public function error() { return $this->error; } @@ -138,7 +138,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { global $conf; @@ -182,7 +182,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * * @return string */ - function outputBox($head = null, $contents = null) + public function outputBox($head = null, $contents = null) { global $langs, $user, $conf; @@ -204,7 +204,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { global $langs, $user, $conf; @@ -385,7 +385,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * @param array $forcedirwidget null=All default directories. This parameter is used by modulebuilder module only. * @return array Array list of widget */ - static function getWidgetsList($forcedirwidget = null) + public static function getWidgetsList($forcedirwidget = null) { global $conf, $langs, $db; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c64b408336c..e23b32c5fb7 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -40,53 +40,53 @@ class CMailFile public $sendmode; public $sendsetup; - var $subject; // Topic: Subject of email - var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). + public $subject; // Topic: Subject of email + public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Return-Path: Email where to send bounds. - var $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) - var $errors_to; // Errors-To: Email where to send errors. - var $addr_to; - var $addr_cc; - var $addr_bcc; - var $trackid; + public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) + public $errors_to; // Errors-To: Email where to send errors. + public $addr_to; + public $addr_cc; + public $addr_bcc; + public $trackid; - var $mixed_boundary; - var $related_boundary; - var $alternative_boundary; - var $deliveryreceipt; + public $mixed_boundary; + public $related_boundary; + public $alternative_boundary; + public $deliveryreceipt; - var $eol; - var $eol2; + public $eol; + public $eol2; /** * @var string Error code (or message) */ public $error=''; - var $smtps; // Contains SMTPs object (if this method is used) - var $phpmailer; // Contains PHPMailer object (if this method is used) + public $smtps; // Contains SMTPs object (if this method is used) + public $phpmailer; // Contains PHPMailer object (if this method is used) /** * @var string CSS */ public $css; //! Defined css style for body background - var $styleCSS; + public $styleCSS; //! Defined background directly in body tag - var $bodyCSS; + public $bodyCSS; - var $headers; - var $message; + public $headers; + public $message; // Image - var $html; - var $image_boundary; - var $atleastoneimage=0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). - var $html_images=array(); - var $images_encoded=array(); - var $image_types = array( + public $html; + public $image_boundary; + public $atleastoneimage=0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). + public $html_images=array(); + public $images_encoded=array(); + public $image_types = array( 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', @@ -119,7 +119,7 @@ class CMailFile * @param string $sendcontext 'standard', 'emailing', ... (used to define with sending mode and parameters to use) * @param string $replyto Reply-to email (will be set to same value than From by default if not provided) */ - function __construct($subject, $to, $from, $msg, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = 0, $errors_to = '', $css = '', $trackid = '', $moreinheader = '', $sendcontext = 'standard', $replyto = '') + public function __construct($subject, $to, $from, $msg, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = 0, $errors_to = '', $css = '', $trackid = '', $moreinheader = '', $sendcontext = 'standard', $replyto = '') { global $conf, $dolibarr_main_data_root; @@ -352,71 +352,55 @@ class CMailFile elseif ($this->sendmode == 'swiftmailer') { // Use Swift Mailer library - // ------------------------------------------ - $host = dol_getprefix('email'); require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/DomainPart.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/EmailValidation.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php'; + // egulias autoloader lib + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/classes/Swift/InputByteStream.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/classes/Swift/Signer.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php'; - //require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/classes/Swift/SignedMessage.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; - // Create the message - //$this->message = Swift_Message::newInstance(); - $this->message = new Swift_Message(); + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; + + // Create the message + //$this->message = Swift_Message::newInstance(); + $this->message = new Swift_Message(); //$this->message = new Swift_SignedMessage(); // Adding a trackid header to a message - $headers = $this->message->getHeaders(); - $headers->addTextHeader('X-Dolibarr-TRACKID', $trackid . '@' . $host); - $headerID = time() . '.swiftmailer-dolibarr-' . $trackid . '@' . $host; - $msgid = $headers->get('Message-ID'); - $msgid->setId($headerID); - $headers->addIdHeader('References', $headerID); - // TODO if (! empty($moreinheader)) ... + $headers = $this->message->getHeaders(); + $headers->addTextHeader('X-Dolibarr-TRACKID', $trackid . '@' . $host); + $headerID = time() . '.swiftmailer-dolibarr-' . $trackid . '@' . $host; + $msgid = $headers->get('Message-ID'); + $msgid->setId($headerID); + $headers->addIdHeader('References', $headerID); + // TODO if (! empty($moreinheader)) ... - // Give the message a subject - try { - $result = $this->message->setSubject($subject); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } + // Give the message a subject + try { + $result = $this->message->setSubject($subject); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } - // Set the From address with an associative array - //$this->message->setFrom(array('john@doe.com' => 'John Doe')); - if (! empty($from)) { + // Set the From address with an associative array + //$this->message->setFrom(array('john@doe.com' => 'John Doe')); + if (! empty($from)) { try { - $result = $this->message->setFrom($this->getArrayAddress($from)); + $result = $this->message->setFrom($this->getArrayAddress($from)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } } - // Set the To addresses with an associative array - if (! empty($to)) { + // Set the To addresses with an associative array + if (! empty($to)) { try { - $result = $this->message->setTo($this->getArrayAddress($to)); + $result = $this->message->setTo($this->getArrayAddress($to)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } } - if (! empty($replyto)) { + if (! empty($replyto)) { try { $result = $this->message->SetReplyTo($this->getArrayAddress($replyto)); } catch (Exception $e) { @@ -424,16 +408,14 @@ class CMailFile } } - try { - $result = $this->message->setCharSet($conf->file->character_set_client); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } + try { + $result = $this->message->setCharSet($conf->file->character_set_client); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } - if (! empty($this->html)) - { - if (!empty($css)) - { + if (! empty($this->html)) { + if (!empty($css)) { $this->css = $css; $this->buildCSS(); } @@ -493,7 +475,7 @@ class CMailFile * * @return boolean True if mail sent, false otherwise */ - function sendfile() + public function sendfile() { global $conf,$db,$langs; @@ -752,9 +734,9 @@ class CMailFile } elseif ($this->sendmode == 'swiftmailer') { - // Use Swift Mailer library - // ------------------------------------------ - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; + // Use Swift Mailer library + // ------------------------------------------ + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; // Clean parameters if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver=ini_get('SMTP'); @@ -844,20 +826,20 @@ class CMailFile * @param string $stringtoencode String to encode * @return string string encoded */ - static function encodetorfc2822($stringtoencode) + public static function encodetorfc2822($stringtoencode) { global $conf; return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?='; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read a file on disk and return encoded content for emails (mode = 'mail') * * @param string $sourcefile Path to file to encode * @return int <0 if KO, encoded string if OK */ - function _encode_file($sourcefile) + private function _encode_file($sourcefile) { // phpcs:enable $newsourcefile=dol_osencode($sourcefile); @@ -877,7 +859,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write content of a SMTP request into a dump file (mode = all) * Used for debugging. @@ -885,7 +867,7 @@ class CMailFile * * @return void */ - function dump_mail() + public function dump_mail() { // phpcs:enable global $conf,$dolibarr_main_data_root; @@ -923,7 +905,7 @@ class CMailFile * @param string $msg String * @return string Completed string */ - function checkIfHTML($msg) + public function checkIfHTML($msg) { if (!preg_match('/^[\s\t]*css)) { @@ -972,13 +954,13 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create SMTP headers (mode = 'mail') * * @return string headers */ - function write_smtpheaders() + public function write_smtpheaders() { // phpcs:enable global $conf; @@ -1036,7 +1018,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create header MIME (mode = 'mail') * @@ -1044,7 +1026,7 @@ class CMailFile * @param array $mimefilename_list Array of mime types * @return string mime headers */ - function write_mimeheaders($filename_list, $mimefilename_list) + public function write_mimeheaders($filename_list, $mimefilename_list) { // phpcs:enable $mimedone=0; @@ -1067,14 +1049,14 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return email content (mode = 'mail') * * @param string $msgtext Message string * @return string String content */ - function write_body($msgtext) + public function write_body($msgtext) { // phpcs:enable global $conf; @@ -1169,7 +1151,7 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach file to email (mode = 'mail') * @@ -1178,7 +1160,7 @@ class CMailFile * @param array $mimefilename_list Tableau * @return string Chaine fichiers encodes */ - function write_files($filename_list, $mimetype_list, $mimefilename_list) + public function write_files($filename_list, $mimetype_list, $mimefilename_list) { // phpcs:enable $out = ''; @@ -1218,14 +1200,14 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach an image to email (mode = 'mail') * * @param array $images_list Array of array image * @return string Chaine images encodees */ - function write_images($images_list) + public function write_images($images_list) { // phpcs:enable $out = ''; @@ -1251,7 +1233,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Try to create a socket connection * @@ -1259,7 +1241,7 @@ class CMailFile * @param int $port Example: 25, 465 * @return int Socket id if ok, 0 if KO */ - function check_server_port($host, $port) + public function check_server_port($host, $port) { // phpcs:enable global $conf; @@ -1315,7 +1297,7 @@ class CMailFile return $_retVal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This function has been modified as provided by SirSir to allow multiline responses when * using SMTP Extensions. @@ -1324,7 +1306,7 @@ class CMailFile * @param string $response Response string * @return boolean true if success */ - function server_parse($socket, $response) + public function server_parse($socket, $response) { // phpcs:enable $_retVal = true; // Indicates if Object was created or not @@ -1354,7 +1336,7 @@ class CMailFile * @param string $images_dir Location of physical images files * @return int >0 if OK, <0 if KO */ - function findHtmlImages($images_dir) + public function findHtmlImages($images_dir) { // Build the list of image extensions $extensions = array_keys($this->image_types); @@ -1456,7 +1438,7 @@ class CMailFile * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' * If format 4: 'John Doe' or 'john@doe.com' if no label exists */ - static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) + public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) { global $conf; @@ -1523,7 +1505,7 @@ class CMailFile * @param string $address Example: 'John Doe , Alan Smith ' or 'john@doe.com, alan@smith.com' * @return array array of email => name */ - function getArrayAddress($address) + public function getArrayAddress($address) { global $conf; diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 8bd70d8e063..cd5c9ae28b7 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -59,7 +59,7 @@ class CSMSFile * @param int $priority Priority * @param int $class Class */ - function __construct($to, $from, $msg, $deliveryreceipt = 0, $deferred = 0, $priority = 3, $class = 1) + public function __construct($to, $from, $msg, $deliveryreceipt = 0, $deferred = 0, $priority = 3, $class = 1) { global $conf; @@ -94,7 +94,7 @@ class CSMSFile * * @return boolean True if sms sent, false otherwise */ - function sendfile() + public function sendfile() { global $conf; @@ -195,17 +195,17 @@ class CSMSFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Write content of a SendSms request into a dump file (mode = all) - * Used for debugging. - * - * @return void - */ - function dump_sms() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Write content of a SendSms request into a dump file (mode = all) + * Used for debugging. + * + * @return void + */ + public function dump_sms() + { // phpcs:enable - global $conf,$dolibarr_main_data_root; + global $conf,$dolibarr_main_data_root; if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir { @@ -226,7 +226,7 @@ class CSMSFile } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write content of a SendSms result into a dump file (mode = all) * Used for debugging. @@ -234,7 +234,7 @@ class CSMSFile * @param int $result Result of sms sending * @return void */ - function dump_sms_result($result) + public function dump_sms_result($result) { // phpcs:enable global $conf,$dolibarr_main_data_root; diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index dc0490285be..55bd3a8381d 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -55,12 +55,12 @@ class AntiVir * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Scan a file with antivirus. * This function runs the command defined in setup. This antivirus command must return 0 if OK. @@ -69,7 +69,7 @@ class AntiVir * @param string $file File to scan * @return int <0 if KO (-98 if error, -99 if virus), 0 if OK */ - function dol_avscan_file($file) + public function dol_avscan_file($file) { // phpcs:enable global $conf; @@ -153,7 +153,7 @@ class AntiVir * @param string $file File to scan * @return string Full command line to run */ - function getCliCommand($file) + public function getCliCommand($file) { global $conf; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 0250a138fb8..1351f0ea3c7 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -60,7 +60,7 @@ class Canvas * @param DoliDB $db Database handler * @param string $actiontype Action type ('create', 'view', 'edit', 'list') */ - function __construct($db, $actiontype = 'view') + public function __construct($db, $actiontype = 'view') { $this->db = $db; @@ -91,7 +91,7 @@ class Canvas * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) * @return void */ - function getCanvas($module, $card, $canvas) + public function getCanvas($module, $card, $canvas) { global $conf, $langs; @@ -133,7 +133,7 @@ class Canvas //print ' => template_dir='.$this->template_dir.'
'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Shared method for canvas to assign values for templates * @@ -142,7 +142,7 @@ class Canvas * @param string $ref Object ref (if id not provided) * @return void */ - function assign_values(&$action = 'view', $id = 0, $ref = '') + public function assign_values(&$action = 'view', $id = 0, $ref = '') { // phpcs:enable if (method_exists($this->control, 'assign_values')) $this->control->assign_values($action, $id, $ref); @@ -154,7 +154,7 @@ class Canvas * @param string $action Action code * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ - function displayCanvasExists($action) + public function displayCanvasExists($action) { if (empty($this->template_dir)) return 0; @@ -162,7 +162,7 @@ class Canvas else return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display a canvas page. This will include the template for output. * Variables used by templates may have been defined or loaded before into the assign_values function. @@ -170,7 +170,7 @@ class Canvas * @param string $action Action code * @return void */ - function display_canvas($action) + public function display_canvas($action) { // phpcs:enable global $db, $conf, $langs, $user, $canvas; @@ -188,7 +188,7 @@ class Canvas * * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) */ - function hasActions() + public function hasActions() { return (is_object($this->control)); } @@ -204,7 +204,7 @@ class Canvas * @return mixed Return return code of doActions of canvas * @see http://wiki.dolibarr.org/index.php/Canvas_development */ - function doActions(&$action = 'view', $id = 0) + public function doActions(&$action = 'view', $id = 0) { if (method_exists($this->control, 'doActions')) { diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index e93af622a27..a97d992bf89 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -73,7 +73,7 @@ class Ccountry // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -86,7 +86,7 @@ class Ccountry // 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; @@ -165,7 +165,7 @@ class Ccountry // extends CommonObject * @param string $code Code * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($id, $code = '') + public function fetch($id, $code = '') { global $langs; $sql = "SELECT"; @@ -214,7 +214,7 @@ class Ccountry // 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; @@ -285,7 +285,7 @@ class Ccountry // 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; diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 6d00b4b8d8d..502ba924513 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -69,7 +69,7 @@ class Comment extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -82,7 +82,7 @@ class Comment 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; @@ -155,7 +155,7 @@ class Comment extends CommonObject * @param int $ref ref object * @return int <0 if KO, 0 if not found, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $langs; @@ -213,7 +213,7 @@ class Comment extends CommonObject * @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; @@ -278,7 +278,7 @@ class Comment 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; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index c1b483efe8c..d4a89c18e19 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -61,7 +61,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -69,7 +69,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_user($user, $outputlangs) + public function get_substitutionarray_user($user, $outputlangs) { // phpcs:enable global $conf; @@ -99,7 +99,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -107,7 +107,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_mysoc($mysoc, $outputlangs) + public function get_substitutionarray_mysoc($mysoc, $outputlangs) { // phpcs:enable global $conf; @@ -159,7 +159,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -167,7 +167,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_thirdparty($object, $outputlangs) + public function get_substitutionarray_thirdparty($object, $outputlangs) { // phpcs:enable global $conf; @@ -240,7 +240,7 @@ abstract class CommonDocGenerator return $array_thirdparty; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -249,7 +249,7 @@ abstract class CommonDocGenerator * @param array $array_key Name of the key for return array * @return array Array of substitution key->code */ - function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -314,14 +314,14 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_other($outputlangs) + public function get_substitutionarray_other($outputlangs) { // phpcs:enable global $conf; @@ -352,7 +352,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -361,7 +361,7 @@ abstract class CommonDocGenerator * @param string $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -518,7 +518,7 @@ abstract class CommonDocGenerator return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -526,7 +526,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_lines($line, $outputlangs) + public function get_substitutionarray_lines($line, $outputlangs) { // phpcs:enable global $conf; @@ -599,7 +599,7 @@ abstract class CommonDocGenerator return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -608,7 +608,7 @@ abstract class CommonDocGenerator * @param array $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -662,7 +662,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -670,7 +670,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Lang object to use for output * @return array Substitution array */ - function get_substitutionarray_shipment_lines($line, $outputlangs) + public function get_substitutionarray_shipment_lines($line, $outputlangs) { // phpcs:enable global $conf; @@ -683,7 +683,7 @@ abstract class CommonDocGenerator 'line_desc'=>$line->desc, 'line_vatrate'=>vatrate($line->tva_tx, true, $line->info_bits), 'line_up'=>price($line->subprice), - 'line_total_up'=>price($line->subprice * $line->qty), + 'line_total_up'=>price($line->subprice * $line->qty), 'line_qty'=>$line->qty, 'line_qty_shipped'=>$line->qty_shipped, 'line_qty_asked'=>$line->qty_asked, @@ -711,7 +711,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -720,7 +720,7 @@ abstract class CommonDocGenerator * @param boolean $recursive Want to fetch child array or child object * @return array Array of substitution key->code */ - function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) + public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) { // phpcs:enable $array_other = array(); @@ -740,7 +740,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fill array with couple extrafield key => extrafield value * @@ -751,8 +751,8 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Lang object to use for output * @return array Substitution array */ - function fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs) - { + public function fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs) + { // phpcs:enable global $conf; foreach($extrafields->attribute_label as $key=>$label) @@ -838,7 +838,7 @@ abstract class CommonDocGenerator * @param int $hidebottom Hide bottom * @return void */ - function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) + public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) { if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); $pdf->line($x+$l, $y, $x+$l, $y+$h); @@ -848,13 +848,13 @@ abstract class CommonDocGenerator /** - * uasort callback function to Sort colums fields + * uasort callback function to Sort colums fields * - * @param array $a PDF lines array fields configs - * @param array $b PDF lines array fields configs - * @return int Return compare result + * @param array $a PDF lines array fields configs + * @param array $b PDF lines array fields configs + * @return int Return compare result */ - function columnSort($a, $b) + public function columnSort($a, $b) { if(empty($a['rank'])){ $a['rank'] = 0; } if(empty($b['rank'])){ $b['rank'] = 0; } @@ -874,7 +874,7 @@ abstract class CommonDocGenerator * @param int $hideref Do not show ref * @return null */ - function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $conf; @@ -950,7 +950,7 @@ abstract class CommonDocGenerator * @param string $colKey the column key * @return float width in mm */ - function getColumnContentWidth($colKey) + public function getColumnContentWidth($colKey) { $colDef = $this->cols[$colKey]; return $colDef['width'] - $colDef['content']['padding'][3] - $colDef['content']['padding'][1]; @@ -958,12 +958,12 @@ abstract class CommonDocGenerator /** - * get column content X (abscissa) left position from column key + * get column content X (abscissa) left position from column key * - * @param string $colKey the column key - * @return float X position in mm + * @param string $colKey the column key + * @return float X position in mm */ - function getColumnContentXStart($colKey) + public function getColumnContentXStart($colKey) { $colDef = $this->cols[$colKey]; return $colDef['xStartPos'] + $colDef['content']['padding'][3]; @@ -975,22 +975,22 @@ abstract class CommonDocGenerator * @param string $colKey the column key * @return int rank on success and -1 on error */ - function getColumnRank($colKey) + public function getColumnRank($colKey) { if(!isset($this->cols[$colKey]['rank'])) return -1; return $this->cols[$colKey]['rank']; } /** - * get column position rank from column key + * get column position rank from column key * - * @param string $newColKey the new column key - * @param array $defArray a single column definition array - * @param string $targetCol target column used to place the new column beside - * @param bool $insertAfterTarget insert before or after target column ? - * @return int new rank on success and -1 on error + * @param string $newColKey the new column key + * @param array $defArray a single column definition array + * @param string $targetCol target column used to place the new column beside + * @param bool $insertAfterTarget insert before or after target column ? + * @return int new rank on success and -1 on error */ - function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) + public function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) { // prepare wanted rank $rank = -1; @@ -1033,7 +1033,7 @@ abstract class CommonDocGenerator * @param string $columnText column text * @return int new rank on success and -1 on error */ - function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') + public function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') { global $hookmanager; @@ -1055,12 +1055,12 @@ abstract class CommonDocGenerator /** - * get column status from column key + * get column status from column key * - * @param string $colKey the column key - * @return float width in mm + * @param string $colKey the column key + * @return float width in mm */ - function getColumnStatus($colKey) + public function getColumnStatus($colKey) { if( !empty($this->cols[$colKey]['status'])){ return true; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 7e8c9002042..5926f954a46 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -97,7 +97,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return double Remain of amount to pay */ - function getRemainToPay($multicurrency = 0) + public function getRemainToPay($multicurrency = 0) { $alreadypaid=0; $alreadypaid+=$this->getSommePaiement($multicurrency); @@ -112,7 +112,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int Amount of payment already done, <0 if KO */ - function getSommePaiement($multicurrency = 0) + public function getSommePaiement($multicurrency = 0) { $table='paiement_facture'; $field='fk_facture'; @@ -149,7 +149,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of deposits amount otherwise */ - function getSumDepositsUsed($multicurrency = 0) + public function getSumDepositsUsed($multicurrency = 0) { if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { @@ -178,7 +178,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumCreditNotesUsed($multicurrency = 0) + public function getSumCreditNotesUsed($multicurrency = 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -200,7 +200,7 @@ abstract class CommonInvoice extends CommonObject * * @return array Tableau d'id de factures avoirs */ - function getListIdAvoirFromInvoice() + public function getListIdAvoirFromInvoice() { $idarray=array(); @@ -233,7 +233,7 @@ abstract class CommonInvoice extends CommonObject * @param string $option filtre sur statut ('', 'validated', ...) * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon */ - function getIdReplacingInvoice($option = '') + public function getIdReplacingInvoice($option = '') { $sql = 'SELECT rowid'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; @@ -274,7 +274,7 @@ abstract class CommonInvoice extends CommonObject * @param string $filtertype 1 to filter on type of payment == 'PRE' * @return array Array with list of payments */ - function getListOfPayments($filtertype = '') + public function getListOfPayments($filtertype = '') { $retarray=array(); @@ -325,7 +325,7 @@ abstract class CommonInvoice extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if an invoice can be deleted * Rule is: @@ -339,8 +339,8 @@ abstract class CommonInvoice extends CommonObject * * @return int <=0 if no, >0 if yes */ - function is_erasable() - { + public function is_erasable() + { // phpcs:enable global $conf; @@ -428,7 +428,7 @@ abstract class CommonInvoice extends CommonObject * * @return string Label of type of invoice */ - function getLibType() + public function getLibType() { global $langs; if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); @@ -447,12 +447,12 @@ abstract class CommonInvoice extends CommonObject * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label of status */ - function getLibStatut($mode = 0, $alreadypaid = -1) + public function getLibStatut($mode = 0, $alreadypaid = -1) { return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -463,18 +463,16 @@ abstract class CommonInvoice extends CommonObject * @param int $type Type invoice * @return string Label of status */ - function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) + public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) { // phpcs:enable global $langs; $langs->load('bills'); //print "$paye,$status,$mode,$alreadypaid,$type"; - if ($mode == 0) - { + if ($mode == 0) { $prefix=''; - if (! $paye) - { + if (! $paye) { if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); @@ -585,7 +583,7 @@ abstract class CommonInvoice extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi une date limite de reglement de facture en fonction des * conditions de reglements de la facture et date de facturation. @@ -593,7 +591,7 @@ abstract class CommonInvoice extends CommonObject * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. * @return date Date limite de reglement si ok, <0 si ko */ - function calculate_date_lim_reglement($cond_reglement = 0) + public function calculate_date_lim_reglement($cond_reglement = 0) { // phpcs:enable if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1f86d60598c..f6232fd9394 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -423,7 +423,7 @@ abstract class CommonObject * @param string $ref_ext Ref ext of object to check * @return int <0 if KO, 0 if OK but not found, >0 if OK and exists */ - static function isExistingObject($element, $id, $ref = '', $ref_ext = '') + public static function isExistingObject($element, $id, $ref = '', $ref_ext = '') { global $db,$conf; @@ -457,7 +457,7 @@ abstract class CommonObject * * @return string String with errors */ - function errorsToString() + public function errorsToString() { return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ', $this->errors)):''); } @@ -468,7 +468,7 @@ abstract class CommonObject * @param string $objref Customer ref * @return string Customer ref formated */ - function getFormatedCustomerRef($objref) + public function getFormatedCustomerRef($objref) { global $hookmanager; @@ -488,7 +488,7 @@ abstract class CommonObject * @param string $objref Supplier ref * @return string Supplier ref formated */ - function getFormatedSupplierRef($objref) + public function getFormatedSupplierRef($objref) { global $hookmanager; @@ -511,7 +511,7 @@ abstract class CommonObject * @param int $maxlen Maximum length * @return string String with full name */ - function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) + public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) { //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."
\n"; $lastname=$this->lastname; @@ -538,7 +538,7 @@ abstract class CommonObject * @param int $withregion 1=Add region into address string * @return string Full address string */ - function getFullAddress($withcountry = 0, $sep = "\n", $withregion = 0) + public function getFullAddress($withcountry = 0, $sep = "\n", $withregion = 0) { if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country))) { @@ -569,7 +569,7 @@ abstract class CommonObject * @param Object $object Object (thirdparty, thirdparty of contact for contact, null for a member) * @return string Full address string */ - function getBannerAddress($htmlkey, $object) + public function getBannerAddress($htmlkey, $object) { global $conf, $langs; @@ -672,6 +672,8 @@ abstract class CommonObject $outdone++; if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); $outdone++; + if ($this->linkedin) $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); + $outdone++; } $out.=''; @@ -688,7 +690,7 @@ abstract class CommonObject * @param int $relativelink 0=Return full external link, 1=Return link relative to root of file * @return string Link or empty string if there is no download link */ - function getLastMainDocLink($modulepart, $initsharekey = 0, $relativelink = 0) + public function getLastMainDocLink($modulepart, $initsharekey = 0, $relativelink = 0) { global $user, $dolibarr_main_url_root; @@ -775,7 +777,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a link between element $this->element and a contact * @@ -785,7 +787,7 @@ abstract class CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) + public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) { // phpcs:enable global $user,$langs; @@ -899,7 +901,7 @@ abstract class CommonObject } else return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Copy contact from one element to current * @@ -907,7 +909,7 @@ abstract class CommonObject * @param string $source Nature of contact ('internal' or 'external') * @return int >0 if OK, <0 if KO */ - function copy_linked_contact($objFrom, $source = 'internal') + public function copy_linked_contact($objFrom, $source = 'internal') { // phpcs:enable $contacts = $objFrom->liste_contact(-1, $source); @@ -922,7 +924,7 @@ abstract class CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a link to contact line * @@ -932,7 +934,7 @@ abstract class CommonObject * @param int $fk_socpeople Id of soc_people to update (not modified if 0) * @return int <0 if KO, >= 0 if OK */ - function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0) + public function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0) { // phpcs:enable // Insert into database @@ -953,7 +955,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to contact line * @@ -961,7 +963,7 @@ abstract class CommonObject * @param int $notrigger Disable all triggers * @return int >0 if OK, <0 if KO */ - function delete_contact($rowid, $notrigger = 0) + public function delete_contact($rowid, $notrigger = 0) { // phpcs:enable global $user; @@ -992,7 +994,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete all links between an object $this and all its contacts * @@ -1000,7 +1002,7 @@ abstract class CommonObject * @param string $code Type of contact (code or id) * @return int >0 if OK, <0 if KO */ - function delete_linked_contact($source = '', $code = '') + public function delete_linked_contact($source = '', $code = '') { // phpcs:enable $temp = array(); @@ -1029,7 +1031,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get array of all contacts for an object * @@ -1039,7 +1041,7 @@ abstract class CommonObject * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) * @return array|int Array of contacts, -1 if error */ - function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '') + public function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '') { // phpcs:enable global $langs; @@ -1109,7 +1111,7 @@ abstract class CommonObject * @param int $rowid Id of link between object and contact * @return int <0 if KO, >=0 if OK */ - function swapContactStatus($rowid) + public function swapContactStatus($rowid) { $sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,"; $sql.= " tc.code, tc.libelle"; @@ -1138,7 +1140,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array with list of possible values for type of contacts * @@ -1149,7 +1151,7 @@ abstract class CommonObject * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') * @return array Array list of type of contacts (id->label if option=0, code->label if option=1) */ - function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') + public function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') { // phpcs:enable global $langs; @@ -1203,7 +1205,7 @@ abstract class CommonObject * @param int $status limited to a certain status * @return array List of id for such contacts */ - function getIdContact($source, $code, $status = 0) + public function getIdContact($source, $code, $status = 0) { global $conf; @@ -1256,14 +1258,14 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object contact with id=$this->contactid into $this->contact * * @param int $contactid Id du contact. Use this->contactid if empty. * @return int <0 if KO, >0 if OK */ - function fetch_contact($contactid = null) + public function fetch_contact($contactid = null) { // phpcs:enable if (empty($contactid)) $contactid=$this->contactid; @@ -1277,14 +1279,14 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty * * @param int $force_thirdparty_id Force thirdparty id * @return int <0 if KO, >0 if OK */ - function fetch_thirdparty($force_thirdparty_id = 0) + public function fetch_thirdparty($force_thirdparty_id = 0) { // phpcs:enable global $conf; @@ -1340,7 +1342,7 @@ abstract class CommonObject return $this->fetch($result->rowid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load data for barcode into properties ->barcode_type* * Properties ->barcode_type that is id of barcode. Type is used to find other properties, but @@ -1348,7 +1350,7 @@ abstract class CommonObject * * @return int <0 if KO, 0 if can't guess type of barcode (ISBN, EAN13...), >0 if OK (all barcode properties loaded) */ - function fetch_barcode() + public function fetch_barcode() { // phpcs:enable global $conf; @@ -1391,13 +1393,13 @@ abstract class CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the project with id $this->fk_project into this->project * * @return int <0 if KO, >=0 if OK */ - function fetch_projet() + public function fetch_projet() { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -1413,13 +1415,13 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the product with id $this->fk_product into this->product * * @return int <0 if KO, >=0 if OK */ - function fetch_product() + public function fetch_product() { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -1433,14 +1435,14 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the user with id $userid into this->user * * @param int $userid Id du contact * @return int <0 if KO, >0 if OK */ - function fetch_user($userid) + public function fetch_user($userid) { // phpcs:enable $user = new User($this->db); @@ -1449,13 +1451,13 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read linked origin object * * @return void */ - function fetch_origin() + public function fetch_origin() { // phpcs:enable if ($this->origin == 'shipping') $this->origin = 'expedition'; @@ -1478,7 +1480,7 @@ abstract class CommonObject * @param string $element Element name * @return int <0 if KO, >0 if OK */ - function fetchObjectFrom($table, $field, $key, $element = null) + public function fetchObjectFrom($table, $field, $key, $element = null) { global $conf; @@ -1514,7 +1516,7 @@ abstract class CommonObject * @param string $field Field selected * @return int <0 if KO, >0 if OK */ - function getValueFrom($table, $id, $field) + public function getValueFrom($table, $id, $field) { $result=false; if (!empty($id) && !empty($field) && !empty($table)) { @@ -1548,7 +1550,7 @@ abstract class CommonObject * @return int <0 if KO, >0 if OK * @see updateExtraField() */ - function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif') + public function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif') { global $user,$langs,$conf; @@ -1618,7 +1620,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load properties id_previous and id_next by comparing $fieldid with $this->ref * @@ -1627,7 +1629,7 @@ abstract class CommonObject * @param int $nodbprefix Do not include DB prefix to forge table name * @return int <0 if KO, >0 if OK */ - function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) + public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) { // phpcs:enable global $conf, $user; @@ -1751,7 +1753,7 @@ abstract class CommonObject * @return array Array of id of contacts (if source=external or internal) * Array of id of third parties with at least one contact on object (if source=thirdparty) */ - function getListContactId($source = 'external') + public function getListContactId($source = 'external') { $contactAlreadySelected = array(); $tab = $this->liste_contact(-1, $source); @@ -1773,7 +1775,7 @@ abstract class CommonObject * @param int $projectid Project id to link element to * @return int <0 if KO, >0 if OK */ - function setProject($projectid) + public function setProject($projectid) { if (! $this->table_element) { @@ -1814,7 +1816,7 @@ abstract class CommonObject * @param int $id Id of new payment method * @return int >0 if OK, <0 if KO */ - function setPaymentMethods($id) + public function setPaymentMethods($id) { dol_syslog(get_class($this).'::setPaymentMethods('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -1856,7 +1858,7 @@ abstract class CommonObject * @param string $code multicurrency code * @return int >0 if OK, <0 if KO */ - function setMulticurrencyCode($code) + public function setMulticurrencyCode($code) { dol_syslog(get_class($this).'::setMulticurrencyCode('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -1898,7 +1900,7 @@ abstract class CommonObject * @param int $mode mode 1 : amounts in company currency will be recalculated, mode 2 : amounts in foreign currency * @return int >0 if OK, <0 if KO */ - function setMulticurrencyRate($rate, $mode = 1) + public function setMulticurrencyRate($rate, $mode = 1) { dol_syslog(get_class($this).'::setMulticurrencyRate('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -1999,7 +2001,7 @@ abstract class CommonObject * @param int $id Id of new payment terms * @return int >0 if OK, <0 if KO */ - function setPaymentTerms($id) + public function setPaymentTerms($id) { dol_syslog(get_class($this).'::setPaymentTerms('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -2043,7 +2045,7 @@ abstract class CommonObject * @param int $id Address id * @return int <0 si ko, >0 si ok */ - function setDeliveryAddress($id) + public function setDeliveryAddress($id) { $fieldname = 'fk_delivery_address'; if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; @@ -2074,7 +2076,7 @@ abstract class CommonObject * * @return int 1 if OK, 0 if KO */ - function setShippingMethod($shipping_method_id, $notrigger = false, $userused = null) + public function setShippingMethod($shipping_method_id, $notrigger = false, $userused = null) { global $user; @@ -2128,7 +2130,7 @@ abstract class CommonObject * @param int $warehouse_id Id of warehouse * @return int 1 if OK, 0 if KO */ - function setWarehouse($warehouse_id) + public function setWarehouse($warehouse_id) { if (! $this->table_element) { dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined", LOG_ERR); @@ -2159,7 +2161,7 @@ abstract class CommonObject * @param string $modelpdf Modele name * @return int <0 if KO, >0 if OK */ - function setDocModel($user, $modelpdf) + public function setDocModel($user, $modelpdf) { if (! $this->table_element) { @@ -2198,7 +2200,7 @@ abstract class CommonObject * @param User $userused Object user * @return int 1 if OK, 0 if KO */ - function setBankAccount($fk_account, $notrigger = false, $userused = null) + public function setBankAccount($fk_account, $notrigger = false, $userused = null) { global $user; @@ -2253,7 +2255,7 @@ abstract class CommonObject // TODO: Move line related operations to CommonObjectLine? - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Save a new position (field rang) for details lines. * You can choose to set position for lines with already a position or lines without any position defined. @@ -2263,7 +2265,7 @@ abstract class CommonObject * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return int <0 if KO, >0 if OK */ - function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true) + public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true) { // phpcs:enable if (! $this->table_element_line) @@ -2348,7 +2350,7 @@ abstract class CommonObject * @param int $id Id of parent line * @return array Array with list of children lines id */ - function getChildrenOfLine($id) + public function getChildrenOfLine($id) { $rows=array(); @@ -2374,7 +2376,7 @@ abstract class CommonObject return $rows; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a lower rank * @@ -2382,7 +2384,7 @@ abstract class CommonObject * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return void */ - function line_up($rowid, $fk_parent_line = true) + public function line_up($rowid, $fk_parent_line = true) { // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); @@ -2394,7 +2396,7 @@ abstract class CommonObject $this->updateLineUp($rowid, $rang); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a higher rank * @@ -2402,7 +2404,7 @@ abstract class CommonObject * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return void */ - function line_down($rowid, $fk_parent_line = true) + public function line_down($rowid, $fk_parent_line = true) { // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); @@ -2424,7 +2426,7 @@ abstract class CommonObject * @param int $rang Position * @return void */ - function updateRangOfLine($rowid, $rang) + public function updateRangOfLine($rowid, $rang) { $fieldposition = 'rang'; if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; @@ -2439,14 +2441,14 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update position of line with ajax (rang) * * @param array $rows Array of rows * @return void */ - function line_ajaxorder($rows) + public function line_ajaxorder($rows) { // phpcs:enable $num = count($rows); @@ -2463,7 +2465,7 @@ abstract class CommonObject * @param int $rang Position * @return void */ - function updateLineUp($rowid, $rang) + public function updateLineUp($rowid, $rang) { if ($rang > 1) { @@ -2497,7 +2499,7 @@ abstract class CommonObject * @param int $max Max * @return void */ - function updateLineDown($rowid, $rang, $max) + public function updateLineDown($rowid, $rang, $max) { if ($rang < $max) { @@ -2529,7 +2531,7 @@ abstract class CommonObject * @param int $rowid Id of line * @return int Value of rang in table of lines */ - function getRangOfLine($rowid) + public function getRangOfLine($rowid) { $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE rowid ='.$rowid; @@ -2549,7 +2551,7 @@ abstract class CommonObject * @param int $rang Rang value * @return int Rowid of the line */ - function getIdOfLine($rang) + public function getIdOfLine($rang) { $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; @@ -2562,14 +2564,14 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value used for position of line (rang) * * @param int $fk_parent_line Parent line id * @return int Max value of rang in table of lines */ - function line_max($fk_parent_line = 0) + public function line_max($fk_parent_line = 0) { // phpcs:enable // Search the last rang with fk_parent_line @@ -2610,14 +2612,14 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update external ref of element * * @param string $ref_ext Update field ref_ext * @return int <0 if KO, >0 if OK */ - function update_ref_ext($ref_ext) + public function update_ref_ext($ref_ext) { // phpcs:enable if (! $this->table_element) @@ -2643,7 +2645,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update note of element * @@ -2651,7 +2653,7 @@ abstract class CommonObject * @param string $suffix '', '_public' or '_private' * @return int <0 if KO, >0 if OK */ - function update_note($note, $suffix = '') + public function update_note($note, $suffix = '') { // phpcs:enable global $user; @@ -2696,7 +2698,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update public note (kept for backward compatibility) * @@ -2705,13 +2707,13 @@ abstract class CommonObject * @deprecated * @see update_note() */ - function update_note_public($note) + public function update_note_public($note) { // phpcs:enable return $this->update_note($note, '_public'); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines). * Must be called at end of methods addline or updateline. @@ -2722,7 +2724,7 @@ abstract class CommonObject * @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object. * @return int <0 if KO, >0 if OK */ - function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) + public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) { // phpcs:enable global $conf, $hookmanager, $action; @@ -2950,7 +2952,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add objects linked in llx_element_element. * @@ -2959,7 +2961,7 @@ abstract class CommonObject * @return int <=0 if KO, >0 if OK * @see fetchObjectLinked(), updateObjectLinked(), deleteObjectLinked() */ - function add_object_linked($origin = null, $origin_id = null) + public function add_object_linked($origin = null, $origin_id = null) { // phpcs:enable $origin = (! empty($origin) ? $origin : $this->origin); @@ -3020,7 +3022,7 @@ abstract class CommonObject * @return int <0 if KO, >0 if OK * @see add_object_linked(), updateObjectLinked(), deleteObjectLinked() */ - function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1) + public function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1) { global $conf; @@ -3224,7 +3226,7 @@ abstract class CommonObject * @return int >0 if OK, <0 if KO * @see add_object_linked(), fetObjectLinked(), deleteObjectLinked() */ - function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '') + public function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '') { $updatesource=false; $updatetarget=false; @@ -3271,7 +3273,7 @@ abstract class CommonObject * @return int >0 if OK, <0 if KO * @see add_object_linked, updateObjectLinked, fetchObjectLinked */ - function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '') + public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '') { $deletesource=false; $deletetarget=false; @@ -3332,7 +3334,7 @@ abstract class CommonObject * @param string $trigkey Trigger key to use for trigger * @return int <0 if KO, >0 if OK */ - function setStatut($status, $elementId = null, $elementType = '', $trigkey = '') + public function setStatut($status, $elementId = null, $elementType = '', $trigkey = '') { global $user,$langs,$conf; @@ -3420,7 +3422,7 @@ abstract class CommonObject * @param string $ref Record ref * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function getCanvas($id = 0, $ref = '') + public function getCanvas($id = 0, $ref = '') { global $conf; @@ -3461,7 +3463,7 @@ abstract class CommonObject * @param int $lineid Id of line * @return int Special code */ - function getSpecialCode($lineid) + public function getSpecialCode($lineid) { $sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE rowid = '.$lineid; @@ -3480,7 +3482,7 @@ abstract class CommonObject * @param int $id Force id of object * @return int <0 if KO, 0 if not used, >0 if already used */ - function isObjectUsed($id = 0) + public function isObjectUsed($id = 0) { global $langs; @@ -3549,7 +3551,7 @@ abstract class CommonObject * @param int $predefined -1=All, 0=Count free product/service only, 1=Count predefined product/service only, 2=Count predefined product, 3=Count predefined service * @return int <0 if KO, 0 if no predefined products, nb of lines with predefined products if found */ - function hasProductsOrServices($predefined = -1) + public function hasProductsOrServices($predefined = -1) { $nb=0; @@ -3572,7 +3574,7 @@ abstract class CommonObject * * @return float */ - function getTotalDiscount() + public function getTotalDiscount() { $total_discount=0.00; @@ -3612,7 +3614,7 @@ abstract class CommonObject * * @return array array('weight'=>...,'volume'=>...) */ - function getTotalWeightVolume() + public function getTotalWeightVolume() { $totalWeight = 0; $totalVolume = 0; @@ -3706,7 +3708,7 @@ abstract class CommonObject * * @return int <0 if KO, >0 if OK */ - function setExtraParameters() + public function setExtraParameters() { $this->db->begin(); @@ -3732,14 +3734,14 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return incoterms informations * TODO Use a cache for label get * * @return string incoterms info */ - function display_incoterms() + public function display_incoterms() { // phpcs:enable $out = ''; @@ -3765,7 +3767,7 @@ abstract class CommonObject * * @return string incoterms info */ - function getIncotermsForPDF() + public function getIncotermsForPDF() { $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; $resql = $this->db->query($sql); @@ -3796,7 +3798,7 @@ abstract class CommonObject * @param string $location location of incoterm * @return int <0 if KO, >0 if OK */ - function setIncoterms($id_incoterm, $location) + public function setIncoterms($id_incoterm, $location) { if ($this->id && $this->table_element) { @@ -3844,7 +3846,7 @@ abstract class CommonObject * @param Societe $buyer Object thirdparty who buy * @return void */ - function formAddObjectLine($dateSelector, $seller, $buyer) + public function formAddObjectLine($dateSelector, $seller, $buyer) { global $conf,$user,$langs,$object,$hookmanager; global $form,$bcnd,$var; @@ -3887,7 +3889,7 @@ abstract class CommonObject * @param int $dateSelector 1=Show also date range input fields * @return void */ - function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0) + public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0) { global $conf, $hookmanager, $langs, $user; // TODO We should not use global var for this ! @@ -4029,8 +4031,8 @@ abstract class CommonObject * Return HTML content of a detail line * TODO Move this into an output class file (htmlline.class.php) * - * @param string $action GET/POST action - * @param CommonObjectLine $line Selected object line to output + * @param string $action GET/POST action + * @param CommonObjectLine $line Selected object line to output * @param string $var Is it a an odd line (true) * @param int $num Number of line (0) * @param int $i I @@ -4041,7 +4043,7 @@ abstract class CommonObject * @param int $extrafieldsline Object of extrafield line attribute * @return void */ - function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0) + public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0) { global $conf,$langs,$user,$object,$hookmanager; global $form,$bc,$bcdd; @@ -4159,7 +4161,7 @@ abstract class CommonObject * @param string $restrictlist ''=All lines, 'services'=Restrict to services only * @return void */ - function printOriginLinesList($restrictlist = '') + public function printOriginLinesList($restrictlist = '') { global $langs, $hookmanager, $conf; @@ -4213,7 +4215,7 @@ abstract class CommonObject * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) * @return void */ - function printOriginLine($line, $var, $restrictlist = '') + public function printOriginLine($line, $var, $restrictlist = '') { global $langs, $conf; @@ -4348,7 +4350,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add resources to the current object : add entry into llx_element_resources * Need $this->element & $this->id @@ -4359,7 +4361,7 @@ abstract class CommonObject * @param int $mandatory Mandatory or not * @return int <=0 if KO, >0 if OK */ - function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0) + public function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0) { // phpcs:enable $this->db->begin(); @@ -4394,7 +4396,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to resource line * @@ -4403,7 +4405,7 @@ abstract class CommonObject * @param int $notrigger Disable all triggers * @return int >0 if OK, <0 if KO */ - function delete_resource($rowid, $element, $notrigger = 0) + public function delete_resource($rowid, $element, $notrigger = 0) { // phpcs:enable global $user; @@ -4440,7 +4442,7 @@ abstract class CommonObject * * @return void */ - function __clone() + public function __clone() { // Force a copy of this->lines, otherwise it will point to same object. if (isset($this->lines) && is_array($this->lines)) @@ -4617,9 +4619,15 @@ abstract class CommonObject if ($useonlinesignature) $setsharekey=true; if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; } - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } if ($setsharekey) { @@ -4717,7 +4725,7 @@ abstract class CommonObject * @param string $file Path file in UTF8 to original file to create thumbs from. * @return void */ - function addThumbs($file) + public function addThumbs($file) { global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; @@ -4753,7 +4761,7 @@ abstract class CommonObject * @param string $alternatevalue Alternate value to use * @return string|string[] Default value (can be an array if the GETPOST return an array) **/ - function getDefaultCreateValueFor($fieldname, $alternatevalue = null) + public function getDefaultCreateValueFor($fieldname, $alternatevalue = null) { global $conf, $_POST; @@ -4782,7 +4790,7 @@ abstract class CommonObject /* For triggers */ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Call trigger based on this instance. * Some context information may also be provided into array property this->context. @@ -4793,7 +4801,7 @@ abstract class CommonObject * @param User $user Object user * @return int Result of run_triggers */ - function call_trigger($trigger_name, $user) + public function call_trigger($trigger_name, $user) { // phpcs:enable global $langs,$conf; @@ -4820,7 +4828,7 @@ abstract class CommonObject /* Functions for extrafields */ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to get extra fields of an object into $this->array_options * This method is in most cases called by method fetch of objects but you can call it separately. @@ -4829,7 +4837,7 @@ abstract class CommonObject * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters. * @return int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded */ - function fetch_optionals($rowid = null, $optionsArray = null) + public function fetch_optionals($rowid = null, $optionsArray = null) { // phpcs:enable if (empty($rowid)) $rowid=$this->id; @@ -4940,7 +4948,7 @@ abstract class CommonObject * * @return int <0 if KO, >0 if OK */ - function deleteExtraFields() + public function deleteExtraFields() { $this->db->begin(); @@ -4973,7 +4981,7 @@ abstract class CommonObject * @return int -1=error, O=did nothing, 1=OK * @see updateExtraField(), setValueFrom() */ - function insertExtraFields($trigger = '', $userused = null) + public function insertExtraFields($trigger = '', $userused = null) { global $conf,$langs,$user; @@ -5219,7 +5227,7 @@ abstract class CommonObject * @return int -1=error, O=did nothing, 1=OK * @see setValueFrom(), insertExtraFields() */ - function updateExtraField($key, $trigger = null, $userused = null) + public function updateExtraField($key, $trigger = null, $userused = null) { global $conf,$langs,$user; @@ -5353,7 +5361,7 @@ abstract class CommonObject * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. * @return string */ - function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0) + public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0) { global $conf,$langs,$form; @@ -5963,7 +5971,7 @@ abstract class CommonObject * @param mixed $showsize Value for css to define size. May also be a numeric. * @return string */ - function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $showsize = 0) + public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $showsize = 0) { global $conf,$langs,$form; @@ -6334,7 +6342,7 @@ abstract class CommonObject * @param string $onetrtd All fields in same tr td * @return string */ - function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0) + public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0) { global $db, $conf, $langs, $action, $form; @@ -6642,7 +6650,7 @@ abstract class CommonObject return $buyPrice; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show photos of an object (nbmax maximum), into several columns * @@ -6660,7 +6668,7 @@ abstract class CommonObject * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ - function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0) + public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0) { // phpcs:enable global $conf,$user,$langs; @@ -7447,9 +7455,18 @@ abstract class CommonObject */ public function initAsSpecimenCommon() { - $this->id = 0; + global $user; - // TODO... + $this->id = 0; + if (array_key_exists('label', $this->fields)) $this->label='This is label'; + if (array_key_exists('note_public', $this->fields)) $this->note_public='Public note'; + if (array_key_exists('note_private', $this->fields)) $this->note_private='Private note'; + if (array_key_exists('date_creation', $this->fields)) $this->date_creation=(dol_now()-3600*24); + if (array_key_exists('date_modification', $this->fields)) $this->date_modification=(dol_now()-3600*24); + if (array_key_exists('fk_user_creat', $this->fields)) $this->fk_user_creat=$user->id; + if (array_key_exists('fk_user_modif', $this->fields)) $this->fk_user_modif=$user->id; + if (array_key_exists('date', $this->fields)) $this->date=dol_now(); + // ... } @@ -7474,15 +7491,15 @@ abstract class CommonObject return count($this->comments); } - /** - * Return nb comments already posted - * - * @return int - */ - public function getNbComments() - { - return count($this->comments); - } + /** + * Return nb comments already posted + * + * @return int + */ + public function getNbComments() + { + return count($this->comments); + } /** * Trim object parameters diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 0055559c4dc..18bcfcee8d5 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -61,43 +61,57 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; */ abstract class CommonStickerGenerator { - public $code; // Code of format + public $code; // Code of format - /** + /** * @var array format Array with informations */ public $format; - // protected - var $_Avery_Name = ''; // Nom du format de l'etiquette - var $_Margin_Left = 0; // Marge de gauche de l'etiquette - var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette - var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes - var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes - var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page - var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page - var $_Width = 0; // Largeur de chaque etiquette - var $_Height = 0; // Hauteur de chaque etiquette - var $_Char_Size = 10; // Hauteur des caracteres - var $_Line_Height = 10; // Hauteur par defaut d'une ligne - var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values - var $_Metric_Doc = 'mm'; // Type of metric for the doc.. - var $_COUNTX = 1; - var $_COUNTY = 1; - var $_First = 1; - var $Tformat; - + // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore + // protected + // Nom du format de l'etiquette + protected $_Avery_Name = ''; + // Marge de gauche de l'etiquette + protected $_Margin_Left = 0; + // marge en haut de la page avant la premiere etiquette + protected $_Margin_Top = 0; + // Espace horizontal entre 2 bandes d'etiquettes + protected $_X_Space = 0; + // Espace vertical entre 2 bandes d'etiquettes + protected $_Y_Space = 0; + // NX Nombre d'etiquettes sur la largeur de la page + protected $_X_Number = 0; + // NY Nombre d'etiquettes sur la hauteur de la page + protected $_Y_Number = 0; + // Largeur de chaque etiquette + protected $_Width = 0; + // Hauteur de chaque etiquette + protected $_Height = 0; + // Hauteur des caracteres + protected $_Char_Size = 10; + // Hauteur par defaut d'une ligne + protected $_Line_Height = 10; + // Type of metric.. Will help to calculate good values + protected $_Metric = 'mm'; + // Type of metric for the doc.. + protected $_Metric_Doc = 'mm'; + protected $_COUNTX = 1; + protected $_COUNTY = 1; + protected $_First = 1; + public $Tformat; + // phpcs:enable /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP strem. * @@ -107,7 +121,7 @@ abstract class CommonStickerGenerator * @param string $outputdir Output directory for pdf file * @return int 1=OK, 0=KO */ - abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = ''); + public abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = ''); // phpcs:enable /** @@ -118,9 +132,9 @@ abstract class CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - abstract function addSticker(&$pdf, $outputlangs, $param); + public abstract function addSticker(&$pdf, $outputlangs, $param); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Methode qui permet de modifier la taille des caracteres * Cela modiera aussi l'espace entre chaque ligne @@ -129,7 +143,7 @@ abstract class CommonStickerGenerator * @param int $pt point * @return void */ - function Set_Char_Size(&$pdf, $pt) + public function Set_Char_Size(&$pdf, $pt) { // phpcs:enable if ($pt > 3) { @@ -139,7 +153,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * protected Print dot line * @@ -152,8 +167,8 @@ abstract class CommonStickerGenerator * @param int $nbPointilles Nb pointilles * @return void */ - function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) - { + protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) + { // phpcs:enable $pdf->SetLineWidth($epaisseur); $length=abs($x1-$x2); @@ -182,7 +197,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Function realisant une croix aux 4 coins des cartes * @@ -195,7 +211,7 @@ abstract class CommonStickerGenerator * @param int $taille Size * @return void */ - function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4) + protected function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4) { // phpcs:enable $pdf->SetDrawColor(192, 192, 192); @@ -240,14 +256,15 @@ abstract class CommonStickerGenerator return $value; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Give the height for a char size given. * * @param int $pt Point * @return int Height chars */ - function _Get_Height_Chars($pt) + protected function _Get_Height_Chars($pt) { // phpcs:enable // Tableau de concordance entre la hauteur des caracteres et de l'espacement entre les lignes @@ -259,7 +276,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Set format * @@ -267,7 +285,7 @@ abstract class CommonStickerGenerator * @param string $format Format * @return void */ - function _Set_Format(&$pdf, $format) + protected function _Set_Format(&$pdf, $format) { // phpcs:enable $this->_Metric = $format['metric']; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 5de1475a3f0..ecbecdeee2d 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -32,22 +32,22 @@ */ class Conf { - /** \public */ - //! To store properties found in conf file - var $file; + /** \public */ + //! To store properties found in conf file + public $file; - /** + /** * @var DoliDB Database handler. */ public $db; - //! To store properties found into database - var $global; - //! To store browser info - var $browser; + //! To store properties found into database + public $global; + //! To store browser info + public $browser; - //! To store if javascript/ajax is enabked - public $use_javascript_ajax; + //! To store if javascript/ajax is enabked + public $use_javascript_ajax; //! Used to store current currency (ISO code like 'USD', 'EUR', ...) public $currency; //! Used to store current css (from theme) @@ -55,19 +55,36 @@ class Conf public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) //! Used to store current menu handler public $standard_menu; + // List of activated modules + public $modules = array(); + public $modules_parts = array( + 'css' => array(), + 'js' => array(), + 'tabs' => array(), + 'triggers' => array(), + 'login' => array(), + 'substitutions' => array(), + 'menus' => array(), + 'theme' => array(), + 'sms' => array(), + 'tpl' => array(), + 'barcode' => array(), + 'models' => array(), + 'societe' => array(), + 'hooks' => array(), + 'dir' => array(), + 'syslog' => array(), + ); - public $modules = array(); // List of activated modules - public $modules_parts = array('css'=>array(),'js'=>array(),'tabs'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'sms'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'societe'=>array(),'hooks'=>array(),'dir'=>array(), 'syslog' =>array()); + public $logbuffer = array(); - var $logbuffer = array(); + /** + * @var LogHandlerInterface[] + */ + public $loghandlers = array(); - /** - * @var LogHandlerInterface[] - */ - var $loghandlers = array(); - - //! To store properties of multi-company - public $multicompany; + //! To store properties of multi-company + public $multicompany; //! Used to store running instance for multi-company (default 1) public $entity = 1; //! Used to store list of entities to use for each element @@ -83,7 +100,7 @@ class Conf /** * Constructor */ - function __construct() + public function __construct() { // Properly declare multi-modules objects. $this->file = new stdClass(); @@ -124,13 +141,13 @@ class Conf /** - * Load setup values into conf object (read llx_const) + * Load setup values into conf object (read llx_const) * Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called. * - * @param DoliDB $db Database handler - * @return int < 0 if KO, >= 0 if OK + * @param DoliDB $db Database handler + * @return int < 0 if KO, >= 0 if OK */ - function setValues($db) + public function setValues($db) { global $conf; @@ -201,8 +218,8 @@ class Conf $i++; } - $db->free($resql); - } + $db->free($resql); + } // Include other local consts.php files and fetch their values to the corresponding database constants. if (! empty($this->global->LOCAL_CONSTS_FILES)) { @@ -216,8 +233,8 @@ class Conf } } - //var_dump($this->modules); - //var_dump($this->modules_parts['theme']); + //var_dump($this->modules); + //var_dump($this->modules_parts['theme']); // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC. // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore. @@ -234,12 +251,10 @@ class Conf } // Object $mc - if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) - { + if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) { global $mc; $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); - if ($ret) - { + if ($ret) { $mc = new ActionsMulticompany($db); $this->mc = $mc; } @@ -575,7 +590,9 @@ class Conf $this->adherent->subscription = new stdClass(); $this->adherent->subscription->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60; } - if (isset($this->agenda)) $this->agenda->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60; + if (isset($this->agenda)) { + $this->agenda->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60; + } if (isset($this->projet)) { $this->projet->warning_delay=(isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE)?$this->global->MAIN_DELAY_PROJECT_TO_CLOSE:7)*24*60*60; @@ -615,9 +632,9 @@ class Conf $this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60; } if (isset($this->expensereport)) { - $this->expensereport->approve = new stdClass(); + $this->expensereport->approve = new stdClass(); $this->expensereport->approve->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS)?$this->global->MAIN_DELAY_EXPENSEREPORTS:0)*24*60*60; - $this->expensereport->payment = new stdClass(); + $this->expensereport->payment = new stdClass(); $this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60; } diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index a3a8a0dd5ff..cb31a287656 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -27,55 +27,55 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; class CoreObject extends CommonObject { - public $withChild = true; - - /** - * @var Array $_fields Fields to synchronize with Database - */ - protected $fields=array(); + public $withChild = true; /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct(DoliDB &$db) + * @var Array $_fields Fields to synchronize with Database + */ + protected $fields=array(); + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB &$db) { $this->db = $db; - } + } /** * Function to init fields * * @return bool */ - protected function init() + protected function init() { - $this->id = 0; - $this->datec = 0; - $this->tms = 0; + $this->id = 0; + $this->datec = 0; + $this->tms = 0; - if (!empty($this->fields)) - { - foreach ($this->fields as $field=>$info) - { - if ($this->isDate($info)) $this->{$field} = time(); - elseif ($this->isArray($info)) $this->{$field} = array(); - elseif ($this->isInt($info)) $this->{$field} = (int) 0; - elseif ($this->isFloat($info)) $this->{$field} = (double) 0; - else $this->{$field} = ''; - } + if (!empty($this->fields)) + { + foreach ($this->fields as $field=>$info) + { + if ($this->isDate($info)) $this->{$field} = time(); + elseif ($this->isArray($info)) $this->{$field} = array(); + elseif ($this->isInt($info)) $this->{$field} = (int) 0; + elseif ($this->isFloat($info)) $this->{$field} = (double) 0; + else $this->{$field} = ''; + } $this->to_delete=false; $this->is_clone=false; - return true; - } - else + return true; + } + else { - return false; - } - } + return false; + } + } /** * Test type of field @@ -86,15 +86,15 @@ class CoreObject extends CommonObject */ private function checkFieldType($field, $type) { - if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) - { - return $this->{'is_'.$type}($this->fields[$field]); - } - else + if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) + { + return $this->{'is_'.$type}($this->fields[$field]); + } + else { return false; } - } + } /** * Get object and children from database @@ -103,15 +103,15 @@ class CoreObject extends CommonObject * @param bool $loadChild used to load children from database * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($id, $loadChild = true) + public function fetch($id, $loadChild = true) { - $res = $this->fetchCommon($id); - if($res>0) { - if ($loadChild) $this->fetchChild(); - } + $res = $this->fetchCommon($id); + if($res>0) { + if ($loadChild) $this->fetchChild(); + } - return $res; - } + return $res; + } /** @@ -125,25 +125,25 @@ class CoreObject extends CommonObject */ public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false) { - if(!empty($id)) - { - foreach($this->{$tabName} as $k=>&$object) - { - if($object->{$key} === $id) return $k; - } - } + if(!empty($id)) + { + foreach($this->{$tabName} as $k=>&$object) + { + if($object->{$key} === $id) return $k; + } + } - $k = count($this->{$tabName}); + $k = count($this->{$tabName}); - $className = ucfirst($tabName); - $this->{$tabName}[$k] = new $className($this->db); - if($id>0 && $key==='id' && $try_to_load) - { - $this->{$tabName}[$k]->fetch($id); - } + $className = ucfirst($tabName); + $this->{$tabName}[$k] = new $className($this->db); + if($id>0 && $key==='id' && $try_to_load) + { + $this->{$tabName}[$k]->fetch($id); + } - return $k; - } + return $k; + } /** @@ -156,16 +156,16 @@ class CoreObject extends CommonObject */ public function removeChild($tabName, $id, $key = 'id') { - foreach ($this->{$tabName} as &$object) - { - if ($object->{$key} == $id) - { - $object->to_delete = true; - return true; - } - } - return false; - } + foreach ($this->{$tabName} as &$object) + { + if ($object->{$key} == $id) + { + $object->to_delete = true; + return true; + } + } + return false; + } /** @@ -175,10 +175,10 @@ class CoreObject extends CommonObject */ public function fetchChild() { - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) - { - foreach($this->childtables as &$childTable) - { + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) + { + foreach($this->childtables as &$childTable) + { $className = ucfirst($childTable); $this->{$className}=array(); @@ -200,9 +200,9 @@ class CoreObject extends CommonObject { $this->errors[] = $this->db->lasterror(); } - } - } - } + } + } + } /** * Function to update children data @@ -210,26 +210,26 @@ class CoreObject extends CommonObject * @param User $user user object * @return void */ - public function saveChild(User &$user) + public function saveChild(User &$user) { - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) - { - foreach($this->childtables as &$childTable) - { - $className = ucfirst($childTable); - if(!empty($this->{$className})) - { - foreach($this->{$className} as $i => &$object) - { - $object->{$this->fk_element} = $this->id; + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) + { + foreach($this->childtables as &$childTable) + { + $className = ucfirst($childTable); + if(!empty($this->{$className})) + { + foreach($this->{$className} as $i => &$object) + { + $object->{$this->fk_element} = $this->id; - $object->update($user); - if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); - } - } - } - } - } + $object->update($user); + if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); + } + } + } + } + } /** @@ -240,7 +240,7 @@ class CoreObject extends CommonObject */ public function update(User &$user) { - if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed + if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed elseif (isset($this->to_delete) && $this->to_delete==true) return $this->delete($user); $error = 0; @@ -270,7 +270,7 @@ class CoreObject extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Function to create object in database @@ -280,26 +280,26 @@ class CoreObject extends CommonObject */ public function create(User &$user) { - if($this->id > 0) return $this->update($user); + if($this->id > 0) return $this->update($user); $error = 0; $this->db->begin(); $res = $this->createCommon($user); - if($res) - { - $this->id = $this->db->last_insert_id($this->table_element); + if($res) + { + $this->id = $this->db->last_insert_id($this->table_element); - $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); + $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); if ($result < 0) $error++; else $this->saveChild($user); - } - else + } + else { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; - } + } if (empty($error)) { @@ -311,7 +311,7 @@ class CoreObject extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Function to delete object in database @@ -319,9 +319,9 @@ class CoreObject extends CommonObject * @param User $user user object * @return < 0 if ko, > 0 if ok */ - public function delete(User &$user) + public function delete(User &$user) { - if ($this->id <= 0) return 0; + if ($this->id <= 0) return 0; $error = 0; $this->db->begin(); @@ -360,7 +360,7 @@ class CoreObject extends CommonObject $this->db->rollback(); return -1; } - } + } /** @@ -372,12 +372,12 @@ class CoreObject extends CommonObject */ public function getDate($field, $format = '') { - if(empty($this->{$field})) return ''; - else + if(empty($this->{$field})) return ''; + else { - return dol_print_date($this->{$field}, $format); - } - } + return dol_print_date($this->{$field}, $format); + } + } /** * Function to set date in field @@ -388,18 +388,18 @@ class CoreObject extends CommonObject */ public function setDate($field, $date) { - if (empty($date)) - { - $this->{$field} = 0; - } - else + if (empty($date)) + { + $this->{$field} = 0; + } + else { - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $this->{$field} = dol_stringtotime($date); - } + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + $this->{$field} = dol_stringtotime($date); + } - return $this->{$field}; - } + return $this->{$field}; + } /** @@ -410,29 +410,29 @@ class CoreObject extends CommonObject */ public function setValues(&$Tab) { - foreach ($Tab as $key => $value) - { - if($this->checkFieldType($key, 'date')) - { - $this->setDate($key, $value); - } - elseif( $this->checkFieldType($key, 'array')) - { - $this->{$key} = $value; - } - elseif( $this->checkFieldType($key, 'float') ) - { - $this->{$key} = (double) price2num($value); - } - elseif( $this->checkFieldType($key, 'int') ) { - $this->{$key} = (int) price2num($value); - } - else + foreach ($Tab as $key => $value) + { + if($this->checkFieldType($key, 'date')) { - $this->{$key} = $value; - } - } + $this->setDate($key, $value); + } + elseif( $this->checkFieldType($key, 'array')) + { + $this->{$key} = $value; + } + elseif( $this->checkFieldType($key, 'float') ) + { + $this->{$key} = (double) price2num($value); + } + elseif( $this->checkFieldType($key, 'int') ) { + $this->{$key} = (int) price2num($value); + } + else + { + $this->{$key} = $value; + } + } - return 1; - } + return 1; + } } diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index 6ad6523f199..97f5b9b016f 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -21,14 +21,8 @@ * \brief This file is a CRUD class file (Create/Read/Update/Delete) for c_departements dictionary */ -// Put here all includes required by your class file -//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 to manage dictionary States (used by imports) + * Class to manage dictionary States (used by imports) */ class Cstate // extends CommonObject { @@ -79,7 +73,7 @@ class Cstate // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -92,7 +86,7 @@ class Cstate // 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; @@ -124,22 +118,20 @@ class Cstate // extends CommonObject $resql=$this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. + //if (! $notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + //} } // Commit or rollback @@ -168,7 +160,7 @@ class Cstate // extends CommonObject * @param string $code Code * @return int <0 if KO, >0 if OK */ - function fetch($id, $code = '') + public function fetch($id, $code = '') { global $langs; $sql = "SELECT"; @@ -212,7 +204,7 @@ class Cstate // 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; @@ -239,10 +231,10 @@ class Cstate // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -252,11 +244,11 @@ class Cstate // extends CommonObject //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback - if ($error) + if ($error) { foreach($this->errors as $errmsg) { @@ -281,7 +273,7 @@ class Cstate // 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; @@ -295,10 +287,10 @@ class Cstate // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -308,8 +300,8 @@ class Cstate // extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback if ($error) diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index ffaccbfe964..6c86c987d17 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -63,7 +63,7 @@ class Ctypent // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -76,7 +76,7 @@ class Ctypent // 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; @@ -166,7 +166,7 @@ class Ctypent // 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 = '') { global $langs; $sql = "SELECT"; @@ -214,7 +214,7 @@ class Ctypent // 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; @@ -285,7 +285,7 @@ class Ctypent // 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; @@ -299,10 +299,10 @@ class Ctypent // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -312,12 +312,12 @@ class Ctypent // extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback - if ($error) - { + if ($error) + { foreach($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); @@ -325,11 +325,11 @@ class Ctypent // extends CommonObject } $this->db->rollback(); return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } + } + else + { + $this->db->commit(); + return 1; + } + } } diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 3970ff2df27..0e3987da516 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -66,7 +66,7 @@ class CUnits // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -79,7 +79,7 @@ class CUnits // 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; @@ -170,7 +170,7 @@ class CUnits // extends CommonObject * @param string $unit_type unit type * @return int <0 if KO, >0 if OK */ - function fetch($id, $code = '', $short_label = '', $unit_type = '') + public function fetch($id, $code = '', $short_label = '', $unit_type = '') { global $langs; @@ -310,7 +310,7 @@ class CUnits // 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; @@ -383,7 +383,7 @@ class CUnits // 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; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 9615c040eb0..0a681b95b18 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -60,7 +60,8 @@ class DiscountAbsolute public $multicurrency_amount_ht; public $multicurrency_amount_tva; public $multicurrency_amount_ttc; - public $tva_tx; // Vat rate + // Vat rate + public $tva_tx; /** * @var int User ID Id utilisateur qui accorde la remise @@ -98,7 +99,7 @@ class DiscountAbsolute * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -112,7 +113,7 @@ class DiscountAbsolute * @param int $fk_invoice_supplier_source fk_invoice_supplier_source * @return int <0 if KO, =0 if not found, >0 if OK */ - function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) + public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) { global $conf; @@ -194,7 +195,7 @@ class DiscountAbsolute * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -253,10 +254,10 @@ class DiscountAbsolute /** * Delete object in database. If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed * - * @param User $user Object of user asking to delete - * @return int <0 if KO, >0 if OK + * @param User $user Object of user asking to delete + * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { global $conf, $langs; @@ -291,8 +292,8 @@ class DiscountAbsolute // Check if we can remove the discount if ($this->fk_invoice_supplier_source) { - $sql="SELECT COUNT(rowid) as nb"; - $sql.=" FROM ".MAIN_DB_PREFIX."societe_remise_except"; + $sql="SELECT COUNT(rowid) as nb"; + $sql.=" FROM ".MAIN_DB_PREFIX."societe_remise_except"; $sql.=" WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount $sql.=" OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit $sql.=" AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; @@ -389,7 +390,7 @@ class DiscountAbsolute - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link the discount to a particular invoice line or a particular invoice. * When discount is a global discount used as an invoice line, we link using rowidline. @@ -399,7 +400,7 @@ class DiscountAbsolute * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) * @return int <0 if KO, >0 if OK */ - function link_to_invoice($rowidline, $rowidinvoice) + public function link_to_invoice($rowidline, $rowidinvoice) { // phpcs:enable // Check parameters @@ -445,20 +446,20 @@ class DiscountAbsolute } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link the discount to a particular invoice line or a particular invoice. * Do not call this if discount is linked to a reconcialiated invoice * * @return int <0 if KO, >0 if OK */ - function unlink_invoice() + public function unlink_invoice() { // phpcs:enable $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - if(! empty($this->discount_type)) { - $sql.=" SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; - } else { + if (! empty($this->discount_type)) { + $sql.=" SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; + } else { $sql.=" SET fk_facture_line = NULL, fk_facture = NULL"; } $sql.=" WHERE rowid = ".$this->id; @@ -487,9 +488,9 @@ class DiscountAbsolute * @param int $discount_type 0 => customer discount, 1 => supplier discount * @return int <0 if KO, amount otherwise */ - function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0) + public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0) { - global $conf; + global $conf; $sql = "SELECT SUM(rc.amount_ttc) as amount"; //$sql = "SELECT rc.amount_ttc as amount"; @@ -527,10 +528,10 @@ class DiscountAbsolute * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * * @param CommonInvoice $invoice Object invoice (customer of supplier) - * @param int $multicurrency Return multicurrency_amount instead of amount + * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumDepositsUsed($invoice, $multicurrency = 0) + public function getSumDepositsUsed($invoice, $multicurrency = 0) { dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); @@ -572,11 +573,11 @@ class DiscountAbsolute /** * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment * - * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and excess received amount otherwise + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and excess received amount otherwise */ - function getSumCreditNotesUsed($invoice, $multicurrency = 0) + public function getSumCreditNotesUsed($invoice, $multicurrency = 0) { dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); @@ -616,13 +617,13 @@ class DiscountAbsolute } /** - * Return clickable ref of object (with picto or not) + * Return clickable ref of object (with picto or not) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only - * @param string $option Where to link to ('invoice' or 'discount') - * @return string String with URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only + * @param string $option Where to link to ('invoice' or 'discount') + * @return string String with URL */ - function getNomUrl($withpicto, $option = 'invoice') + public function getNomUrl($withpicto, $option = 'invoice') { global $langs; @@ -660,7 +661,7 @@ class DiscountAbsolute * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 4cbf20a8a75..110d850bfd0 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -28,43 +28,43 @@ */ class DolEditor { - var $tool; // Store the selected tool + public $tool; // Store the selected tool - // If using fckeditor - var $editor; + // If using fckeditor + public $editor; - // If not using fckeditor - var $content; - var $htmlname; - var $toolbarname; - var $toolbarstartexpanded; - var $rows; - var $cols; - var $height; - var $width; - var $readonly; + // If not using fckeditor + public $content; + public $htmlname; + public $toolbarname; + public $toolbarstartexpanded; + public $rows; + public $cols; + public $height; + public $width; + public $readonly; /** - * Create an object to build an HTML area to edit a large string content + * Create an object to build an HTML area to edit a large string content * - * @param string $htmlname HTML name of WYSIWIG field - * @param string $content Content of WYSIWIG field - * @param int $width Width in pixel of edit area (auto by default) - * @param int $height Height in pixel of edit area (200px by default) - * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). - * @param string $toolbarlocation Where bar is stored : - * 'In' each window has its own toolbar - * 'Out:name' share toolbar into the div called 'name' - * @param boolean $toolbarstartexpanded Bar is visible or not at start - * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. - * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. - * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". - * @param int $rows Size of rows for textarea tool - * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') - * @param int $readonly 0=Read/Edit, 1=Read only + * @param string $htmlname HTML name of WYSIWIG field + * @param string $content Content of WYSIWIG field + * @param int $width Width in pixel of edit area (auto by default) + * @param int $height Height in pixel of edit area (200px by default) + * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). + * @param string $toolbarlocation Where bar is stored : + * 'In' each window has its own toolbar + * 'Out:name' share toolbar into the div called 'name' + * @param boolean $toolbarstartexpanded Bar is visible or not at start + * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. + * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. + * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". + * @param int $rows Size of rows for textarea tool + * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') + * @param int $readonly 0=Read/Edit, 1=Read only */ - function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) + public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) { global $conf,$langs; @@ -137,7 +137,7 @@ class DolEditor } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output edit area inside the HTML stream. * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) @@ -149,7 +149,7 @@ class DolEditor * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) * @return void|string */ - function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') + public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') { // phpcs:enable global $conf,$langs; diff --git a/htdocs/core/class/dolexception.class.php b/htdocs/core/class/dolexception.class.php index b61bc6e388c..be04c9fd741 100644 --- a/htdocs/core/class/dolexception.class.php +++ b/htdocs/core/class/dolexception.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010 Regis Houssin * * 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 @@ -16,21 +16,21 @@ */ /** - * \file htdocs/core/class/dolexception.class.php - * \ingroup core - * \brief File of class for exceptions + * \file htdocs/core/class/dolexception.class.php + * \ingroup core + * \brief File of class for exceptions */ /** - * Class to manage exceptions + * Class to manage exceptions */ class DolException extends Exception { /** * Constructor */ - function __construct() + public function __construct() { } } diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 22ec32045a0..79515725aa1 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -33,7 +33,7 @@ */ class DolGeoIP { - var $gi; + public $gi; /** * Constructor @@ -41,7 +41,7 @@ class DolGeoIP * @param string $type 'country' or 'city' * @param string $datfile Data file */ - function __construct($type, $datfile) + public function __construct($type, $datfile) { if ($type == 'country') { @@ -88,7 +88,7 @@ class DolGeoIP * @param string $ip IP to scan * @return string Country code (two letters) */ - function getCountryCodeFromIP($ip) + public function getCountryCodeFromIP($ip) { if (empty($this->gi)) { @@ -112,7 +112,7 @@ class DolGeoIP * @param string $name FQN of host (example: myserver.xyz.com) * @return string Country code (two letters) */ - function getCountryCodeFromName($name) + public function getCountryCodeFromName($name) { if (empty($this->gi)) { @@ -121,27 +121,27 @@ class DolGeoIP return geoip_country_code_by_name($this->gi, $name); } - /** - * Return verion of data file - * - * @return string Version of datafile - */ - function getVersion() - { - if ($this->gi == 'NOGI') return geoip_database_info(); - return 'Not available (not using PHP internal geo functions)'; - } + /** + * Return verion of data file + * + * @return string Version of datafile + */ + public function getVersion() + { + if ($this->gi == 'NOGI') return geoip_database_info(); + return 'Not available (not using PHP internal geo functions)'; + } - /** - * Close geoip object - * - * @return void - */ - function close() - { - if (function_exists('geoip_close')) // With some geoip with PEAR, geoip_close function may not exists - { - geoip_close($this->gi); - } - } + /** + * Close geoip object + * + * @return void + */ + public function close() + { + if (function_exists('geoip_close')) { + // With some geoip with PEAR, geoip_close function may not exists + geoip_close($this->gi); + } + } } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 7fd9258ddd7..386b378abdd 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -88,7 +88,7 @@ class DolGraph * * @param string $library 'jflot' (default) or 'artichow' (no more supported) */ - function __construct($library = 'jflot') + public function __construct($library = 'jflot') { global $conf; global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet; @@ -128,130 +128,130 @@ class DolGraph } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set Y precision * * @param float $which_prec Precision * @return boolean */ - function SetPrecisionY($which_prec) + public function SetPrecisionY($which_prec) { // phpcs:enable $this->PrecisionY = $which_prec; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * * @param float $xi Xi * @return boolean True */ - function SetHorizTickIncrement($xi) + public function SetHorizTickIncrement($xi) { // phpcs:enable $this->horizTickIncrement = $xi; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * * @param float $xt Xt * @return boolean True */ - function SetNumXTicks($xt) + public function SetNumXTicks($xt) { // phpcs:enable $this->SetNumXTicks = $xt; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set label interval to reduce number of labels * * @param float $x Label interval * @return boolean True */ - function SetLabelInterval($x) + public function SetLabelInterval($x) { // phpcs:enable $this->labelInterval = $x; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide X grid * * @param boolean $bool XGrid or not * @return boolean true */ - function SetHideXGrid($bool) + public function SetHideXGrid($bool) { // phpcs:enable $this->hideXGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide Y grid * * @param boolean $bool YGrid or not * @return boolean true */ - function SetHideYGrid($bool) + public function SetHideYGrid($bool) { // phpcs:enable $this->hideYGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set y label * * @param string $label Y label * @return boolean|null True */ - function SetYLabel($label) + public function SetYLabel($label) { // phpcs:enable $this->YLabel = $label; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set width * * @param int $w Width * @return boolean|null True */ - function SetWidth($w) + public function SetWidth($w) { // phpcs:enable $this->width = $w; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set title * * @param string $title Title * @return void */ - function SetTitle($title) + public function SetTitle($title) { // phpcs:enable $this->title = $title; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * @@ -259,172 +259,172 @@ class DolGraph * @return void * @see draw_jflot for syntax of data array */ - function SetData($data) + public function SetData($data) { // phpcs:enable $this->data = $data; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * * @param array $datacolor Data color array(array(R,G,B),array(R,G,B)...) * @return void */ - function SetDataColor($datacolor) + public function SetDataColor($datacolor) { // phpcs:enable $this->datacolor = $datacolor; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set type * * @param array $type Array with type for each serie. Example: array('pie'), array('lines',...,'bars') * @return void */ - function SetType($type) + public function SetType($type) { // phpcs:enable $this->type = $type; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set legend * * @param array $legend Legend. Example: array('seriename1','seriname2',...) * @return void */ - function SetLegend($legend) + public function SetLegend($legend) { // phpcs:enable $this->Legend = $legend; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min width * * @param int $legendwidthmin Min width * @return void */ - function SetLegendWidthMin($legendwidthmin) + public function SetLegendWidthMin($legendwidthmin) { // phpcs:enable $this->LegendWidthMin = $legendwidthmin; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set max value * * @param int $max Max value * @return void */ - function SetMaxValue($max) + public function SetMaxValue($max) { // phpcs:enable $this->MaxValue = $max; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value * * @return int Max value */ - function GetMaxValue() + public function GetMaxValue() { // phpcs:enable return $this->MaxValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min value * * @param int $min Min value * @return void */ - function SetMinValue($min) + public function SetMinValue($min) { // phpcs:enable $this->MinValue = $min; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get min value * * @return int Max value */ - function GetMinValue() + public function GetMinValue() { // phpcs:enable return $this->MinValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set height * * @param int $h Height * @return void */ - function SetHeight($h) + public function SetHeight($h) { // phpcs:enable $this->height = $h; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - function SetShading($s) + public function SetShading($s) { // phpcs:enable $this->SetShading = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - function SetCssPrefix($s) + public function SetCssPrefix($s) { // phpcs:enable $this->cssprefix = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bg color * * @return void */ - function ResetBgColor() + public function ResetBgColor() { // phpcs:enable unset($this->bgcolor); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bgcolorgrid * * @return void */ - function ResetBgColorGrid() + public function ResetBgColorGrid() { // phpcs:enable unset($this->bgcolorgrid); @@ -435,7 +435,7 @@ class DolGraph * * @return string Error */ - function isGraphKo() + public function isGraphKo() { return $this->error; } @@ -446,7 +446,7 @@ class DolGraph * @param int $showlegend 1=Show legend (default), 0=Hide legend * @return void */ - function setShowLegend($showlegend) + public function setShowLegend($showlegend) { $this->showlegend=$showlegend; } @@ -457,7 +457,7 @@ class DolGraph * @param int $showpointvalue 1=Show value for each point, as tooltip or inline (default), 0=Hide value * @return void */ - function setShowPointValue($showpointvalue) + public function setShowPointValue($showpointvalue) { $this->showpointvalue=$showpointvalue; } @@ -468,21 +468,21 @@ class DolGraph * @param int $showpercent 1=Show percent for each point, as tooltip or inline, 0=Hide percent (default) * @return void */ - function setShowPercent($showpercent) + public function setShowPercent($showpercent) { $this->showpercent=$showpercent; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of complete image * * @param array $bg_color array(R,G,B) ou 'onglet' ou 'default' * @return void */ - function SetBgColor($bg_color = array(255,255,255)) + public function SetBgColor($bg_color = array(255,255,255)) { // phpcs:enable global $theme_bgcolor,$theme_bgcoloronglet; @@ -505,14 +505,14 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of grid * * @param array $bg_colorgrid array(R,G,B) ou 'onglet' ou 'default' * @return void */ - function SetBgColorGrid($bg_colorgrid = array(255,255,255)) + public function SetBgColorGrid($bg_colorgrid = array(255,255,255)) { // phpcs:enable global $theme_bgcolor,$theme_bgcoloronglet; @@ -535,25 +535,25 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset data color * * @return void */ - function ResetDataColor() - { + public function ResetDataColor() + { // phpcs:enable - unset($this->datacolor); - } + unset($this->datacolor); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Get max value * * @return int Max value */ - function GetMaxValueInData() + public function GetMaxValueInData() { // phpcs:enable $k = 0; @@ -574,13 +574,13 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return int Min value of all data */ - function GetMinValueInData() + public function GetMinValueInData() { // phpcs:enable $k = 0; @@ -601,13 +601,13 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return max value of all data * * @return int Max value of all data */ - function GetCeilMaxValue() + public function GetCeilMaxValue() { // phpcs:enable $max = $this->GetMaxValueInData(); @@ -626,13 +626,13 @@ class DolGraph return $res; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return double Max value of all data */ - function GetFloorMinValue() + public function GetFloorMinValue() { // phpcs:enable $min = $this->GetMinValueInData(); @@ -658,7 +658,7 @@ class DolGraph * @param string $fileurl Url path to show image if saved onto disk * @return integer|null */ - function draw($file, $fileurl = '') + public function draw($file, $fileurl = '') { if (empty($file)) { @@ -1127,7 +1127,7 @@ class DolGraph * @param int $shownographyet Show graph to say there is not enough data * @return string HTML string to show graph */ - function show($shownographyet = 0) + public function show($shownographyet = 0) { global $langs; @@ -1149,7 +1149,7 @@ class DolGraph * @param string $defaultsize Value we want as default size * @return int Value of width or height to use by default */ - static function getDefaultGraphSizeForStats($direction, $defaultsize = '') + public static function getDefaultGraphSizeForStats($direction, $defaultsize = '') { global $conf; diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 19de8abb3f6..0a98925e46a 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -111,9 +111,9 @@ class dolReceiptPrinter extends Escpos */ public $db; - var $tags; - var $printer; - var $template; + public $tags; + public $printer; + public $template; /** * @var string Error code (or message) @@ -132,7 +132,7 @@ class dolReceiptPrinter extends Escpos * * @param DoliDB $db database */ - function __construct($db) + public function __construct($db) { $this->db=$db; $this->tags = array( @@ -211,7 +211,7 @@ class dolReceiptPrinter extends Escpos * * @return int 0 if OK; >0 if KO */ - function listPrinters() + public function listPrinters() { global $conf; $error = 0; @@ -279,7 +279,7 @@ class dolReceiptPrinter extends Escpos * * @return int 0 if OK; >0 if KO */ - function listPrintersTemplates() + public function listPrintersTemplates() { global $conf; $error = 0; @@ -311,7 +311,7 @@ class dolReceiptPrinter extends Escpos * @param string $htmlname select html name * @return int 0 if OK; >0 if KO */ - function selectTypePrinter($selected = '', $htmlname = 'printertypeid') + public function selectTypePrinter($selected = '', $htmlname = 'printertypeid') { global $langs; @@ -335,7 +335,7 @@ class dolReceiptPrinter extends Escpos * @param string $htmlname select html name * @return int 0 if OK; >0 if KO */ - function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') + public function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') { global $langs; @@ -352,7 +352,6 @@ class dolReceiptPrinter extends Escpos } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Add a printer in db * @@ -362,9 +361,8 @@ class dolReceiptPrinter extends Escpos * @param string $parameter Printer parameter * @return int 0 if OK; >0 if KO */ - function AddPrinter($name, $type, $profile, $parameter) + public function addPrinter($name, $type, $profile, $parameter) { - // phpcs:enable global $conf; $error = 0; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; @@ -378,7 +376,6 @@ class dolReceiptPrinter extends Escpos return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Update a printer in db * @@ -389,9 +386,8 @@ class dolReceiptPrinter extends Escpos * @param int $printerid Printer id * @return int 0 if OK; >0 if KO */ - function UpdatePrinter($name, $type, $profile, $parameter, $printerid) + public function updatePrinter($name, $type, $profile, $parameter, $printerid) { - // phpcs:enable global $conf; $error = 0; $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; @@ -408,16 +404,14 @@ class dolReceiptPrinter extends Escpos return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Delete a printer from db * * @param int $printerid Printer id * @return int 0 if OK; >0 if KO */ - function DeletePrinter($printerid) + public function deletePrinter($printerid) { - // phpcs:enable global $conf; $error = 0; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; @@ -430,7 +424,6 @@ class dolReceiptPrinter extends Escpos return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Update a printer template in db * @@ -439,9 +432,8 @@ class dolReceiptPrinter extends Escpos * @param int $templateid Template id * @return int 0 if OK; >0 if KO */ - function UpdateTemplate($name, $template, $templateid) + public function updateTemplate($name, $template, $templateid) { - // phpcs:enable global $conf; $error = 0; $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; @@ -457,20 +449,18 @@ class dolReceiptPrinter extends Escpos } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Send Test page to Printer * * @param int $printerid Printer id * @return int 0 if OK; >0 if KO */ - function SendTestToPrinter($printerid) + public function sendTestToPrinter($printerid) { - // phpcs:enable global $conf; $error = 0; $img = new EscposImage(DOL_DOCUMENT_ROOT .'/theme/common/dolibarr_logo_bw.png'); - $ret = $this->InitPrinter($printerid); + $ret = $this->initPrinter($printerid); if ($ret>0) { setEventMessages($this->error, $this->errors, 'errors'); } else { @@ -492,7 +482,6 @@ class dolReceiptPrinter extends Escpos return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Print Receipt Ticket * @@ -501,9 +490,8 @@ class dolReceiptPrinter extends Escpos * @param int $printerid Printer id * @return int 0 if OK; >0 if KO */ - function SendToPrinter($object, $templateid, $printerid) + public function sendToPrinter($object, $templateid, $printerid) { - // phpcs:enable global $conf; $error = 0; $ret = $this->loadTemplate($templateid); @@ -542,15 +530,12 @@ class dolReceiptPrinter extends Escpos // print ticket $level = 0; $html = '
';
-        $ret = $this->InitPrinter($printerid);
+        $ret = $this->initPrinter($printerid);
         if ($ret>0) {
             setEventMessages($this->error, $this->errors, 'errors');
-        }
-        else
-        {
+        } else {
             $nboflines = count($vals);
-            for ($line=0; $line < $nboflines; $line++)
-            {
+            for ($line=0; $line < $nboflines; $line++) {
                 switch ($vals[$line]['tag']) {
                     case 'DOL_ALIGN_CENTER':
                         $this->printer->setJustification(Escpos::JUSTIFY_CENTER);
@@ -627,10 +612,10 @@ class dolReceiptPrinter extends Escpos
     /**
      *  Function to load Template
      *
-     *  @param   int       $templateid        Template id
-     *  @return  int                        0 if OK; >0 if KO
+     *  @param   int       $templateid          Template id
+     *  @return  int                            0 if OK; >0 if KO
      */
-    function loadTemplate($templateid)
+    public function loadTemplate($templateid)
     {
         global $conf;
         $error = 0;
@@ -656,16 +641,14 @@ class dolReceiptPrinter extends Escpos
     }
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
     /**
      *  Function Init Printer
      *
      *  @param   int       $printerid       Printer id
      *  @return  int                        0 if OK; >0 if KO
      */
-    function InitPrinter($printerid)
+    public function initPrinter($printerid)
     {
-        // phpcs:enable
         global $conf;
         $error=0;
         $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php
index 5c9797a2407..f9eeeabf4c6 100644
--- a/htdocs/core/class/emailsenderprofile.class.php
+++ b/htdocs/core/class/emailsenderprofile.class.php
@@ -277,7 +277,7 @@ class EmailSenderProfile extends CommonObject
 	 *	@param	int		$withpicto					Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
 	 *	@return	string								String with URL
 	 */
-	function getNomUrl($withpicto = 0)
+	public function getNomUrl($withpicto = 0)
 	{
 		global $db, $conf, $langs;
 		global $dolibarr_main_authentication, $dolibarr_main_demo;
@@ -286,16 +286,15 @@ class EmailSenderProfile extends CommonObject
 		$result = '';
 		$companylink = '';
 
-    $label=$this->label;
+        $label=$this->label;
 
-    $url='';
+        $url='';
 		//$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id;
 
 		$linkstart = '';
 		$linkend='';
 
-		if ($withpicto)
-		{
+		if ($withpicto) {
 			$result.=($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend);
 			if ($withpicto != 2) $result.=' ';
 		}
@@ -303,29 +302,18 @@ class EmailSenderProfile extends CommonObject
 		return $result;
 	}
 
-	/**
-	 * Return link to download file from a direct external access
-	 *
-	 * @param	int				$withpicto			Add download picto into link
-	 * @return	string			HTML link to file
-	 */
-	function getDirectExternalLink($withpicto = 0)
-	{
-		return 'todo';
-	}
-
 	/**
 	 *  Retourne le libelle du status d'un user (actif, inactif)
 	 *
 	 *  @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
 	 *
@@ -333,49 +321,49 @@ class EmailSenderProfile 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)
 	{
 		global $langs;
 
 		if ($mode == 0 || $mode == 1)
 		{
 			if ($status == 1) return $langs->trans('Enabled');
-			if ($status == 0) return $langs->trans('Disabled');
+			elseif ($status == 0) return $langs->trans('Disabled');
 		}
 		elseif ($mode == 2)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
-			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
 		}
 		elseif ($mode == 3)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
-			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
 		}
 		elseif ($mode == 4)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
-			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
 		}
 		elseif ($mode == 5)
 		{
 			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
 		}
 		elseif ($mode == 6)
 		{
 			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
 		}
 	}
 
-	/**
-	 *	Charge les informations d'ordre info dans l'objet commande
+    /**
+     *  Charge les informations d'ordre info dans l'objet commande
 	 *
-	 *	@param  int		$id       Id of order
-	 *	@return	void
+	 *  @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/core/class/events.class.php b/htdocs/core/class/events.class.php
index 50b948a85be..50fc116611a 100644
--- a/htdocs/core/class/events.class.php
+++ b/htdocs/core/class/events.class.php
@@ -119,7 +119,7 @@ class Events // extends CommonObject
 	 *
 	 *  @param		DoliDB		$db      Database handler
 	 */
-	function __construct($db)
+	public function __construct($db)
 	{
 		$this->db = $db;
 	}
@@ -129,9 +129,9 @@ class Events // extends CommonObject
 	 *   Create in database
 	 *
 	 *   @param      User	$user       User that create
-	 *   @return     int     		    <0 if KO, >0 if OK
+	 *   @return     int                <0 if KO, >0 if OK
 	 */
-	function create($user)
+	public function create($user)
 	{
 		global $conf, $langs;
 
@@ -183,7 +183,7 @@ class Events // extends CommonObject
 	 * @param   int		$notrigger	    0=no, 1=yes (no update trigger)
 	 * @return  int         			<0 if KO, >0 if OK
 	 */
-	function update($user = null, $notrigger = 0)
+    public function update($user = null, $notrigger = 0)
 	{
 		global $conf, $langs;
 
@@ -220,7 +220,7 @@ class Events // extends CommonObject
 	 *  @param  User	$user       User that load
 	 *  @return int         		<0 if KO, >0 if OK
 	 */
-	function fetch($id, $user = null)
+    public function fetch($id, $user = null)
 	{
 		global $langs;
 
@@ -271,7 +271,7 @@ class Events // extends CommonObject
 	 *	@param	User	$user       User that delete
 	 *	@return	int					<0 if KO, >0 if OK
 	 */
-	function delete($user)
+    public function delete($user)
 	{
 		global $conf, $langs;
 
@@ -296,8 +296,8 @@ class Events // extends CommonObject
      *	id must be 0 if object instance is a specimen.
      *
      *  @return	void
-	 */
-	function initAsSpecimen()
+     */
+    public function initAsSpecimen()
 	{
 		$this->id=0;
 
@@ -305,5 +305,5 @@ class Events // extends CommonObject
 		$this->type='';
 		$this->dateevent=time();
 		$this->description='This is a specimen event';
-	}
+    }
 }
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 0ef7f8d295b..ce8916c1871 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -148,7 +148,7 @@ class ExtraFields
 	public $errors = array();
 
     /**
-	 * @var integer DB Error number
+	 * @var string DB Error number
 	 */
 	public $errno;
 
@@ -182,7 +182,7 @@ class ExtraFields
 	 *
 	 *  @param		DoliDB		$db      Database handler
 	*/
-	function __construct($db)
+	public function __construct($db)
 	{
 		$this->db = $db;
 		$this->error = '';
@@ -226,7 +226,7 @@ class ExtraFields
 	 *  @param  string  		$enabled  		 	Condition to have the field enabled or not
 	 *  @return int      							<=0 if KO, >0 if OK
 	 */
-	function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1')
+	public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1')
 	{
 		if (empty($attrname)) return -1;
 		if (empty($label)) return -1;
@@ -469,7 +469,7 @@ class ExtraFields
 	 *  @param  string	$elementtype    Element type ('member', 'product', 'thirdparty', 'contact', ...)
 	 *  @return int              		< 0 if KO, 0 if nothing is done, 1 if OK
 	 */
-	function delete($attrname, $elementtype = 'member')
+	public function delete($attrname, $elementtype = 'member')
 	{
 		if ($elementtype == 'thirdparty') $elementtype='societe';
 		if ($elementtype == 'contact') $elementtype='socpeople';
@@ -586,7 +586,7 @@ class ExtraFields
      *  @param  int     $totalizable        Is extrafield totalizable on list
 	 * 	@return	int							>0 if OK, <=0 if KO
 	 */
-	function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0)
+	public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0)
 	{
 		if ($elementtype == 'thirdparty') $elementtype='societe';
 		if ($elementtype == 'contact') $elementtype='socpeople';
@@ -819,7 +819,7 @@ class ExtraFields
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * 	Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ...
 	 *
@@ -827,7 +827,7 @@ class ExtraFields
 	 * 	@param	boolean		$forceload			Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED. Deprecated. Should not be required.
 	 * 	@return	array							Array of attributes keys+label for all extra fields.
 	 */
-	function fetch_name_optionals_label($elementtype, $forceload = false)
+	public function fetch_name_optionals_label($elementtype, $forceload = false)
 	{
         // phpcs:enable
 		global $conf;
@@ -950,7 +950,7 @@ class ExtraFields
 	 * @param  string  $extrafieldsobjectkey	If defined (for example $object->table_element), use the new method to get extrafields data
 	 * @return string
 	 */
-	function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '')
+	public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '')
 	{
 		global $conf,$langs,$form;
 
@@ -1565,7 +1565,7 @@ class ExtraFields
 	 * @param	string	$extrafieldsobjectkey	If defined (for example $object->table_element), use the new method to get extrafields data
 	 * @return	string							Formated value
 	 */
-	function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '')
+	public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '')
 	{
 		global $conf,$langs;
 
@@ -1877,7 +1877,7 @@ class ExtraFields
 	 * @param	string	$extrafieldsobjectkey	If defined, use the new method to get extrafields data
 	 * @return	string							Formated value
 	 */
-	function getAlignFlag($key, $extrafieldsobjectkey = '')
+	public function getAlignFlag($key, $extrafieldsobjectkey = '')
 	{
 		global $conf,$langs;
 
@@ -1929,7 +1929,7 @@ class ExtraFields
 	 * @param	string	$object			Object
 	 * @return 	string					HTML code with line for separator
 	 */
-	function showSeparator($key, $object)
+	public function showSeparator($key, $object)
 	{
 		global $langs;
 
@@ -1947,7 +1947,7 @@ class ExtraFields
 	 * @param	string	$onlykey		Only following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must must set this to avoid to have other extrafields being reset.
 	 * @return	int						1 if array_options set, 0 if no value, -1 if error (field required missing for example)
 	 */
-	function setOptionalsFromPost($extralabels, &$object, $onlykey = '')
+	public function setOptionalsFromPost($extralabels, &$object, $onlykey = '')
 	{
 		global $_POST, $langs;
 		$nofillrequired='';// For error when required field left blank
@@ -2046,7 +2046,7 @@ class ExtraFields
 	 * @param  string			$keysuffix      		Suffix string to add into name and id of field (can be used to avoid duplicate names)
 	 * @return array|int								array_options set or 0 if no value
 	 */
-	function getOptionalsFromPost($extrafieldsobjectkey, $keyprefix = '', $keysuffix = '')
+	public function getOptionalsFromPost($extrafieldsobjectkey, $keyprefix = '', $keysuffix = '')
 	{
 		global $_POST;
 
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index d90707db4dd..bd36dba199b 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -41,7 +41,7 @@ class FileUpload
 	 * @param int		$fk_element		fk_element
 	 * @param string	$element		element
 	 */
-	function __construct($options = null, $fk_element = null, $element = null)
+	public function __construct($options = null, $fk_element = null, $element = null)
 	{
 		global $db, $conf;
 		global $object;
diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php
index ddbe70303d2..014946434be 100644
--- a/htdocs/core/class/fiscalyear.class.php
+++ b/htdocs/core/class/fiscalyear.class.php
@@ -82,7 +82,7 @@ class Fiscalyear extends CommonObject
 	 *
 	 * @param	DoliDB		$db		Database handler
 	 */
-	function __construct(DoliDB $db)
+	public function __construct(DoliDB $db)
 	{
 		global $langs;
 
@@ -98,7 +98,7 @@ class Fiscalyear extends CommonObject
 	 *	@param		User	$user   User making creation
 	 *	@return 	int				<0 if KO, >0 if OK
 	 */
-	function create($user)
+	public function create($user)
 	{
 		global $conf;
 
@@ -159,7 +159,7 @@ class Fiscalyear extends CommonObject
 	 *	@param	User	$user		User making update
 	 *	@return	int					<0 if KO, >0 if OK
 	 */
-	function update($user)
+	public function update($user)
 	{
 		global $langs;
 
@@ -203,7 +203,7 @@ class Fiscalyear extends CommonObject
 	* @param	int		$id		Id of record to load
 	* @return	int				<0 if KO, >0 if OK
 	*/
-	function fetch($id)
+	public function fetch($id)
 	{
 		$sql = "SELECT rowid, label, date_start, date_end, statut";
 		$sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear";
@@ -237,7 +237,7 @@ class Fiscalyear extends CommonObject
 	*	@param	int		$id		Id of record to delete
 	*	@return	int				<0 if KO, >0 if OK
 	*/
-	function delete($id)
+	public function delete($id)
 	{
 		$this->db->begin();
 
@@ -264,12 +264,12 @@ class Fiscalyear 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
 	 * @return  string   		   	Label
 	 */
-	function getLibStatut($mode = 0)
+	public function getLibStatut($mode = 0)
 	{
 		return $this->LibStatut($this->statut, $mode);
 	}
 
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Give a label from a status
 	 *
@@ -277,7 +277,7 @@ class Fiscalyear 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
 	 *  @return string      		Label
 	 */
-	function LibStatut($statut, $mode = 0)
+	public function LibStatut($statut, $mode = 0)
 	{
 		// phpcs:enable
 		global $langs;
@@ -318,7 +318,7 @@ class Fiscalyear extends CommonObject
 	 * @param	int		$id      Id of record
 	 * @return	void
 	 */
-	function info($id)
+	public function info($id)
 	{
 		$sql = 'SELECT fy.rowid, fy.datec, fy.fk_user_author, fy.fk_user_modif,';
 		$sql.= ' fy.tms';
@@ -364,7 +364,7 @@ class Fiscalyear extends CommonObject
 	 *	@param	int		$dateend	Date end to scan
 	 *	@return	string				Number of entries
 	 */
-	function getAccountancyEntriesByFiscalYear($datestart, $dateend)
+	public function getAccountancyEntriesByFiscalYear($datestart, $dateend)
 	{
 		global $conf;
 
@@ -386,11 +386,11 @@ class Fiscalyear extends CommonObject
 	/**
 	 *  Return the number of movements by fiscal year
 	 *
-	 *	@param	int		$datestart	Date start to scan
-	 *	@param	int		$dateend	Date end to scan
-	 *	@return	string				Number of movements
+	 *  @param	int		$datestart	Date start to scan
+	 *  @param	int		$dateend	Date end to scan
+	 *  @return	string				Number of movements
 	 */
-	function getAccountancyMovementsByFiscalYear($datestart, $dateend)
+	public function getAccountancyMovementsByFiscalYear($datestart, $dateend)
 	{
 		global $conf;
 
diff --git a/htdocs/core/class/genericobject.class.php b/htdocs/core/class/genericobject.class.php
index 993d884c88b..a8d837bbaba 100644
--- a/htdocs/core/class/genericobject.class.php
+++ b/htdocs/core/class/genericobject.class.php
@@ -34,7 +34,7 @@ class GenericObject extends CommonObject
      *
      * @param       DoliDB      $db     Database handler
      */
-    function __construct($db)
+    public function __construct($db)
     {
         $this->db=$db;
     }
diff --git a/htdocs/core/class/google.class.php b/htdocs/core/class/google.class.php
index 797f0a14af1..a472e6dcf22 100644
--- a/htdocs/core/class/google.class.php
+++ b/htdocs/core/class/google.class.php
@@ -26,63 +26,63 @@
  */
 class GoogleAPI
 {
-	/**
+    /**
      * @var DoliDB Database handler.
      */
     public $db;
 
-	/**
-	 * @var string Error code (or message)
-	 */
-	public $error='';
+    /**
+     * @var string Error code (or message)
+     */
+    public $error='';
 
-	public $key;
+    public $key;
 
-	/**
-	 * Constructor
-	 *
-	 * @param 	DoliDB		$db			Database handler
-	 * @param	string		$key		Google key
-	 */
-	function __construct($db, $key)
-	{
-		$this->db=$db;
-		$this->key=$key;
-	}
+    /**
+     * Constructor
+     *
+     * @param 	DoliDB		$db			Database handler
+     * @param	string		$key		Google key
+     */
+    public function __construct($db, $key)
+    {
+        $this->db=$db;
+        $this->key=$key;
+    }
 
 
-	/**
-	 *  Return geo coordinates of an address
-	 *
-	 *  @param	string	$address	Address
-	 * 								Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France
-	 *								Example: 188, rue de Fontenay,+94300,+Vincennes,+France
-	 *	@return	string				Coordinates
-	 */
-	function getGeoCoordinatesOfAddress($address)
-	{
-		global $conf;
+    /**
+     *  Return geo coordinates of an address
+     *
+     *  @param	string	$address	Address
+     * 								Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France
+     *								Example: 188, rue de Fontenay,+94300,+Vincennes,+France
+     *	@return	string				Coordinates
+     */
+    public function getGeoCoordinatesOfAddress($address)
+    {
+        global $conf;
 
-		$i=0;
+        $i=0;
 
-		// Desired address
-		$urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key;
+        // Desired address
+        $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key;
 
-		// Retrieve the URL contents
-		$page = file_get_contents($urladdress);
+        // Retrieve the URL contents
+        $page = file_get_contents($urladdress);
 
-		$code = strstr($page, '');
-		$code = strstr($code, '>');
-		$val=strpos($code, "<");
-		$code = substr($code, 1, $val-1);
-		//print $code;
-		//print "
"; - $latitude = substr($code, 0, strpos($code, ",")); - $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); + $code = strstr($page, ''); + $code = strstr($code, '>'); + $val=strpos($code, "<"); + $code = substr($code, 1, $val-1); + //print $code; + //print "
"; + $latitude = substr($code, 0, strpos($code, ",")); + $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); - // Output the coordinates - //echo "Longitude: $longitude ',' Latitude: $latitude"; + // Output the coordinates + //echo "Longitude: $longitude ',' Latitude: $latitude"; - $i++; - } + $i++; + } } diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 0db47d1ade0..f23aa1da5a3 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -45,24 +45,24 @@ class HookManager public $errors = array(); // Context hookmanager was created for ('thirdpartycard', 'thirdpartydao', ...) - var $contextarray=array(); + public $contextarray=array(); // Array with instantiated classes - var $hooks=array(); + public $hooks=array(); // Array result - var $resArray=array(); + public $resArray=array(); // Printable result - var $resPrint=''; + public $resPrint=''; // Nb of qualified hook ran - var $resNbOfHooks=0; + public $resNbOfHooks=0; /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -79,7 +79,7 @@ class HookManager * @param string[] $arraycontext Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ... * @return int Always 1 */ - function initHooks($arraycontext) + public function initHooks($arraycontext) { global $conf; @@ -125,18 +125,18 @@ class HookManager } /** - * Execute hooks (if they were initialized) for the given method + * Execute hooks (if they were initialized) for the given method * - * @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...) - * @param array $parameters Array of parameters - * @param Object $object Object to use hooks on - * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) - * @return mixed For 'addreplace' hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. - * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. - * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. - * $this->error or this->errors are also defined by class called by this function if error. + * @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...) + * @param array $parameters Array of parameters + * @param Object $object Object to use hooks on + * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) + * @return mixed For 'addreplace' hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. + * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. + * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. + * $this->error or this->errors are also defined by class called by this function if error. */ - function executeHooks($method, $parameters = array(), &$object = '', &$action = '') + public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') { if (! is_array($this->hooks) || empty($this->hooks)) return ''; @@ -145,7 +145,7 @@ class HookManager // Define type of hook ('output' or 'addreplace'. 'returnvalue' is deprecated because a 'addreplace' hook can also return resPrint and resArray). $hooktype='output'; -if (in_array( + if (in_array( $method, array( 'addCalendarChoice', @@ -204,10 +204,9 @@ if (in_array( ) )) $hooktype='addreplace'; - if ($method == 'insertExtraFields') - { - $hooktype='returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available. - dol_syslog("Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)", LOG_WARNING); + if ($method == 'insertExtraFields') { + $hooktype='returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available. + dol_syslog("Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)", LOG_WARNING); } // Init return properties diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0f8969cdace..a83ff1083e6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -17,7 +17,7 @@ * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2014 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Christophe Battarel * Copyright (C) 2018 Josep Lluis Amador @@ -102,7 +102,7 @@ class Form * @param string $paramid Key of parameter for id ('id', 'socid') * @return string HTML edit field */ - function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id') + public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id') { global $conf,$langs; @@ -164,7 +164,7 @@ class Form * @param string $paramid Key of parameter for id ('id', 'socid') * @return string HTML edit field */ - function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 0, $formatfunc = '', $paramid = 'id') + public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 0, $formatfunc = '', $paramid = 'id') { global $conf,$langs,$db; @@ -441,7 +441,7 @@ class Form * @see Use function textwithpicto if you can. * TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip */ - function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) + public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) { global $conf; @@ -526,7 +526,7 @@ class Form * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string HTML code of text, picto, tooltip */ - function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger = '', $forcenowrap = 0) + public function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger = '', $forcenowrap = 0) { global $conf, $langs; @@ -578,7 +578,7 @@ class Form * @param int $alwaysvisible 1=select button always visible * @return string Select list */ - function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0) + public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0) { global $conf,$langs,$hookmanager; @@ -663,7 +663,7 @@ class Form return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return combo list of activated countries, into language of user * @@ -678,7 +678,7 @@ class Form * @param int $addspecialentries 1=Add dedicated entries for group of countries (like 'European Economic Community', ...) * @return string HTML string with select */ - function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0) + public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0) { // phpcs:enable global $conf,$langs,$mysoc; @@ -778,7 +778,7 @@ class Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of incoterms * @@ -791,7 +791,7 @@ class Form * @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return string HTML string with select and input */ - function select_incoterms($selected = '', $location_incoterms = '', $page = '', $htmlname = 'incoterm_id', $htmloption = '', $forcecombo = 1, $events = array()) + public function select_incoterms($selected = '', $location_incoterms = '', $page = '', $htmlname = 'incoterm_id', $htmloption = '', $forcecombo = 1, $events = array()) { // phpcs:enable global $conf,$langs; @@ -872,7 +872,7 @@ class Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of types of lines (product or service) * Example: 0=product, 1=service, 9=other (for external module) @@ -884,7 +884,7 @@ class Form * @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service') * @return void */ - function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0) + public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0) { // phpcs:enable global $db,$langs,$user,$conf; @@ -929,13 +929,13 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into cache cache_types_fees, array of types of fees * * @return int Nb of lines loaded, <0 if KO */ - function load_cache_types_fees() + public function load_cache_types_fees() { // phpcs:enable global $langs; @@ -978,7 +978,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of types of notes * @@ -987,7 +987,7 @@ class Form * @param int $showempty Add an empty field * @return void */ - function select_type_fees($selected = '', $htmlname = 'type', $showempty = 0) + public function select_type_fees($selected = '', $htmlname = 'type', $showempty = 0) { // phpcs:enable global $user, $langs; @@ -1018,7 +1018,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML code to select a company. * @@ -1031,13 +1031,13 @@ class Form * @return string Return select box for thirdparty. * @deprecated 3.8 Use select_company instead. For exemple $form->select_thirdparty(GETPOST('socid'),'socid','',0) => $form->select_company(GETPOST('socid'),'socid','',1,0,0,array(),0) */ - function select_thirdparty($selected = '', $htmlname = 'socid', $filter = '', $limit = 20, $ajaxoptions = array(), $forcecombo = 0) + public function select_thirdparty($selected = '', $htmlname = 'socid', $filter = '', $limit = 20, $ajaxoptions = array(), $forcecombo = 0) { // phpcs:enable return $this->select_thirdparty_list($selected, $htmlname, $filter, 1, 0, $forcecombo, array(), '', 0, $limit); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output html form to select a third party * @@ -1057,7 +1057,7 @@ class Form * @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter) * @return string HTML string with select box for thirdparty. */ - function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false) + public function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false) { // phpcs:enable global $conf,$user,$langs; @@ -1101,7 +1101,7 @@ class Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output html form to select a third party. * Note, you must use the select_company to get the component to select a third party. This function must only be called by select_company. @@ -1121,7 +1121,7 @@ class Form * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string HTML string with */ - function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false) + public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false) { // phpcs:enable global $conf,$user,$langs; @@ -1284,18 +1284,18 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return HTML combo list of absolute discounts + * Return HTML combo list of absolute discounts * - * @param string $selected Id remise fixe pre-selectionnee - * @param string $htmlname Nom champ formulaire - * @param string $filter Criteres optionnels de filtre - * @param int $socid Id of thirdparty - * @param int $maxvalue Max value for lines that can be selected - * @return int Return number of qualifed lines in list + * @param string $selected Id remise fixe pre-selectionnee + * @param string $htmlname Nom champ formulaire + * @param string $filter Criteres optionnels de filtre + * @param int $socid Id of thirdparty + * @param int $maxvalue Max value for lines that can be selected + * @return int Return number of qualifed lines in list */ - function select_remises($selected, $htmlname, $filter, $socid, $maxvalue = 0) + public function select_remises($selected, $htmlname, $filter, $socid, $maxvalue = 0) { // phpcs:enable global $langs,$conf; @@ -1361,33 +1361,33 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of all contacts (for a third party or all) + * Return list of all contacts (for a third party or all) * - * @param int $socid Id ot third party or 0 for all - * @param string $selected Id contact pre-selectionne - * @param string $htmlname Name of HTML field ('none' for a not editable field) - * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list - * @param string $exclude List of contacts id to exclude - * @param string $limitto Disable answers that are not id in this array list - * @param integer $showfunction Add function into label - * @param string $moreclass Add more class to class style - * @param integer $showsoc Add company into label - * @param int $forcecombo Force to use combo box + * @param int $socid Id ot third party or 0 for all + * @param string $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML field ('none' for a not editable field) + * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list + * @param string $exclude List of contacts id to exclude + * @param string $limitto Disable answers that are not id in this array list + * @param integer $showfunction Add function into label + * @param string $moreclass Add more class to class style + * @param integer $showsoc Add company into label + * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param bool $options_only Return options only (for ajax treatment) * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @param string $htmlid Html id to use instead of htmlname - * @return int <0 if KO, Nb of contact in list if OK + * @return int <0 if KO, Nb of contact in list if OK * @deprected You can use selectcontacts directly (warning order of param was changed) */ - function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '') - { + public function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '') + { // phpcs:enable print $this->selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $moreclass, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid); return $this->num; - } + } /** * Return HTML code of the SELECT of list of all contacts (for a third party or all). @@ -1412,8 +1412,8 @@ class Form * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return int <0 if KO, Nb of contact in list if OK */ - function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false) - { + public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false) + { global $conf,$langs,$hookmanager,$action; $langs->load('companies'); @@ -1543,7 +1543,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of users * @@ -1559,13 +1559,13 @@ class Form * @deprecated Use select_dolusers instead * @see select_dolusers() */ - function select_users($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0') + public function select_users($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0') { // phpcs:enable print $this->select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of users * @@ -1589,7 +1589,7 @@ class Form * @return string HTML select string * @see select_dolgroups */ - function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false) + public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false) { // phpcs:enable global $conf,$user,$langs; @@ -1774,7 +1774,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of users. Selected users are stored into session. * List of users are provided into $_SESSION['assignedtouser']. @@ -1797,7 +1797,7 @@ class Form * @return string HTML select string * @see select_dolgroups */ - function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array()) + public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array()) { // phpcs:enable global $conf, $user, $langs; @@ -1864,7 +1864,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for customer in Ajax if Ajax activated or go to select_produits_list * @@ -1890,7 +1890,7 @@ class Form * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) * @return void */ - function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = array()) + public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = array()) { // phpcs:enable global $langs,$conf; @@ -2008,7 +2008,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for a customer * @@ -2032,7 +2032,7 @@ class Form * 'warehouseinternal' = select products from warehouses for internal correct/transfer only * @return array Array of keys for json */ - function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') + public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') { // phpcs:enable global $langs,$conf,$user,$db; @@ -2561,7 +2561,7 @@ class Form $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>$outprice_ht, 'price_ttc'=>$outprice_ttc, 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) * @@ -2576,7 +2576,7 @@ class Form * @param string $morecss More CSS * @return void */ - function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') + public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') { // phpcs:enable global $langs,$conf; @@ -2605,7 +2605,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of suppliers products * @@ -2622,7 +2622,7 @@ class Form * @param string $morecss Add more CSS * @return array Array of keys for json */ - function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') + public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') { // phpcs:enable global $langs,$conf,$db; @@ -2837,7 +2837,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of suppliers prices for a product * @@ -2846,7 +2846,7 @@ class Form * @param int $selected_supplier Pre-selected supplier if more than 1 result * @return void */ - function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') + public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') { // phpcs:enable global $langs,$conf; @@ -2950,7 +2950,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of delivery address * @@ -2960,7 +2960,7 @@ class Form * @param int $showempty Add an empty field * @return integer|null */ - function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) + public function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) { // phpcs:enable // looking for users @@ -3004,13 +3004,13 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into cache list of payment terms * * @return int Nb of lines loaded, <0 if KO */ - function load_cache_conditions_paiements() + public function load_cache_conditions_paiements() { // phpcs:enable global $langs; @@ -3053,13 +3053,13 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge dans cache la liste des délais de livraison possibles * * @return int Nb of lines loaded, <0 if KO */ - function load_cache_availability() + public function load_cache_availability() { // phpcs:enable global $langs; @@ -3111,7 +3111,7 @@ class Form * @param int $addempty Add empty entry * @return void */ - function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) + public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) { global $langs,$user; @@ -3143,7 +3143,7 @@ class Form * * @return int Nb of lines loaded, <0 if KO */ - function loadCacheInputReason() + public function loadCacheInputReason() { global $langs; @@ -3197,7 +3197,7 @@ class Form * @param int $addempty Add an empty entry * @return void */ - function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) + public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) { global $langs,$user; @@ -3225,13 +3225,13 @@ class Form if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge dans cache la liste des types de paiements possibles * * @return int Nb of lines loaded, <0 if KO */ - function load_cache_types_paiements() + public function load_cache_types_paiements() { // phpcs:enable global $langs; @@ -3279,7 +3279,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment modes. * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want. @@ -3293,7 +3293,7 @@ class Form * @param string $morecss Add more CSS on select tag * @return void */ - function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') + public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') { // phpcs:enable global $langs, $user, $conf; @@ -3325,7 +3325,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment methods * @@ -3340,7 +3340,7 @@ class Form * @param string $morecss Add more CSS on select tag * @return void */ - function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') + public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') { // phpcs:enable global $langs,$user; @@ -3394,7 +3394,7 @@ class Form * @param string $htmlname Nom de la zone select * @return string Code of HTML select to chose tax or not */ - function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') + public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') { global $langs; @@ -3432,7 +3432,7 @@ class Form * @param string $moreattrib To add more attribute on select * @return void */ - function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') + public function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') { global $langs, $conf, $user; @@ -3485,7 +3485,7 @@ class Form * @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 formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) + public function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) { global $langs, $db; @@ -3516,7 +3516,7 @@ class Form * * @return string HTML select */ - function selectSituationInvoices($selected = '', $socid = 0) + public function selectSituationInvoices($selected = '', $socid = 0) { global $langs; @@ -3570,7 +3570,7 @@ class Form * @param int $showempty Add a nempty line * @return string HTML select */ - function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) + public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) { global $langs; @@ -3608,7 +3608,7 @@ class Form return $return; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select list of bank accounts * @@ -3621,7 +3621,7 @@ class Form * @param int $showcurrency Show currency in label * @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...) */ - function select_comptes($selected = '', $htmlname = 'accountid', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0) + public function select_comptes($selected = '', $htmlname = 'accountid', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0) { // phpcs:enable global $langs, $conf; @@ -3682,6 +3682,75 @@ class Form return $num; } + /** + * Return a HTML select list of establishment + * + * @param string $selected Id establishment pre-selected + * @param string $htmlname Name of select zone + * @param int $statut Status of searched establishment (0=open, 1=closed, 2=both) + * @param string $filtre To filter list + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param string $moreattrib To add more attribute on select + * @return int <0 if error, Num of establishment found if OK (0, 1, 2, ...) + */ + public function selectEstablishments($selected = '', $htmlname = 'entity', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '') + { + // phpcs:enable + global $langs, $conf; + + $langs->load("admin"); + $num = 0; + + $sql = "SELECT rowid, name, fk_country, status, entity"; + $sql.= " FROM ".MAIN_DB_PREFIX."establishment"; + $sql.= " WHERE 1=1"; + if ($statut != 2) $sql.= " AND status = '".$statut."'"; + if ($filtre) $sql.=" AND ".$filtre; + $sql.= " ORDER BY name"; + + dol_syslog(get_class($this)."::select_establishment", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + if ($num) + { + print '"; + } + else + { + if ($statut == 0) print ''.$langs->trans("NoActiveEstablishmentDefined").''; + else print ''.$langs->trans("NoEstablishmentFound").''; + } + } + else { + dol_print_error($this->db); + } + } + /** * Display form to select bank account * @@ -3691,7 +3760,7 @@ class Form * @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 formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) + public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) { global $langs; if ($htmlname != "none") { @@ -3716,7 +3785,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of categories having choosed type * @@ -3729,7 +3798,7 @@ class Form * @return string * @see select_categories */ - function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $excludeafterid = 0, $outputmode = 0) + public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $excludeafterid = 0, $outputmode = 0) { // phpcs:enable global $conf, $langs; @@ -3803,7 +3872,7 @@ class Form return $output; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a confirmation HTML form or AJAX popup * @@ -3820,7 +3889,7 @@ class Form * @deprecated * @see formconfirm() */ - function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) + public function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) { // phpcs:enable dol_syslog(__METHOD__ . ': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING); @@ -3851,7 +3920,7 @@ class Form * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a section. * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form */ - function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 210, $width = 500, $disableformtag = 0) + public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 210, $width = 500, $disableformtag = 0) { global $langs,$conf; global $useglobalvars; @@ -4117,7 +4186,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a form to select a project * @@ -4131,7 +4200,7 @@ class Form * @param int $nooutput No print is done. String is returned. * @return string Return html content */ - function form_project($page, $socid, $selected = '', $htmlname = 'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0) + public function form_project($page, $socid, $selected = '', $htmlname = 'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0) { // phpcs:enable global $langs; @@ -4177,7 +4246,7 @@ class Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a form to select payment conditions * @@ -4187,7 +4256,7 @@ class Form * @param int $addempty Add empty entry * @return void */ - function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0) + public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0) { // phpcs:enable global $langs; @@ -4212,7 +4281,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a form to select a delivery delay * @@ -4222,7 +4291,7 @@ class Form * @param int $addempty Ajoute entree vide * @return void */ - function form_availability($page, $selected = '', $htmlname = 'availability', $addempty = 0) + public function form_availability($page, $selected = '', $htmlname = 'availability', $addempty = 0) { // phpcs:enable global $langs; @@ -4248,17 +4317,17 @@ class Form } /** - * Output HTML form to select list of input reason (events that triggered an object creation, like after sending an emailing, making an advert, ...) + * Output HTML form to select list of input reason (events that triggered an object creation, like after sending an emailing, making an advert, ...) * List found into table c_input_reason loaded by loadCacheInputReason * * @param string $page Page * @param string $selected Id condition pre-selectionne * @param string $htmlname Name of select html field - * @param int $addempty Add empty entry + * @param int $addempty Add empty entry * @return void - */ - function formInputReason($page, $selected = '', $htmlname = 'demandreason', $addempty = 0) - { + */ + public function formInputReason($page, $selected = '', $htmlname = 'demandreason', $addempty = 0) + { global $langs; if ($htmlname != "none") { @@ -4288,7 +4357,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a form + html select a date * @@ -4301,7 +4370,7 @@ class Form * @return string * @see selectDate */ - function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0) + public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0) { // phpcs:enable global $langs; @@ -4331,7 +4400,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a select form to choose a user * @@ -4342,7 +4411,7 @@ class Form * @param array $include List of users id to include * @return void */ - function form_users($page, $selected = '', $htmlname = 'userid', $exclude = '', $include = '') + public function form_users($page, $selected = '', $htmlname = 'userid', $exclude = '', $include = '') { // phpcs:enable global $langs; @@ -4371,7 +4440,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form with payment mode * @@ -4383,7 +4452,7 @@ class Form * @param int $addempty 1=Add empty entry * @return void */ - function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0) + public function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0) { // phpcs:enable global $langs; @@ -4408,7 +4477,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form with multicurrency code * @@ -4417,7 +4486,7 @@ class Form * @param string $htmlname Name of select html field * @return void */ - function form_multicurrency_code($page, $selected = '', $htmlname = 'multicurrency_code') + public function form_multicurrency_code($page, $selected = '', $htmlname = 'multicurrency_code') { // phpcs:enable global $langs; @@ -4437,7 +4506,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form with multicurrency rate * @@ -4447,7 +4516,7 @@ class Form * @param string $currency Currency code to explain the rate * @return void */ - function form_multicurrency_rate($page, $rate = '', $htmlname = 'multicurrency_tx', $currency = '') + public function form_multicurrency_rate($page, $rate = '', $htmlname = 'multicurrency_tx', $currency = '') { // phpcs:enable global $langs, $mysoc, $conf; @@ -4480,7 +4549,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a select box with available absolute discounts * @@ -4496,7 +4565,7 @@ class Form * @param int $discount_type 0 => customer discount, 1 => supplier discount * @return void */ - function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter = '', $maxvalue = 0, $more = '', $hidelist = 0, $discount_type = 0) + public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter = '', $maxvalue = 0, $more = '', $hidelist = 0, $discount_type = 0) { // phpcs:enable global $conf,$langs; @@ -4577,18 +4646,18 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Show forms to select a contact - * - * @param string $page Page - * @param Societe $societe Filter on third party - * @param int $selected Id contact pre-selectionne - * @param string $htmlname Name of HTML select. If 'none', we just show contact link. - * @return void - */ - function form_contacts($page, $societe, $selected = '', $htmlname = 'contactid') - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show forms to select a contact + * + * @param string $page Page + * @param Societe $societe Filter on third party + * @param int $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML select. If 'none', we just show contact link. + * @return void + */ + public function form_contacts($page, $societe, $selected = '', $htmlname = 'contactid') + { // phpcs:enable global $langs, $conf; @@ -4623,7 +4692,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output html select to select thirdparty * @@ -4638,7 +4707,7 @@ class Form * @param int $nooutput No print output. Return it only. * @return void */ - function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0) + public function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0) { // phpcs:enable global $langs; @@ -4672,7 +4741,7 @@ class Form else print $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste des devises, dans la langue de l'utilisateur * @@ -4681,7 +4750,7 @@ class Form * @deprecated * @return void */ - function select_currency($selected = '', $htmlname = 'currency_id') + public function select_currency($selected = '', $htmlname = 'currency_id') { // phpcs:enable print $this->selectCurrency($selected, $htmlname); @@ -4694,7 +4763,7 @@ class Form * @param string $htmlname name of HTML select list * @return string */ - function selectCurrency($selected = '', $htmlname = 'currency_id') + public function selectCurrency($selected = '', $htmlname = 'currency_id') { global $conf,$langs,$user; @@ -4737,7 +4806,7 @@ class Form * @param integer $useempty 1=Add empty line * @return string */ - function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0) + public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0) { global $db,$conf,$langs,$user; @@ -4755,7 +4824,7 @@ class Form $out=''; $out.= ''."\n"; if (is_array($array) && ! empty($array)) { @@ -6178,7 +6246,7 @@ class Form foreach ($array as $key => $value) { $out.= ''."\n"; + } + print ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return html select list with available languages (key='en_US', value='United States' for example) * * @param string $selected Paper format pre-selected * @param string $htmlname Name of HTML select field - * @param string $filter Value to filter on code - * @param int $showempty Add empty value - * @return string Return HTML output + * @param string $filter Value to filter on code + * @param int $showempty Add empty value + * @return string Return HTML output */ - function select_paper_format($selected = '', $htmlname = 'paperformat_id', $filter = 0, $showempty = 0) + public function select_paper_format($selected = '', $htmlname = 'paperformat_id', $filter = 0, $showempty = 0) { // phpcs:enable global $langs; diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index f7a7199ab03..c41ba24f17f 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -45,7 +45,7 @@ class FormBarCode * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -60,7 +60,7 @@ class FormBarCode * @param int $idForm Id du formulaire * @return string HTML select string */ - function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') + public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') { global $conf, $langs; @@ -86,7 +86,7 @@ class FormBarCode { $disable = 'disabled'; } - + if (!empty($conf->use_javascript_ajax)) { $select_encoder = ''; @@ -94,7 +94,7 @@ class FormBarCode $select_encoder.= ''; $select_encoder.= ''; } - + $selectname=(!empty($conf->use_javascript_ajax)?'coder':'coder'.$code_id); $select_encoder.= ''; - + if (!empty($conf->use_javascript_ajax)) { $select_encoder.= ''; @@ -113,7 +113,7 @@ class FormBarCode return $select_encoder; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Print form to select type of barcode * @@ -123,7 +123,7 @@ class FormBarCode * @return void * @deprecated */ - function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + public function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) { // phpcs:enable print $this->selectBarcodeType($selected, $htmlname, $useempty); @@ -137,7 +137,7 @@ class FormBarCode * @param int $useempty Display empty value in select * @return string */ - function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + public function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) { global $langs, $conf; @@ -183,7 +183,7 @@ class FormBarCode return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form to select type of barcode * @@ -193,7 +193,7 @@ class FormBarCode * @return void * @deprecated */ - function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') + public function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') { // phpcs:enable print $this->formBarcodeType($page, $selected, $htmlname); @@ -207,7 +207,7 @@ class FormBarCode * @param string $htmlname Nom du formulaire select * @return string */ - function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') + public function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') { global $langs, $conf; $out = ''; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index f92bee4519f..65f92c86948 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -46,13 +46,13 @@ class FormCompany * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of labels (translated) of third parties type * @@ -60,7 +60,7 @@ class FormCompany * @param string $filter Add a SQL filter to select * @return array Array of types */ - function typent_array($mode = 0, $filter = '') + public function typent_array($mode = 0, $filter = '') { // phpcs:enable global $langs,$mysoc; @@ -95,7 +95,7 @@ class FormCompany return $effs; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) * @@ -103,7 +103,7 @@ class FormCompany * @param string $filter Add a SQL filter to select * @return array Array of types d'effectifs */ - function effectif_array($mode = 0, $filter = '') + public function effectif_array($mode = 0, $filter = '') { // phpcs:enable $effs = array(); @@ -135,7 +135,7 @@ class FormCompany } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Affiche formulaire de selection des modes de reglement * @@ -145,7 +145,7 @@ class FormCompany * @param int $empty Add empty value in list * @return void */ - function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) + public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) { // phpcs:enable global $user, $langs; @@ -186,7 +186,7 @@ class FormCompany print ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. * In the case of an all-country list, the display breaks on the country. @@ -198,13 +198,13 @@ class FormCompany * @param string $htmlname Id of department * @return void */ - function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') + public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') { // phpcs:enable print $this->select_state($selected, $country_codeid, $htmlname); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. * In the case of an all-country list, the display breaks on the country. @@ -217,7 +217,7 @@ class FormCompany * @return string String with HTML select * @see select_country */ - function select_state($selected = '', $country_codeid = 0, $htmlname = 'state_id') + public function select_state($selected = '', $country_codeid = 0, $htmlname = 'state_id') { // phpcs:enable global $conf,$langs,$user; @@ -319,7 +319,7 @@ class FormCompany } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste deroulante des regions actives dont le pays est actif * La cle de la liste est le code (il peut y avoir plusieurs entree pour @@ -330,7 +330,7 @@ class FormCompany * @param string $htmlname Name of HTML select field * @return void */ - function select_region($selected = '', $htmlname = 'region_id') + public function select_region($selected = '', $htmlname = 'region_id') { // phpcs:enable global $conf,$langs; @@ -387,7 +387,7 @@ class FormCompany } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return combo list with people title * @@ -396,7 +396,7 @@ class FormCompany * @param string $morecss Add more css on SELECT element * @return string String with HTML select */ - function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth100') + public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth100') { // phpcs:enable global $conf,$langs,$user; @@ -445,7 +445,7 @@ class FormCompany return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays. @@ -457,13 +457,13 @@ class FormCompany * @deprecated Use print xxx->select_juridicalstatus instead * @see select_juridicalstatus() */ - function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '') + public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '') { // phpcs:enable print $this->select_juridicalstatus($selected, $country_codeid, $filter); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays @@ -474,7 +474,7 @@ class FormCompany * @param string $htmlname HTML name of select * @return string String with HTML select */ - function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code') + public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code') { // phpcs:enable global $conf,$langs,$user; @@ -579,7 +579,7 @@ class FormCompany * @param string $morecss More CSS on select component * @return int The selected third party ID */ - function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') + public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') { global $conf, $langs; @@ -738,7 +738,7 @@ class FormCompany * @param string $morecss Add more css to select component * @return void */ - function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') + public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') { global $user, $langs; @@ -762,7 +762,7 @@ class FormCompany } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a select list with zip codes and their town * @@ -775,7 +775,7 @@ class FormCompany * @param string $morecss More css * @return string */ - function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') + public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') { // phpcs:enable global $conf; @@ -795,7 +795,7 @@ class FormCompany return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...) * @@ -806,7 +806,7 @@ class FormCompany * @param string $morecss More css * @return string HTML string with prof id */ - function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') + public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') { // phpcs:enable global $conf,$langs; @@ -847,7 +847,7 @@ class FormCompany return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select with localtax values for thirdparties * @@ -856,7 +856,7 @@ class FormCompany * @param string $htmlname HTML select name * @return void */ - function select_localtax($local, $selected, $htmlname) + public function select_localtax($local, $selected, $htmlname) { // phpcs:enable $tax=get_localtax_by_third($local); @@ -900,7 +900,7 @@ class FormCompany * @param string $morecss More css * @return string HTML string */ - function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '') + public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '') { global $conf,$langs; diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index d7cf1cd62d9..195f09663b3 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -49,7 +49,7 @@ class FormContract } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a combo list with contracts qualified for a third party * @@ -60,8 +60,8 @@ class FormContract * @param int $showempty Show empty line * @return int Nbr of project if OK, <0 if KO */ - function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) - { + public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) + { // phpcs:enable global $db,$user,$conf,$langs; @@ -164,21 +164,21 @@ class FormContract dol_print_error($db); return -1; } - } + } - /** - * Show a form to select a contract - * - * @param int $page Page - * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) - * @param int $selected Id contract preselected - * @param string $htmlname Nom de la zone html - * @param int $maxlength Maximum length of label - * @param int $showempty Show empty line - * @return int Nbr of project if OK, <0 if KO - */ - function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) - { + /** + * Show a form to select a contract + * + * @param int $page Page + * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) + * @param int $selected Id contract preselected + * @param string $htmlname Nom de la zone html + * @param int $maxlength Maximum length of label + * @param int $showempty Show empty line + * @return int Nbr of project if OK, <0 if KO + */ + public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) + { global $langs; print "\n"; diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 13cf88e9aa2..0611d553af1 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -18,7 +18,7 @@ */ /** - * \file core/class/html.formcron.class.php + * \file htdocs/core/class/html.formcron.class.php * \brief Fichier de la classe des fonctions predefinie de composants html cron */ @@ -28,75 +28,75 @@ */ class FormCron extends Form { - /** + /** * @var DoliDB Database handler. */ public $db; - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - /** - * 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; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Display On Off selector - * - * @param string $htmlname Html control name - * @param integer $selected selected value - * @param integer $readonly Select is read only or not - * @return string HTML select field - */ - function select_typejob($htmlname, $selected = 0, $readonly = 0) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Display On Off selector + * + * @param string $htmlname Html control name + * @param integer $selected selected value + * @param integer $readonly Select is read only or not + * @return string HTML select field + */ + public function select_typejob($htmlname, $selected = 0, $readonly = 0) + { // phpcs:enable - global $langs; + global $langs; - $langs->load('cron@cron'); - if (!empty($readonly)) { - if ($selected=='command') { - $out= $langs->trans('CronType_command'); - $out.=''; - } elseif ($selected=='method') { - $out= $langs->trans('CronType_method'); - $out.=''; - } - }else { + $langs->load('cron@cron'); + if (!empty($readonly)) { + if ($selected=='command') { + $out= $langs->trans('CronType_command'); + $out.=''; + } elseif ($selected=='method') { + $out= $langs->trans('CronType_method'); + $out.=''; + } + } else { - $out=''; - if ($selected=='command') { - $selected_attr=' selected '; - } else { - $selected_attr=''; - } - $out.= ''; + if ($selected=='command') { + $selected_attr=' selected '; + } else { + $selected_attr=''; + } + $out.= ''; - if ($selected=='method') { - $selected_attr=' selected '; - } else { - $selected_attr=''; - } - $out.= ''; + if ($selected=='method') { + $selected_attr=' selected '; + } else { + $selected_attr=''; + } + $out.= ''; - $out.=''; - } + $out.=''; + } - return $out; - } + return $out; + } } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index c53a5562997..5e875be176d 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -51,14 +51,14 @@ class FormFile * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numoffiles=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form to upload a new file. * @@ -70,7 +70,7 @@ class FormFile * @param int $size Length of input file area. Deprecated. * @param Object $object Object to use (when attachment is done on an element) * @param string $options Add an option column - * @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). + * @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). * Deprecated 2 should never be used and if 1 is used, option should no be enabled. * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' * @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files @@ -79,7 +79,7 @@ class FormFile * @param string $sectiondir If upload must be done inside a particular directory (is sectiondir defined, sectionid must not be) * @return int <0 if KO, >0 if OK */ - function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '') + public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '') { // phpcs:enable global $conf,$langs, $hookmanager; @@ -174,14 +174,23 @@ class FormFile $out .= ""; if ($savingdocmask) - { - $out .= '
'; - if (! empty($options)) $out .= ''; - $out .= ''; - $out .= ''; - } + { + //add a global variable for disable the auto renaming on upload + if (! empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT)) + { + $rename=''; + } + else { + $rename='checked'; + } + + $out .= ''; + if (! empty($options)) $out .= ''; + $out .= ''; + $out .= ''; + } $out .= "
'.$options.''; - $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); - $out .= '
'.$options.''; + $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); + $out .= '
"; @@ -238,7 +247,7 @@ class FormFile } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show the box with list of available documents for object * @@ -261,7 +270,7 @@ class FormFile * @return int <0 if KO, number of shown files if OK * @deprecated Use print xxx->showdocuments() instead. */ - function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '') + public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '') { // phpcs:enable $this->numoffiles=0; @@ -294,7 +303,7 @@ class FormFile * @param int $hideifempty Hide section of generated files if there is no file * @return string Output string with HTML array of documents (might be empty string) */ - function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0) + public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0) { // Deprecation warning if (! empty($iconPDF)) { @@ -893,7 +902,7 @@ class FormFile * @param string $filter Filter filenames on this regex string (Example: '\.pdf$') * @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles */ - function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '') + public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '') { global $conf, $langs; @@ -996,7 +1005,7 @@ class FormFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show list of documents in $filearray (may be they are all in same directory but may not) * This also sync database if $upload_dir is defined. @@ -1028,7 +1037,7 @@ class FormFile * @return int <0 if KO, nb of files shown if OK * @see list_of_autoecmfiles */ - function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0) + public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0) { // phpcs:enable global $user, $conf, $langs, $hookmanager; @@ -1138,10 +1147,10 @@ class FormFile print '
'; - print $this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2'); + $this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2'); print '
'; - print $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2'); + $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2'); print '
'; - print $this->selectAnalyticCodesTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2'); + // Group + print '
'; + $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2'); print '
'; + + $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Bom"), $langs->transnoentities("Bom")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Bom"), $langs->transnoentities("Bom")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + // Parametrage du prefix + $texte.= ''; + $texte.= ''; + + $texte.= ''; + + $texte.= ''; + + $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
'; + $texte.= ''; + + return $texte; + } + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + public function getExample() + { + global $conf,$langs,$mysoc; + + $old_code_client=$mysoc->code_client; + $old_code_type=$mysoc->typent_code; + $mysoc->code_client='CCCCCCCCCC'; + $mysoc->typent_code='TTTTTTTTTT'; + $numExample = $this->getNextValue($mysoc, ''); + $mysoc->code_client=$old_code_client; + $mysoc->typent_code=$old_code_type; + + if (! $numExample) + { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next free value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objsoc, $object) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + // We get cursor rule + $mask=$conf->global->BOM_ADVANCED_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $date = ($object->date_bom ? $object->date_bom : $object->date); + + $numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', $objsoc, $date); + + return $numFinal; + } +} diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php new file mode 100644 index 00000000000..00a20898712 --- /dev/null +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -0,0 +1,149 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/mod_bom_standard.php + * \ingroup bom + * \brief File of class to manage customer order numbering rules standard + */ +require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php'; + +/** + * Class to manage customer order numbering rules standard + */ +class mod_bom_standard extends ModeleNumRefboms +{ + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + public $prefix='BOM'; + + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * @var string name + */ + public $name='standard'; + + + /** + * Return description of numbering module + * + * @return string Text with description + */ + public function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + } + + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + public function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Test si les numeros deje en vigueur dans la base ne provoquent pas de + * de conflits qui empechera cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + public function canBeActivated() + { + global $conf,$langs,$db; + + $coyymm=''; $max=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."bom"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; } + } + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next free value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objsoc, $object) + { + global $db,$conf; + + // D'abord on recupere la valeur max + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog("mod_bom_standard::getNextValue", LOG_DEBUG); + return -1; + } + + //$date=time(); + $date=$object->date; + $yymm = strftime("%y%m", $date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max+1); + + dol_syslog("mod_bom_standard::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } +} diff --git a/htdocs/core/modules/bom/modules_bom.php b/htdocs/core/modules/bom/modules_bom.php new file mode 100644 index 00000000000..fc4d2167980 --- /dev/null +++ b/htdocs/core/modules/bom/modules_bom.php @@ -0,0 +1,150 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/modules_bom.php + * \ingroup bom + * \brief File that contains parent class for boms models + * and parent class for boms numbering models + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit + + +/** + * Parent class for boms models + */ +abstract class ModelePDFBoms extends CommonDocGenerator +{ + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + public static function liste_modeles($db, $maxfilenamelength = 0) + { + // phpcs:enable + global $conf; + + $type = 'order'; + $list = array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $list = getListOfModels($db, $type, $maxfilenamelength); + + return $list; + } +} + + + +/** + * Parent class to manage numbering of BOMs + */ +abstract class ModeleNumRefBoms +{ + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + public function isEnabled() + { + return true; + } + + /** + * Renvoie la description par defaut du modele de numerotation + * + * @return string Texte descripif + */ + public function info() + { + global $langs; + $langs->load("mrp"); + return $langs->trans("NoDescription"); + } + + /** + * Renvoie un exemple de numerotation + * + * @return string Example + */ + public function getExample() + { + global $langs; + $langs->load("mrp"); + return $langs->trans("NoExample"); + } + + /** + * Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + public function canBeActivated() + { + return true; + } + + /** + * Renvoie prochaine valeur attribuee + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Valeur + */ + public function getNextValue($objsoc, $object) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Renvoie version du module numerotation + * + * @return string Valeur + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 999494ea6c3..80876747d59 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -45,7 +45,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -78,7 +78,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $this->tab_height = 200; //$this->line_height * $this->line_per_page; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction to generate document on disk * @@ -88,7 +88,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts * @param Translate $outputlangs Lang output object * @return int 1=ok, 0=ko */ - function write_file($object, $_dir, $number, $outputlangs) + public function write_file($object, $_dir, $number, $outputlangs) { // phpcs:enable global $user,$conf,$langs,$hookmanager; @@ -209,7 +209,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Generate Header * @@ -219,7 +219,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts * @param Translate $outputlangs Object language for output * @return void */ - function Header(&$pdf, $page, $pages, $outputlangs) + public function Header(&$pdf, $page, $pages, $outputlangs) { // phpcs:enable global $langs; @@ -317,7 +317,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output array * @@ -327,7 +327,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts * @param Translate $outputlangs Object lang * @return void */ - function Body(&$pdf, $pagenb, $pages, $outputlangs) + public function Body(&$pdf, $pagenb, $pages, $outputlangs) { // phpcs:enable // x=10 - Num @@ -378,15 +378,15 @@ class BordereauChequeBlochet extends ModeleChequeReceipts /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return void + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return void */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 0bdf6f0fc91..0183300c4ad 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -25,7 +25,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php'; /** - * Class to manage cheque receipts numbering rules Mint + * Class to manage cheque receipts numbering rules Mint */ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts { @@ -50,7 +50,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -62,7 +62,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -74,7 +74,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -109,7 +109,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -145,7 +145,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -153,7 +153,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * @param string $objforref Object for number to search * @return string Next free value */ - function chequereceipt_get_num($objsoc, $objforref) + public function chequereceipt_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index c978dbaa0f3..da1ec40620c 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -49,7 +49,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -89,7 +89,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -112,7 +112,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -133,7 +133,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -141,7 +141,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * @param string $objforref Object for number to search * @return string Next free value */ - function chequereceipt_get_num($objsoc, $objforref) + public function chequereceipt_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index d13384805d5..29fd071200a 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -46,7 +46,7 @@ abstract class ModeleNumRefChequeReceipts * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -56,7 +56,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -68,7 +68,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -80,7 +80,7 @@ abstract class ModeleNumRefChequeReceipts * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -92,7 +92,7 @@ abstract class ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -103,7 +103,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -127,7 +127,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -135,7 +135,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -154,7 +154,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator /** - * Cree un bordereau remise de cheque + * Cree un bordereau remise de cheque * * @param DoliDB $db Database handler * @param int $id Object invoice (or id of invoice) diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 14f3c1fc862..d2f2ba9af07 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -63,7 +63,7 @@ class doc_generic_order_odt extends ModelePDFCommandes * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -108,7 +108,7 @@ class doc_generic_order_odt extends ModelePDFCommandes * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -191,9 +191,9 @@ class doc_generic_order_odt extends ModelePDFCommandes return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * * @param Commande $object Object source to build document * @param Translate $outputlangs Lang output object @@ -203,7 +203,7 @@ class doc_generic_order_odt extends ModelePDFCommandes * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -338,7 +338,7 @@ class doc_generic_order_odt extends ModelePDFCommandes // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->commande->dir_temp, diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 5354e6bc2c7..ec8aa3978d9 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -68,7 +68,7 @@ class pdf_einstein extends ModelePDFCommandes public $type; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -203,7 +203,7 @@ class pdf_einstein extends ModelePDFCommandes $this->atleastonediscount=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -215,7 +215,7 @@ class pdf_einstein extends ModelePDFCommandes * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes; @@ -652,7 +652,7 @@ class pdf_einstein extends ModelePDFCommandes } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -662,13 +662,13 @@ class pdf_einstein extends ModelePDFCommandes * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -678,7 +678,7 @@ class pdf_einstein extends ModelePDFCommandes * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -855,18 +855,18 @@ class pdf_einstein extends ModelePDFCommandes } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * - * @param TCPDF $pdf Object PDF + * @param TCPDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1129,7 +1129,7 @@ class pdf_einstein extends ModelePDFCommandes * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1239,7 +1239,7 @@ class pdf_einstein extends ModelePDFCommandes * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle") { global $conf,$langs,$hookmanager; @@ -1450,7 +1450,7 @@ class pdf_einstein extends ModelePDFCommandes * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 75db1887e4d..f7ce304b380 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -643,7 +643,7 @@ class pdf_eratosthene extends ModelePDFCommandes if ($pagenb == $pageposafter) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); - } + } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); @@ -816,7 +816,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->MultiCell(80, 4, $dlp, 0, 'L'); $posy=$pdf->GetY()+1; - } + } elseif ($object->availability_code || $object->availability) // Show availability conditions { $pdf->SetFont('', 'B', $default_font_size - 2); @@ -831,7 +831,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); $posy=$pdf->GetY()+1; - } + } // Show payment mode if ($object->mode_reglement_code @@ -889,8 +889,8 @@ class pdf_eratosthene extends ModelePDFCommandes $posy=$pdf->GetY()+2; } } - } - } + } + } // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') @@ -1672,5 +1672,5 @@ class pdf_eratosthene extends ModelePDFCommandes { $this->cols = $hookmanager->resArray; } - } + } } diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index 66a5307cbfa..f10f858544f 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -46,7 +46,7 @@ class pdf_proforma extends pdf_einstein * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -67,7 +67,7 @@ class pdf_proforma extends pdf_einstein * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma") { global $conf,$langs,$hookmanager; diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index e888905b3be..620ab210f31 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -42,13 +42,6 @@ class mod_commande_marbre extends ModeleNumRefCommandes */ public $error=''; - /** - * @var string - * @deprecated - * @see name - */ - public $nom='Marbre'; - /** * @var string name */ @@ -60,7 +53,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +65,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +77,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +112,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -155,7 +148,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -163,7 +156,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index bfe853996ce..40ca0e2e222 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -44,13 +44,6 @@ class mod_commande_saphir extends ModeleNumRefCommandes */ public $error = ''; - /** - * @var string nom - * @deprecated - * @see name - */ - public $nom='Saphir'; - /** * @var string name */ @@ -62,7 +55,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -102,7 +95,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -128,7 +121,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -151,7 +144,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -159,7 +152,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 6090ad35028..47fb20a56b4 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; abstract class ModelePDFCommandes extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -66,10 +66,8 @@ abstract class ModelePDFCommandes extends CommonDocGenerator /** - * \class ModeleNumRefCommandes - * \brief Classe mere des modeles de numerotation des references de commandes + * Parent class to manage numbering of Sale Orders */ - abstract class ModeleNumRefCommandes { /** @@ -82,7 +80,7 @@ abstract class ModeleNumRefCommandes * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -92,7 +90,7 @@ abstract class ModeleNumRefCommandes * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("orders"); @@ -104,7 +102,7 @@ abstract class ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("orders"); @@ -116,7 +114,7 @@ abstract class ModeleNumRefCommandes * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +126,7 @@ abstract class ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +137,7 @@ abstract class ModeleNumRefCommandes * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 1f77537ceb5..8319bff919b 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -58,11 +58,11 @@ class doc_generic_contract_odt extends ModelePDFContract /** - * Constructor + * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -107,7 +107,7 @@ class doc_generic_contract_odt extends ModelePDFContract * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -181,19 +181,19 @@ class doc_generic_contract_odt extends ModelePDFContract return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * - * @param Contract $object Object source to build document - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param Contract $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @return int 1 if OK, <=0 if KO + * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -291,10 +291,9 @@ class doc_generic_contract_odt extends ModelePDFContract // Recipient name $contactobject=null; - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if (! empty($usecontact)) { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 84f363af74c..fd0f5cd38a0 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -61,7 +61,7 @@ class pdf_strato extends ModelePDFContract public $type; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -124,7 +124,7 @@ class pdf_strato extends ModelePDFContract * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -160,7 +160,7 @@ class pdf_strato extends ModelePDFContract $this->posxdesc=$this->marge_gauche+1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -171,9 +171,9 @@ class pdf_strato extends ModelePDFContract * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref * @return int 1=OK, 0=KO - */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + */ + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$hookmanager,$mysoc; @@ -513,7 +513,7 @@ class pdf_strato extends ModelePDFContract * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf; @@ -522,7 +522,7 @@ class pdf_strato extends ModelePDFContract if ($hidetop) $hidetop=-1; $default_font_size = pdf_getPDFFontSize($outputlangs); -/* + /* $pdf->SetXY($this->marge_gauche, $tab_top); $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8); @@ -546,7 +546,7 @@ class pdf_strato extends ModelePDFContract $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY); $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also. -*/ + */ // Output Rect $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3); // Rect prend une longueur en 3eme param et 4eme param @@ -560,7 +560,7 @@ class pdf_strato extends ModelePDFContract * @param Translate $outputlangs Object language for output * @return void */ - private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs) + private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs) { $pdf->SetDrawColor(128, 128, 128); $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2); @@ -577,19 +577,19 @@ class pdf_strato extends ModelePDFContract $pdf->SetXY($posmiddle + 5, $posy + 5); $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1); - } + } - /** - * Show top header of page. - * - * @param PDF $pdf Object PDF - * @param CommonObject $object Object to show - * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output - * @return void - */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) - { + /** + * Show top header of page. + * + * @param PDF $pdf Object PDF + * @param CommonObject $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void + */ + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + { global $conf,$langs; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -767,7 +767,7 @@ class pdf_strato extends ModelePDFContract * @param int $hidefreetext 1=Hide free text * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index db7689d7855..3dfa0533cbe 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -59,7 +59,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $conf,$langs; @@ -95,7 +95,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -118,7 +118,7 @@ class mod_contract_magre extends ModelNumRefContracts * @param Object $contract contract object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $db,$conf; @@ -137,15 +137,15 @@ class mod_contract_magre extends ModelNumRefContracts return $numFinal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next value * - * @param Societe $objsoc third party object - * @param Object $objforref contract object - * @return string Value if OK, 0 if KO - */ - function contract_get_num($objsoc, $objforref) + * @param Societe $objsoc third party object + * @param Object $objforref contract object + * @return string Value if OK, 0 if KO + */ + public function contract_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/contract/mod_contract_olive.php b/htdocs/core/modules/contract/mod_contract_olive.php index 799bd297633..c1a395c4439 100644 --- a/htdocs/core/modules/contract/mod_contract_olive.php +++ b/htdocs/core/modules/contract/mod_contract_olive.php @@ -66,7 +66,7 @@ class mod_contract_olive extends ModelNumRefContracts * * @return string Description of module */ - function info() + public function info() { global $langs; @@ -81,7 +81,7 @@ class mod_contract_olive extends ModelNumRefContracts * @param Contrat $contract Object contract * @return string Return next value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return ''; @@ -101,7 +101,7 @@ class mod_contract_olive extends ModelNumRefContracts * -3 ErrorProductCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $type) + public function verif($db, &$code, $product, $type) { global $conf; diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 2106463107e..2f644f2762f 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -61,7 +61,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -73,7 +73,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_contract_serpis extends ModelNumRefContracts * @param Object $contract contract object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $db,$conf; @@ -153,7 +153,7 @@ class mod_contract_serpis extends ModelNumRefContracts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next value * @@ -161,7 +161,7 @@ class mod_contract_serpis extends ModelNumRefContracts * @param Object $objforref contract object * @return string Value if OK, 0 if KO */ - function contract_get_num($objsoc, $objforref) + public function contract_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 0c126459436..9cbc2092979 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -43,7 +43,7 @@ abstract class ModelePDFContract extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -51,7 +51,7 @@ abstract class ModelePDFContract extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -82,7 +82,7 @@ class ModelNumRefContracts * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -92,7 +92,7 @@ class ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("contracts"); @@ -104,7 +104,7 @@ class ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("contracts"); @@ -116,7 +116,7 @@ class ModelNumRefContracts * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ class ModelNumRefContracts * @param Object $contract contract object * @return string Value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ class ModelNumRefContracts * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index cbb6f3807cc..6ef76d21b78 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -40,7 +40,7 @@ class html_cerfafr extends ModeleDon * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs; @@ -58,13 +58,13 @@ class html_cerfafr extends ModeleDon * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write the object to document file to disk * @@ -73,7 +73,7 @@ class html_cerfafr extends ModeleDon * @param string $currency Currency code * @return int >0 if OK, <0 if KO */ - function write_file($don, $outputlangs, $currency = '') + public function write_file($don, $outputlangs, $currency = '') { // phpcs:enable global $user,$conf,$langs,$mysoc; @@ -306,22 +306,22 @@ class html_cerfafr extends ModeleDon $dix[3]=intval($valeur_entiere%100000000/10000000); $cent[3]=intval($valeur_entiere%1000000000/100000000); $chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf'); - $secon_c=''; - $trio_c=''; - for($i=1; $i<=3; $i++){ + $secon_c=''; + $trio_c=''; + for($i=1; $i<=3; $i++) { $prim[$i]=''; $secon[$i]=''; $trio[$i]=''; - if($dix[$i]==0){ + if ($dix[$i]==0) { $secon[$i]=''; $prim[$i]=$chif[$unite[$i]]; } - elseif($dix[$i]==1){ + elseif ($dix[$i]==1) { $secon[$i]=''; $prim[$i]=$chif[($unite[$i]+10)]; } - elseif($dix[$i]==2){ - if($unite[$i]==1){ + elseif ($dix[$i]==2) { + if ($unite[$i]==1) { $secon[$i]='vingt et'; $prim[$i]=$chif[$unite[$i]]; } @@ -330,8 +330,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==3){ - if($unite[$i]==1){ + elseif ($dix[$i]==3) { + if ($unite[$i]==1) { $secon[$i]='trente et'; $prim[$i]=$chif[$unite[$i]]; } @@ -340,8 +340,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==4){ - if($unite[$i]==1){ + elseif ($dix[$i]==4) { + if ($unite[$i]==1) { $secon[$i]='quarante et'; $prim[$i]=$chif[$unite[$i]]; } @@ -350,8 +350,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==5){ - if($unite[$i]==1){ + elseif ($dix[$i]==5) { + if ($unite[$i]==1) { $secon[$i]='cinquante et'; $prim[$i]=$chif[$unite[$i]]; } @@ -360,8 +360,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==6){ - if($unite[$i]==1){ + elseif ($dix[$i]==6) { + if ($unite[$i]==1) { $secon[$i]='soixante et'; $prim[$i]=$chif[$unite[$i]]; } @@ -370,8 +370,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==7){ - if($unite[$i]==1){ + elseif ($dix[$i]==7) { + if ($unite[$i]==1) { $secon[$i]='soixante et'; $prim[$i]=$chif[$unite[$i]+10]; } @@ -380,8 +380,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]+10]; } } - elseif($dix[$i]==8){ - if($unite[$i]==1){ + elseif ($dix[$i]==8) { + if ($unite[$i]==1) { $secon[$i]='quatre-vingts et'; $prim[$i]=$chif[$unite[$i]]; } @@ -390,8 +390,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==9){ - if($unite[$i]==1){ + elseif ($dix[$i]==9) { + if ($unite[$i]==1) { $secon[$i]='quatre-vingts et'; $prim[$i]=$chif[$unite[$i]+10]; } @@ -407,19 +407,19 @@ class html_cerfafr extends ModeleDon $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); $secon_c=$chif2[$dix_c]; - if($cent_c==1) $trio_c='cent'; - elseif($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; + if ($cent_c==1) $trio_c='cent'; + elseif ($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; - if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) + if (($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million '; - elseif(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) + elseif (($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions '; else $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]; - if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) + if (($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) $somme = $somme.' mille '; - elseif(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) + elseif (($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles '; else $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]; @@ -428,7 +428,7 @@ class html_cerfafr extends ModeleDon $somme = $somme. ' '. $dev1 .' ' ; - if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) + if (($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) return $somme. ' et zéro '. $dev2; else return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2; diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index adda4dce750..9957bf4f326 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -39,7 +39,7 @@ abstract class ModeleDon extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -47,7 +47,7 @@ abstract class ModeleDon extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -78,7 +78,7 @@ abstract class ModeleNumRefDons * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -88,7 +88,7 @@ abstract class ModeleNumRefDons * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -100,7 +100,7 @@ abstract class ModeleNumRefDons * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -113,7 +113,7 @@ abstract class ModeleNumRefDons * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -123,7 +123,7 @@ abstract class ModeleNumRefDons * * @return string Valeur */ - function getNextValue() + public function getNextValue() { global $langs; return $langs->trans("NotAvailable"); @@ -134,7 +134,7 @@ abstract class ModeleNumRefDons * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 558ffe44e0a..53891a1c340 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -64,7 +64,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -109,7 +109,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -191,7 +191,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -203,7 +203,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -337,7 +337,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->expedition->dir_temp, diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 628d9102e96..649d20154e4 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -58,7 +58,7 @@ class pdf_merou extends ModelePdfExpedition public $type; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -116,7 +116,7 @@ class pdf_merou extends ModelePdfExpedition * * @param DoliDB $db Database handler */ - function __construct($db = 0) + public function __construct($db = 0) { global $conf,$langs,$mysoc; @@ -142,7 +142,7 @@ class pdf_merou extends ModelePdfExpedition } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -154,7 +154,7 @@ class pdf_merou extends ModelePdfExpedition * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$conf,$langs,$mysoc,$hookmanager; @@ -460,7 +460,7 @@ class pdf_merou extends ModelePdfExpedition * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $langs; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -498,7 +498,7 @@ class pdf_merou extends ModelePdfExpedition * @param int $hidefreetext 1=Hide free text * @return void */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 2); @@ -527,7 +527,7 @@ class pdf_merou extends ModelePdfExpedition * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs,$hookmanager; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 116fae7c354..e0de76bb7b7 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -57,7 +57,7 @@ class pdf_rouget extends ModelePdfExpedition public $type; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -115,7 +115,7 @@ class pdf_rouget extends ModelePdfExpedition * * @param DoliDB $db Database handler */ - function __construct($db = 0) + public function __construct($db = 0) { global $conf,$langs,$mysoc; @@ -156,23 +156,22 @@ class pdf_rouget extends ModelePdfExpedition $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images - if ($this->page_largeur < 210) // To work with US executive format - { - $this->posxweightvol-=20; - $this->posxpicture-=20; - $this->posxqtyordered-=20; - $this->posxqtytoship-=20; - } + // To work with US executive format + if ($this->page_largeur < 210) { + $this->posxweightvol-=20; + $this->posxpicture-=20; + $this->posxqtyordered-=20; + $this->posxqtytoship-=20; + } - if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) - { + if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); $this->posxqtyordered = $this->posxqtytoship; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -184,7 +183,7 @@ class pdf_rouget extends ModelePdfExpedition * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$conf,$langs,$hookmanager; @@ -664,7 +663,7 @@ class pdf_rouget extends ModelePdfExpedition } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -675,7 +674,7 @@ class pdf_rouget extends ModelePdfExpedition * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -783,7 +782,7 @@ class pdf_rouget extends ModelePdfExpedition * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf; @@ -868,7 +867,7 @@ class pdf_rouget extends ModelePdfExpedition * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs,$mysoc; @@ -1108,15 +1107,15 @@ class pdf_rouget extends ModelePdfExpedition } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php index ac0c286d389..7b20d1df4d8 100644 --- a/htdocs/core/modules/expedition/mod_expedition_ribera.php +++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php @@ -57,7 +57,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * * @return string text description */ - function info() + public function info() { global $conf, $langs; @@ -93,7 +93,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -119,7 +119,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * @param Object $shipment Shipment object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $db,$conf; @@ -140,7 +140,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition return $numFinal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -148,7 +148,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * @param Object $objforref Shipment object * @return string Next free value */ - function expedition_get_num($objsoc, $objforref) + public function expedition_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index 3bf655c6f23..40033df65f7 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -59,7 +59,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -71,7 +71,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -82,7 +82,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -117,7 +117,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * @param Object $shipment Shipment object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $db,$conf; @@ -150,7 +150,7 @@ class mod_expedition_safor extends ModelNumRefExpedition return $this->prefix.$yymm."-".$num; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -158,7 +158,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * @param Object $objforref Shipment object * @return string Next free value */ - function expedition_get_num($objsoc, $objforref) + public function expedition_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index 7b88a83392e..3a2d7774e33 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -42,7 +42,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models * @@ -50,7 +50,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -80,7 +80,7 @@ abstract class ModelNumRefExpedition * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -90,7 +90,7 @@ abstract class ModelNumRefExpedition * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("sendings"); @@ -102,7 +102,7 @@ abstract class ModelNumRefExpedition * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("sendings"); @@ -114,7 +114,7 @@ abstract class ModelNumRefExpedition * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -126,7 +126,7 @@ abstract class ModelNumRefExpedition * @param Object $shipment Shipment object * @return string Value */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $langs; return $langs->trans("NotAvailable"); @@ -137,7 +137,7 @@ abstract class ModelNumRefExpedition * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 03ebe71e88d..2563028ee93 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -114,13 +114,13 @@ class pdf_standard extends ModeleExpenseReport public $emetteur; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { global $conf, $langs, $mysoc; // Translations @@ -192,7 +192,7 @@ class pdf_standard extends ModeleExpenseReport } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -204,7 +204,7 @@ class pdf_standard extends ModeleExpenseReport * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager; @@ -450,8 +450,7 @@ class pdf_standard extends ModeleExpenseReport } // Show square - if ($pagenb == 1) - { + if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } @@ -625,7 +624,7 @@ class pdf_standard extends ModeleExpenseReport * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs, $hookmanager; @@ -770,8 +769,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create, "day", false, $outputlangs), 0, 'L'); } - if ($object->fk_statut==99) - { + if ($object->fk_statut==99) { if ($object->fk_user_refuse > 0) { $userfee=new User($this->db); $userfee->fetch($object->fk_user_refuse); $posy+=6; @@ -840,7 +838,7 @@ class pdf_standard extends ModeleExpenseReport * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1054,15 +1052,15 @@ class pdf_standard extends ModeleExpenseReport } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index b4d1b7b2b6e..a878fb1325c 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -59,10 +59,10 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * * @return string Text with description */ - function info() + public function info() { - global $langs; - return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + global $langs; + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); } @@ -71,7 +71,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -83,7 +83,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -117,7 +117,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($object) + public function getNextValue($object) { global $db,$conf; diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php index e9c5eb06dd5..2311de4841a 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php @@ -59,7 +59,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport * * @return string Texte descripif */ - function info() + public function info() { global $db, $conf, $langs; @@ -99,7 +99,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport * * @return string Example */ - function getExample() + public function getExample() { global $db, $conf,$langs,$user; @@ -116,15 +116,15 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport return $numExample; } - /** - * Return next free value - * - * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO - */ - function getNextValue($object) + /** + * Return next free value + * + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($object) { - global $db,$conf; + global $db,$conf; require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; @@ -154,5 +154,5 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport $numFinal=get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser); return $numFinal; - } + } } diff --git a/htdocs/core/modules/expensereport/modules_expensereport.php b/htdocs/core/modules/expensereport/modules_expensereport.php index a31a61f67e1..fde96e56af5 100644 --- a/htdocs/core/modules/expensereport/modules_expensereport.php +++ b/htdocs/core/modules/expensereport/modules_expensereport.php @@ -29,7 +29,7 @@ abstract class ModeleExpenseReport extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active models generation * @@ -37,7 +37,7 @@ abstract class ModeleExpenseReport extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -52,7 +52,6 @@ abstract class ModeleExpenseReport extends CommonDocGenerator } } -// phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * expensereport_pdf_create * @@ -68,8 +67,7 @@ abstract class ModeleExpenseReport extends CommonDocGenerator */ function expensereport_pdf_create(DoliDB $db, ExpenseReport $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - // phpcs:enable - return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } /** @@ -89,7 +87,7 @@ abstract class ModeleNumRefExpenseReport * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -99,7 +97,7 @@ abstract class ModeleNumRefExpenseReport * * @return string Descriptive text */ - function info() + public function info() { global $langs; $langs->load("orders"); @@ -111,7 +109,7 @@ abstract class ModeleNumRefExpenseReport * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("trips"); @@ -123,7 +121,7 @@ abstract class ModeleNumRefExpenseReport * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -134,26 +132,26 @@ abstract class ModeleNumRefExpenseReport * @param Object $object Object we need next value for * @return string Value */ - function getNextValue($object) + public function getNextValue($object) { global $langs; return $langs->trans("NotAvailable"); } - /** - * Returns the version of the numbering module - * - * @return string Value - */ - function getVersion() - { - global $langs; - $langs->load("admin"); + /** + * Returns the version of the numbering module + * + * @return string Value + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); - } + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); + } } diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index a90e550c3da..249d1563988 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -62,7 +62,7 @@ class ExportCsv extends ModeleExports * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; @@ -89,7 +89,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -99,7 +99,7 @@ class ExportCsv extends ModeleExports * * @return string Return driver label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -109,7 +109,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -119,7 +119,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -129,7 +129,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -139,7 +139,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -149,13 +149,13 @@ class ExportCsv extends ModeleExports * * @return string */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open output file * @@ -163,7 +163,7 @@ class ExportCsv extends ModeleExports * @param Translate $outputlangs Output language object * @return int <0 if KO, >=0 if OK */ - function open_file($file, $outputlangs) + public function open_file($file, $outputlangs) { // phpcs:enable global $langs; @@ -184,21 +184,21 @@ class ExportCsv extends ModeleExports return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header into file * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_header($outputlangs) + public function write_header($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line into file * @@ -208,7 +208,7 @@ class ExportCsv extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -234,7 +234,7 @@ class ExportCsv extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record line into file * @@ -244,7 +244,7 @@ class ExportCsv extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -288,26 +288,26 @@ class ExportCsv extends ModeleExports return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output footer into file * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_footer($outputlangs) + public function write_footer($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close file handle * * @return int <0 if KO, >0 if OK */ - function close_file() + public function close_file() { // phpcs:enable fclose($this->handle); diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index 7b12651cfa0..28357c0a09a 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -70,17 +70,17 @@ class ExportExcel extends ModeleExports * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; $this->id='excel'; // Same value then xxx in file name export_xxx.modules.php - $this->label='Excel 95'; // Label of driver + $this->label='Excel 95'; // Label of driver $this->desc = $langs->trans('Excel95FormatDesc'); $this->extension='xls'; // Extension for generated file by this driver - $this->picto='mime/xls'; // Picto - $this->version='1.30'; // Driver version + $this->picto='mime/xls'; // Picto + $this->version='1.30'; // Driver version $this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages) @@ -112,7 +112,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -122,7 +122,7 @@ class ExportExcel extends ModeleExports * * @return string Return driver label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -132,7 +132,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -142,7 +142,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -152,7 +152,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -162,7 +162,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -172,13 +172,13 @@ class ExportExcel extends ModeleExports * * @return string */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open output file * @@ -186,7 +186,7 @@ class ExportExcel extends ModeleExports * @param Translate $outputlangs Output language object * @return int <0 if KO, >=0 if OK */ - function open_file($file, $outputlangs) + public function open_file($file, $outputlangs) { // phpcs:enable global $user,$conf,$langs; @@ -202,8 +202,7 @@ class ExportExcel extends ModeleExports $ret=1; $outputlangs->load("exports"); - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { + if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) { require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php'; require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php'; require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; @@ -249,14 +248,14 @@ class ExportExcel extends ModeleExports return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write header * * @param Translate $outputlangs Object lang to translate values * @return int <0 if KO, >0 if OK */ - function write_header($outputlangs) + public function write_header($outputlangs) { // phpcs:enable //$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO @@ -265,7 +264,7 @@ class ExportExcel extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line into file * @@ -275,7 +274,7 @@ class ExportExcel extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -322,7 +321,7 @@ class ExportExcel extends ModeleExports return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record line into file * @@ -332,7 +331,7 @@ class ExportExcel extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -442,27 +441,27 @@ class ExportExcel extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write footer * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_footer($outputlangs) + public function write_footer($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close Excel file * * @return int <0 if KO, >0 if OK */ - function close_file() + public function close_file() { // phpcs:enable global $conf; @@ -483,42 +482,43 @@ class ExportExcel extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Clean a cell to respect rules of Excel file cells + * Clean a cell to respect rules of Excel file cells * - * @param string $newvalue String to clean - * @return string Value cleaned + * @param string $newvalue String to clean + * @return string Value cleaned */ - function excel_clean($newvalue) + public function excel_clean($newvalue) { // phpcs:enable - // Rule Dolibarr: No HTML - $newvalue=dol_string_nohtmltag($newvalue); + // Rule Dolibarr: No HTML + $newvalue=dol_string_nohtmltag($newvalue); - return $newvalue; + return $newvalue; } /** - * Convert a column to letter (1->A, 0->B, 27->AA, ...) + * Convert a column to letter (1->A, 0->B, 27->AA, ...) * - * @param int $c Column position - * @return string Letter + * @param int $c Column position + * @return string Letter */ - function column2Letter($c) + public function column2Letter($c) { - $c = intval($c); - if ($c <= 0) return ''; + $c = intval($c); + if ($c <= 0) { + return ''; + } - while ($c != 0) - { - $p = ($c - 1) % 26; - $c = intval(($c - $p) / 26); - $letter = chr(65 + $p) . $letter; - } + while ($c != 0) { + $p = ($c - 1) % 26; + $c = intval(($c - $p) / 26); + $letter = chr(65 + $p) . $letter; + } - return $letter; + return $letter; } } diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index 28dae8ed6fd..1b6b973632a 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -70,7 +70,7 @@ class ExportExcel2007 extends ExportExcel * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; @@ -108,29 +108,29 @@ class ExportExcel2007 extends ExportExcel } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close Excel file * * @return int <0 if KO, >0 if OK */ - function close_file() - { + public function close_file() + { // phpcs:enable - global $conf; + global $conf; - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $this->workbook->close(); - } - else - { + if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) + { + $this->workbook->close(); + } + else + { require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php'; - $objWriter = new PHPExcel_Writer_Excel2007($this->workbook); + $objWriter = new PHPExcel_Writer_Excel2007($this->workbook); $objWriter->save($this->file); $this->workbook->disconnectWorksheets(); unset($this->workbook); - } - return 1; - } + } + return 1; + } } diff --git a/htdocs/core/modules/export/export_excelnew.modules.php b/htdocs/core/modules/export/export_excel2007new.modules.php similarity index 75% rename from htdocs/core/modules/export/export_excelnew.modules.php rename to htdocs/core/modules/export/export_excel2007new.modules.php index f6a54b040d3..10dbb2fa28c 100644 --- a/htdocs/core/modules/export/export_excelnew.modules.php +++ b/htdocs/core/modules/export/export_excel2007new.modules.php @@ -32,7 +32,7 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx; /** * Class to build export files with Excel format */ -class ExportExcelnew extends ModeleExports +class ExportExcel2007new extends ModeleExports { /** * @var int ID @@ -72,7 +72,7 @@ class ExportExcelnew extends ModeleExports * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; @@ -105,7 +105,7 @@ class ExportExcelnew extends ModeleExports * * @return string */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -115,7 +115,7 @@ class ExportExcelnew extends ModeleExports * * @return string Return driver label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -125,7 +125,7 @@ class ExportExcelnew extends ModeleExports * * @return string */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -135,7 +135,7 @@ class ExportExcelnew extends ModeleExports * * @return string */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -145,7 +145,7 @@ class ExportExcelnew extends ModeleExports * * @return string */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -155,7 +155,7 @@ class ExportExcelnew extends ModeleExports * * @return string */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -165,13 +165,13 @@ class ExportExcelnew extends ModeleExports * * @return string */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open output file * @@ -179,7 +179,7 @@ class ExportExcelnew extends ModeleExports * @param Translate $outputlangs Output language object * @return int <0 if KO, >=0 if OK */ - function open_file($file, $outputlangs) + public function open_file($file, $outputlangs) { // phpcs:enable global $user,$conf,$langs; @@ -227,14 +227,14 @@ class ExportExcelnew extends ModeleExports return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write header * * @param Translate $outputlangs Object lang to translate values * @return int <0 if KO, >0 if OK */ - function write_header($outputlangs) + public function write_header($outputlangs) { // phpcs:enable //$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO @@ -243,7 +243,7 @@ class ExportExcelnew extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line into file * @@ -253,7 +253,7 @@ class ExportExcelnew extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -286,7 +286,7 @@ class ExportExcelnew extends ModeleExports return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record line into file * @@ -296,7 +296,7 @@ class ExportExcelnew extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -333,32 +333,32 @@ class ExportExcelnew extends ModeleExports if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i', $newvalue)) { - $newvalue=dol_stringtotime($newvalue); - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue)); - $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); - $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd'); + $newvalue=dol_stringtotime($newvalue); + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue)); + $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); + $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd'); } elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i', $newvalue)) { - $newvalue=dol_stringtotime($newvalue); - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue)); - $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); - $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss'); + $newvalue=dol_stringtotime($newvalue); + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue)); + $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); + $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss'); } else { - if ($typefield == 'Text' || $typefield == 'TextAuto') - { - //$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING); - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue); - $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); - $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@'); - $this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT); - } - else - { - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue); - } + if ($typefield == 'Text' || $typefield == 'TextAuto') + { + //$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING); + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue); + $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); + $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@'); + $this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT); + } + else + { + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue); + } } $this->col++; } @@ -367,48 +367,48 @@ class ExportExcelnew extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write footer * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_footer($outputlangs) + public function write_footer($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close Excel file * * @return int <0 if KO, >0 if OK */ - function close_file() + public function close_file() { // phpcs:enable - global $conf; + global $conf; - $objWriter = new Xlsx($this->workbook); - $objWriter->save($this->file); - $this->workbook->disconnectWorksheets(); - unset($this->workbook); + $objWriter = new Xlsx($this->workbook); + $objWriter->save($this->file); + $this->workbook->disconnectWorksheets(); + unset($this->workbook); return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Clean a cell to respect rules of Excel file cells * * @param string $newvalue String to clean * @return string Value cleaned */ - function excel_clean($newvalue) + public function excel_clean($newvalue) { // phpcs:enable // Rule Dolibarr: No HTML @@ -424,14 +424,13 @@ class ExportExcelnew extends ModeleExports * @param int $c Column position * @return string Letter */ - function column2Letter($c) + public function column2Letter($c) { $c = intval($c); if ($c <= 0) return ''; - while ($c != 0) - { + while ($c != 0) { $p = ($c - 1) % 26; $c = intval(($c - $p) / 26); $letter = chr(65 + $p) . $letter; diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index e3855e5f17e..33d7d860368 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -59,11 +59,11 @@ class ExportTsv extends ModeleExports /** - * Constructor - * - * @param DoliDB $db Database handler + * Constructor + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; @@ -85,7 +85,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -95,7 +95,7 @@ class ExportTsv extends ModeleExports * * @return string Return driver label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -105,7 +105,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -115,7 +115,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -125,7 +125,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -135,7 +135,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -145,21 +145,21 @@ class ExportTsv extends ModeleExports * * @return string */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Open output file - * - * @param string $file Path of filename to generate - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >=0 if OK - */ - function open_file($file, $outputlangs) + * Open output file + * + * @param string $file Path of filename to generate + * @param Translate $outputlangs Output language object + * @return int <0 if KO, >=0 if OK + */ + public function open_file($file, $outputlangs) { // phpcs:enable global $langs; @@ -180,21 +180,21 @@ class ExportTsv extends ModeleExports return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header into file * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_header($outputlangs) + public function write_header($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line into file * @@ -203,8 +203,8 @@ class ExportTsv extends ModeleExports * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK - */ - function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + */ + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) { // phpcs:enable foreach($array_selected_sorted as $code => $value) @@ -219,7 +219,7 @@ class ExportTsv extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record line into file * @@ -229,7 +229,7 @@ class ExportTsv extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -263,33 +263,33 @@ class ExportTsv extends ModeleExports return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output footer into file * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_footer($outputlangs) + public function write_footer($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close file handle * * @return int <0 if KO, >0 if OK */ - function close_file() + public function close_file() { // phpcs:enable fclose($this->handle); return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Clean a cell to respect rules of TSV file cells * @@ -297,21 +297,20 @@ class ExportTsv extends ModeleExports * @param string $charset Input AND Output character set * @return string Value cleaned */ - function tsv_clean($newvalue, $charset) + public function tsv_clean($newvalue, $charset) { // phpcs:enable - // Rule Dolibarr: No HTML - $newvalue=dol_string_nohtmltag($newvalue, 1, $charset); + // Rule Dolibarr: No HTML + $newvalue=dol_string_nohtmltag($newvalue, 1, $charset); - // Rule 1 TSV: No CR, LF in cells - $newvalue=str_replace("\r", '', $newvalue); + // Rule 1 TSV: No CR, LF in cells + $newvalue=str_replace("\r", '', $newvalue); $newvalue=str_replace("\n", '\n', $newvalue); // Rule 2 TSV: If value contains tab, we must replace by space - if (preg_match('/'.$this->separator.'/', $newvalue)) - { - $newvalue=str_replace("\t", " ", $newvalue); - } + if (preg_match('/'.$this->separator.'/', $newvalue)) { + $newvalue=str_replace("\t", " ", $newvalue); + } return $newvalue; } diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 9ab3a45533d..17318e058ab 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -44,7 +44,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac public $libversion=array(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into memory list of available export format * @@ -52,7 +52,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param integer $maxfilenamelength Max length of value to show * @return array List of templates (same content than array this->driverlabel) */ - function liste_modeles($db, $maxfilenamelength = 0) + public function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable dol_syslog(get_class($this)."::liste_modeles"); @@ -107,7 +107,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Picto string */ - function getPictoForKey($key) + public function getPictoForKey($key) { return $this->picto[$key]; } @@ -118,7 +118,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Label */ - function getDriverLabelForKey($key) + public function getDriverLabelForKey($key) { return $this->driverlabel[$key]; } @@ -129,7 +129,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Description */ - function getDriverDescForKey($key) + public function getDriverDescForKey($key) { return $this->driverdesc[$key]; } @@ -140,7 +140,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Driver version */ - function getDriverVersionForKey($key) + public function getDriverVersionForKey($key) { return $this->driverversion[$key]; } @@ -151,7 +151,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Label of library */ - function getLibLabelForKey($key) + public function getLibLabelForKey($key) { return $this->liblabel[$key]; } @@ -162,7 +162,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Version of library */ - function getLibVersionForKey($key) + public function getLibVersionForKey($key) { return $this->libversion[$key]; } diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index c5405d9c3a9..77a779d8ce0 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -63,8 +63,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $conf, $langs, $mysoc; // Load translation files required by the page @@ -99,7 +99,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures // Recupere emetteur $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini - } + } /** @@ -108,8 +108,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) - { + public function info($langs) + { global $conf, $langs; // Load translation files required by the page @@ -188,11 +188,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures $texte.= ''; return $texte; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * * @param Facture $object Object source to build document * @param Translate $outputlangs Lang output object @@ -202,8 +202,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -521,5 +521,5 @@ class doc_generic_invoice_odt extends ModelePDFFactures } return -1; - } + } } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 3eb5905ccd2..1ba60bf9b41 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -137,7 +137,7 @@ class pdf_crabe extends ModelePDFFactures * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -218,7 +218,7 @@ class pdf_crabe extends ModelePDFFactures } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -230,7 +230,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; @@ -782,7 +782,7 @@ class pdf_crabe extends ModelePDFFactures } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -793,7 +793,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $heightforfooter height for footer * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0) { // phpcs:enable global $conf; @@ -928,7 +928,7 @@ class pdf_crabe extends ModelePDFFactures } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function _tableau_versements_header * @@ -942,7 +942,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $tab3_height height * @return void */ - function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) + private function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) { // phpcs:enable $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); @@ -967,7 +967,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -977,7 +977,7 @@ class pdf_crabe extends ModelePDFFactures * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -1126,7 +1126,7 @@ class pdf_crabe extends ModelePDFFactures } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -1137,7 +1137,7 @@ class pdf_crabe extends ModelePDFFactures * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1455,7 +1455,7 @@ class pdf_crabe extends ModelePDFFactures * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1611,7 +1611,7 @@ class pdf_crabe extends ModelePDFFactures * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs; @@ -1886,7 +1886,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 174f34bfb4b..da45babde4f 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1,13 +1,13 @@ - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2012-2014 Raphaël Doursenaud - * Copyright (C) 2015 Marcos García - * Copyright (C) 2017 Ferran Marcet +/* Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud + * Copyright (C) 2015 Marcos García + * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -26,9 +26,9 @@ */ /** - * \file htdocs/core/modules/facture/doc/pdf_sponge.modules.php - * \ingroup facture - * \brief File of class to generate customers invoices from sponge model + * \file htdocs/core/modules/facture/doc/pdf_sponge.modules.php + * \ingroup facture + * \brief File of class to generate customers invoices from sponge model */ require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; @@ -59,7 +59,7 @@ class pdf_sponge extends ModelePDFFactures public $description; /** - * @var int Save the name of generated file as the main doc when generating a doc with this template + * @var int Save the name of generated file as the main doc when generating a doc with this template */ public $update_main_doc_field; @@ -106,7 +106,7 @@ class pdf_sponge extends ModelePDFFactures * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -860,7 +860,7 @@ class pdf_sponge extends ModelePDFFactures * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs) + public function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs) { global $conf; @@ -1148,9 +1148,9 @@ class pdf_sponge extends ModelePDFFactures /** - * Show total to pay + * Show total to pay * - * @param PDF $pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart @@ -1478,7 +1478,7 @@ class pdf_sponge extends ModelePDFFactures * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1545,7 +1545,7 @@ class pdf_sponge extends ModelePDFFactures * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs; @@ -1818,7 +1818,7 @@ class pdf_sponge extends ModelePDFFactures * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; @@ -1826,16 +1826,16 @@ class pdf_sponge extends ModelePDFFactures } /** - * Define Array Column Field + * Define Array Column Field * - * @param object $object common object - * @param outputlangs $outputlangs langs - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @return null - */ - function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + * @param object $object common object + * @param outputlangs $outputlangs langs + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return null + */ + public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $conf, $hookmanager; diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 18bf4383200..0933d38306c 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -53,7 +53,7 @@ class mod_facture_mars extends ModeleNumRefFactures /** * Constructor */ - function __construct() + public function __construct() { if (! empty($conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX)) { @@ -66,7 +66,7 @@ class mod_facture_mars extends ModeleNumRefFactures * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -78,7 +78,7 @@ class mod_facture_mars extends ModeleNumRefFactures * * @return string Example */ - function getExample() + public function getExample() { return $this->prefixinvoice."0501-0001"; } @@ -89,7 +89,7 @@ class mod_facture_mars extends ModeleNumRefFactures * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs,$conf,$db; @@ -149,7 +149,7 @@ class mod_facture_mars extends ModeleNumRefFactures * @param string $mode 'next' for next value or 'last' for last value * @return string Value */ - function getNextValue($objsoc, $invoice, $mode = 'next') + public function getNextValue($objsoc, $invoice, $mode = 'next') { global $db; $prefix=$this->prefixinvoice; @@ -216,16 +216,16 @@ class mod_facture_mars extends ModeleNumRefFactures else dol_print_error('', 'Bad parameter for getNextValue'); } - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value - */ - function getNumRef($objsoc, $objforref, $mode = 'next') - { - return $this->getNextValue($objsoc, $objforref, $mode); - } + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value + */ + public function getNumRef($objsoc, $objforref, $mode = 'next') + { + return $this->getNextValue($objsoc, $objforref, $mode); + } } diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 1cb86fdfdff..2ef492660b2 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -50,7 +50,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * * @return string Texte descripif */ - function info() + public function info() { global $db, $conf, $langs; @@ -108,7 +108,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -135,7 +135,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * @param string $mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $invoice, $mode = 'next') + public function getNextValue($objsoc, $invoice, $mode = 'next') { global $db,$conf; @@ -182,7 +182,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * @param string $mode 'next' for next value or 'last' for last value * @return string Next free value */ - function getNumRef($objsoc, $objforref, $mode = 'next') + public function getNumRef($objsoc, $objforref, $mode = 'next') { return $this->getNextValue($objsoc, $objforref, $mode); } diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 5aa8f8e83b3..6e588aed098 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -50,7 +50,7 @@ class mod_facture_terre extends ModeleNumRefFactures /** * Constructor */ - function __construct() + public function __construct() { if (! empty($conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX)) { @@ -63,7 +63,7 @@ class mod_facture_terre extends ModeleNumRefFactures * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -75,7 +75,7 @@ class mod_facture_terre extends ModeleNumRefFactures * * @return string Example */ - function getExample() + public function getExample() { return $this->prefixinvoice."0501-0001"; } @@ -86,7 +86,7 @@ class mod_facture_terre extends ModeleNumRefFactures * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs,$conf,$db; @@ -167,7 +167,7 @@ class mod_facture_terre extends ModeleNumRefFactures * @param string $mode 'next' for next value or 'last' for last value * @return string Value */ - function getNextValue($objsoc, $invoice, $mode = 'next') + public function getNextValue($objsoc, $invoice, $mode = 'next') { global $db; @@ -231,16 +231,16 @@ class mod_facture_terre extends ModeleNumRefFactures else dol_print_error('', 'Bad parameter for getNextValue'); } - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value - */ - function getNumRef($objsoc, $objforref, $mode = 'next') - { - return $this->getNextValue($objsoc, $objforref, $mode); - } + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value + */ + public function getNumRef($objsoc, $objforref, $mode = 'next') + { + return $this->getNextValue($objsoc, $objforref, $mode); + } } diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 7232853b4d8..7ed9eb7e94a 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -42,7 +42,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -50,7 +50,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -80,7 +80,7 @@ abstract class ModeleNumRefFactures * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -90,7 +90,7 @@ abstract class ModeleNumRefFactures * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -102,7 +102,7 @@ abstract class ModeleNumRefFactures * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -115,7 +115,7 @@ abstract class ModeleNumRefFactures * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -127,7 +127,7 @@ abstract class ModeleNumRefFactures * @param Facture $facture Objet facture * @return string Value */ - function getNextValue($objsoc, $facture) + public function getNextValue($objsoc, $facture) { global $langs; return $langs->trans("NotAvailable"); @@ -138,15 +138,15 @@ abstract class ModeleNumRefFactures * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); } } diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 91a4ff6d332..559b4cd6d5e 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -116,7 +116,7 @@ class pdf_soleil extends ModelePDFFicheinter * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -151,7 +151,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->posxdesc=$this->marge_gauche+1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -163,7 +163,7 @@ class pdf_soleil extends ModelePDFFicheinter * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager; @@ -338,15 +338,12 @@ class pdf_soleil extends ModelePDFFicheinter // Description of product line $curX = $this->posxdesc-1; - // Description of product line - if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) - { - $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true); - } - else - { - $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true); - } + // Description of product line + if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) { + $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true); + } else { + $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true); + } if ($objectligne->duration > 0) { @@ -496,7 +493,7 @@ class pdf_soleil extends ModelePDFFicheinter * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf; @@ -556,7 +553,7 @@ class pdf_soleil extends ModelePDFFicheinter * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -732,7 +729,7 @@ class pdf_soleil extends ModelePDFFicheinter * @param int $hidefreetext 1=Hide free text * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 08f3449d940..25b98473238 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -61,7 +61,7 @@ class mod_arctic extends ModeleNumRefFicheinter * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -101,7 +101,7 @@ class mod_arctic extends ModeleNumRefFicheinter * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -124,7 +124,7 @@ class mod_arctic extends ModeleNumRefFicheinter * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = 0, $object = '') { global $db,$conf; @@ -152,7 +152,7 @@ class mod_arctic extends ModeleNumRefFicheinter * @param Object $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index 472ffface10..4f66d6940f1 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -61,7 +61,7 @@ class mod_pacific extends ModeleNumRefFicheinter * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +72,7 @@ class mod_pacific extends ModeleNumRefFicheinter * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -83,7 +83,7 @@ class mod_pacific extends ModeleNumRefFicheinter * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs,$conf,$db; @@ -122,7 +122,7 @@ class mod_pacific extends ModeleNumRefFicheinter * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = 0, $object = '') { global $db,$conf; @@ -158,7 +158,7 @@ class mod_pacific extends ModeleNumRefFicheinter * @param Object $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index 0c88cd88d56..f5056bf45bb 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -40,7 +40,7 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -79,7 +79,7 @@ abstract class ModeleNumRefFicheinter * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -89,7 +89,7 @@ abstract class ModeleNumRefFicheinter * * @return string Descriptive text */ - function info() + public function info() { global $langs; $langs->load("ficheinter"); @@ -101,7 +101,7 @@ abstract class ModeleNumRefFicheinter * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("ficheinter"); @@ -114,7 +114,7 @@ abstract class ModeleNumRefFicheinter * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -124,7 +124,7 @@ abstract class ModeleNumRefFicheinter * * @return string Value */ - function getNextValue() + public function getNextValue() { global $langs; return $langs->trans("NotAvailable"); @@ -135,21 +135,21 @@ abstract class ModeleNumRefFicheinter * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); } } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps +// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create an intervention document on disk using template defined into FICHEINTER_ADDON_PDF * diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index 3174208e85b..8c6fd9ebe97 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -60,9 +60,9 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * * @return string text description */ - function info() + public function info() { - global $db, $conf, $langs; + global $db, $conf, $langs; $langs->load("bills"); @@ -96,7 +96,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$user; @@ -119,7 +119,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * @param Object $holiday holiday object * @return string Value if OK, 0 if KO */ - function getNextValue($user, $holiday) + public function getNextValue($user, $holiday) { global $db,$conf; @@ -138,7 +138,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays return $numFinal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next value * @@ -146,7 +146,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * @param Object $objforref Holiday object * @return string Value if OK, 0 if KO */ - function holiday_get_num($fuser, $objforref) + public function holiday_get_num($fuser, $objforref) { // phpcs:enable return $this->getNextValue($fuser, $objforref); diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index 3e118d8aff9..187eb19d80d 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -62,7 +62,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -85,7 +85,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -120,7 +120,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * @param Object $holiday Holiday object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $holiday) + public function getNextValue($objsoc, $holiday) { global $db,$conf; @@ -154,7 +154,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next value * @@ -162,7 +162,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * @param Object $objforref Holiday object * @return string Value if OK, 0 if KO */ - function holiday_get_num($fuser, $objforref) + public function holiday_get_num($fuser, $objforref) { // phpcs:enable return $this->getNextValue($fuser, $objforref); diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php index 8076451b883..9bd0a448ebc 100644 --- a/htdocs/core/modules/holiday/modules_holiday.php +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -44,7 +44,7 @@ abstract class ModelePDFHoliday extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -52,7 +52,7 @@ abstract class ModelePDFHoliday extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -83,7 +83,7 @@ class ModelNumRefHolidays * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -93,7 +93,7 @@ class ModelNumRefHolidays * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("holidays"); @@ -105,7 +105,7 @@ class ModelNumRefHolidays * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("holidays"); @@ -117,7 +117,7 @@ class ModelNumRefHolidays * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -129,7 +129,7 @@ class ModelNumRefHolidays * @param Object $contract contract object * @return string Value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return $langs->trans("NotAvailable"); @@ -140,7 +140,7 @@ class ModelNumRefHolidays * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -149,6 +149,6 @@ class ModelNumRefHolidays elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); elseif ($this->version == 'dolibarr') return DOL_VERSION; elseif ($this->version) return $this->version; - return $langs->trans("NotAvailable"); + else return $langs->trans("NotAvailable"); } } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 17b6e556908..dbb8fadfe12 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -93,7 +93,7 @@ class ImportCsv extends ModeleImports * @param DoliDB $db Database handler * @param string $datatoimport String code describing import set (ex: 'societe_1') */ - function __construct($db, $datatoimport) + public function __construct($db, $datatoimport) { global $conf, $langs; $this->db = $db; @@ -118,20 +118,20 @@ class ImportCsv extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header of an example file for this format * * @param Translate $outputlangs Output language * @return string */ - function write_header_example($outputlangs) + public function write_header_example($outputlangs) { // phpcs:enable return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line of an example file for this format * @@ -139,14 +139,14 @@ class ImportCsv extends ModeleImports * @param array $headerlinefields Array of fields name * @return string */ - function write_title_example($outputlangs, $headerlinefields) + public function write_title_example($outputlangs, $headerlinefields) { // phpcs:enable $s=join($this->separator, array_map('cleansep', $headerlinefields)); return $s."\n"; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record of an example file for this format * @@ -154,21 +154,21 @@ class ImportCsv extends ModeleImports * @param array $contentlinevalues Array of lines * @return string */ - function write_record_example($outputlangs, $contentlinevalues) + public function write_record_example($outputlangs, $contentlinevalues) { // phpcs:enable $s=join($this->separator, array_map('cleansep', $contentlinevalues)); return $s."\n"; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output footer of an example file for this format * * @param Translate $outputlangs Output language * @return string */ - function write_footer_example($outputlangs) + public function write_footer_example($outputlangs) { // phpcs:enable return ''; @@ -176,14 +176,14 @@ class ImportCsv extends ModeleImports - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open input file * * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ - function import_open_file($file) + public function import_open_file($file) { // phpcs:enable global $langs; @@ -209,40 +209,40 @@ class ImportCsv extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of records. File must be closed. * * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ - function import_get_nb_of_lines($file) + public function import_get_nb_of_lines($file) { // phpcs:enable return dol_count_nb_of_line($file); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Input header line from file * * @return int <0 if KO, >=0 if OK */ - function import_read_header() + public function import_read_header() { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array of next record in input file. * * @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) */ - function import_read_record() + public function import_read_record() { // phpcs:enable global $conf; @@ -293,13 +293,13 @@ class ImportCsv extends ModeleImports return $newarrayres; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close file handle * * @return integer */ - function import_close_file() + public function import_close_file() { // phpcs:enable fclose($this->handle); @@ -307,7 +307,7 @@ class ImportCsv extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert a record into database * @@ -319,7 +319,7 @@ class ImportCsv extends ModeleImports * @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. * @return int <0 if KO, >0 if OK */ - function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) + public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) { // phpcs:enable global $langs,$conf,$user; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 3cdd100068e..44134281fb4 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -95,7 +95,7 @@ class ImportXlsx extends ModeleImports * @param DoliDB $db Database handler * @param string $datatoimport String code describing import set (ex: 'societe_1') */ - function __construct($db, $datatoimport) + public function __construct($db, $datatoimport) { global $conf,$langs; $this->db = $db; @@ -125,14 +125,14 @@ class ImportXlsx extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header of an example file for this format * * @param Translate $outputlangs Output language * @return string */ - function write_header_example($outputlangs) + public function write_header_example($outputlangs) { // phpcs:enable global $user,$conf,$langs; @@ -158,7 +158,7 @@ class ImportXlsx extends ModeleImports return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line of an example file for this format * @@ -166,7 +166,7 @@ class ImportXlsx extends ModeleImports * @param array $headerlinefields Array of fields name * @return string */ - function write_title_example($outputlangs, $headerlinefields) + public function write_title_example($outputlangs, $headerlinefields) { // phpcs:enable global $conf; @@ -184,7 +184,7 @@ class ImportXlsx extends ModeleImports return ''; // final output will be generated in footer } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record of an example file for this format * @@ -192,7 +192,7 @@ class ImportXlsx extends ModeleImports * @param array $contentlinevalues Array of lines * @return string */ - function write_record_example($outputlangs, $contentlinevalues) + public function write_record_example($outputlangs, $contentlinevalues) { // phpcs:enable $col = 0; @@ -205,14 +205,14 @@ class ImportXlsx extends ModeleImports return ''; // final output will be generated in footer } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output footer of an example file for this format * * @param Translate $outputlangs Output language * @return string */ - function write_footer_example($outputlangs) + public function write_footer_example($outputlangs) { // phpcs:enable // return the file content as a string @@ -229,14 +229,14 @@ class ImportXlsx extends ModeleImports - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open input file * * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ - function import_open_file($file) + public function import_open_file($file) { // phpcs:enable global $langs; @@ -253,14 +253,14 @@ class ImportXlsx extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of records. File must be closed. * * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ - function import_get_nb_of_lines($file) + public function import_get_nb_of_lines($file) { // phpcs:enable $reader = new PHPExcel_Reader_Excel2007(); @@ -275,13 +275,13 @@ class ImportXlsx extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Input header line from file * * @return int <0 if KO, >=0 if OK */ - function import_read_header() + public function import_read_header() { // phpcs:enable // This is not called by the import code !!! @@ -294,13 +294,13 @@ class ImportXlsx extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array of next record in input file. * * @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) */ - function import_read_record() + public function import_read_record() { // phpcs:enable global $conf; @@ -319,13 +319,13 @@ class ImportXlsx extends ModeleImports return $array; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close file handle * * @return integer */ - function import_close_file() + public function import_close_file() { // phpcs:enable $this->workbook->disconnectWorksheets(); @@ -334,7 +334,7 @@ class ImportXlsx extends ModeleImports // What is this doing here ? it is common to all imports, is should be in the parent class - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert a record into database * @@ -346,7 +346,7 @@ class ImportXlsx extends ModeleImports * @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. * @return int <0 if KO, >0 if OK */ - function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) + public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) { // phpcs:enable global $langs,$conf,$user; diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 1c885bda1b4..7595c3c6c52 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -79,7 +79,7 @@ class ModeleImports /** * Constructor */ - function __construct() + public function __construct() { } @@ -89,7 +89,7 @@ class ModeleImports * * @return string Id */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -99,7 +99,7 @@ class ModeleImports * * @return string Label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -109,7 +109,7 @@ class ModeleImports * * @return string Description */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -119,7 +119,7 @@ class ModeleImports * * @return string Driver suffix */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -129,7 +129,7 @@ class ModeleImports * * @return string Driver version */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -139,7 +139,7 @@ class ModeleImports * * @return string Label of external lib */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -149,13 +149,13 @@ class ModeleImports * * @return string Version of external lib */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge en memoire et renvoie la liste des modeles actifs * @@ -163,7 +163,7 @@ class ModeleImports * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - function liste_modeles($db, $maxfilenamelength = 0) + public function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable dol_syslog(get_class($this)."::liste_modeles"); @@ -213,7 +213,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getPictoForKey($key) + public function getPictoForKey($key) { return $this->picto[$key]; } @@ -224,7 +224,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getDriverLabelForKey($key) + public function getDriverLabelForKey($key) { return $this->driverlabel[$key]; } @@ -235,7 +235,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getDriverDescForKey($key) + public function getDriverDescForKey($key) { return $this->driverdesc[$key]; } @@ -246,7 +246,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getDriverVersionForKey($key) + public function getDriverVersionForKey($key) { return $this->driverversion[$key]; } @@ -257,7 +257,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getLibLabelForKey($key) + public function getLibLabelForKey($key) { return $this->liblabel[$key]; } @@ -268,7 +268,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getLibVersionForKey($key) + public function getLibVersionForKey($key) { return $this->libversion[$key]; } diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index e8e5a6f9205..e84a05dd227 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -117,7 +117,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -174,20 +174,20 @@ class pdf_typhon extends ModelePDFDeliveryOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * - * @param Object $object Object to generate - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref + * @param Object $object Object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -637,7 +637,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -647,7 +647,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -678,7 +678,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -740,7 +740,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs,$hookmanager; @@ -910,18 +910,18 @@ class pdf_typhon extends ModelePDFDeliveryOrder } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } } diff --git a/htdocs/core/modules/livraison/mod_livraison_jade.php b/htdocs/core/modules/livraison/mod_livraison_jade.php index 89cb2794be3..fe94bf839c1 100644 --- a/htdocs/core/modules/livraison/mod_livraison_jade.php +++ b/htdocs/core/modules/livraison/mod_livraison_jade.php @@ -65,7 +65,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * * @return string Texte descripif */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -76,7 +76,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -87,7 +87,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs,$conf,$db; @@ -125,7 +125,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -138,8 +138,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder $resql=$db->query($sql); dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); if ($obj) $max = intval($obj->max); else $max=0; @@ -161,15 +160,15 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Return next free ref - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object livraison - * @return string Texte descriptif + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return next free ref + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object livraison + * @return string Texte descriptif */ - function livraison_get_num($objsoc = 0, $object = '') + public function livraison_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php index 4f8a0640816..2fc2e16d7fd 100644 --- a/htdocs/core/modules/livraison/mod_livraison_saphir.php +++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php @@ -60,8 +60,8 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * * @return string Texte descripif */ - function info() - { + public function info() + { global $conf, $langs; $langs->load("bills"); @@ -100,7 +100,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -124,7 +124,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * @param Object $object Object delivery * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -152,13 +152,13 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * @param string $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free ref * @@ -166,7 +166,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * @param Object $object Objet livraison * @return string Texte descripif */ - function livraison_get_num($objsoc = 0, $object = '') + public function livraison_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/livraison/modules_livraison.php b/htdocs/core/modules/livraison/modules_livraison.php index 8ed70b102fd..ce9d9b77f77 100644 --- a/htdocs/core/modules/livraison/modules_livraison.php +++ b/htdocs/core/modules/livraison/modules_livraison.php @@ -36,119 +36,119 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Return list of active generation modules - * - * @param DoliDB $db Database handler + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates - */ - static function liste_modeles($db, $maxfilenamelength = 0) - { + * @return array List of templates + */ + public static function liste_modeles($db, $maxfilenamelength = 0) + { // phpcs:enable - global $conf; + global $conf; - $type='delivery'; - $liste=array(); + $type='delivery'; + $liste=array(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $liste=getListOfModels($db, $type, $maxfilenamelength); + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db, $type, $maxfilenamelength); - return $liste; - } + return $liste; + } } /** - * \class ModeleNumRefDeliveryOrder - * \brief Classe mere des modeles de numerotation des references de bon de livraison + * \class ModeleNumRefDeliveryOrder + * \brief Classe mere des modeles de numerotation des references de bon de livraison */ abstract class ModeleNumRefDeliveryOrder { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - function isEnabled() - { - return true; - } + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + public function isEnabled() + { + return true; + } - /** - * Renvoi la description par defaut du modele de numerotation - * - * @return string Texte descripif - */ - function info() - { - global $langs; - $langs->load("deliveries"); - return $langs->trans("NoDescription"); - } + /** + * Renvoi la description par defaut du modele de numerotation + * + * @return string Texte descripif + */ + public function info() + { + global $langs; + $langs->load("deliveries"); + return $langs->trans("NoDescription"); + } - /** - * Renvoi un exemple de numerotation - * - * @return string Example - */ - function getExample() - { - global $langs; - $langs->load("deliveries"); - return $langs->trans("NoExample"); - } + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + public function getExample() + { + global $langs; + $langs->load("deliveries"); + return $langs->trans("NoExample"); + } - /** - * Test si les numeros deja en vigueur dans la base ne provoquent pas d - * de conflits qui empechera cette numerotation de fonctionner. - * - * @return boolean false si conflit, true si ok - */ - function canBeActivated() - { - return true; - } + /** + * Test si les numeros deja en vigueur dans la base ne provoquent pas d + * de conflits qui empechera cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + public function canBeActivated() + { + return true; + } - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object third party - * @param Object $object Object delivery - * @return string Valeur - */ - function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } + /** + * Renvoi prochaine valeur attribuee + * + * @param Societe $objsoc Object third party + * @param Object $object Object delivery + * @return string Valeur + */ + public function getNextValue($objsoc, $object) + { + global $langs; + return $langs->trans("NotAvailable"); + } - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - function getVersion() - { - global $langs; - $langs->load("admin"); + /** + * Renvoi version du module numerotation + * + * @return string Valeur + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); - } + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); + } } diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 180feec8699..a29fdd119bf 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -25,13 +25,13 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; */ class mailing_advthirdparties extends MailingTargets { - var $name='ThirdPartyAdvancedTargeting'; + public $name='ThirdPartyAdvancedTargeting'; // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc="Third parties"; - var $require_admin=0; + public $desc="Third parties"; + public $require_admin=0; - var $require_module=array("none"); // This module should not be displayed as Selector in mailling - var $picto='company'; + public $require_module=array("none"); // This module should not be displayed as Selector in mailling + public $picto='company'; /** * @var DoliDB Database handler. @@ -44,13 +44,13 @@ class mailing_advthirdparties extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This is the main function that returns the array of emails * @@ -60,7 +60,7 @@ class mailing_advthirdparties extends MailingTargets * @param array $contactid Array of contact id to add * @return int <0 if error, number of emails added if ok */ - function add_to_target_spec($mailing_id, $socid, $type_of_target, $contactid) + public function add_to_target_spec($mailing_id, $socid, $type_of_target, $contactid) { // phpcs:enable global $conf, $langs; @@ -190,7 +190,7 @@ class mailing_advthirdparties extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { // CHANGE THIS: Optionnal @@ -208,7 +208,7 @@ class mailing_advthirdparties extends MailingTargets * @param string $sql Not use here * @return int Nb of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { global $conf; @@ -228,7 +228,7 @@ class mailing_advthirdparties extends MailingTargets * * @return string A html select zone */ - function formFilter() + public function formFilter() { global $conf, $langs; @@ -287,7 +287,7 @@ class mailing_advthirdparties extends MailingTargets * @param string $type type * @return string Url link */ - function url($id, $type) + public function url($id, $type) { if ($type=='thirdparty') { $companystatic=new Societe($this->db); diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 77d1cc10d72..79c58b1c7ce 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -32,12 +32,12 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; */ class mailing_contacts1 extends MailingTargets { - var $name='ContactCompanies'; // Identifiant du module mailing + public $name='ContactCompanies'; // Identifiant du module mailing // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Contacts of thirdparties (prospects, customers, suppliers...)'; - var $require_module=array("societe"); // Module mailing actif si modules require_module actifs - var $require_admin=0; // Module mailing actif pour user admin ou non - var $picto='contact'; + public $desc='Contacts of thirdparties (prospects, customers, suppliers...)'; + public $require_module=array("societe"); // Module mailing actif si modules require_module actifs + public $require_admin=0; // Module mailing actif pour user admin ou non + public $picto='contact'; /** * @var DoliDB Database handler. @@ -45,15 +45,15 @@ class mailing_contacts1 extends MailingTargets public $db; - /** - * 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; + } /** @@ -64,8 +64,8 @@ class mailing_contacts1 extends MailingTargets * * @return string[] Array with SQL requests */ - function getSqlArrayForStats() - { + public function getSqlArrayForStats() + { global $conf, $langs; $langs->load("commercial"); @@ -80,7 +80,7 @@ class mailing_contacts1 extends MailingTargets $statssql[0].= " AND c.statut = 1"; return $statssql; - } + } /** @@ -91,8 +91,8 @@ class mailing_contacts1 extends MailingTargets * @param string $sql Requete sql de comptage * @return int */ - function getNbOfRecipients($sql = '') - { + public function getNbOfRecipients($sql = '') + { global $conf; $sql = "SELECT count(distinct(c.email)) as nb"; @@ -105,7 +105,7 @@ class mailing_contacts1 extends MailingTargets // The request must return a field called "nb" to be understandable by parent::getNbOfRecipients return parent::getNbOfRecipients($sql); - } + } /** @@ -113,8 +113,8 @@ class mailing_contacts1 extends MailingTargets * * @return string Retourne zone select */ - function formFilter() - { + public function formFilter() + { global $langs; // Load translation files required by the page @@ -311,7 +311,7 @@ class mailing_contacts1 extends MailingTargets $s.=''; return $s; - } + } /** @@ -320,21 +320,21 @@ class mailing_contacts1 extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) - { - return ''.img_object('', "contact").''; - } + public function url($id) + { + return ''.img_object('', "contact").''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int <0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) - { + public function add_to_target($mailing_id) + { // phpcs:enable global $conf, $langs; @@ -448,5 +448,5 @@ class mailing_contacts1 extends MailingTargets } return parent::add_to_target($mailing_id, $cibles); - } + } } diff --git a/htdocs/core/modules/mailings/example.modules.php b/htdocs/core/modules/mailings/example.modules.php index 8feadc6b6e2..45af3dd5b4d 100644 --- a/htdocs/core/modules/mailings/example.modules.php +++ b/htdocs/core/modules/mailings/example.modules.php @@ -26,17 +26,17 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; class mailing_example extends MailingTargets { // CHANGE THIS: Put here a name not already used - var $name='example'; + public $name='example'; // CHANGE THIS: Put here a description of your selector module. // This label is used if no translation is found for key MailingModuleDescXXX where XXX=name is found - var $desc='Put here a description'; - // CHANGE THIS: Set to 1 if selector is available for admin users only - var $require_admin=0; + public $desc='Put here a description'; + // CHANGE THIS: Set to 1 if selector is available for admin users only + public $require_admin=0; // CHANGE THIS: Add a tooltip language key to add a tooltip help icon after the email target selector - var $tooltip='MyTooltipLangKey'; + public $tooltip='MyTooltipLangKey'; - var $require_module=array(); - var $picto=''; + public $require_module=array(); + public $picto=''; /** * @var DoliDB Database handler. @@ -50,20 +50,20 @@ class mailing_example extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable $target = array(); @@ -92,7 +92,7 @@ class mailing_example extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { // CHANGE THIS: Optionnal @@ -103,14 +103,14 @@ class mailing_example extends MailingTargets /** - * 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. + * 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 $sql Requete sql de comptage - * @return int|string Number of recipient or '?' + * @return int|string Number of recipient or '?' */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { // CHANGE THIS: Optionnal @@ -121,11 +121,11 @@ class mailing_example extends MailingTargets /** * This is to add a form filter to provide variant of selector - * If used, the HTML select must be called "filter" + * If used, the HTML select must be called "filter" * * @return string A html select zone */ - function formFilter() + public function formFilter() { // CHANGE THIS: Optionnal @@ -141,7 +141,7 @@ class mailing_example extends MailingTargets * @param int $id ID * @return string Url link */ - function url($id) + public function url($id) { // CHANGE THIS: Optionnal diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index d417bdc8bef..2ea4ba8e3b5 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -33,14 +33,14 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; */ class mailing_fraise extends MailingTargets { - var $name='FundationMembers'; // Identifiant du module mailing + public $name='FundationMembers'; // Identifiant du module mailing // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Foundation members with emails'; + public $desc='Foundation members with emails'; // Set to 1 if selector is available for admin users only - var $require_admin=0; + public $require_admin=0; - var $require_module=array('adherent'); - var $picto='user'; + public $require_module=array('adherent'); + public $picto='user'; /** * @var DoliDB Database handler. @@ -52,7 +52,7 @@ class mailing_fraise extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -66,7 +66,7 @@ class mailing_fraise extends MailingTargets * * @return string[] Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { global $langs; @@ -90,7 +90,7 @@ class mailing_fraise extends MailingTargets * @param string $sql Requete sql de comptage * @return int Nb of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { $sql = "SELECT count(distinct(a.email)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; @@ -107,7 +107,7 @@ class mailing_fraise extends MailingTargets * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $conf, $langs; @@ -214,20 +214,20 @@ class mailing_fraise extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) + public function url($id) { return ''.img_object('', "user").''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $langs,$_POST; diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 0e28b156e09..6c97e165199 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -49,7 +49,7 @@ class MailingTargets // This can't be abstract as it is used for some method * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -59,7 +59,7 @@ class MailingTargets // This can't be abstract as it is used for some method * * @return string Return translation of module label. Try translation of $this->name then translation of 'MailingModuleDesc'.$this->name, or $this->desc if not found */ - function getDesc() + public function getDesc() { global $langs, $form; @@ -80,7 +80,7 @@ class MailingTargets // This can't be abstract as it is used for some method * * @return integer Example */ - function getNbOfRecords() + public function getNbOfRecords() { return 0; } @@ -91,7 +91,7 @@ class MailingTargets // This can't be abstract as it is used for some method * @param string $sql Sql request to count * @return int Nb of recipient, or <0 if error */ - function getNbOfRecipients($sql) + public function getNbOfRecipients($sql) { $result=$this->db->query($sql); if ($result) @@ -112,19 +112,19 @@ class MailingTargets // This can't be abstract as it is used for some method * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Met a jour nombre de destinataires * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb destinataires si ok */ - function update_nb($mailing_id) + public function update_nb($mailing_id) { // phpcs:enable // Mise a jour nombre de destinataire dans table des mailings @@ -151,7 +151,7 @@ class MailingTargets // This can't be abstract as it is used for some method return $nb; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * @@ -159,7 +159,7 @@ class MailingTargets // This can't be abstract as it is used for some method * @param array $cibles Array with targets * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id, $cibles) + public function add_to_target($mailing_id, $cibles) { // phpcs:enable global $conf; @@ -200,8 +200,8 @@ class MailingTargets // This can't be abstract as it is used for some method if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') { // Si erreur autre que doublon - dol_syslog($this->db->error()); - $this->error=$this->db->error(); + dol_syslog($this->db->error().' : '.$targetarray['email']); + $this->error=$this->db->error().' : '.$targetarray['email']; $this->db->rollback(); return -1; } @@ -247,14 +247,14 @@ class MailingTargets // This can't be abstract as it is used for some method return $j; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Supprime tous les destinataires de la table des cibles * - * @param int $mailing_id Id of emailing - * @return void + * @param int $mailing_id Id of emailing + * @return void */ - function clear_target($mailing_id) + public function clear_target($mailing_id) { // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index a0815aac9ec..74dc86c1d9a 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -30,12 +30,12 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; */ class mailing_pomme extends MailingTargets { - var $name='DolibarrUsers'; // Identifiant du module mailing + public $name='DolibarrUsers'; // Identifiant du module mailing // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Dolibarr users with emails'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e - var $require_module=array(); // Module mailing actif si modules require_module actifs - var $require_admin=1; // Module mailing actif pour user admin ou non - var $picto='user'; + public $desc='Dolibarr users with emails'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e + public $require_module=array(); // Module mailing actif si modules require_module actifs + public $require_admin=1; // Module mailing actif pour user admin ou non + public $picto='user'; /** * @var DoliDB Database handler. @@ -48,7 +48,7 @@ class mailing_pomme extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } @@ -62,7 +62,7 @@ class mailing_pomme extends MailingTargets * * @return string[] Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { global $conf, $langs; @@ -88,7 +88,7 @@ class mailing_pomme extends MailingTargets * @param string $sql SQL request to use to count * @return int Number of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { global $conf; @@ -108,7 +108,7 @@ class mailing_pomme extends MailingTargets * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $langs; @@ -140,20 +140,20 @@ class mailing_pomme extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) + public function url($id) { return ''.img_object('', "user").''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $conf, $langs; @@ -191,17 +191,17 @@ class mailing_pomme extends MailingTargets if ($old <> $obj->email) { $cibles[$j] = array( - 'email' => $obj->email, - 'fk_contact' => $obj->fk_contact, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'other' => - ($langs->transnoentities("Login").'='.$obj->login).';'. - ($langs->transnoentities("UserTitle").'='.$obj->civility_id).';'. - ($langs->transnoentities("PhonePro").'='.$obj->office_phone), - 'source_url' => $this->url($obj->id), - 'source_id' => $obj->id, - 'source_type' => 'user' + 'email' => $obj->email, + 'fk_contact' => $obj->fk_contact, + 'lastname' => $obj->lastname, + 'firstname' => $obj->firstname, + 'other' => + ($langs->transnoentities("Login").'='.$obj->login).';'. + ($langs->transnoentities("UserTitle").'='.$obj->civility_id).';'. + ($langs->transnoentities("PhonePro").'='.$obj->office_phone), + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'user' ); $old = $obj->email; $j++; @@ -218,5 +218,5 @@ class mailing_pomme extends MailingTargets } return parent::add_to_target($mailing_id, $cibles); - } + } } diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 4835fe5123d..9a30a063ad3 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -24,13 +24,13 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; */ class mailing_thirdparties extends MailingTargets { - var $name='ThirdPartiesByCategories'; + public $name='ThirdPartiesByCategories'; // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc="Third parties (by categories)"; - var $require_admin=0; + public $desc="Third parties (by categories)"; + public $require_admin=0; - var $require_module=array("societe"); // This module allows to select by categories must be also enabled if category module is not activated - var $picto='company'; + public $require_module=array("societe"); // This module allows to select by categories must be also enabled if category module is not activated + public $picto='company'; /** * @var DoliDB Database handler. @@ -43,7 +43,7 @@ class mailing_thirdparties extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $langs->load("companies"); @@ -52,14 +52,14 @@ class mailing_thirdparties extends MailingTargets } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $conf, $langs; @@ -200,7 +200,7 @@ class mailing_thirdparties extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { // CHANGE THIS: Optionnal @@ -218,7 +218,7 @@ class mailing_thirdparties extends MailingTargets * @param string $sql Requete sql de comptage * @return int Nb of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { global $conf; @@ -238,7 +238,7 @@ class mailing_thirdparties extends MailingTargets * * @return string A html select zone */ - function formFilter() + public function formFilter() { global $conf, $langs; @@ -319,7 +319,7 @@ class mailing_thirdparties extends MailingTargets * @param int $id ID * @return string Url link */ - function url($id) + public function url($id) { return ''.img_object('', "company").''; } diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 5c6438b469f..a19c5480722 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -22,20 +22,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; */ class mailing_thirdparties_services_expired extends MailingTargets { - var $name='DolibarrContractsLinesExpired'; + public $name='DolibarrContractsLinesExpired'; // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Third parties with expired contract\'s lines'; - var $require_admin=0; + public $desc='Third parties with expired contract\'s lines'; + public $require_admin=0; - var $require_module=array('contrat'); - var $picto='company'; + public $require_module=array('contrat'); + public $picto='company'; /** * @var DoliDB Database handler. */ public $db; - var $arrayofproducts=array(); + public $arrayofproducts=array(); /** @@ -43,7 +43,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -77,14 +77,14 @@ class mailing_thirdparties_services_expired extends MailingTargets } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable $key=GETPOST('filter', 'int'); @@ -171,7 +171,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { //var $statssql=array(); @@ -189,7 +189,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * @param string $sql SQL request to use to count * @return int Number of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { $now=dol_now(); @@ -215,7 +215,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * * @return string A html select zone */ - function formFilter() + public function formFilter() { global $langs; @@ -238,7 +238,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * @param int $id ID * @return string Url link */ - function url($id) + public function url($id) { return ''.img_object('', "company").''; } diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 92f4bb3f059..f4eac646db6 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -30,24 +30,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; */ class mailing_xinputfile extends MailingTargets { - var $name='EmailsFromFile'; // Identifiant du module mailing - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e - var $require_module=array(); // Module mailing actif si modules require_module actifs - var $require_admin=0; // Module mailing actif pour user admin ou non - var $picto='generic'; - var $tooltip='UseFormatFileEmailToTarget'; + public $name='EmailsFromFile'; // Identifiant du module mailing + // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + public $desc='EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e + public $require_module=array(); // Module mailing actif si modules require_module actifs + public $require_admin=0; // Module mailing actif pour user admin ou non + public $picto='generic'; + public $tooltip='UseFormatFileEmailToTarget'; - /** - * 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; + } /** @@ -58,7 +58,7 @@ class mailing_xinputfile extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { global $langs; $langs->load("users"); @@ -76,7 +76,7 @@ class mailing_xinputfile extends MailingTargets * @param string $sql Sql request to count * @return string '' means NA */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { return ''; } @@ -88,7 +88,7 @@ class mailing_xinputfile extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) + public function url($id) { global $langs; return $langs->trans('LineInFile', $id); @@ -101,7 +101,7 @@ class mailing_xinputfile extends MailingTargets * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $langs; @@ -110,14 +110,14 @@ class mailing_xinputfile extends MailingTargets return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $conf,$langs,$_FILES; @@ -180,7 +180,9 @@ class mailing_xinputfile extends MailingTargets { $i++; $langs->load("errors"); - $this->error = $langs->trans("ErrorFoundBadEmailInFile", $i, $cpt, $email); + $msg = $langs->trans("ErrorFoundBadEmailInFile", $i, $cpt, $email); + if (! empty($msg)) $this->error = $msg; + else $this->error = 'ErrorFoundBadEmailInFile '.$i.' '.$cpt.' '.$email; // We experience case where $langs->trans return an empty string. } } } diff --git a/htdocs/core/modules/mailings/xinputuser.modules.php b/htdocs/core/modules/mailings/xinputuser.modules.php index 96177483542..62990ec6f90 100644 --- a/htdocs/core/modules/mailings/xinputuser.modules.php +++ b/htdocs/core/modules/mailings/xinputuser.modules.php @@ -30,13 +30,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; */ class mailing_xinputuser extends MailingTargets { - var $name='EmailsFromUser'; // Identifiant du module mailing + public $name='EmailsFromUser'; // Identifiant du module mailing // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='EMails input by user'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e - var $require_module=array(); // Module mailing actif si modules require_module actifs - var $require_admin=0; // Module mailing actif pour user admin ou non - var $picto='generic'; - var $tooltip='UseFormatInputEmailToTarget'; + public $desc='EMails input by user'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e + public $require_module=array(); // Module mailing actif si modules require_module actifs + public $require_admin=0; // Module mailing actif pour user admin ou non + public $picto='generic'; + public $tooltip='UseFormatInputEmailToTarget'; /** @@ -44,7 +44,7 @@ class mailing_xinputuser extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } @@ -58,7 +58,7 @@ class mailing_xinputuser extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { global $langs; $langs->load("users"); @@ -76,7 +76,7 @@ class mailing_xinputuser extends MailingTargets * @param string $sql Sql request to count * @return string '' means NA */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { return ''; } @@ -88,7 +88,7 @@ class mailing_xinputuser extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) + public function url($id) { return ''; } @@ -99,7 +99,7 @@ class mailing_xinputuser extends MailingTargets * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $langs; @@ -108,14 +108,14 @@ class mailing_xinputuser extends MailingTargets return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $conf,$langs,$_FILES; diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 40b591aed3a..f3a105f99f1 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -42,12 +42,12 @@ class pdf_standard extends CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - function addSticker(&$pdf, $outputlangs, $param) + public function addSticker(&$pdf, $outputlangs, $param) { // use this method in future refactoring } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) * - __LOGO__ is replace with company logo @@ -63,7 +63,7 @@ class pdf_standard extends CommonStickerGenerator * @param string $photo Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text) * @return void */ - function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') + public function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') { // phpcs:enable global $db,$mysoc,$conf,$langs; @@ -237,7 +237,7 @@ class pdf_standard extends CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP stream. * @@ -248,7 +248,7 @@ class pdf_standard extends CommonStickerGenerator * @param int $nooutput 1=Generate only file on disk and do not return it on response * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0) { // phpcs:enable global $user,$conf,$langs,$mysoc,$_Avery_Labels; diff --git a/htdocs/core/modules/member/modules_cards.php b/htdocs/core/modules/member/modules_cards.php index 4d70e984d69..cf665b45759 100644 --- a/htdocs/core/modules/member/modules_cards.php +++ b/htdocs/core/modules/member/modules_cards.php @@ -40,7 +40,7 @@ class ModelePDFCards public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ class ModelePDFCards * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - function liste_modeles($db, $maxfilenamelength = 0) + public function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 2a4ff0fc42e..ea247d3b5f9 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -37,7 +37,7 @@ class modAccounting extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 6cf5e45c7f2..c0d5e8f4116 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -38,23 +38,23 @@ class modAdherent extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $conf; + global $conf; $this->db = $db; $this->numero = 310; $this->family = "hr"; $this->module_position = '55'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Management of members of a foundation or association"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto='user'; @@ -67,9 +67,9 @@ class modAdherent extends DolibarrModules // Dependencies $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with $this->langfiles = array("members","companies"); $this->phpmin = array(5,4); // Minimum version of PHP required by module @@ -248,9 +248,9 @@ class modAdherent extends DolibarrModules $this->rights[$r][5] = 'creer'; - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports @@ -269,36 +269,36 @@ class modAdherent extends DolibarrModules $this->export_label[$r]='MembersAndSubscriptions'; $this->export_permission[$r]=array(array("adherent","export")); $this->export_fields_array[$r]=array( - 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature', - 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", - 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", - 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', - 'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel', - 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' - ); + 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature', + 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", + 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", + 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', + 'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel', + 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' + ); $this->export_TypeFields_array[$r]=array( - 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", - 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", - 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', - 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' - ); + 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", + 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", + 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', + 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' + ); $this->export_entities_array[$r]=array( - 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member', - 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", - 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", - 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', - 'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription' - ); + 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member', + 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", + 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", + 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', + 'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription' + ); // Add extra fields $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - // End add axtra fields + // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') '; $this->export_dependencies_array[$r]=array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them @@ -317,54 +317,54 @@ class modAdherent extends DolibarrModules $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array( - 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password", - "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", - 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", - 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", - 'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription' - ); - // Add extra fields - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - } - } - // End add extra fields - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array( - 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)', - 'a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); + 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password", + "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", + 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", + 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", + 'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription' + ); + // Add extra fields + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + } + } + // End add extra fields + $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r]=array( + 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)', + 'a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); $this->import_examplevalues_array[$r]=array( - 'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1', - 'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1', - 'a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member", - 'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now, '%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') - ); + 'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1', + 'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1', + 'a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member", + 'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now, '%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') + ); // Cronjobs $arraydate=dol_getdate(dol_now()); $datestart=dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0=>array( - 'label'=>'SendReminderForExpiredSubscriptionTitle', - 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', - 'objectname'=>'Adherent', - 'method'=>'sendReminderForExpiredSubscription', - 'parameters'=>'10;0', - 'comment'=>'SendReminderForExpiredSubscription', - 'frequency'=>1, - 'unitfrequency'=> 3600 * 24, - 'priority'=>50, - 'status'=>1, - 'test'=>'$conf->adherent->enabled', - 'datestart'=>$datestart - ), + 0=>array( + 'label'=>'SendReminderForExpiredSubscriptionTitle', + 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', + 'objectname'=>'Adherent', + 'method'=>'sendReminderForExpiredSubscription', + 'parameters'=>'10;0', + 'comment'=>'SendReminderForExpiredSubscription', + 'frequency'=>1, + 'unitfrequency'=> 3600 * 24, + 'priority'=>50, + 'status'=>1, + 'test'=>'$conf->adherent->enabled', + 'datestart'=>$datestart + ), ); } @@ -377,7 +377,7 @@ class modAdherent extends DolibarrModules * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index fc2c173d90c..95278005fb1 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -43,7 +43,7 @@ class modAgenda extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -204,18 +204,20 @@ class modAgenda extends DolibarrModules // 'target'=>'', // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // $r++; - $this->menu[$r]=array('fk_menu'=>0, - 'type'=>'top', - 'titre'=>'TMenuAgenda', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php', - 'langs'=>'agenda', - 'position'=>86, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); - $r++; + $this->menu[$r]=array( + 'fk_menu'=>0, + 'type'=>'top', + 'titre'=>'TMenuAgenda', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/index.php', + 'langs'=>'agenda', + 'position'=>86, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2, + ); + $r++; $this->menu[$r]=array('fk_menu'=>'r=0', 'type'=>'left', @@ -396,7 +398,7 @@ class modAgenda extends DolibarrModules $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date", 'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric", 'ac.durationp'=>"Duree", - 'cac.libelle'=>"List:c_actioncomm:libelle:id", + 'cac.libelle'=>"List:c_actioncomm:libelle:libelle", 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text', 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text', 's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text'); diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 8bfec6a1734..b860bf5b9bc 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -38,7 +38,7 @@ class modApi extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; @@ -224,14 +224,14 @@ class modApi extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - $sql = array(); + public function init($options = '') + { + $sql = array(); - $result=$this->_load_tables('/api/sql/'); + $result = $this->_load_tables('/api/sql/'); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } /** * Function called when module is disabled. @@ -241,7 +241,7 @@ class modApi extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function remove($options = '') + public function remove($options = '') { // Remove old constants with entity fields different of 0 $sql = array( diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index d7464c8ac0e..b162fabc559 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -313,22 +313,22 @@ class modAsset extends DolibarrModules } /** - * 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 + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - global $conf; + public function init($options = '') + { + global $conf; - // Permissions - $this->remove($options); + // Permissions + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 08dcd61351d..fb2c818043e 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -41,7 +41,7 @@ class modBanque extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -210,7 +210,7 @@ class modBanque extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index 7c4fcd78bf1..d3efcd1dbdd 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -39,7 +39,7 @@ class modBarcode extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 55; @@ -129,7 +129,7 @@ class modBarcode extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 0ed248f00ab..d9833e2978e 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -30,21 +30,21 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modBlockedLog extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $langs, $conf, $mysoc; + global $langs, $conf, $mysoc; $this->db = $db; $this->numero = 3200; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'blockedlog'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "base"; // Module position in the family on 2 digits ('01', '10', '20', ...) $this->module_position = '75'; @@ -67,10 +67,10 @@ class modBlockedLog extends DolibarrModules // Dependancies //------------- - $this->hidden = false; // A condition to disable module - $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled + $this->hidden = false; // A condition to disable module + $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array('blockedlog'); $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) @@ -81,24 +81,24 @@ class modBlockedLog extends DolibarrModules // enable this module. /*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) { - $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); - $this->automatic_activation = array(); - foreach($tmp as $key) - { - $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; - } + $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); + $this->automatic_activation = array(); + foreach($tmp as $key) + { + $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; + } }*/ //var_dump($this->automatic_activation); $this->always_enabled = (!empty($conf->blockedlog->enabled) - && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) - && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) - && $this->alreadyUsed(1)); + && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) + && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) + && $this->alreadyUsed(1)); // Constants //----------- $this->const = array( - 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) + 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) ); // New pages on tabs @@ -145,12 +145,11 @@ class modBlockedLog extends DolibarrModules * * @return boolean True if already used, otherwise False */ - function alreadyUsed() + public function alreadyUsed() { - - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $b=new BlockedLog($this->db); - return $b->alreadyUsed(1); + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + $b=new BlockedLog($this->db); + return $b->alreadyUsed(1); } @@ -162,89 +161,89 @@ class modBlockedLog extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { - global $conf, $user; + global $conf, $user; - $sql = array(); + $sql = array(); - // If already used, we add an entry to show we enable module - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); + $object=new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); - $b=new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_SET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } + $b=new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_SET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } - $res = $b->create($user); - if ($res<=0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } + $res = $b->create($user); + if ($res<=0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } - return $this->_init($sql, $options); + return $this->_init($sql, $options); } /** - * Function called when module is disabled. - * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function remove($options = '') + * Function called when module is disabled. + * The remove function removes tabs, constants, boxes, permissions and menus 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 = '') { - global $conf, $user; + global $conf, $user; - $sql = array(); + $sql = array(); - // If already used, we add an entry to show we enable module - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); + $object=new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); - $b=new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_RESET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } + $b=new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_RESET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } - if ($b->alreadyUsed(1)) - { - $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error - } - else - { - $res = $b->create($user); - } - if ($res<=0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } + if ($b->alreadyUsed(1)) + { + $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error + } + else + { + $res = $b->create($user); + } + if ($res<=0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } - return $this->_remove($sql, $options); + return $this->_remove($sql, $options); } } diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php new file mode 100644 index 00000000000..6cfac4e2050 --- /dev/null +++ b/htdocs/core/modules/modBom.class.php @@ -0,0 +1,376 @@ + + * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2019 Maxime Kohlhaas + * + * 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 . + */ + +/** + * \defgroup bom Module Bom + * \brief Bom module descriptor. + * + * \file htdocs/bom/core/modules/modBom.class.php + * \ingroup bom + * \brief Description and activation file for module Bom + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +/** + * Description and activation class for module Bom + */ +class modBom extends DolibarrModules +{ + /** + * 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 = 650; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'bom'; + + // 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 = "products"; + // 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 'ModuleBomName' not found (Bom is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleBomDesc' not found (Bom is name of module). + $this->description = "Bill of Materials (BOM) definitions for Manufacturing Resource Planning"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "Bill of Materials definitions. They can be used to make Manufacturing Resource Planning"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'experimental'; + + //Url to the file with your last numberversion of this module + //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; + // Key used in llx_const table to save module status enabled/disabled (where BILLOFMATERIALS is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // 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('/bom/css/bom.css.php'), // Set this to relative path of css file if module has its own css file + 'js' => array('/bom/js/bom.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 + */ + ); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/bom/temp","/bom/subdir"); + $this->dirs = array("/bom/temp"); + + // Config pages. Put here list of php page, stored into bom/admin directory, to use to setup module. + $this->config_page_url = array("bom.php"); + + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->langfiles = array("mrp"); + //$this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(9,0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'BomWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$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('BILLOFMATERIALS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('BILLOFMATERIALS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); + $this->const = array( + 1=>array('BOM_ADDON_PDF', 'chaine', 'avalue', 'Name of PDF model of BOM', 0), + 2=>array('BOM_ADDON', 'chaine', 'mod_bom_standard', 'Name of numbering rules of BOM', 0), + 3=>array('BOM_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/boms', '', 0) + ); + + // 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->bom) || ! isset($conf->bom->enabled)) + { + $conf->bom=new stdClass(); + $conf->bom->enabled=0; + } + + + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@bom:$user->rights->bom->read:/bom/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@bom:$user->rights->othermodule->read:/bom/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // + // Where objecttype can be + // '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(); + /* Example: + $this->dictionaries=array( + 'langs'=>'mylangfile@bom', + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor + '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->bom->enabled,$conf->bom->enabled,$conf->bom->enabled) // Condition to show each dictionary + ); + */ + + + // Boxes/Widgets + // Add here list of php file(s) stored in bom/core/boxes that contains class to show a widget. + $this->boxes = array( + //0=>array('file'=>'bomwidget1.php@bom','note'=>'Widget provided by Bom','enabledbydefaulton'=>'Home'), + //1=>array('file'=>'bomwidget2.php@bom','note'=>'Widget provided by Bom'), + //2=>array('file'=>'bomwidget3.php@bom','note'=>'Widget provided by Bom') + ); + + + // 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'=>'/bom/class/bom.class.php', 'objectname'=>'Bom', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->bom->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->bom->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->bom->enabled', 'priority'=>50) + // ); + + + // 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 bom of Bom'; // 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->bom->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->bom->level1->level2) + + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update bom of Bom'; // 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->bom->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->bom->level1->level2) + + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete bom of Bom'; // 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->bom->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->bom->level1->level2) + + + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; + + // 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'=>'Bom', + 'mainmenu'=>'bom', + 'leftmenu'=>'', + 'url'=>'/bom/bom_list.php', + 'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->enabled' if entry must be visible if module is enabled. + 'perms'=>'1', // Use 'perms'=>'$user->rights->bom->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 */ + + /* BEGIN MODULEBUILDER LEFTMENU BILLOFMATERIALS + $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=bom', // '' 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 Bom', + 'mainmenu'=>'bom', + 'leftmenu'=>'bom_bom_list', + 'url'=>'/bom/bom_list.php', + 'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->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->bom->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=bom,fk_leftmenu=bom', // '' 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 Bom', + 'mainmenu'=>'bom', + 'leftmenu'=>'bom_bom_new', + 'url'=>'/bom/bom_page.php?action=create', + 'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->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->bom->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=bom', // '' 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 Bom', + 'mainmenu'=>'bom', + 'leftmenu'=>'bom_bom', + 'url'=>'/bom/bom_list.php', + 'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1100+$r, + 'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->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->bom->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=bom,fk_leftmenu=bom_bom', // '' 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 Bom', + 'mainmenu'=>'bom', + 'leftmenu'=>'bom_bom', + 'url'=>'/bom/bom_card.php?action=create', + 'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1100+$r, + 'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->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->bom->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 BILLOFMATERIALS */ + + + // Exports + $r=1; + + /* BEGIN MODULEBUILDER EXPORT BILLOFMATERIALS */ + /* + $langs->load("mrp@mrp"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='BomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='bom'; + $keyforclass = 'Bom'; $keyforclassfile='/mymobule/class/bom.class.php'; $keyforelement='bom'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='bom'; $keyforaliasextra='extra'; $keyforelement='bom'; + 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.'bom as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('bom').')'; + $r++; */ + /* END MODULEBUILDER EXPORT BILLOFMATERIALS */ + } + + /** + * 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('/bom/sql/'); + if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') + + // Create extrafields + 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, '', '', 'mrp', '$conf->bom->enabled'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->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, '', '', 'mrp', '$conf->bom->enabled'); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled'); + + $sql = array(); + + 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(); + + return $this->_remove($sql, $options); + } +} diff --git a/htdocs/core/modules/modBookmark.class.php b/htdocs/core/modules/modBookmark.class.php index 38da9a62059..0717236a1bb 100644 --- a/htdocs/core/modules/modBookmark.class.php +++ b/htdocs/core/modules/modBookmark.class.php @@ -38,7 +38,7 @@ class modBookmark extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 330; diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index ed1a4485152..68dda5a94f2 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -35,7 +35,7 @@ class modCashDesk extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -121,24 +121,24 @@ class modCashDesk extends DolibarrModules // 'target'=>'', // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // $r++; - } + } /** - * 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 + * 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 */ - function init($options = '') - { - $sql = array(); + public function init($options = '') + { + $sql = array(); - // Remove permissions and default values - $this->remove($options); + // Remove permissions and default values + $this->remove($options); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 82d0d9d8289..d8f8b6915f3 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -37,7 +37,7 @@ class modCategorie extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -483,7 +483,7 @@ class modCategorie extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modClickToDial.class.php b/htdocs/core/modules/modClickToDial.class.php index 6e8ad1d3041..a25b0fd4571 100644 --- a/htdocs/core/modules/modClickToDial.class.php +++ b/htdocs/core/modules/modClickToDial.class.php @@ -38,7 +38,7 @@ class modClickToDial extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 58; diff --git a/htdocs/core/modules/modCollab.class.php b/htdocs/core/modules/modCollab.class.php index 1e1db01f616..62de6a62b0c 100644 --- a/htdocs/core/modules/modCollab.class.php +++ b/htdocs/core/modules/modCollab.class.php @@ -32,33 +32,33 @@ class modCollab extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $langs,$conf; + global $langs,$conf; $this->db = $db; $this->numero = 30000; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "portal"; $this->module_position = '51'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc..."; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'development'; // 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. $this->picto='globe'; - // Data directories to create when module is enabled - $this->dirs = array("/collab/temp"); + // Data directories to create when module is enabled + $this->dirs = array("/collab/temp"); // Config pages //------------- @@ -66,15 +66,15 @@ class modCollab extends DolibarrModules // Dependancies //------------- - $this->hidden = ! empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module - $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->hidden = ! empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module + $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array("collab"); // Constants //----------- - $this->const = array(); + $this->const = array(); // New pages on tabs // ----------------- @@ -84,42 +84,42 @@ class modCollab extends DolibarrModules //------ $this->boxes = array(); - // Permissions - $this->rights = array(); // Permission array used by this module - $this->rights_class = 'collab'; - $r=0; + // Permissions + $this->rights = array(); // Permission array used by this module + $this->rights_class = 'collab'; + $r=0; - /*$this->rights[$r][0] = 30001; - $this->rights[$r][1] = 'Read website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'read'; - $r++; + /*$this->rights[$r][0] = 30001; + $this->rights[$r][1] = 'Read website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'read'; + $r++; - $this->rights[$r][0] = 30002; - $this->rights[$r][1] = 'Create/modify website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'write'; - $r++; + $this->rights[$r][0] = 30002; + $this->rights[$r][1] = 'Create/modify website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'write'; + $r++; - $this->rights[$r][0] = 30003; - $this->rights[$r][1] = 'Delete website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'delete'; - $r++;*/ + $this->rights[$r][0] = 30003; + $this->rights[$r][1] = 'Delete website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'delete'; + $r++;*/ // Main menu entries $r=0; $this->menu[$r]=array( 'fk_menu'=>'0', // 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 Left menu entry - 'titre'=>'Collab', + 'type'=>'top', // This is a Left menu entry + 'titre'=>'Collab', 'mainmenu'=>'collab', - 'url'=>'/collab/index.php', - 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100, - 'enabled'=>'$conf->collab->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 + 'url'=>'/collab/index.php', + 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>100, + 'enabled'=>'$conf->collab->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 $r++; } } diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 63e2fe4bf88..025bbf0a50c 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -43,7 +43,7 @@ class modCommande extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -269,7 +269,7 @@ class modCommande extends DolibarrModules * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; @@ -299,6 +299,6 @@ class modCommande extends DolibarrModules "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")" ); - return $this->_init($sql, $options); + return $this->_init($sql, $options); } } diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index 226292537f5..01692979c13 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -40,7 +40,7 @@ class modComptabilite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -101,16 +101,16 @@ class modComptabilite extends DolibarrModules } - /** - * 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 + /** + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { global $conf; // Nettoyage avant activation diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index 8bcc645d3ba..b3053cceae0 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -39,7 +39,7 @@ class modContrat extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; @@ -212,7 +212,7 @@ class modContrat extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 31d27abac0b..f07ddeaeaae 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -37,7 +37,7 @@ class modCron extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs, $conf; diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index 5dfc0fb83dd..be88c709090 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -210,15 +210,15 @@ class modDataPolicy extends DolibarrModules { */ public function init($options = '') { - global $langs; + global $langs; - $this->_load_tables('/datapolicy/sql/'); + $this->_load_tables('/datapolicy/sql/'); // Create extrafields include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); - /* + /* // Extrafield contact $result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); @@ -239,7 +239,7 @@ class modDataPolicy extends DolibarrModules { $result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0); $result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'adherent', 0, 0, '', '', 0, '', '0', 0); - */ + */ $sql = array(); diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index ce2a8056e48..61b725f1d8e 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -37,7 +37,7 @@ class modDeplacement extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -152,7 +152,7 @@ class modDeplacement extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index 455c28914da..8b1ad690efe 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -39,7 +39,7 @@ class modDocumentGeneration extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 1520; @@ -96,15 +96,15 @@ class modDocumentGeneration extends DolibarrModules /** - * 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 + * 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 - */ - function init($options = '') - { + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { global $conf; // Permissions diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index bb27b309c1d..d196cdb1c0e 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -40,7 +40,7 @@ class modDon extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 700; @@ -151,7 +151,7 @@ class modDon extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php index 6e915afc6f8..708f0fb86a7 100644 --- a/htdocs/core/modules/modDynamicPrices.class.php +++ b/htdocs/core/modules/modDynamicPrices.class.php @@ -36,7 +36,7 @@ class modDynamicPrices extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2200; diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index 602bc37a03c..0208541d2e2 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -37,7 +37,7 @@ class modECM extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 443146d13a4..e096d840864 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -41,7 +41,7 @@ class modExpedition extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -308,14 +308,14 @@ class modExpedition extends DolibarrModules /** - * 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 + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index d715cb119ca..d6ef55fe646 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -36,7 +36,7 @@ class modExpenseReport extends DolibarrModules * * @param Database $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -203,14 +203,14 @@ class modExpenseReport extends DolibarrModules } /** - * 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. + * 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 - * @return int 1 if OK, 0 if KO + * @param string $options Options + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index b0d95137316..d636772caff 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -38,7 +38,7 @@ class modExport extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 240; diff --git a/htdocs/core/modules/modExternalRss.class.php b/htdocs/core/modules/modExternalRss.class.php index e384bccbcba..4e271b4573f 100644 --- a/htdocs/core/modules/modExternalRss.class.php +++ b/htdocs/core/modules/modExternalRss.class.php @@ -38,7 +38,7 @@ class modExternalRss extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -86,7 +86,7 @@ class modExternalRss extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; @@ -126,7 +126,7 @@ class modExternalRss extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function remove($options = '') + public function remove($options = '') { $sql = array(); diff --git a/htdocs/core/modules/modExternalSite.class.php b/htdocs/core/modules/modExternalSite.class.php index 0a720579eda..6cbd7141af8 100644 --- a/htdocs/core/modules/modExternalSite.class.php +++ b/htdocs/core/modules/modExternalSite.class.php @@ -39,7 +39,7 @@ class modExternalSite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modFTP.class.php b/htdocs/core/modules/modFTP.class.php index a54cbc24963..699617cd99e 100644 --- a/htdocs/core/modules/modFTP.class.php +++ b/htdocs/core/modules/modFTP.class.php @@ -33,12 +33,12 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modFTP extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index c8e29205306..106de48e96d 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -40,7 +40,7 @@ class modFacture extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -347,14 +347,14 @@ class modFacture extends DolibarrModules /** - * 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 + * 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 ('', 'newboxdefonly', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf, $langs; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 873aba7eb30..7085fbef000 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -39,7 +39,7 @@ class modFckeditor extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2000; diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index de2d40490c0..8267000297b 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -42,7 +42,7 @@ class modFicheinter extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -201,14 +201,14 @@ class modFicheinter extends DolibarrModules /** - * 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 + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 3510834a836..12193b630c8 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -39,7 +39,7 @@ class modFournisseur extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -61,12 +61,13 @@ class modFournisseur extends DolibarrModules $this->picto='company'; // Data directories to create when module is enabled - $this->dirs = array("/fournisseur/temp", - "/fournisseur/commande", - "/fournisseur/commande/temp", - "/fournisseur/facture", - "/fournisseur/facture/temp" - ); + $this->dirs = array( + "/fournisseur/temp", + "/fournisseur/commande", + "/fournisseur/commande/temp", + "/fournisseur/facture", + "/fournisseur/facture/temp" + ); // Dependencies $this->depends = array("modSociete"); @@ -622,7 +623,7 @@ class modFournisseur extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modGeoIPMaxmind.class.php b/htdocs/core/modules/modGeoIPMaxmind.class.php index 0b090abfa80..91c82e713db 100644 --- a/htdocs/core/modules/modGeoIPMaxmind.class.php +++ b/htdocs/core/modules/modGeoIPMaxmind.class.php @@ -37,7 +37,7 @@ class modGeoIPMaxmind extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2900; diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index 9dbf4ee124f..bfff235bdae 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -36,7 +36,7 @@ class modGravatar extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 68aad4e3533..ea4ff52f473 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -131,7 +131,7 @@ class modHRM extends DolibarrModules * @param string $options Enabling module ('', 'noboxes') * @return int if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 01a70a429ad..09a30e16914 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -41,7 +41,7 @@ class modHoliday extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modIFTTT.class.php b/htdocs/core/modules/modIFTTT.class.php new file mode 100644 index 00000000000..c3bab06ed93 --- /dev/null +++ b/htdocs/core/modules/modIFTTT.class.php @@ -0,0 +1,251 @@ + + * + * 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 . + */ + +/** + * \defgroup ifttt Module IFTTT + * \brief Descriptor file for IFTTT module + * \file htdocs/core/modules/modIFTTT.class.php + * \ingroup ifttt + * \brief Description and activation file for module IFTTT + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +/** + * Description and activation class for module IFTTT + */ +class modIFTTT extends DolibarrModules +{ + /** + * 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 = 2620; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'ifttt'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "interface"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "IFTTT interface"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version + $this->version = 'development'; + // 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); + // Can be enabled / disabled only in the main company with superadmin account + $this->core_enabled = 1; + // 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='technic'; + + $this->module_parts = array(); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/api/temp"); + $this->dirs = array(); + + // Config pages. Put here list of php page, stored into api/admin directory, to use to setup module. + $this->config_page_url = array("index.php@ifttt"); + + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->langfiles = array("other"); + + // 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(); + + // Array to add new pages in new tabs + // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@api:$user->rights->ifttt->read:/api/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 + // 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@api:$user->rights->othermodule->read:/api/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. + // '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 + $this->tabs = array(); + + // Dictionaries + if (! isset($conf->ifttt->enabled)) + { + $conf->ifttt=new stdClass(); + $conf->ifttt->enabled=0; + } + $this->dictionaries=array(); + + // Boxes + // Add here list of php file(s) stored in core/boxes that contains class to show a box. + $this->boxes = array(); // List of boxes + // Example: + //$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>''));); + + // Permissions + $this->rights = array(); // Permission array used by this module + $r=0; + + // Add here list of permission defined by an id, a label, a boolean and two constant strings. + // Example: + // $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + // $this->rights[$r][1] = 'Permision label'; // Permission label + // $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $r++; + + + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; + + // Add here entries to declare new menus + // + // Example to declare a new Top Menu entry and its Left menu entry: + // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu + // 'type'=>'top', // This is a Top menu entry + // 'titre'=>'Api top menu', + // 'mainmenu'=>'api', + // 'leftmenu'=>'api', + // 'url'=>'/api/pagetop.php', + // 'langs'=>'mylangfile@api', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'enabled'=>'$conf->ifttt->enabled', // Define condition to show or hide menu entry. Use '$conf->ifttt->enabled' if entry must be visible if module is enabled. + // 'perms'=>'1', // Use 'perms'=>'$user->rights->ifttt->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare a Left Menu entry into an existing Top menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // 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'=>'Api left menu', + // 'mainmenu'=>'xxx', + // 'leftmenu'=>'api', + // 'url'=>'/api/pagelevel2.php', + // 'langs'=>'mylangfile@api', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'enabled'=>'$conf->ifttt->enabled', // Define condition to show or hide menu entry. Use '$conf->ifttt->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->ifttt->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + + + // Exports + $r=1; + + // Example: + // $this->export_code[$r]=$this->rights_class.'_'.$r; + // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. + // $this->export_permission[$r]=array(array("facture","facture","export")); + // $this->export_fields_array[$r]=array( + // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', + // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', + // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", + // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", + // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", + // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' + //); + // $this->export_entities_array[$r]=array( + // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', + // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice", + // 'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line", + // 'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", + // 'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' + //); + // $this->export_sql_start[$r]='SELECT DISTINCT '; + // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; + // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; + // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; + // $this->export_sql_order[$r] .=' ORDER BY s.nom'; + // $r++; + } + + /** + * 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 = '') + { + $sql = array(); + + $result=$this->_load_tables('/ifttt/sql/'); + + 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 = '') + { + // Remove old constants with entity fields different of 0 + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_IFTTT', 1), + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('IFTTT_PRODUCTION_MODE', 1) + ); + + return $this->_remove($sql, $options); + } +} diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index e7d47763013..2f5c8c77db8 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -38,7 +38,7 @@ class modImport extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 250; diff --git a/htdocs/core/modules/modIncoterm.class.php b/htdocs/core/modules/modIncoterm.class.php index 9d07028c5dd..8cae0980ff7 100644 --- a/htdocs/core/modules/modIncoterm.class.php +++ b/htdocs/core/modules/modIncoterm.class.php @@ -38,8 +38,8 @@ class modIncoterm extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $langs,$conf; $this->db = $db; diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index c0f02229f2b..fefc7117b10 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -38,7 +38,7 @@ class modLabel extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 60; @@ -100,13 +100,13 @@ class modLabel extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { // Permissions $this->remove($options); $sql = array(); return $this->_init($sql, $options); - } + } } diff --git a/htdocs/core/modules/modLdap.class.php b/htdocs/core/modules/modLdap.class.php index a2a355060d1..b2a290fe46a 100644 --- a/htdocs/core/modules/modLdap.class.php +++ b/htdocs/core/modules/modLdap.class.php @@ -37,7 +37,7 @@ class modLdap extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 200; diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 43a2876ef79..e4d1a048c6f 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -37,7 +37,7 @@ class modLoan extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -149,14 +149,14 @@ class modLoan extends DolibarrModules /** - * 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 + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index bbcd651d453..36893ddfa13 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -39,7 +39,7 @@ class modMailing extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 22; @@ -142,14 +142,14 @@ class modMailing extends DolibarrModules /** - * 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 + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modMailmanSpip.class.php b/htdocs/core/modules/modMailmanSpip.class.php index 2c4123fc3fa..ecae27155b5 100644 --- a/htdocs/core/modules/modMailmanSpip.class.php +++ b/htdocs/core/modules/modMailmanSpip.class.php @@ -38,7 +38,7 @@ class modMailmanSpip extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 105; diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index 22124404673..f5b79570c1a 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -35,7 +35,7 @@ class modMargin extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 94d307ae522..59b3dcde2ce 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -35,7 +35,7 @@ class modModuleBuilder extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 32bd1bd5980..e3f37c5f284 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -38,8 +38,8 @@ class modMultiCurrency extends DolibarrModules * * @param DoliDB $db Database handler */ - public function __construct($db) - { + public function __construct($db) + { global $langs, $conf; $this->db = $db; diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index 54698dca703..c73c8210072 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -36,7 +36,7 @@ class modNotification extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 600; @@ -89,7 +89,7 @@ class modNotification extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index 27310e9c84e..f4f52eae80a 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -40,7 +40,7 @@ class modOauth extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 66000; @@ -130,7 +130,7 @@ class modOauth extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index a47a2791b60..be2e9b6e449 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -37,8 +37,8 @@ class modOpenSurvey extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $langs,$conf; $this->db = $db; @@ -119,51 +119,57 @@ class modOpenSurvey extends DolibarrModules $r++; - // Menus - //------- + // Menus + //------- $r=0; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'Survey', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey', - 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', - 'langs'=>'opensurvey', - 'position'=>200, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->read', - 'target'=>'', - 'user'=>0); - $r++; + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'Survey', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey', + 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', + 'langs'=>'opensurvey', + 'position'=>200, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->read', + 'target'=>'', + 'user'=>0, + ); + $r++; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'NewSurvey', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey_new', - 'url'=>'/opensurvey/wizard/index.php', - 'langs'=>'opensurvey', - 'position'=>210, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->write', - 'target'=>'', - 'user'=>0); - $r++; + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'NewSurvey', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey_new', + 'url'=>'/opensurvey/wizard/index.php', + 'langs'=>'opensurvey', + 'position'=>210, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->write', + 'target'=>'', + 'user'=>0, + ); + $r++; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'List', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey_list', - 'url'=>'/opensurvey/list.php', - 'langs'=>'opensurvey', - 'position'=>220, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->read', - 'target'=>'', - 'user'=>0); - $r++; - } + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'List', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey_list', + 'url'=>'/opensurvey/list.php', + 'langs'=>'opensurvey', + 'position'=>220, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->read', + 'target'=>'', + 'user'=>0, + ); + $r++; + } /** * Function called when module is enabled. @@ -173,13 +179,13 @@ class modOpenSurvey extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - // Permissions - $this->remove($options); + public function init($options = '') + { + // Permissions + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modPaybox.class.php b/htdocs/core/modules/modPaybox.class.php index 6349d5474b3..635c428f3fa 100644 --- a/htdocs/core/modules/modPaybox.class.php +++ b/htdocs/core/modules/modPaybox.class.php @@ -36,7 +36,7 @@ class modPayBox extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index a4aa8fcc6b0..99ef4dd45de 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -37,7 +37,7 @@ class modPaypal extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index f18bf1bf03c..ec4c4ca3a46 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -40,7 +40,7 @@ class modPrelevement extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -124,40 +124,41 @@ class modPrelevement extends DolibarrModules $this->rights[$r][4] = 'bons'; $this->rights[$r][5] = 'credit'; -/* $this->rights[2][0] = 154; + /* + $this->rights[2][0] = 154; $this->rights[2][1] = 'Setup withdraw account'; $this->rights[2][2] = 'w'; $this->rights[2][3] = 0; $this->rights[2][4] = 'bons'; $this->rights[2][5] = 'configurer'; -*/ + */ - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. - } + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } - /** - * 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 - */ - function init($options = '') - { - global $conf; + /** + * 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 = '') + { + global $conf; - // Permissions - $this->remove($options); + // Permissions + $this->remove($options); - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", - ); + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", + ); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index bb8a2be6120..09992bd176d 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -40,7 +40,7 @@ class modPrinting extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 64000; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 4c6c420aa50..368a41a6fac 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -42,7 +42,7 @@ class modProduct extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $mysoc; @@ -521,7 +521,7 @@ class modProduct extends DolibarrModules if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); -$this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( 'sp.price'=>"PriceQtyMinHT*", 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' @@ -625,20 +625,20 @@ $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array } - /** - * 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 ('', 'newboxdefonly', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function init($options = '') - { - $this->remove($options); + /** + * 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 ('', 'newboxdefonly', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index f5e8fc6324c..65cefa6676a 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -38,7 +38,7 @@ class modProductBatch extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; @@ -114,7 +114,7 @@ class modProductBatch extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $db,$conf; diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index eeca1e8883f..f100e8629e7 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -41,7 +41,7 @@ class modProjet extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -310,7 +310,7 @@ class modProjet extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index a2a32241065..b28477f3719 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -41,7 +41,7 @@ class modPropale extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -265,7 +265,7 @@ class modPropale extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 6d00acb2d16..2694b852b7a 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -40,7 +40,7 @@ class modReceiptPrinter extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 67000; @@ -130,7 +130,7 @@ class modReceiptPrinter extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; // Clean before activation diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 663a854f7a5..9fc82dc9ad6 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -36,7 +36,7 @@ class modReception extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -243,7 +243,7 @@ class modReception extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index 4756f2a1a41..e111e81ef6b 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -43,7 +43,7 @@ class modSalaries extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -159,14 +159,14 @@ class modSalaries extends DolibarrModules /** - * 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 + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 2e3ed91bf06..9fa79683a7f 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -40,7 +40,7 @@ class modService extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $mysoc; @@ -71,7 +71,7 @@ class modService extends DolibarrModules // Config pages $this->config_page_url = array("product.php@product"); - $this->langfiles = array("products","companies","bills"); + $this->langfiles = array("products","companies","stocks","bills"); // Constants $this->const = array(); @@ -115,27 +115,23 @@ class modService extends DolibarrModules $this->rights[$r][4] = 'export'; $r++; - - /* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert - $r=0; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'ProductVatMassChange', - 'url'=>'/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools', - 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>300, - 'enabled'=>'$conf->product->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // 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'=>0); // 0=Menu for internal users, 1=external users, 2=both - $r++; - */ - - // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts + $r=0; + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'ProductVatMassChange', + 'url'=>'/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools', + 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>300, + 'enabled'=>'$conf->product->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // 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'=>0); // 0=Menu for internal users, 1=external users, 2=both + $r++; + */ // Exports //-------- @@ -148,57 +144,36 @@ class modService extends DolibarrModules $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock')); if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; - //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); - $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric')); + $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); + if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); + if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; + $this->export_TypeFields_array[$r]=array( + 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date' + ); + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); + if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service"); + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'service')); if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'service')); - // Add extra fields - $sql="SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'"; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $typeFilter="Text"; - switch($obj->type) - { - case 'int': - case 'double': - case 'price': - $typeFilter="Numeric"; - break; - case 'date': - case 'datetime': - $typeFilter="Date"; - break; - case 'boolean': - $typeFilter="Boolean"; - break; - case 'sellist': - $tmp=''; - $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; - break; - } - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; - $this->export_entities_array[$r][$fieldname]='product'; - } - } - // End add extra fields - + if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); + if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; + if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; - + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) { @@ -215,6 +190,7 @@ class modService extends DolibarrModules 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; //$this->export_TypeFields_array[$r]=array( // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', @@ -226,12 +202,61 @@ class modService extends DolibarrModules 'pr.price_ttc'=>"product", 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', - 'pr.date_price'=>"product"); + 'pr.recuperableonly'=>'product', + 'pr.date_price'=>"product"); $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; } + + if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) + { + // Exports virtual products + $r++; + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r]=array(array("service","export")); + $this->export_fields_array[$r]=array( + 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", + 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", + 'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', + 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", + 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' + ); + if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); + if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); + $this->export_TypeFields_array[$r]=array( + 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", + 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', + 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", + 'p.datec'=>'Date','p.tms'=>'Date' + ); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); + if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); + $this->export_entities_array[$r]=array( + 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", + 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct", + 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', + 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", + 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" + ); + if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); + if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); + $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; + $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; + } } @@ -239,11 +264,13 @@ class modService extends DolibarrModules //-------- $r=0; + // Import list of services + $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; $this->import_label[$r]="Products"; // Translation key $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_entities_array[$r]=array(); // We define here only fields that use a different icon from the one defined in import_icon $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array( @@ -252,9 +279,14 @@ class modService extends DolibarrModules 'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", 'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation' ); - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); + if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields + $import_extrafield_sample=array(); $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) @@ -268,15 +300,25 @@ class modService extends DolibarrModules } // End add extra fields $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); + $this->import_regex_array[$r]=array( + 'p.ref' => '[^ ]', + 'p.price_base_type' => '\AHT\z|\ATTC\z', + 'p.tosell' => '^[0|1]$', + 'p.tobuy' => '^[0|1]$', + 'p.fk_product_type' => '^[0|1]$', + 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'p.recuperableonly' => '^[0|1]$', + 'p.finished' => '^[0|1]$' + ); $this->import_examplevalues_array[$r]=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31'); - - + $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); + if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled + if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) { if (! empty($conf->fournisseur->enabled)) { - // Import suppliers prices (note: this code is duplicated into module product) + // Import suppliers prices (note: this code is duplicated in module Service) $r++; $this->import_code[$r]=$this->rights_class.'_supplierprices'; $this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key @@ -284,9 +326,15 @@ class modService extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); $this->import_tables_creator_array[$r]=array('sp'=>'fk_user'); - $this->import_fields_array[$r]=array( - 'sp.fk_product'=>"ProductOrService*", - 'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.default_vat_code'=>'VATCode' + $this->import_fields_array[$r]=array(//field order as per structure of table llx_product_fournisseur_price, without optional fields + 'sp.fk_product'=>"ProductOrService*", + 'sp.fk_soc' => "Supplier*", + 'sp.ref_fourn' => 'SupplierRef', + 'sp.quantity' => "QtyMin*", + 'sp.tva_tx' => 'VATRate', + 'sp.default_vat_code' => 'VATCode', + 'sp.delivery_time_days' => 'DeliveryDelay', + 'sp.supplier_reputation' => 'SupplierReputation' ); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); @@ -297,11 +345,23 @@ class modService extends DolibarrModules 'sp.remise_percent'=>'DiscountQtyMin' )); + if ($conf->multicurrency->enabled) + { + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( + 'sp.fk_multicurrency'=>'CurrencyCodeId',//ideally this should be automatically obtained from the CurrencyCode on the next line + 'sp.multicurrency_code'=>'CurrencyCode', + 'sp.multicurrency_tx'=>'CurrencyRate', + 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', + 'sp.multicurrency_price'=>'CurrencyPrice', + )); + } + $this->import_convertvalue_array[$r]=array( 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('sp.fk_product'=>"PREF123456", + $this->import_examplevalues_array[$r]=array( + 'sp.fk_product'=>"PREF123456", 'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21', 'sp.price'=>"50", 'sp.unitprice'=>'50', @@ -311,7 +371,7 @@ class modService extends DolibarrModules if (! empty($conf->global->PRODUIT_MULTIPRICES)) { - // Import product multiprice + // Import products multiprices $r++; $this->import_code[$r]=$this->rights_class.'_multiprice'; $this->import_label[$r]="ProductsOrServiceMultiPrice"; // Translation key @@ -325,17 +385,20 @@ class modService extends DolibarrModules 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation*'); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1", 'pr.price_base_type'=>"HT",'pr.price_level'=>"1", 'pr.price'=>"100",'pr.price_ttc'=>"110", 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", - 'pr.tva_tx'=>'19.6', - 'pr.date_price'=>'2013-04-10'); + 'pr.tva_tx'=>'20', + 'pr.recuperableonly'=>'0', + 'pr.date_price'=>'2013-04-10'); } if (! empty($conf->global->MAIN_MULTILANGS)) { + // Import translations of product names and descriptions $r++; $this->import_code[$r]=$this->rights_class.'_languages'; $this->import_label[$r]="ProductsOrServicesTranslations"; @@ -363,7 +426,7 @@ class modService extends DolibarrModules * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { $this->remove($options); diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index b7e1bfd44a3..d8d8d8fb76e 100644 --- a/htdocs/core/modules/modSocialNetworks.class.php +++ b/htdocs/core/modules/modSocialNetworks.class.php @@ -36,7 +36,7 @@ class modSocialNetworks extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b879959946d..32b3b4b97fc 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -41,7 +41,7 @@ class modSociete extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -720,15 +720,15 @@ class modSociete extends DolibarrModules /** - * 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 + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { global $conf, $langs; // We disable this to prevent pb of modules not correctly disabled diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index fa283c58137..230d9dd5fbe 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -40,7 +40,7 @@ class modStock extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; @@ -351,14 +351,14 @@ class modStock extends DolibarrModules /** - * 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 + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index a2b2a68127a..ae15e763fd8 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -36,7 +36,7 @@ class modStripe extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 3d580fa439c..882b02b5fb4 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -42,7 +42,7 @@ class modSupplierProposal extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -57,10 +57,10 @@ class modSupplierProposal extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto='supplier_proposal'; - + // Data directories to create when module is enabled. $this->dirs = array(); - + // Config pages. Put here list of php page names stored in admin directory used to setup module. $this->config_page_url = array("supplier_proposal.php"); @@ -206,7 +206,7 @@ class modSupplierProposal extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php index a291b7977ee..1ac6ead1087 100644 --- a/htdocs/core/modules/modSyslog.class.php +++ b/htdocs/core/modules/modSyslog.class.php @@ -37,7 +37,7 @@ class modSyslog extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 42; diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index a2f51ef0cc1..c113f9a339a 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -41,7 +41,7 @@ class modTax extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -185,7 +185,7 @@ class modTax extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index e08def907a1..e6deef76144 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -231,23 +231,9 @@ class modTicket extends DolibarrModules 'titre' => 'List', 'mainmenu' => 'ticket', 'leftmenu' => 'ticketlist', - 'url' => '/ticket/list.php', - 'langs' => 'ticket', - 'position' => 103, - 'enabled' => '$conf->ticket->enabled', - 'perms' => '$user->rights->ticket->read', - 'target' => '', - 'user' => 2); - $r++; - - $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticketlist', - 'type' => 'left', - 'titre' => 'MenuListNonClosed', - 'mainmenu' => 'ticket', - 'leftmenu' => 'ticketlist', 'url' => '/ticket/list.php?search_fk_status=non_closed', 'langs' => 'ticket', - 'position' => 104, + 'position' => 103, 'enabled' => '$conf->ticket->enabled', 'perms' => '$user->rights->ticket->read', 'target' => '', @@ -259,7 +245,7 @@ class modTicket extends DolibarrModules 'titre' => 'MenuTicketMyAssign', 'mainmenu' => 'ticket', 'leftmenu' => 'ticketmy', - 'url' => '/ticket/list.php?mode=my_assign', + 'url' => '/ticket/list.php?mode=mine&search_fk_status=non_closed', 'langs' => 'ticket', 'position' => 105, 'enabled' => '$conf->ticket->enabled', @@ -268,19 +254,6 @@ class modTicket extends DolibarrModules 'user' => 0); $r++; - $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticketmy', - 'type' => 'left', - 'titre' => 'MenuTicketMyAssignNonClosed', - 'mainmenu' => 'ticket', - 'url' => '/ticket/list.php?mode=my_assign&search_fk_status=non_closed', - 'langs' => 'ticket', - 'position' => 106, - 'enabled' => '$conf->ticket->enabled', - 'perms' => '$user->rights->ticket->read', - 'target' => '', - 'user' => 0); - $r++; - $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket', 'type' => 'left', 'titre' => 'Statistics', diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index bef84b3a157..baf7f94d0f4 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -38,7 +38,7 @@ class modUser extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -331,8 +331,8 @@ class modUser extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { global $conf; // Permissions @@ -341,5 +341,5 @@ class modUser extends DolibarrModules $sql = array(); return $this->_init($sql, $options); - } + } } diff --git a/htdocs/core/modules/modWebServices.class.php b/htdocs/core/modules/modWebServices.class.php index 9d32b03df79..2aa98e80679 100644 --- a/htdocs/core/modules/modWebServices.class.php +++ b/htdocs/core/modules/modWebServices.class.php @@ -35,7 +35,7 @@ class modWebServices extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2600; diff --git a/htdocs/core/modules/modWebServicesClient.class.php b/htdocs/core/modules/modWebServicesClient.class.php index 6ec7bb5aae9..33c7bae997a 100644 --- a/htdocs/core/modules/modWebServicesClient.class.php +++ b/htdocs/core/modules/modWebServicesClient.class.php @@ -35,7 +35,7 @@ class modWebServicesClient extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2660; diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 4fd6cd2976f..6f882f082ad 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -36,7 +36,7 @@ class modWebsite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; @@ -138,14 +138,14 @@ class modWebsite extends DolibarrModules /** - * 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 + * 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 + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index 955165ffd80..7d2e833a4fc 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -37,7 +37,7 @@ class modWorkflow extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -137,9 +137,9 @@ class modWorkflow extends DolibarrModules * It also creates data directories * * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php index 42f7b0c8be0..19e74cf3c19 100644 --- a/htdocs/core/modules/payment/mod_payment_ant.php +++ b/htdocs/core/modules/payment/mod_payment_ant.php @@ -59,7 +59,7 @@ class mod_payment_ant extends ModeleNumRefPayments * * @return string Texte descripif */ - function info() + public function info() { global $db, $conf, $langs; @@ -99,7 +99,7 @@ class mod_payment_ant extends ModeleNumRefPayments * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -122,7 +122,7 @@ class mod_payment_ant extends ModeleNumRefPayments * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -143,7 +143,7 @@ class mod_payment_ant extends ModeleNumRefPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -151,7 +151,7 @@ class mod_payment_ant extends ModeleNumRefPayments * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php index c8c850affda..a6cfca7e1df 100644 --- a/htdocs/core/modules/payment/mod_payment_cicada.php +++ b/htdocs/core/modules/payment/mod_payment_cicada.php @@ -60,7 +60,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +72,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -155,7 +155,7 @@ class mod_payment_cicada extends ModeleNumRefPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -163,7 +163,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * @param string $objforref Object for number to search * @return string Next free value */ - function payment_get_num($objsoc, $objforref) + public function payment_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/payment/modules_payment.php b/htdocs/core/modules/payment/modules_payment.php index 0773204a1c8..b85c97008e3 100644 --- a/htdocs/core/modules/payment/modules_payment.php +++ b/htdocs/core/modules/payment/modules_payment.php @@ -33,7 +33,7 @@ abstract class ModeleNumRefPayments * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -43,7 +43,7 @@ abstract class ModeleNumRefPayments * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -55,7 +55,7 @@ abstract class ModeleNumRefPayments * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -67,7 +67,7 @@ abstract class ModeleNumRefPayments * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -79,7 +79,7 @@ abstract class ModeleNumRefPayments * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -90,15 +90,15 @@ abstract class ModeleNumRefPayments * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); } } diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index f4c10aa5952..3bbf1c879ea 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -47,7 +47,7 @@ class PrintingDriver * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -59,7 +59,7 @@ class PrintingDriver * @param integer $maxfilenamelength Max length of value to show * @return array List of drivers */ - static function listDrivers($db, $maxfilenamelength = 0) + public static function listDrivers($db, $maxfilenamelength = 0) { global $conf; @@ -80,7 +80,7 @@ class PrintingDriver * * @return string Return translation of key PrintingModuleDescXXX where XXX is module name, or $this->desc if not exists */ - function getDesc() + public function getDesc() { global $langs; $langs->load("printing"); diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index d061fc33b7d..b8bccf0280b 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -70,7 +70,7 @@ class printing_printgcp extends PrintingDriver * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $dolibarr_main_url_root; @@ -89,47 +89,47 @@ class printing_printgcp extends PrintingDriver ); } else { - $this->google_id = $conf->global->OAUTH_GOOGLE_ID; - $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; - // Token storage - $storage = new DoliStorage($this->db, $this->conf); - //$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE); - // Setup the credentials for the requests + $this->google_id = $conf->global->OAUTH_GOOGLE_ID; + $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; + // Token storage + $storage = new DoliStorage($this->db, $this->conf); + //$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE); + // Setup the credentials for the requests $credentials = new Credentials( - $this->google_id, - $this->google_secret, - $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' - ); - $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken'); - $serviceFactory = new \OAuth\ServiceFactory(); - $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); - $token_ok=true; - try { - $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $token_ok = false; - } - //var_dump($this->errors);exit; + $this->google_id, + $this->google_secret, + $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' + ); + $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken'); + $serviceFactory = new \OAuth\ServiceFactory(); + $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); + $token_ok=true; + try { + $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $token_ok = false; + } + //var_dump($this->errors);exit; - $expire = false; - // Is token expired or will token expire in the next 30 seconds - if ($token_ok) { - $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); - } + $expire = false; + // Is token expired or will token expire in the next 30 seconds + if ($token_ok) { + $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); + } - // Token expired so we refresh it - if ($token_ok && $expire) { - try { - // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois - $refreshtoken = $token->getRefreshToken(); - $token = $apiService->refreshAccessToken($token); - $token->setRefreshToken($refreshtoken); - $storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } + // Token expired so we refresh it + if ($token_ok && $expire) { + try { + // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois + $refreshtoken = $token->getRefreshToken(); + $token = $apiService->refreshAccessToken($token); + $token->setRefreshToken($refreshtoken); + $storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } if ($this->google_id != '' && $this->google_secret != '') { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); $this->conf[] = array( diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index af650b1695e..f5ebbdd53de 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -62,7 +62,7 @@ class printing_printipp extends PrintingDriver * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -152,7 +152,7 @@ class printing_printipp extends PrintingDriver * * @return int 0 if OK, >0 if KO */ - function listAvailablePrinters() + public function listAvailablePrinters() { global $conf, $langs; $error = 0; diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index fab88a91bfd..e178d16d5bc 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -41,12 +41,12 @@ class pdf_standardlabel extends CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - function addSticker(&$pdf, $outputlangs, $param) + public function addSticker(&$pdf, $outputlangs, $param) { // use this method in future refactoring } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) * - %LOGO% is replace with company logo @@ -61,7 +61,7 @@ class pdf_standardlabel extends CommonStickerGenerator * @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text) * @return void */ - function Add_PDF_label(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $photo = '') + public function Add_PDF_label(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $photo = '') { // phpcs:enable global $mysoc, $conf, $langs; @@ -227,7 +227,7 @@ class pdf_standardlabel extends CommonStickerGenerator - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP strem. * @@ -238,7 +238,7 @@ class pdf_standardlabel extends CommonStickerGenerator * @param string $filename Short file name of PDF output file * @return int 1=OK, 0=KO */ - function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf') + public function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf') { // phpcs:enable global $user,$conf,$langs,$mysoc,$_Avery_Labels; diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index f6641d1365d..7670a623c49 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -96,7 +96,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - function addSticker(&$pdf, $outputlangs, $param) + public function addSticker(&$pdf, $outputlangs, $param) { global $mysoc,$conf; @@ -266,7 +266,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP strem. * @@ -277,7 +277,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator * @param string $filename Short file name of PDF output file * @return int 1=OK, 0=KO */ - function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf') + public function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf') { // phpcs:enable global $user,$conf,$langs,$mysoc,$_Avery_Labels; diff --git a/htdocs/core/modules/printsheet/modules_labels.php b/htdocs/core/modules/printsheet/modules_labels.php index b64d2a4dfe3..7377c56aa3b 100644 --- a/htdocs/core/modules/printsheet/modules_labels.php +++ b/htdocs/core/modules/printsheet/modules_labels.php @@ -40,7 +40,7 @@ class ModelePDFLabels public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ class ModelePDFLabels * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - function liste_modeles($db, $maxfilenamelength = 0) + public function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 048c0e06846..edb54b13ace 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -61,7 +61,7 @@ class doc_generic_product_odt extends ModelePDFProduct * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -101,12 +101,12 @@ class doc_generic_product_odt extends ModelePDFProduct /** - * Return description of a module + * Return description of a module * - * @param Translate $langs Lang object to use for output - * @return string Description + * @param Translate $langs Lang object to use for output + * @return string Description */ - function info($langs) + public function info($langs) { global $conf, $langs; @@ -205,7 +205,7 @@ class doc_generic_product_odt extends ModelePDFProduct return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -217,7 +217,7 @@ class doc_generic_product_odt extends ModelePDFProduct * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $product,$langs,$conf,$mysoc,$hookmanager,$user; @@ -320,8 +320,8 @@ class doc_generic_product_odt extends ModelePDFProduct $contactobject=null; if (! empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index d5bfd453322..b8b05410fb1 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -148,7 +148,7 @@ class pdf_standard extends ModelePDFProduct } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -160,8 +160,8 @@ class pdf_standard extends ModelePDFProduct * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager; @@ -204,7 +204,7 @@ class pdf_standard extends ModelePDFProduct if (file_exists($dir)) { - // Add pdfgeneration hook + // Add pdfgeneration hook if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; @@ -592,7 +592,7 @@ class pdf_standard extends ModelePDFProduct $this->error=$langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR"); return 0; } - } + } /** @@ -608,7 +608,7 @@ class pdf_standard extends ModelePDFProduct * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -718,7 +718,7 @@ class pdf_standard extends ModelePDFProduct * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { global $conf,$langs,$hookmanager; @@ -853,24 +853,24 @@ class pdf_standard extends ModelePDFProduct $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); */ - } + } - $pdf->SetTextColor(0, 0, 0); - } + $pdf->SetTextColor(0, 0, 0); + } - /** - * Show footer of page. Need this->emetteur object - * - * @param TCPDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text - */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } } diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index 8d48d4aa85e..97a00a14575 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -72,7 +72,7 @@ class mod_codeproduct_elephant extends ModeleProductCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 0; $this->code_modifiable = 1; @@ -83,13 +83,14 @@ class mod_codeproduct_elephant extends ModeleProductCode } - /** Return description of module - * - * @param Translate $langs Object langs - * @return string Description of module - */ - function info($langs) - { + /** + * Return description of module + * + * @param Translate $langs Object langs + * @return string Description of module + */ + public function info($langs) + { global $conf, $mc; global $form; @@ -127,7 +128,7 @@ class mod_codeproduct_elephant extends ModeleProductCode $texte.= ''; return $texte; - } + } /** @@ -138,7 +139,7 @@ class mod_codeproduct_elephant extends ModeleProductCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - function getExample($langs, $objproduct = 0, $type = -1) + public function getExample($langs, $objproduct = 0, $type = -1) { if ($type == 0 || $type == -1) { @@ -179,7 +180,7 @@ class mod_codeproduct_elephant extends ModeleProductCode * @param int $type Produit ou service (0:product, 1:service) * @return string Value if OK, '' if module not configured, <0 if KO */ - function getNextValue($objproduct = 0, $type = -1) + public function getNextValue($objproduct = 0, $type = -1) { global $db,$conf; @@ -219,13 +220,13 @@ class mod_codeproduct_elephant extends ModeleProductCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if mask/numbering use prefix * * @return int 0 or 1 */ - function verif_prefixIsUsed() + public function verif_prefixIsUsed() { // phpcs:enable global $conf; @@ -254,7 +255,7 @@ class mod_codeproduct_elephant extends ModeleProductCode * -4 ErrorPrefixRequired * -5 Other (see this->error) */ - function verif($db, &$code, $product, $type) + public function verif($db, &$code, $product, $type) { global $conf; @@ -296,16 +297,16 @@ class mod_codeproduct_elephant extends ModeleProductCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi si un code est pris ou non (par autre tiers) + * Renvoi si un code est pris ou non (par autre tiers) * - * @param DoliDB $db Handler acces base - * @param string $code Code a verifier - * @param Product $product Objet product - * @return int 0 if available, <0 if KO + * @param DoliDB $db Handler acces base + * @param string $code Code a verifier + * @param Product $product Objet product + * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $product) + public function verif_dispo($db, $code, $product) { // phpcs:enable $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; diff --git a/htdocs/core/modules/product/mod_codeproduct_leopard.php b/htdocs/core/modules/product/mod_codeproduct_leopard.php index 1cf17fef6e7..a7b03eed2f0 100644 --- a/htdocs/core/modules/product/mod_codeproduct_leopard.php +++ b/htdocs/core/modules/product/mod_codeproduct_leopard.php @@ -71,7 +71,7 @@ class mod_codeproduct_leopard extends ModeleProductCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 1; $this->code_modifiable = 1; @@ -81,12 +81,13 @@ class mod_codeproduct_leopard extends ModeleProductCode } - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { $langs->load("companies"); return $langs->trans("LeopardNumRefModelDesc"); @@ -100,7 +101,7 @@ class mod_codeproduct_leopard extends ModeleProductCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return next value */ - function getNextValue($objproduct = 0, $type = -1) + public function getNextValue($objproduct = 0, $type = -1) { global $langs; return ''; @@ -108,19 +109,19 @@ class mod_codeproduct_leopard extends ModeleProductCode /** - * Check validity of code according to its rules + * Check validity of code according to its rules * - * @param DoliDB $db Database handler - * @param string $code Code to check/correct - * @param Product $product Object product + * @param DoliDB $db Database handler + * @param string $code Code to check/correct + * @param Product $product Object product * @param int $type 0 = product , 1 = service - * @return int 0 if OK - * -1 ErrorBadProductCodeSyntax - * -2 ErrorProductCodeRequired - * -3 ErrorProductCodeAlreadyUsed - * -4 ErrorPrefixRequired + * @return int 0 if OK + * -1 ErrorBadProductCodeSyntax + * -2 ErrorProductCodeRequired + * -3 ErrorProductCodeAlreadyUsed + * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $type) + public function verif($db, &$code, $product, $type) { global $conf; @@ -131,7 +132,7 @@ class mod_codeproduct_leopard extends ModeleProductCode { $result=0; } - elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) + elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) { $result=-2; } diff --git a/htdocs/core/modules/product/modules_product.class.php b/htdocs/core/modules/product/modules_product.class.php index c0f83c1eace..30350d9378f 100644 --- a/htdocs/core/modules/product/modules_product.class.php +++ b/htdocs/core/modules/product/modules_product.class.php @@ -33,13 +33,13 @@ */ abstract class ModelePDFProduct extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -47,33 +47,33 @@ abstract class ModelePDFProduct extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) - { + public static function liste_modeles($db, $maxfilenamelength = 0) + { // phpcs:enable - global $conf; + global $conf; - $type='product'; - $liste=array(); + $type='product'; + $liste=array(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $liste=getListOfModels($db, $type, $maxfilenamelength); - return $liste; - } + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db, $type, $maxfilenamelength); + return $liste; + } } abstract class ModeleProductCode { /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; /** Renvoi la description par defaut du modele de numerotation * * @param Translate $langs Object langs * @return string Texte descripif */ - function info($langs) + public function info($langs) { $langs->load("bills"); return $langs->trans("NoDescription"); @@ -84,7 +84,7 @@ abstract class ModeleProductCode * @param Translate $langs Object langs * @return string Nom du module */ - function getNom($langs) + public function getNom($langs) { return empty($this->name)?$this->nom:$this->name; } @@ -95,7 +95,7 @@ abstract class ModeleProductCode * @param Translate $langs Object langs * @return string Example */ - function getExample($langs) + public function getExample($langs) { $langs->load("bills"); return $langs->trans("NoExample"); @@ -106,7 +106,7 @@ abstract class ModeleProductCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -118,7 +118,7 @@ abstract class ModeleProductCode * @param int $type Type * @return string Value */ - function getNextValue($objproduct = 0, $type = -1) + public function getNextValue($objproduct = 0, $type = -1) { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); @@ -129,7 +129,7 @@ abstract class ModeleProductCode * * @return string Version */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -141,7 +141,7 @@ abstract class ModeleProductCode return $langs->trans("NotAvailable"); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi la liste des modeles de numérotation * @@ -149,7 +149,7 @@ abstract class ModeleProductCode * @param integer $maxfilenamelength Max length of value to show * @return array List of numbers */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable $liste=array(); @@ -175,22 +175,24 @@ abstract class ModeleProductCode } /** - * Return description of module parameters + * Return description of module parameters * - * @param Translate $langs Output language - * @param Product $product Product object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier - * @return string HTML translated description + * @param Translate $langs Output language + * @param Product $product Product object + * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @return string HTML translated description */ - function getToolTip($langs, $product, $type) + public function getToolTip($langs, $product, $type) { global $conf; $langs->load("admin"); $s=''; - if ($type == -1) $s.=$langs->trans("Name").': '.$this->getNom($langs).'
'; - if ($type == -1) $s.=$langs->trans("Version").': '.$this->getVersion().'
'; + if ($type == -1) { + $s.=$langs->trans("Name").': '.$this->getNom($langs).'
'; + $s.=$langs->trans("Version").': '.$this->getVersion().'
'; + } if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'
'; if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'
'; if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': '.$this->getNom($langs).'
'; @@ -241,13 +243,13 @@ abstract class ModeleProductCode return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Check if mask/numbering use prefix - * - * @return int 0=no, 1=yes - */ - function verif_prefixIsUsed() + * Check if mask/numbering use prefix + * + * @return int 0=no, 1=yes + */ + public function verif_prefixIsUsed() { // phpcs:enable return 0; diff --git a/htdocs/core/modules/product_batch/modules_product_batch.class.php b/htdocs/core/modules/product_batch/modules_product_batch.class.php index 5708033a8ea..38cd9dda385 100644 --- a/htdocs/core/modules/product_batch/modules_product_batch.class.php +++ b/htdocs/core/modules/product_batch/modules_product_batch.class.php @@ -38,30 +38,30 @@ */ abstract class ModelePDFProductBatch extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error=''; - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return list of active generation modules - * + * @var string Error code (or message) + */ + public $error=''; + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * * @param DoliDB $db Database handler * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) - { + public static function liste_modeles($db, $maxfilenamelength = 0) + { // phpcs:enable - global $conf; + global $conf; - $type='product_batch'; - $list = array(); + $type = 'product_batch'; + $list = array(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $list = getListOfModels($db, $type, $maxfilenamelength); - return $list; - } + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $list = getListOfModels($db, $type, $maxfilenamelength); + return $list; + } } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index e1c54a13a35..b925a29327c 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -78,7 +78,7 @@ class doc_generic_project_odt extends ModelePDFProjects * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -117,7 +117,7 @@ class doc_generic_project_odt extends ModelePDFProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -126,7 +126,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param string $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -156,7 +156,7 @@ class doc_generic_project_odt extends ModelePDFProjects return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -164,7 +164,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_tasks(Task $task, $outputlangs) + public function get_substitutionarray_tasks(Task $task, $outputlangs) { // phpcs:enable global $conf; @@ -197,7 +197,7 @@ class doc_generic_project_odt extends ModelePDFProjects return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -205,7 +205,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_contacts($contact, $outputlangs) + public function get_substitutionarray_project_contacts($contact, $outputlangs) { // phpcs:enable global $conf; @@ -255,7 +255,7 @@ class doc_generic_project_odt extends ModelePDFProjects return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -263,19 +263,19 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_file($file, $outputlangs) - { + public function get_substitutionarray_project_file($file, $outputlangs) + { // phpcs:enable - global $conf; + global $conf; - return array( - 'projfile_name'=>$file['name'], - 'projfile_date'=>dol_print_date($file['date'], 'day'), - 'projfile_size'=>$file['size'] - ); - } + return array( + 'projfile_name'=>$file['name'], + 'projfile_date'=>dol_print_date($file['date'], 'day'), + 'projfile_size'=>$file['size'] + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -283,23 +283,23 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_reference($refdetail, $outputlangs) - { + public function get_substitutionarray_project_reference($refdetail, $outputlangs) + { // phpcs:enable - global $conf; + global $conf; - return array( - 'projref_type'=>$refdetail['type'], - 'projref_ref'=>$refdetail['ref'], - 'projref_date'=>dol_print_date($refdetail['date'], 'day'), - 'projref_socname'=>$refdetail['socname'], - 'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs), - 'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs), - 'projref_status'=>$refdetail['status'] - ); - } + return array( + 'projref_type'=>$refdetail['type'], + 'projref_ref'=>$refdetail['ref'], + 'projref_date'=>dol_print_date($refdetail['date'], 'day'), + 'projref_socname'=>$refdetail['socname'], + 'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs), + 'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs), + 'projref_status'=>$refdetail['status'] + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -307,7 +307,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_tasksressource($taskressource, $outputlangs) + public function get_substitutionarray_tasksressource($taskressource, $outputlangs) { // phpcs:enable global $conf; @@ -323,7 +323,7 @@ class doc_generic_project_odt extends ModelePDFProjects ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -331,7 +331,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_taskstime($tasktime, $outputlangs) + public function get_substitutionarray_taskstime($tasktime, $outputlangs) { // phpcs:enable global $conf; @@ -352,7 +352,7 @@ class doc_generic_project_odt extends ModelePDFProjects ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -360,7 +360,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_task_file($file, $outputlangs) + public function get_substitutionarray_task_file($file, $outputlangs) { // phpcs:enable global $conf; @@ -379,7 +379,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -462,7 +462,7 @@ class doc_generic_project_odt extends ModelePDFProjects return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -471,7 +471,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param string $srctemplatepath Full path of source filename for generator using a template file * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath) + public function write_file($object, $outputlangs, $srctemplatepath) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -588,7 +588,7 @@ class doc_generic_project_odt extends ModelePDFProjects // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->projet->dir_temp, diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 8b05da32e37..e5f5e9a9654 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -116,7 +116,7 @@ class pdf_baleine extends ModelePDFProjects * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -165,7 +165,7 @@ class pdf_baleine extends ModelePDFProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -173,7 +173,7 @@ class pdf_baleine extends ModelePDFProjects * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs) + public function write_file($object, $outputlangs) { // phpcs:enable global $conf, $hookmanager, $langs, $user; @@ -533,7 +533,7 @@ class pdf_baleine extends ModelePDFProjects * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -580,7 +580,7 @@ class pdf_baleine extends ModelePDFProjects * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -665,15 +665,15 @@ class pdf_baleine extends ModelePDFProjects } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Project $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return integer + * @param PDF $pdf PDF + * @param Project $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 8f9c9932389..f24f400f2af 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2018 Charlene Benke - * Copyright (C) 2018 Laurent Destailleur +/* Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2015-2018 Charlene Benke + * Copyright (C) 2018 Laurent Destailleur * * 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 @@ -65,7 +65,7 @@ class pdf_beluga extends ModelePDFProjects * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -114,7 +114,7 @@ class pdf_beluga extends ModelePDFProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -122,7 +122,7 @@ class pdf_beluga extends ModelePDFProjects * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs) + public function write_file($object, $outputlangs) { // phpcs:enable global $conf, $hookmanager, $langs, $user; @@ -685,7 +685,7 @@ class pdf_beluga extends ModelePDFProjects * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -732,7 +732,7 @@ class pdf_beluga extends ModelePDFProjects * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -793,15 +793,15 @@ class pdf_beluga extends ModelePDFProjects } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Project $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return integer + * @param PDF $pdf PDF + * @param Project $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 047f1cf946f..1846e556b1e 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -48,7 +48,7 @@ class pdf_timespent extends ModelePDFProjects * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -97,7 +97,7 @@ class pdf_timespent extends ModelePDFProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -105,7 +105,7 @@ class pdf_timespent extends ModelePDFProjects * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs) + public function write_file($object, $outputlangs) { // phpcs:enable global $conf, $hookmanager, $langs, $user; @@ -464,7 +464,7 @@ class pdf_timespent extends ModelePDFProjects * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -511,7 +511,7 @@ class pdf_timespent extends ModelePDFProjects * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -595,19 +595,19 @@ class pdf_timespent extends ModelePDFProjects */ } - /** - * Show footer of page. Need this->emetteur object + /** + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Project $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return integer - */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + * @param PDF $pdf PDF + * @param Project $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return integer + */ + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } } diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 68d0feaf2dc..25553fb19c9 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -62,7 +62,7 @@ class mod_project_simple extends ModeleNumRefProjects * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_project_simple extends ModeleNumRefProjects * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -85,7 +85,7 @@ class mod_project_simple extends ModeleNumRefProjects * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -122,7 +122,7 @@ class mod_project_simple extends ModeleNumRefProjects * @param Project $project Object project * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $project) + public function getNextValue($objsoc, $project) { global $db,$conf; @@ -159,7 +159,7 @@ class mod_project_simple extends ModeleNumRefProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next reference not yet used as a reference * @@ -167,7 +167,7 @@ class mod_project_simple extends ModeleNumRefProjects * @param Project $project Object project * @return string Next not used reference */ - function project_get_num($objsoc = 0, $project = '') + public function project_get_num($objsoc = 0, $project = '') { // phpcs:enable return $this->getNextValue($objsoc, $project); diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 7d2d3665582..f987d4d3b32 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -59,7 +59,7 @@ class mod_project_universal extends ModeleNumRefProjects * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -100,7 +100,7 @@ class mod_project_universal extends ModeleNumRefProjects * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -123,7 +123,7 @@ class mod_project_universal extends ModeleNumRefProjects * @param Project $project Object project * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $project) + public function getNextValue($objsoc, $project) { global $db,$conf; @@ -145,7 +145,7 @@ class mod_project_universal extends ModeleNumRefProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next reference not yet used as a reference * @@ -153,7 +153,7 @@ class mod_project_universal extends ModeleNumRefProjects * @param Project $project Object project * @return string Next not used reference */ - function project_get_num($objsoc = 0, $project = '') + public function project_get_num($objsoc = 0, $project = '') { // phpcs:enable return $this->getNextValue($objsoc, $project); diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index 65a424941b8..f77111bade3 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -37,7 +37,7 @@ abstract class ModelePDFProjects extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -45,7 +45,7 @@ abstract class ModelePDFProjects extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -77,7 +77,7 @@ abstract class ModeleNumRefProjects * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -87,7 +87,7 @@ abstract class ModeleNumRefProjects * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("projects"); @@ -99,7 +99,7 @@ abstract class ModeleNumRefProjects * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("projects"); @@ -112,7 +112,7 @@ abstract class ModeleNumRefProjects * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -124,7 +124,7 @@ abstract class ModeleNumRefProjects * @param Project $project Object project * @return string Valeur */ - function getNextValue($objsoc, $project) + public function getNextValue($objsoc, $project) { global $langs; return $langs->trans("NotAvailable"); @@ -135,15 +135,15 @@ abstract class ModeleNumRefProjects * * @return string Valeur */ - function getVersion() - { + public function getVersion() + { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); - } + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); + } } diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index fefaefc426c..151d800f04d 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -62,7 +62,7 @@ class doc_generic_task_odt extends ModelePDFTask public $emetteur; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -79,7 +79,7 @@ class doc_generic_task_odt extends ModelePDFTask * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -118,7 +118,7 @@ class doc_generic_task_odt extends ModelePDFTask } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -127,7 +127,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param string $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -163,7 +163,7 @@ class doc_generic_task_odt extends ModelePDFTask return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -171,30 +171,30 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_tasks($task, $outputlangs) - { + public function get_substitutionarray_tasks($task, $outputlangs) + { // phpcs:enable - global $conf; + global $conf; - return array( - 'task_ref'=>$task->ref, - 'task_fk_project'=>$task->fk_project, - 'task_projectref'=>$task->projectref, - 'task_projectlabel'=>$task->projectlabel, - 'task_label'=>$task->label, - 'task_description'=>$task->description, - 'task_fk_parent'=>$task->fk_parent, - 'task_duration'=>$task->duration, - 'task_progress'=>$task->progress, - 'task_public'=>$task->public, - 'task_date_start'=>dol_print_date($task->date_start, 'day'), - 'task_date_end'=>dol_print_date($task->date_end, 'day'), - 'task_note_private'=>$task->note_private, - 'task_note_public'=>$task->note_public - ); - } + return array( + 'task_ref'=>$task->ref, + 'task_fk_project'=>$task->fk_project, + 'task_projectref'=>$task->projectref, + 'task_projectlabel'=>$task->projectlabel, + 'task_label'=>$task->label, + 'task_description'=>$task->description, + 'task_fk_parent'=>$task->fk_parent, + 'task_duration'=>$task->duration, + 'task_progress'=>$task->progress, + 'task_public'=>$task->public, + 'task_date_start'=>dol_print_date($task->date_start, 'day'), + 'task_date_end'=>dol_print_date($task->date_end, 'day'), + 'task_note_private'=>$task->note_private, + 'task_note_public'=>$task->note_public + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -202,7 +202,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_contacts($contact, $outputlangs) + public function get_substitutionarray_project_contacts($contact, $outputlangs) { // phpcs:enable global $conf; @@ -219,7 +219,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -227,7 +227,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_file($file, $outputlangs) + public function get_substitutionarray_project_file($file, $outputlangs) { // phpcs:enable global $conf; @@ -239,7 +239,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -247,7 +247,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_reference($refdetail, $outputlangs) + public function get_substitutionarray_project_reference($refdetail, $outputlangs) { // phpcs:enable global $conf; @@ -263,7 +263,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -271,7 +271,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_tasksressource($taskressource, $outputlangs) + public function get_substitutionarray_tasksressource($taskressource, $outputlangs) { // phpcs:enable global $conf; @@ -287,7 +287,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -295,7 +295,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_taskstime($tasktime, $outputlangs) + public function get_substitutionarray_taskstime($tasktime, $outputlangs) { // phpcs:enable global $conf; @@ -312,7 +312,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -320,7 +320,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_task_file($file, $outputlangs) + public function get_substitutionarray_task_file($file, $outputlangs) { // phpcs:enable global $conf; @@ -339,7 +339,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -422,7 +422,7 @@ class doc_generic_task_odt extends ModelePDFTask return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -431,7 +431,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param string $srctemplatepath Full path of source filename for generator using a template file * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath) + public function write_file($object, $outputlangs, $srctemplatepath) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -515,7 +515,7 @@ class doc_generic_task_odt extends ModelePDFTask // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->projet->dir_temp, diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 47baf9e7d4c..4632fedec4a 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -62,7 +62,7 @@ class mod_task_simple extends ModeleNumRefTask * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_task_simple extends ModeleNumRefTask * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -85,7 +85,7 @@ class mod_task_simple extends ModeleNumRefTask * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -123,7 +123,7 @@ class mod_task_simple extends ModeleNumRefTask * @param Task $object Object Task * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -159,7 +159,7 @@ class mod_task_simple extends ModeleNumRefTask } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next reference not yet used as a reference * @@ -167,7 +167,7 @@ class mod_task_simple extends ModeleNumRefTask * @param Task $object Object task * @return string Next not used reference */ - function task_get_num($objsoc = 0, $object = '') + public function task_get_num($objsoc = 0, $object = '') { return $this->getNextValue($objsoc, $object); } diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index b92fe03ae3f..f1d295802a9 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -59,7 +59,7 @@ class mod_task_universal extends ModeleNumRefTask * * @return string Texte descripif */ - function info() + public function info() { global $conf,$langs; @@ -100,7 +100,7 @@ class mod_task_universal extends ModeleNumRefTask * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -123,7 +123,7 @@ class mod_task_universal extends ModeleNumRefTask * @param Task $object Object task * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -145,7 +145,7 @@ class mod_task_universal extends ModeleNumRefTask } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next reference not yet used as a reference * @@ -153,7 +153,7 @@ class mod_task_universal extends ModeleNumRefTask * @param Task $object Object task * @return string Next not used reference */ - function project_get_num($objsoc = 0, $object = '') + public function project_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/project/task/modules_task.php b/htdocs/core/modules/project/task/modules_task.php index 3e1b00fcf47..e37c4b1dabb 100644 --- a/htdocs/core/modules/project/task/modules_task.php +++ b/htdocs/core/modules/project/task/modules_task.php @@ -38,7 +38,7 @@ abstract class ModelePDFTask extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -46,7 +46,7 @@ abstract class ModelePDFTask extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -78,7 +78,7 @@ abstract class ModeleNumRefTask * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -88,7 +88,7 @@ abstract class ModeleNumRefTask * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("projects"); @@ -100,7 +100,7 @@ abstract class ModeleNumRefTask * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("projects"); @@ -113,7 +113,7 @@ abstract class ModeleNumRefTask * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -125,7 +125,7 @@ abstract class ModeleNumRefTask * @param Project $project Object project * @return string Valeur */ - function getNextValue($objsoc, $project) + public function getNextValue($objsoc, $project) { global $langs; return $langs->trans("NotAvailable"); @@ -136,7 +136,7 @@ abstract class ModeleNumRefTask * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 4af8e8d1e32..d303e52d734 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -60,7 +60,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -105,7 +105,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -219,7 +219,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -231,7 +231,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index fd254490ec1..24fe36b3213 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -125,7 +125,7 @@ class pdf_azur extends ModelePDFPropales * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -202,7 +202,7 @@ class pdf_azur extends ModelePDFPropales $this->atleastonediscount=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -214,7 +214,7 @@ class pdf_azur extends ModelePDFPropales * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; @@ -837,7 +837,7 @@ class pdf_azur extends ModelePDFPropales } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -847,13 +847,13 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -863,7 +863,7 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -1034,7 +1034,7 @@ class pdf_azur extends ModelePDFPropales } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -1045,7 +1045,7 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1323,7 +1323,7 @@ class pdf_azur extends ModelePDFPropales * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1442,7 +1442,7 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; @@ -1665,14 +1665,14 @@ class pdf_azur extends ModelePDFPropales * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show area for the customer to sign * @@ -1682,7 +1682,7 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _signature_area(&$pdf, $object, $posy, $outputlangs) + private function _signature_area(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 936309fb6d8..668693e67cc 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -903,7 +903,7 @@ class pdf_cyan extends ModelePDFPropales * @param Translate $outputlangs Langs object * @return void */ - function drawInfoTable(&$pdf, $object, $posy, $outputlangs) + public function drawInfoTable(&$pdf, $object, $posy, $outputlangs) { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1360,7 +1360,7 @@ class pdf_cyan extends ModelePDFPropales * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1427,7 +1427,7 @@ class pdf_cyan extends ModelePDFPropales * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; @@ -1652,7 +1652,7 @@ class pdf_cyan extends ModelePDFPropales * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; @@ -1705,7 +1705,7 @@ class pdf_cyan extends ModelePDFPropales * @param int $hideref Do not show ref * @return null */ - function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $conf, $hookmanager; diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index abbc4df42b6..0e03574a3d4 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -62,7 +62,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -86,7 +86,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -124,7 +124,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * @param Propal $propal Object commercial proposal * @return string Next value */ - function getNextValue($objsoc, $propal) + public function getNextValue($objsoc, $propal) { global $db,$conf; @@ -165,7 +165,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * @param Object $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index f30ef4e48d1..972bb94cb64 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -62,7 +62,7 @@ class mod_propale_saphir extends ModeleNumRefPropales * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -102,7 +102,7 @@ class mod_propale_saphir extends ModeleNumRefPropales * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -128,7 +128,7 @@ class mod_propale_saphir extends ModeleNumRefPropales * @param Propal $propal Object commercial proposal * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $propal) + public function getNextValue($objsoc, $propal) { global $db,$conf; diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index cb4e253fc09..dc01941ece4 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -42,7 +42,7 @@ abstract class ModelePDFPropales extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -50,7 +50,7 @@ abstract class ModelePDFPropales extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -81,7 +81,7 @@ abstract class ModeleNumRefPropales * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -91,7 +91,7 @@ abstract class ModeleNumRefPropales * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("propale"); @@ -103,7 +103,7 @@ abstract class ModeleNumRefPropales * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("propale"); @@ -116,7 +116,7 @@ abstract class ModeleNumRefPropales * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ abstract class ModeleNumRefPropales * @param Propal $propal Object commercial proposal * @return string Valeur */ - function getNextValue($objsoc, $propal) + public function getNextValue($objsoc, $propal) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ abstract class ModeleNumRefPropales * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 15682551670..127c7a92352 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -37,7 +37,7 @@ class pdf_paiement * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; @@ -83,7 +83,7 @@ class pdf_paiement } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant la rapport sur le disque * @@ -93,7 +93,7 @@ class pdf_paiement * @param string $outputlangs Lang output object * @return int <0 if KO, >0 if OK */ - function write_file($_dir, $month, $year, $outputlangs) + public function write_file($_dir, $month, $year, $outputlangs) { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -125,7 +125,7 @@ class pdf_paiement $year = sprintf("%04d", $year); $file = $dir . "/payments-".$year."-".$month.".pdf"; - switch ($this->doc_type) { + switch ($this->doc_type) { case "client": $file = $dir . "/payments-".$year."-".$month.".pdf"; break; @@ -159,9 +159,9 @@ class pdf_paiement $num=0; $lines=array(); - // count number of lines of payment - $sql = "SELECT p.rowid as prowid"; - switch ($this->doc_type) { + // count number of lines of payment + $sql = "SELECT p.rowid as prowid"; + switch ($this->doc_type) { case "client": $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p"; break; @@ -340,6 +340,7 @@ class pdf_paiement return 1; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Show top header of page. * @@ -349,8 +350,9 @@ class pdf_paiement * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $page, $showaddress, $outputlangs) + protected function _pagehead(&$pdf, $page, $showaddress, $outputlangs) { + // phpcs:enable global $langs, $conf; // Do not add the BACKGROUND as this is a report @@ -359,7 +361,7 @@ class pdf_paiement $default_font_size = pdf_getPDFFontSize($outputlangs); $title=$conf->global->MAIN_INFO_SOCIETE_NOM; - switch($this->doc_type) { + switch($this->doc_type) { case "client": $title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments"); break; @@ -412,7 +414,7 @@ class pdf_paiement } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output body * @@ -422,7 +424,7 @@ class pdf_paiement * @param Translate $outputlangs Object langs * @return void */ - function Body(&$pdf, $page, $lines, $outputlangs) + public function Body(&$pdf, $page, $lines, $outputlangs) { // phpcs:enable global $langs; diff --git a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php index 0b823e0419e..b25b979783e 100644 --- a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php @@ -35,7 +35,7 @@ class pdf_paiement_fourn extends pdf_paiement * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { parent::__construct($db); $this->doc_type = "fourn"; diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index fdd2a92d15b..4854af7bfac 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -58,8 +58,8 @@ class doc_generic_reception_odt extends ModelePdfReception * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $conf,$langs,$mysoc; $langs->load("main"); @@ -94,18 +94,18 @@ class doc_generic_reception_odt extends ModelePdfReception // Recupere emetteur $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - } + } - /** - * Return description of a module - * - * @param Translate $langs Lang object to use for output - * @return string Description - */ - function info($langs) - { - global $conf,$langs; + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + public function info($langs) + { + global $conf,$langs; $langs->load("companies"); $langs->load("errors"); @@ -183,22 +183,22 @@ class doc_generic_reception_odt extends ModelePdfReception $texte.= ''; return $texte; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * - * @param Reception $object Object source to build document - * @param Translate $outputlangs Lang output object + * @param Reception $object Object source to build document + * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 9a4c3b2010d..dec1f35e7b0 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_squille extends ModelePdfReception { - var $emetteur; // Objet societe qui emet + public $emetteur; // Objet societe qui emet /** @@ -40,7 +40,7 @@ class pdf_squille extends ModelePdfReception * * @param DoliDB $db Database handler */ - function __construct($db = 0) + public function __construct($db = 0) { global $conf,$langs,$mysoc; @@ -98,7 +98,7 @@ class pdf_squille extends ModelePdfReception } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -110,7 +110,7 @@ class pdf_squille extends ModelePdfReception * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$conf,$langs,$hookmanager; @@ -592,7 +592,7 @@ class pdf_squille extends ModelePdfReception } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -604,7 +604,7 @@ class pdf_squille extends ModelePdfReception * @param int $totalOrdered Total ordered * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) { // phpcs:enable global $conf,$mysoc; @@ -707,7 +707,7 @@ class pdf_squille extends ModelePdfReception * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf; @@ -786,7 +786,7 @@ class pdf_squille extends ModelePdfReception * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs,$mysoc; @@ -1037,7 +1037,7 @@ class pdf_squille extends ModelePdfReception * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index 7624ec5cec0..09b3fbfb1f5 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -28,10 +28,10 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php'; */ class mod_reception_beryl extends ModelNumRefReception { - var $version='dolibarr'; - var $prefix='RCP'; - var $error=''; - var $nom='Beryl'; + public $version='dolibarr'; + public $prefix='RCP'; + public $error=''; + public $nom='Beryl'; /** @@ -39,7 +39,7 @@ class mod_reception_beryl extends ModelNumRefReception * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -51,7 +51,7 @@ class mod_reception_beryl extends ModelNumRefReception * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -62,7 +62,7 @@ class mod_reception_beryl extends ModelNumRefReception * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -97,7 +97,7 @@ class mod_reception_beryl extends ModelNumRefReception * @param Object $shipment Shipment object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $db,$conf; @@ -130,7 +130,7 @@ class mod_reception_beryl extends ModelNumRefReception return $this->prefix.$yymm."-".$num; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -138,7 +138,7 @@ class mod_reception_beryl extends ModelNumRefReception * @param Object $objforref Shipment object * @return string Next free value */ - function reception_get_num($objsoc, $objforref) + public function reception_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php index bbf5443255a..6f7d66f8ef3 100644 --- a/htdocs/core/modules/reception/mod_reception_moonstone.php +++ b/htdocs/core/modules/reception/mod_reception_moonstone.php @@ -29,16 +29,16 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php'; */ class mod_reception_moonstone extends ModelNumRefReception { - var $version='dolibarr'; - var $error = ''; - var $nom = 'Moonstone'; + public $version='dolibarr'; + public $error = ''; + public $nom = 'Moonstone'; - /** - * Return default description of numbering model - * - * @return string text description - */ - function info() + /** + * Return default description of numbering model + * + * @return string text description + */ + public function info() { global $conf,$langs; @@ -74,7 +74,7 @@ class mod_reception_moonstone extends ModelNumRefReception * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -100,7 +100,7 @@ class mod_reception_moonstone extends ModelNumRefReception * @param Object $reception Reception object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $reception) + public function getNextValue($objsoc, $reception) { global $db,$conf; @@ -119,9 +119,9 @@ class mod_reception_moonstone extends ModelNumRefReception $numFinal=get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date); return $numFinal; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -129,7 +129,7 @@ class mod_reception_moonstone extends ModelNumRefReception * @param Object $objforref Reception object * @return string Next free value */ - function reception_get_num($objsoc, $objforref) + public function reception_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/reception/modules_reception.php b/htdocs/core/modules/reception/modules_reception.php index 62e2434d9ac..f258ce04d5c 100644 --- a/htdocs/core/modules/reception/modules_reception.php +++ b/htdocs/core/modules/reception/modules_reception.php @@ -32,7 +32,7 @@ abstract class ModelePdfReception extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -40,7 +40,7 @@ abstract class ModelePdfReception extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -61,13 +61,13 @@ abstract class ModelePdfReception extends CommonDocGenerator */ abstract class ModelNumRefReception { - var $error=''; + public $error=''; /** Return if a model can be used or not * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -77,7 +77,7 @@ abstract class ModelNumRefReception * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("reception"); @@ -89,7 +89,7 @@ abstract class ModelNumRefReception * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("reception"); @@ -101,7 +101,7 @@ abstract class ModelNumRefReception * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -113,7 +113,7 @@ abstract class ModelNumRefReception * @param Object $shipment Shipment object * @return string Value */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $langs; return $langs->trans("NotAvailable"); @@ -124,15 +124,15 @@ abstract class ModelNumRefReception * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; return $langs->trans("NotAvailable"); } } diff --git a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php index b0caa7d0b15..c9bdff46ece 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php @@ -56,7 +56,7 @@ class modGeneratePassNone extends ModeleGenPassword * @param Translate $langs Handler de langue * @param User $user Handler du user connecte */ - function __construct($db, $conf, $langs, $user) + public function __construct($db, $conf, $langs, $user) { $this->id = "none"; $this->length = 0; @@ -72,7 +72,7 @@ class modGeneratePassNone extends ModeleGenPassword * * @return string Description of text */ - function getDescription() + public function getDescription() { global $langs; return $langs->trans("PasswordGenerationNone"); @@ -83,7 +83,7 @@ class modGeneratePassNone extends ModeleGenPassword * * @return string Example of password */ - function getExample() + public function getExample() { return $this->langs->trans("None"); } @@ -93,7 +93,7 @@ class modGeneratePassNone extends ModeleGenPassword * * @return string Return a new generated password */ - function getNewGeneratedPassword() + public function getNewGeneratedPassword() { return ""; } @@ -104,7 +104,7 @@ class modGeneratePassNone extends ModeleGenPassword * @param string $password Password to check * @return int 0 if KO, >0 if OK */ - function validatePassword($password) + public function validatePassword($password) { return 1; } diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index 3e4ee4326d3..bccb1353087 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -70,7 +70,7 @@ class modGeneratePassPerso extends ModeleGenPassword * @param Translate $langs Handler de langue * @param User $user Handler du user connecte */ - function __construct($db, $conf, $langs, $user) + public function __construct($db, $conf, $langs, $user) { $this->id = "Perso"; $this->length = $langs->trans("SetupPerso"); @@ -120,7 +120,7 @@ class modGeneratePassPerso extends ModeleGenPassword * * @return string Description of text */ - function getDescription() + public function getDescription() { global $langs; return $langs->trans("PasswordGenerationPerso"); @@ -131,39 +131,42 @@ class modGeneratePassPerso extends ModeleGenPassword * * @return string Example of password */ - function getExample() + public function getExample() { return $this->getNewGeneratedPassword(); } /** - * Build new password + * Build new password * - * @return string Return a new generated password + * @return string Return a new generated password */ - function getNewGeneratedPassword() + public function getNewGeneratedPassword() { $pass = ""; - for($i=0; $i<$this->NbMaj; $i++){ // Y + for ($i=0; $i<$this->NbMaj; $i++) { + // Y $pass .= $this->Maj[mt_rand(0, strlen($this->Maj) - 1)]; } - for($i=0; $i<$this->NbNum; $i++){ // X + for ($i=0; $i<$this->NbNum; $i++) { + // X $pass .= $this->Nb[mt_rand(0, strlen($this->Nb) - 1)]; } - for($i=0; $i<$this->NbSpe; $i++){ // @ + for ($i=0; $i<$this->NbSpe; $i++) { + // @ $pass .= $this->Spe[mt_rand(0, strlen($this->Spe) - 1)]; } - for($i=strlen($pass);$i<$this->length2; $i++){ // y + for ($i=strlen($pass);$i<$this->length2; $i++) { + // y $pass .= $this->All[mt_rand(0, strlen($this->All) -1)]; } $pass = str_shuffle($pass); - if ($this->validatePassword($pass)) - { + if ($this->validatePassword($pass)) { return $pass; } @@ -171,31 +174,31 @@ class modGeneratePassPerso extends ModeleGenPassword } /** - * Validate a password + * Validate a password * - * @param string $password Password to check - * @return int 0 if KO, >0 if OK + * @param string $password Password to check + * @return int 0 if KO, >0 if OK */ - function validatePassword($password) + public function validatePassword($password) { $password_a = str_split($password); $maj = str_split($this->Maj); $num = str_split($this->Nb); $spe = str_split($this->Spe); - if(count(array_intersect($password_a, $maj)) < $this->NbMaj){ + if (count(array_intersect($password_a, $maj)) < $this->NbMaj) { return 0; } - if(count(array_intersect($password_a, $num)) < $this->NbNum){ + if (count(array_intersect($password_a, $num)) < $this->NbNum) { return 0; } - if(count(array_intersect($password_a, $spe)) < $this->NbSpe){ + if (count(array_intersect($password_a, $spe)) < $this->NbSpe) { return 0; } - if(!$this->consecutiveInterationSameCharacter($password)){ + if (!$this->consecutiveInterationSameCharacter($password)) { return 0; } @@ -203,25 +206,25 @@ class modGeneratePassPerso extends ModeleGenPassword } /** - * consecutive iterations of the same character + * consecutive iterations of the same character * - * @param string $password Password to check - * @return int 0 if KO, >0 if OK + * @param string $password Password to check + * @return int 0 if KO, >0 if OK */ - function consecutiveInterationSameCharacter($password) + public function consecutiveInterationSameCharacter($password) { $last = ""; $count = 0; $char = str_split($password); - foreach($char as $c){ - if($c != $last){ + foreach($char as $c) { + if($c != $last) { $last = $c; $count = 0; - }else{ + } else { $count++; } - if($count >= $this->NbRepeat) { + if ($count >= $this->NbRepeat) { return 0; } } diff --git a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php index 124ecf32321..88dc53e7e32 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php @@ -56,7 +56,7 @@ class modGeneratePassStandard extends ModeleGenPassword * @param Translate $langs Handler de langue * @param User $user Handler du user connecte */ - function __construct($db, $conf, $langs, $user) + public function __construct($db, $conf, $langs, $user) { $this->id = "standard"; $this->length = 8; @@ -72,7 +72,7 @@ class modGeneratePassStandard extends ModeleGenPassword * * @return string Description of module */ - function getDescription() + public function getDescription() { global $langs; return $langs->trans("PasswordGenerationStandard"); @@ -83,7 +83,7 @@ class modGeneratePassStandard extends ModeleGenPassword * * @return string Example of password */ - function getExample() + public function getExample() { return $this->getNewGeneratedPassword(); } @@ -93,7 +93,7 @@ class modGeneratePassStandard extends ModeleGenPassword * * @return string Return a new generated password */ - function getNewGeneratedPassword() + public function getNewGeneratedPassword() { // start with a blank password $password = ""; @@ -123,15 +123,15 @@ class modGeneratePassStandard extends ModeleGenPassword return $password; } - /** - * Validate a password - * - * @param string $password Password to check - * @return int 0 if KO, >0 if OK - */ - function validatePassword($password) - { - if (dol_strlen($password) < $this->length) return 0; - return 1; - } + /** + * Validate a password + * + * @param string $password Password to check + * @return int 0 if KO, >0 if OK + */ + public function validatePassword($password) + { + if (dol_strlen($password) < $this->length) return 0; + return 1; + } } diff --git a/htdocs/core/modules/security/generate/modules_genpassword.php b/htdocs/core/modules/security/generate/modules_genpassword.php index a22d19e0845..5515a298379 100644 --- a/htdocs/core/modules/security/generate/modules_genpassword.php +++ b/htdocs/core/modules/security/generate/modules_genpassword.php @@ -40,7 +40,7 @@ abstract class ModeleGenPassword * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -50,18 +50,18 @@ abstract class ModeleGenPassword * * @return string Description of text */ - function getDescription() + public function getDescription() { global $langs; return $langs->trans("NoDescription"); } /** - * Return an example of password generated by this module + * Return an example of password generated by this module * - * @return string Example of password + * @return string Example of password */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -69,11 +69,11 @@ abstract class ModeleGenPassword } /** - * Build new password + * Build new password * - * @return string Return a new generated password + * @return string Return a new generated password */ - function getNewGeneratedPassword() + public function getNewGeneratedPassword() { global $langs; return $langs->trans("NotAvailable"); @@ -85,7 +85,7 @@ abstract class ModeleGenPassword * @param string $password Password to check * @return int 0 if KO, >0 if OK */ - function validatePassword($password) + public function validatePassword($password) { return 1; } diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 1b5707330da..0043f14990d 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -54,7 +54,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -90,7 +90,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc * @param Translate $langs Object language * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -174,7 +174,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -186,10 +186,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { @@ -265,7 +265,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity], @@ -419,7 +419,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc } $odfHandler->saveToDisk($file); - }catch (Exception $e){ + } catch (Exception $e){ $this->error=$e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 75cc33df4bd..f8d4f137048 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -72,7 +72,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 0; $this->code_modifiable = 1; @@ -83,12 +83,13 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode } - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { global $conf, $mc; global $form; @@ -139,7 +140,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { if ($type == 0 || $type == -1) { @@ -200,7 +201,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * @param int $type Client ou fournisseur (0:customer, 1:supplier) * @return string Value if OK, '' if module not configured, <0 if KO */ - function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = 0, $type = -1) { global $db,$conf; @@ -237,13 +238,13 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if mask/numbering use prefix * * @return int 0 or 1 */ - function verif_prefixIsUsed() + public function verif_prefixIsUsed() { // phpcs:enable global $conf; @@ -272,7 +273,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * -4 ErrorPrefixRequired * -5 Other (see this->error) */ - function verif($db, &$code, $soc, $type) + public function verif($db, &$code, $soc, $type) { global $conf; @@ -314,7 +315,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi si un code est pris ou non (par autre tiers) * @@ -324,7 +325,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * @param int $type 0 = customer/prospect , 1 = supplier * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $soc, $type = 0) + public function verif_dispo($db, $code, $soc, $type = 0) { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index 77be301464c..c7d204a5010 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -70,7 +70,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 1; $this->code_modifiable = 1; @@ -80,12 +80,13 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode } - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { $langs->load("companies"); return $langs->trans("LeopardNumRefModelDesc"); @@ -99,7 +100,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return next value */ - function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = 0, $type = -1) { global $langs; return ''; @@ -119,7 +120,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $soc, $type) + public function verif($db, &$code, $soc, $type) { global $conf; diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 97acb109b97..69ee75911a6 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -70,7 +70,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Constructor */ - function __construct() + public function __construct() { $this->nom = "Monkey"; $this->name = "Monkey"; @@ -84,12 +84,13 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode } - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { return $langs->trans("MonkeyNumRefModelDesc", $this->prefixcustomer, $this->prefixsupplier); } @@ -103,7 +104,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { return $this->prefixcustomer.'0901-00001
'.$this->prefixsupplier.'0901-00001'; } @@ -112,11 +113,11 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Return next value * - * @param Societe $objsoc Object third party - * @param int $type Client ou fournisseur (1:client, 2:fournisseur) + * @param Societe $objsoc Object third party + * @param int $type Client ou fournisseur (1:client, 2:fournisseur) * @return string Value if OK, '' if module not configured, <0 if KO */ - function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = 0, $type = -1) { global $db, $conf, $mc; @@ -177,7 +178,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $soc, $type) + public function verif($db, &$code, $soc, $type) { global $conf; @@ -224,7 +225,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi si un code est pris ou non (par autre tiers) * @@ -234,7 +235,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * @param int $type 0 = customer/prospect , 1 = supplier * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $soc, $type = 0) + public function verif_dispo($db, $code, $soc, $type = 0) { // phpcs:enable global $conf, $mc; @@ -265,14 +266,14 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi si un code respecte la syntaxe + * Renvoi si un code respecte la syntaxe * - * @param string $code Code a verifier - * @return int 0 si OK, <0 si KO + * @param string $code Code a verifier + * @return int 0 si OK, <0 si KO */ - function verif_syntax($code) + public function verif_syntax($code) { // phpcs:enable $res = 0; diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 835213a7402..1472bd982c7 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -57,7 +57,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode /** * Constructor */ - function __construct() + public function __construct() { global $conf; if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; @@ -73,7 +73,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * @param Translate $langs Object langs * @return string Description of module */ - function info($langs) + public function info($langs) { global $conf; global $form; @@ -112,7 +112,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { $s=''; $s.=$this->prefixcustomeraccountancycode.'CUSTCODE'; @@ -122,7 +122,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set accountancy account code for a third party into this->code * @@ -131,7 +131,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * @param string $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ - function get_code($db, $societe, $type = '') + public function get_code($db, $societe, $type = '') { // phpcs:enable global $conf; @@ -196,7 +196,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * @param string $type 'supplier' or 'customer' * @return int 0 if OK but not available, >0 if OK and available, <0 if KO */ - function verif($db, $code, $societe, $type) + public function verif($db, $code, $societe, $type) { $sql = "SELECT "; if ($type == 'customer') $sql.= "code_compta"; diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php index 65cbba944b1..373e20b8eb6 100644 --- a/htdocs/core/modules/societe/mod_codecompta_panicum.php +++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php @@ -52,7 +52,7 @@ class mod_codecompta_panicum extends ModeleAccountancyCode /** * Constructor */ - function __construct() + public function __construct() { } @@ -63,7 +63,7 @@ class mod_codecompta_panicum extends ModeleAccountancyCode * @param Translate $langs Object langs * @return string Description of module */ - function info($langs) + public function info($langs) { return $langs->trans("ModuleCompanyCode".$this->name); } @@ -76,12 +76,12 @@ class mod_codecompta_panicum extends ModeleAccountancyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set accountancy account code for a third party into this->code * @@ -90,7 +90,7 @@ class mod_codecompta_panicum extends ModeleAccountancyCode * @param int $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ - function get_code($db, $societe, $type = '') + public function get_code($db, $societe, $type = '') { // phpcs:enable $this->code=''; diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index fe2b3d4feb3..d185b4cfcf7 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -38,7 +38,7 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -46,7 +46,7 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -77,7 +77,7 @@ abstract class ModeleThirdPartyCode * @param Translate $langs Object langs * @return string Texte descripif */ - function info($langs) + public function info($langs) { $langs->load("bills"); return $langs->trans("NoDescription"); @@ -88,7 +88,7 @@ abstract class ModeleThirdPartyCode * @param Translate $langs Object langs * @return string Nom du module */ - function getNom($langs) + public function getNom($langs) { return $this->nom; } @@ -99,7 +99,7 @@ abstract class ModeleThirdPartyCode * @param Translate $langs Object langs * @return string Example */ - function getExample($langs) + public function getExample($langs) { $langs->load("bills"); return $langs->trans("NoExample"); @@ -110,7 +110,7 @@ abstract class ModeleThirdPartyCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -122,18 +122,19 @@ abstract class ModeleThirdPartyCode * @param int $type Type * @return string Value */ - function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = 0, $type = -1) { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); } - /** Return version of module + /** + * Return version of module * - * @return string Version + * @return string Version */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -145,7 +146,7 @@ abstract class ModeleThirdPartyCode return $langs->trans("NotAvailable"); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la liste des modeles de numérotation * @@ -153,7 +154,7 @@ abstract class ModeleThirdPartyCode * @param integer $maxfilenamelength Max length of value to show * @return array List of numbers */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable $liste=array(); @@ -186,7 +187,7 @@ abstract class ModeleThirdPartyCode * @param int $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ - function getToolTip($langs, $soc, $type) + public function getToolTip($langs, $soc, $type) { global $conf; @@ -245,13 +246,13 @@ abstract class ModeleThirdPartyCode return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if mask/numbering use prefix * * @return int 0=no, 1=yes */ - function verif_prefixIsUsed() + public function verif_prefixIsUsed() { // phpcs:enable return 0; @@ -271,25 +272,27 @@ abstract class ModeleAccountancyCode public $error=''; - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { $langs->load("bills"); return $langs->trans("NoDescription"); } - /** Return an example of result returned by getNextValue + /** + * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs - * @param societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Example + * @param Translate $langs Object langs + * @param societe $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { $langs->load("bills"); return $langs->trans("NoExample"); @@ -300,16 +303,17 @@ abstract class ModeleAccountancyCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } - /** Return version of module + /** + * Return version of module * - * @return string Version + * @return string Version */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -322,14 +326,14 @@ abstract class ModeleAccountancyCode } /** - * Return description of module parameters + * Return description of module parameters * - * @param Translate $langs Output language - * @param Societe $soc Third party object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier - * @return string HTML translated description + * @param Translate $langs Output language + * @param Societe $soc Third party object + * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @return string HTML translated description */ - function getToolTip($langs, $soc, $type) + public function getToolTip($langs, $soc, $type) { global $conf,$db; @@ -358,7 +362,7 @@ abstract class ModeleAccountancyCode return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set accountancy account code for a third party into this->code * @@ -367,7 +371,7 @@ abstract class ModeleAccountancyCode * @param int $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ - function get_code($db, $societe, $type = '') + public function get_code($db, $societe, $type = '') { // phpcs:enable global $langs; @@ -377,8 +381,6 @@ abstract class ModeleAccountancyCode } - -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Create a document onto disk according to template module. * @@ -396,8 +398,7 @@ abstract class ModeleAccountancyCode */ function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - // phpcs:enable - dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); + dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); - return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index c5bc5f53c8e..4c8f33b3506 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -61,7 +61,7 @@ class doc_generic_stock_odt extends ModelePDFStock * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -106,7 +106,7 @@ class doc_generic_stock_odt extends ModelePDFStock * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf, $langs; @@ -205,7 +205,7 @@ class doc_generic_stock_odt extends ModelePDFStock return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -217,7 +217,7 @@ class doc_generic_stock_odt extends ModelePDFStock * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $stock,$langs,$conf,$mysoc,$hookmanager,$user; @@ -357,13 +357,13 @@ class doc_generic_stock_odt extends ModelePDFStock // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( - $srctemplatepath, - array( - 'PATH_TO_TMP' => $conf->produit->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. - 'DELIMITER_LEFT' => '{', - 'DELIMITER_RIGHT' => '}' + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->produit->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' ) ); } diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index c46799b6e41..7f174149e09 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -51,7 +51,7 @@ class pdf_standard extends ModelePDFStock */ public $description; - /** + /** * @var string document type */ public $type; @@ -177,7 +177,7 @@ class pdf_standard extends ModelePDFStock } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -189,7 +189,7 @@ class pdf_standard extends ModelePDFStock * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager; @@ -834,17 +834,17 @@ class pdf_standard extends ModelePDFStock /** * Show table for lines * - * @param TCPDF $pdf Object PDF - * @param string $tab_top Top position of table - * @param string $tab_height Height of table (rectangle) - * @param int $nexY Y (not used) - * @param Translate $outputlangs Langs object - * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title - * @param int $hidebottom Hide bottom bar of array - * @param string $currency Currency code - * @return void + * @param TCPDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -914,8 +914,7 @@ class pdf_standard extends ModelePDFStock if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); -$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', - 'C'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', 'C'); } //$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); @@ -948,7 +947,7 @@ $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->tran * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { global $conf,$langs,$db,$hookmanager; @@ -1176,7 +1175,7 @@ $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->tran * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 495dd3a6ef8..563c2ea1011 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -179,7 +179,7 @@ class pdf_stdmovement extends ModelePDFMovement } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -191,7 +191,7 @@ class pdf_stdmovement extends ModelePDFMovement * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager; @@ -203,9 +203,9 @@ class pdf_stdmovement extends ModelePDFMovement // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries")); - /** - * TODO: get from object - */ + /** + * TODO: get from object + */ $id=GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -327,9 +327,9 @@ class pdf_stdmovement extends ModelePDFMovement $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - /* - * END TODO - **/ + /* + * END TODO + **/ //$nblignes = count($object->lines); @@ -822,7 +822,7 @@ class pdf_stdmovement extends ModelePDFMovement * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -948,7 +948,7 @@ class pdf_stdmovement extends ModelePDFMovement * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { global $conf,$langs,$db,$hookmanager; @@ -1168,15 +1168,15 @@ class pdf_stdmovement extends ModelePDFMovement } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param TCPDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param TCPDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/stock/modules_movement.php b/htdocs/core/modules/stock/modules_movement.php index b6298fa6cc9..76548664524 100644 --- a/htdocs/core/modules/stock/modules_movement.php +++ b/htdocs/core/modules/stock/modules_movement.php @@ -36,7 +36,7 @@ abstract class ModelePDFMovement extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -44,7 +44,7 @@ abstract class ModelePDFMovement extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/stock/modules_stock.php b/htdocs/core/modules/stock/modules_stock.php index c7d564ef082..a60437cd38a 100644 --- a/htdocs/core/modules/stock/modules_stock.php +++ b/htdocs/core/modules/stock/modules_stock.php @@ -19,25 +19,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; /** - * Parent class for stock models of doc generators + * Parent class for stock models of doc generators */ abstract class ModelePDFStock extends CommonDocGenerator { /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * - * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 46707dfaa14..8302db4ab31 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -33,11 +33,11 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturef */ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices { - /** + /** * Dolibarr version of the loaded document * @public string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error code (or message) @@ -64,24 +64,24 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** - * Return description of numbering model + * Return description of numbering model * * @return string Text with description */ - function info() + public function info() { - global $langs; - $langs->load("bills"); - return $langs->trans("CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit); + global $langs; + $langs->load("bills"); + return $langs->trans("CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit); } /** - * Returns a numbering example + * Returns a numbering example * * @return string Example */ - function getExample() + public function getExample() { return $this->prefixinvoice."1301-0001"; } @@ -92,7 +92,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -164,13 +164,13 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** * Return next value - * - * @param Societe $objsoc Object third party - * @param Object $object Object invoice + * + * @param Societe $objsoc Object third party + * @param Object $object Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, 0 if KO + * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object, $mode = 'next') + public function getNextValue($objsoc, $object, $mode = 'next') { global $db,$conf; @@ -236,14 +236,14 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** - * Return next free value - * + * Return next free value + * * @param Societe $objsoc Object third party * @param string $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string Next free value */ - function getNumRef($objsoc, $objforref, $mode = 'next') + public function getNumRef($objsoc, $objforref, $mode = 'next') { return $this->getNextValue($objsoc, $objforref, $mode); } diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 4e2b84edcc8..7f85cbe5bb6 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -65,9 +65,9 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices * * @return string Description Text */ - function info() + public function info() { - global $conf, $langs; + global $conf, $langs; // Load translation files required by the page $langs->loadLangs(array("bills","admin")); @@ -98,7 +98,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $texte.= '
 
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'.$form->textwithpicto('', $tooltip, 1, 1).''.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).''.img_edit().''; + print ''.img_edit().''; print "  ".img_delete()."
'.$langs->trans("LinkedToDolibarrThirdParty").''.$company->getNomUrl(1).'
'.$langs->trans("LinkedToDolibarrThirdParty").''.$company->getNomUrl(1).'
' . $langs->trans("Project") . ''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">' . $langs->trans("AddProject") . ' '; print '
'; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '
'; - print '
'.$langs->trans("SelectExportDataSet").'

'; // Affiche les modules d'exports + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'; print ''; print ''; @@ -490,8 +480,7 @@ if ($step == 1 || ! $datatoexport) print ''; } print '
'.$langs->trans("Module").'
'.$langs->trans("NoExportableData").'
'; - - print '
'; + print ''; print ''; } @@ -500,10 +489,6 @@ if ($step == 2 && $datatoexport) { llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones'); - - /* - * Affichage onglets - */ $h = 0; $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=1'; @@ -515,11 +500,12 @@ if ($step == 2 && $datatoexport) $hselected=$h; $h++; - dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -1); + dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -2); print '
'; print '
'; - print ''; + + print '
'; // Module print ''; @@ -551,24 +537,25 @@ if ($step == 2 && $datatoexport) print ''; print ''; print ''; - print '
'.$langs->trans("Module").'
'; - print $langs->trans("SelectExportFields").' '; + print '
'; + print ''.$langs->trans("SelectExportFields").' '; if(empty($conf->global->EXPORTS_SHARE_MODELS))$htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1, $user->id); else $htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1); print ' '; print ''; - print '
'; + print '
'; print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; print ''; - print ''; print ''; print ''; @@ -659,7 +646,7 @@ if ($step == 2 && $datatoexport) } print '
'.$langs->trans("Entities").''.$langs->trans("ExportableFields").''; - print ''.$langs->trans("All").""; + print ''; + print ''.$langs->trans("All").""; print ' / '; - print ''.$langs->trans("None").""; + print ''.$langs->trans("None").""; print ''.$langs->trans("ExportedFields").'
'; - + print '
'; /* * Barre d'action @@ -697,9 +684,6 @@ if ($step == 3 && $datatoexport) llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones'); - /* - * Affichage onglets - */ $h = 0; $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=1'; @@ -715,11 +699,11 @@ if ($step == 3 && $datatoexport) $hselected=$h; $h++; - dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -1); + dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -2); print '
'; print '
'; - print ''; + print '
'; // Module print ''; @@ -754,11 +738,13 @@ if ($step == 3 && $datatoexport) print '
'; // Combo list of export models - print $langs->trans("SelectFilterFields").'
'; + print ''.$langs->trans("SelectFilterFields").'

'; // un formulaire en plus pour recuperer les filtres print ''; + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'.$langs->trans("Module").'
'; print ''; print ''; @@ -848,6 +834,7 @@ if ($step == 3 && $datatoexport) } print '
'.$langs->trans("Entities").'
'; + print '
'; print ''; @@ -873,9 +860,6 @@ if ($step == 4 && $datatoexport) llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones'); - /* - * Affichage onglets - */ $stepoffset=0; $h = 0; @@ -901,14 +885,14 @@ if ($step == 4 && $datatoexport) $hselected=$h; $h++; - dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -1); + dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -2); print '
'; print '
'; - print ''; + print '
'; // Module - print ''; + print ''; print ''; } @@ -961,7 +961,7 @@ if ($action == 'create') $numcontrat=$formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1); if ($numcontrat==0) { - print '   '.$langs->trans("AddContract").''; + print '   '.$langs->trans("AddContract").' '; } print ''; } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 26173db12af..d49f58ed52e 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -55,10 +55,10 @@ class Interventions extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->fichinter = new Fichinter($this->db); } @@ -72,23 +72,23 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention report not found'); - } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention report not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->fichinter->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->fichinter); + $this->fichinter->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->fichinter); } /** @@ -106,7 +106,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -130,8 +130,7 @@ class Interventions extends DolibarrApi if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter - if ($search_sale > 0) - { + if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters @@ -141,7 +140,7 @@ class Interventions extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -169,7 +168,7 @@ class Interventions extends DolibarrApi $obj = $db->fetch_object($result); $fichinter_static = new Fichinter($db); if($fichinter_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); + $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); } $i++; } @@ -180,7 +179,7 @@ class Interventions extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No finchinter found'); } - return $obj_ret; + return $obj_ret; } /** @@ -189,7 +188,7 @@ class Interventions extends DolibarrApi * @param array $request_data Request data * @return int ID of intervention */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,28 +217,28 @@ class Interventions extends DolibarrApi * @return int */ /* TODO - function getLines($id) + public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention not found'); - } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->fichinter->getLinesArray(); - $result = array(); - foreach ($this->fichinter->lines as $line) { - array_push($result,$this->_cleanObjectDatas($line)); - } - return $result; + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->fichinter->getLinesArray(); + $result = array(); + foreach ($this->fichinter->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; } - */ + */ /** * Add a line to given intervention @@ -251,7 +250,7 @@ class Interventions extends DolibarrApi * * @return int */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -292,30 +291,30 @@ class Interventions extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) { - throw new RestException(401); - } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention not found'); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) { + throw new RestException(401); + } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error); - } + if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Intervention deleted' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Intervention deleted' + ) + ); } /** @@ -333,7 +332,7 @@ class Interventions extends DolibarrApi * * @return array */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -369,7 +368,7 @@ class Interventions extends DolibarrApi * * @return array */ - function closeFichinter($id) + public function closeFichinter($id) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { @@ -406,7 +405,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $fichinter = array(); foreach (Interventions::$FIELDS as $field) { @@ -424,16 +423,16 @@ class Interventions extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->statuts_short); - unset($object->statuts_logo); - unset($object->statuts); + unset($object->statuts_short); + unset($object->statuts_logo); + unset($object->statuts); - return $object; + return $object; } /** @@ -444,7 +443,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function _validateLine($data) + private function _validateLine($data) { $fichinter = array(); foreach (Interventions::$FIELDSLINE as $field) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 97ecffacf95..43cd79bfe70 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -122,20 +122,20 @@ class Fichinter extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { $this->db = $db; $this->products = array(); - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -179,7 +179,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -313,7 +313,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { if (! is_numeric($this->duration)) { $this->duration = 0; @@ -373,13 +373,13 @@ class Fichinter extends CommonObject * @param string $ref Ref of intervention * @return int <0 if KO, >0 if OK */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { $sql = "SELECT f.rowid, f.ref, f.description, f.fk_soc, f.fk_statut,"; $sql.= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; $sql.= " f.date_valid as datev,"; $sql.= " f.tms as datem,"; - $sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat"; + $sql.= " f.duree, f.fk_projet as fk_project, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f"; if ($ref) { $sql.= " WHERE f.entity IN (".getEntity('intervention').")"; @@ -407,15 +407,15 @@ class Fichinter extends CommonObject $this->datet = $this->db->jdate($obj->datet); $this->datev = $this->db->jdate($obj->datev); $this->datem = $this->db->jdate($obj->datem); - $this->fk_project = $obj->fk_projet; + $this->fk_project = $obj->fk_project; $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; - $this->modelpdf = $obj->model_pdf; - $this->fk_contrat = $obj->fk_contrat; + $this->modelpdf = $obj->model_pdf; + $this->fk_contrat = $obj->fk_contrat; - $this->user_creation= $obj->fk_user_author; + $this->user_creation = $obj->fk_user_author; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; @@ -447,7 +447,7 @@ class Fichinter extends CommonObject * @param User $user User that set draft * @return int <0 if KO, >0 if OK */ - function setDraft($user) + public function setDraft($user) { global $langs, $conf; @@ -483,7 +483,7 @@ class Fichinter extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function setValid($user, $notrigger = 0) + public function setValid($user, $notrigger = 0) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -595,7 +595,7 @@ class Fichinter extends CommonObject * * @return float Amount */ - function getAmount() + public function getAmount() { global $db; @@ -653,12 +653,12 @@ class Fichinter 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 * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the label of a statut * @@ -666,7 +666,7 @@ class Fichinter 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 */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable // Init/load array of translation of status @@ -716,7 +716,7 @@ class Fichinter 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, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $hookmanager; @@ -782,7 +782,7 @@ class Fichinter extends CommonObject * @param Societe $soc Thirdparty object * @return string Free reference for intervention */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf, $db, $langs; $langs->load("interventions"); @@ -838,7 +838,7 @@ class Fichinter extends CommonObject * @param int $id Id of object * @return void */ - function info($id) + public function info($id) { global $conf; @@ -897,7 +897,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1002,16 +1002,16 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Defines a delivery date of intervention + * Defines a delivery date of intervention * - * @param User $user Object user who define - * @param date $date_delivery date of delivery - * @return int <0 if ko, >0 if ok - */ - function set_date_delivery($user, $date_delivery) - { + * @param User $user Object user who define + * @param date $date_delivery date of delivery + * @return int <0 if ko, >0 if ok + */ + public function set_date_delivery($user, $date_delivery) + { // phpcs:enable global $conf; @@ -1036,7 +1036,7 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define the label of the intervention * @@ -1044,7 +1044,7 @@ class Fichinter extends CommonObject * @param string $description description * @return int <0 if KO, >0 if OK */ - function set_description($user, $description) + public function set_description($user, $description) { // phpcs:enable global $conf; @@ -1071,7 +1071,7 @@ class Fichinter extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link intervention to a contract * @@ -1079,8 +1079,8 @@ class Fichinter extends CommonObject * @param int $contractid Description * @return int <0 if ko, >0 if ok */ - function set_contrat($user, $contractid) - { + public function set_contrat($user, $contractid) + { // phpcs:enable global $conf; @@ -1112,7 +1112,7 @@ class Fichinter extends CommonObject * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$hookmanager; @@ -1205,7 +1205,7 @@ class Fichinter extends CommonObject * @param array $array_options Array option * @return int >0 if ok, <0 if ko */ - function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_options = '') + public function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_options = '') { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); @@ -1249,7 +1249,7 @@ class Fichinter extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -1280,14 +1280,14 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines ->lines * * @return int <0 if KO, >0 if OK */ - function fetch_lines() - { + public function fetch_lines() + { // phpcs:enable $this->lines = array(); @@ -1395,7 +1395,7 @@ class FichinterLigne extends CommonObjectLine * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -1406,7 +1406,7 @@ class FichinterLigne extends CommonObjectLine * @param int $rowid Line id * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang,'; $sql.= ' ft.date as datei'; @@ -1443,7 +1443,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int <0 if ko, >0 if ok */ - function insert($user, $notrigger = 0) + public function insert($user, $notrigger = 0) { global $langs,$conf; @@ -1539,7 +1539,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int <0 if ko, >0 if ok */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs,$conf; @@ -1600,13 +1600,13 @@ class FichinterLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total duration into llx_fichinter * * @return int <0 si ko, >0 si ok */ - function update_total() + public function update_total() { // phpcs:enable global $conf; @@ -1660,7 +1660,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int >0 if ok, <0 if ko */ - function deleteline($user, $notrigger = 0) + public function deleteline($user, $notrigger = 0) { global $langs,$conf; diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index 80d7e6107c8..7112f6cdf77 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -33,181 +33,181 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class FichinterStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. - * @param string $mode Option ('customer', 'supplier') - * @param int $userid Id user for filter (creation user) - */ - function __construct($db, $socid, $mode, $userid = 0) - { - global $user, $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. + * @param string $mode Option ('customer', 'supplier') + * @param int $userid Id user for filter (creation user) + */ + public function __construct($db, $socid, $mode, $userid = 0) + { + global $user, $conf; - $this->db = $db; + $this->db = $db; - $this->socid = ($socid > 0 ? $socid : 0); + $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; - $this->cachefilesuffix = $mode; + $this->cachefilesuffix = $mode; - $this->where.= " c.entity = ".$conf->entity; - if ($mode == 'customer') - { - $object=new Fichinter($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; - $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='0'; - $this->field_line='0'; - //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled - } - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($this->socid) - { - $this->where.=" AND c.fk_soc = ".$this->socid; - } + $this->where.= " c.entity = ".$conf->entity; + if ($mode == 'customer') + { + $object=new Fichinter($this->db); + $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; + $this->field='0'; + $this->field_line='0'; + //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled + } + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($this->socid) + { + $this->where.=" AND c.fk_soc = ".$this->socid; + } if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; - } + } - /** - * Return intervention number by month for a year - * - * @param int $year Year to scan + /** + * Return intervention number by month for a year + * + * @param int $year Year to scan * @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 with number by month - */ - function getNbByMonth($year, $format = 0) - { - global $user; + * @return array Array with number by month + */ + public function getNbByMonth($year, $format = 0) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); - return $res; - } + $res=$this->_getNbByMonth($year, $sql, $format); + return $res; + } - /** - * Return interventions number per year - * - * @return array Array with number by year - * - */ - function getNbByYear() - { - global $user; + /** + * Return interventions number per year + * + * @return array Array with number by year + * + */ + public function getNbByYear() + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - return $this->_getNbByYear($sql); - } + return $this->_getNbByYear($sql); + } - /** - * Return the intervention amount by month for a year - * - * @param int $year Year to scan + /** + * Return the intervention amount by month for a year + * + * @param int $year Year to scan * @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 with amount by month - */ - function getAmountByMonth($year, $format = 0) - { - global $user; + * @return array Array with amount by month + */ + public function getAmountByMonth($year, $format = 0) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); - return $res; - } + $res=$this->_getAmountByMonth($year, $sql, $format); + return $res; + } - /** - * Return the intervention amount average by month for a year - * - * @param int $year year for stats - * @return array array with number by month - */ - function getAverageByMonth($year) - { - global $user; + /** + * Return the intervention amount average by month for a year + * + * @param int $year year for stats + * @return array array with number by month + */ + public function getAverageByMonth($year) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - return $this->_getAverageByMonth($year, $sql); - } + return $this->_getAverageByMonth($year, $sql); + } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - global $user; + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } - /** - * Return nb, amount of predefined product for year - * - * @param int $year Year to scan - * @return array Array of values - */ - function getAllByProduct($year) - { - global $user; + /** + * Return nb, amount of predefined product for year + * + * @param int $year Year to scan + * @return array Array of values + */ + public function getAllByProduct($year) + { + global $user; - $sql = "SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid"; - $sql.= " AND c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; + $sql = "SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg"; + $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid"; + $sql.= " AND c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql.= " GROUP BY product.ref"; $sql.= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql); - } + return $this->_getAllByProduct($sql); + } } diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 4391d14ea3c..3f94401bc9d 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -44,10 +44,10 @@ class SupplierInvoices extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->invoice = new FactureFournisseur($this->db); } @@ -61,23 +61,23 @@ class SupplierInvoices extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { + throw new RestException(401); + } $result = $this->invoice->fetch($id); if( ! $result ) { throw new RestException(404, 'Supplier invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->invoice->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->invoice); + $this->invoice->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->invoice); } /** @@ -94,9 +94,9 @@ class SupplierInvoices extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" * @return array Array of invoice objects * - * @throws RestException + * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') { global $db, $conf; @@ -120,14 +120,21 @@ class SupplierInvoices extends DolibarrApi if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Filter by status - if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; - if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; - if ($status == 'paid') $sql.= " AND t.fk_statut IN (2)"; - if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (3)"; + // Filter by status + if ($status == 'draft') { + $sql.= " AND t.fk_statut IN (0)"; + } + if ($status == 'unpaid') { + $sql.= " AND t.fk_statut IN (1)"; + } + if ($status == 'paid') { + $sql.= " AND t.fk_statut IN (2)"; + } + if ($status == 'cancelled') { + $sql.= " AND t.fk_statut IN (3)"; + } // Insert sale filter - if ($search_sale > 0) - { + if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters @@ -137,7 +144,7 @@ class SupplierInvoices extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -182,7 +189,7 @@ class SupplierInvoices extends DolibarrApi * @param array $request_data Request datas * @return int ID of supplier invoice */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,7 +225,7 @@ class SupplierInvoices 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->fournisseur->facture->creer) { throw new RestException(401); @@ -229,9 +236,9 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; @@ -250,7 +257,7 @@ class SupplierInvoices extends DolibarrApi * @param int $id Supplier invoice ID * @return type */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) { throw new RestException(401); @@ -260,9 +267,9 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( $this->invoice->delete(DolibarrApiAccess::$user) < 0) { @@ -296,34 +303,34 @@ class SupplierInvoices extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { - throw new RestException(401); - } - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } + if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); - } + $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Invoice validated (Ref='.$this->invoice->ref.')' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Invoice validated (Ref='.$this->invoice->ref.')' + ) + ); } /** @@ -332,7 +339,7 @@ class SupplierInvoices extends DolibarrApi * @param Object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -354,7 +361,7 @@ class SupplierInvoices extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $invoice = array(); foreach (SupplierInvoices::$FIELDS as $field) { diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 38c9ab9e200..9a898fae3a7 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -44,7 +44,7 @@ class SupplierOrders extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -61,23 +61,23 @@ class SupplierOrders extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { + throw new RestException(401); + } $result = $this->order->fetch($id); if ( ! $result ) { throw new RestException(404, 'Supplier order not found'); } - if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->order->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->order); + $this->order->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->order); } /** @@ -94,9 +94,9 @@ class SupplierOrders extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" * @return array Array of order objects * - * @throws RestException + * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') { global $db, $conf; @@ -120,7 +120,7 @@ class SupplierOrders extends DolibarrApi if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Filter by status + // Filter by status if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; if ($status == 'validated') $sql.= " AND t.fk_statut IN (1)"; if ($status == 'approved') $sql.= " AND t.fk_statut IN (2)"; @@ -141,7 +141,7 @@ class SupplierOrders extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -178,7 +178,7 @@ class SupplierOrders extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No supplier order found'); } - return $obj_ret; + return $obj_ret; } /** @@ -187,7 +187,7 @@ class SupplierOrders extends DolibarrApi * @param array $request_data Request datas * @return int ID of supplier order */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { throw new RestException(401, "Insuffisant rights"); @@ -223,7 +223,7 @@ class SupplierOrders 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->fournisseur->commande->creer) { throw new RestException(401); @@ -234,9 +234,9 @@ class SupplierOrders extends DolibarrApi throw new RestException(404, 'Supplier order not found'); } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; @@ -255,7 +255,7 @@ class SupplierOrders extends DolibarrApi * @param int $id Supplier order ID * @return type */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->fournisseur->commande->supprimer) { throw new RestException(401); @@ -265,9 +265,9 @@ class SupplierOrders extends DolibarrApi throw new RestException(404, 'Supplier order not found'); } - if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if ( $this->order->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500); @@ -300,34 +300,34 @@ class SupplierOrders extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { - throw new RestException(401); - } - $result = $this->order->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Order not found'); - } + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401); + } + $result = $this->order->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Order not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Order: '.$this->order->error); - } + $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Order: '.$this->order->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Order validated (Ref='.$this->order->ref.')' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Order validated (Ref='.$this->order->ref.')' + ) + ); } /** @@ -336,7 +336,7 @@ class SupplierOrders extends DolibarrApi * @param Object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -358,7 +358,7 @@ class SupplierOrders extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $order = array(); foreach (SupplierOrders::$FIELDS as $field) { diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index 0636a356111..42e9b9153db 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; */ class Fournisseur extends Societe { - var $next_prev_filter="te.fournisseur = 1"; // Used to add a filter in Form::showrefnav method + public $next_prev_filter="te.fournisseur = 1"; // Used to add a filter in Form::showrefnav method /** @@ -41,7 +41,7 @@ class Fournisseur extends Societe * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -55,7 +55,7 @@ class Fournisseur extends Societe * * @return int Nb of orders */ - function getNbOfOrders() + public function getNbOfOrders() { $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; @@ -81,7 +81,7 @@ class Fournisseur extends Societe * * @return int Nb of ref prices, or <0 if error */ - function nbOfProductRefs() + public function nbOfProductRefs() { global $conf; @@ -102,13 +102,13 @@ class Fournisseur extends Societe } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load statistics indicators * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -145,7 +145,7 @@ class Fournisseur extends Societe } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a supplier category * @@ -153,7 +153,7 @@ class Fournisseur extends Societe * @param string $name Category name * @return int <0 if KO, 0 if OK */ - function CreateCategory($user, $name) + public function CreateCategory($user, $name) { // phpcs:enable $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label,visible,type)"; @@ -175,13 +175,13 @@ class Fournisseur extends Societe } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the suppliers list * * @return array Array of suppliers */ - function ListArray() + public function ListArray() { // phpcs:enable global $conf; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9ee3883bb60..fbc53183ea1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -262,7 +262,7 @@ class CommandeFournisseur extends CommonOrder $sql.= " c.date_commande as date_commande, c.date_livraison as date_livraison, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_input_method,"; $sql.= " c.fk_account,"; $sql.= " c.note_private, c.note_public, c.model_pdf, c.extraparams, c.billed,"; - $sql.= " c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc,"; + $sql.= " c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc,"; $sql.= " cm.libelle as methode_commande,"; $sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,"; $sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle"; @@ -272,7 +272,7 @@ class CommandeFournisseur extends CommonOrder $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON c.fk_cond_reglement = cr.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON c.fk_mode_reglement = p.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; $sql.= " WHERE c.entity = ".$conf->entity; if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'"; else $sql.= " AND c.rowid=".$id; @@ -375,14 +375,14 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ - function fetch_lines($only_product = 0) + public function fetch_lines($only_product = 0) { // phpcs:enable //$result=$this->fetch_lines(); @@ -616,7 +616,7 @@ class CommandeFournisseur extends CommonOrder return $this->LibStatut($this->statut, $mode, $this->billed); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -625,7 +625,7 @@ class CommandeFournisseur extends CommonOrder * @param int $billed 1=Billed * @return string Label of status */ - function LibStatut($statut, $mode = 0, $billed = 0) + public function LibStatut($statut, $mode = 0, $billed = 0) { // phpcs:enable global $conf, $langs; @@ -1079,7 +1079,7 @@ class CommandeFournisseur extends CommonOrder return $result ; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Cancel an approved order. * The cancellation is done after approval @@ -1088,12 +1088,12 @@ class CommandeFournisseur extends CommonOrder * @param int $idwarehouse Id warehouse to use for stock change (not used for supplier orders). * @return int >0 if Ok, <0 if Ko */ - function Cancel($user, $idwarehouse = -1) + public function Cancel($user, $idwarehouse = -1) { // phpcs:enable global $langs,$conf; - $error=0; + $error=0; //dol_syslog("CommandeFournisseur::Cancel"); $result = 0; @@ -2006,13 +2006,13 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get list of order methods * * @return int 0 if OK, <0 if KO */ - function get_methodes_commande() + public function get_methodes_commande() { // phpcs:enable $sql = "SELECT rowid, libelle"; @@ -2093,7 +2093,7 @@ class CommandeFournisseur extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set a delivery in database for this supplier order * @@ -2103,7 +2103,7 @@ class CommandeFournisseur extends CommonOrder * @param string $comment Comment * @return int <0 if KO, >0 if OK */ - function Livraison($user, $date, $type, $comment) + public function Livraison($user, $date, $type, $comment) { // phpcs:enable global $conf, $langs; @@ -2210,7 +2210,7 @@ class CommandeFournisseur extends CommonOrder return $result ; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the planned delivery date * @@ -2219,7 +2219,7 @@ class CommandeFournisseur extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_date_livraison($user, $date_livraison, $notrigger = 0) + public function set_date_livraison($user, $date_livraison, $notrigger = 0) { // phpcs:enable if ($user->rights->fournisseur->commande->creer) @@ -2276,7 +2276,7 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the id projet * @@ -2285,7 +2285,7 @@ class CommandeFournisseur extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - function set_id_projet($user, $id_projet, $notrigger = 0) + public function set_id_projet($user, $id_projet, $notrigger = 0) { // phpcs:enable if ($user->rights->fournisseur->commande->creer) @@ -2469,7 +2469,7 @@ class CommandeFournisseur extends CommonOrder */ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $notrigger = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') { - global $mysoc, $conf; + global $mysoc, $conf; dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2739,13 +2739,13 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 si ko, >0 si ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -2782,14 +2782,14 @@ class CommandeFournisseur extends CommonOrder } } - // 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; @@ -2918,7 +2918,7 @@ class CommandeFournisseur extends CommonOrder * @return Translated string */ public function getMaxDeliveryTimeDay($langs) - { + { if (empty($this->lines)) return ''; $obj = new ProductFournisseur($this->db); @@ -3155,7 +3155,7 @@ class CommandeFournisseur extends CommonOrder * @param int $filtre_statut Filter on shipment status * @return int <0 if KO, Nb of lines found if OK */ - function loadReceptions($filtre_statut = -1) + public function loadReceptions($filtre_statut = -1) { $this->receptions = array(); @@ -3579,7 +3579,7 @@ class CommandeFournisseurLigne extends CommonOrderLine * @param int $notrigger 1=Disable call to triggers * @return int <0 if KO, >0 if OK */ - function delete($notrigger) + public function delete($notrigger) { global $user; diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 49f23cf5191..6db4607573c 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -17,21 +17,19 @@ */ /** - * \file fourn/class/fournisseur.commande.dispatch.class.php + * \file htdocs/fourn/class/fournisseur.commande.dispatch.class.php * \ingroup fournisseur stock * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) - * Initialy built by build_class_from_table on 2015-02-24 10:38 + * Initialy built by build_class_from_table on 2015-02-24 10:38 */ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; require_once DOL_DOCUMENT_ROOT."/reception/class/reception.class.php"; -//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; -//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; /** - * Class to manage table commandefournisseurdispatch + * Class to manage table commandefournisseurdispatch */ class CommandeFournisseurDispatch extends CommonObject { @@ -114,7 +112,7 @@ class CommandeFournisseurDispatch extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -135,7 +133,7 @@ class CommandeFournisseurDispatch 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, $hookmanager; $error=0; @@ -256,7 +254,7 @@ class CommandeFournisseurDispatch extends CommonObject * @param string $ref Ref * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $langs; $sql = "SELECT"; @@ -325,7 +323,7 @@ class CommandeFournisseurDispatch extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -420,7 +418,7 @@ class CommandeFournisseurDispatch 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; @@ -477,7 +475,7 @@ class CommandeFournisseurDispatch extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -531,15 +529,15 @@ class CommandeFournisseurDispatch extends CommonObject /** * Return label of the status of object * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto * @return string Label */ - 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 label of a status * @@ -547,7 +545,7 @@ class CommandeFournisseurDispatch 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 * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -568,20 +566,20 @@ class CommandeFournisseurDispatch extends CommonObject elseif ($mode == 3) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4'); + elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); } elseif ($mode == 4) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); } elseif ($mode == 5) { if ($statut==0) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - if ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - if ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + elseif ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut4'); + elseif ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); } } @@ -592,7 +590,7 @@ class CommandeFournisseurDispatch extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 05b6754bc5d..d2c7ad43a00 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -29,9 +29,9 @@ */ /** - * \file htdocs/fourn/class/fournisseur.facture.class.php - * \ingroup fournisseur,facture - * \brief File of class to manage suppliers invoices + * \file htdocs/fourn/class/fournisseur.facture.class.php + * \ingroup fournisseur,facture + * \brief File of class to manage suppliers invoices */ include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; @@ -53,14 +53,14 @@ class FactureFournisseur extends CommonInvoice public $table_element='facture_fourn'; /** - * @var int Name of subtable line - */ - public $table_element_line='facture_fourn_det'; + * @var int Name of subtable line + */ + public $table_element_line='facture_fourn_det'; /** - * @var int Field with ID of parent key if this field has a parent - */ - public $fk_element='fk_facture_fourn'; + * @var int Field with ID of parent key if this field has a parent + */ + public $fk_element='fk_facture_fourn'; public $picto='bill'; @@ -707,22 +707,22 @@ class FactureFournisseur extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load this->lines * * @return int 1 si ok, < 0 si erreur */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable - $this->lines = array(); + $this->lines = array(); $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx'; $sql.= ', f.localtax1_tx, f.localtax2_tx, f.localtax1_type, f.localtax2_type, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; - $sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; + $sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid'; $sql.= ' WHERE fk_facture_fourn='.$this->id; @@ -783,12 +783,12 @@ class FactureFournisseur extends CommonInvoice $line->fk_unit = $obj->fk_unit; // Multicurrency - $line->fk_multicurrency = $obj->fk_multicurrency; - $line->multicurrency_code = $obj->multicurrency_code; - $line->multicurrency_subprice = $obj->multicurrency_subprice; - $line->multicurrency_total_ht = $obj->multicurrency_total_ht; - $line->multicurrency_total_tva = $obj->multicurrency_total_tva; - $line->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $line->fk_multicurrency = $obj->fk_multicurrency; + $line->multicurrency_code = $obj->multicurrency_code; + $line->multicurrency_subprice = $obj->multicurrency_subprice; + $line->multicurrency_total_ht = $obj->multicurrency_total_ht; + $line->multicurrency_total_tva = $obj->multicurrency_total_tva; + $line->multicurrency_total_ttc = $obj->multicurrency_total_ttc; $this->lines[$i] = $line; @@ -934,14 +934,14 @@ class FactureFournisseur extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount) * * @param int $idremise Id of absolute discount * @return int >0 if OK, <0 if KO */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -1187,16 +1187,16 @@ class FactureFournisseur extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag invoice as a payed invoice * * @param User $user Object user - * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet. Not implementd yet. - * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet. Not implementd yet. + * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet. Not implementd yet. + * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet. Not implementd yet. * @return int <0 si ko, >0 si ok */ - function set_paid($user, $close_code = '', $close_note = '') + public function set_paid($user, $close_code = '', $close_note = '') { // phpcs:enable global $conf,$langs; @@ -1237,7 +1237,7 @@ class FactureFournisseur extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED * Fonction utilisee quand un paiement prelevement est refuse, @@ -1246,7 +1246,7 @@ class FactureFournisseur extends CommonInvoice * @param User $user Object user that change status * @return int <0 si ok, >0 si ok */ - function set_unpaid($user) + public function set_unpaid($user) { // phpcs:enable global $conf,$langs; @@ -1450,7 +1450,7 @@ class FactureFournisseur extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -1458,7 +1458,7 @@ class FactureFournisseur extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function set_draft($user, $idwarehouse = -1) + public function set_draft($user, $idwarehouse = -1) { // phpcs:enable global $conf,$langs; @@ -2033,7 +2033,7 @@ class FactureFournisseur extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi liste des factures remplacables * Statut validee ou abandonnee pour raison autre + non payee + aucun paiement + pas deja remplacee @@ -2042,7 +2042,7 @@ class FactureFournisseur extends CommonInvoice * @return array|int Tableau des factures ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) * <0 if error */ - function list_replacable_supplier_invoices($socid = 0) + public function list_replacable_supplier_invoices($socid = 0) { // phpcs:enable global $conf; @@ -2084,7 +2084,7 @@ class FactureFournisseur extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi liste des factures qualifiables pour correction par avoir * Les factures qui respectent les regles suivantes sont retournees: @@ -2094,7 +2094,7 @@ class FactureFournisseur extends CommonInvoice * @return array|int Tableau des factures ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) * <0 if error */ - function list_qualified_avoir_supplier_invoices($socid = 0) + public function list_qualified_avoir_supplier_invoices($socid = 0) { // phpcs:enable global $conf; @@ -2137,14 +2137,14 @@ class FactureFournisseur extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -2246,8 +2246,8 @@ class FactureFournisseur extends CommonInvoice if (! empty($this->total_ttc)) $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; - if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; - if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; + elseif ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; + elseif ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; if ($moretitle) $label.=' - '.$moretitle; $ref=$this->ref; @@ -2434,13 +2434,13 @@ class FactureFournisseur extends CommonInvoice $this->total_ttc = $xnbp*119.6; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -3187,13 +3187,13 @@ class SupplierInvoiceLine extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour de l'objet ligne de commande en base * * @return int <0 si ko, >0 si ok */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 731695d8d27..bbdea07270e 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -107,7 +107,7 @@ class ProductFournisseur extends Product * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs; @@ -118,14 +118,14 @@ class ProductFournisseur extends Product - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove all prices for this couple supplier-product * * @param int $id_fourn Supplier Id * @return int < 0 if error, > 0 if ok */ - function remove_fournisseur($id_fourn) + public function remove_fournisseur($id_fourn) { // phpcs:enable $ok=1; @@ -156,14 +156,14 @@ class ProductFournisseur extends Product } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a price for a couple supplier-product * * @param int $rowid Line id of price * @return int <0 if KO, >0 if OK */ - function remove_product_fournisseur_price($rowid) + public function remove_product_fournisseur_price($rowid) { // phpcs:enable global $conf, $user; @@ -202,7 +202,7 @@ class ProductFournisseur extends Product } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Modify the purchase price for a supplier * @@ -229,7 +229,7 @@ class ProductFournisseur extends Product * @param string $desc_fourn Custom description for product_fourn_price * @return int <0 if KO, >=0 if OK */ - function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '') + public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '') { // phpcs:enable global $conf, $langs; @@ -473,7 +473,7 @@ class ProductFournisseur extends Product } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Loads the price information of a provider * @@ -481,7 +481,7 @@ class ProductFournisseur extends Product * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead * @return int < 0 if KO, 0 if OK but not found, > 0 if OK */ - function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) + public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) { // phpcs:enable global $conf; @@ -563,7 +563,7 @@ class ProductFournisseur extends Product } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List all supplier prices of a product * @@ -574,7 +574,7 @@ class ProductFournisseur extends Product * @param int $offset Offset * @return array Array of Products with new properties to define supplier price */ - function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) + public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) { // phpcs:enable global $conf; @@ -666,7 +666,7 @@ class ProductFournisseur extends Product } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load properties for minimum price * @@ -675,7 +675,7 @@ class ProductFournisseur extends Product * @param int $socid get min price for specific supplier * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK */ - function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) + public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) { // phpcs:enable global $conf; @@ -810,7 +810,7 @@ class ProductFournisseur extends Product * @param int $expression_id Expression * @return int <0 if KO, >0 if OK */ - function setSupplierPriceExpression($expression_id) + public function setSupplierPriceExpression($expression_id) { global $conf; @@ -848,7 +848,7 @@ class ProductFournisseur extends Product * @return string String with supplier price * TODO Remove this method. Use getNomUrl directly. */ - function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) + public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) { $thirdparty = new Fournisseur($this->db); $thirdparty->fetch($this->fourn_id); @@ -856,7 +856,7 @@ class ProductFournisseur extends Product return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display price of product * @@ -868,7 +868,7 @@ class ProductFournisseur extends Product * to display in table format. * @return string String with supplier price */ - function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) + public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) { // phpcs:enable global $langs; @@ -921,7 +921,7 @@ class ProductFournisseur extends Product * @param int $offset Offset * @return array Array of Log prices */ - function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) + public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) { global $conf; @@ -967,7 +967,7 @@ class ProductFournisseur extends Product * to display in table format. * @return string HTML String with supplier price */ - function displayPriceProductFournisseurLog($productFournLogList = array()) + public function displayPriceProductFournisseurLog($productFournLogList = array()) { global $langs; @@ -1001,7 +1001,7 @@ class ProductFournisseur extends Product * @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; @@ -1056,7 +1056,7 @@ class ProductFournisseur extends Product return $result; } - + /** * Private function to log price history * diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 56d1e95a164..a5016822c66 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -48,7 +48,7 @@ class PaiementFourn extends Paiement public $picto = 'payment'; - var $statut; //Status of payment. 0 = unvalidated; 1 = validated + public $statut; //Status of payment. 0 = unvalidated; 1 = validated // fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...) // fk_paiement dans llx_paiement_facture est le rowid du paiement @@ -69,7 +69,7 @@ class PaiementFourn extends Paiement * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -82,7 +82,7 @@ class PaiementFourn extends Paiement * @param int $fk_bank Id of bank line associated to payment * @return int <0 if KO, -2 if not found, >0 if OK */ - function fetch($id, $ref = '', $fk_bank = '') + public function fetch($id, $ref = '', $fk_bank = '') { $error=0; @@ -146,7 +146,7 @@ class PaiementFourn extends Paiement * @param Societe $thirdparty Thirdparty * @return int id of created payment, < 0 if error */ - function create($user, $closepaidinvoices = 0, $thirdparty = null) + public function create($user, $closepaidinvoices = 0, $thirdparty = null) { global $langs,$conf; @@ -319,7 +319,7 @@ class PaiementFourn extends Paiement * @param int $notrigger No trigger * @return int <0 si ko, >0 si ok */ - function delete($notrigger = 0) + public function delete($notrigger = 0) { global $conf, $user, $langs; @@ -421,7 +421,7 @@ class PaiementFourn extends Paiement * @param int $id Id du paiement dont il faut afficher les infos * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, datec, fk_user_author as fk_user_creat, tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as c'; @@ -465,7 +465,7 @@ class PaiementFourn extends Paiement * @param string $filter SQL filter * @return array Array of supplier invoice id */ - function getBillsArray($filter = '') + public function getBillsArray($filter = '') { $sql = 'SELECT fk_facturefourn'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'facture_fourn as f'; @@ -503,12 +503,12 @@ class PaiementFourn extends Paiement * @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 = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -516,7 +516,7 @@ class PaiementFourn extends Paiement * @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 du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -570,7 +570,7 @@ class PaiementFourn extends Paiement * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) { global $langs; @@ -606,7 +606,7 @@ class PaiementFourn extends Paiement * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $user,$langs,$conf; @@ -631,7 +631,7 @@ class PaiementFourn extends Paiement * @param string $mode 'next' for next value or 'last' for last value * @return string free ref or last ref */ - function getNextNumRef($soc, $mode = 'next') + public function getNextNumRef($soc, $mode = 'next') { global $conf, $db, $langs; $langs->load("bills"); @@ -755,7 +755,7 @@ class PaiementFourn extends Paiement * * @return string 'dolibarr' if standard comportment or paid in dolibarr currency, 'customer' if payment received from multicurrency inputs */ - function getWay() + public function getWay() { global $conf; @@ -776,14 +776,14 @@ class PaiementFourn extends Paiement } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the third party of object, from id into this->thirdparty * * @param int $force_thirdparty_id Force thirdparty id * @return int <0 if KO, >0 if OK */ - function fetch_thirdparty($force_thirdparty_id = 0) + public function fetch_thirdparty($force_thirdparty_id = 0) { // phpcs:enable require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 353fe5273f1..644ebd79347 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1496,7 +1496,7 @@ if ($action=='create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").' '; } print ''; @@ -1558,7 +1558,7 @@ if ($action=='create') $langs->load('projects'); print '
'; } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 56bde44b7bd..48d6cd28a1e 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -484,7 +484,7 @@ $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; $sql.= ' cf.date_creation as date_creation, cf.tms as date_update,'; -$sql.= " p.rowid as project_id, p.ref as project_ref,"; +$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; $sql.= " u.firstname, u.lastname, u.photo, u.login"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); @@ -792,7 +792,7 @@ if ($resql) if (! empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type @@ -972,6 +972,7 @@ if ($resql) { $projectstatic->id=$obj->project_id; $projectstatic->ref=$obj->project_ref; + $projectstatic->title=$obj->project_title; print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 24834b508ac..3f17d9de915 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -426,7 +426,7 @@ if (empty($reshook)) //var_dump($object->getRemainToPay(0)); //var_dump($discount->amount_ttc);exit; - if ($discount->amount_ttc > $object->getRemainToPay(0)) + if (price2num($discount->amount_ttc) > price2num($object->getRemainToPay(0))) { // TODO Split the discount in 2 automatically $error++; @@ -776,7 +776,7 @@ if (empty($reshook)) $totaldeposits = $facture_source->getSumDepositsUsed(); $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); - $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 1, 0, 0, 0, 0, 0, '', '', 'TTC'); + $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 0, 0, 0, 1, 0, 0, '', '', 'TTC'); } } } @@ -1755,7 +1755,7 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '.$langs->trans("AddThirdParty").' '; } print ''; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index bfe7fb4df85..73d5a4b3a4d 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -368,7 +368,7 @@ if (! $search_all) $sql.= " typent.code,"; $sql.= " state.code_departement, state.nom,"; $sql.= ' country.code,'; - $sql.= " p.rowid, p.ref"; + $sql.= " p.rowid, p.ref, p.title"; foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by { @@ -671,7 +671,7 @@ if ($resql) if (! empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 078fcb2c59d..45146324e32 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -149,7 +149,7 @@ class Holiday extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -162,7 +162,7 @@ class Holiday extends CommonObject * @param Societe $objsoc third party object * @return string Holiday free reference */ - function getNextNumRef($objsoc) + public function getNextNumRef($objsoc) { global $langs, $conf; $langs->load("order"); @@ -221,7 +221,7 @@ class Holiday extends CommonObject * * @return int <0 if KO, >0 if OK */ - function updateBalance() + public function updateBalance() { $this->db->begin(); @@ -250,7 +250,7 @@ class Holiday 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; $error=0; @@ -336,7 +336,7 @@ class Holiday extends CommonObject * @param string $ref Ref object * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $langs; @@ -420,7 +420,7 @@ class Holiday extends CommonObject * @param string $filter SQL Filter * @return int -1 if KO, 1 if OK, 2 if no result */ - function fetchByUser($user_id, $order = '', $filter = '') + public function fetchByUser($user_id, $order = '', $filter = '') { global $langs, $conf; @@ -548,7 +548,7 @@ class Holiday extends CommonObject * @param string $filter SQL Filter * @return int -1 if KO, 1 if OK, 2 if no result */ - function fetchAll($order, $filter) + public function fetchAll($order, $filter) { global $langs; @@ -674,7 +674,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function validate($user = null, $notrigger = 0) + public function validate($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -745,7 +745,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function approve($user = null, $notrigger = 0) + public function approve($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -858,7 +858,7 @@ class Holiday 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; @@ -972,7 +972,7 @@ class Holiday 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; @@ -1022,15 +1022,15 @@ class Holiday extends CommonObject * This function can be used to avoid to have 2 leave requests on same period for example. * Warning: It consumes a lot of memory because it load in ->holiday all holiday of a dedicated user at each call. * - * @param int $fk_user Id user - * @param date $dateStart Start date of period to check - * @param date $dateEnd End date of period to check - * @param int $halfday Tag to define how start and end the period to check: - * 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning + * @param int $fk_user Id user + * @param date $dateStart Start date of period to check + * @param date $dateEnd End date of period to check + * @param int $halfday Tag to define how start and end the period to check: + * 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning * @return boolean False = New range overlap an existing holiday, True = no overlapping (is never on holiday during checked period). * @see verifDateHolidayForTimestamp */ - function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) + public function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) { $this->fetchByUser($fk_user, '', ''); @@ -1112,7 +1112,7 @@ class Holiday extends CommonObject * @return array array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. * @see verifDateHolidayCP */ - function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') + public function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') { global $langs, $conf; @@ -1175,7 +1175,7 @@ class Holiday 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, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) { global $langs; @@ -1211,12 +1211,12 @@ class Holiday 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 * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode, $this->date_debut); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the label of a statut * @@ -1225,7 +1225,7 @@ class Holiday extends CommonObject * @param date $startdate Date holiday should start * @return string Label */ - function LibStatut($statut, $mode = 0, $startdate = '') + public function LibStatut($statut, $mode = 0, $startdate = '') { // phpcs:enable global $langs; @@ -1290,7 +1290,7 @@ class Holiday extends CommonObject * @param string $htmlname Name of HTML select field * @return string Show select of status */ - function selectStatutCP($selected = '', $htmlname = 'select_statut') + public function selectStatutCP($selected = '', $htmlname = 'select_statut') { global $langs; @@ -1324,7 +1324,7 @@ class Holiday extends CommonObject * @param string $value vrai si mise à jour OK sinon faux * @return boolean ok or ko */ - function updateConfCP($name, $value) + public function updateConfCP($name, $value) { $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; @@ -1348,7 +1348,7 @@ class Holiday extends CommonObject * @param string $createifnotfound 'stringvalue'=Create entry with string value if not found. For example 'YYYYMMDDHHMMSS'. * @return string Value of parameter. Example: 'YYYYMMDDHHMMSS' or < 0 if error */ - function getConfCP($name, $createifnotfound = '') + public function getConfCP($name, $createifnotfound = '') { $sql = "SELECT value"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; @@ -1403,7 +1403,7 @@ class Holiday extends CommonObject * @param int $fk_type Type of vacation * @return int 0=Nothing done, 1=OK, -1=KO */ - function updateSoldeCP($userID = '', $nbHoliday = '', $fk_type = '') + public function updateSoldeCP($userID = '', $nbHoliday = '', $fk_type = '') { global $user, $langs; @@ -1552,7 +1552,7 @@ class Holiday extends CommonObject * @param string $name name du paramètre de configuration * @return string retourne checked si > 0 */ - function getCheckOption($name) + public function getCheckOption($name) { $sql = "SELECT value"; @@ -1579,7 +1579,7 @@ class Holiday extends CommonObject * @param int $userid Id user * @return void */ - function createCPusers($single = false, $userid = '') + public function createCPusers($single = false, $userid = '') { // Si c'est l'ensemble des utilisateurs à ajouter if (! $single) @@ -1614,7 +1614,7 @@ class Holiday extends CommonObject * @param int $user_id ID de l'utilisateur à supprimer * @return boolean Vrai si pas d'erreur, faut si Erreur */ - function deleteCPuser($user_id) + public function deleteCPuser($user_id) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_users"; @@ -1631,7 +1631,7 @@ class Holiday extends CommonObject * @param int $fk_type Filter on type * @return float Retourne le solde de congés payés de l'utilisateur */ - function getCPforUser($user_id, $fk_type = 0) + public function getCPforUser($user_id, $fk_type = 0) { $sql = "SELECT nb_holiday"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; @@ -1661,7 +1661,7 @@ class Holiday extends CommonObject * @param string $filters Filters * @return array|string|int Return an array */ - function fetchUsers($stringlist = true, $type = true, $filters = '') + public function fetchUsers($stringlist = true, $type = true, $filters = '') { global $conf; @@ -1874,14 +1874,14 @@ class Holiday extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of people with permission to validate leave requests. * Search for permission "approve leave requests" * * @return array Array of user ids */ - function fetch_users_approver_holiday() + public function fetch_users_approver_holiday() { // phpcs:enable $users_validator=array(); @@ -1922,7 +1922,7 @@ class Holiday extends CommonObject * * @return int retourne le nombre d'utilisateur */ - function countActiveUsers() + public function countActiveUsers() { $sql = "SELECT count(u.rowid) as compteur"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; @@ -1938,7 +1938,7 @@ class Holiday extends CommonObject * * @return int retourne le nombre d'utilisateur */ - function countActiveUsersWithoutCP() + public function countActiveUsersWithoutCP() { $sql = "SELECT count(u.rowid) as compteur"; @@ -1958,7 +1958,7 @@ class Holiday extends CommonObject * @param int $userCP Number of active users into table of holidays * @return int <0 if KO, >0 if OK */ - function verifNbUsers($userDolibarrWithoutCP, $userCP) + public function verifNbUsers($userDolibarrWithoutCP, $userCP) { if (empty($userCP)) $userCP=0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); @@ -1976,7 +1976,7 @@ class Holiday extends CommonObject * @param int $fk_type Type of vacation * @return int Id of record added, 0 if nothing done, < 0 if KO */ - function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type) + public function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type) { global $conf, $langs; @@ -2045,7 +2045,7 @@ class Holiday extends CommonObject * @param string $filter Filtre de séléction * @return int -1 si erreur, 1 si OK et 2 si pas de résultat */ - function fetchLog($order, $filter) + public function fetchLog($order, $filter) { global $langs; @@ -2122,7 +2122,7 @@ class Holiday extends CommonObject * @param int $affect Filter on affect (a request will change sold or not). -1 = Both * @return array Return array with list of types */ - function getTypes($active = -1, $affect = -1) + public function getTypes($active = -1, $affect = -1) { global $mysoc; @@ -2159,7 +2159,7 @@ class Holiday extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 4ea0b76a9d4..1985926563b 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -78,7 +78,7 @@ dol_fiche_head($head, 'establishments', $langs->trans("HRM"), -1, "user"); $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status"; $sql.= " FROM ".MAIN_DB_PREFIX."establishment as e"; -$sql.= " WHERE e.entity = ".$conf->entity; +$sql.= " WHERE e.entity IN (".getEntity('establishment').')'; $sql.= $db->order($sortfield, $sortorder); $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 5759d567761..8d8098642e2 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -102,7 +102,7 @@ class Establishment extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -116,7 +116,7 @@ class Establishment extends CommonObject * @param User $user User making creation * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -187,12 +187,12 @@ class Establishment extends CommonObject * @param User $user User making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { global $langs; - // Check parameters - if (empty($this->name)) + // Check parameters + if (empty($this->name)) { $this->error='ErrorBadParameter'; return -1; @@ -208,6 +208,7 @@ class Establishment extends CommonObject $sql .= ", fk_country = ".($this->country_id > 0 ? $this->country_id : 'null'); $sql .= ", status = ".$this->db->escape($this->status); $sql .= ", fk_user_mod = " . $user->id; + $sql .= ", entity = " . $this->entity; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); @@ -228,9 +229,9 @@ class Establishment extends CommonObject * @param int $id Id of record to load * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { - $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status, e.fk_country as country_id,"; + $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status, e.fk_country as country_id, e.entity,"; $sql.= ' c.code as country_code, c.label as country'; $sql.= " FROM ".MAIN_DB_PREFIX."establishment as e"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON e.fk_country = c.rowid'; @@ -249,6 +250,7 @@ class Establishment extends CommonObject $this->zip = $obj->zip; $this->town = $obj->town; $this->status = $obj->status; + $this->entity = $obj->entity; $this->country_id = $obj->country_id; $this->country_code = $obj->country_code; @@ -269,7 +271,7 @@ class Establishment extends CommonObject * @param int $id Id of record to delete * @return int <0 if KO, >0 if OK */ - function delete($id) + public function delete($id) { $this->db->begin(); @@ -296,12 +298,12 @@ class Establishment 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 * @return string Label */ - 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 /** * Give a label from a status * @@ -309,7 +311,7 @@ class Establishment 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 * @return string Label */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -350,9 +352,9 @@ class Establishment extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { - $sql = 'SELECT e.rowid, e.datec, e.fk_user_author, e.tms, e.fk_user_mod'; + $sql = 'SELECT e.rowid, e.datec, e.fk_user_author, e.tms, e.fk_user_mod, e.entity'; $sql.= ' FROM '.MAIN_DB_PREFIX.'establishment as e'; $sql.= ' WHERE e.rowid = '.$id; @@ -390,13 +392,44 @@ class Establishment extends CommonObject } } + /** + * Get on record Establishment + * + * @param int $id Id of record + * @return Object + */ + public function getEstablishment($id) + { + $sql = 'SELECT e.rowid, e.name, e.datec, e.fk_user_author, e.tms, e.fk_user_mod, e.entity'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'establishment as e'; + $sql.= ' WHERE e.rowid = '.$id; + + dol_syslog(get_class($this)."::fetch info", LOG_DEBUG); + $result = $this->db->query($sql); + + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + + return $obj; + } + /** * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @return string String with URL */ - function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0) { global $langs; @@ -415,12 +448,40 @@ class Establishment extends CommonObject return $result; } + /** + * Return clicable name (with picto eventually) + * + * @param int $id Id of record + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @return string String with URL + */ + public function getNomUrlParent($id = 0, $withpicto = 0) + { + global $langs, $conf; + + $result=''; + + $obj = $this->getEstablishment(($id>0)?$id:$conf->entity); + + $link = ''; + $linkend=''; + + $picto='building'; + + $label=$langs->trans("Show").': '.$obj->name; + + if ($withpicto) $result.=($link.img_object($label, $picto).$linkend); + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$link.$obj->name.$linkend; + return $result; + } + /** * Return account country code * * @return string country code */ - function getCountryCode() + public function getCountryCode() { global $mysoc; diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 28763f8b0f3..37a3d7f538b 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -92,8 +92,7 @@ elseif ($action == 'add') $object->status = GETPOST('status', 'int'); $object->fk_user_author = $user->id; $object->datec = dol_now(); - - + $object->entity = GETPOST('entity', 'int')>0?GETPOST('entity', 'int'):$conf->entity; $id = $object->create($user); @@ -141,6 +140,7 @@ elseif ($action == 'update') $object->country_id = GETPOST('country_id', 'int'); $object->fk_user_mod = $user->id; $object->status = GETPOST('status', 'int'); + $object->entity = GETPOST('entity', 'int')>0?GETPOST('entity', 'int'):$conf->entity; $result = $object->update($user); @@ -190,6 +190,14 @@ if ($action == 'create') print ''; print ''; + // Parent + print ''; + print ''; + print ''; + print ''; + // Address print ''; print ''; @@ -202,7 +210,7 @@ if ($action == 'create') print ''; print ''; print ''; print ''; print ''; + + // Parent + print ''; + print ''; // Address @@ -292,12 +306,12 @@ if (($id || $ref) && $action == 'edit') // Zipcode / Town print ''; print ''; @@ -366,6 +380,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; print ''; + + // Parent + print ''; + print ''; + print ''; + print ''; // Address print ''; diff --git a/htdocs/ifttt/README.md b/htdocs/ifttt/README.md new file mode 100644 index 00000000000..581853f80c6 --- /dev/null +++ b/htdocs/ifttt/README.md @@ -0,0 +1,7 @@ +API REST +======== + +## Integrate your ERP with any other applications using IFTTT + +This module provides the triggers and services to make Dolibarr compatible with IFTTT Services. + diff --git a/htdocs/ifttt/admin/index.php b/htdocs/ifttt/admin/index.php new file mode 100644 index 00000000000..d6eb777109b --- /dev/null +++ b/htdocs/ifttt/admin/index.php @@ -0,0 +1,131 @@ + + * Copyright (C) 2005-2016 Laurent Destailleur + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012-2018 Regis Houssin + * Copyright (C) 2015 Jean-François Ferry + * + * 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/ifttt/admin/index.php + * \ingroup api + * \brief Page to setup IFTTT module + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + +// Load translation files required by the page +$langs->load("admin"); + +if (! $user->admin) + accessforbidden(); + +$action=GETPOST('action', 'aZ09'); + + +if ($action == 'setproductionmode') +{ + $status = GETPOST('status', 'alpha'); + + if (dolibarr_set_const($db, 'IFTTT_PRODUCTION_MODE', $status, 'chaine', 0, '', 0) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + + +/* + * View + */ + +llxHeader(); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("IFTTTSetup"), $linkback, 'title_setup'); + +print $langs->trans("IFTTTDesc")."
\n"; +print "
\n"; + +//print '
'; +print ''; +print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; //print img_object($objexport->array_export_module[0]->getName(),$objexport->array_export_module[0]->picto).' '; print $objexport->array_export_module[0]->getName(); @@ -962,8 +946,9 @@ if ($step == 4 && $datatoexport) // Select request if all fields are selected $sqlmaxforexport=$objexport->build_sql(0, array(), array()); - print $langs->trans("ChooseFieldsOrdersAndTitle").'
'; + print '
'.$langs->trans("ChooseFieldsOrdersAndTitle").'
'; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -1034,6 +1019,7 @@ if ($step == 4 && $datatoexport) } print '
'.$langs->trans("Entities").'
'; + print '
'; print ''; @@ -1064,6 +1050,7 @@ if ($step == 4 && $datatoexport) print ''; print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -1104,6 +1091,8 @@ if ($step == 4 && $datatoexport) } print '
'.$langs->trans("ExportModelName").'
'; + print '
'; + print ''; } } @@ -1121,9 +1110,6 @@ if ($step == 5 && $datatoexport) llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones'); - /* - * Affichage onglets - */ $h = 0; $stepoffset=0; @@ -1153,7 +1139,7 @@ if ($step == 5 && $datatoexport) $hselected=$h; $h++; - dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -1); + dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -2); /* * Confirmation suppression fichier @@ -1166,7 +1152,7 @@ if ($step == 5 && $datatoexport) print '
'; print '
'; - print ''; + print '
'; // Module print ''; @@ -1193,7 +1179,7 @@ if ($step == 5 && $datatoexport) } print ''; - // List of filtered fiels + // List of filtered fields if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) { print ''; @@ -1222,9 +1208,9 @@ if ($step == 5 && $datatoexport) // List of available export formats $htmltabloflibs = '
'.$langs->trans("Module").''.$list.'
'.$langs->trans("FilteredFields").'
'; $htmltabloflibs.= ''; - $htmltabloflibs.= ''; + $htmltabloflibs.= ''; $htmltabloflibs.= ''; - $htmltabloflibs.= ''; + $htmltabloflibs.= ''; $htmltabloflibs.= ''."\n"; $liste=$objmodelexport->liste_modeles($db); @@ -1238,7 +1224,7 @@ if ($step == 5 && $datatoexport) } $htmltabloflibs.= ''; - $htmltabloflibs.= ''; @@ -1266,17 +1252,11 @@ if ($step == 5 && $datatoexport) print '
'.$langs->trans("AvailableFormats").''.$langs->trans("AvailableFormats").''.$langs->trans("LibraryUsed").''.$langs->trans("LibraryVersion").''.$langs->trans("LibraryVersion").'
'.img_picto_common($key, $objmodelexport->getPictoForKey($key)).' '; + $htmltabloflibs.= ''.img_picto_common($key, $objmodelexport->getPictoForKey($key)).' '; $text=$objmodelexport->getDriverDescForKey($key); $label=$listeall[$key]; $htmltabloflibs.= $form->textwithpicto($label, $text).'
'; - print '
'; - if (! is_dir($conf->export->dir_temp)) dol_mkdir($conf->export->dir_temp); - // Affiche liste des documents + // Show existing generated documents // NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste - print $formfile->showdocuments('export', '', $upload_dir, $_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport, $liste, 1, (! empty($_POST['model'])?$_POST['model']:'csv'), 1, 1, 0, 0, 0, '', $langs->trans('Files'), '', '', ''); - - print '
'; - - print '
'; + print $formfile->showdocuments('export', '', $upload_dir, $_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport, $liste, 1, (! empty($_POST['model'])?$_POST['model']:'csv'), 1, 1, 0, 0, 0, '', ' ', '', '', ''); } llxFooter(); diff --git a/htdocs/exports/index.php b/htdocs/exports/index.php index 698e44190dd..f84f7bb8418 100644 --- a/htdocs/exports/index.php +++ b/htdocs/exports/index.php @@ -44,50 +44,9 @@ llxHeader('', $langs->trans("ExportsArea"), 'EN:Module_Exports_En|FR:Module_Expo print load_fiche_titre($langs->trans("ExportsArea")); print $langs->trans("FormatedExportDesc1").'
'; -//print $langs->trans("FormatedExportDesc2").' '; -//print $langs->trans("FormatedExportDesc3").'
'; print '
'; -//print '
'; - - -// List export set -/* -print ''; -print ''; -print ''; -print ''; -//print ''; -print ''; -if (count($export->array_export_code)) -{ - foreach ($export->array_export_code as $key => $value) - { - - print ''; - // print ''; - print ''; - - } -} -else -{ - print ''; -} -print '
'.$langs->trans("Module").''.$langs->trans("ExportableDatas").' 
'; - //print img_object($export->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' '; - print $export->array_export_module[$key]->getName(); - print ''; - print img_object($export->array_export_module[$key]->getName(),$export->array_export_icon[$key]).' '; - $string=$langs->trans($export->array_export_label[$key]); - print ($string!=$export->array_export_label[$key]?$string:$export->array_export_label[$key]); - print ''; - // print ''.img_picto($langs->trans("NewExport"),'filenew').''; - // print '
'.$langs->trans("NoExportableData").'
'; -print '
'; -*/ - print '
'; if (count($export->array_export_code)) { @@ -99,19 +58,15 @@ if (count($export->array_export_code)) { print ''.$langs->trans("NewExport").''; } - /* - print '
rights->export->creer?'':' disabled'); - print '>
'; - */ } print '
'; print '
'; -//print '
'; // List of available export formats + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -141,9 +96,7 @@ foreach($liste as $key => $val) } print '
'.$langs->trans("AvailableFormats").'
'; - - -//print '
'; +print '
'; // End of page llxFooter(); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index eb4ca875448..987968e241f 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -948,7 +948,7 @@ if ($action == 'create') $numprojet=$formproject->select_projects($soc->id, $projectid, 'projectid'); if ($numprojet==0) { - print '   '.$langs->trans("AddProject").''; + print '   '.$langs->trans("AddProject").' '; } print '
' . $langs->trans('Project') . ''; $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">' . $langs->trans("AddProject") . ' '; print '
'; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; if ($obj->project_id > 0) print $projectstatic->getNomUrl(1); print '
'; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '
'.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).''; + print $form->selectEstablishments(GETPOST('entity', 'int')>0?GETPOST('entity', 'int'):$conf->entity, 'entity', 1); + print '
'.$form->editfieldkey('Address', 'address', '', $object, 0).'
'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; -print $formcompany->select_ziptown( + print $formcompany->select_ziptown( GETPOST('zipcode', 'alpha'), 'zipcode', array ( @@ -218,7 +226,7 @@ print $formcompany->select_ziptown( print '
'.$form->editfieldkey('Town', 'town', '', $object, 0).''; -print $formcompany->select_ziptown(GETPOST('town', 'alpha'), 'town', array ( + print $formcompany->select_ziptown(GETPOST('town', 'alpha'), 'town', array ( 'zipcode', 'selectcountry_id' )); @@ -282,6 +290,12 @@ if (($id || $ref) && $action == 'edit') // Name print '
'.$form->editfieldkey('Name', 'name', '', $object, 0, 'string', '', 1).''; print ''; + print '
'.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).''; + print $form->selectEstablishments($object->entity>0?$object->entity:$conf->entity, 'entity', 1); print '
'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; -print $formcompany->select_ziptown($object->zip, 'zipcode', array ( + print $formcompany->select_ziptown($object->zip, 'zipcode', array ( 'town', 'selectcountry_id' ), 6) . '
'.$form->editfieldkey('Town', 'town', '', $object, 0).''; -print $formcompany->select_ziptown($object->town, 'town', array ( + print $formcompany->select_ziptown($object->town, 'town', array ( 'zipcode', 'selectcountry_id' )) . '
'.$langs->trans("Name").''.$object->name.'
'.$langs->trans("Parent").''.$object->getNomUrlParent($object->entity).'
'; + +print ''; +print ""; +print '"; +print ""; +print ""; + +print ''; +print ''; +$production_mode=(empty($conf->global->IFTTT_PRODUCTION_MODE)?false:true); +if ($production_mode) +{ + print ''; +} +else +{ + print ''; +} +print ''; +print ''; + +print '
".$langs->trans("Parameter")."'.$langs->trans("Value")." 
'.$langs->trans("ProductionMode").''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ' 
'; +print '

'; + +/* + +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + +// Show message +$message=''; +$url=$urlwithroot.'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]'; +$message.=$langs->trans("UrlToGetKeyToUseAPIs").':
'; +$message.=img_picto('', 'object_globe.png').' '.$url; +print $message; +print '
'; +print '
'; + +// Explorer +print ''.$langs->trans("ApiExporerIs").':
'; +if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer')) +{ + $url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; + print img_picto('', 'object_globe.png').' '.$url."
\n"; +} +else +{ + print $langs->trans("NotAvailableWithThisDistribution"); +} + +*/ + +llxFooter(); +$db->close(); diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 59a110f5090..aebf983b541 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -27,21 +27,21 @@ */ class Import { - var $array_import_module; - var $array_import_perms; - var $array_import_icon; - var $array_import_code; - var $array_import_label; - var $array_import_tables; - var $array_import_tables_creator; - var $array_import_fields; - var $array_import_fieldshidden; - var $array_import_entities; - var $array_import_regex; - var $array_import_updatekeys; - var $array_import_examplevalues; - var $array_import_convertvalue; - var $array_import_run_sql_after; + public $array_import_module; + public $array_import_perms; + public $array_import_icon; + public $array_import_code; + public $array_import_label; + public $array_import_tables; + public $array_import_tables_creator; + public $array_import_fields; + public $array_import_fieldshidden; + public $array_import_entities; + public $array_import_regex; + public $array_import_updatekeys; + public $array_import_examplevalues; + public $array_import_convertvalue; + public $array_import_run_sql_after; /** * @var string Error code (or message) @@ -54,18 +54,18 @@ class Import public $errors = array(); - /** - * 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; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load description int this->array_import_module, this->array_import_fields, ... of an importable dataset * @@ -73,7 +73,7 @@ class Import * @param string $filter Load a particular dataset only. Index will start to 0. * @return int <0 if KO, >0 if OK */ - function load_arrays($user, $filter = '') + public function load_arrays($user, $filter = '') { // phpcs:enable global $langs,$conf; @@ -185,7 +185,7 @@ class Import - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build an import example file. * Arrays this->array_export_xxx are already loaded for required datatoexport @@ -196,7 +196,7 @@ class Import * @param string $datatoimport Dataset to import * @return string <0 if KO, >0 if OK */ - function build_example_file($model, $headerlinefields, $contentlinevalues, $datatoimport) + public function build_example_file($model, $headerlinefields, $contentlinevalues, $datatoimport) { // phpcs:enable global $conf,$langs; @@ -236,7 +236,7 @@ class Import * @param User $user Object user that save * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf; @@ -276,7 +276,7 @@ class Import * @param int $id Id of profil to load * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = 'SELECT em.rowid, em.field, em.label, em.type'; $sql.= ' FROM '.MAIN_DB_PREFIX.'import_model as em'; @@ -316,7 +316,7 @@ class Import * @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; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 7964c378003..9227998e4a0 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -345,6 +345,7 @@ if ($step == 1 || ! $datatoimport) print '
'.$langs->trans("SelectImportDataSet").'

'; // Affiche les modules d'imports + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -384,6 +385,7 @@ if ($step == 1 || ! $datatoimport) print ''; } print '
'.$langs->trans("Module").'
'.$langs->trans("NoImportableData").'
'; + print '
'; dol_fiche_end(); } @@ -402,12 +404,12 @@ if ($step == 2 && $datatoimport) $head = import_prepare_head($param, 2); - dol_fiche_head($head, 'step2', $langs->trans("NewImport"), -1); + dol_fiche_head($head, 'step2', $langs->trans("NewImport"), -2); print '
'; print '
'; - print ''; + print '
'; // Module print ''; @@ -427,7 +429,7 @@ if ($step == 2 && $datatoimport) print '
'.$langs->trans("Module").'
'; - print '

'; + print '
'; dol_fiche_end(); @@ -437,6 +439,8 @@ if ($step == 2 && $datatoimport) print ''; print ''.$langs->trans("ChooseFormatOfFileToImport", img_picto('', 'filenew')).'

'; + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; $filetoimport=''; @@ -461,7 +465,10 @@ if ($step == 2 && $datatoimport) print ''; } - print '
'; + print ''; + print '
'; + + print ''; } @@ -480,7 +487,7 @@ if ($step == 3 && $datatoimport) $head = import_prepare_head($param, 3); - dol_fiche_head($head, 'step3', $langs->trans("NewImport"), -1); + dol_fiche_head($head, 'step3', $langs->trans("NewImport"), -2); /* * Confirm delete file @@ -493,7 +500,7 @@ if ($step == 3 && $datatoimport) print '
'; print '
'; - print ''; + print '
'; // Module print ''; @@ -520,7 +527,7 @@ if ($step == 3 && $datatoimport) print '
'; print '
'; - print '
'.$langs->trans("Module").'
'; + print '
'; //print ''; // Source file format @@ -553,6 +560,7 @@ if ($step == 3 && $datatoimport) print ''.$langs->trans("ChooseFileToImport", img_picto('', 'filenew')).'

'; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'.$langs->trans("InformationOnSourceFile").'
'; $filetoimport=''; @@ -631,7 +639,10 @@ if ($step == 3 && $datatoimport) } } - print '
'; + print ''; + print '
'; + + print ''; } @@ -742,12 +753,12 @@ if ($step == 4 && $datatoimport) $head = import_prepare_head($param, 4); - dol_fiche_head($head, 'step4', $langs->trans("NewImport"), -1); + dol_fiche_head($head, 'step4', $langs->trans("NewImport"), -2); print '
'; print '
'; - print ''; + print '
'; // Module print ''; @@ -773,7 +784,7 @@ if ($step == 4 && $datatoimport) print ''.$langs->trans("InformationOnSourceFile").''; print '
'; print '
'; - print '
'.$langs->trans("Module").'
'; + print '
'; //print ''; // Source file format @@ -834,15 +845,17 @@ if ($step == 4 && $datatoimport) print ''; print ''; print ''; - print '
'.$langs->trans("InformationOnSourceFile").'
'; + + print '
'; print $langs->trans("SelectImportFields", img_picto('', 'grip_title', '')).' '; $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1); print ''; - print '
'; + print '
'; print ''; // Title of array with fields - print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; print ''; print ''; print ''; @@ -1039,6 +1052,7 @@ if ($step == 4 && $datatoimport) print ''; print '
'.$langs->trans("FieldsInSourceFile").''.$langs->trans("FieldsInTargetDatabase").'
'; + print ''; if ($conf->use_javascript_ajax) @@ -1103,7 +1117,7 @@ if ($step == 4 && $datatoimport) { print '
'."\n"; print ''."\n"; - print $langs->trans("SaveImportModel"); + print '
'.$langs->trans("SaveImportModel").'
'; print '
'; print ''; @@ -1215,12 +1229,12 @@ if ($step == 5 && $datatoimport) print ''; // step 5 print ''; // step 5 - dol_fiche_head($head, 'step5', $langs->trans("NewImport"), -1); + dol_fiche_head($head, 'step5', $langs->trans("NewImport"), -2); print '
'; print '
'; - print ''; + print '
'; // Module print ''; @@ -1246,7 +1260,7 @@ if ($step == 5 && $datatoimport) print ''.$langs->trans("InformationOnSourceFile").''; print '
'; print '
'; - print '
'.$langs->trans("Module").'
'; + print '
'; //print ''; // Source file format @@ -1352,8 +1366,7 @@ if ($step == 5 && $datatoimport) print '
'; print '
'; - print '
'.$langs->trans("InformationOnSourceFile").'
'; - //print ''; + print '
'.$langs->trans("InformationOnTargetTables").'
'; // Tables imported print '\n"; - print ""; } else { @@ -302,13 +302,13 @@ if ($result) print "\n"; //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++; @@ -330,13 +330,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 "
'; @@ -1578,7 +1591,7 @@ if ($step == 5 && $datatoimport) $importid=dol_print_date(dol_now(), '%Y%m%d%H%M%S'); print '
'; - print $langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).'
'; + print ''.$langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).'
'; if (empty($nboferrors)) print $langs->trans("DataLoadedWithId", $importid).'
'; print '
'; diff --git a/htdocs/includes/jquery/js/jquery-migrate.js b/htdocs/includes/jquery/js/jquery-migrate.js deleted file mode 100644 index 350b79958d1..00000000000 --- a/htdocs/includes/jquery/js/jquery-migrate.js +++ /dev/null @@ -1,540 +0,0 @@ -/*! - * jQuery Migrate - v3.0.0 - 2016-06-09 - * Copyright jQuery Foundation and other contributors - */ -(function( jQuery, window ) { -"use strict"; - - -jQuery.migrateVersion = "3.0.0"; - - -( function() { - - // Support: IE9 only - // IE9 only creates console object when dev tools are first opened - // Also, avoid Function#bind here to simplify PhantomJS usage - var log = window.console && window.console.log && - function() { window.console.log.apply( window.console, arguments ); }, - rbadVersions = /^[12]\./; - - if ( !log ) { - return; - } - - // Need jQuery 3.0.0+ and no older Migrate loaded - if ( !jQuery || rbadVersions.test( jQuery.fn.jquery ) ) { - log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" ); - } - if ( jQuery.migrateWarnings ) { - log( "JQMIGRATE: Migrate plugin loaded multiple times" ); - } - - // Show a message on the console so devs know we're active - log( "JQMIGRATE: Migrate is installed" + - ( jQuery.migrateMute ? "" : " with logging active" ) + - ", version " + jQuery.migrateVersion ); - -} )(); - -var warnedAbout = {}; - -// List of warnings already given; public read only -jQuery.migrateWarnings = []; - -// Set to false to disable traces that appear with warnings -if ( jQuery.migrateTrace === undefined ) { - jQuery.migrateTrace = true; -} - -// Forget any warnings we've already given; public -jQuery.migrateReset = function() { - warnedAbout = {}; - jQuery.migrateWarnings.length = 0; -}; - -function migrateWarn( msg ) { - var console = window.console; - if ( !warnedAbout[ msg ] ) { - warnedAbout[ msg ] = true; - jQuery.migrateWarnings.push( msg ); - if ( console && console.warn && !jQuery.migrateMute ) { - console.warn( "JQMIGRATE: " + msg ); - if ( jQuery.migrateTrace && console.trace ) { - console.trace(); - } - } - } -} - -function migrateWarnProp( obj, prop, value, msg ) { - Object.defineProperty( obj, prop, { - configurable: true, - enumerable: true, - get: function() { - migrateWarn( msg ); - return value; - } - } ); -} - -if ( document.compatMode === "BackCompat" ) { - - // JQuery has never supported or tested Quirks Mode - migrateWarn( "jQuery is not compatible with Quirks Mode" ); -} - - -var oldInit = jQuery.fn.init, - oldIsNumeric = jQuery.isNumeric, - oldFind = jQuery.find, - rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, - rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g; - -jQuery.fn.init = function( arg1 ) { - var args = Array.prototype.slice.call( arguments ); - - if ( typeof arg1 === "string" && arg1 === "#" ) { - - // JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0 - migrateWarn( "jQuery( '#' ) is not a valid selector" ); - args[ 0 ] = []; - } - - return oldInit.apply( this, args ); -}; -jQuery.fn.init.prototype = jQuery.fn; - -jQuery.find = function( selector ) { - var args = Array.prototype.slice.call( arguments ); - - // Support: PhantomJS 1.x - // String#match fails to match when used with a //g RegExp, only on some strings - if ( typeof selector === "string" && rattrHashTest.test( selector ) ) { - - // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0 - // First see if qS thinks it's a valid selector, if so avoid a false positive - try { - document.querySelector( selector ); - } catch ( err1 ) { - - // Didn't *look* valid to qSA, warn and try quoting what we think is the value - selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) { - return "[" + attr + op + "\"" + value + "\"]"; - } ); - - // If the regexp *may* have created an invalid selector, don't update it - // Note that there may be false alarms if selector uses jQuery extensions - try { - document.querySelector( selector ); - migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] ); - args[ 0 ] = selector; - } catch ( err2 ) { - migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] ); - } - } - } - - return oldFind.apply( this, args ); -}; - -// Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) -var findProp; -for ( findProp in oldFind ) { - if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { - jQuery.find[ findProp ] = oldFind[ findProp ]; - } -} - -// The number of elements contained in the matched element set -jQuery.fn.size = function() { - migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" ); - return this.length; -}; - -jQuery.parseJSON = function() { - migrateWarn( "jQuery.parseJSON is deprecated; use JSON.parse" ); - return JSON.parse.apply( null, arguments ); -}; - -jQuery.isNumeric = function( val ) { - - // The jQuery 2.2.3 implementation of isNumeric - function isNumeric2( obj ) { - var realStringObj = obj && obj.toString(); - return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0; - } - - var newValue = oldIsNumeric( val ), - oldValue = isNumeric2( val ); - - if ( newValue !== oldValue ) { - migrateWarn( "jQuery.isNumeric() should not be called on constructed objects" ); - } - - return oldValue; -}; - -migrateWarnProp( jQuery, "unique", jQuery.uniqueSort, - "jQuery.unique is deprecated, use jQuery.uniqueSort" ); - -// Now jQuery.expr.pseudos is the standard incantation -migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos, - "jQuery.expr.filters is now jQuery.expr.pseudos" ); -migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos, - "jQuery.expr[\":\"] is now jQuery.expr.pseudos" ); - - -var oldAjax = jQuery.ajax; - -jQuery.ajax = function( ) { - var jQXHR = oldAjax.apply( this, arguments ); - - // Be sure we got a jQXHR (e.g., not sync) - if ( jQXHR.promise ) { - migrateWarnProp( jQXHR, "success", jQXHR.done, - "jQXHR.success is deprecated and removed" ); - migrateWarnProp( jQXHR, "error", jQXHR.fail, - "jQXHR.error is deprecated and removed" ); - migrateWarnProp( jQXHR, "complete", jQXHR.always, - "jQXHR.complete is deprecated and removed" ); - } - - return jQXHR; -}; - - -var oldRemoveAttr = jQuery.fn.removeAttr, - oldToggleClass = jQuery.fn.toggleClass, - rmatchNonSpace = /\S+/g; - -jQuery.fn.removeAttr = function( name ) { - var self = this; - - jQuery.each( name.match( rmatchNonSpace ), function( i, attr ) { - if ( jQuery.expr.match.bool.test( attr ) ) { - migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr ); - self.prop( attr, false ); - } - } ); - - return oldRemoveAttr.apply( this, arguments ); -}; - -jQuery.fn.toggleClass = function( state ) { - - // Only deprecating no-args or single boolean arg - if ( state !== undefined && typeof state !== "boolean" ) { - return oldToggleClass.apply( this, arguments ); - } - - migrateWarn( "jQuery.fn.toggleClass( boolean ) is deprecated" ); - - // Toggle entire class name of each element - return this.each( function() { - var className = this.getAttribute && this.getAttribute( "class" ) || ""; - - if ( className ) { - jQuery.data( this, "__className__", className ); - } - - // If the element has a class name or if we're passed `false`, - // then remove the whole classname (if there was one, the above saved it). - // Otherwise bring back whatever was previously saved (if anything), - // falling back to the empty string if nothing was stored. - if ( this.setAttribute ) { - this.setAttribute( "class", - className || state === false ? - "" : - jQuery.data( this, "__className__" ) || "" - ); - } - } ); -}; - - -var internalSwapCall = false; - -// If this version of jQuery has .swap(), don't false-alarm on internal uses -if ( jQuery.swap ) { - jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) { - var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get; - - if ( oldHook ) { - jQuery.cssHooks[ name ].get = function() { - var ret; - - internalSwapCall = true; - ret = oldHook.apply( this, arguments ); - internalSwapCall = false; - return ret; - }; - } - } ); -} - -jQuery.swap = function( elem, options, callback, args ) { - var ret, name, - old = {}; - - if ( !internalSwapCall ) { - migrateWarn( "jQuery.swap() is undocumented and deprecated" ); - } - - // Remember the old values, and insert the new ones - for ( name in options ) { - old[ name ] = elem.style[ name ]; - elem.style[ name ] = options[ name ]; - } - - ret = callback.apply( elem, args || [] ); - - // Revert the old values - for ( name in options ) { - elem.style[ name ] = old[ name ]; - } - - return ret; -}; - -var oldData = jQuery.data; - -jQuery.data = function( elem, name, value ) { - var curData; - - // If the name is transformed, look for the un-transformed name in the data object - if ( name && name !== jQuery.camelCase( name ) ) { - curData = jQuery.hasData( elem ) && oldData.call( this, elem ); - if ( curData && name in curData ) { - migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name ); - if ( arguments.length > 2 ) { - curData[ name ] = value; - } - return curData[ name ]; - } - } - - return oldData.apply( this, arguments ); -}; - -var oldTweenRun = jQuery.Tween.prototype.run; - -jQuery.Tween.prototype.run = function( percent ) { - if ( jQuery.easing[ this.easing ].length > 1 ) { - migrateWarn( - "easing function " + - "\"jQuery.easing." + this.easing.toString() + - "\" should use only first argument" - ); - - jQuery.easing[ this.easing ] = jQuery.easing[ this.easing ].bind( - jQuery.easing, - percent, this.options.duration * percent, 0, 1, this.options.duration - ); - } - - oldTweenRun.apply( this, arguments ); -}; - -var oldLoad = jQuery.fn.load, - originalFix = jQuery.event.fix; - -jQuery.event.props = []; -jQuery.event.fixHooks = {}; - -jQuery.event.fix = function( originalEvent ) { - var event, - type = originalEvent.type, - fixHook = this.fixHooks[ type ], - props = jQuery.event.props; - - if ( props.length ) { - migrateWarn( "jQuery.event.props are deprecated and removed: " + props.join() ); - while ( props.length ) { - jQuery.event.addProp( props.pop() ); - } - } - - if ( fixHook && !fixHook._migrated_ ) { - fixHook._migrated_ = true; - migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type ); - if ( ( props = fixHook.props ) && props.length ) { - while ( props.length ) { - jQuery.event.addProp( props.pop() ); - } - } - } - - event = originalFix.call( this, originalEvent ); - - return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event; -}; - -jQuery.each( [ "load", "unload", "error" ], function( _, name ) { - - jQuery.fn[ name ] = function() { - var args = Array.prototype.slice.call( arguments, 0 ); - - // If this is an ajax load() the first arg should be the string URL; - // technically this could also be the "Anything" arg of the event .load() - // which just goes to show why this dumb signature has been deprecated! - // jQuery custom builds that exclude the Ajax module justifiably die here. - if ( name === "load" && typeof args[ 0 ] === "string" ) { - return oldLoad.apply( this, args ); - } - - migrateWarn( "jQuery.fn." + name + "() is deprecated" ); - - args.splice( 0, 0, name ); - if ( arguments.length ) { - return this.on.apply( this, args ); - } - - // Use .triggerHandler here because: - // - load and unload events don't need to bubble, only applied to window or image - // - error event should not bubble to window, although it does pre-1.7 - // See http://bugs.jquery.com/ticket/11820 - this.triggerHandler.apply( this, args ); - return this; - }; - -} ); - -// Trigger "ready" event only once, on document ready -jQuery( function() { - jQuery( document ).triggerHandler( "ready" ); -} ); - -jQuery.event.special.ready = { - setup: function() { - if ( this === document ) { - migrateWarn( "'ready' event is deprecated" ); - } - } -}; - -jQuery.fn.extend( { - - bind: function( types, data, fn ) { - migrateWarn( "jQuery.fn.bind() is deprecated" ); - return this.on( types, null, data, fn ); - }, - unbind: function( types, fn ) { - migrateWarn( "jQuery.fn.unbind() is deprecated" ); - return this.off( types, null, fn ); - }, - delegate: function( selector, types, data, fn ) { - migrateWarn( "jQuery.fn.delegate() is deprecated" ); - return this.on( types, selector, data, fn ); - }, - undelegate: function( selector, types, fn ) { - migrateWarn( "jQuery.fn.undelegate() is deprecated" ); - return arguments.length === 1 ? - this.off( selector, "**" ) : - this.off( types, selector || "**", fn ); - } -} ); - - -var oldOffset = jQuery.fn.offset; - -jQuery.fn.offset = function() { - var docElem, - elem = this[ 0 ], - origin = { top: 0, left: 0 }; - - if ( !elem || !elem.nodeType ) { - migrateWarn( "jQuery.fn.offset() requires a valid DOM element" ); - return origin; - } - - docElem = ( elem.ownerDocument || document ).documentElement; - if ( !jQuery.contains( docElem, elem ) ) { - migrateWarn( "jQuery.fn.offset() requires an element connected to a document" ); - return origin; - } - - return oldOffset.apply( this, arguments ); -}; - - -var oldParam = jQuery.param; - -jQuery.param = function( data, traditional ) { - var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; - - if ( traditional === undefined && ajaxTraditional ) { - - migrateWarn( "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" ); - traditional = ajaxTraditional; - } - - return oldParam.call( this, data, traditional ); -}; - -var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack; - -jQuery.fn.andSelf = function() { - migrateWarn( "jQuery.fn.andSelf() replaced by jQuery.fn.addBack()" ); - return oldSelf.apply( this, arguments ); -}; - - -var oldDeferred = jQuery.Deferred, - tuples = [ - - // Action, add listener, callbacks, .then handlers, final state - [ "resolve", "done", jQuery.Callbacks( "once memory" ), - jQuery.Callbacks( "once memory" ), "resolved" ], - [ "reject", "fail", jQuery.Callbacks( "once memory" ), - jQuery.Callbacks( "once memory" ), "rejected" ], - [ "notify", "progress", jQuery.Callbacks( "memory" ), - jQuery.Callbacks( "memory" ) ] - ]; - -jQuery.Deferred = function( func ) { - var deferred = oldDeferred(), - promise = deferred.promise(); - - deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) { - var fns = arguments; - - migrateWarn( "deferred.pipe() is deprecated" ); - - return jQuery.Deferred( function( newDefer ) { - jQuery.each( tuples, function( i, tuple ) { - var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; - - // Deferred.done(function() { bind to newDefer or newDefer.resolve }) - // deferred.fail(function() { bind to newDefer or newDefer.reject }) - // deferred.progress(function() { bind to newDefer or newDefer.notify }) - deferred[ tuple[ 1 ] ]( function() { - var returned = fn && fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise() - .done( newDefer.resolve ) - .fail( newDefer.reject ) - .progress( newDefer.notify ); - } else { - newDefer[ tuple[ 0 ] + "With" ]( - this === promise ? newDefer.promise() : this, - fn ? [ returned ] : arguments - ); - } - } ); - } ); - fns = null; - } ).promise(); - - }; - - if ( func ) { - func.call( deferred, deferred ); - } - - return deferred; -}; - - - -})( jQuery, window ); \ No newline at end of file diff --git a/htdocs/includes/jquery/js/jquery-migrate.min.js b/htdocs/includes/jquery/js/jquery-migrate.min.js deleted file mode 100644 index a2813c5d2d8..00000000000 --- a/htdocs/includes/jquery/js/jquery-migrate.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! jQuery Migrate v3.0.0 | (c) jQuery Foundation and other contributors | jquery.org/license */ -"undefined"==typeof jQuery.migrateMute&&(jQuery.migrateMute=!0),function(a,b){"use strict";function c(c){var d=b.console;e[c]||(e[c]=!0,a.migrateWarnings.push(c),d&&d.warn&&!a.migrateMute&&(d.warn("JQMIGRATE: "+c),a.migrateTrace&&d.trace&&d.trace()))}function d(a,b,d,e){Object.defineProperty(a,b,{configurable:!0,enumerable:!0,get:function(){return c(e),d}})}a.migrateVersion="3.0.0",function(){var c=b.console&&b.console.log&&function(){b.console.log.apply(b.console,arguments)},d=/^[12]\./;c&&(a&&!d.test(a.fn.jquery)||c("JQMIGRATE: jQuery 3.0.0+ REQUIRED"),a.migrateWarnings&&c("JQMIGRATE: Migrate plugin loaded multiple times"),c("JQMIGRATE: Migrate is installed"+(a.migrateMute?"":" with logging active")+", version "+a.migrateVersion))}();var e={};a.migrateWarnings=[],void 0===a.migrateTrace&&(a.migrateTrace=!0),a.migrateReset=function(){e={},a.migrateWarnings.length=0},"BackCompat"===document.compatMode&&c("jQuery is not compatible with Quirks Mode");var f=a.fn.init,g=a.isNumeric,h=a.find,i=/\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,j=/\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g;a.fn.init=function(a){var b=Array.prototype.slice.call(arguments);return"string"==typeof a&&"#"===a&&(c("jQuery( '#' ) is not a valid selector"),b[0]=[]),f.apply(this,b)},a.fn.init.prototype=a.fn,a.find=function(a){var b=Array.prototype.slice.call(arguments);if("string"==typeof a&&i.test(a))try{document.querySelector(a)}catch(d){a=a.replace(j,function(a,b,c,d){return"["+b+c+'"'+d+'"]'});try{document.querySelector(a),c("Attribute selector with '#' must be quoted: "+b[0]),b[0]=a}catch(e){c("Attribute selector with '#' was not fixed: "+b[0])}}return h.apply(this,b)};var k;for(k in h)Object.prototype.hasOwnProperty.call(h,k)&&(a.find[k]=h[k]);a.fn.size=function(){return c("jQuery.fn.size() is deprecated; use the .length property"),this.length},a.parseJSON=function(){return c("jQuery.parseJSON is deprecated; use JSON.parse"),JSON.parse.apply(null,arguments)},a.isNumeric=function(b){function d(b){var c=b&&b.toString();return!a.isArray(b)&&c-parseFloat(c)+1>=0}var e=g(b),f=d(b);return e!==f&&c("jQuery.isNumeric() should not be called on constructed objects"),f},d(a,"unique",a.uniqueSort,"jQuery.unique is deprecated, use jQuery.uniqueSort"),d(a.expr,"filters",a.expr.pseudos,"jQuery.expr.filters is now jQuery.expr.pseudos"),d(a.expr,":",a.expr.pseudos,'jQuery.expr[":"] is now jQuery.expr.pseudos');var l=a.ajax;a.ajax=function(){var a=l.apply(this,arguments);return a.promise&&(d(a,"success",a.done,"jQXHR.success is deprecated and removed"),d(a,"error",a.fail,"jQXHR.error is deprecated and removed"),d(a,"complete",a.always,"jQXHR.complete is deprecated and removed")),a};var m=a.fn.removeAttr,n=a.fn.toggleClass,o=/\S+/g;a.fn.removeAttr=function(b){var d=this;return a.each(b.match(o),function(b,e){a.expr.match.bool.test(e)&&(c("jQuery.fn.removeAttr no longer sets boolean properties: "+e),d.prop(e,!1))}),m.apply(this,arguments)},a.fn.toggleClass=function(b){return void 0!==b&&"boolean"!=typeof b?n.apply(this,arguments):(c("jQuery.fn.toggleClass( boolean ) is deprecated"),this.each(function(){var c=this.getAttribute&&this.getAttribute("class")||"";c&&a.data(this,"__className__",c),this.setAttribute&&this.setAttribute("class",c||b===!1?"":a.data(this,"__className__")||"")}))};var p=!1;a.swap&&a.each(["height","width","reliableMarginRight"],function(b,c){var d=a.cssHooks[c]&&a.cssHooks[c].get;d&&(a.cssHooks[c].get=function(){var a;return p=!0,a=d.apply(this,arguments),p=!1,a})}),a.swap=function(a,b,d,e){var f,g,h={};p||c("jQuery.swap() is undocumented and deprecated");for(g in b)h[g]=a.style[g],a.style[g]=b[g];f=d.apply(a,e||[]);for(g in b)a.style[g]=h[g];return f};var q=a.data;a.data=function(b,d,e){var f;return d&&d!==a.camelCase(d)&&(f=a.hasData(b)&&q.call(this,b),f&&d in f)?(c("jQuery.data() always sets/gets camelCased names: "+d),arguments.length>2&&(f[d]=e),f[d]):q.apply(this,arguments)};var r=a.Tween.prototype.run;a.Tween.prototype.run=function(b){a.easing[this.easing].length>1&&(c('easing function "jQuery.easing.'+this.easing.toString()+'" should use only first argument'),a.easing[this.easing]=a.easing[this.easing].bind(a.easing,b,this.options.duration*b,0,1,this.options.duration)),r.apply(this,arguments)};var s=a.fn.load,t=a.event.fix;a.event.props=[],a.event.fixHooks={},a.event.fix=function(b){var d,e=b.type,f=this.fixHooks[e],g=a.event.props;if(g.length)for(c("jQuery.event.props are deprecated and removed: "+g.join());g.length;)a.event.addProp(g.pop());if(f&&!f._migrated_&&(f._migrated_=!0,c("jQuery.event.fixHooks are deprecated and removed: "+e),(g=f.props)&&g.length))for(;g.length;)a.event.addProp(g.pop());return d=t.call(this,b),f&&f.filter?f.filter(d,b):d},a.each(["load","unload","error"],function(b,d){a.fn[d]=function(){var a=Array.prototype.slice.call(arguments,0);return"load"===d&&"string"==typeof a[0]?s.apply(this,a):(c("jQuery.fn."+d+"() is deprecated"),a.splice(0,0,d),arguments.length?this.on.apply(this,a):(this.triggerHandler.apply(this,a),this))}}),a(function(){a(document).triggerHandler("ready")}),a.event.special.ready={setup:function(){this===document&&c("'ready' event is deprecated")}},a.fn.extend({bind:function(a,b,d){return c("jQuery.fn.bind() is deprecated"),this.on(a,null,b,d)},unbind:function(a,b){return c("jQuery.fn.unbind() is deprecated"),this.off(a,null,b)},delegate:function(a,b,d,e){return c("jQuery.fn.delegate() is deprecated"),this.on(b,a,d,e)},undelegate:function(a,b,d){return c("jQuery.fn.undelegate() is deprecated"),1===arguments.length?this.off(a,"**"):this.off(b,a||"**",d)}});var u=a.fn.offset;a.fn.offset=function(){var b,d=this[0],e={top:0,left:0};return d&&d.nodeType?(b=(d.ownerDocument||document).documentElement,a.contains(b,d)?u.apply(this,arguments):(c("jQuery.fn.offset() requires an element connected to a document"),e)):(c("jQuery.fn.offset() requires a valid DOM element"),e)};var v=a.param;a.param=function(b,d){var e=a.ajaxSettings&&a.ajaxSettings.traditional;return void 0===d&&e&&(c("jQuery.param() no longer uses jQuery.ajaxSettings.traditional"),d=e),v.call(this,b,d)};var w=a.fn.andSelf||a.fn.addBack;a.fn.andSelf=function(){return c("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()"),w.apply(this,arguments)};var x=a.Deferred,y=[["resolve","done",a.Callbacks("once memory"),a.Callbacks("once memory"),"resolved"],["reject","fail",a.Callbacks("once memory"),a.Callbacks("once memory"),"rejected"],["notify","progress",a.Callbacks("memory"),a.Callbacks("memory")]];a.Deferred=function(b){var d=x(),e=d.promise();return d.pipe=e.pipe=function(){var b=arguments;return c("deferred.pipe() is deprecated"),a.Deferred(function(c){a.each(y,function(f,g){var h=a.isFunction(b[f])&&b[f];d[g[1]](function(){var b=h&&h.apply(this,arguments);b&&a.isFunction(b.promise)?b.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[g[0]+"With"](this===e?c.promise():this,h?[b]:arguments)})}),b=null}).promise()},b&&b.call(d,d),d}}(jQuery,window); \ No newline at end of file diff --git a/htdocs/includes/jquery/js/jquery.js b/htdocs/includes/jquery/js/jquery.js index 072e308110f..9b5206bcc60 100644 --- a/htdocs/includes/jquery/js/jquery.js +++ b/htdocs/includes/jquery/js/jquery.js @@ -1,15 +1,15 @@ /*! - * jQuery JavaScript Library v3.1.1 + * jQuery JavaScript Library v3.3.1 * https://jquery.com/ * * Includes Sizzle.js * https://sizzlejs.com/ * - * Copyright jQuery Foundation and other contributors + * Copyright JS Foundation and other contributors * Released under the MIT license * https://jquery.org/license * - * Date: 2016-09-22T22:30Z + * Date: 2018-01-20T17:24Z */ ( function( global, factory ) { @@ -71,16 +71,57 @@ var ObjectFunctionString = fnToString.call( Object ); var support = {}; +var isFunction = function isFunction( obj ) { + + // Support: Chrome <=57, Firefox <=52 + // In some browsers, typeof returns "function" for HTML elements + // (i.e., `typeof document.createElement( "object" ) === "function"`). + // We don't want to classify *any* DOM node as a function. + return typeof obj === "function" && typeof obj.nodeType !== "number"; + }; - function DOMEval( code, doc ) { +var isWindow = function isWindow( obj ) { + return obj != null && obj === obj.window; + }; + + + + + var preservedScriptAttributes = { + type: true, + src: true, + noModule: true + }; + + function DOMEval( code, doc, node ) { doc = doc || document; - var script = doc.createElement( "script" ); + var i, + script = doc.createElement( "script" ); script.text = code; + if ( node ) { + for ( i in preservedScriptAttributes ) { + if ( node[ i ] ) { + script[ i ] = node[ i ]; + } + } + } doc.head.appendChild( script ).parentNode.removeChild( script ); } + + +function toType( obj ) { + if ( obj == null ) { + return obj + ""; + } + + // Support: Android <=2.3 only (functionish RegExp) + return typeof obj === "object" || typeof obj === "function" ? + class2type[ toString.call( obj ) ] || "object" : + typeof obj; +} /* global Symbol */ // Defining this global in .eslintrc.json would create a danger of using the global // unguarded in another place, it seems safer to define global only for this module @@ -88,7 +129,7 @@ var support = {}; var - version = "3.1.1", + version = "3.3.1", // Define a local copy of jQuery jQuery = function( selector, context ) { @@ -100,16 +141,7 @@ var // Support: Android <=4.0 only // Make sure we trim BOM and NBSP - rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, - - // Matches dashed string for camelizing - rmsPrefix = /^-ms-/, - rdashAlpha = /-([a-z])/g, - - // Used by jQuery.camelCase as callback to replace() - fcamelCase = function( all, letter ) { - return letter.toUpperCase(); - }; + rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; jQuery.fn = jQuery.prototype = { @@ -209,7 +241,7 @@ jQuery.extend = jQuery.fn.extend = function() { } // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { + if ( typeof target !== "object" && !isFunction( target ) ) { target = {}; } @@ -236,11 +268,11 @@ jQuery.extend = jQuery.fn.extend = function() { // Recurse if we're merging plain objects or arrays if ( deep && copy && ( jQuery.isPlainObject( copy ) || - ( copyIsArray = jQuery.isArray( copy ) ) ) ) { + ( copyIsArray = Array.isArray( copy ) ) ) ) { if ( copyIsArray ) { copyIsArray = false; - clone = src && jQuery.isArray( src ) ? src : []; + clone = src && Array.isArray( src ) ? src : []; } else { clone = src && jQuery.isPlainObject( src ) ? src : {}; @@ -275,30 +307,6 @@ jQuery.extend( { noop: function() {}, - isFunction: function( obj ) { - return jQuery.type( obj ) === "function"; - }, - - isArray: Array.isArray, - - isWindow: function( obj ) { - return obj != null && obj === obj.window; - }, - - isNumeric: function( obj ) { - - // As of jQuery 3.0, isNumeric is limited to - // strings and numbers (primitives or objects) - // that can be coerced to finite numbers (gh-2662) - var type = jQuery.type( obj ); - return ( type === "number" || type === "string" ) && - - // parseFloat NaNs numeric-cast false positives ("") - // ...but misinterprets leading-number strings, particularly hex literals ("0x...") - // subtraction forces infinities to NaN - !isNaN( obj - parseFloat( obj ) ); - }, - isPlainObject: function( obj ) { var proto, Ctor; @@ -332,33 +340,11 @@ jQuery.extend( { return true; }, - type: function( obj ) { - if ( obj == null ) { - return obj + ""; - } - - // Support: Android <=2.3 only (functionish RegExp) - return typeof obj === "object" || typeof obj === "function" ? - class2type[ toString.call( obj ) ] || "object" : - typeof obj; - }, - // Evaluates a script in a global context globalEval: function( code ) { DOMEval( code ); }, - // Convert dashed to camelCase; used by the css and data modules - // Support: IE <=9 - 11, Edge 12 - 13 - // Microsoft forgot to hump their vendor prefix (#9572) - camelCase: function( string ) { - return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); - }, - each: function( obj, callback ) { var length, i = 0; @@ -479,37 +465,6 @@ jQuery.extend( { // A global GUID counter for objects guid: 1, - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function( fn, context ) { - var tmp, args, proxy; - - if ( typeof context === "string" ) { - tmp = fn[ context ]; - context = fn; - fn = tmp; - } - - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if ( !jQuery.isFunction( fn ) ) { - return undefined; - } - - // Simulated bind - args = slice.call( arguments, 2 ); - proxy = function() { - return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); - }; - - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || jQuery.guid++; - - return proxy; - }, - - now: Date.now, - // jQuery.support is not used in Core but other projects attach their // properties to it so it needs to exist. support: support @@ -532,9 +487,9 @@ function isArrayLike( obj ) { // hasOwn isn't used here due to false negatives // regarding Nodelist length in IE var length = !!obj && "length" in obj && obj.length, - type = jQuery.type( obj ); + type = toType( obj ); - if ( type === "function" || jQuery.isWindow( obj ) ) { + if ( isFunction( obj ) || isWindow( obj ) ) { return false; } @@ -2843,15 +2798,20 @@ var siblings = function( n, elem ) { var rneedsContext = jQuery.expr.match.needsContext; + + +function nodeName( elem, name ) { + + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + +}; var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); -var risSimple = /^.[^:#\[\.,]*$/; - // Implement the identical functionality for filter and not function winnow( elements, qualifier, not ) { - if ( jQuery.isFunction( qualifier ) ) { + if ( isFunction( qualifier ) ) { return jQuery.grep( elements, function( elem, i ) { return !!qualifier.call( elem, i, elem ) !== not; } ); @@ -2871,16 +2831,8 @@ function winnow( elements, qualifier, not ) { } ); } - // Simple selector that can be filtered directly, removing non-Elements - if ( risSimple.test( qualifier ) ) { - return jQuery.filter( qualifier, elements, not ); - } - - // Complex selector, compare the two sets, removing non-Elements - qualifier = jQuery.filter( qualifier, elements ); - return jQuery.grep( elements, function( elem ) { - return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1; - } ); + // Filtered directly for both simple and complex selectors + return jQuery.filter( qualifier, elements, not ); } jQuery.filter = function( expr, elems, not ) { @@ -3001,7 +2953,7 @@ var rootjQuery, for ( match in context ) { // Properties of context are called as methods if possible - if ( jQuery.isFunction( this[ match ] ) ) { + if ( isFunction( this[ match ] ) ) { this[ match ]( context[ match ] ); // ...and otherwise set as attributes @@ -3044,7 +2996,7 @@ var rootjQuery, // HANDLE: $(function) // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { + } else if ( isFunction( selector ) ) { return root.ready !== undefined ? root.ready( selector ) : @@ -3194,7 +3146,18 @@ jQuery.each( { return siblings( elem.firstChild ); }, contents: function( elem ) { - return elem.contentDocument || jQuery.merge( [], elem.childNodes ); + if ( nodeName( elem, "iframe" ) ) { + return elem.contentDocument; + } + + // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only + // Treat the template element as a regular one in browsers that + // don't support it. + if ( nodeName( elem, "template" ) ) { + elem = elem.content || elem; + } + + return jQuery.merge( [], elem.childNodes ); } }, function( name, fn ) { jQuery.fn[ name ] = function( until, selector ) { @@ -3292,7 +3255,7 @@ jQuery.Callbacks = function( options ) { fire = function() { // Enforce single-firing - locked = options.once; + locked = locked || options.once; // Execute callbacks for all pending executions, // respecting firingIndex overrides and runtime changes @@ -3348,11 +3311,11 @@ jQuery.Callbacks = function( options ) { ( function add( args ) { jQuery.each( args, function( _, arg ) { - if ( jQuery.isFunction( arg ) ) { + if ( isFunction( arg ) ) { if ( !options.unique || !self.has( arg ) ) { list.push( arg ); } - } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { + } else if ( arg && arg.length && toType( arg ) !== "string" ) { // Inspect recursively add( arg ); @@ -3461,25 +3424,26 @@ function Thrower( ex ) { throw ex; } -function adoptValue( value, resolve, reject ) { +function adoptValue( value, resolve, reject, noValue ) { var method; try { // Check for promise aspect first to privilege synchronous behavior - if ( value && jQuery.isFunction( ( method = value.promise ) ) ) { + if ( value && isFunction( ( method = value.promise ) ) ) { method.call( value ).done( resolve ).fail( reject ); // Other thenables - } else if ( value && jQuery.isFunction( ( method = value.then ) ) ) { + } else if ( value && isFunction( ( method = value.then ) ) ) { method.call( value, resolve, reject ); // Other non-thenables } else { - // Support: Android 4.0 only - // Strict mode functions invoked without .call/.apply get global-object context - resolve.call( undefined, value ); + // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: + // * false: [ value ].slice( 0 ) => resolve( value ) + // * true: [ value ].slice( 1 ) => resolve() + resolve.apply( undefined, [ value ].slice( noValue ) ); } // For Promises/A+, convert exceptions into rejections @@ -3489,7 +3453,7 @@ function adoptValue( value, resolve, reject ) { // Support: Android 4.0 only // Strict mode functions invoked without .call/.apply get global-object context - reject.call( undefined, value ); + reject.apply( undefined, [ value ] ); } } @@ -3528,14 +3492,14 @@ jQuery.extend( { jQuery.each( tuples, function( i, tuple ) { // Map tuples (progress, done, fail) to arguments (done, fail, progress) - var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; + var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; // deferred.progress(function() { bind to newDefer or newDefer.notify }) // deferred.done(function() { bind to newDefer or newDefer.resolve }) // deferred.fail(function() { bind to newDefer or newDefer.reject }) deferred[ tuple[ 1 ] ]( function() { var returned = fn && fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { + if ( returned && isFunction( returned.promise ) ) { returned.promise() .progress( newDefer.notify ) .done( newDefer.resolve ) @@ -3589,7 +3553,7 @@ jQuery.extend( { returned.then; // Handle a returned thenable - if ( jQuery.isFunction( then ) ) { + if ( isFunction( then ) ) { // Special processors (notify) just wait for resolution if ( special ) { @@ -3685,7 +3649,7 @@ jQuery.extend( { resolve( 0, newDefer, - jQuery.isFunction( onProgress ) ? + isFunction( onProgress ) ? onProgress : Identity, newDefer.notifyWith @@ -3697,7 +3661,7 @@ jQuery.extend( { resolve( 0, newDefer, - jQuery.isFunction( onFulfilled ) ? + isFunction( onFulfilled ) ? onFulfilled : Identity ) @@ -3708,7 +3672,7 @@ jQuery.extend( { resolve( 0, newDefer, - jQuery.isFunction( onRejected ) ? + isFunction( onRejected ) ? onRejected : Thrower ) @@ -3748,8 +3712,15 @@ jQuery.extend( { // fulfilled_callbacks.disable tuples[ 3 - i ][ 2 ].disable, + // rejected_handlers.disable + // fulfilled_handlers.disable + tuples[ 3 - i ][ 3 ].disable, + // progress_callbacks.lock - tuples[ 0 ][ 2 ].lock + tuples[ 0 ][ 2 ].lock, + + // progress_handlers.lock + tuples[ 0 ][ 3 ].lock ); } @@ -3814,11 +3785,12 @@ jQuery.extend( { // Single- and empty arguments are adopted like Promise.resolve if ( remaining <= 1 ) { - adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject ); + adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject, + !remaining ); // Use .then() to unwrap secondary thenables (cf. gh-3000) if ( master.state() === "pending" || - jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { + isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { return master.then(); } @@ -3886,15 +3858,6 @@ jQuery.extend( { // the ready event fires. See #6781 readyWait: 1, - // Hold (or release) the ready event - holdReady: function( hold ) { - if ( hold ) { - jQuery.readyWait++; - } else { - jQuery.ready( true ); - } - }, - // Handle when the DOM is ready ready: function( wait ) { @@ -3955,7 +3918,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { bulk = key == null; // Sets many values - if ( jQuery.type( key ) === "object" ) { + if ( toType( key ) === "object" ) { chainable = true; for ( i in key ) { access( elems, fn, i, key[ i ], true, emptyGet, raw ); @@ -3965,7 +3928,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { } else if ( value !== undefined ) { chainable = true; - if ( !jQuery.isFunction( value ) ) { + if ( !isFunction( value ) ) { raw = true; } @@ -4007,6 +3970,23 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { return len ? fn( elems[ 0 ], key ) : emptyGet; }; + + +// Matches dashed string for camelizing +var rmsPrefix = /^-ms-/, + rdashAlpha = /-([a-z])/g; + +// Used by camelCase as callback to replace() +function fcamelCase( all, letter ) { + return letter.toUpperCase(); +} + +// Convert dashed to camelCase; used by the css and data modules +// Support: IE <=9 - 11, Edge 12 - 15 +// Microsoft forgot to hump their vendor prefix (#9572) +function camelCase( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); +} var acceptData = function( owner ) { // Accepts only: @@ -4069,14 +4049,14 @@ Data.prototype = { // Handle: [ owner, key, value ] args // Always use camelCase key (gh-2257) if ( typeof data === "string" ) { - cache[ jQuery.camelCase( data ) ] = value; + cache[ camelCase( data ) ] = value; // Handle: [ owner, { properties } ] args } else { // Copy the properties one-by-one to the cache object for ( prop in data ) { - cache[ jQuery.camelCase( prop ) ] = data[ prop ]; + cache[ camelCase( prop ) ] = data[ prop ]; } } return cache; @@ -4086,7 +4066,7 @@ Data.prototype = { this.cache( owner ) : // Always use camelCase key (gh-2257) - owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ]; + owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; }, access: function( owner, key, value ) { @@ -4130,13 +4110,13 @@ Data.prototype = { if ( key !== undefined ) { // Support array or space separated string of keys - if ( jQuery.isArray( key ) ) { + if ( Array.isArray( key ) ) { // If key is an array of keys... // We always set camelCase keys, so remove that. - key = key.map( jQuery.camelCase ); + key = key.map( camelCase ); } else { - key = jQuery.camelCase( key ); + key = camelCase( key ); // If a key with the spaces exists, use it. // Otherwise, create an array by matching non-whitespace @@ -4282,7 +4262,7 @@ jQuery.fn.extend( { if ( attrs[ i ] ) { name = attrs[ i ].name; if ( name.indexOf( "data-" ) === 0 ) { - name = jQuery.camelCase( name.slice( 5 ) ); + name = camelCase( name.slice( 5 ) ); dataAttr( elem, name, data[ name ] ); } } @@ -4356,7 +4336,7 @@ jQuery.extend( { // Speed up dequeue by getting out quickly if this is just a lookup if ( data ) { - if ( !queue || jQuery.isArray( data ) ) { + if ( !queue || Array.isArray( data ) ) { queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); } else { queue.push( data ); @@ -4529,8 +4509,7 @@ var swap = function( elem, options, callback, args ) { function adjustCSS( elem, prop, valueParts, tween ) { - var adjusted, - scale = 1, + var adjusted, scale, maxIterations = 20, currentValue = tween ? function() { @@ -4548,30 +4527,33 @@ function adjustCSS( elem, prop, valueParts, tween ) { if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { + // Support: Firefox <=54 + // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) + initial = initial / 2; + // Trust units reported by jQuery.css unit = unit || initialInUnit[ 3 ]; - // Make sure we update the tween properties later on - valueParts = valueParts || []; - // Iteratively approximate from a nonzero starting point initialInUnit = +initial || 1; - do { + while ( maxIterations-- ) { - // If previous iteration zeroed out, double until we get *something*. - // Use string for doubling so we don't accidentally see scale as unchanged below - scale = scale || ".5"; - - // Adjust and apply - initialInUnit = initialInUnit / scale; + // Evaluate and update our best guess (doubling guesses that zero out). + // Finish if the scale equals or crosses 1 (making the old*new product non-positive). jQuery.style( elem, prop, initialInUnit + unit ); + if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { + maxIterations = 0; + } + initialInUnit = initialInUnit / scale; - // Update scale, tolerating zero or NaN from tween.cur() - // Break the loop if scale is unchanged or perfect, or if we've just had enough. - } while ( - scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations - ); + } + + initialInUnit = initialInUnit * 2; + jQuery.style( elem, prop, initialInUnit + unit ); + + // Make sure we update the tween properties later on + valueParts = valueParts || []; } if ( valueParts ) { @@ -4689,7 +4671,7 @@ var rcheckableType = ( /^(?:checkbox|radio)$/i ); var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i ); -var rscriptType = ( /^$|\/(?:java|ecma)script/i ); +var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); @@ -4733,7 +4715,7 @@ function getAll( context, tag ) { ret = []; } - if ( tag === undefined || tag && jQuery.nodeName( context, tag ) ) { + if ( tag === undefined || tag && nodeName( context, tag ) ) { return jQuery.merge( [ context ], ret ); } @@ -4771,7 +4753,7 @@ function buildFragment( elems, context, scripts, selection, ignored ) { if ( elem || elem === 0 ) { // Add nodes directly - if ( jQuery.type( elem ) === "object" ) { + if ( toType( elem ) === "object" ) { // Support: Android <=4.0 only, PhantomJS 1 only // push.apply(_, arraylike) throws on ancient WebKit @@ -5281,7 +5263,7 @@ jQuery.event = { enumerable: true, configurable: true, - get: jQuery.isFunction( hook ) ? + get: isFunction( hook ) ? function() { if ( this.originalEvent ) { return hook( this.originalEvent ); @@ -5340,7 +5322,7 @@ jQuery.event = { // For checkbox, fire native event so checked state will be right trigger: function() { - if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { + if ( this.type === "checkbox" && this.click && nodeName( this, "input" ) ) { this.click(); return false; } @@ -5348,7 +5330,7 @@ jQuery.event = { // For cross-browser consistency, don't fire native .click() on links _default: function( event ) { - return jQuery.nodeName( event.target, "a" ); + return nodeName( event.target, "a" ); } }, @@ -5416,7 +5398,7 @@ jQuery.Event = function( src, props ) { } // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); + this.timeStamp = src && src.timeStamp || Date.now(); // Mark it as fixed this[ jQuery.expando ] = true; @@ -5615,21 +5597,21 @@ var /* eslint-enable */ - // Support: IE <=10 - 11, Edge 12 - 13 + // Support: IE <=10 - 11, Edge 12 - 13 only // In IE/Edge using regex groups here causes severe slowdowns. // See https://connect.microsoft.com/IE/feedback/details/1736512/ rnoInnerhtml = /\s*$/g; +// Prefer a tbody over its parent table for containing new rows function manipulationTarget( elem, content ) { - if ( jQuery.nodeName( elem, "table" ) && - jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { + if ( nodeName( elem, "table" ) && + nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { - return elem.getElementsByTagName( "tbody" )[ 0 ] || elem; + return jQuery( elem ).children( "tbody" )[ 0 ] || elem; } return elem; @@ -5641,10 +5623,8 @@ function disableScript( elem ) { return elem; } function restoreScript( elem ) { - var match = rscriptTypeMasked.exec( elem.type ); - - if ( match ) { - elem.type = match[ 1 ]; + if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { + elem.type = elem.type.slice( 5 ); } else { elem.removeAttribute( "type" ); } @@ -5710,15 +5690,15 @@ function domManip( collection, args, callback, ignored ) { l = collection.length, iNoClone = l - 1, value = args[ 0 ], - isFunction = jQuery.isFunction( value ); + valueIsFunction = isFunction( value ); // We can't cloneNode fragments that contain checked, in WebKit - if ( isFunction || + if ( valueIsFunction || ( l > 1 && typeof value === "string" && !support.checkClone && rchecked.test( value ) ) ) { return collection.each( function( index ) { var self = collection.eq( index ); - if ( isFunction ) { + if ( valueIsFunction ) { args[ 0 ] = value.call( this, index, self.html() ); } domManip( self, args, callback, ignored ); @@ -5772,14 +5752,14 @@ function domManip( collection, args, callback, ignored ) { !dataPriv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { - if ( node.src ) { + if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { // Optional AJAX dependency, but won't run scripts if not present if ( jQuery._evalUrl ) { jQuery._evalUrl( node.src ); } } else { - DOMEval( node.textContent.replace( rcleanScript, "" ), doc ); + DOMEval( node.textContent.replace( rcleanScript, "" ), doc, node ); } } } @@ -6059,8 +6039,6 @@ jQuery.each( { return this.pushStack( ret ); }; } ); -var rmargin = ( /^margin/ ); - var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); var getStyles = function( elem ) { @@ -6077,6 +6055,8 @@ var getStyles = function( elem ) { return view.getComputedStyle( elem ); }; +var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); + ( function() { @@ -6090,25 +6070,33 @@ var getStyles = function( elem ) { return; } + container.style.cssText = "position:absolute;left:-11111px;width:60px;" + + "margin-top:1px;padding:0;border:0"; div.style.cssText = - "box-sizing:border-box;" + - "position:relative;display:block;" + + "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + "margin:auto;border:1px;padding:1px;" + - "top:1%;width:50%"; - div.innerHTML = ""; - documentElement.appendChild( container ); + "width:60%;top:1%"; + documentElement.appendChild( container ).appendChild( div ); var divStyle = window.getComputedStyle( div ); pixelPositionVal = divStyle.top !== "1%"; // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 - reliableMarginLeftVal = divStyle.marginLeft === "2px"; - boxSizingReliableVal = divStyle.width === "4px"; + reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; - // Support: Android 4.0 - 4.3 only + // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 // Some styles come back with percentage values, even though they shouldn't - div.style.marginRight = "50%"; - pixelMarginRightVal = divStyle.marginRight === "4px"; + div.style.right = "60%"; + pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; + + // Support: IE 9 - 11 only + // Detect misreporting of content dimensions for box-sizing:border-box elements + boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; + + // Support: IE 9 only + // Detect overflow:scroll screwiness (gh-3699) + div.style.position = "absolute"; + scrollboxSizeVal = div.offsetWidth === 36 || "absolute"; documentElement.removeChild( container ); @@ -6117,7 +6105,12 @@ var getStyles = function( elem ) { div = null; } - var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal, + function roundPixelMeasures( measure ) { + return Math.round( parseFloat( measure ) ); + } + + var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, + reliableMarginLeftVal, container = document.createElement( "div" ), div = document.createElement( "div" ); @@ -6132,26 +6125,26 @@ var getStyles = function( elem ) { div.cloneNode( true ).style.backgroundClip = ""; support.clearCloneStyle = div.style.backgroundClip === "content-box"; - container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + - "padding:0;margin-top:1px;position:absolute"; - container.appendChild( div ); - jQuery.extend( support, { - pixelPosition: function() { - computeStyleTests(); - return pixelPositionVal; - }, boxSizingReliable: function() { computeStyleTests(); return boxSizingReliableVal; }, - pixelMarginRight: function() { + pixelBoxStyles: function() { computeStyleTests(); - return pixelMarginRightVal; + return pixelBoxStylesVal; + }, + pixelPosition: function() { + computeStyleTests(); + return pixelPositionVal; }, reliableMarginLeft: function() { computeStyleTests(); return reliableMarginLeftVal; + }, + scrollboxSize: function() { + computeStyleTests(); + return scrollboxSizeVal; } } ); } )(); @@ -6159,12 +6152,18 @@ var getStyles = function( elem ) { function curCSS( elem, name, computed ) { var width, minWidth, maxWidth, ret, + + // Support: Firefox 51+ + // Retrieving style before computed somehow + // fixes an issue with getting wrong values + // on detached elements style = elem.style; computed = computed || getStyles( elem ); - // Support: IE <=9 only - // getPropertyValue is only needed for .css('filter') (#12537) + // getPropertyValue is needed for: + // .css('filter') (IE 9 only, #12537) + // .css('--customProperty) (#3144) if ( computed ) { ret = computed.getPropertyValue( name ) || computed[ name ]; @@ -6177,7 +6176,7 @@ function curCSS( elem, name, computed ) { // but width seems to be reliably pixels. // This is against the CSSOM draft spec: // https://drafts.csswg.org/cssom/#resolved-values - if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { + if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { // Remember the original values width = style.width; @@ -6230,6 +6229,7 @@ var // except "table", "table-cell", or "table-caption" // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display rdisplayswap = /^(none|table(?!-c[ea]).+)/, + rcustomProp = /^--/, cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssNormalTransform = { letterSpacing: "0", @@ -6259,6 +6259,16 @@ function vendorPropName( name ) { } } +// Return a property mapped along what jQuery.cssProps suggests or to +// a vendor prefixed property. +function finalPropName( name ) { + var ret = jQuery.cssProps[ name ]; + if ( !ret ) { + ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name; + } + return ret; +} + function setPositiveNumber( elem, value, subtract ) { // Any relative (+/-) values have already been @@ -6271,100 +6281,120 @@ function setPositiveNumber( elem, value, subtract ) { value; } -function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { - var i, - val = 0; +function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { + var i = dimension === "width" ? 1 : 0, + extra = 0, + delta = 0; - // If we already have the right measurement, avoid augmentation - if ( extra === ( isBorderBox ? "border" : "content" ) ) { - i = 4; - - // Otherwise initialize for horizontal or vertical properties - } else { - i = name === "width" ? 1 : 0; + // Adjustment may not be necessary + if ( box === ( isBorderBox ? "border" : "content" ) ) { + return 0; } for ( ; i < 4; i += 2 ) { - // Both box models exclude margin, so add it if we want it - if ( extra === "margin" ) { - val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); + // Both box models exclude margin + if ( box === "margin" ) { + delta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); } - if ( isBorderBox ) { + // If we get here with a content-box, we're seeking "padding" or "border" or "margin" + if ( !isBorderBox ) { - // border-box includes padding, so remove it if we want content - if ( extra === "content" ) { - val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + // Add padding + delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + + // For "border" or "margin", add border + if ( box !== "padding" ) { + delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + + // But still keep track of it otherwise + } else { + extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); } - // At this point, extra isn't border nor margin, so remove border - if ( extra !== "margin" ) { - val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); - } + // If we get here with a border-box (content + padding + border), we're seeking "content" or + // "padding" or "margin" } else { - // At this point, extra isn't content, so add padding - val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + // For "content", subtract padding + if ( box === "content" ) { + delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + } - // At this point, extra isn't content nor padding, so add border - if ( extra !== "padding" ) { - val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + // For "content" or "padding", subtract border + if ( box !== "margin" ) { + delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); } } } - return val; + // Account for positive content-box scroll gutter when requested by providing computedVal + if ( !isBorderBox && computedVal >= 0 ) { + + // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border + // Assuming integer scroll gutter, subtract the rest and round down + delta += Math.max( 0, Math.ceil( + elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + computedVal - + delta - + extra - + 0.5 + ) ); + } + + return delta; } -function getWidthOrHeight( elem, name, extra ) { +function getWidthOrHeight( elem, dimension, extra ) { - // Start with offset property, which is equivalent to the border-box value - var val, - valueIsBorderBox = true, - styles = getStyles( elem ), - isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + // Start with computed style + var styles = getStyles( elem ), + val = curCSS( elem, dimension, styles ), + isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + valueIsBorderBox = isBorderBox; - // Support: IE <=11 only - // Running getBoundingClientRect on a disconnected node - // in IE throws an error. - if ( elem.getClientRects().length ) { - val = elem.getBoundingClientRect()[ name ]; - } - - // Some non-html elements return undefined for offsetWidth, so check for null/undefined - // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 - // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 - if ( val <= 0 || val == null ) { - - // Fall back to computed then uncomputed css if necessary - val = curCSS( elem, name, styles ); - if ( val < 0 || val == null ) { - val = elem.style[ name ]; - } - - // Computed unit is not pixels. Stop here and return. - if ( rnumnonpx.test( val ) ) { + // Support: Firefox <=54 + // Return a confounding non-pixel value or feign ignorance, as appropriate. + if ( rnumnonpx.test( val ) ) { + if ( !extra ) { return val; } - - // Check for style in case a browser which returns unreliable values - // for getComputedStyle silently falls back to the reliable elem.style - valueIsBorderBox = isBorderBox && - ( support.boxSizingReliable() || val === elem.style[ name ] ); - - // Normalize "", auto, and prepare for extra - val = parseFloat( val ) || 0; + val = "auto"; } - // Use the active box-sizing model to add/subtract irrelevant styles + // Check for style in case a browser which returns unreliable values + // for getComputedStyle silently falls back to the reliable elem.style + valueIsBorderBox = valueIsBorderBox && + ( support.boxSizingReliable() || val === elem.style[ dimension ] ); + + // Fall back to offsetWidth/offsetHeight when value is "auto" + // This happens for inline elements with no explicit setting (gh-3571) + // Support: Android <=4.1 - 4.3 only + // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) + if ( val === "auto" || + !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) { + + val = elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ]; + + // offsetWidth/offsetHeight provide border-box values + valueIsBorderBox = true; + } + + // Normalize "" and auto + val = parseFloat( val ) || 0; + + // Adjust for the element's box model return ( val + - augmentWidthOrHeight( + boxModelAdjustment( elem, - name, + dimension, extra || ( isBorderBox ? "border" : "content" ), valueIsBorderBox, - styles + styles, + + // Provide the current computed size to request scroll gutter calculation (gh-3589) + val ) ) + "px"; } @@ -6405,9 +6435,7 @@ jQuery.extend( { // Add in properties whose names you wish to fix before // setting or getting the value - cssProps: { - "float": "cssFloat" - }, + cssProps: {}, // Get and set the style property on a DOM Node style: function( elem, name, value, extra ) { @@ -6419,11 +6447,16 @@ jQuery.extend( { // Make sure that we're working with the right name var ret, type, hooks, - origName = jQuery.camelCase( name ), + origName = camelCase( name ), + isCustomProp = rcustomProp.test( name ), style = elem.style; - name = jQuery.cssProps[ origName ] || - ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); + // Make sure that we're working with the right name. We don't + // want to query the value if it is a CSS custom property + // since they are user-defined. + if ( !isCustomProp ) { + name = finalPropName( origName ); + } // Gets hook for the prefixed version, then unprefixed version hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; @@ -6459,7 +6492,11 @@ jQuery.extend( { if ( !hooks || !( "set" in hooks ) || ( value = hooks.set( elem, value, extra ) ) !== undefined ) { - style[ name ] = value; + if ( isCustomProp ) { + style.setProperty( name, value ); + } else { + style[ name ] = value; + } } } else { @@ -6478,11 +6515,15 @@ jQuery.extend( { css: function( elem, name, extra, styles ) { var val, num, hooks, - origName = jQuery.camelCase( name ); + origName = camelCase( name ), + isCustomProp = rcustomProp.test( name ); - // Make sure that we're working with the right name - name = jQuery.cssProps[ origName ] || - ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); + // Make sure that we're working with the right name. We don't + // want to modify the value if it is a CSS custom property + // since they are user-defined. + if ( !isCustomProp ) { + name = finalPropName( origName ); + } // Try prefixed name followed by the unprefixed name hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; @@ -6507,12 +6548,13 @@ jQuery.extend( { num = parseFloat( val ); return extra === true || isFinite( num ) ? num || 0 : val; } + return val; } } ); -jQuery.each( [ "height", "width" ], function( i, name ) { - jQuery.cssHooks[ name ] = { +jQuery.each( [ "height", "width" ], function( i, dimension ) { + jQuery.cssHooks[ dimension ] = { get: function( elem, computed, extra ) { if ( computed ) { @@ -6528,29 +6570,41 @@ jQuery.each( [ "height", "width" ], function( i, name ) { // in IE throws an error. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? swap( elem, cssShow, function() { - return getWidthOrHeight( elem, name, extra ); + return getWidthOrHeight( elem, dimension, extra ); } ) : - getWidthOrHeight( elem, name, extra ); + getWidthOrHeight( elem, dimension, extra ); } }, set: function( elem, value, extra ) { var matches, - styles = extra && getStyles( elem ), - subtract = extra && augmentWidthOrHeight( + styles = getStyles( elem ), + isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + subtract = extra && boxModelAdjustment( elem, - name, + dimension, extra, - jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + isBorderBox, styles ); + // Account for unreliable border-box dimensions by comparing offset* to computed and + // faking a content-box to get border and padding (gh-3699) + if ( isBorderBox && support.scrollboxSize() === styles.position ) { + subtract -= Math.ceil( + elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + parseFloat( styles[ dimension ] ) - + boxModelAdjustment( elem, dimension, "border", false, styles ) - + 0.5 + ); + } + // Convert to pixels if value adjustment is needed if ( subtract && ( matches = rcssNum.exec( value ) ) && ( matches[ 3 ] || "px" ) !== "px" ) { - elem.style[ name ] = value; - value = jQuery.css( elem, name ); + elem.style[ dimension ] = value; + value = jQuery.css( elem, dimension ); } return setPositiveNumber( elem, value, subtract ); @@ -6594,7 +6648,7 @@ jQuery.each( { } }; - if ( !rmargin.test( prefix ) ) { + if ( prefix !== "margin" ) { jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; } } ); @@ -6606,7 +6660,7 @@ jQuery.fn.extend( { map = {}, i = 0; - if ( jQuery.isArray( name ) ) { + if ( Array.isArray( name ) ) { styles = getStyles( elem ); len = name.length; @@ -6744,13 +6798,18 @@ jQuery.fx.step = {}; var - fxNow, timerId, + fxNow, inProgress, rfxtypes = /^(?:toggle|show|hide)$/, rrun = /queueHooks$/; -function raf() { - if ( timerId ) { - window.requestAnimationFrame( raf ); +function schedule() { + if ( inProgress ) { + if ( document.hidden === false && window.requestAnimationFrame ) { + window.requestAnimationFrame( schedule ); + } else { + window.setTimeout( schedule, jQuery.fx.interval ); + } + jQuery.fx.tick(); } } @@ -6760,7 +6819,7 @@ function createFxNow() { window.setTimeout( function() { fxNow = undefined; } ); - return ( fxNow = jQuery.now() ); + return ( fxNow = Date.now() ); } // Generate parameters to create a standard animation @@ -6864,9 +6923,10 @@ function defaultPrefilter( elem, props, opts ) { // Restrict "overflow" and "display" styles during box animations if ( isBox && elem.nodeType === 1 ) { - // Support: IE <=9 - 11, Edge 12 - 13 + // Support: IE <=9 - 11, Edge 12 - 15 // Record all 3 overflow attributes because IE does not infer the shorthand - // from identically-valued overflowX and overflowY + // from identically-valued overflowX and overflowY and Edge just mirrors + // the overflowX value there. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; // Identify a display type, preferring old show/hide data over the CSS cascade @@ -6974,10 +7034,10 @@ function propFilter( props, specialEasing ) { // camelCase, specialEasing and expand cssHook pass for ( index in props ) { - name = jQuery.camelCase( index ); + name = camelCase( index ); easing = specialEasing[ name ]; value = props[ index ]; - if ( jQuery.isArray( value ) ) { + if ( Array.isArray( value ) ) { easing = value[ 1 ]; value = props[ index ] = value[ 0 ]; } @@ -7036,12 +7096,19 @@ function Animation( elem, properties, options ) { deferred.notifyWith( elem, [ animation, percent, remaining ] ); + // If there's more to do, yield if ( percent < 1 && length ) { return remaining; - } else { - deferred.resolveWith( elem, [ animation ] ); - return false; } + + // If this was an empty animation, synthesize a final progress notification + if ( !length ) { + deferred.notifyWith( elem, [ animation, 1, 0 ] ); + } + + // Resolve the animation and report its conclusion + deferred.resolveWith( elem, [ animation ] ); + return false; }, animation = deferred.promise( { elem: elem, @@ -7092,9 +7159,9 @@ function Animation( elem, properties, options ) { for ( ; index < length; index++ ) { result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); if ( result ) { - if ( jQuery.isFunction( result.stop ) ) { + if ( isFunction( result.stop ) ) { jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = - jQuery.proxy( result.stop, result ); + result.stop.bind( result ); } return result; } @@ -7102,10 +7169,17 @@ function Animation( elem, properties, options ) { jQuery.map( props, createTween, animation ); - if ( jQuery.isFunction( animation.opts.start ) ) { + if ( isFunction( animation.opts.start ) ) { animation.opts.start.call( elem, animation ); } + // Attach callbacks from options + animation + .progress( animation.opts.progress ) + .done( animation.opts.done, animation.opts.complete ) + .fail( animation.opts.fail ) + .always( animation.opts.always ); + jQuery.fx.timer( jQuery.extend( tick, { elem: elem, @@ -7114,11 +7188,7 @@ function Animation( elem, properties, options ) { } ) ); - // attach callbacks from options - return animation.progress( animation.opts.progress ) - .done( animation.opts.done, animation.opts.complete ) - .fail( animation.opts.fail ) - .always( animation.opts.always ); + return animation; } jQuery.Animation = jQuery.extend( Animation, { @@ -7132,7 +7202,7 @@ jQuery.Animation = jQuery.extend( Animation, { }, tweener: function( props, callback ) { - if ( jQuery.isFunction( props ) ) { + if ( isFunction( props ) ) { callback = props; props = [ "*" ]; } else { @@ -7164,13 +7234,13 @@ jQuery.Animation = jQuery.extend( Animation, { jQuery.speed = function( speed, easing, fn ) { var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { complete: fn || !fn && easing || - jQuery.isFunction( speed ) && speed, + isFunction( speed ) && speed, duration: speed, - easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing + easing: fn && easing || easing && !isFunction( easing ) && easing }; - // Go to the end state if fx are off or if document is hidden - if ( jQuery.fx.off || document.hidden ) { + // Go to the end state if fx are off + if ( jQuery.fx.off ) { opt.duration = 0; } else { @@ -7193,7 +7263,7 @@ jQuery.speed = function( speed, easing, fn ) { opt.old = opt.complete; opt.complete = function() { - if ( jQuery.isFunction( opt.old ) ) { + if ( isFunction( opt.old ) ) { opt.old.call( this ); } @@ -7357,12 +7427,12 @@ jQuery.fx.tick = function() { i = 0, timers = jQuery.timers; - fxNow = jQuery.now(); + fxNow = Date.now(); for ( ; i < timers.length; i++ ) { timer = timers[ i ]; - // Checks the timer has not already been removed + // Run the timer and safely remove it when done (allowing for external removal) if ( !timer() && timers[ i ] === timer ) { timers.splice( i--, 1 ); } @@ -7376,30 +7446,21 @@ jQuery.fx.tick = function() { jQuery.fx.timer = function( timer ) { jQuery.timers.push( timer ); - if ( timer() ) { - jQuery.fx.start(); - } else { - jQuery.timers.pop(); - } + jQuery.fx.start(); }; jQuery.fx.interval = 13; jQuery.fx.start = function() { - if ( !timerId ) { - timerId = window.requestAnimationFrame ? - window.requestAnimationFrame( raf ) : - window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); + if ( inProgress ) { + return; } + + inProgress = true; + schedule(); }; jQuery.fx.stop = function() { - if ( window.cancelAnimationFrame ) { - window.cancelAnimationFrame( timerId ); - } else { - window.clearInterval( timerId ); - } - - timerId = null; + inProgress = null; }; jQuery.fx.speeds = { @@ -7516,7 +7577,7 @@ jQuery.extend( { type: { set: function( elem, value ) { if ( !support.radioValue && value === "radio" && - jQuery.nodeName( elem, "input" ) ) { + nodeName( elem, "input" ) ) { var val = elem.value; elem.setAttribute( "type", value ); if ( val ) { @@ -7719,7 +7780,7 @@ jQuery.each( [ // Strip and collapse whitespace according to HTML spec - // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace + // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace function stripAndCollapse( value ) { var tokens = value.match( rnothtmlwhite ) || []; return tokens.join( " " ); @@ -7730,20 +7791,30 @@ function getClass( elem ) { return elem.getAttribute && elem.getAttribute( "class" ) || ""; } +function classesToArray( value ) { + if ( Array.isArray( value ) ) { + return value; + } + if ( typeof value === "string" ) { + return value.match( rnothtmlwhite ) || []; + } + return []; +} + jQuery.fn.extend( { addClass: function( value ) { var classes, elem, cur, curValue, clazz, j, finalValue, i = 0; - if ( jQuery.isFunction( value ) ) { + if ( isFunction( value ) ) { return this.each( function( j ) { jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); } ); } - if ( typeof value === "string" && value ) { - classes = value.match( rnothtmlwhite ) || []; + classes = classesToArray( value ); + if ( classes.length ) { while ( ( elem = this[ i++ ] ) ) { curValue = getClass( elem ); cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); @@ -7772,7 +7843,7 @@ jQuery.fn.extend( { var classes, elem, cur, curValue, clazz, j, finalValue, i = 0; - if ( jQuery.isFunction( value ) ) { + if ( isFunction( value ) ) { return this.each( function( j ) { jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); } ); @@ -7782,9 +7853,9 @@ jQuery.fn.extend( { return this.attr( "class", "" ); } - if ( typeof value === "string" && value ) { - classes = value.match( rnothtmlwhite ) || []; + classes = classesToArray( value ); + if ( classes.length ) { while ( ( elem = this[ i++ ] ) ) { curValue = getClass( elem ); @@ -7814,13 +7885,14 @@ jQuery.fn.extend( { }, toggleClass: function( value, stateVal ) { - var type = typeof value; + var type = typeof value, + isValidValue = type === "string" || Array.isArray( value ); - if ( typeof stateVal === "boolean" && type === "string" ) { + if ( typeof stateVal === "boolean" && isValidValue ) { return stateVal ? this.addClass( value ) : this.removeClass( value ); } - if ( jQuery.isFunction( value ) ) { + if ( isFunction( value ) ) { return this.each( function( i ) { jQuery( this ).toggleClass( value.call( this, i, getClass( this ), stateVal ), @@ -7832,12 +7904,12 @@ jQuery.fn.extend( { return this.each( function() { var className, i, self, classNames; - if ( type === "string" ) { + if ( isValidValue ) { // Toggle individual class names i = 0; self = jQuery( this ); - classNames = value.match( rnothtmlwhite ) || []; + classNames = classesToArray( value ); while ( ( className = classNames[ i++ ] ) ) { @@ -7896,7 +7968,7 @@ var rreturn = /\r/g; jQuery.fn.extend( { val: function( value ) { - var hooks, ret, isFunction, + var hooks, ret, valueIsFunction, elem = this[ 0 ]; if ( !arguments.length ) { @@ -7925,7 +7997,7 @@ jQuery.fn.extend( { return; } - isFunction = jQuery.isFunction( value ); + valueIsFunction = isFunction( value ); return this.each( function( i ) { var val; @@ -7934,7 +8006,7 @@ jQuery.fn.extend( { return; } - if ( isFunction ) { + if ( valueIsFunction ) { val = value.call( this, i, jQuery( this ).val() ); } else { val = value; @@ -7947,7 +8019,7 @@ jQuery.fn.extend( { } else if ( typeof val === "number" ) { val += ""; - } else if ( jQuery.isArray( val ) ) { + } else if ( Array.isArray( val ) ) { val = jQuery.map( val, function( value ) { return value == null ? "" : value + ""; } ); @@ -8006,7 +8078,7 @@ jQuery.extend( { // Don't return options that are disabled or in a disabled optgroup !option.disabled && ( !option.parentNode.disabled || - !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { + !nodeName( option.parentNode, "optgroup" ) ) ) { // Get the specific value for the option value = jQuery( option ).val(); @@ -8058,7 +8130,7 @@ jQuery.extend( { jQuery.each( [ "radio", "checkbox" ], function() { jQuery.valHooks[ this ] = { set: function( elem, value ) { - if ( jQuery.isArray( value ) ) { + if ( Array.isArray( value ) ) { return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); } } @@ -8076,18 +8148,24 @@ jQuery.each( [ "radio", "checkbox" ], function() { // Return jQuery for attributes-only inclusion -var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/; +support.focusin = "onfocusin" in window; + + +var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + stopPropagationCallback = function( e ) { + e.stopPropagation(); + }; jQuery.extend( jQuery.event, { trigger: function( event, data, elem, onlyHandlers ) { - var i, cur, tmp, bubbleType, ontype, handle, special, + var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, eventPath = [ elem || document ], type = hasOwn.call( event, "type" ) ? event.type : event, namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; - cur = tmp = elem = elem || document; + cur = lastElement = tmp = elem = elem || document; // Don't do events on text and comment nodes if ( elem.nodeType === 3 || elem.nodeType === 8 ) { @@ -8139,7 +8217,7 @@ jQuery.extend( jQuery.event, { // Determine event propagation path in advance, per W3C events spec (#9951) // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { bubbleType = special.delegateType || type; if ( !rfocusMorph.test( bubbleType + type ) ) { @@ -8159,7 +8237,7 @@ jQuery.extend( jQuery.event, { // Fire handlers on the event path i = 0; while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { - + lastElement = cur; event.type = i > 1 ? bubbleType : special.bindType || type; @@ -8191,7 +8269,7 @@ jQuery.extend( jQuery.event, { // Call a native DOM method on the target with the same name as the event. // Don't do default actions on window, that's where global variables be (#6170) - if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { + if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { // Don't re-trigger an onFOO event when we call its FOO() method tmp = elem[ ontype ]; @@ -8202,7 +8280,17 @@ jQuery.extend( jQuery.event, { // Prevent re-triggering of the same event, since we already bubbled it above jQuery.event.triggered = type; + + if ( event.isPropagationStopped() ) { + lastElement.addEventListener( type, stopPropagationCallback ); + } + elem[ type ](); + + if ( event.isPropagationStopped() ) { + lastElement.removeEventListener( type, stopPropagationCallback ); + } + jQuery.event.triggered = undefined; if ( tmp ) { @@ -8248,31 +8336,6 @@ jQuery.fn.extend( { } ); -jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + - "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup contextmenu" ).split( " " ), - function( i, name ) { - - // Handle event binding - jQuery.fn[ name ] = function( data, fn ) { - return arguments.length > 0 ? - this.on( name, null, data, fn ) : - this.trigger( name ); - }; -} ); - -jQuery.fn.extend( { - hover: function( fnOver, fnOut ) { - return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); - } -} ); - - - - -support.focusin = "onfocusin" in window; - - // Support: Firefox <=44 // Firefox doesn't have focus(in | out) events // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 @@ -8316,7 +8379,7 @@ if ( !support.focusin ) { } var location = window.location; -var nonce = jQuery.now(); +var nonce = Date.now(); var rquery = ( /\?/ ); @@ -8353,7 +8416,7 @@ var function buildParams( prefix, obj, traditional, add ) { var name; - if ( jQuery.isArray( obj ) ) { + if ( Array.isArray( obj ) ) { // Serialize array item. jQuery.each( obj, function( i, v ) { @@ -8374,7 +8437,7 @@ function buildParams( prefix, obj, traditional, add ) { } } ); - } else if ( !traditional && jQuery.type( obj ) === "object" ) { + } else if ( !traditional && toType( obj ) === "object" ) { // Serialize object item. for ( name in obj ) { @@ -8396,7 +8459,7 @@ jQuery.param = function( a, traditional ) { add = function( key, valueOrFunction ) { // If value is a function, invoke it and use its return value - var value = jQuery.isFunction( valueOrFunction ) ? + var value = isFunction( valueOrFunction ) ? valueOrFunction() : valueOrFunction; @@ -8405,7 +8468,7 @@ jQuery.param = function( a, traditional ) { }; // If an array was passed in, assume that it is an array of form elements. - if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { + if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { // Serialize the form elements jQuery.each( a, function() { @@ -8451,7 +8514,7 @@ jQuery.fn.extend( { return null; } - if ( jQuery.isArray( val ) ) { + if ( Array.isArray( val ) ) { return jQuery.map( val, function( val ) { return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; } ); @@ -8514,7 +8577,7 @@ function addToPrefiltersOrTransports( structure ) { i = 0, dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; - if ( jQuery.isFunction( func ) ) { + if ( isFunction( func ) ) { // For each dataType in the dataTypeExpression while ( ( dataType = dataTypes[ i++ ] ) ) { @@ -8986,7 +9049,7 @@ jQuery.extend( { if ( s.crossDomain == null ) { urlAnchor = document.createElement( "a" ); - // Support: IE <=8 - 11, Edge 12 - 13 + // Support: IE <=8 - 11, Edge 12 - 15 // IE throws exception on accessing the href property if url is malformed, // e.g. http://example.com:80x/ try { @@ -9044,8 +9107,8 @@ jQuery.extend( { // Remember the hash so we can put it back uncached = s.url.slice( cacheURL.length ); - // If data is available, append data to url - if ( s.data ) { + // If data is available and should be processed, append data to url + if ( s.data && ( s.processData || typeof s.data === "string" ) ) { cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; // #9682: remove data so that it's not used in an eventual retry @@ -9282,7 +9345,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) { jQuery[ method ] = function( url, data, callback, type ) { // Shift arguments if data argument was omitted - if ( jQuery.isFunction( data ) ) { + if ( isFunction( data ) ) { type = type || callback; callback = data; data = undefined; @@ -9320,7 +9383,7 @@ jQuery.fn.extend( { var wrap; if ( this[ 0 ] ) { - if ( jQuery.isFunction( html ) ) { + if ( isFunction( html ) ) { html = html.call( this[ 0 ] ); } @@ -9346,7 +9409,7 @@ jQuery.fn.extend( { }, wrapInner: function( html ) { - if ( jQuery.isFunction( html ) ) { + if ( isFunction( html ) ) { return this.each( function( i ) { jQuery( this ).wrapInner( html.call( this, i ) ); } ); @@ -9366,10 +9429,10 @@ jQuery.fn.extend( { }, wrap: function( html ) { - var isFunction = jQuery.isFunction( html ); + var htmlIsFunction = isFunction( html ); return this.each( function( i ) { - jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html ); + jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); } ); }, @@ -9461,7 +9524,8 @@ jQuery.ajaxTransport( function( options ) { return function() { if ( callback ) { callback = errorCallback = xhr.onload = - xhr.onerror = xhr.onabort = xhr.onreadystatechange = null; + xhr.onerror = xhr.onabort = xhr.ontimeout = + xhr.onreadystatechange = null; if ( type === "abort" ) { xhr.abort(); @@ -9501,7 +9565,7 @@ jQuery.ajaxTransport( function( options ) { // Listen to events xhr.onload = callback(); - errorCallback = xhr.onerror = callback( "error" ); + errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); // Support: IE 9 only // Use onreadystatechange to replace onabort @@ -9655,7 +9719,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { // Get callback name, remembering preexisting value associated with it - callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? + callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback; @@ -9706,7 +9770,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { } // Call if it was a function and we have a response - if ( responseContainer && jQuery.isFunction( overwritten ) ) { + if ( responseContainer && isFunction( overwritten ) ) { overwritten( responseContainer[ 0 ] ); } @@ -9798,7 +9862,7 @@ jQuery.fn.load = function( url, params, callback ) { } // If it's a function - if ( jQuery.isFunction( params ) ) { + if ( isFunction( params ) ) { // We assume that it's the callback callback = params; @@ -9876,13 +9940,6 @@ jQuery.expr.pseudos.animated = function( elem ) { -/** - * Gets a window from an element - */ -function getWindow( elem ) { - return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView; -} - jQuery.offset = { setOffset: function( elem, options, i ) { var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, @@ -9913,7 +9970,7 @@ jQuery.offset = { curLeft = parseFloat( curCSSLeft ) || 0; } - if ( jQuery.isFunction( options ) ) { + if ( isFunction( options ) ) { // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); @@ -9936,6 +9993,8 @@ jQuery.offset = { }; jQuery.fn.extend( { + + // offset() relates an element's border box to the document origin offset: function( options ) { // Preserve chaining for setter @@ -9947,13 +10006,14 @@ jQuery.fn.extend( { } ); } - var docElem, win, rect, doc, + var rect, win, elem = this[ 0 ]; if ( !elem ) { return; } + // Return zeros for disconnected and hidden (display: none) elements (gh-2310) // Support: IE <=11 only // Running getBoundingClientRect on a // disconnected node in IE throws an error @@ -9961,56 +10021,52 @@ jQuery.fn.extend( { return { top: 0, left: 0 }; } + // Get document-relative position by adding viewport scroll to viewport-relative gBCR rect = elem.getBoundingClientRect(); - - // Make sure element is not hidden (display: none) - if ( rect.width || rect.height ) { - doc = elem.ownerDocument; - win = getWindow( doc ); - docElem = doc.documentElement; - - return { - top: rect.top + win.pageYOffset - docElem.clientTop, - left: rect.left + win.pageXOffset - docElem.clientLeft - }; - } - - // Return zeros for disconnected and hidden elements (gh-2310) - return rect; + win = elem.ownerDocument.defaultView; + return { + top: rect.top + win.pageYOffset, + left: rect.left + win.pageXOffset + }; }, + // position() relates an element's margin box to its offset parent's padding box + // This corresponds to the behavior of CSS absolute positioning position: function() { if ( !this[ 0 ] ) { return; } - var offsetParent, offset, + var offsetParent, offset, doc, elem = this[ 0 ], parentOffset = { top: 0, left: 0 }; - // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, - // because it is its only offset parent + // position:fixed elements are offset from the viewport, which itself always has zero offset if ( jQuery.css( elem, "position" ) === "fixed" ) { - // Assume getBoundingClientRect is there when computed position is fixed + // Assume position:fixed implies availability of getBoundingClientRect offset = elem.getBoundingClientRect(); } else { - - // Get *real* offsetParent - offsetParent = this.offsetParent(); - - // Get correct offsets offset = this.offset(); - if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { - parentOffset = offsetParent.offset(); - } - // Add offsetParent borders - parentOffset = { - top: parentOffset.top + jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ), - left: parentOffset.left + jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ) - }; + // Account for the *real* offset parent, which can be the document or its root element + // when a statically positioned element is identified + doc = elem.ownerDocument; + offsetParent = elem.offsetParent || doc.documentElement; + while ( offsetParent && + ( offsetParent === doc.body || offsetParent === doc.documentElement ) && + jQuery.css( offsetParent, "position" ) === "static" ) { + + offsetParent = offsetParent.parentNode; + } + if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) { + + // Incorporate borders into its offset, since they are outside its content origin + parentOffset = jQuery( offsetParent ).offset(); + parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true ); + parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true ); + } } // Subtract parent offsets and element margins @@ -10049,7 +10105,14 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( jQuery.fn[ method ] = function( val ) { return access( this, function( elem, method, val ) { - var win = getWindow( elem ); + + // Coalesce documents and windows + var win; + if ( isWindow( elem ) ) { + win = elem; + } else if ( elem.nodeType === 9 ) { + win = elem.defaultView; + } if ( val === undefined ) { return win ? win[ prop ] : elem[ method ]; @@ -10103,7 +10166,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { return access( this, function( elem, type, value ) { var doc; - if ( jQuery.isWindow( elem ) ) { + if ( isWindow( elem ) ) { // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) return funcName.indexOf( "outer" ) === 0 ? @@ -10137,6 +10200,28 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { } ); +jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup contextmenu" ).split( " " ), + function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + return arguments.length > 0 ? + this.on( name, null, data, fn ) : + this.trigger( name ); + }; +} ); + +jQuery.fn.extend( { + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +} ); + + + + jQuery.fn.extend( { bind: function( types, data, fn ) { @@ -10158,7 +10243,67 @@ jQuery.fn.extend( { } } ); +// Bind a function to a context, optionally partially applying any +// arguments. +// jQuery.proxy is deprecated to promote standards (specifically Function#bind) +// However, it is not slated for removal any time soon +jQuery.proxy = function( fn, context ) { + var tmp, args, proxy; + + if ( typeof context === "string" ) { + tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + args = slice.call( arguments, 2 ); + proxy = function() { + return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || jQuery.guid++; + + return proxy; +}; + +jQuery.holdReady = function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } +}; +jQuery.isArray = Array.isArray; jQuery.parseJSON = JSON.parse; +jQuery.nodeName = nodeName; +jQuery.isFunction = isFunction; +jQuery.isWindow = isWindow; +jQuery.camelCase = camelCase; +jQuery.type = toType; + +jQuery.now = Date.now; + +jQuery.isNumeric = function( obj ) { + + // As of jQuery 3.0, isNumeric is limited to + // strings and numbers (primitives or objects) + // that can be coerced to finite numbers (gh-2662) + var type = jQuery.type( obj ); + return ( type === "number" || type === "string" ) && + + // parseFloat NaNs numeric-cast false positives ("") + // ...but misinterprets leading-number strings, particularly hex literals ("0x...") + // subtraction forces infinities to NaN + !isNaN( obj - parseFloat( obj ) ); +}; @@ -10215,6 +10360,5 @@ if ( !noGlobal ) { - return jQuery; } ); diff --git a/htdocs/includes/jquery/js/jquery.min.js b/htdocs/includes/jquery/js/jquery.min.js index 4c5be4c0fbe..4d9b3a25875 100644 --- a/htdocs/includes/jquery/js/jquery.min.js +++ b/htdocs/includes/jquery/js/jquery.min.js @@ -1,4 +1,2 @@ -/*! jQuery v3.1.1 | (c) jQuery Foundation | jquery.org/license */ -!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.1.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0&&("form"in a||"label"in a)},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"form"in b?b.parentNode&&b.disabled===!1?"label"in b?"label"in b.parentNode?b.parentNode.disabled===a:b.disabled===a:b.isDisabled===a||b.isDisabled!==!a&&ea(b)===a:b.disabled===a:"label"in b&&b.disabled===a}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}}):(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c,d,e,f=b.getElementById(a);if(f){if(c=f.getAttributeNode("id"),c&&c.value===a)return[f];e=b.getElementsByName(a),d=0;while(f=e[d++])if(c=f.getAttributeNode("id"),c&&c.value===a)return[f]}return[]}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML="";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[c<0?c+b:c]}),even:pa(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=c<0?c+b:c;++d1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;d-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,c,e){var f,i,j,k,l,m="function"==typeof a&&a,n=!e&&g(a=m.selector||a);if(c=c||[],1===n.length){if(i=n[0]=n[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&9===b.nodeType&&p&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(_,aa),b)||[])[0],!b)return c;m&&(b=b.parentNode),a=a.slice(i.shift().value.length)}f=V.needsContext.test(a)?0:i.length;while(f--){if(j=i[f],d.relative[k=j.type])break;if((l=d.find[k])&&(e=l(j.matches[0].replace(_,aa),$.test(i[0].type)&&qa(b.parentNode)||b))){if(i.splice(f,1),a=e.length&&sa(i),!a)return G.apply(c,e),c;break}}}return(m||h(a,n))(e,b,!p,c,!b||$.test(a)&&qa(b.parentNode)||b),c},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext,B=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,C=/^.[^:#\[\.,]*$/;function D(a,b,c){return r.isFunction(b)?r.grep(a,function(a,d){return!!b.call(a,d,a)!==c}):b.nodeType?r.grep(a,function(a){return a===b!==c}):"string"!=typeof b?r.grep(a,function(a){return i.call(b,a)>-1!==c}):C.test(b)?r.filter(b,a,c):(b=r.filter(b,a),r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType}))}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(D(this,a||[],!1))},not:function(a){return this.pushStack(D(this,a||[],!0))},is:function(a){return!!D(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var E,F=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,G=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||E,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:F.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),B.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};G.prototype=r.fn,E=r(d);var H=/^(?:parents|prev(?:Until|All))/,I={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function J(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return J(a,"nextSibling")},prev:function(a){return J(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return a.contentDocument||r.merge([],a.childNodes)}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(I[a]||r.uniqueSort(e),H.test(a)&&e.reverse()),this.pushStack(e)}});var K=/[^\x20\t\r\n\f]+/g;function L(a){var b={};return r.each(a.match(K)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?L(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function M(a){return a}function N(a){throw a}function O(a,b,c){var d;try{a&&r.isFunction(d=a.promise)?d.call(a).done(b).fail(c):a&&r.isFunction(d=a.then)?d.call(a,b,c):b.call(void 0,a)}catch(a){c.call(void 0,a)}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b=f&&(d!==N&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:M,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:M)),c[2][3].add(g(0,a,r.isFunction(d)?d:N))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(O(a,g.done(h(c)).resolve,g.reject),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)O(e[c],h(c),g.reject);return g.promise()}});var P=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&P.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var Q=r.Deferred();r.fn.ready=function(a){return Q.then(a)["catch"](function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,holdReady:function(a){a?r.readyWait++:r.ready(!0)},ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||Q.resolveWith(d,[r]))}}),r.ready.then=Q.then;function R(){d.removeEventListener("DOMContentLoaded",R), -a.removeEventListener("load",R),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",R),a.addEventListener("load",R));var S=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)S(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h1,null,!0)},removeData:function(a){return this.each(function(){W.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=V.get(a,b),c&&(!d||r.isArray(c)?d=V.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return V.get(a,c)||V.access(a,c,{empty:r.Callbacks("once memory").add(function(){V.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length\x20\t\r\n\f]+)/i,ka=/^$|\/(?:java|ecma)script/i,la={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};la.optgroup=la.option,la.tbody=la.tfoot=la.colgroup=la.caption=la.thead,la.th=la.td;function ma(a,b){var c;return c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[],void 0===b||b&&r.nodeName(a,b)?r.merge([a],c):c}function na(a,b){for(var c=0,d=a.length;c-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=ma(l.appendChild(f),"script"),j&&na(g),c){k=0;while(f=g[k++])ka.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var qa=d.documentElement,ra=/^key/,sa=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ta=/^([^.]*)(?:\.(.+)|)/;function ua(){return!0}function va(){return!1}function wa(){try{return d.activeElement}catch(a){}}function xa(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)xa(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=va;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(qa,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(K)||[""],j=b.length;while(j--)h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.hasData(a)&&V.get(a);if(q&&(i=q.events)){b=(b||"").match(K)||[""],j=b.length;while(j--)if(h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&V.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(V.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i\x20\t\r\n\f]*)[^>]*)\/>/gi,za=/\s*$/g;function Da(a,b){return r.nodeName(a,"table")&&r.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a:a}function Ea(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Fa(a){var b=Ba.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ga(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(V.hasData(a)&&(f=V.access(a),g=V.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c1&&"string"==typeof q&&!o.checkClone&&Aa.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ia(f,b,c,d)});if(m&&(e=pa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(ma(e,"script"),Ea),i=h.length;l")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=ma(h),f=ma(a),d=0,e=f.length;d0&&na(g,!i&&ma(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(T(c)){if(b=c[V.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[V.expando]=void 0}c[W.expando]&&(c[W.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ja(this,a,!0)},remove:function(a){return Ja(this,a)},text:function(a){return S(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.appendChild(a)}})},prepend:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(ma(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return S(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!za.test(a)&&!la[(ja.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c1)}});function Ya(a,b,c,d,e){return new Ya.prototype.init(a,b,c,d,e)}r.Tween=Ya,Ya.prototype={constructor:Ya,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=Ya.propHooks[this.prop];return a&&a.get?a.get(this):Ya.propHooks._default.get(this)},run:function(a){var b,c=Ya.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Ya.propHooks._default.set(this),this}},Ya.prototype.init.prototype=Ya.prototype,Ya.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},Ya.propHooks.scrollTop=Ya.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=Ya.prototype.init,r.fx.step={};var Za,$a,_a=/^(?:toggle|show|hide)$/,ab=/queueHooks$/;function bb(){$a&&(a.requestAnimationFrame(bb),r.fx.tick())}function cb(){return a.setTimeout(function(){Za=void 0}),Za=r.now()}function db(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ba[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function eb(a,b,c){for(var d,e=(hb.tweeners[b]||[]).concat(hb.tweeners["*"]),f=0,g=e.length;f1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?ib:void 0)), -void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b),null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&r.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(K);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),ib={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=jb[b]||r.find.attr;jb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=jb[g],jb[g]=e,e=null!=c(a,b,d)?g:null,jb[g]=f),e}});var kb=/^(?:input|select|textarea|button)$/i,lb=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return S(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):kb.test(a.nodeName)||lb.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function mb(a){var b=a.match(K)||[];return b.join(" ")}function nb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,nb(this)))});if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=mb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,nb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=mb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,nb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(K)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=nb(this),b&&V.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":V.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+mb(nb(c))+" ").indexOf(b)>-1)return!0;return!1}});var ob=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":r.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(ob,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:mb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(r.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var pb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!pb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,pb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(V.get(h,"events")||{})[b.type]&&V.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&T(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!T(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=V.access(d,b);e||d.addEventListener(a,c,!0),V.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=V.access(d,b)-1;e?V.access(d,b,e):(d.removeEventListener(a,c,!0),V.remove(d,b))}}});var qb=a.location,rb=r.now(),sb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var tb=/\[\]$/,ub=/\r?\n/g,vb=/^(?:submit|button|image|reset|file)$/i,wb=/^(?:input|select|textarea|keygen)/i;function xb(a,b,c,d){var e;if(r.isArray(b))r.each(b,function(b,e){c||tb.test(a)?d(a,e):xb(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)xb(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(r.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)xb(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&wb.test(this.nodeName)&&!vb.test(a)&&(this.checked||!ia.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:r.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(ub,"\r\n")}}):{name:b.name,value:c.replace(ub,"\r\n")}}).get()}});var yb=/%20/g,zb=/#.*$/,Ab=/([?&])_=[^&]*/,Bb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Cb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Db=/^(?:GET|HEAD)$/,Eb=/^\/\//,Fb={},Gb={},Hb="*/".concat("*"),Ib=d.createElement("a");Ib.href=qb.href;function Jb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(K)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Kb(a,b,c,d){var e={},f=a===Gb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Lb(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Mb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Nb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:qb.href,type:"GET",isLocal:Cb.test(qb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Hb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Lb(Lb(a,r.ajaxSettings),b):Lb(r.ajaxSettings,a)},ajaxPrefilter:Jb(Fb),ajaxTransport:Jb(Gb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Bb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||qb.href)+"").replace(Eb,qb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(K)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Ib.protocol+"//"+Ib.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Kb(Fb,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Db.test(o.type),f=o.url.replace(zb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(yb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(sb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Ab,"$1"),n=(sb.test(f)?"&":"?")+"_="+rb++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Hb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Kb(Gb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Mb(o,y,d)),v=Nb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Ob={0:200,1223:204},Pb=r.ajaxSettings.xhr();o.cors=!!Pb&&"withCredentials"in Pb,o.ajax=Pb=!!Pb,r.ajaxTransport(function(b){var c,d;if(o.cors||Pb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Ob[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r("'."\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 "
"; + print ""; print dol_print_date($db->jdate($objp->datef), 'day')."".$product_static->getNomUrl(1)."".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/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..cdb5a4b74f4 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); } @@ -289,18 +286,18 @@ class MyModuleApi extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $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 +308,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..7416eb1c35e 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -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..c95bcdcb8f4 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; @@ -474,7 +474,7 @@ class Products extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -502,7 +502,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 .= '