diff --git a/.travis.yml b/.travis.yml index 1f4fc328a49..ee378d191dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,6 +53,10 @@ addons: - php8.1-mysqli - php8.1-xml - php8.1-intl + - php8.2-pgsql + - php8.2-mysqli + - php8.2-xml + - php8.2-intl env: global: @@ -73,8 +77,8 @@ jobs: php: '8.1' env: DB=mysql - stage: PHP Dev - if: type = push AND branch = 17.0 - php: nightly + if: type = push AND branch = develop + php: '8.2' env: DB=mysql notifications: @@ -120,7 +124,7 @@ install: squizlabs/php_codesniffer ^3 fi # phpunit 9 is required for php 8 - if [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = '8.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then composer self-update 2.4.4 composer -n require --ignore-platform-reqs phpunit/phpunit ^8 \ php-parallel-lint/php-parallel-lint ^1.2 \ @@ -260,7 +264,7 @@ before_script: # enable php-fpm - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - | - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = '8.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then # Copy the included pool sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf fi diff --git a/ChangeLog b/ChangeLog index ce8c34636f6..62ccda4bbb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -280,6 +280,7 @@ Following changes may create regressions for some external modules, but were nec * You must use "$objectoffield" to manipulate the current object inside the formulare of computed custom extrafields instead of $obj/$object. * Making a global search is sending the parameter using always the name search_all (instead of sometimes sall and search_all) * The property $url_last_version must be public if defined into module descriptor files; +* Filters in class field definitions must be a Dolibarr filter syntax string. ***** ChangeLog for 16.0.5 compared to 16.0.4 ***** diff --git a/build/debian/rules b/build/debian/rules index b63fcffde93..df6abfd1b89 100755 --- a/build/debian/rules +++ b/build/debian/rules @@ -19,6 +19,10 @@ override_dh_auto_clean: override_dh_auto_build: # Do nothing. Added to disable launchpad to use bugged dh_auto_build search for ant +# Force the compression format for control files +override_dh_builddeb: + dh_builddeb -- -Zxz + #override_dh_compress: # dh_compress --no-act -X.png @@ -124,4 +128,4 @@ override_dh_fixperms: # Give rights to the webserver on the upload directory chown www-data:www-data debian/dolibarr/var/lib/dolibarr/documents chmod 2775 debian/dolibarr/var/lib/dolibarr/documents - + diff --git a/build/debian/source/options b/build/debian/source/options index 8d8fd181896..49a59df5428 100644 --- a/build/debian/source/options +++ b/build/debian/source/options @@ -1,3 +1,5 @@ -# Force use of gzip compression by dpkg-buildpackage +# Force use of gzip compression by dpkg-buildpackage for the tarball *.debian.tar.gz +# See also option --compression from command line of dpkg-buildpackage +# Format for the control files are defined into the rules file in override_dh_builddeb section compression = "gzip" #compression-level = 9 diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index f0433da142b..b7586e3909f 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -1050,16 +1050,16 @@ if ($nboftargetok) { print "Go into directory $BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build\n"; chdir("$BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build"); #$cmd="dpkg-source -b $BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build"; - $cmd="dpkg-buildpackage -us -uc"; + $cmd="dpkg-buildpackage -us -uc --compression=gzip"; print "Launch DEB build ($cmd)\n"; $ret=`$cmd 2>&1 3>&1`; print $ret."\n"; chdir("$olddir"); - + print "You can check bin package with lintian --pedantic -E -I \"$NEWDESTI/${FILENAMEDEB}_all.deb\"\n"; print "You can check src package with lintian --pedantic -E -I \"$NEWDESTI/${FILENAMEDEB}.dsc\"\n"; - + # Move to final dir print "Move *_all.deb *.dsc *.orig.tar.gz *.changes to $NEWDESTI\n"; $ret=`mv $BUILDROOT/*_all.deb "$NEWDESTI/"`; diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 91b7673ab81..324f5d8d447 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -321,7 +321,7 @@ if ($resql) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_account) { $param .= '&search_account='.urlencode($search_account); diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 2bd1037db39..13a07be6dfc 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -81,6 +81,10 @@ $list_account[] = '---Others---'; $list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT'; +if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { + $list_account[] = 'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT'; + $list_account[] = 'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT'; +} if (isModEnabled('banque')) { $list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH'; } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 3a7be3e073e..174d8fdf13e 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-2021 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -66,12 +66,7 @@ $error = 0; * Actions */ -if (in_array($action, array( - 'setBANK_DISABLE_DIRECT_INPUT', - 'setACCOUNTANCY_COMBO_FOR_AUX', - 'setACCOUNTING_MANAGE_ZERO', - 'setACCOUNTING_LIST_SORT_VENTILATION_TODO', - 'setACCOUNTING_LIST_SORT_VENTILATION_DONE'))) { +if (in_array($action, array('setBANK_DISABLE_DIRECT_INPUT', 'setACCOUNTANCY_COMBO_FOR_AUX', 'setACCOUNTING_MANAGE_ZERO'))) { $constname = preg_replace('/^set/', '', $action); $constvalue = GETPOST('value', 'int'); $res = dolibarr_set_const($db, $constname, $constvalue, 'yesno', 0, '', $conf->entity); @@ -121,34 +116,6 @@ if ($action == 'update') { } } -if ($action == 'setlistsorttodo') { - $setlistsorttodo = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } -} - -if ($action == 'setlistsortdone') { - $setlistsortdone = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } -} - if ($action == 'setmanagezero') { $setmanagezero = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity); @@ -275,6 +242,19 @@ if ($action == 'setenableautolettering') { } } +if ($action == 'setenablevatreversecharge') { + $setenablevatreversecharge = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE", $setenablevatreversecharge, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} /* * View @@ -404,33 +384,6 @@ print ''; print ''.$langs->trans('BindingOptions').''; print "\n"; -// TO DO Mutualize code for yes/no constants -print ''; -print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; -if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { - 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_LIST_SORT_VENTILATION_DONE").''; -if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; -} else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; -} -print ''; - // Param a user $user->rights->accounting->chartofaccount can access foreach ($list_binding as $key) { print ''; @@ -495,14 +448,20 @@ print ''; print ''; print '
'; -// Lettering params + +// Show advanced options +print '
'; + + +// Advanced params print ''; print ''; -print ''; +print ''; print "\n"; print ''; -print ''; +print ''; if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { print ''; if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { print ''; - print ''; + print ''; if (!empty($conf->global->ACCOUNTING_ENABLE_AUTOLETTERING)) { print ''; } +print ''; +print ''; +if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { + print ''; +} else { + print ''; +} +print ''; + print '
'.$langs->trans('Options').' '.$langs->trans('Lettering').'' . $langs->trans('OptionsAdvanced') . '
'.$langs->trans("ACCOUNTING_ENABLE_LETTERING").''; +print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_LETTERING"), $langs->trans("ACCOUNTING_ENABLE_LETTERING_DESC", $langs->transnoentitiesnoconv("NumMvts")).'
'.$langs->trans("EnablingThisFeatureIsNotNecessary")).'
'; print img_picto($langs->trans("Activated"), 'switch_on'); @@ -516,7 +475,8 @@ print '
' . $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING") . ''; + print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING"), $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING_DESC")) . ''; print img_picto($langs->trans("Activated"), 'switch_on'); @@ -529,8 +489,23 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { print '
'; +print $form->textwithpicto($langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE"), $langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC", $langs->transnoentities("MenuDefaultAccounts"))).''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print '
'; + print '
'; print ''; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 620e4158ceb..01bfa1da942 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -416,7 +416,7 @@ if ($resql) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($searchCategoryProductOperator == 1) { $param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator); diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index 40055a4b75f..31b99be39a3 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -296,7 +296,7 @@ if ($resql) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_subaccount) { $param .= '&search_subaccount='.urlencode($search_subaccount); diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index fd8cd8ad688..c45a1202419 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -327,7 +327,7 @@ if ($action != 'export_csv') { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index c1874476fbc..d84c9212659 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -715,7 +715,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } // List of mass actions available diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 419369fe9d3..599e2360147 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -686,7 +686,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 8c21b070d9f..a3c39cb06ee 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -816,8 +816,8 @@ class AccountancyExport // Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!! // as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec // TODO: we should filter more than only accent to avoid wrong line size - // TODO: remove invoice number doc_ref in libelle, - // TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software + // TODO: remove invoice number doc_ref in label, + // TODO: we should offer an option for customer to build the label using invoice number / name / date in accounting software //$Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 30), 30); $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->label_operation, 30), 30); $Tab['codetva'] = str_repeat(' ', 2); diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 8e5f7690dd1..0fd2fb2e61d 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -684,10 +684,10 @@ class AccountingAccount extends CommonObject } /** - * Retourne le libelle du statut d'un user (actif, inactif) + * Return the label of the status * - * @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 + * @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) { @@ -696,11 +696,11 @@ class AccountingAccount extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @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 + * @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) { diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 7c71d073629..f59ba4559e1 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -312,10 +312,10 @@ class AccountingJournal extends CommonObject } /** - * Retourne le libelle du statut d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court - * @return string Label of type + * @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 getLibType($mode = 0) { @@ -327,7 +327,7 @@ class AccountingJournal extends CommonObject * Return type of an accounting journal * * @param int $nature Id type - * @param int $mode 0=libelle long, 1=libelle court + * @param int $mode 0=label long, 1=label short * @return string Label of type */ public function LibType($nature, $mode = 0) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 888cc568cf8..0e5ecd25563 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -65,10 +65,10 @@ $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusonPour le détail de la facture ref…e') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0) { $page = 0; } @@ -81,6 +81,8 @@ if (!$sortfield) { if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = "DESC"; + } else { + $sortorder = "ASC"; } } @@ -159,6 +161,12 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('ac } } +if (GETPOST('sortfield') == 'f.datef, f.ref, fd.rowid') { + $value = (GETPOST('sortorder') == 'asc,asc,asc' ? 0 : 1); + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity); +} + /* * View @@ -317,7 +325,7 @@ if ($result) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_societe) { $param .= "&search_societe=".urlencode($search_societe); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 8834ad69cf8..509e131f766 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -91,6 +91,8 @@ if (!$sortfield) { if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = "DESC"; + } else { + $sortorder = "ASC"; } } @@ -208,6 +210,11 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { } } +if (GETPOST('sortfield') == 'f.datef, f.ref, l.rowid') { + $value = (GETPOST('sortorder') == 'asc,asc,asc' ? 0 : 1); + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $value, 'yesno', 0, '', $conf->entity); +} /* @@ -382,7 +389,7 @@ if ($result) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_societe) { $param .= '&search_societe='.urlencode($search_societe); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 1d0653fc5ac..fbb92ebb18e 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -75,6 +75,8 @@ if (!$sortfield) { if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = "DESC"; + } else { + $sortorder = "ASC"; } } @@ -149,6 +151,12 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->acco } } +if (GETPOST('sortfield') == 'erd.date, erd.rowid') { + $value = (GETPOST('sortorder') == 'asc,asc' ? 0 : 1); + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity); +} + /* * View @@ -248,7 +256,7 @@ if ($result) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_login) { $param .= '&search_login='.urlencode($search_login); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 4ad8c80a2c1..e8822f2f669 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -84,6 +84,8 @@ if (!$sortfield) { if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = "DESC"; + } else { + $sortorder = "ASC"; } } @@ -199,6 +201,11 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { } } +if (GETPOST('sortfield') == 'erd.date, erd.rowid') { + $value = (GETPOST('sortorder') == 'asc,asc' ? 0 : 1); + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $value, 'yesno', 0, '', $conf->entity); +} /* @@ -306,7 +313,7 @@ if ($result) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_login) { $param .= '&search_login='.urlencode($search_login); diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 0137e63406f..89f495a97bc 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -1211,6 +1211,8 @@ if (empty($action) || $action == 'view') { print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; + + $i++; } } @@ -1336,6 +1338,8 @@ if (empty($action) || $action == 'view') { print ''.($mt >= 0 ? price($mt) : '').""; print ""; + + $i++; } } } else { // Waiting account @@ -1373,11 +1377,18 @@ if (empty($action) || $action == 'view') { print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; + + $i++; } } } } + if (!$i) { + $colspan = 8; + print ''.$langs->trans("NoRecordFound").''; + } + print ""; print ''; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index ffffc21a9f9..514edeb4528 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -615,6 +615,8 @@ if (empty($action) || $action == 'view') { print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; + + $i++; } } @@ -649,6 +651,8 @@ if (empty($action) || $action == 'view') { print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; + + $i++; } // VAT @@ -685,11 +689,18 @@ if (empty($action) || $action == 'view') { print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; + + $i++; } } } } + if (!$i) { + $colspan = 7; + print ''.$langs->trans("NoRecordFound").''; + } + print ""; print ''; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 12303089dca..319328cdc6e 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -3,7 +3,7 @@ * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2018 Frédéric France @@ -32,6 +32,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; @@ -103,9 +104,11 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlr, f.close_code,"; +$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle as label, f.ref_supplier, f.date_lim_reglement as dlr, f.close_code, f.vat_reverse_charge,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code, fd.info_bits,"; -$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur,"; +$sql .= " p.default_vat_code AS product_buy_default_vat_code, p.tva_tx as product_buy_vat, p.localtax1_tx as product_buy_localvat1, p.localtax2_tx as product_buy_localvat2,"; +$sql .= " co.code as country_code, co.label as country_label,"; +$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.fk_pays,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { $sql .= " spe.accountancy_code_customer as code_compta,"; $sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,"; @@ -127,6 +130,7 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } @@ -166,12 +170,18 @@ if ($result) { $tablocaltax2 = array(); $tabcompany = array(); $tabother = array(); + $tabrctva = array(); + $tabrclocaltax1 = array(); + $tabrclocaltax2 = array(); $num = $db->num_rows($result); // Variables $cptfour = ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'; $cpttva = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; + $rcctva = (!empty($conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT)) ? $conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT : 'NotDefined'; + $rcdtva = (!empty($conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT)) ? $conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT : 'NotDefined'; + $country_code_in_EEC = getCountriesInEEC(); // This make a database call but there is a cache done into $conf->cache['country_code_in_EEC'] $i = 0; while ($i < $num) { @@ -230,6 +240,53 @@ if ($result) { $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; } + // VAT Reverse charge + if (($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) && $obj->vat_reverse_charge == 1 && in_array($obj->country_code, $country_code_in_EEC)) { + $rcvatdata = getTaxesFromId($obj->product_buy_vat . ($obj->product_buy_default_vat_code ? ' (' . $obj->product_buy_default_vat_code . ')' : ''), $mysoc, $mysoc, 0); + $rcc_compta_tva = (!empty($vatdata['accountancy_code_vat_reverse_charge_credit']) ? $vatdata['accountancy_code_vat_reverse_charge_credit'] : $rcctva); + $rcd_compta_tva = (!empty($vatdata['accountancy_code_vat_reverse_charge_debit']) ? $vatdata['accountancy_code_vat_reverse_charge_debit'] : $rcdtva); + $rcc_compta_localtax1 = (!empty($vatdata['accountancy_code_vat_reverse_charge_credit']) ? $vatdata['accountancy_code_vat_reverse_charge_credit'] : $rcctva); + $rcd_compta_localtax1 = (!empty($vatdata['accountancy_code_vat_reverse_charge_debit']) ? $vatdata['accountancy_code_vat_reverse_charge_debit'] : $rcdtva); + $rcc_compta_localtax2 = (!empty($vatdata['accountancy_code_vat_reverse_charge_credit']) ? $vatdata['accountancy_code_vat_reverse_charge_credit'] : $rcctva); + $rcd_compta_localtax2 = (!empty($vatdata['accountancy_code_vat_reverse_charge_debit']) ? $vatdata['accountancy_code_vat_reverse_charge_debit'] : $rcdtva); + if (price2num($obj->product_buy_vat) || !empty($obj->product_buy_default_vat_code)) { + $vat_key = vatrate($obj->product_buy_vat) . ($obj->product_buy_default_vat_code ? ' (' . $obj->product_buy_default_vat_code . ')' : ''); + $val_value = $vat_key; + $def_tva[$obj->rowid][$rcc_compta_tva][$vat_key] = $val_value; + $def_tva[$obj->rowid][$rcd_compta_tva][$vat_key] = $val_value; + } + + if (!isset($tabrctva[$obj->rowid][$rcc_compta_tva])) { + $tabrctva[$obj->rowid][$rcc_compta_tva] = 0; + } + if (!isset($tabrctva[$obj->rowid][$rcd_compta_tva])) { + $tabrctva[$obj->rowid][$rcd_compta_tva] = 0; + } + if (!isset($tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1])) { + $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] = 0; + } + if (!isset($tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1])) { + $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] = 0; + } + if (!isset($tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2])) { + $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] = 0; + } + if (!isset($tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2])) { + $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] = 0; + } + + $rcvat = (double) price2num($obj->total_ttc * $obj->product_buy_vat / 100, 'MT'); + $rclocalvat1 = (double) price2num($obj->total_ttc * $obj->product_buy_localvat1 / 100, 'MT'); + $rclocalvat2 = (double) price2num($obj->total_ttc * $obj->product_buy_localvat2 / 100, 'MT'); + + $tabrctva[$obj->rowid][$rcd_compta_tva] += $rcvat; + $tabrctva[$obj->rowid][$rcc_compta_tva] -= $rcvat; + $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] += $rclocalvat1; + $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] -= $rclocalvat1; + $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] += $rclocalvat2; + $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] -= $rclocalvat2; + } + $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; @@ -470,6 +527,29 @@ if ($action == 'writebookkeeping') { $arrayofvat = $tablocaltax2; } + // VAT Reverse charge + if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { + $has_vat = false; + foreach ($arrayofvat[$key] as $k => $mt) { + if ($mt) { + $has_vat = true; + } + } + + if (!$has_vat) { + $arrayofvat = $tabrctva; + if ($numtax == 1) { + $arrayofvat = $tabrclocaltax1; + } + if ($numtax == 2) { + $arrayofvat = $tabrclocaltax2; + } + if (!is_array($arrayofvat[$key])) { + $arrayofvat[$key] = array(); + } + } + } + foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label @@ -720,6 +800,29 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $arrayofvat = $tablocaltax2; } + // VAT Reverse charge + if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { + $has_vat = false; + foreach ($arrayofvat[$key] as $k => $mt) { + if ($mt) { + $has_vat = true; + } + } + + if (!$has_vat) { + $arrayofvat = $tabrctva; + if ($numtax == 1) { + $arrayofvat = $tabrclocaltax1; + } + if ($numtax == 2) { + $arrayofvat = $tabrclocaltax2; + } + if (!is_array($arrayofvat[$key])) { + $arrayofvat[$key] = array(); + } + } + } + foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { print '"'.$key.'"'.$sep; @@ -998,6 +1101,29 @@ if (empty($action) || $action == 'view') { $arrayofvat = $tablocaltax2; } + // VAT Reverse charge + if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { + $has_vat = false; + foreach ($arrayofvat[$key] as $k => $mt) { + if ($mt) { + $has_vat = true; + } + } + + if (!$has_vat) { + $arrayofvat = $tabrctva; + if ($numtax == 1) { + $arrayofvat = $tabrclocaltax1; + } + if ($numtax == 2) { + $arrayofvat = $tabrclocaltax2; + } + if (!is_array($arrayofvat[$key])) { + $arrayofvat[$key] = array(); + } + } + } + foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { print ''; diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index cf652a29345..621683ea4cb 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -272,9 +272,10 @@ $object_label = $langs->trans("ObjectsRef"); if ($object->nature == 2 || $object->nature == 3) $object_label = $langs->trans("InvoiceRef"); if ($object->nature == 5) $object_label = $langs->trans("ExpenseReportRef"); -/* - * Show result array - */ + +// Show result array +$i = 0; + print '
'; print '
'; @@ -304,11 +305,21 @@ if (is_array($journal_data) && !empty($journal_data)) { print '' . $line['debit'] . ''; print '' . $line['credit'] . ''; print ''; + + $i++; } } } } +if (!$i) { + $colspan = 7; + if ($object->nature == 4) { + $colspan++; + } + print ''.$langs->trans("NoRecordFound").''; +} + print ''; print '
'; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index ea9841d2fbb..11c4bf290fd 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -83,6 +83,8 @@ if (!$sortfield) { if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = "DESC"; + } else { + $sortorder = "ASC"; } } @@ -164,6 +166,12 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->acco } } +if (GETPOST('sortfield') == 'f.datef, f.ref, l.rowid') { + $value = (GETPOST('sortorder') == 'asc,asc,asc' ? 0 : 1); + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity); +} + /* * View @@ -322,7 +330,7 @@ if ($result) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_societe) { $param .= "&search_societe=".urlencode($search_societe); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 3ec92f490bd..9c9ee109383 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -93,6 +93,8 @@ if (!$sortfield) { if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = "DESC"; + } else { + $sortorder = "ASC"; } } @@ -210,6 +212,11 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { } } +if (GETPOST('sortfield') == 'f.datef, f.ref, l.rowid') { + $value = (GETPOST('sortorder') == 'asc,asc,asc' ? 0 : 1); + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $value, 'yesno', 0, '', $conf->entity); +} /* @@ -386,7 +393,7 @@ if ($result) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_societe) { $param .= '&search_societe='.urlencode($search_societe); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7f9adb32266..5a6853a5f9b 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2413,8 +2413,7 @@ class Adherent extends CommonObject } // Only picto if ($withpictoimg > 0) { - $picto = ''. - img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : $dataparams.' class="'.$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1).''; + $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : $dataparams), 0, 0, $notooltip ? 0 : 1).''; } else { // Picto must be a photo $picto = ''; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 9ee0de6c055..ea7c68bbff8 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -774,7 +774,7 @@ class AdherentType extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (' class="'.(($withpicto != 2) ? 'paddingright' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 5f8dbf07249..90f211d7a33 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -452,10 +452,10 @@ class Subscription extends CommonObject /** - * Retourne le libelle du statut d'une adhesion + * Return the label of the status * - * @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 + * @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) { @@ -464,16 +464,19 @@ class Subscription extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @return string Label + * @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) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; - $langs->load("members"); + + //$langs->load("members"); + return ''; } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 35d4015e270..0c4a5aaccf1 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -188,7 +188,8 @@ $result = restrictedArea($user, 'adherent'); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -324,14 +325,17 @@ $formother = new FormOther($db); $membertypestatic = new AdherentType($db); $memberstatic = new Adherent($db); +$now = dol_now(); + // Page Header $title = $langs->trans("Members")." - ".$langs->trans("List"); $help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; -llxHeader('', $title, $help_url); +$morejs = array(); +$morecss = array(); -$now = dol_now(); - +// Build and execute select +// -------------------------------------------------------------------- if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) { $sql = "SELECT DISTINCT"; } else { @@ -356,7 +360,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); @@ -487,16 +491,14 @@ if ($search_country) { if ($search_import_key) { $sql .= natural_search("d.import_key", $search_import_key); } - // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -// Count total nb of records with no order and no limits +// Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ @@ -510,7 +512,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -533,8 +535,7 @@ if (!$resql) { $num = $db->num_rows($resql); -$arrayofselected = is_array($toselect) ? $toselect : array(); - +// Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -542,6 +543,13 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ exit; } +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll + +$arrayofselected = is_array($toselect) ? $toselect : array(); + if ($search_type > 0) { $membertype = new AdherentType($db); @@ -558,7 +566,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($sall != "") { $param .= "&sall=".urlencode($sall); @@ -1351,7 +1359,7 @@ if ($num == 0) { $colspan++; } } - print ''.$langs->trans("NoRecordFound").''; + print ''.$langs->trans("NoRecordFound").''; } $db->free($resql); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index ea2796ae910..8296fd5591d 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -451,7 +451,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } $param .= '&id='.$rowid; if ($optioncss != '') { diff --git a/htdocs/admin/accounting.php b/htdocs/admin/accounting.php index fba458936b8..18d383a1b3c 100644 --- a/htdocs/admin/accounting.php +++ b/htdocs/admin/accounting.php @@ -55,6 +55,7 @@ $error = 0; $title = $langs->trans("ConfigAccountingExpert"); $help_url = ''; + llxHeader('', $title, $help_url); $linkback = ''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 4baddd8b29b..6b0b722b629 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -226,7 +226,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 880589fb5b1..98a4eec28fb 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -603,7 +603,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Filters print '
'; - print ''; + print '
'; print ''; print ''; print ''; @@ -615,20 +615,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea 'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')), 'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')), 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')), + 'replyto'=>array('label'=>'ReplyTo', 'data-placeholder'=>$langs->trans('SearchString')), 'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')), 'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')), // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2 //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value //'X1'=>'---', - //'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'), - //'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'), 'X2'=>'---', 'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1), 'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1), 'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1), 'answered'=>array('label'=>'Answered', 'data-noparam'=>1), - 'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), - 'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), + 'smaller'=>array('label'=>$langs->trans("Size").' ('.$langs->trans("SmallerThan").")", 'data-placeholder'=>$langs->trans('NumberOfBytes')), + 'larger'=>array('label'=>$langs->trans("Size").' ('.$langs->trans("LargerThan").")", 'data-placeholder'=>$langs->trans('NumberOfBytes')), 'X3'=>'---', 'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1), 'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1), @@ -662,7 +661,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; - print ''; + print ''; print ''; // List filters foreach ($object->filters as $rulefilter) { @@ -690,7 +689,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'.img_picto('', 'filter', 'class="pictofixedwidth opacitymedium"').$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'
'; print ''; print '
'; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; $arrayoftypes = array( @@ -730,13 +735,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; - print ''; + print ''; print ''; // List operations $nboflines = count($object->actions); @@ -766,12 +769,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; // Move up/down diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index ccee1f604b2..20d9ddf4ac9 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -337,7 +337,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index dbf47365440..280a3b06247 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -334,7 +334,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { @@ -627,7 +627,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print '\n\n"; $found++; @@ -242,7 +251,7 @@ if (isModEnabled('commande')) { print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")).''; } print "\n\n"; $found++; @@ -261,7 +270,7 @@ if (isModEnabled("expedition")) { print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).''; } print "\n\n"; $found++; @@ -278,7 +287,7 @@ if (isModEnabled("expedition")) { print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).''; } print "\n\n"; $found++; @@ -313,7 +322,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).''; } print "\n\n"; $found++; @@ -335,7 +344,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).''; } print "\n\n"; $found++; @@ -380,7 +389,7 @@ if (isModEnabled("reception")) { print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).''; } print "\n\n"; $found++; diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 15db7d2ba0d..bc3f4609d1f 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -601,6 +601,9 @@ print '
'; print 'MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = '.getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)')."
"; print '
'; +print 'MAIN_DISALLOW_EXT_URL_INTO_DESCRIPTIONS = '.getDolGlobalString('MAIN_DISALLOW_EXT_URL_INTO_DESCRIPTIONS', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
"; +print '
'; + print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.getDolGlobalString('MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
"; print '
'; diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 3e04243eb72..045ecda2cc7 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -259,7 +259,7 @@ if ($result) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index fcbc01abef1..6013ae41e94 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -226,7 +226,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if (isset($optioncss) && $optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index 166eb12935c..ef9afa10458 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -197,7 +197,7 @@ if ($object->id > 0) { $param .= '&contextpage=' . urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit=' . urlencode($limit); + $param .= '&limit='.((int) $limit); } diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index 4b3b530148d..8f8c551d66b 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -354,7 +354,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index 51a55e0e144..44a0fa504a3 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -199,7 +199,7 @@ if ($object->id > 0) { // $param .= '&contextpage=' . urlencode($contextpage); // } // if ($limit > 0 && $limit != $conf->liste_limit) { - // $param .= '&limit=' . urlencode($limit); + // $param .= '&limit='.((int) $limit); // } // // diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index 51e45f244d0..8ccf50a8ab1 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -360,7 +360,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index b3b2a1d36f4..bf5a07f98b5 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -325,7 +325,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_id != '') { $param .= '&search_id='.urlencode($search_id); diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index ddd57d34e76..5e25d788ac7 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -241,7 +241,7 @@ if ($object->id > 0) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 065a3a578b7..0819c4f1cd1 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -442,7 +442,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } foreach ($search as $key => $val) { if (is_array($search[$key])) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 45cbfdef383..43a40705660 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1168,7 +1168,7 @@ class BOM extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index 16673d6b8a3..f21d88fa02a 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -247,7 +247,7 @@ if ($object->id > 0) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index fd5866eaff8..732ddf20a93 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -396,7 +396,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { diff --git a/htdocs/bookcal/booking_agenda.php b/htdocs/bookcal/booking_agenda.php index b171b953b42..da4c9936860 100644 --- a/htdocs/bookcal/booking_agenda.php +++ b/htdocs/bookcal/booking_agenda.php @@ -247,7 +247,7 @@ if ($object->id > 0) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index e030a52b7e3..e416dd498ed 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -396,7 +396,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index 7e1e3825b39..f1f81f9e45c 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -268,10 +268,10 @@ class Bookmark extends CommonObject } /** - * Return label of contact status + * Return the label of the status * - * @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 + * @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) { diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 34b727aaa16..2bd7109c80b 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -221,7 +221,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 5822e6dd9d2..2b35cc38c4c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1666,7 +1666,7 @@ class ActionComm extends CommonObject } $canread = 0; - if (!empty($user->rights->agenda->myactions->read) && $this->authorid == $user->id) { + if ($user->hasRight('agenda', 'myactions', 'read') && ($this->authorid == $user->id || $this->userownerid == $user->id)) { $canread = 1; // Can read my event } if (!empty($user->rights->agenda->myactions->read) && array_key_exists($user->id, $this->userassigned)) { diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 786e571ee3c..12303f87ed8 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -301,7 +301,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($actioncode != '') { if (is_array($actioncode)) { @@ -934,6 +934,7 @@ while ($i < $imaxinloop) { $actionstatic->datep = $db->jdate($obj->dp); $actionstatic->percentage = $obj->percent; $actionstatic->authorid = $obj->fk_user_author; + $actionstatic->userownerid = $obj->fk_user_action; // Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid // but only if we need it diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 443444859eb..f77833c0e37 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->load("mails"); +$langs->loadLangs(array("mails")); $id = (GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int')); @@ -48,20 +48,18 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $urlfrom = GETPOST('urlfrom'); +$backtopageforcancel = GETPOST('backtopageforcancel'); // Initialize technical objects $object = new Mailing($db); $extrafields = new ExtraFields($db); - -if ($id > 0) { - $result = $object->fetch($id); -} +$hookmanager->initHooks(array('mailingcard', 'globalcard')); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('mailingcard', 'globalcard')); +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $object->substitutionarray = FormMail::getAvailableSubstitKey('emailing'); @@ -86,10 +84,14 @@ $listofmethods['smtps'] = 'SMTP/SMTPS socket library'; if (empty($user->rights->mailing->lire) || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) { accessforbidden(); } +if (empty($action) && empty($object->id)) { + accessforbidden('Object not found'); +} $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + /* * Actions */ @@ -567,7 +569,7 @@ if (empty($reshook)) { } // Action update description of emailing - if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') { + if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto' || $action == 'setevenunsubscribe') { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); if ($action == 'settitle') { @@ -582,10 +584,13 @@ if (empty($reshook)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } elseif ($action == 'setfrom' && empty($object->email_from)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); + } elseif ($action == 'setevenunsubscribe') { + $object->evenunsubscribe = (GETPOST('evenunsubscribe') ? 1 : 0); } if (!$mesg) { - if ($object->update($user) >= 0) { + $result = $object->update($user); + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -747,20 +752,21 @@ llxHeader( array() ); + if ($action == 'create') { // EMailing in creation mode print ''."\n"; print ''; print ''; - $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':

'; foreach ($object->substitutionarray as $key => $val) { $htmltext .= $key.' = '.$langs->trans($val).'
'; } - $htmltext .= '
'; + $htmltext .= '
'; - $availablelink = $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'availvar'); + $availablelink = $form->textwithpicto(''.$langs->trans("AvailableVariables").'', $htmltext, 1, 'help', '', 0, 2, 'availvar'); //print ''.img_picto($langs->trans("ClickToShowDescription"), $imginfo).''; @@ -931,18 +937,9 @@ if ($action == 'create') { dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; + print '
'; print '
'; - - print '
'.img_picto('', 'technic', 'class="pictofixedwidth"').$form->textwithpicto($langs->trans("EmailcollectorOperations"), $langs->trans("EmailcollectorOperationsDesc")).''.img_picto('', 'technic', 'class="pictofixedwidth"').$form->textwithpicto($langs->trans("EmailcollectorOperations"), $langs->trans("EmailcollectorOperationsDesc")).''; + $htmltext = $langs->transnoentitiesnoconv("OperationParamDesc"); + print $form->textwithpicto($langs->trans("Parameters"), $htmltext, 1, 'help', '', 0, 2, 'operationparamtt'); + print '
'; print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'minwidth150 maxwidth300', 1); print ''; - //print ''; - $htmltext = $langs->transnoentitiesnoconv("OperationParamDesc"); - print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'operationparamtt'); + print ''; print ''; print '
'; if ($action == 'editoperation' && $ruleaction['id'] == $operationid) { - print '
'; + //print '
'; + print ''; print ''; print ''; print ''; } else { - print dol_escape_htmltag($ruleaction['actionparam']); + print dol_nl2br(dol_escape_htmltag($ruleaction['actionparam'], 0, 1)); } print '
'; $url = $_SERVER["PHP_SELF"].'?id='.$obj->rowid; if ($limit) { - $url .= '&limit='.urlencode($limit); + $url .= '&limit='.((int) $limit); } if ($page) { $url .= '&page='.urlencode($page); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 47e4939ef82..167e851a6c2 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -623,7 +623,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if (!empty($search) && is_array($search)) { foreach ($search as $key => $val) { diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 1af4b25bb27..09172e985e9 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -478,7 +478,7 @@ if ($mode == 'feature') { if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) { $yesno = 'Yes'; } else { - $yesno = 'No'; + $yesno = 'No'; } require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; $interfaces = new Interfaces($db); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 68bec8431a7..a0e741a290f 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -231,7 +231,7 @@ if ($action == 'install') { if (!$error) { @dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the target directory $submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulenameval; - if (!dol_is_dir($modulenamedir)) { + if (!dol_is_dir($submodulenamedir)) { $submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval; } dol_syslog("We copy now directory ".$submodulenamedir." into target dir ".$dirins.'/'.$modulenameval); @@ -476,7 +476,7 @@ foreach ($modulesdir as $dir) { dol_syslog("Module ".get_class($objMod)." not qualified"); } } else { - print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; + print "admin/modules.php Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } } catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 7a7e49a3129..9c8473f5f7f 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -181,16 +181,25 @@ $formproduct = new FormProduct($db); $disabled = ''; if (isModEnabled('productbatch')) { + // If module lot/serial enabled, we force the inc/dec mode to STOCK_CALCULATE_ON_SHIPMENT_CLOSE and STOCK_CALCULATE_ON_RECEPTION_CLOSE $langs->load("productbatch"); $disabled = ' disabled'; - print info_admin($langs->trans("WhenProductBatchModuleOnOptionAreForced")); + + // STOCK_CALCULATE_ON_SHIPMENT_CLOSE + $descmode = $langs->trans('DeStockOnShipmentOnClosing'); + if (!isModEnabled('reception')) { + // STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER + $incmode = $langs->trans('ReStockOnDispatchOrder'); + } else { + // STOCK_CALCULATE_ON_RECEPTION_CLOSE + $incmode = $langs->trans('StockOnReceptionOnClosing'); + } + print info_admin($langs->trans("WhenProductBatchModuleOnOptionAreForced", $descmode, $incmode)); } -//if (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) -//{ + print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule")); print '
'; -//} print '
'; @@ -221,7 +230,7 @@ if (isModEnabled('facture')) { print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")).''; } print "
'; - - // Description - /* - print ''; - */ + print '
'; - print $form->editfieldkey("MailTitle", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string'); - print ''; - print $form->editfieldval("MailTitle", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string'); - print '
'."\n"; // From print ''; + print '
'; @@ -975,10 +972,18 @@ if ($action == 'create') { } print '
'; + print '
'; + + print '
'; + print '
'; + + print ''; + // Number of distinct emails - print ''; - // Other attributes + // Other attributes. Fields from hook formObjectOptions and Extrafields. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'; + print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); - print ''; + print ''; $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { $text = ''; @@ -1000,12 +1005,14 @@ if ($action == 'create') { } print '
'; + print '
'; + print ''; - print ""; + print '
'; print dol_get_fiche_end(); @@ -1022,11 +1029,8 @@ if ($action == 'create') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneEMailing', $object->ref), 'confirm_clone', $formquestion, 'yes', 2, 240); } - /* - * Actions Buttons - */ - - if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) { + // Actions Buttons + if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test', 'editevenunsubscribe'))) { print "\n\n
\n"; if (($object->statut == 1) && ($user->hasRight('mailing', 'valider') || $object->user_validation == $user->id)) { @@ -1198,17 +1202,32 @@ if ($action == 'create') { $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref = '
'; + // Ref customer + $morehtmlref .= $form->editfieldkey("", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string', '', null, null, '', 1); + $morehtmlref .= '
'; + $morehtmlright = ''; - if ($object->statut == 2) { - $morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + $nbtry = $nbok = 0; + if ($object->statut == 2 || $object->statut == 3) { + $nbtry = $object->countNbOfTargets('alreadysent'); + $nbko = $object->countNbOfTargets('alreadysentko'); + + $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; + if ($nbko) { + $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + } + $morehtmlright .= ')   '; } - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; + print '
'; print '
'; - print ''; + print '
'; /* print ''; @@ -1217,13 +1236,20 @@ if ($action == 'create') { print ''; */ - // Topic - print ''; // From print ''; // To print ''; + print '
'.$langs->trans("Ref").'
'.$langs->trans("MailTitle").''.$object->title.'
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).'
'; + print '
'; + + + print '
'; + print '
'; + + print ''; + // Number of distinct emails print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); @@ -1259,30 +1285,32 @@ if ($action == 'create') { print '
'; print '
'; + print '
'; + + print '
'; print dol_get_fiche_end(); - - print "
\n"; + print "

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

