From 67e938bdfa0f42d9ac55a1adb9c2063a4b4604f9 Mon Sep 17 00:00:00 2001 From: atm-thibaultf Date: Wed, 2 Aug 2023 11:52:03 +0200 Subject: [PATCH 01/15] FIX_reload_linked_objects_on_propal_closeas --- htdocs/comm/propal/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 2454c074da2..b0ce0bea415 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -700,6 +700,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); $action = 'closeas'; } elseif (GETPOST('statut', 'int') == $object::STATUS_SIGNED || GETPOST('statut', 'int') == $object::STATUS_NOTSIGNED) { + $locationTarget = ''; // prevent browser refresh from closing proposal several times if ($object->statut == $object::STATUS_VALIDATED || ( ! empty($conf->global->PROPAL_SKIP_ACCEPT_REFUSE) && $object->statut == $object::STATUS_DRAFT)) { $db->begin(); @@ -708,10 +709,12 @@ if (empty($reshook)) { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; + } else { + // Needed if object linked modified by trigger (because linked objects can't be fetched two times : linkedObjectsFullLoaded) + $locationTarget = DOL_URL_ROOT . '/comm/propal/card.php?id=' . $object->id; } $deposit = null; - $locationTarget = ''; $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); From 8000341f84222f6c8f6443cacff554871b7f9434 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Aug 2023 15:42:14 +0200 Subject: [PATCH 02/15] Fix security --- htdocs/admin/system/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 8c50799ef64..0f9df69698e 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -597,7 +597,7 @@ print '
'; print 'WEBSITE_MAIN_SECURITY_FORCESTS = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCESTS) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCESTS).'   ('.$langs->trans("Example").": \"max-age=31536000; includeSubDomains\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCEPP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCEPP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCEPP).'   ('.$langs->trans("Example").": \"camera: 'none'; microphone: 'none';\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCEPP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCEPP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCEPP).'   ('.$langs->trans("Example").": \"camera: (); microphone: ();\")
"; print '
'; print '
'; From f191527d714f8cd12bab8087c31d5e3ac76fa774 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Aug 2023 13:08:05 +0200 Subject: [PATCH 03/15] css --- htdocs/cron/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index b8cb76bc7c1..c418f18e2fb 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -647,7 +647,7 @@ if ($num > 0) { print ''; // Duration - print ''; + print ''; if (!empty($datelastresult) && ($datelastresult >= $datelastrun)) { $nbseconds = max($datelastresult - $datelastrun, 1); print $nbseconds.' '.($nbseconds > 1 ? $langs->trans("SecondShort") : $langs->trans("SecondShort")); From a773c5db85554030bba908f8ca899be520ec90e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Aug 2023 14:09:06 +0200 Subject: [PATCH 04/15] Fix css --- htdocs/admin/modules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 3cd35480a5d..0242e021ab3 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -991,7 +991,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { } // Picto + Name of module - print ' '; + print ' '; $alttext = ''; //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version); //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin); @@ -1008,7 +1008,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { print "\n"; // Desc - print ''; + print ''; print nl2br($objMod->getDesc()); print "\n"; @@ -1019,7 +1019,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { print ''; // Version - print ''; + print ''; if ($objMod->needUpdate) { $versionTitle = $langs->trans('ModuleUpdateAvailable').' : '.$objMod->lastVersion; print ''.$versiontrans.''; @@ -1029,7 +1029,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { print "\n"; // Link enable/disable - print ''; + print ''; print $codeenabledisable; print "\n"; From 76f0a57e915e4f7de08e6db79bb9b0a302400f35 Mon Sep 17 00:00:00 2001 From: atm-sami <139965072+atm-sami@users.noreply.github.com> Date: Tue, 8 Aug 2023 20:23:53 +0200 Subject: [PATCH 05/15] FIX propal list : warning if product module is not enabled (#25583) --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 6587fc5e1a9..94a14f341ba 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1126,7 +1126,7 @@ if ($resql) { $moreforfilter .= ''; } // If the user can view products - if (isModEnabled('categorie') && $user->hasRight('categorie', 'read') && ($user->rights->produit->lire || $user->rights->service->lire)) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'read') && ($user->hasRight('product', 'read') || $user->hasRight('service', 'read'))) { $searchCategoryProductOperator = -1; include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $tmptitle = $langs->trans('IncludingProductWithTag'); From 3bc698d0caee2be5fc3fabdc24c42d5e0ceeae28 Mon Sep 17 00:00:00 2001 From: Olivier Lesueur <139786198+ol-fr@users.noreply.github.com> Date: Tue, 8 Aug 2023 21:30:27 +0200 Subject: [PATCH 06/15] FIX #25580 install/step1.php - wrong command line argument used for $main_dir (#25581) Co-authored-by: Olivier Lesueur --- htdocs/install/step1.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 7958012b0a1..75a75512554 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -84,22 +84,34 @@ if (@file_exists($forcedfile)) { // If forced install is enabled, replace the post values. These are empty because form fields are disabled. if ($force_install_noedit) { $main_dir = detect_dolibarr_main_document_root(); - if (!empty($argv[1])) { - $main_dir = $argv[1]; // override when executing the script in command line + if (!empty($argv[3])) { + $main_dir = $argv[3]; // override when executing the script in command line } if (!empty($force_install_main_data_root)) { $main_data_dir = $force_install_main_data_root; } else { $main_data_dir = detect_dolibarr_main_data_root($main_dir); } + if (!empty($argv[4])) { + $main_data_dir = $argv[4]; // override when executing the script in command line + } $main_url = detect_dolibarr_main_url_root(); + if (!empty($argv[5])) { + $main_url = $argv[5]; // override when executing the script in command line + } if (!empty($force_install_databaserootlogin)) { $userroot = parse_database_login($force_install_databaserootlogin); } + if (!empty($argv[6])) { + $userroot = $argv[6]; // override when executing the script in command line + } if (!empty($force_install_databaserootpass)) { $passroot = parse_database_pass($force_install_databaserootpass); } + if (!empty($argv[7])) { + $passroot = $argv[7]; // override when executing the script in command line + } } if ($force_install_noedit == 2) { if (!empty($force_install_type)) { From 48ede1ffbd80dbf5473acd485bf1b9d1cb4a2e18 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Tue, 8 Aug 2023 21:31:57 +0200 Subject: [PATCH 07/15] fix: wrong perms label in French for BOM (#25576) --- htdocs/langs/fr_FR/admin.lang | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 87bda927e14..82b4cedf333 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -900,9 +900,9 @@ Permission609=Supprimer les étiquettes Permission611=Lire les attributs des variantes produits Permission612=Créer/mettre à jour les attributs des variantes produits Permission613=Supprimer les attributs des variantes produits -Permission650=Lire les Nomenclatures (BOM) -Permission651=Créer/modifier les Nomenclatures (BOM) -Permission652=Supprimer les Nomenclatures (BOM) +Permission651=Lire les Nomenclatures (BOM) +Permission652=Créer/modifier les Nomenclatures (BOM) +Permission653=Supprimer les Nomenclatures (BOM) Permission660=Lire les ordres de fabrication (OF) Permission661=Créer/mettre à jour les ordres de fabrication (OF) Permission662=Supprimer les ordres de fabrication (OF) From b0e4558e3fa744f28c4a1043fc3598501a2002d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Aug 2023 21:53:52 +0200 Subject: [PATCH 08/15] Fix #25586 --- htdocs/commande/card.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6a599354e48..0a458b7b103 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -688,21 +688,6 @@ if (empty($reshook)) { $tva_tx = ''; } - - // Prepare a price equivalent for minimum price check - $pu_equivalent = $pu_ht; - $pu_equivalent_ttc = $pu_ttc; - $currency_tx = $object->multicurrency_tx; - - // Check if we have a foreing currency - // If so, we update the pu_equiv as the equivalent price in base currency - if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; - } - if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; - } - $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); @@ -995,6 +980,20 @@ if (empty($reshook)) { $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we muste keep this value + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); From 4a22bef13d0087957988bdf181a86a8c60ec74bd Mon Sep 17 00:00:00 2001 From: atm-lucas <121817516+atm-lucasmantegari@users.noreply.github.com> Date: Tue, 8 Aug 2023 22:02:45 +0200 Subject: [PATCH 09/15] fix entitylang test (#25569) --- htdocs/imports/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 3ddcb2ecb7a..8c540b98595 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1145,7 +1145,7 @@ if ($step == 4 && $datatoimport) { $entity = (!empty($objimport->array_import_entities[0][$code]) ? $objimport->array_import_entities[0][$code] : $objimport->array_import_icon[0]); $entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... - $entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ... + $entitylang = !empty($entitytolang[$entity]) ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ... print '=> '; print ''; From 50801997522ec2b26fec0124960e73fbe6b8a807 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Aug 2023 01:00:15 +0200 Subject: [PATCH 10/15] FIX The plus button of combo list disappear on create if creation fails --- htdocs/core/class/commonobject.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7a29daf0c37..1352be4b86c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6976,7 +6976,7 @@ abstract class CommonObject $value = price($value); } $out = ' '; - } elseif ($type == 'select') { + } elseif ($type == 'select') { // combo list $out = ''; if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; @@ -7350,8 +7350,9 @@ abstract class CommonObject $out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, $moreparam, 0, empty($val['disabled']) ? 0 : 1); - if (!empty($param_list_array[2])) { // If the entry into $fields is set to add a create button - if (!GETPOSTISSET('backtopage') && empty($val['disabled']) && empty($nonewbutton)) { // To avoid to open several times the 'Create Object' button and to avoid to have button if field is protected by a "disabled". + if (!empty($param_list_array[2])) { // If the entry into $fields is set, we must add a create button + if ((!GETPOSTISSET('backtopage') || strpos(GETPOST('backtopage'), $_SERVER['PHP_SELF']) === 0) // // To avoid to open several times the 'Plus' button (we accept only one level) + && empty($val['disabled']) && empty($nonewbutton)) { // and to avoid to show the button if the field is protected by a "disabled". list($class, $classfile) = explode(':', $param_list[0]); if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) { $url_path = dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); From 20b3f9e2d0b063457977336142db08c020b85f6f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Aug 2023 01:08:34 +0200 Subject: [PATCH 11/15] Fix go back to page --- htdocs/product/card.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 86497cf38e3..146d979441d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -690,10 +690,12 @@ if (empty($reshook)) { $object->setCategories($categories); if (!empty($backtopage)) { - $backtopage = preg_replace('/__ID__/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation - if (preg_match('/\?/', $backtopage)) { - $backtopage .= '&socid='.$object->id; // Old method + $backtopage = preg_replace('/__ID__/', $object->id, $backtopage); // New method to autoselect parent roject after a New on another form object creation + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect parent after a New on another form object creation + if (preg_match('/\?/', $backtopage)) { // Old method + $backtopage .= '&socid='.$object->id; } + header("Location: ".$backtopage); exit; } else { From c3df2d15deb7bfa868492d329b906b738bb46be7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Aug 2023 12:26:32 +0200 Subject: [PATCH 12/15] Fix status --- htdocs/comm/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 030e2d33eaf..f5b21ee2501 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1458,6 +1458,8 @@ if ($object->id > 0) { $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->status; + $facturestatic->status = $objp->status; + $facturestatic->paye = $objp->paye; $facturestatic->alreadypaid = $objp->am; $facturestatic->date = $db->jdate($objp->df); $facturestatic->date_lim_reglement = $db->jdate($objp->dl); From 38ddc9cea1fbbb84e9dedb4b9c6233958f0f81ad Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 9 Aug 2023 12:36:26 +0200 Subject: [PATCH 13/15] FIX avoid php8 warnings (#25596) --- htdocs/core/class/extrafields.class.php | 11 ++++++----- htdocs/product/class/product.class.php | 18 +++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 8817324461c..30e6ec0dea6 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1722,11 +1722,12 @@ class ExtraFields $translabel = ''; if (!empty($obj->$field_toshow)) { $translabel = $langs->trans($obj->$field_toshow); - } - if ($translabel != $obj->$field_toshow) { - $value .= dol_trunc($translabel, 24).' '; - } else { - $value .= $obj->$field_toshow.' '; + + if ($translabel != $obj->$field_toshow) { + $value .= dol_trunc($translabel, 24).' '; + } else { + $value .= $obj->$field_toshow.' '; + } } } } else { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9c1f14e96b4..ce0d05fd048 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2677,18 +2677,18 @@ class Product extends CommonObject if ($resql) { $result = $this->db->fetch_array($resql); - $this->multiprices[$i] = $result["price"]; - $this->multiprices_ttc[$i] = $result["price_ttc"]; - $this->multiprices_min[$i] = $result["price_min"]; - $this->multiprices_min_ttc[$i] = $result["price_min_ttc"]; - $this->multiprices_base_type[$i] = $result["price_base_type"]; + $this->multiprices[$i] = (!empty($result["price"]) ? $result["price"] : 0); + $this->multiprices_ttc[$i] = (!empty($result["price_ttc"]) ? $result["price_ttc"] : 0); + $this->multiprices_min[$i] = (!empty($result["price_min"]) ? $result["price_min"] : 0); + $this->multiprices_min_ttc[$i] = (!empty($result["price_min_ttc"]) ? $result["price_min_ttc"] : 0); + $this->multiprices_base_type[$i] = (!empty($result["price_base_type"]) ? $result["price_base_type"] : ''); // Next two fields are used only if PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on - $this->multiprices_tva_tx[$i] = $result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')' - $this->multiprices_recuperableonly[$i] = $result["recuperableonly"]; + $this->multiprices_tva_tx[$i] = (!empty($result["tva_tx"]) ? $result["tva_tx"] : 0); // TODO Add ' ('.$result['default_vat_code'].')' + $this->multiprices_recuperableonly[$i] = (!empty($result["recuperableonly"]) ? $result["recuperableonly"] : 0); // Price by quantity - $this->prices_by_qty[$i] = $result["price_by_qty"]; - $this->prices_by_qty_id[$i] = $result["rowid"]; + $this->prices_by_qty[$i] = (!empty($result["price_by_qty"]) ? $result["price_by_qty"] : 0); + $this->prices_by_qty_id[$i] = (!empty($result["rowid"]) ? $result["rowid"] : 0); // Récuperation de la liste des prix selon qty si flag positionné if ($this->prices_by_qty[$i] == 1) { $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; From 954c54ad3faa6a0ede8351377b81869226d1d647 Mon Sep 17 00:00:00 2001 From: am97 Date: Wed, 9 Aug 2023 12:50:14 +0200 Subject: [PATCH 14/15] Fix SQL syntax error (#25562) Single quotes are needed to indicate that 'project' and 'external' are strings, otherwise the requests fail --- htdocs/core/lib/contact.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index b63e7b025c7..7225cde0c89 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -71,7 +71,7 @@ function contact_prepare_head(Contact $object) $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as n'; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (n.rowid = cc.element_id)'; $sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id); - $sql .= ' AND cc.fk_c_type_contact IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE element="project" AND source="external")'; + $sql .= ' AND cc.fk_c_type_contact IN (SELECT rowid FROM '.MAIN_DB_PREFIX."c_type_contact WHERE element='project' AND source='external')"; $sql .= ' AND n.entity IN ('.getEntity('project').')'; $resql = $db->query($sql); if ($resql) { @@ -190,7 +190,7 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $ $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (p.rowid = cc.element_id)'; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_contact as ctc ON (ctc.rowid = cc.fk_c_type_contact)'; $sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id); - $sql .= ' AND ctc.element="project" AND ctc.source="external"'; + $sql .= " AND ctc.element='project' AND ctc.source='external'"; $sql .= ' AND p.entity IN ('.getEntity('project').')'; $sql .= ' ORDER BY p.dateo DESC'; From bf51e493dd1c27bdc4c42bf512a25e385ed2146c Mon Sep 17 00:00:00 2001 From: atm-greg <30891670+atm-greg@users.noreply.github.com> Date: Wed, 9 Aug 2023 13:16:58 +0200 Subject: [PATCH 15/15] fix error seteventmessage on white screen (#25523) * fix error seteventmessage on white screen * Update card.php --------- Co-authored-by: Laurent Destailleur --- htdocs/holiday/card.php | 342 ++++++++++++++++++++-------------------- 1 file changed, 173 insertions(+), 169 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 3e800760606..1812509352f 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -284,7 +284,6 @@ if (empty($reshook)) { $error++; } } - // If no SQL error we redirect to the request card if (!$error) { $db->commit(); @@ -924,14 +923,16 @@ $help_url = 'EN:Module_Holiday'; llxHeader('', $title, $help_url); $edit = false; +$errors = []; if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { - // If user has no permission to create a leave - if ((in_array($fuserid, $childids) && empty($user->rights->holiday->write)) || (!in_array($fuserid, $childids) && ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->holiday->writeall_advance) || empty($user->rights->holiday->writeall))))) { + // Form to add a leave request + print load_fiche_titre($langs->trans('MenuAddCP'), '', 'title_hrm.png'); + + // If user has no permission to create a leave + if ((in_array($fuserid, $childids) && empty($user->rights->holiday->write)) || (!in_array($fuserid, $childids) && ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->holiday->writeall_advance) || empty($user->rights->holiday->writeall))))) { $errors[] = $langs->trans('CantCreateCP'); } else { - // Form to add a leave request - print load_fiche_titre($langs->trans('MenuAddCP'), '', 'title_hrm.png'); // Error management if (GETPOST('error')) { @@ -962,188 +963,191 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { break; } - setEventMessages($errors, null, 'errors'); - } - - - print ''."\n"; - - - // Formulaire de demande - print '
'."\n"; - print ''."\n"; - print ''."\n"; - - if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { - print dol_get_fiche_head('', '', '', -1); - - $out = ''; - $nb_holiday = 0; - $typeleaves = $object->getTypes(1, 1); - foreach ($typeleaves as $key => $val) { - $nb_type = $object->getCPforUser($user->id, $val['rowid']); - $nb_holiday += $nb_type; - - $out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': '.($nb_type ? price2num($nb_type) : 0).'
'; - //$out .= ' - '.$val['label'].': '.($nb_type ?price2num($nb_type) : 0).'
'; + if (count($errors)) { + setEventMessages('', $errors, 'errors'); } - print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'
'; - print $out; - - print dol_get_fiche_end(); - } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) { - print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'
'; } + } - print dol_get_fiche_head(); - //print ''.$langs->trans('DelayToRequestCP',$object->getConfCP('delayForRequest')).'

'; + print ''."\n"; - print ''; - print ''; - // User for leave request - print ''; - print ''; - print ''; - print ''; + // Formulaire de demande + print ''."\n"; + print ''."\n"; + print ''."\n"; - // Type - print ''; - print ''; - print ''; - print ''; + if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { + print dol_get_fiche_head('', '', '', -1); - // Date start - print ''; - print ''; - print ''; - print ''; + $out = ''; + $nb_holiday = 0; + $typeleaves = $object->getTypes(1, 1); + foreach ($typeleaves as $key => $val) { + $nb_type = $object->getCPforUser($user->id, $val['rowid']); + $nb_holiday += $nb_type; - // Date end - print ''; - print ''; - print ''; - print ''; + $out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': '.($nb_type ? price2num($nb_type) : 0).'
'; + //$out .= ' - '.$val['label'].': '.($nb_type ?price2num($nb_type) : 0).'
'; + } + print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'
'; + print $out; - // Approver - print ''; - print ''; - print ''; - print ''; + //print ''.$langs->trans('DelayToRequestCP',$object->getConfCP('delayForRequest')).'

'; - // Description - print ''; - print ''; - print ''; + print '
'.$langs->trans("User").''; - if ($cancreate && !$cancreateall) { - print img_picto('', 'user').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500'); - //print ''; - } else { - print img_picto('', 'user').$form->select_dolusers($fuserid ? $fuserid : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500'); - } - print '
'.$langs->trans("Type").''; - $typeleaves = $object->getTypes(1, -1); - $arraytypeleaves = array(); - foreach ($typeleaves as $key => $val) { - $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); - $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')' : ''); - $arraytypeleaves[$val['rowid']] = $labeltoshow; - } - print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ?GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', true); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print '
'; - print $form->textwithpicto($langs->trans("DateDebCP"), $langs->trans("FirstDayOfHoliday")); - print ''; - // Si la demande ne vient pas de l'agenda - if (!GETPOST('date_debut_')) { - print $form->selectDate(-1, 'date_debut_', 0, 0, 0, '', 1, 1); - } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month', 'int'), GETPOST('date_debut_day', 'int'), GETPOST('date_debut_year', 'int')); - print $form->selectDate($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1); - } - print '     '; - print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday', 'alpha') ?GETPOST('starthalfday', 'alpha') : 'morning')); - print '
'; - print $form->textwithpicto($langs->trans("DateFinCP"), $langs->trans("LastDayOfHoliday")); - print ''; - if (!GETPOST('date_fin_')) { - print $form->selectDate(-1, 'date_fin_', 0, 0, 0, '', 1, 1); - } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month', 'int'), GETPOST('date_fin_day', 'int'), GETPOST('date_fin_year', 'int')); - print $form->selectDate($tmpdate, 'date_fin_', 0, 0, 0, '', 1, 1); - } - print '     '; - print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday', 'alpha') ?GETPOST('endhalfday', 'alpha') : 'afternoon')); - print '
'.$langs->trans("ReviewedByCP").''; + print dol_get_fiche_end(); + } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) { + print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'
'; + } - $object = new Holiday($db); - $include_users = $object->fetch_users_approver_holiday(); - if (empty($include_users)) { - print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); - } else { - // Defined default approver (the forced approved of user or the supervisor if no forced value defined) - // Note: This use will be set only if the deinfed approvr has permission to approve so is inside include_users - $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator); - if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) { - $defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver - } - if (GETPOST('valideur', 'int') > 0) { - $defaultselectuser = GETPOST('valideur', 'int'); - } - $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500'); - print img_picto('', 'user').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); - } + print dol_get_fiche_head(); - //print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent - print '
'.$langs->trans("DescCP").''; - $doleditor = new DolEditor('description', GETPOST('description', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, ROWS_3, '90%'); - print $doleditor->Create(1); - print '
'; + print ''; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // User for leave request + print ''; + print ''; + print ''; + print ''; - print ''; - print '
'.$langs->trans("User").''; + if ($cancreate && !$cancreateall) { + print img_picto('', 'user').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500'); + //print ''; + } else { + print img_picto('', 'user').$form->select_dolusers($fuserid ? $fuserid : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500'); + } + print '
'; + // Type + print ''; + print ''.$langs->trans("Type").''; + print ''; + $typeleaves = $object->getTypes(1, -1); + $arraytypeleaves = array(); + foreach ($typeleaves as $key => $val) { + $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); + $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')' : ''); + $arraytypeleaves[$val['rowid']] = $labeltoshow; + } + print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ?GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', true); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + print ''; + print ''; - print dol_get_fiche_end(); + // Date start + print ''; + print ''; + print $form->textwithpicto($langs->trans("DateDebCP"), $langs->trans("FirstDayOfHoliday")); + print ''; + print ''; + // Si la demande ne vient pas de l'agenda + if (!GETPOST('date_debut_')) { + print $form->selectDate(-1, 'date_debut_', 0, 0, 0, '', 1, 1); + } else { + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month', 'int'), GETPOST('date_debut_day', 'int'), GETPOST('date_debut_year', 'int')); + print $form->selectDate($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1); + } + print '     '; + print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday', 'alpha') ?GETPOST('starthalfday', 'alpha') : 'morning')); + print ''; + print ''; - print $form->buttonsSaveCancel("SendRequestCP"); + // Date end + print ''; + print ''; + print $form->textwithpicto($langs->trans("DateFinCP"), $langs->trans("LastDayOfHoliday")); + print ''; + print ''; + if (!GETPOST('date_fin_')) { + print $form->selectDate(-1, 'date_fin_', 0, 0, 0, '', 1, 1); + } else { + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month', 'int'), GETPOST('date_fin_day', 'int'), GETPOST('date_fin_year', 'int')); + print $form->selectDate($tmpdate, 'date_fin_', 0, 0, 0, '', 1, 1); + } + print '     '; + print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday', 'alpha') ?GETPOST('endhalfday', 'alpha') : 'afternoon')); + print ''; + print ''; + + // Approver + print ''; + print ''.$langs->trans("ReviewedByCP").''; + print ''; + + $object = new Holiday($db); + $include_users = $object->fetch_users_approver_holiday(); + if (empty($include_users)) { + print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); + } else { + // Defined default approver (the forced approved of user or the supervisor if no forced value defined) + // Note: This use will be set only if the deinfed approvr has permission to approve so is inside include_users + $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator); + if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) { + $defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver + } + if (GETPOST('valideur', 'int') > 0) { + $defaultselectuser = GETPOST('valideur', 'int'); + } + $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500'); + print img_picto('', 'user').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + } + + //print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent + print ''; + print ''; + + // Description + print ''; + print ''.$langs->trans("DescCP").''; + print ''; + $doleditor = new DolEditor('description', GETPOST('description', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, ROWS_3, '90%'); + print $doleditor->Create(1); + print ''; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print ''; + print ''; + + print dol_get_fiche_end(); + + print $form->buttonsSaveCancel("SendRequestCP"); + + print ''."\n"; - print ''."\n"; - } } else { if ($error) { print '
';