From a7b593026b134ed0706541b9bd553d4636add04e Mon Sep 17 00:00:00 2001 From: marc Date: Fri, 22 Jul 2022 00:55:14 +0200 Subject: [PATCH 01/10] Fix #21449 --- htdocs/supplier_proposal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index ad35c8f9914..595be78d4df 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -302,7 +302,7 @@ $sql .= " p.rowid as project_id, p.ref as project_ref,"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " sc.fk_soc, sc.fk_user,"; } -$sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as status, u.admin, u.employee, u.email as uemail"; +$sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as statut, u.admin, u.employee, u.email as uemail"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { From 5d75ea015b0d69c59899032aaccc3aa9dbce7a1b Mon Sep 17 00:00:00 2001 From: spooky360 Date: Fri, 22 Jul 2022 09:51:57 +0200 Subject: [PATCH 02/10] Added "$object" parameter to $formfile->showdocuments call Added "$object" parameter to $formfile->showdocuments call in order to use the $object reference on the showDocuments hook called inside showdocuments function. Otherwise, the hook is called with a null reference. --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 35e5257fce0..d1e1dc85c9a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2665,7 +2665,7 @@ if ($action == 'create') { $delallowed = $usercancreate; $modelpdf = (!empty($object->model_pdf) ? $object->model_pdf : (empty($conf->global->COMMANDE_SUPPLIER_ADDON_PDF) ? '' : $conf->global->COMMANDE_SUPPLIER_ADDON_PDF)); - print $formfile->showdocuments('commande_fournisseur', $objref, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 0, 0, '', '', '', $object->thirdparty->default_lang); + print $formfile->showdocuments('commande_fournisseur', $objref, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 0, 0, '', '', '', $object->thirdparty->default_lang, '', $object); $somethingshown = $formfile->numoffiles; // Show links to link elements From 9463f24a73dd9af2808eb80daace75c97f48bfea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jul 2022 11:35:56 +0200 Subject: [PATCH 03/10] Better fix --- htdocs/supplier_proposal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 595be78d4df..8f7094ee486 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -302,7 +302,7 @@ $sql .= " p.rowid as project_id, p.ref as project_ref,"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " sc.fk_soc, sc.fk_user,"; } -$sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as statut, u.admin, u.employee, u.email as uemail"; +$sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as ustatus, u.admin, u.employee, u.email as uemail"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { From c342d0cde93f33f0e4b70c5df5228b407e10ff58 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 22 Jul 2022 10:51:28 +0200 Subject: [PATCH 04/10] fix: display message only if change --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 222bc55e7b8..73a9eb13fbe 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1880,9 +1880,9 @@ class CommandeFournisseur extends CommonOrder if (!empty($prod->packaging) && ($qty % $prod->packaging) > 0) { $coeff = intval($qty / $prod->packaging) + 1; $qty = $prod->packaging * $coeff; + setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); } } - setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); } } From c3016c6175cdc7cf8d0535cf89ec22623e76511b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jul 2022 13:44:47 +0200 Subject: [PATCH 05/10] Fix php8 --- htdocs/core/class/commondocgenerator.class.php | 13 +++++++++++-- htdocs/core/class/translate.class.php | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index bee63613bca..d0b64fdca77 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -895,7 +895,12 @@ abstract class CommonDocGenerator //Add value to store price with currency $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { - $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; + $valueofselectkey = $object->array_options['options_'.$key]; + if (array_key_exists($valueofselectkey, $extrafields->attributes[$object->table_element]['param'][$key]['options'])) { + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$valueofselectkey]; + } else { + $object->array_options['options_'.$key] = ''; + } } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $valArray = explode(',', $object->array_options['options_'.$key]); $output = array(); @@ -945,7 +950,11 @@ abstract class CommonDocGenerator } } - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + if (array_key_exists('option_'.$key, $object->array_options)) { + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + } else { + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => '')); + } } } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 94bd36799fc..c11f94fa047 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -904,11 +904,11 @@ class Translate * This function need module "numberwords" to be installed. If not it will return * same number (this module is not provided by default as it use non GPL source code). * - * @param int $number Number to encode in full text - * @param string $isamount ''=it's just a number, '1'=It's an amount (default currency), 'currencycode'=It's an amount (foreign currency) - * @return string Label translated in UTF8 (but without entities) - * 10 if setDefaultLang was en_US => ten - * 123 if setDefaultLang was fr_FR => cent vingt trois + * @param int|string $number Number to encode in full text + * @param string $isamount ''=it's just a number, '1'=It's an amount (default currency), 'currencycode'=It's an amount (foreign currency) + * @return string Label translated in UTF8 (but without entities) + * 10 if setDefaultLang was en_US => ten + * 123 if setDefaultLang was fr_FR => cent vingt trois */ public function getLabelFromNumber($number, $isamount = '') { From 0bcc03cd5d9eba7bf6238f06f79abcc40b26bf66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jul 2022 14:32:13 +0200 Subject: [PATCH 06/10] css --- htdocs/admin/const.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 1426c323c01..a5a68a0bb49 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -220,7 +220,7 @@ if (!empty($conf->multicompany->enabled) && !$user->entity) { print ''; print ''; } -print ''; +print ''; print "\n"; print ''; @@ -273,7 +273,7 @@ if ($result) { print ''; // Date last change - print ''; + print ''; print dol_print_date($db->jdate($obj->tms), 'dayhour'); print ''; From af73f2b6830599cd2ad81beb710f49931fb166c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jul 2022 13:44:47 +0200 Subject: [PATCH 07/10] Fix php8 --- htdocs/core/class/commondocgenerator.class.php | 13 +++++++++++-- htdocs/core/class/translate.class.php | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index bee63613bca..d0b64fdca77 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -895,7 +895,12 @@ abstract class CommonDocGenerator //Add value to store price with currency $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { - $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; + $valueofselectkey = $object->array_options['options_'.$key]; + if (array_key_exists($valueofselectkey, $extrafields->attributes[$object->table_element]['param'][$key]['options'])) { + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$valueofselectkey]; + } else { + $object->array_options['options_'.$key] = ''; + } } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $valArray = explode(',', $object->array_options['options_'.$key]); $output = array(); @@ -945,7 +950,11 @@ abstract class CommonDocGenerator } } - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + if (array_key_exists('option_'.$key, $object->array_options)) { + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + } else { + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => '')); + } } } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 94bd36799fc..c11f94fa047 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -904,11 +904,11 @@ class Translate * This function need module "numberwords" to be installed. If not it will return * same number (this module is not provided by default as it use non GPL source code). * - * @param int $number Number to encode in full text - * @param string $isamount ''=it's just a number, '1'=It's an amount (default currency), 'currencycode'=It's an amount (foreign currency) - * @return string Label translated in UTF8 (but without entities) - * 10 if setDefaultLang was en_US => ten - * 123 if setDefaultLang was fr_FR => cent vingt trois + * @param int|string $number Number to encode in full text + * @param string $isamount ''=it's just a number, '1'=It's an amount (default currency), 'currencycode'=It's an amount (foreign currency) + * @return string Label translated in UTF8 (but without entities) + * 10 if setDefaultLang was en_US => ten + * 123 if setDefaultLang was fr_FR => cent vingt trois */ public function getLabelFromNumber($number, $isamount = '') { From e7161edffe95e55744012c2620464b7690266121 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jul 2022 15:11:00 +0200 Subject: [PATCH 08/10] Fix missing @ in dolEval --- 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 bfb1e170078..dee765d174a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8611,7 +8611,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1' } } elseif ($onlysimplestring == '2') { // We must accept: (($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found" - if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/;[]', '/').']/i', $s)) { + if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/@;[]', '/').']/i', $s)) { if ($returnvalue) { return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s; } else { @@ -9020,7 +9020,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, if ($values[0] != $type) { continue; } - //var_dump(verifCond($values[4])); + var_dump($value.' '.verifCond($values[4])); if (verifCond($values[4])) { if ($values[3]) { From 481bd93ab821ba9fba9558242e4b6bde95c1677e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jul 2022 15:12:08 +0200 Subject: [PATCH 09/10] Fix var_dump --- htdocs/core/lib/functions.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dee765d174a..38b60b9f17b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9020,7 +9020,6 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, if ($values[0] != $type) { continue; } - var_dump($value.' '.verifCond($values[4])); if (verifCond($values[4])) { if ($values[3]) { From 99f632b3fff0004c77e06813ef18775467f39012 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jul 2022 15:40:55 +0200 Subject: [PATCH 10/10] Add transaction db missing --- htdocs/core/actions_addupdatedelete.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 506a1465fdc..4452c9a7eb8 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -134,6 +134,8 @@ if ($action == 'add' && !empty($permissiontoadd)) { } if (!$error) { + $db->begin(); + $result = $object->create($user); if ($result > 0) { // Creation OK @@ -141,14 +143,19 @@ if ($action == 'add' && !empty($permissiontoadd)) { $categories = GETPOST('categories', 'array:int'); $object->setCategories($categories); } + $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation + $db->commit(); + if (empty($noback)) { header("Location: " . $urltogo); exit; } } else { + $db->rollback(); + $error++; // Creation KO if (!empty($object->errors)) {