'; foreach ($object->substitutionarray as $key => $val) { $htmltext .= $key.' = '.$langs->trans($val).'
'; } - $htmltext .= '
'; + $htmltext .= '
'; // Print mail content - print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'generic'); + print load_fiche_titre($langs->trans("EMail"), ''.$form->textwithpicto($langs->trans("AvailableVariables").'', $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'generic'); print dol_get_fiche_head(null, '', '', -1); - print ''; + print '
'; // Subject print ''; @@ -1336,6 +1364,7 @@ if ($action == 'create') { print '
'.$langs->trans("MailTopic").'
'; + // Message print '
'; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index ba3839afa5f..16b73702be0 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmailing.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; // Load translation files required by the page $langs->load("mails"); @@ -99,14 +100,22 @@ if ($action == 'add' && $user->hasRight('mailing', 'creer')) { // Add recipient $classname = "mailing_".$module; if (file_exists($file)) { - require_once $file; + include_once $file; // Add targets into database - $obj = new $classname($db); - dol_syslog("Call add_to_target on class ".$classname); - $result = $obj->add_to_target($id); + dol_syslog("Call add_to_target() on class ".$classname." evenunsubscribe=".$object->evenunsubscribe); - $sqlmessage = $obj->sql; + if (class_exists($classname)) { + $obj = new $classname($db); + $obj->evenunsubscribe = $object->evenunsubscribe; + + $result = $obj->add_to_target($id); + + $sqlmessage = $obj->sql; + } else { + $result = -1; + break; + } } } if ($result > 0) { @@ -198,6 +207,38 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_dest_status = ''; } +// Action update description of emailing +if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto' || $action == 'setevenunsubscribe') { + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + + if ($action == 'settitle') { + $object->title = trim(GETPOST('title', 'alpha')); + } elseif ($action == 'setemail_from') { + $object->email_from = trim(GETPOST('email_from', 'alphawithlgt')); // Must allow 'name ' + } elseif ($action == 'setemail_replyto') { + $object->email_replyto = trim(GETPOST('email_replyto', 'alphawithlgt')); // Must allow 'name ' + } elseif ($action == 'setemail_errorsto') { + $object->email_errorsto = trim(GETPOST('email_errorsto', 'alphawithlgt')); // Must allow 'name ' + } elseif ($action == 'settitle' && empty($object->title)) { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); + } elseif ($action == 'setfrom' && empty($object->email_from)) { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); + } elseif ($action == 'setevenunsubscribe') { + $object->evenunsubscribe = (GETPOST('evenunsubscribe') ? 1 : 0); + } + + if (!$mesg) { + $result = $object->update($user); + if ($result >= 0) { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + $mesg = $object->error; + } + + setEventMessages($mesg, null, 'errors'); + $action = ""; +} /* @@ -224,7 +265,7 @@ if ($object->fetch($id) >= 0) { $morehtmlright = ''; $nbtry = $nbok = 0; - if ($object->statut == 2 || $object->statut == 3) { + if ($object->statut == $object::STATUS_SENTPARTIALY || $object->statut == $object::STATUS_SENTCOMPLETELY) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); $nbok = ($nbtry - $nbko); @@ -239,13 +280,12 @@ if ($object->fetch($id) >= 0) { dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; + print '
'; print '
'; print ''; - //print ''; - - print ''; // Errors to - print ''; - // Nb of distinct emails - print '
'.$langs->trans("MailTitle").''.$object->title.'
'.$langs->trans("MailFrom").''; + print '
'.$langs->trans("MailFrom").''; $emailarray = CMailFile::getArrayAddress($object->email_from); foreach ($emailarray as $email => $name) { if ($name && $name != $email) { @@ -264,7 +304,7 @@ if ($object->fetch($id) >= 0) { print '
'.$langs->trans("MailErrorsTo").''; + print '
'.$langs->trans("MailErrorsTo").''; $emailarray = CMailFile::getArrayAddress($object->email_errorsto); foreach ($emailarray as $email => $name) { if ($name != $email) { @@ -280,10 +320,19 @@ if ($object->fetch($id) >= 0) { } print '
'; + print '
'; + print '
'; + + + print '
'; + print '
'; + + print ''; + + // Number of distinct emails + print ''; - print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); - print ''; + print ''; $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { $text = ''; @@ -295,7 +344,7 @@ if ($object->fetch($id) >= 0) { } } if (empty($nbemail)) { - $nbemail .= ' '.img_warning('');//.' '.$langs->trans("NoTargetYet").''; + $nbemail .= ' '.img_warning($langs->trans('ToAddRecipientsChooseHere'));//.' '.$langs->trans("NoTargetYet").''; } if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); @@ -305,16 +354,21 @@ if ($object->fetch($id) >= 0) { } print '
'; + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - print "
"; + print ''; + print '
'; + print '
'; + + print '
'; print dol_get_fiche_end(); print '
'; - $allowaddtarget = ($object->statut == 0); + $allowaddtarget = ($object->statut == $object::STATUS_DRAFT); // Show email selectors if ($allowaddtarget && $user->rights->mailing->creer) { @@ -327,7 +381,11 @@ if ($object->fetch($id) >= 0) { print '
'; print '
'.$langs->trans("RecipientSelectionModules").'
'; print '
'.$langs->trans("NbOfUniqueEMails").'
'; - print '
'.$langs->trans("Filter").'
'; + print '
'.$langs->trans("Filters"); + print '    
'.$langs->trans("EvenUnsubscribe").' '; + print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle', '', 1); + print '
'; + print '
'; print '
 
'; print '
'; // End tr @@ -386,8 +444,9 @@ if ($object->fetch($id) >= 0) { $var = !$var; if ($allowaddtarget) { - print ''; + print ''; print ''; + print ''; print ''; } else { print '
'; @@ -404,6 +463,8 @@ if ($object->fetch($id) >= 0) { print '
'; try { + $obj->evenunsubscribe = $object->evenunsubscribe; // Set flag to include/exclude email that has opt-out. + $nbofrecipient = $obj->getNbOfRecipients(''); } catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); @@ -470,8 +531,10 @@ if ($object->fetch($id) >= 0) { // List of selected targets $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms,"; - $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text"; + $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text,"; + $sql .= " COUNT(mu.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = mc.email"; $sql .= " WHERE mc.fk_mailing=".((int) $object->id); $asearchcriteriahasbeenset = 0; if ($search_lastname) { @@ -494,8 +557,10 @@ if ($object->fetch($id) >= 0) { $sql .= " AND mc.statut = ".((int) $search_dest_status); $asearchcriteriahasbeenset++; } + $sql .= ' GROUP BY mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms, mc.source_url, mc.source_id, mc.source_type, mc.error_text'; $sql .= $db->order($sortfield, $sortorder); + // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -529,7 +594,7 @@ if ($object->fetch($id) >= 0) { $param = "&id=".$object->id; //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_lastname) { $param .= "&search_lastname=".urlencode($search_lastname); @@ -578,6 +643,14 @@ if ($object->fetch($id) >= 0) { // Ligne des champs de filtres print ''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + print $searchpicto; + print ''; + } // EMail print ''; print ''; @@ -614,10 +687,13 @@ if ($object->fetch($id) >= 0) { print $formmailing->selectDestinariesStatus($search_dest_status, 'search_dest_status', 1); print ''; // Action column - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); - print $searchpicto; - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + print $searchpicto; + print ''; + } + print ''; if ($page) { @@ -625,6 +701,10 @@ if ($object->fetch($id) >= 0) { } print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + } print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "mc.lastname", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "mc.firstname", $param, "", "", $sortfield, $sortorder); @@ -635,7 +715,10 @@ if ($object->fetch($id) >= 0) { // Date sending print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, '', 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "mc.statut", $param, '', 'class="right"', $sortfield, $sortorder); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + } print ''; $i = 0; @@ -656,10 +739,37 @@ if ($object->fetch($id) >= 0) { $obj = $db->fetch_object($resql); print ''; - print ''.img_picto('$obj->email', 'email', 'class="paddingright"').dol_escape_htmltag($obj->email).''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + print ''; + if ($obj->statut == $object::STATUS_DRAFT) { // Not sent yet + if (!empty($user->rights->mailing->creer)) { + print ''.img_delete($langs->trans("RemoveRecipient")).''; + } + } + /*if ($obj->statut == -1) // Sent with error + { + print ''.$langs->trans("Retry").''; + }*/ + print ''; + } + + print ''; + print img_picto($obj->email, 'email', 'class="paddingright"'); + if ($obj->nb > 0) { + print img_warning($langs->trans("EmailOptedOut"), 'warning', 'pictofixedwidth'); + } + print dol_escape_htmltag($obj->email); + print ''; + print ''.dol_escape_htmltag($obj->lastname).''; + print ''.dol_escape_htmltag($obj->firstname).''; + print ''.dol_escape_htmltag($obj->other).''; + print ''; if (empty($obj->source_id) || empty($obj->source_type)) { print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility @@ -691,7 +801,7 @@ if ($object->fetch($id) >= 0) { print ''; // Status of recipient sending email (Warning != status of emailing) - if ($obj->statut == 0) { + if ($obj->statut == $object::STATUS_DRAFT) { // Date sent print ''; @@ -707,19 +817,21 @@ if ($object->fetch($id) >= 0) { print ''; } - // Search Icon - print ''; - print ''; - if ($obj->statut == 0) { // Not sent yet - if (!empty($user->rights->mailing->creer) && $allowaddtarget) { - print ''.img_delete($langs->trans("RemoveRecipient")).''; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + print ''; + if ($obj->statut == $object::STATUS_DRAFT) { // Not sent yet + if (!empty($user->rights->mailing->creer)) { + print ''.img_delete($langs->trans("RemoveRecipient")).''; + } } + /*if ($obj->statut == -1) // Sent with error + { + print ''.$langs->trans("Retry").''; + }*/ + print ''; } - /*if ($obj->statut == -1) // Sent with error - { - print ''.$langs->trans("Retry").''; - }*/ - print ''; print ''; $i++; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index ef83c5d1470..451478e8058 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -61,6 +61,11 @@ class Mailing extends CommonObject */ public $body; + /** + * @var int 1=Email will be sent even to email that has opt-out + */ + public $evenunsubscribe; + /** * @var int number of email */ @@ -317,6 +322,7 @@ class Mailing extends CommonObject $sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'"; $sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'"; $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'"; + $sql .= ", evenunsubscribe = ".((int) $this->evenunsubscribe); $sql .= " WHERE rowid = ".(int) $this->id; dol_syslog(__METHOD__, LOG_DEBUG); @@ -351,13 +357,14 @@ class Mailing extends CommonObject * Get object from database * * @param int $rowid Id of emailing + * @param string $ref Title to search from title * @return int <0 if KO, >0 if OK */ - public function fetch($rowid) + public function fetch($rowid, $ref = '') { global $conf; - $sql = "SELECT m.rowid, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage"; + $sql = "SELECT m.rowid, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe"; $sql .= ", m.email_from, m.email_replyto, m.email_errorsto"; $sql .= ", m.statut, m.nbemail"; $sql .= ", m.fk_user_creat, m.fk_user_valid"; @@ -366,7 +373,12 @@ class Mailing extends CommonObject $sql .= ", m.date_envoi"; $sql .= ", m.extraparams"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; - $sql .= " WHERE m.rowid = ".(int) $rowid; + $sql .= " WHERE entity IN (".getEntity('mailing').")"; + if ($ref) { + $sql .= " AND m.titre = '".$this->db->escape($ref)."'"; + } else { + $sql .= " AND m.rowid = ".(int) $rowid; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -389,6 +401,7 @@ class Mailing extends CommonObject $this->bgcolor = $obj->bgcolor; $this->bgimage = $obj->bgimage; + $this->evenunsubscribe = $obj->evenunsubscribe; $this->email_from = $obj->email_from; $this->email_replyto = $obj->email_replyto; @@ -454,6 +467,7 @@ class Mailing extends CommonObject $object->body = ''; $object->bgcolor = ''; $object->bgimage = ''; + $object->evenunsubscribe = 0; //$object->email_from = ''; // We do not reset from email because it is a mandatory value $object->email_replyto = ''; @@ -891,7 +905,7 @@ class Mailing extends CommonObject /** - * Return the label of a given status of a recipient + * Return the label of a given status of a recipient * TODO Add class mailin_target.class.php * * @param int $status Id status diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index e6163b9f2da..3fea5458a2d 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -271,7 +271,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); diff --git a/htdocs/comm/propal/agenda.php b/htdocs/comm/propal/agenda.php index 42e15dca146..c679fd267da 100644 --- a/htdocs/comm/propal/agenda.php +++ b/htdocs/comm/propal/agenda.php @@ -230,7 +230,7 @@ if ($object->id > 0) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } // Try to know count of actioncomm from cache diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 13b9aa1a4fe..1b159c9a113 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -875,7 +875,7 @@ if ($resql) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($sall) { $param .= '&sall='.urlencode($sall); diff --git a/htdocs/commande/agenda.php b/htdocs/commande/agenda.php index a998229f776..0cb944afa63 100644 --- a/htdocs/commande/agenda.php +++ b/htdocs/commande/agenda.php @@ -230,7 +230,7 @@ if ($object->id > 0) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } // Try to know count of actioncomm from cache diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 27b9a05181b..49e6b0b3555 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -587,7 +587,7 @@ if (empty($reshook)) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($sall) { $param .= '&sall='.urlencode($sall); @@ -1143,7 +1143,7 @@ if ($resql) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($sall) { $param .= '&sall='.urlencode($sall); diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index d5b0336b95a..3faa292b78d 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -671,7 +671,7 @@ if ($resql) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($sall) { $param .= '&sall='.urlencode($sall); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index a678c176ca7..5740c58c86c 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -286,7 +286,7 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' $param .= '&offset='.urlencode($offset); } if ($limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_conciliated != '' && $search_conciliated != '-1') { $param .= '&search_conciliated='.urlencode($search_conciliated); @@ -438,7 +438,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($id > 0) { $param .= '&id='.urlencode($id); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index f9a665640cd..c036a0b3414 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -2589,10 +2589,10 @@ class AccountLine extends CommonObjectLine /** - * Return label of status (activity, closed) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * @return string Libelle + * @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) { @@ -2601,11 +2601,11 @@ class AccountLine extends CommonObjectLine // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given 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 Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 912f46e074a..7029bddb6d1 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -603,10 +603,10 @@ class PaymentVarious extends CommonObject /** - * Retourne le libelle du statut + * Return the 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 - * @return string Libelle + * @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) { @@ -615,11 +615,11 @@ class PaymentVarious extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given 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 - * @return string Libelle + * @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) { diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 073e9de9a15..85c9e72af5a 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -313,7 +313,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_ref != '') { $param .= '&search_ref='.urlencode($search_ref); diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index d72238e3fe6..ec703f3fea4 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -351,7 +351,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 1333a6b2346..4451707bdff 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -348,7 +348,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } foreach ($search as $key => $val) { if (is_array($search[$key])) { diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index fa812a14c3d..c0254f6c316 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -338,10 +338,10 @@ class Deplacement extends CommonObject /** - * Retourne le libelle du statut + * Return the 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 - * @return string Libelle + * @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) { @@ -350,11 +350,11 @@ class Deplacement extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given 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 - * @return string Libelle + * @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) { diff --git a/htdocs/compta/facture/agenda.php b/htdocs/compta/facture/agenda.php index a452a8dd6aa..45f495c1723 100644 --- a/htdocs/compta/facture/agenda.php +++ b/htdocs/compta/facture/agenda.php @@ -230,7 +230,7 @@ if ($object->id > 0) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } // Try to know count of actioncomm from cache diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 58c7e35724d..901207a8d58 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3908,7 +3908,7 @@ if ($action == 'create') { print $objectsrc->getNomUrl(1); // We check if Origin document (id and type is known) has already at least one invoice attached to it $objectsrc->fetchObjectLinked($originid, $origin, '', 'facture'); - if (is_array($objectsrc->linkedObjects['facture']) && count($objectsrc->linkedObjects['facture']) >= 1) { + if (isset($objectsrc->linkedObjects['facture']) && is_array($objectsrc->linkedObjects['facture']) && count($objectsrc->linkedObjects['facture']) >= 1) { setEventMessages('WarningBillExist', null, 'warnings'); echo ' - '.$langs->trans('LatestRelatedBill').' '.end($objectsrc->linkedObjects['facture'])->getNomUrl(1); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5d69bb2b6dd..b9b4ff3d1c2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3393,7 +3393,6 @@ class Facture extends CommonInvoice // Set new ref and define current status if (!$error) { - $this->ref = $num; $this->ref = $num; $this->statut = self::STATUS_VALIDATED; $this->status = self::STATUS_VALIDATED; @@ -6441,7 +6440,7 @@ class FactureLigne extends CommonInvoiceLine return -1; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'element_time'; $sql .= ' SET invoice_id = NULL, invoice_line_id = NULL'; $sql .= ' WHERE invoice_line_id = '.((int) $this->id); if (!$this->db->query($sql)) { diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index d0c8ea7f1f5..e0d45a5e38f 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -440,7 +440,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($socid > 0) { $param .= '&socid='.urlencode($socid); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 928ffcfc4bd..407b2dc4e3c 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -993,7 +993,7 @@ if ($resql) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($sall) { $param .= '&sall='.urlencode($sall); @@ -2590,6 +2590,9 @@ if ($resql) { $i++; } + // Use correct digits number for totals + $totalarray['val']['total_margin'] = price2num($totalarray['val']['total_margin'], 'MT'); + // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; } diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 95647d0f65e..7adb74fbc4e 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -604,10 +604,10 @@ class Localtax extends CommonObject } /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @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 + * @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) { @@ -616,16 +616,16 @@ class Localtax extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @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 + * @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 - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + //global $langs; return ''; } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index e84b0004564..3732c37ab2f 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -995,10 +995,10 @@ class RemiseCheque extends CommonObject } /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @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 + * @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) { @@ -1007,11 +1007,11 @@ class RemiseCheque extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return label of a status + * Return the label of a given 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 Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index f573ec5be56..4be546c792c 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1303,10 +1303,10 @@ class Paiement extends CommonObject } /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @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 + * @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) { @@ -1315,11 +1315,11 @@ class Paiement extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @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 + * @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) { diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 6db18f6aa55..5e39e05c818 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -301,7 +301,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if (GETPOST("orphelins")) { diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php index 6089f9dbcb5..88650256ecc 100644 --- a/htdocs/compta/payment_vat/card.php +++ b/htdocs/compta/payment_vat/card.php @@ -222,11 +222,8 @@ print dol_get_fiche_end(); $disable_delete = 0; $sql = 'SELECT f.rowid as scid, f.label as label, f.paye, f.amount as tva_amount, pf.amount'; -//$sql .= ', pc.libelle as sc_type'; $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_vat as pf,'.MAIN_DB_PREFIX.'tva as f'; -//$sql .= ', '.MAIN_DB_PREFIX.'c_chargesociales as pc'; $sql .= ' WHERE pf.fk_tva = f.rowid'; -//$sql .= ' AND f.fk_type = pc.id'; $sql .= ' AND f.entity = '.$conf->entity; $sql .= ' AND pf.rowid = '.((int) $object->id); diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 727b3b85f48..8752e63517a 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -412,7 +412,7 @@ if ($id > 0 || $ref) { $urladd = "&id=".urlencode($id); if ($limit > 0 && $limit != $conf->liste_limit) { - $urladd .= '&limit='.urlencode($limit); + $urladd .= '&limit='.((int) $limit); } print ''."\n"; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3618817e19a..f4f88885a00 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1888,7 +1888,7 @@ class BonPrelevement extends CommonObject fputs($this->file, substr("000000000000000".$montant, -16)); - // Libelle F + // Label F fputs($this->file, substr("*_".$ref."_RDVnet".$rowid." ", 0, 31)); diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 85f0be90125..39c48e0767e 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -395,7 +395,7 @@ if ($resql) { $param = ''; if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($socid) { $param .= '&socid='.urlencode($socid); diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 4c3d26720c3..949ebed87c5 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -235,7 +235,7 @@ if ($resql) { $i = 0; if ($limit > 0 && $limit != $conf->liste_limit) { - $param.='&limit='.urlencode($limit); + $param.='&limit='.((int) $limit); } $param = "&id=".urlencode($id); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 307a7239fe8..96c365997b0 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -196,7 +196,7 @@ if ($result) { $param .= '&type=bank-transfer'; } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index 8dd056ed796..974ed47deff 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -159,7 +159,7 @@ if ($result) { $param .= '&type=bank-transfer'; } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } $param .= "&statut=".urlencode($statut); diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index d03132b04f7..741179d067e 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -441,9 +441,9 @@ class Cchargesociales } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of the 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 $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) @@ -453,11 +453,11 @@ class Cchargesociales // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un status donne + * Return the label of a given status * - * @param int $status Id status - * @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 + * @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) { diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 73d101d7ae6..a798eee92bb 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -664,10 +664,10 @@ class PaymentSocialContribution extends CommonObject /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @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 + * @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) { @@ -676,11 +676,11 @@ class PaymentSocialContribution extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @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 + * @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) { diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index ed92d834488..6ea46c3ea4e 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -314,7 +314,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 9956cf5153a..8c575ad4b6a 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -114,7 +114,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($sortfield) { $param .= '&sortfield='.urlencode($sortfield); diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index fcc241c728d..3a088ca30b5 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -663,16 +663,16 @@ class PaymentVAT extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @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 + * @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 - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + global $langs; $langs->load('compta'); /*if ($mode == 0) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 2be181d7350..15e8dc8609a 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -849,7 +849,7 @@ class Tva extends CommonObject } /** - * Retourne le libelle du statut d'une TVA (impaye, payee) + * Return the label of the VAT status f object * * @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 * @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) @@ -862,7 +862,7 @@ class Tva extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given VAT 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 diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index eddba0b5ad3..23fcf2d8c0a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1580,10 +1580,10 @@ class Contact extends CommonObject } /** - * Return label of contact status + * Return the label of the status * - * @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 + * @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) { @@ -1592,11 +1592,11 @@ class Contact extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given 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 Libelle + * @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) { @@ -2009,9 +2009,9 @@ class Contact extends CommonObject /** * Return status of prospect * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @param int $mode 0=label long, 1=label short, 2=Picto + Label short, 3=Picto, 4=Picto + Label long * @param string $label Label to use for status for added status - * @return string Libelle + * @return string Label */ public function getLibProspCommStatut($mode = 0, $label = '') { @@ -2029,7 +2029,7 @@ class Contact extends CommonObject * Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img * Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img * Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1) - * @return string Libelle du statut + * @return string Label of status */ public function libProspCommStatut($statut, $mode = 0, $label = '', $picto = '') { diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 8efae5a836d..7b2374830b3 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -382,7 +382,7 @@ if ($sql_select) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($sprod_fulldescr) { $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7a8fb3114fc..a6177876bf7 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -746,12 +746,22 @@ if (empty($reshook)) { $fk_unit = GETPOST('unit', 'alpha'); + // update price_ht with discount + // TODO Use object->updateline instead objedtline->update + + $price_ht = price2num(GETPOST('elprice'), 'MU'); + $remise_percent = price2num(GETPOST('elremise_percent'), 2); + if ($remise_percent > 0) { + $remise = round(($price_ht * $remise_percent / 100), 2); + $price_ht = ($price_ht - $remise); + } + $objectline->fk_product = GETPOST('idprod', 'int'); $objectline->description = GETPOST('product_desc', 'restricthtml'); - $objectline->price_ht = price2num(GETPOST('elprice'), 'MU'); + $objectline->price_ht = $price_ht; $objectline->subprice = price2num(GETPOST('elprice'), 'MU'); $objectline->qty = price2num(GETPOST('elqty'), 'MS'); - $objectline->remise_percent = price2num(GETPOST('elremise_percent'), 2); + $objectline->remise_percent = $remise_percent; $objectline->tva_tx = ($txtva ? $txtva : 0); // Field may be disabled, so we use vat rate 0 $objectline->vat_src_code = $vat_src_code; $objectline->localtax1_tx = is_numeric($localtax1_tx) ? $localtax1_tx : 0; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 15b4776c2b9..a671297b0de 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -545,7 +545,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } if ($search_all != '') { $param .= '&search_all='.urlencode($search_all); diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index ed670627a90..5166ba52b52 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2023 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 @@ -17,7 +17,7 @@ /** * \file htdocs/core/ajax/objectonoff.php - * \brief File to set status for an object + * \brief File to set status for an object. Called when ajax_object_onoff() is used. * This Ajax service is oftenly called when option MAIN_DIRECT_STATUS_UPDATE is set. */ @@ -45,6 +45,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; $action = GETPOST('action', 'aZ09'); +$backtopage = GETPOST('backtopage'); $id = GETPOST('id', 'int'); $element = GETPOST('element', 'alpha'); // 'myobject' (myobject=mymodule) or 'myobject@mymodule' or 'myobject_mysubobject' (myobject=mymodule) @@ -79,7 +80,7 @@ if (!empty($user->socid)) { // We check permission. // Check is done on $user->rights->element->create or $user->rights->element->subelement->create (because $action = 'set') -if (preg_match('/status$/', $field)) { +if (preg_match('/status$/', $field) || ($field == 'evenunsubscribe' && $object->table_element == 'mailing')) { restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission); } elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) { // Special case for products restrictedArea($user, 'produit|service', $object, 'product&product', '', '', 'rowid'); @@ -114,4 +115,9 @@ if (($action == 'set') && !empty($id)) { http_response_code(500); exit; } + + if ($backtopage) { + header('Location: '.$backtopage); + exit; + } } diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index cdaa9298f63..2cecc278392 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -152,7 +152,7 @@ class box_funnel_of_prospection extends ModeleBoxes 'graph' => '1' ); - if ($user->rights->projet->lire || !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + if ($user->hasRight('projet', 'lire') || getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { $sql = "SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."c_lead_status as cls"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 127584e3f9f..64e4d690308 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1236,8 +1236,8 @@ abstract class CommonDocGenerator // save curent cell padding $curentCellPaddinds = $pdf->getCellPaddings(); // set cell padding with column content definition - $pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]); - $pdf->writeHTMLCell($colDef['width'], 2, $colDef['xStartPos'], $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); + $pdf->setCellPaddings(isset($colDef['content']['padding'][3]) ? $colDef['content']['padding'][3] : 0, isset($colDef['content']['padding'][0]) ? $colDef['content']['padding'][0] : 0, isset($colDef['content']['padding'][1]) ? $colDef['content']['padding'][1] : 0, isset($colDef['content']['padding'][2]) ? $colDef['content']['padding'][2] : 0); + $pdf->writeHTMLCell($colDef['width'], 2, isset($colDef['xStartPos']) ? $colDef['xStartPos'] : 0, $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); // restore cell padding $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e53cc85c21f..d411321386b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6461,6 +6461,14 @@ abstract class CommonObject dol_syslog('Error bad setup of extrafield', LOG_WARNING); } break; + case 'checkbox': + case 'chkbxlst': + if (is_array($this->array_options[$key])) { + $new_array_options[$key] = implode(',', $this->array_options[$key]); + } else { + $new_array_options[$key] = $this->array_options[$key]; + } + break; } } @@ -6814,6 +6822,14 @@ abstract class CommonObject } break; */ + case 'checkbox': + case 'chkbxlst': + if (is_array($this->array_options[$key])) { + $new_array_options[$key] = implode(',', $this->array_options[$key]); + } else { + $new_array_options[$key] = $this->array_options[$key]; + } + break; } $this->db->begin(); @@ -8256,7 +8272,7 @@ abstract class CommonObject // Test on 'enabled' ('enabled' is different than 'list' = 'visibility') $enabled = 1; if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key])) { - $enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '1'); + $enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '2'); } if (empty($enabled)) { continue; @@ -8264,12 +8280,12 @@ abstract class CommonObject $visibility = 1; if ($visibility && isset($extrafields->attributes[$this->table_element]['list'][$key])) { - $visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '1'); + $visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '2'); } $perms = 1; if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key])) { - $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '1'); + $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '2'); } if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) { @@ -9982,7 +9998,7 @@ abstract class CommonObject $this->db->begin(); $statusfield = 'status'; - if ($this->element == 'don' || $this->element == 'donation') { + if (in_array($this->element, array('don', 'donation', 'shipping'))) { $statusfield = 'fk_statut'; } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 589d28453fc..b3991ecfcf2 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -109,6 +109,24 @@ class Conf public $tzuserinputkey = 'tzserver'; // Use 'tzuserrel' to always store date in GMT and show date in time zone of user. + // TODO Remove this part. + public $fournisseur; + public $product; + public $service; + public $contrat; + public $actions; + public $agenda; + public $commande; + public $propal; + public $facture; + public $user; + public $adherent; + public $bank; + public $notification; + public $expensereport; + public $productbatch; + + /** * Constructor @@ -165,7 +183,6 @@ class Conf $this->commande = new stdClass(); $this->propal = new stdClass(); $this->facture = new stdClass(); - $this->contrat = new stdClass(); $this->user = new stdClass(); $this->adherent = new stdClass(); $this->bank = new stdClass(); @@ -635,18 +652,19 @@ class Conf unset($this->global->PROJECT_USE_SEARCH_TO_SELECT); } - if (!empty($this->productbatch->enabled)) { + if (isModEnabled('productbatch')) { + // If module lot/serial enabled, we force the inc/dec mode to STOCK_CALCULATE_ON_SHIPMENT_CLOSE and STOCK_CALCULATE_ON_RECEPTION_CLOSE $this->global->STOCK_CALCULATE_ON_BILL = 0; $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0; - if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1; if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT)) $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 1; + if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1; $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0; - if (empty($this->reception->enabled)) { + if (!isModEnabled('reception')) { $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1; } else { - if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) $this->global->STOCK_CALCULATE_ON_RECEPTION = 1; if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION)) $this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 1; + if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) $this->global->STOCK_CALCULATE_ON_RECEPTION = 1; } } diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index c43ba48db10..229e5b9e352 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -305,10 +305,10 @@ class EmailSenderProfile extends CommonObject } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of a given status * - * @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 + * @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) { @@ -317,11 +317,11 @@ class EmailSenderProfile extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return the status + * Return the label of a given 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 */ public static function LibStatut($status, $mode = 0) { diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 73a8b86ea47..5c44e140be9 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -961,9 +961,9 @@ class ExtraFields $unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key]; $required = $this->attributes[$extrafieldsobjectkey]['required'][$key]; $param = $this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1'); + $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '2'); $langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1'); + $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '2'); $totalizable = $this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) @@ -1267,7 +1267,7 @@ class ExtraFields $labeltoshow = ''; $obj = $this->db->fetch_object($resql); - // Several field into label (eq table:code|libelle:rowid) + // Several field into label (eq table:code|label:rowid) $notrans = false; $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label) && count($fields_label) > 1) { @@ -1487,7 +1487,7 @@ class ExtraFields $obj = $this->db->fetch_object($resql); $notrans = false; - // Several field into label (eq table:code|libelle:rowid) + // Several field into label (eq table:code|label:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label)) { $notrans = true; @@ -1597,9 +1597,9 @@ class ExtraFields $unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key]; $required = $this->attributes[$extrafieldsobjectkey]['required'][$key]; $param = $this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1'); + $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '2'); $langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1'); + $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '2'); $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) @@ -1722,7 +1722,7 @@ class ExtraFields $obj = $this->db->fetch_object($resql); - // Several field into label (eq table:code|libelle:rowid) + // Several field into label (eq table:code|label:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label) && count($fields_label) > 1) { @@ -1830,7 +1830,7 @@ class ExtraFields $value = ''; // value was used, so now we reste it to use it to build final output $toprint = array(); while ($obj = $this->db->fetch_object($resql)) { - // Several field into label (eq table:code|libelle:rowid) + // Several field into label (eq table:code|label:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { if (is_array($fields_label) && count($fields_label) > 1) { @@ -2097,17 +2097,17 @@ class ExtraFields $enabled = 1; if (isset($this->attributes[$object->table_element]['enabled'][$key])) { // 'enabled' is often a condition on module enabled or not - $enabled = dol_eval($this->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'); + $enabled = dol_eval($this->attributes[$object->table_element]['enabled'][$key], 1, 1, '2'); } $visibility = 1; if (isset($this->attributes[$object->table_element]['list'][$key])) { // 'list' is option for visibility - $visibility = intval(dol_eval($this->attributes[$object->table_element]['list'][$key], 1, 1, '1')); + $visibility = intval(dol_eval($this->attributes[$object->table_element]['list'][$key], 1, 1, '2')); } $perms = 1; if (isset($this->attributes[$object->table_element]['perms'][$key])) { - $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1, 1, '1'); + $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1, 1, '2'); } if (empty($enabled) || ( diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index cf512d5f173..5484fea6663 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -196,7 +196,7 @@ class Form * @param string $value Value to show/edit * @param object $object Object (that we want to show) * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') + * @param string $typeofdata Type of data ('string' by default, 'checkbox', 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value, or a select combo). Use '' to use same than $value * @param object $extObject External object ??? * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') @@ -267,7 +267,7 @@ class Form $ret .= ''; } elseif (preg_match('/^(checkbox)/', $typeofdata)) { $tmp = explode(':', $typeofdata); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { // if wysiwyg is enabled $typeofdata = 'ckeditor' $tmp = explode(':', $typeofdata); $cols = (empty($tmp[2]) ? '' : $tmp[2]); @@ -342,7 +342,7 @@ class Form $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); } elseif (preg_match('/^(checkbox)/', $typeofdata)) { $tmp = explode(':', $typeofdata); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { $ret .= dol_htmlentitiesbr($value); } elseif (preg_match('/^safehtmlstring/', $typeofdata)) { @@ -5087,21 +5087,21 @@ class Form * print '});'."\n"; * print ''."\n"; * - * @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated) - * @param string $title Title - * @param string $question Question - * @param string $action Action - * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...')) - * 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss', - * 'other', 'onecolumn' or 'hidden'... - * @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0 - * @param int|string $useajax 0=No, 1=Yes use Ajax to show the popup, 2=Yes and also submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx - * @param int|string $height Force height of box (0 = auto) - * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones. - * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a section. - * @param string $labelbuttonyes Label for Yes - * @param string $labelbuttonno Label for No - * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form + * @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated) + * @param string $title Title + * @param string $question Question + * @param string $action Action + * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...')) + * 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss', + * 'other', 'onecolumn' or 'hidden'... + * @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0 + * @param int|string $useajax 0=No, 1=Yes use Ajax to show the popup, 2=Yes and also submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx + * @param int|string $height Force height of box (0 = auto) + * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones. + * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a section. + * @param string $labelbuttonyes Label for Yes + * @param string $labelbuttonno Label for No + * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form */ public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes = 'Yes', $labelbuttonno = 'No') { @@ -8112,26 +8112,26 @@ class Form /** - * Return a HTML select string, built from an array of key+value. + * Return a HTML select string, built from an array of key+value. * Note: Do not apply langs->trans function on returned content, content may be entity encoded twice. * - * @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect - * @param array $array Array like array(key => value) or array(key=>array('label'=>..., 'data-...'=>..., 'disabled'=>..., 'css'=>...)) - * @param string|string[] $id Preselected key or preselected keys for multiselect. Use 'ifone' to autoselect record if there is only one record. - * @param int|string $show_empty 0 no empty value allowed, 1 or string to add an empty value into list (If 1: key is -1 and value is '' or ' ', If placeholder string: key is -1 and value is the string), <0 to add an empty value with key that is this value. - * @param int $key_in_label 1 to show key into label with format "[key] value" - * @param int $value_as_key 1 to use value as key - * @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 int $translate 1=Translate and encode value - * @param int $maxlen Length maximum for labels - * @param int $disabled Html select box is disabled - * @param string $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' or 'POS' = Do not sort, we keep original order - * @param string $morecss Add more class to css styles - * @param int $addjscombo Add js combo - * @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set - * @param int $disablebademail 1=Check if a not valid email, 2=Check string '---', and if found into value, disable and colorize entry - * @param int $nohtmlescape No html escaping. - * @return string HTML select string. + * @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect + * @param array $array Array like array(key => value) or array(key=>array('label'=>..., 'data-...'=>..., 'disabled'=>..., 'css'=>...)) + * @param string|string[] $id Preselected key or preselected keys for multiselect. Use 'ifone' to autoselect record if there is only one record. + * @param int|string $show_empty 0 no empty value allowed, 1 or string to add an empty value into list (If 1: key is -1 and value is '' or ' ', If placeholder string: key is -1 and value is the string), <0 to add an empty value with key that is this value. + * @param int $key_in_label 1 to show key into label with format "[key] value" + * @param int $value_as_key 1 to use value as key + * @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 int $translate 1=Translate and encode value + * @param int $maxlen Length maximum for labels + * @param int $disabled Html select box is disabled + * @param string $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' or 'POS' = Do not sort, we keep original order + * @param string $morecss Add more class to css styles + * @param int $addjscombo Add js combo + * @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set + * @param int $disablebademail 1=Check if a not valid email, 2=Check string '---', and if found into value, disable and colorize entry + * @param int $nohtmlescape No html escaping. + * @return string HTML select string. * @see multiselectarray(), selectArrayAjax(), selectArrayFilter() */ public static function selectarray($htmlname, $array, $id = '', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam = '', $translate = 0, $maxlen = 0, $disabled = 0, $sort = '', $morecss = 'minwidth75', $addjscombo = 1, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0) @@ -8245,7 +8245,7 @@ class Form if (is_array($tmpvalue)) { foreach ($tmpvalue as $keyforvalue => $valueforvalue) { if (preg_match('/^data-/', $keyforvalue)) { - $out .= ' ' . $keyforvalue . '="' . $valueforvalue . '"'; + $out .= ' '.$keyforvalue.'="'.dol_escape_htmltag($valueforvalue).'"'; } } } @@ -8377,18 +8377,18 @@ class Form * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. * - * @param string $htmlname Name of html select area - * @param array $array Array (key=>array('text'=>'A text', 'url'=>'An url'), ...) - * @param string $id Preselected key - * @param string $moreparam Add more parameters onto the select tag - * @param int $disableFiltering If set to 1, results are not filtered with searched string - * @param int $disabled Html select box is disabled - * @param int $minimumInputLength Minimum Input Length - * @param string $morecss Add more class to css styles - * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected. - * @param string $placeholder String to use as placeholder - * @param integer $acceptdelayedhtml 1 = caller is requesting to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) - * @return string HTML select string + * @param string $htmlname Name of html select area + * @param array $array Array (key=>array('text'=>'A text', 'url'=>'An url'), ...) + * @param string $id Preselected key + * @param string $moreparam Add more parameters onto the select tag + * @param int $disableFiltering If set to 1, results are not filtered with searched string + * @param int $disabled Html select box is disabled + * @param int $minimumInputLength Minimum Input Length + * @param string $morecss Add more class to css styles + * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected. + * @param string $placeholder String to use as placeholder + * @param integer $acceptdelayedhtml 1 = caller is requesting to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) + * @return string HTML select string * @see selectArrayAjax(), ajax_combobox() in ajax.lib.php */ public static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0) @@ -8401,7 +8401,7 @@ class Form return ''; } - $out = ''; + $out = ''; $formattedarrayresult = array(); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 118e75773c1..6bcd8ea1e6c 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -429,7 +429,9 @@ class FormOther if (!is_numeric($showempty)) { $textforempty = $showempty; } - $moreforfilter .= ''."\n"; + $moreforfilter .= '