From 895957e89da1de1e296e3310acb93108d6939642 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Thu, 2 Feb 2023 08:41:08 +0100 Subject: [PATCH 01/12] Modify margin rates in offers like VAT rates. --- htdocs/admin/propal.php | 13 ++++++++++ htdocs/comm/propal/card.php | 31 ++++++++++++++++++++++++ htdocs/core/tpl/objectline_title.tpl.php | 16 +++++++++--- htdocs/langs/en_US/margins.lang | 1 + htdocs/langs/fr_FR/margins.lang | 1 + 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 10044e33b5b..289c514c703 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -615,6 +615,19 @@ print " \n"; print ""; +print ''; +print ''.$langs->trans("ModifyMarginRates").''; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PROPALE_MODIFY_MARGIN_RATES'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("PROPALE_MODIFY_MARGIN_RATES", $arrval, $conf->global->PROPALE_MODIFY_MARGIN_RATES); +} +print "\n"; +print ''; +print "\n"; + print "
"; print ''; print ""; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3f74c4a860f..c1912451cc8 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -914,6 +914,37 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } + } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines', 'none') !== '' && $usercancreate) { + // Define margin + $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); + foreach ($object->lines as &$line) { + $subprice = price2num($line->pa_ht * (1 + $margin_rate/100), 'MU'); + $prod = new Product($db); + $prod->fetch($line->fk_product); + if ($prod->price_min > $subprice) { + $price_subprice = price($subprice, 0, $outlangs, 1, -1, -1, 'auto'); + $price_price_min = price($prod->price_min, 0, $outlangs, 1, -1, -1, 'auto'); + setEventMessages($prod->ref.' - '.$prod->label.' ('.$price_subprice.' < '.$price_price_min.' '.strtolower($langs->trans("MinPrice")).')'."\n", null, 'warnings'); + } + // Manage $line->subprice and $line->multicurrency_subprice + $multicurrency_subprice = $subprice * $line->multicurrency_subprice / $line->subprice; + // Update DB + $result = $object->updateline($line->id, $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_rate, $line->localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice); + // Update $object with new margin info + $line->price = $subprice; + $line->marge_tx = $margin_rate; + $line->marque_tx = $margin_rate * $line->pa_ht / $subprice; + $line->total_ht = $line->qty * $subprice; + $line->total_tva = $line->tva_tx * $line->qty * $subprice; + $line->total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice; + // Manage $line->subprice and $line->multicurrency_subprice + $line->multicurrency_total_ht = $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_tva = $line->tva_tx * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + // Used previous $line->subprice and $line->multicurrency_subprice above, now they can be set to their new values + $line->subprice = $subprice; + $line->multicurrency_subprice = $multicurrency_subprice; + } } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 4640d710705..991910865e4 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -140,9 +140,19 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { } } - if (!empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { - print ''.$langs->trans('MarginRate').''; - } + if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { + print ''.$langs->trans('MarginRate'); + if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { + print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; + if (GETPOST('mode', 'aZ09') == 'marginforalllines') { + print '
'; + print ''; + print ''; + print '
'; + } + } + print ''; + } if (!empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) { print ''.$langs->trans('MarkRate').''; } diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index a91b139ec7b..9101966eff2 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -6,6 +6,7 @@ TotalMargin=Total Margin MarginOnProducts=Margin / Products MarginOnServices=Margin / Services MarginRate=Margin rate +ModifyMarginRates=Modify margin rates MarkRate=Mark rate DisplayMarginRates=Display margin rates DisplayMarkRates=Display mark rates diff --git a/htdocs/langs/fr_FR/margins.lang b/htdocs/langs/fr_FR/margins.lang index a8a68c6599f..742b8ce76c0 100644 --- a/htdocs/langs/fr_FR/margins.lang +++ b/htdocs/langs/fr_FR/margins.lang @@ -8,6 +8,7 @@ MarginOnServices=Marge / Services MarginRate=Taux de marge MarkRate=Taux de marque DisplayMarginRates=Afficher les taux de marge +ModifyMarginRates=Modifier les taux de marge DisplayMarkRates=Afficher les taux de marque InputPrice=Saisir un prix margin=Gestion des marges From 35ce7352e8ed9ec613ddaa8b4005ba0330c94405 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Feb 2023 08:09:57 +0000 Subject: [PATCH 02/12] Fixing style errors. --- htdocs/comm/propal/card.php | 62 ++++++++++++------------ htdocs/core/tpl/objectline_title.tpl.php | 26 +++++----- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c1912451cc8..88f3c1e44aa 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -914,37 +914,37 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines', 'none') !== '' && $usercancreate) { - // Define margin - $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); - foreach ($object->lines as &$line) { - $subprice = price2num($line->pa_ht * (1 + $margin_rate/100), 'MU'); - $prod = new Product($db); - $prod->fetch($line->fk_product); - if ($prod->price_min > $subprice) { - $price_subprice = price($subprice, 0, $outlangs, 1, -1, -1, 'auto'); - $price_price_min = price($prod->price_min, 0, $outlangs, 1, -1, -1, 'auto'); - setEventMessages($prod->ref.' - '.$prod->label.' ('.$price_subprice.' < '.$price_price_min.' '.strtolower($langs->trans("MinPrice")).')'."\n", null, 'warnings'); - } - // Manage $line->subprice and $line->multicurrency_subprice - $multicurrency_subprice = $subprice * $line->multicurrency_subprice / $line->subprice; - // Update DB - $result = $object->updateline($line->id, $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_rate, $line->localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice); - // Update $object with new margin info - $line->price = $subprice; - $line->marge_tx = $margin_rate; - $line->marque_tx = $margin_rate * $line->pa_ht / $subprice; - $line->total_ht = $line->qty * $subprice; - $line->total_tva = $line->tva_tx * $line->qty * $subprice; - $line->total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice; - // Manage $line->subprice and $line->multicurrency_subprice - $line->multicurrency_total_ht = $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - $line->multicurrency_total_tva = $line->tva_tx * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - // Used previous $line->subprice and $line->multicurrency_subprice above, now they can be set to their new values - $line->subprice = $subprice; - $line->multicurrency_subprice = $multicurrency_subprice; - } + } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines', 'none') !== '' && $usercancreate) { + // Define margin + $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); + foreach ($object->lines as &$line) { + $subprice = price2num($line->pa_ht * (1 + $margin_rate/100), 'MU'); + $prod = new Product($db); + $prod->fetch($line->fk_product); + if ($prod->price_min > $subprice) { + $price_subprice = price($subprice, 0, $outlangs, 1, -1, -1, 'auto'); + $price_price_min = price($prod->price_min, 0, $outlangs, 1, -1, -1, 'auto'); + setEventMessages($prod->ref.' - '.$prod->label.' ('.$price_subprice.' < '.$price_price_min.' '.strtolower($langs->trans("MinPrice")).')'."\n", null, 'warnings'); + } + // Manage $line->subprice and $line->multicurrency_subprice + $multicurrency_subprice = $subprice * $line->multicurrency_subprice / $line->subprice; + // Update DB + $result = $object->updateline($line->id, $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_rate, $line->localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice); + // Update $object with new margin info + $line->price = $subprice; + $line->marge_tx = $margin_rate; + $line->marque_tx = $margin_rate * $line->pa_ht / $subprice; + $line->total_ht = $line->qty * $subprice; + $line->total_tva = $line->tva_tx * $line->qty * $subprice; + $line->total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice; + // Manage $line->subprice and $line->multicurrency_subprice + $line->multicurrency_total_ht = $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_tva = $line->tva_tx * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + // Used previous $line->subprice and $line->multicurrency_subprice above, now they can be set to their new values + $line->subprice = $subprice; + $line->multicurrency_subprice = $multicurrency_subprice; + } } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 991910865e4..e2882bcd43f 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -140,19 +140,19 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { } } - if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { - print ''.$langs->trans('MarginRate'); - if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { - print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; - if (GETPOST('mode', 'aZ09') == 'marginforalllines') { - print '
'; - print ''; - print ''; - print '
'; - } - } - print ''; - } + if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { + print ''.$langs->trans('MarginRate'); + if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { + print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; + if (GETPOST('mode', 'aZ09') == 'marginforalllines') { + print '
'; + print ''; + print ''; + print '
'; + } + } + print ''; + } if (!empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) { print ''.$langs->trans('MarkRate').''; } From cd4064c0349138a86afd63f2432e3f0e8bb611c8 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Thu, 2 Feb 2023 10:07:52 +0100 Subject: [PATCH 03/12] Dolibarr was using td here but is now using th so th was substituted for td. --- htdocs/core/tpl/objectline_title.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index e2882bcd43f..e00a34551a5 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -141,7 +141,7 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { } if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { - print ''.$langs->trans('MarginRate'); + print ''.$langs->trans('MarginRate'); if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; if (GETPOST('mode', 'aZ09') == 'marginforalllines') { @@ -151,7 +151,7 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { print ''; } } - print ''; + print ''; } if (!empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) { print ''.$langs->trans('MarkRate').''; From 99e5c894843a6084489228a26e9eb94c29a0979b Mon Sep 17 00:00:00 2001 From: mgabriel Date: Thu, 2 Feb 2023 10:20:02 +0100 Subject: [PATCH 04/12] In CodingPhpTest::testPHP, found a GETPOST that uses 'none' as a parameter which is not allowe. --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 88f3c1e44aa..d3310085f1f 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -914,7 +914,7 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines', 'none') !== '' && $usercancreate) { + } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines') !== '' && $usercancreate) { // Define margin $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); foreach ($object->lines as &$line) { From b8cd507287008ac7e9bdf4bda5969dff203b1930 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Mon, 6 Feb 2023 10:06:23 +0100 Subject: [PATCH 05/12] As suggested by Dolibarr, removed PROPALE_MODIFY_MARGIN_RATES as not needed. --- htdocs/admin/propal.php | 13 ------------- htdocs/comm/propal/card.php | 2 +- htdocs/core/tpl/objectline_title.tpl.php | 4 ++-- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 289c514c703..10044e33b5b 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -615,19 +615,6 @@ print " \n"; print ""; -print ''; -print ''.$langs->trans("ModifyMarginRates").''; -print ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('PROPALE_MODIFY_MARGIN_RATES'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("PROPALE_MODIFY_MARGIN_RATES", $arrval, $conf->global->PROPALE_MODIFY_MARGIN_RATES); -} -print "\n"; -print ''; -print "\n"; - print ""; print ''; print ""; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index d3310085f1f..f1e191b323d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -914,7 +914,7 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines') !== '' && $usercancreate) { + } elseif ($action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines') !== '' && $usercancreate) { // Define margin $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); foreach ($object->lines as &$line) { diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index e00a34551a5..24231d3fe68 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -140,9 +140,9 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { } } - if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { + if (!empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { print ''.$langs->trans('MarginRate'); - if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { + if ($user->hasRight("propal", "creer")) { print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; if (GETPOST('mode', 'aZ09') == 'marginforalllines') { print '
'; From 7dad374affcd6a8b3dca595f59c57060f4b4261a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 22 Feb 2023 09:32:12 +0100 Subject: [PATCH 06/12] fix emty status select list --- htdocs/fichinter/list.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index d2b326a6ba4..f3e88404f6d 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -6,7 +6,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021-2023 Frédéric France * Copyright (C) 2022 Charlène Benke * * This program is free software; you can redistribute it and/or modify @@ -574,8 +574,12 @@ if (!empty($arrayfields['f.note_private']['checked'])) { // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { print ''; - $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short - $liststatus = $objectstatic->statuts_short; + $liststatus = [ + $object::STATUS_DRAFT => $langs->transnoentitiesnoconv('Draft'), + $object::STATUS_VALIDATED => $langs->transnoentitiesnoconv('Validated'), + $object::STATUS_BILLED => $langs->transnoentitiesnoconv('StatusInterInvoiced'), + $object::STATUS_CLOSED => $langs->transnoentitiesnoconv('Done'), + ]; if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 } From d9fda122ff0d22d7748b2409027c11f6c1242944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 22 Feb 2023 18:14:44 +0100 Subject: [PATCH 07/12] utf8_decode is deprecated --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4345c936432..61324e4ce9e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13,7 +13,7 @@ * Copyright (C) 2014 Cédric GROSS * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2019-2022 Thibault Foucart * Copyright (C) 2020 Open-Dsi * Copyright (C) 2021 Gauthier VERDOL @@ -8890,7 +8890,7 @@ function dol_osencode($str) } if ($tmp == 'iso-8859-1') { - return utf8_decode($str); + return mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1'); } return $str; } From ed046e16d2536ab77cec3dd1ac6c48834d4780a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 22 Feb 2023 18:21:00 +0100 Subject: [PATCH 08/12] Update functions2.lib.php --- htdocs/core/lib/functions2.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 6b51cf76150..188b30116d7 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -178,9 +178,9 @@ function dol_print_file($langs, $filename, $searchalt = 0) $content = file_get_contents($formfilealt); $isutf8 = utf8_check($content); if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') { - print utf8_encode($content); + print mb_convert_encoding($content, 'UTF-8', 'ISO-8859-1'); } elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') { - print utf8_decode($content); + print mb_convert_encoding($content, 'ISO-8859-1', 'UTF-8'); } else { print $content; } From ee95ac237c57142ca5a135c1efcc4caef5455c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 22 Feb 2023 18:21:58 +0100 Subject: [PATCH 09/12] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 61324e4ce9e..e6ac7f2d9f2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8890,7 +8890,7 @@ function dol_osencode($str) } if ($tmp == 'iso-8859-1') { - return mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1'); + return mb_convert_encoding($str, 'ISO-8859-1', 'UTF-8'); } return $str; } From e9e8934a84df49171764075810cef4f93b323208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 22 Feb 2023 21:35:18 +0100 Subject: [PATCH 10/12] doc --- htdocs/core/class/commonstickergenerator.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index e388159f978..3a83d015f65 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -61,6 +61,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; */ abstract class CommonStickerGenerator { + /** + * @var DoliDB Database handler. + */ + public $db; + public $code; // Code of format /** From 2ae87e95e6b78a8238c822a4d7d6fda303258150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 22 Feb 2023 21:56:09 +0100 Subject: [PATCH 11/12] doc --- htdocs/core/class/cgenericdic.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php index 250fb3ec569..60ac9f7984e 100644 --- a/htdocs/core/class/cgenericdic.class.php +++ b/htdocs/core/class/cgenericdic.class.php @@ -30,6 +30,11 @@ */ class CGenericDic { + /** + * @var DoliDB Database handler. + */ + public $db; + /** * @var string Id to identify managed objects */ From c520c3d39037480dcca80818ff7de2c1e0ab2726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 22 Feb 2023 22:17:39 +0100 Subject: [PATCH 12/12] Update translate.class.php --- htdocs/core/class/translate.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 2315428b37a..7379877753b 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -41,6 +41,9 @@ class Translate public $cache_labels = array(); // Cache for labels return by getLabelFromKey method public $cache_currencies = array(); // Cache to store currency symbols private $cache_currencies_all_loaded = false; + public $origlang; + public $error; + public $errors = array(); /** @@ -416,7 +419,7 @@ class Translate * * Value for hash are: 1:Loaded from disk, 2:Not found, 3:Loaded from cache * - * @param Database $db Database handler + * @param DoliDB $db Database handler * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK */ public function loadFromDatabase($db)