From 9051e411d074a300686868724831f150e099c2c1 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 12:00:41 +0100 Subject: [PATCH 001/243] FIX Multilangs : PDF lines description --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/core/lib/pdf.lib.php | 26 ++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2dbaeaf056e..536e7fb59e0 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1680,7 +1680,7 @@ class Propal extends CommonObject $this->lines = array(); // Lines - $result = $this->fetch_lines(); + $result = $this->fetch_lines(0, (!empty(getDolGlobalInt('MAIN_MULTILANGS')) ? 1 : 0)); if ($result < 0) { return -3; } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d6a22f64de5..d5da41777ab 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1410,12 +1410,28 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { global $db, $conf, $langs; + $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); + + //id $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); - $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); - $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + //label + if(!empty($object->lines[$i]->label)){ + $label = $object->lines[$i]->label; + } else { + $label = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['label'] : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); + } + //description + if(!empty($object->lines[$i]->desc)){ + $desc = $object->lines[$i]->desc; + } else { + $desc = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['description'] : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + } + //ref supplier $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders - $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); - $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); + //note + $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); + //dbatch + $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); if ($issupplierline) { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; @@ -1432,7 +1448,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if ($idprod) { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated - if (getDolGlobalInt('MAIN_MULTILANGS') && ($outputlangs->defaultlang != $langs->defaultlang)) { + if ($multilangsactive && ($outputlangs->defaultlang != $langs->defaultlang)) { $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation From ec19dcc8f85afab59a816a4bdba6103fa875e810 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 13:34:50 +0100 Subject: [PATCH 002/243] Invoice --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7232137ae1c..faa54322c49 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2076,7 +2076,7 @@ class Facture extends CommonInvoice // Lines $this->lines = array(); - $result = $this->fetch_lines(); + $result = $this->fetch_lines(0, (!empty(getDolGlobalInt('MAIN_MULTILANGS')) ? 1 : 0)); if ($result < 0) { $this->error = $this->db->error(); return -3; From abc9eb7bdc21dff0608c12bd6ee0ec075c4d7251 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 13:44:19 +0100 Subject: [PATCH 003/243] Clean Code --- htdocs/core/lib/pdf.lib.php | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d5da41777ab..cb242fdf1f4 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1410,28 +1410,27 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { global $db, $conf, $langs; - $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); - - //id + $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); + //id $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); - //label - if(!empty($object->lines[$i]->label)){ - $label = $object->lines[$i]->label; - } else { - $label = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['label'] : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); - } - //description - if(!empty($object->lines[$i]->desc)){ - $desc = $object->lines[$i]->desc; - } else { - $desc = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['description'] : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); - } - //ref supplier + //label + if (!empty($object->lines[$i]->label)) { + $label = $object->lines[$i]->label; + } else { + $label = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['label'] : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); + } + //description + if (!empty($object->lines[$i]->desc)) { + $desc = $object->lines[$i]->desc; + } else { + $desc = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['description'] : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + } + //ref supplier $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders //note - $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); + $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); //dbatch - $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); + $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); if ($issupplierline) { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; From 4d32d93ee2c065e5db590bb64796939e8074d8d9 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 17:28:41 +0100 Subject: [PATCH 004/243] Clean Travis --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 536e7fb59e0..bdc3ee4d7f1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1680,7 +1680,7 @@ class Propal extends CommonObject $this->lines = array(); // Lines - $result = $this->fetch_lines(0, (!empty(getDolGlobalInt('MAIN_MULTILANGS')) ? 1 : 0)); + $result = $this->fetch_lines(0, (getDolGlobalInt('MAIN_MULTILANGS') ? 1 : 0)); if ($result < 0) { return -3; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index faa54322c49..f3466a73eba 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2076,7 +2076,7 @@ class Facture extends CommonInvoice // Lines $this->lines = array(); - $result = $this->fetch_lines(0, (!empty(getDolGlobalInt('MAIN_MULTILANGS')) ? 1 : 0)); + $result = $this->fetch_lines(0, (getDolGlobalInt('MAIN_MULTILANGS') ? 1 : 0)); if ($result < 0) { $this->error = $this->db->error(); return -3; From 86971c7b863c1b891c30f901b5ed3751eeaa720d Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 22 Dec 2023 09:30:35 +0100 Subject: [PATCH 005/243] Clean Conditions --- htdocs/core/lib/pdf.lib.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cb242fdf1f4..4b9fdb6e7c3 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1417,13 +1417,29 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($object->lines[$i]->label)) { $label = $object->lines[$i]->label; } else { - $label = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['label'] : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); + if (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label']) && $multilangsactive) { + $label = $object->lines[$i]->multilangs[$langs->defaultlang]['label']; + } else { + if (!empty($object->lines[$i]->product_label)) { + $label = $object->lines[$i]->product_label; + } else { + $label = ''; + } + } } //description if (!empty($object->lines[$i]->desc)) { $desc = $object->lines[$i]->desc; } else { - $desc = (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description'] && $multilangsactive) ? $object->lines[$i]->multilangs[$langs->defaultlang]['description'] : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + if (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description']) && $multilangsactive) { + $desc = $object->lines[$i]->multilangs[$langs->defaultlang]['description']; + } else { + if (!empty($object->lines[$i]->description)) { + $desc = $object->lines[$i]->description; + } else { + $desc = ''; + } + } } //ref supplier $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders From e24da3242440e88a840accf45bd6c805a47001e7 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 16 Jan 2024 14:13:28 +0100 Subject: [PATCH 006/243] Load multilangs in function pdf_getlinedesc() --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/core/lib/pdf.lib.php | 34 ++++++++++++------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index bdc3ee4d7f1..2dbaeaf056e 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1680,7 +1680,7 @@ class Propal extends CommonObject $this->lines = array(); // Lines - $result = $this->fetch_lines(0, (getDolGlobalInt('MAIN_MULTILANGS') ? 1 : 0)); + $result = $this->fetch_lines(); if ($result < 0) { return -3; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a4ba1d4896f..9d96dce5088 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2076,7 +2076,7 @@ class Facture extends CommonInvoice // Lines $this->lines = array(); - $result = $this->fetch_lines(0, (getDolGlobalInt('MAIN_MULTILANGS') ? 1 : 0)); + $result = $this->fetch_lines(); if ($result < 0) { $this->error = $this->db->error(); return -3; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 4b9fdb6e7c3..3cd9a055bac 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1411,8 +1411,29 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, global $db, $conf, $langs; $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); + + if ($issupplierline) { + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $prodser = new ProductFournisseur($db); + } else { + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $prodser = new Product($db); + + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + } + } + //id $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); + if($idprod) { + $prodser->fetch($idprod); + //load multilangs + if($multilangsactive){ + $prodser->getMultiLangs(); + $object->lines[$i]->multilangs = $prodser->multilangs; + } + } //label if (!empty($object->lines[$i]->label)) { $label = $object->lines[$i]->label; @@ -1448,20 +1469,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, //dbatch $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); - if ($issupplierline) { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $prodser = new ProductFournisseur($db); - } else { - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $prodser = new Product($db); - - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - } - } - if ($idprod) { - $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated if ($multilangsactive && ($outputlangs->defaultlang != $langs->defaultlang)) { $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) From 66a175e48d975e9239cf4874d9864fae6aee80b8 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 22 Jan 2024 14:52:51 +0100 Subject: [PATCH 007/243] langs of recipient --- htdocs/core/lib/pdf.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 3cd9a055bac..6dd5345be66 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1438,8 +1438,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($object->lines[$i]->label)) { $label = $object->lines[$i]->label; } else { - if (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['label']) && $multilangsactive) { - $label = $object->lines[$i]->multilangs[$langs->defaultlang]['label']; + if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['label']) && $multilangsactive) { + $label = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['label']; } else { if (!empty($object->lines[$i]->product_label)) { $label = $object->lines[$i]->product_label; @@ -1452,8 +1452,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($object->lines[$i]->desc)) { $desc = $object->lines[$i]->desc; } else { - if (!empty($object->lines[$i]->multilangs[$langs->defaultlang]['description']) && $multilangsactive) { - $desc = $object->lines[$i]->multilangs[$langs->defaultlang]['description']; + if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['description']) && $multilangsactive) { + $desc = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['description']; } else { if (!empty($object->lines[$i]->description)) { $desc = $object->lines[$i]->description; From 87c16498ca4d93db7ed69f9738182f7b88c33070 Mon Sep 17 00:00:00 2001 From: Kamel Khelifa Date: Fri, 18 Oct 2024 14:26:04 +0200 Subject: [PATCH 008/243] FIX: Fix return value of hook sendMail when hook return -1 who must be return false in sendfile() function --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index db8b30ed249..34b7c2757e5 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -687,7 +687,7 @@ class CMailFile $this->error = "Error in hook maildao sendMail ".$reshook; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - return $reshook; + return false; } if ($reshook == 1) { // Hook replace standard code return true; From 0099fbbd2c4276062e14bd6f010781f4092c97c5 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Mon, 14 Oct 2024 12:21:59 +0200 Subject: [PATCH 009/243] accountingjournal: add create() method Adding a create method ensure we create the accountingjournal in a uniform way, and allow creating the journals in tests without getting out-of-sync. --- .../class/accountingjournal.class.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 4135e982d14..29eb4086fe1 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017-2022 OpenDSI * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,6 +104,50 @@ class AccountingJournal extends CommonObject $this->ismultientitymanaged = 0; } + /** + * Create a new Accounting Journal. + * + * @param User $user the user that created the journal, currently unused + * @return int Return integer <0 on error, or the ID of the created object + */ + public function create($user) + { + $valid_nature = array(1, 2, 3, 4, 5, 8, 9); + if (!in_array((int) $this->nature, $valid_nature)) { + $this->error = get_class($this)."::Create Error invalid field nature '" . strval($this->nature) . "'"; + dol_syslog($this->error, LOG_ERR); + return -1; + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_journal"; + $sql .= " (entity, code, label, nature, active)"; + $sql .= " VALUES (" + . ((int) $this->entity) .",'" + . $this->db->escape($this->code) ."','" + . $this->db->escape($this->label) ."'," + . ((int) $this->nature) ."," + . ((int) $this->active) .")"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = get_class($this)."::Create Error: " . $this->db->lasterror(); + dol_syslog($this->error, LOG_ERR); + return -1; + } + + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_journal"); + if ($id <= 0) { + $this->error = get_class($this)."::Create Error " . $id . ": " . $this->db->lasterror(); + dol_syslog($this->error, LOG_ERR); + return -2; + } + + $this->id = $id; + $this->rowid = $id; + return $id; + } + /** * Load an object from database * From 9e00b5ec0ecfd29ba94eff7c5a94a261a180ff7e Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 28 Nov 2024 12:08:22 +0100 Subject: [PATCH 010/243] FIX output dir --- .../mymodule/doc/pdf_standard_myobject.modules.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index aa2406f6cc8..90eeab74229 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -263,18 +263,18 @@ class pdf_standard_myobject extends ModelePDFMyObject */ //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - - if (getMultidirOutput($object)) { + $dir_output = getMultidirOutput($object, $object->module) . '/' . $object->element; + if ($dir_output) { $object->fetch_thirdparty(); $dir = null; // Definition of $dir and $file if ($object->specimen) { - $dir = getMultidirOutput($object); + $dir = $dir_output; $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = getMultidirOutput($object)."/".$objectref; + $dir = $dir_output."/".$objectref; $file = $dir."/".$objectref.".pdf"; } if ($dir === null) { @@ -837,7 +837,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of active generation modules + * Return list of active generation models * * @param DoliDB $db Database handler * @param int<0,max> $maxfilenamelength Max length of value to show From 98c8a1766689dca350bbfbba7a7162952eace589 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 3 Dec 2024 11:56:36 +0100 Subject: [PATCH 011/243] try to fix phpstan error --- .../core/modules/mymodule/doc/pdf_standard_myobject.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 90eeab74229..c24df9a986e 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -264,7 +264,7 @@ class pdf_standard_myobject extends ModelePDFMyObject //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; $dir_output = getMultidirOutput($object, $object->module) . '/' . $object->element; - if ($dir_output) { + if (!empty($dir_output)) { $object->fetch_thirdparty(); $dir = null; From 5340f9f8c52c032fe5935e101a85b50b52d4feaa Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 5 Dec 2024 16:47:34 +0100 Subject: [PATCH 012/243] Update pdf_standard_myobject.modules.php --- .../modules/mymodule/doc/pdf_standard_myobject.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index c24df9a986e..f9f2a2762bf 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -263,8 +263,10 @@ class pdf_standard_myobject extends ModelePDFMyObject */ //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - $dir_output = getMultidirOutput($object, $object->module) . '/' . $object->element; + $dir_output = getMultidirOutput($object, $object->module); if (!empty($dir_output)) { + $dir_output .= '/' . $object->element; + $object->fetch_thirdparty(); $dir = null; From a1a102b4e4ba92fd1b674cc7aa96c19c87bac5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Cendrier?= Date: Thu, 12 Dec 2024 14:34:49 +0100 Subject: [PATCH 013/243] FIX: $dir cannot be null, commenting wrong test --- .../modules/mymodule/doc/pdf_standard_myobject.modules.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 3e9bfac76cf..1f227a8be10 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -279,9 +279,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $dir = $dir_output."/".$objectref; $file = $dir."/".$objectref.".pdf"; } - if ($dir === null) { - return 0; - } + // if ($dir === null) { + // return 0; + // } if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); From a4785adb3df9cf7162b21814c4e4204a67ce7ad6 Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 12 Dec 2024 15:28:19 +0100 Subject: [PATCH 014/243] FIX : display error when loan can't be deleted --- htdocs/loan/card.php | 4 ++-- htdocs/loan/class/loan.class.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 8c4cc3810b8..45e8fe0fd8a 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -82,7 +82,7 @@ if (empty($reshook)) { if ($result > 0) { setEventMessages($langs->trans('LoanPaid'), null, 'mesgs'); } else { - setEventMessages($loan->error, null, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -95,7 +95,7 @@ if (empty($reshook)) { header("Location: list.php"); exit; } else { - setEventMessages($loan->error, null, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 98051a0d2b6..0f077d0d9ed 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -308,6 +308,7 @@ class Loan extends CommonObject $accountline->fetch($line_url['fk_bank']); $result = $accountline->delete_urls($user); if ($result < 0) { + $this->errors = array_merge($this->errors, [$accountline->error], $accountline->errors); $error++; } } From d9be3efa90a081f6b5c3c64c1e3a36d3432cb2f4 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 13 Dec 2024 06:18:45 +0100 Subject: [PATCH 015/243] FIX #32339 Delete a loan settlement is partial --- htdocs/loan/class/paymentloan.class.php | 44 +++++++++---------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index bd02374a24c..77c8b183b87 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2018 Frederic France - * Copyright (C) 2020 Maxime DEMAREST +/* Copyright (C) 2014-2024 Alexandre Spangaro + * Copyright (C) 2015-2018 Frederic France + * Copyright (C) 2020 Maxime DEMAREST * * 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 @@ -99,6 +99,11 @@ class PaymentLoan extends CommonObject public $type_code; public $type_label; + /** + * @var int + */ + public $bank_line; + /** * Constructor @@ -364,6 +369,7 @@ class PaymentLoan extends CommonObject } $this->db->rollback(); return -1 * $error; + } else { $this->db->commit(); return 1; @@ -380,19 +386,17 @@ class PaymentLoan extends CommonObject */ public function delete($user, $notrigger = 0) { - global $conf, $langs; $error = 0; $this->db->begin(); - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql .= " WHERE type='payment_loan' AND url_id=".((int) $this->id); - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + if ($this->bank_line > 0) { + $accline = new AccountLine($this->db); + $accline->fetch($this->bank_line); + $result = $accline->delete($user); + if ($result < 0) { + $this->errors[] = $accline->error; + $error++; } } @@ -422,22 +426,6 @@ class PaymentLoan extends CommonObject } } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { From ef090aa895dc7d33482f4bd6d4b1ef9bb8d1d395 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 13 Dec 2024 06:22:44 +0100 Subject: [PATCH 016/243] CI --- htdocs/loan/class/paymentloan.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 77c8b183b87..1604383b700 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -369,7 +369,6 @@ class PaymentLoan extends CommonObject } $this->db->rollback(); return -1 * $error; - } else { $this->db->commit(); return 1; From ce06c12da61d778e8004c98748cb6be0e137f51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina=20JOUM?= Date: Wed, 18 Dec 2024 11:19:56 +0100 Subject: [PATCH 017/243] FIX: GETPOST('private_message') --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 265a661448d..3ae08149626 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -458,7 +458,7 @@ if (empty($reshook)) { // Action to add a message (private or not, with email or not). // This may also send an email (concatenated with email_intro and email footer if checkbox was selected) if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $permissiontoread) { - $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0), 0); + $ret = $object->newMessage($user, $action, GETPOSTINT('private_message'), 0); if ($ret > 0) { if (!empty($backtopage)) { From f60f34cdf8cd3c5f67afb7facd8391e389cfde09 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 2 Jan 2025 14:07:46 +0100 Subject: [PATCH 018/243] Backport fix for send email to assigned user on ticket create --- ...terface_50_modTicket_TicketEmail.class.php | 170 ++++++++++++++---- 1 file changed, 137 insertions(+), 33 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 58eeaf18dc3..bead2d3faf6 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -77,45 +77,48 @@ class InterfaceTicketEmail extends DolibarrTriggers if ($res > 0) { // Send email to notification email if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) { - // Init to avoid errors - $filepath = array(); - $filename = array(); - $mimetype = array(); +// Init to avoid errors +// $filepath = array(); +// $filename = array(); +// $mimetype = array(); // Send email to assigned user - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou'); - $message = '

'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."

"; - $message .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; - $message .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; - $message .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; - $message .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; - // Extrafields - if (is_array($object->array_options) && count($object->array_options) > 0) { - foreach ($object->array_options as $key => $value) { - $message .= '
  • '.$langs->trans($key).' : '.$value.'
  • '; - } - } - - $message .= '
'; - $message .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; - $message .= '

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

'; +// $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou'); +// $message = '

'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."

"; +// $message .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; +// $message .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; +// $message .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; +// $message .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; +// // Extrafields +// if (is_array($object->array_options) && count($object->array_options) > 0) { +// foreach ($object->array_options as $key => $value) { +// $message .= '
  • '.$langs->trans($key).' : '.$value.'
  • '; +// } +// } +// +// $message .= '
'; +// $message .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; +// $message .= '

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

'; $sendto = $userstat->email; - $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>'; - - $message = dol_nl2br($message); + $subject_assignee = 'TicketAssignedToYou'; + $body_assignee = 'TicketAssignedEmailBody'; + $see_ticket_assignee = 'SeeThisTicketIntomanagementInterface'; +// $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>'; +// +// $message = dol_nl2br($message); if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); - if ($mailfile->error) { - setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - } else { - $result = $mailfile->sendfile(); - } +// include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; +// $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); +// if ($mailfile->error) { +// setEventMessages($mailfile->error, $mailfile->errors, 'errors'); +// } else { +// $result = $mailfile->sendfile(); +// } if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; } @@ -173,10 +176,15 @@ class InterfaceTicketEmail extends DolibarrTriggers $subject_admin = 'TicketNewEmailSubjectAdmin'; $body_admin = 'TicketNewEmailBodyAdmin'; + $subject_customer = 'TicketNewEmailSubjectCustomer'; $body_customer = 'TicketNewEmailBodyCustomer'; $see_ticket_customer = 'TicketNewEmailBodyInfosTrackUrlCustomer'; + $subject_assignee = 'TicketAssignedToYou'; + $body_assignee = 'TicketAssignedEmailBody'; + $see_ticket_assignee = 'SeeThisTicketIntomanagementInterface'; + // Send email to notification email if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail'])) { $sendto = empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? '' : $conf->global->TICKET_NOTIFICATION_EMAIL_TO; @@ -185,6 +193,34 @@ class InterfaceTicketEmail extends DolibarrTriggers } } + // Send email to assignee if an assignee was set at creation + if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id && empty($object->context['disableticketemail'])) { + $userstat = new User($this->db); + $res = $userstat->fetch($object->fk_user_assign); + if ($res > 0) { + // Send email to notification email + if (!getDolGlobalString('TICKET_DISABLE_ALL_MAILS')) { + // Send email to assigned user + $sendto = $userstat->email; + if (!getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; + $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; + } + + if (!empty($sendto)) { + $this->composeAndSendAssigneeMessage($sendto, $subject_assignee, $body_assignee, $see_ticket_assignee, $object, $langs); + } + + if (!getDolUserString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; + } + } + } else { + $this->error = $userstat->error; + $this->errors = $userstat->errors; + } + } + // Send email to customer if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) { $sendto = ''; @@ -428,9 +464,9 @@ class InterfaceTicketEmail extends DolibarrTriggers $trackid = 'tic'.$object->id; - $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'); - - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { + $old_MAIN_MAIL_AUTOCOPY_TO = null; + if (getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'); $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } @@ -451,4 +487,72 @@ class InterfaceTicketEmail extends DolibarrTriggers $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; } } + + /** + * Composes and sends a message concerning a ticket, to be sent to user assigned to the ticket + * + * @param string $sendto Addresses to send the mail, format "first@address.net, second@address.net, " etc. + * @param string $base_subject email subject. Non-translated string. + * @param string $body email body (first line). Non-translated string. + * @param string $see_ticket string indicating the ticket public address + * @param Ticket $object the ticket thet the email refers to + * @param Translate $langs the translation object + * @return void + */ + private function composeAndSendAssigneeMessage($sendto, $base_subject, $body, $see_ticket, Ticket $object, Translate $langs) + { + global $conf, $user, $mysoc; + + // Init to avoid errors + $filepath = array(); + $filename = array(); + $mimetype = array(); + + // Send email to assigned user + $appli = $mysoc->name; + + $subject = '['.$appli.'] '.$langs->transnoentities($base_subject); + $message = '

'.$langs->transnoentities($body, $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."

"; + $message .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; + $message .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; + $message .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; + $message .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; + // Extrafields + if (is_array($object->array_options) && count($object->array_options) > 0) { + foreach ($object->array_options as $key => $value) { + $message .= '
  • '.$langs->trans($key).' : '.$value.'
  • '; + } + } + + $message .= '
'; + $message .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; + $message .= '

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

'; + + $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>'; + + $message = dol_nl2br($message); + + $old_MAIN_MAIL_AUTOCOPY_TO = null; + if (getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'); + $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; + } + + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); + if ($mailfile->error) { + setEventMessages($mailfile->error, $mailfile->errors, 'errors'); + } else { + $result = $mailfile->sendfile(); + if ($result) { + // update last_msg_sent date + $object->fetch($object->id); + $object->date_last_msg_sent = dol_now(); + $object->update($user); + } + } + if (!getDolUserString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { + $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; + } + } } From 37a815af535a485b9865bbedd483eee99c7827a6 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 2 Jan 2025 14:50:14 +0100 Subject: [PATCH 019/243] Cleaned code --- ...terface_50_modTicket_TicketEmail.class.php | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index bead2d3faf6..55f04a9d43e 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -77,48 +77,17 @@ class InterfaceTicketEmail extends DolibarrTriggers if ($res > 0) { // Send email to notification email if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) { -// Init to avoid errors -// $filepath = array(); -// $filename = array(); -// $mimetype = array(); - // Send email to assigned user -// $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou'); -// $message = '

'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."

"; -// $message .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; -// $message .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; -// $message .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; -// $message .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; -// // Extrafields -// if (is_array($object->array_options) && count($object->array_options) > 0) { -// foreach ($object->array_options as $key => $value) { -// $message .= '
  • '.$langs->trans($key).' : '.$value.'
  • '; -// } -// } -// -// $message .= '
'; -// $message .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; -// $message .= '

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

'; - $sendto = $userstat->email; $subject_assignee = 'TicketAssignedToYou'; $body_assignee = 'TicketAssignedEmailBody'; $see_ticket_assignee = 'SeeThisTicketIntomanagementInterface'; -// $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>'; -// -// $message = dol_nl2br($message); if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } -// include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; -// $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); -// if ($mailfile->error) { -// setEventMessages($mailfile->error, $mailfile->errors, 'errors'); -// } else { -// $result = $mailfile->sendfile(); -// } + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; } From 4c4b773de5797e69e435dbbe89409cf2ca6220d9 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 2 Jan 2025 14:59:44 +0100 Subject: [PATCH 020/243] Fix send on assign --- .../triggers/interface_50_modTicket_TicketEmail.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 55f04a9d43e..00fce02d2c8 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -87,7 +87,9 @@ class InterfaceTicketEmail extends DolibarrTriggers $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } - + if (!empty($sendto)) { + $this->composeAndSendAssigneeMessage($sendto, $subject_assignee, $body_assignee, $see_ticket_assignee, $object, $langs); + } if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; } From 83abe6aa345a484a7c4c1e4c64cb5d33d2d0d3ff Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Thu, 2 Jan 2025 20:42:43 +0100 Subject: [PATCH 021/243] Fix #29624 Wrong property of commande fournisseur used for substitution. --- htdocs/core/lib/functions.lib.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6896113399d..a7cd3d0253b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -20,7 +20,7 @@ * Copyright (C) 2022 Anthony Berton * Copyright (C) 2022 Ferran Marcet * Copyright (C) 2022 Charlene Benke - * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2023-2024 Joachim Kueter * * 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 @@ -8307,15 +8307,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - $substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, 'day', 0, $outputlangs) : ''); - $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%d") : ''); - $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%A") : ''); - $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%m") : ''); - $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%b") : ''); - $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%Y") : ''); - $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%H") : ''); - $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%M") : ''); - $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%S") : ''); + $substitutionarray['__DATE_DELIVERY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, 'day', 0, $outputlangs) : ''); + $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%d") : ''); + $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%A") : ''); + $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%m") : ''); + $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%b") : ''); + $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%Y") : ''); + $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%H") : ''); + $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%M") : ''); + $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%S") : ''); // For backward compatibility (deprecated) $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); From 112220da86222ba4cf9054ac53685c735cc4502d Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 3 Jan 2025 10:08:56 +0100 Subject: [PATCH 022/243] BUG: when there are two identical HTML tags in a substitution string, everything is taken between first opening tag and last closing tag. Write test to reproduce. --- test/phpunit/ODFTest.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/test/phpunit/ODFTest.php b/test/phpunit/ODFTest.php index a7d972bf345..a019d5754e2 100644 --- a/test/phpunit/ODFTest.php +++ b/test/phpunit/ODFTest.php @@ -296,33 +296,39 @@ class ODFTest extends PHPUnit\Framework\TestCase 'charset' => null, 'expected' => utf8_encode('text with intricatedtags'), ], + 24 => [ + 'to_convert' => "text with two (strong) tags", + 'encode' => true, + 'charset' => null, + 'expected' => utf8_encode('text with two (strong) tags'), + ], // One can also pass html-encoded string to the method - 24 => [ + 25 => [ 'to_convert' => 'One&two', 'encode' => true, 'charset' => null, 'expected' => 'One&two', ], - 25 => [ + 26 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => false, 'charset' => 'UTF-8', 'expected' => 'text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\'', ], - 26 => [ + 27 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => true, 'charset' => 'UTF-8', 'expected' => 'text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l'', ], - 27 => [ + 28 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => false, 'charset' => null, 'expected' => utf8_encode('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\''), ], - 28 => [ + 29 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => true, 'charset' => null, @@ -341,20 +347,20 @@ class ODFTest extends PHPUnit\Framework\TestCase // Following tests reflect the current behavior. They may evolve if the method behavior changes. // The method removes hyperlinks and tags that are not dealt with. - 29 => [ + 30 => [ 'to_convert' => '123 trucmachin > truc < troc > tracbla bla', 'encode' => true, 'charset' => null, 'expected' => "123 trucmachin > truc < troc > tracbla bla", ], - 30 => [ + 31 => [ 'to_convert' => '123

Title

bla', 'encode' => true, 'charset' => null, 'expected' => "123 Title bla", ], // HTML should not take \n into account, but only
. - 31 => [ + 32 => [ 'to_convert' => "text with strong text , a line\nbreak and underlined words with it@lic sp&ciàlchärs éè l'", 'encode' => false, 'charset' => 'UTF-8', From b31962f7e2835a294d3079985ba2fe3426152e59 Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 3 Jan 2025 10:41:35 +0100 Subject: [PATCH 023/243] fix --- htdocs/includes/odtphp/odf.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 5a832234686..17dc178b6a2 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -46,8 +46,8 @@ class Odf public $userdefined=array(); const PIXEL_TO_CM = 0.026458333; - const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/s'; - const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/'; + const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>([^(<\1>)]*)<\/\1>))/s'; + const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>([^(<\1>)]*)<\/\1>))/'; /** @@ -1017,4 +1017,4 @@ IMG; $this->contentXml = preg_replace($searchreg, "", $this->contentXml); return $matches[1]; } -} \ No newline at end of file +} From 61b03b0c0575456e098c2e7a2628ba385c1d179d Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 3 Jan 2025 10:50:30 +0100 Subject: [PATCH 024/243] Testing ODF : revert parameters order for assertEquals() --- test/phpunit/ODFTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/ODFTest.php b/test/phpunit/ODFTest.php index a019d5754e2..ab1a2c74d48 100644 --- a/test/phpunit/ODFTest.php +++ b/test/phpunit/ODFTest.php @@ -377,7 +377,7 @@ class ODFTest extends PHPUnit\Framework\TestCase } else { $res = $odf->convertVarToOdf($case['to_convert'], $case['encode']); } - $this->assertEquals($res, $case['expected']); + $this->assertEquals($case['expected'], $res); } print __METHOD__." result=".$result."\n"; From 78bf506790c18a227c8b9936919f92e4a0b46df4 Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 3 Jan 2025 11:14:17 +0100 Subject: [PATCH 025/243] fix tests in error --- htdocs/includes/odtphp/odf.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 17dc178b6a2..f5678d838a3 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -46,8 +46,8 @@ class Odf public $userdefined=array(); const PIXEL_TO_CM = 0.026458333; - const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>([^(<\1>)]*)<\/\1>))/s'; - const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>([^(<\1>)]*)<\/\1>))/'; + const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1>).)*)<\/\1>))/s'; + const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1>).)*)<\/\1>))/'; /** From b7cb799af0245ae3c5737a6bdd9589f9fc5eea7f Mon Sep 17 00:00:00 2001 From: Alexis Thietard Date: Mon, 6 Jan 2025 14:23:13 +0100 Subject: [PATCH 026/243] FIX #21294 Stock import sql query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To respect the PostgreSQL update statement syntax, cf. https://www.postgresql.org/docs/17/sql-update.html ``` column_name The name of a column in the table named by table_name. The column name can be qualified with a subfield name or array subscript, if needed. Do not include the table's name in the specification of a target column — for example, UPDATE table_name SET table_name.col = 1 is invalid. ``` Signed-off-by: Alexis Thietard --- htdocs/core/modules/modStock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index e9e9ccc79a6..f7def03808c 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -429,7 +429,7 @@ class modStock extends DolibarrModules ); $this->import_updatekeys_array[$r] = array('ps.fk_product'=>'Product', 'ps.fk_entrepot'=>"Warehouse"); $this->import_run_sql_after_array[$r] = array( // Because we may change data that are denormalized, we must update dernormalized data after. - 'UPDATE '.MAIN_DB_PREFIX.'product as p SET p.stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' + 'UPDATE '.MAIN_DB_PREFIX.'product as p SET stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' ); } From 886abc96d16510e48b3bb6eed3cdca1ccf4dcde3 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:03:17 +0100 Subject: [PATCH 027/243] handle property for delivery date (named differently in different objects)) --- htdocs/core/lib/functions.lib.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a7cd3d0253b..b587cba9fe1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8307,20 +8307,27 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - $substitutionarray['__DATE_DELIVERY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, 'day', 0, $outputlangs) : ''); - $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%d") : ''); - $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%A") : ''); - $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%m") : ''); - $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%b") : ''); - $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%Y") : ''); - $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%H") : ''); - $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%M") : ''); - $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, "%S") : ''); + // handle date_delivery: in customer oder/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery + $date_delivery = null; + if (property_exists($object, 'date_delivery')) { + $date_delivery = $object->date_delivery; + } elseif (property_exists($object, delivery_date')) { + $date_delivery = $object->delivery_date; + } + $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); + $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%d") : ''); + $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%A") : ''); + $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%m") : ''); + $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%b") : ''); + $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%Y") : ''); + $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%H") : ''); + $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%M") : ''); + $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%S") : ''); // For backward compatibility (deprecated) $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); - $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, 'day', 0, $outputlangs) : ''); + $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); $substitutionarray['__SUPPLIER_ORDER_DELAY_DELIVERY__'] = (isset($object->availability_code) ? ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '')) : ''); $substitutionarray['__EXPIRATION_DATE__'] = (isset($object->fin_validite) ? dol_print_date($object->fin_validite, 'daytext') : ''); From 21607b4f28f20af36d9c03d56b52752b6d90f623 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:11:01 +0100 Subject: [PATCH 028/243] Update functions.lib.php --- 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 b587cba9fe1..53c326c22fa 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8307,12 +8307,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - // handle date_delivery: in customer oder/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery + // handle date_delivery: in customer order/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery $date_delivery = null; if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; } elseif (property_exists($object, delivery_date')) { - $date_delivery = $object->delivery_date; + $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%d") : ''); From 0158b2b8324ffb13299a61cab959f8bcb0c020fd Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:17:00 +0100 Subject: [PATCH 029/243] Update functions.lib.php trying to solve indentation issue --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 53c326c22fa..b3f54ea2d54 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8307,6 +8307,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); + // handle date_delivery: in customer order/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery $date_delivery = null; if (property_exists($object, 'date_delivery')) { From 48a33932644f4377e775a3c9e53dbc1fe12a2e47 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:21:46 +0100 Subject: [PATCH 030/243] Update functions.lib.php trying to solve indentation --- 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 b3f54ea2d54..82b983e1026 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8312,7 +8312,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $date_delivery = null; if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; - } elseif (property_exists($object, delivery_date')) { + } else if (property_exists($object, delivery_date')) { $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); From dd41f3f47d5e391848cad4564309a20f1688a24e Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:25:00 +0100 Subject: [PATCH 031/243] Update functions.lib.php trying to solve whitespace/indentation issues --- htdocs/core/lib/functions.lib.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 82b983e1026..47d7dccd6eb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8307,12 +8307,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - // handle date_delivery: in customer order/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery $date_delivery = null; - if (property_exists($object, 'date_delivery')) { + if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; - } else if (property_exists($object, delivery_date')) { + } elseif (property_exists($object, delivery_date')) { $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); From 7689e0b210e0744b4258b21f6140625554f78a44 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:28:17 +0100 Subject: [PATCH 032/243] Update functions.lib.php solve indentation --- 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 47d7dccd6eb..53c326c22fa 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8309,7 +8309,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); // handle date_delivery: in customer order/supplier order, the property name is delivery_date, in shipment/reception it is date_delivery $date_delivery = null; - if (property_exists($object, 'date_delivery')) { + if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; } elseif (property_exists($object, delivery_date')) { $date_delivery = $object->delivery_date; From 259088c28056ce6c0d29064ce4696b5344e57553 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 09:35:37 +0100 Subject: [PATCH 033/243] Update functions.lib.php fixed typo... --- 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 53c326c22fa..3ea1c942c5a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8311,7 +8311,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $date_delivery = null; if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; - } elseif (property_exists($object, delivery_date')) { + } elseif (property_exists($object, 'delivery_date')) { $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); From c218eaa6ed6ca5e97ddbdaa6c68a8934bede5831 Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Tue, 7 Jan 2025 12:10:40 +0100 Subject: [PATCH 034/243] fix join societe_commerciaux in societe list --- htdocs/societe/list.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 21e811c25c8..59c79e2ec95 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -516,7 +516,7 @@ if ($search_sale == -2) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } elseif (!empty($search_sale) && $search_sale != '-1' || (empty($user->rights->societe->client->voir) && !$socid)) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux AS sc ON s.rowid = sc.fk_soc"; } // Add table from hooks $parameters = array(); @@ -527,9 +527,6 @@ $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } -if ($search_sale && $search_sale != '-1' && $search_sale != '-2') { - $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale -} if (empty($user->rights->fournisseur->lire)) { $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible } From 92d448cfe61b8eb3a51715a76411abf35fe6a9ac Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 14:02:47 +0100 Subject: [PATCH 035/243] Update functions.lib.php fixed spaces From 5c7fd531db29488801bb1b659a4d33ab4d6ba76e Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Tue, 7 Jan 2025 15:01:50 +0100 Subject: [PATCH 036/243] Update functions.lib.php white space From ec58ee940a8de664875d826f2c9ac3eca4b612d5 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:09:48 +0100 Subject: [PATCH 037/243] FIX: product variants copy: also copy multiprice variations --- .../class/ProductCombination.class.php | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 42e3bdc1530..fa642dc2765 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -702,16 +702,16 @@ class ProductCombination * [...] * ) * - * @param User $user Object user - * @param Product $product Parent product - * @param array $combinations Attribute and value combinations. - * @param array $variations Price and weight variations - * @param bool|array $price_var_percent Is the price variation a relative variation? - * @param bool|float $forced_pricevar If the price variation is forced - * @param bool|float $forced_weightvar If the weight variation is forced - * @param bool|string $forced_refvar If the reference is forced - * @param string $ref_ext External reference - * @return int <0 KO, >0 OK + * @param User $user Object user + * @param Product $product Parent product + * @param array $combinations Attribute and value combinations. + * @param array $variations Price and weight variations + * @param bool|array $price_var_percent Is the price variation a relative variation? + * @param bool|float|array $forced_pricevar If the price variation is forced + * @param bool|float $forced_weightvar If the weight variation is forced + * @param bool|string $forced_refvar If the reference is forced + * @param string $ref_ext External reference + * @return int <0 KO, >0 OK */ public function createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false, $forced_refvar = false, $ref_ext = '') { @@ -752,8 +752,8 @@ class ProductCombination $price_impact = $forced_pricevar; } - if (!array($price_var_percent)) { - $price_var_percent[1] = (float) $price_var_percent; + if (!is_array($price_var_percent)) { + $price_var_percent = array(1 => (float) $price_var_percent); } $newcomb = new ProductCombination($this->db); @@ -840,12 +840,7 @@ class ProductCombination $productCombinationLevel->fk_product_attribute_combination = $newcomb->id; $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - - if (is_array($price_var_percent)) { - $productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]); - } else { - $productCombinationLevel->variation_price_percentage = $price_var_percent; - } + $productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]); $newcomb->combination_price_levels[$i] = $productCombinationLevel; } @@ -955,13 +950,26 @@ class ProductCombination $variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val; } + $variation_price_percentage = $combination->variation_price_percentage; + $variation_price = $combination->variation_price; + + if (getDolGlobalInt('PRODUIT_MULTIPRICES') && getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT') > 1) { + $variation_price_percentage = [ ]; + $variation_price = [ ]; + + foreach ($combination->combination_price_levels as $productCombinationLevel) { + $variation_price_percentage[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price_percentage; + $variation_price[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price; + } + } + if ($this->createProductCombination( $user, $destProduct, $variations, array(), - $combination->variation_price_percentage, - $combination->variation_price, + $variation_price_percentage, + $variation_price, $combination->variation_weight ) < 0) { return -1; From 3ef6299c839aa0e1ae473e65942a6ace54dc6644 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:20:57 +0100 Subject: [PATCH 038/243] FIX: phpcs --- htdocs/variants/class/ProductCombination.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index fa642dc2765..e41325f6efb 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -950,8 +950,8 @@ class ProductCombination $variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val; } - $variation_price_percentage = $combination->variation_price_percentage; - $variation_price = $combination->variation_price; + $variation_price_percentage = $combination->variation_price_percentage; + $variation_price = $combination->variation_price; if (getDolGlobalInt('PRODUIT_MULTIPRICES') && getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT') > 1) { $variation_price_percentage = [ ]; From ef564caf28bafb827aec71697e58f2a0e4302fca Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:37:30 +0100 Subject: [PATCH 039/243] FIX: qual --- htdocs/variants/class/ProductCombination.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index e41325f6efb..163ea7be5bd 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -753,7 +753,7 @@ class ProductCombination } if (!is_array($price_var_percent)) { - $price_var_percent = array(1 => (float) $price_var_percent); + $price_var_percent = array(1 => (bool) $price_var_percent); } $newcomb = new ProductCombination($this->db); @@ -840,7 +840,7 @@ class ProductCombination $productCombinationLevel->fk_product_attribute_combination = $newcomb->id; $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - $productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]); + $productCombinationLevel->variation_price_percentage = $price_var_percent[$i]; $newcomb->combination_price_levels[$i] = $productCombinationLevel; } From 169b2ce4e81977278b96ee9976635cc340b2045f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jan 2025 21:52:26 +0100 Subject: [PATCH 040/243] 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 3ea1c942c5a..d2e1d11a6d8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8312,7 +8312,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (property_exists($object, 'date_delivery')) { $date_delivery = $object->date_delivery; } elseif (property_exists($object, 'delivery_date')) { - $date_delivery = $object->delivery_date; + $date_delivery = $object->delivery_date; } $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%d") : ''); From 3737f3c0cd5f8cca1d2f73e506bcaa463971318e Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 8 Jan 2025 12:30:46 +0100 Subject: [PATCH 041/243] FIX select 2 no record found --- htdocs/core/class/html.form.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index aaf856152b7..329017cc3b2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8890,7 +8890,8 @@ class Form escapeMarkup: function (markup) { return markup; }, // let our custom formatter work // Specify format function for selected item formatSelection: formatSelection, - templateSelection: formatSelection /* For 4.0 */ + templateSelection: formatSelection, /* For 4.0 */ + language: select2arrayoflanguage }); /* Add also morecss to the css .select2 that is after the #htmlname, for component that are show dynamically after load, because select2 set From 0c05b8110f3d8f3c3054bb76be3464fbffa6f001 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Wed, 8 Jan 2025 16:19:06 +0100 Subject: [PATCH 042/243] Fix fatal error on sprintf with translate --- htdocs/core/class/translate.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 92b32d2f257..3916ef277d6 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -699,6 +699,10 @@ class Translate $str ); + if (preg_match('/%\)/', $str)) { + $str = preg_replace('/%\)/', '__percent__)', $str); + } + if (strpos($key, 'Format') !== 0) { try { // @phan-suppress-next-line PhanPluginPrintfVariableFormatString @@ -708,6 +712,8 @@ class Translate } } + $str = str_replace('__percent__', '%', $str); + // Encode string into HTML $str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are embraced by "). Use dol_escape_htmltag around text in HTML content From 8e427353e08c5ec6f18ce7a7adc948af2cf80f9c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 07:39:24 +0100 Subject: [PATCH 043/243] FIX avoid to show html entities --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 7c6ad95a238..1b0b28bbb83 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2063,7 +2063,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; if (!empty($object->api_key)) { print ''; - print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste + print showValueWithClipboardCPButton($object->api_key, 1, $langs->transnoentities("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste print ''; } print ''; From 3fcdba2bc3e1fd5db1d2aa0110c473ee62c0ffde Mon Sep 17 00:00:00 2001 From: Hystepik Date: Thu, 9 Jan 2025 09:21:45 +0100 Subject: [PATCH 044/243] better fix for performance --- htdocs/core/class/translate.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 3916ef277d6..905ccf9349b 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -699,9 +699,7 @@ class Translate $str ); - if (preg_match('/%\)/', $str)) { - $str = preg_replace('/%\)/', '__percent__)', $str); - } + $str = preg_replace('/%\)/', '__percent__)', $str); if (strpos($key, 'Format') !== 0) { try { From f0449e349f0adb37cdea60f1268b93232386f93a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 9 Jan 2025 09:59:23 +0100 Subject: [PATCH 045/243] fix: php warning --- htdocs/core/modules/commande/mod_commande_marbre.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index e5e2e525342..e229e17f89e 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -57,7 +57,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes { global $conf, $mysoc; - if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 16.0 && $mysoc->country_code != 'FR') { + if ((float) getDolGlobalString('MAIN_VERSION_LAST_INSTALL') >= 16.0 && $mysoc->country_code != 'FR') { $this->prefix = 'SO'; // We use correct standard code "SO = Sale Order" } } From 4934a335b0bed1d8a36c1808c606d119b277a42d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 10:09:23 +0100 Subject: [PATCH 046/243] FIX use transnoentities to avoid html entities --- htdocs/user/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 1b0b28bbb83..b1f82031b6b 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1211,7 +1211,7 @@ if ($action == 'create' || $action == 'adduserldap') { // We do not use a field password but a field text to show new password to use. $valuetoshow .= ($valuetoshow ? ' + '.$langs->trans("DolibarrPassword") : '').''; if (!empty($conf->use_javascript_ajax)) { - $valuetoshow .= img_picto($langs->trans('Generate'), 'refresh', 'id="generate_password" class="linkobject paddingleft"'); + $valuetoshow .= img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_password" class="linkobject paddingleft"'); } } } @@ -1235,7 +1235,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; if (!empty($conf->use_javascript_ajax)) { - print img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); + print img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); } print ''; } else { @@ -2626,7 +2626,7 @@ if ($action == 'create' || $action == 'adduserldap') { if ($permissiontoeditpasswordandsee) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; if (!empty($conf->use_javascript_ajax)) { - $valuetoshow .= img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->trans('NoPasswordGenerationRuleConfigured') : $langs->trans('Generate')), 'refresh', 'id="generate_password" class="paddingleft'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"'); + $valuetoshow .= img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->transnoentities('NoPasswordGenerationRuleConfigured') : $langs->transnoentities('Generate')), 'refresh', 'id="generate_password" class="paddingleft'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"'); } } else { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); From 029569954358539998885ce37cbd1288f3eaf7f4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 9 Jan 2025 10:21:20 +0100 Subject: [PATCH 047/243] fix: avoid php8 warning/error on failed notification --- .../interface_50_modNotification_Notification.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 8fceee8e47a..d1095b14745 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -96,6 +96,9 @@ class InterfaceNotification extends DolibarrTriggers $notify = new Notify($this->db); $resultSend = $notify->send($action, $object); if ($resultSend < 0) { + if (!isset($this->errors)) { + $this->errors = []; + } $this->errors = array_merge($this->errors, $notify->errors); return $resultSend; } From 41b07d1630a9707f0cc201f70ef2b06cd98ee40a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 10:36:48 +0100 Subject: [PATCH 048/243] FIX compatibility with externals modules --- htdocs/user/card.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index b1f82031b6b..9ee8f3d2b91 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1980,7 +1980,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; // Date login validity - print ''.$langs->trans("RangeOfLoginValidity").''; + print ''.$langs->trans("RangeOfLoginValidity").''; print ''; if ($object->datestartvalidity) { print ''.$langs->trans("FromDate").' '; @@ -2043,9 +2043,9 @@ if ($action == 'create' || $action == 'adduserldap') { // Other form for user password $parameters = array('valuetoshow' => $valuetoshow, 'caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { + if ($reshook === 1) { $valuetoshow = $hookmanager->resPrint; // to replace - } else { + } elseif (empty($reshook)) { $valuetoshow .= $hookmanager->resPrint; // to add } @@ -2057,6 +2057,11 @@ if ($action == 'create' || $action == 'adduserldap') { print ''."\n"; } + // for compatibility with externals modules + if ($reshook > 1) { + print $hookmanager->resPrint; + } + // API key if (isModEnabled('api') && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) { print ''.$langs->trans("ApiKey").''; From e612bb05599deaf712b5158d980251c1bd223273 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Thu, 9 Jan 2025 10:50:47 +0100 Subject: [PATCH 049/243] FIX 20.0 - PHP8 fatal when creating a reception if no corresponding PDF model enabled --- htdocs/reception/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 488fef75ffe..b1791d3da04 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -947,7 +947,7 @@ if ($action == 'create') { include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; $list = ModelePdfReception::liste_modeles($db); - if (count($list) > 1) { + if (is_array($list) && count($list) > 1) { print "".$langs->trans("DefaultModel").""; print ''; print $form->selectarray('model', $list, $conf->global->RECEPTION_ADDON_PDF); From 7618df8726d9564d60b1f70cf28263e9fe1d2f05 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 11:04:32 +0100 Subject: [PATCH 050/243] FIX remove html entities --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 9ee8f3d2b91..816cd95db31 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2656,7 +2656,7 @@ if ($action == 'create' || $action == 'adduserldap') { if ($permissiontoeditpasswordandsee || $user->hasRight("api", "apikey", "generate")) { print ''; if (!empty($conf->use_javascript_ajax)) { - print img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); + print img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); } } print ''; From 7e82f70c77aa42718cb6009d72cb5d806ca7175e Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 9 Jan 2025 11:05:45 +0100 Subject: [PATCH 051/243] add case when HTML tags contain attributes --- htdocs/includes/odtphp/odf.php | 4 ++-- test/phpunit/ODFTest.php | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index f5678d838a3..39f595f4934 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -46,8 +46,8 @@ class Odf public $userdefined=array(); const PIXEL_TO_CM = 0.026458333; - const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1>).)*)<\/\1>))/s'; - const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1>).)*)<\/\1>))/'; + const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1(\s.*)?>).)*)<\/\1>))/s'; + const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1(\s.*)?>).)*)<\/\1>))/'; /** diff --git a/test/phpunit/ODFTest.php b/test/phpunit/ODFTest.php index ab1a2c74d48..2badd77baf6 100644 --- a/test/phpunit/ODFTest.php +++ b/test/phpunit/ODFTest.php @@ -302,33 +302,39 @@ class ODFTest extends PHPUnit\Framework\TestCase 'charset' => null, 'expected' => utf8_encode('text with two (strong) tags'), ], + 25 => [ + 'to_convert' => "text with two (strong) tags and intricated underline ", + 'encode' => true, + 'charset' => null, + 'expected' => utf8_encode('text with two (strong) tags and intricated underline '), + ], // One can also pass html-encoded string to the method - 25 => [ + 26 => [ 'to_convert' => 'One&two', 'encode' => true, 'charset' => null, 'expected' => 'One&two', ], - 26 => [ + 27 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => false, 'charset' => 'UTF-8', 'expected' => 'text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\'', ], - 27 => [ + 28 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => true, 'charset' => 'UTF-8', 'expected' => 'text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l'', ], - 28 => [ + 29 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => false, 'charset' => null, 'expected' => utf8_encode('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\''), ], - 29 => [ + 30 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => true, 'charset' => null, @@ -347,20 +353,20 @@ class ODFTest extends PHPUnit\Framework\TestCase // Following tests reflect the current behavior. They may evolve if the method behavior changes. // The method removes hyperlinks and tags that are not dealt with. - 30 => [ + 31 => [ 'to_convert' => '123 trucmachin > truc < troc > tracbla bla', 'encode' => true, 'charset' => null, 'expected' => "123 trucmachin > truc < troc > tracbla bla", ], - 31 => [ + 32 => [ 'to_convert' => '123

Title

bla', 'encode' => true, 'charset' => null, 'expected' => "123 Title bla", ], // HTML should not take \n into account, but only
. - 32 => [ + 33 => [ 'to_convert' => "text with strong text , a line\nbreak and underlined words with it@lic sp&ciàlchärs éè l'", 'encode' => false, 'charset' => 'UTF-8', From 90713d7773ed8cf46592f26c2e6c757a5fbf865a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 12:07:03 +0100 Subject: [PATCH 052/243] FIX wrong alias table --- htdocs/compta/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index e5119d46c56..9968411c62e 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -444,7 +444,7 @@ if (isModEnabled('don') && $user->hasRight('don', 'lire')) { print ''; print ''; print ''; print ''; print ''; From 0912b3b04f026f668a527cc99cbbc9ccf341752e Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Thu, 9 Jan 2025 15:04:37 +0100 Subject: [PATCH 053/243] fix selectcontacts param --- htdocs/comm/action/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 99d330b745a..0310ac0b225 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1181,8 +1181,14 @@ if ($action == 'create') { $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); } if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int'); + // select "all" or "none" contact by default + if (getDolGlobalInt('MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT')) { + $select_contact_default = 0; // select "all" contacts by default : avoid to use it if there is a lot of contacts + } else { + $select_contact_default = -1; // select "none" by default + } print img_picto('', 'contact', 'class="paddingrightonly"'); - print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); + print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); print ''; } From e37b6fac4d54cd73f509ee889c1bc5335f6ec135 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 9 Jan 2025 20:26:22 +0100 Subject: [PATCH 054/243] Fix pb in output of label of email --- htdocs/core/lib/company.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 39b3037aea5..30a8242a7ec 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -2119,11 +2119,13 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= dol_trunc($libelle, 120); } if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { - $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; $transcode = $langs->trans("Action".$histo[$key]['acode']); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); + $out .= ''; + $out .= img_object($langs->trans("ShowEMailing"), "email").' '; $out .= dol_trunc($libelle, 120); + $out .= ''; } $out .= ''; From 3f7d5cf790b9f5d074e02f71bd0301b3d0cff4c1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 00:33:51 +0100 Subject: [PATCH 055/243] NEW add hook 'addMoreInformationsBlock' --- htdocs/user/card.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 816cd95db31..84da0249955 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2088,6 +2088,13 @@ if ($action == 'create' || $action == 'adduserldap') { print '
'.$langs->trans("BoxTitleLastModifiedDonations", $max); - print '...'; + print '...'; print ''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").'
'; print ''; + // Other informations block + $parameters = array('caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); + $reshook = $hookmanager->executeHooks('addMoreInformationsBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) { + print $hookmanager->resPrint; + } + print ''; print ''; From 8d11c1625f366601d5708631e2096c6494440c94 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 03:04:55 +0100 Subject: [PATCH 056/243] FIX wrong hook name --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 84da0249955..3a5987bf59f 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2088,9 +2088,9 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; - // Other informations block + // Other informations bloc $parameters = array('caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); - $reshook = $hookmanager->executeHooks('addMoreInformationsBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('addMoreInformationBloc', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook > 0) { print $hookmanager->resPrint; } From f8b957fd0d68a7366e44da455d2f7f5a1f5f5862 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 03:10:01 +0100 Subject: [PATCH 057/243] FIX tu veux ou tu veux pas ? --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3a5987bf59f..7db5b6ba454 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2090,7 +2090,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Other informations bloc $parameters = array('caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); - $reshook = $hookmanager->executeHooks('addMoreInformationBloc', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('addMoreInformationBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook > 0) { print $hookmanager->resPrint; } From 5ab7e9ec3fdaa634de7e92d72cec94ed423bcbe6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 03:21:20 +0100 Subject: [PATCH 058/243] FIX use the right hook name --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 7db5b6ba454..e2992a25f46 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2088,9 +2088,9 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; - // Other informations bloc + // Add more object block $parameters = array('caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); - $reshook = $hookmanager->executeHooks('addMoreInformationBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('addMoreObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook > 0) { print $hookmanager->resPrint; } From bbcb43e27d1570d89012ec3a2b1df3c69e6714b7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 10 Jan 2025 06:25:47 +0100 Subject: [PATCH 059/243] FIX Loan - Insurance amount need decimals --- htdocs/loan/card.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 61f0823560d..02e44ce2e73 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,8 +1,8 @@ - * Copyright (C) 2015 Frederic France - * Copyright (C) 2017 Laurent Destailleur - * Copyright (C) 2020 Maxime DEMAREST +/* Copyright (C) 2014-2025 Alexandre Spangaro + * Copyright (C) 2015 Frederic France + * Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2020 Maxime DEMAREST * * 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 @@ -106,7 +106,7 @@ if (empty($reshook)) { if (!$cancel) { $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOST('capital')); + $capital = price2num(GETPOSTFLOAT('capital')); $rate = price2num(GETPOST('rate')); if (!$capital) { @@ -141,7 +141,7 @@ if (empty($reshook)) { $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); $object->fk_project = GETPOSTINT('projectid'); - $object->insurance_amount = GETPOSTINT('insurance_amount'); + $object->insurance_amount = GETPOSTFLOAT('insurance_amount'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); @@ -181,7 +181,7 @@ if (empty($reshook)) { $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOST('capital')); + $capital = price2num(GETPOSTFLOAT('capital')); if (!$capital) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); @@ -192,7 +192,7 @@ if (empty($reshook)) { $object->capital = $capital; $object->nbterm = GETPOSTINT("nbterm"); $object->rate = price2num(GETPOST("rate", 'alpha')); - $object->insurance_amount = price2num(GETPOSTINT('insurance_amount')); + $object->insurance_amount = price2num(GETPOSTFLOAT('insurance_amount')); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); From 3854719ee9fa46aff19ef75e5345f98ec0fd2290 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 06:58:51 +0100 Subject: [PATCH 060/243] FIX phpstan --- htdocs/public/payment/paymentko.php | 1 + htdocs/public/payment/paymentok.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index f8460f8a799..6c63bc291ab 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -145,6 +145,7 @@ $object = new stdClass(); // For triggers */ // Check if we have redirtodomain to do. +$doactionsthenredirect = 0; if ($ws) { $doactionsthenredirect = 1; } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index b70871bdf2d..907d6fc0505 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -174,6 +174,7 @@ $error = 0; // Check if we have redirtodomain to do. $ws_virtuelhost = null; +$doactionsthenredirect = 0; if ($ws) { $doactionsthenredirect = 1; include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; From aa438e29be1e4cd58ea5224b6f758c3729f3b524 Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 9 Jan 2025 17:30:07 +0100 Subject: [PATCH 061/243] fix: avoid duplicate lines in inventory --- htdocs/product/inventory/class/inventory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 890bce9870c..559ac2cd859 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -274,7 +274,7 @@ class Inventory extends CommonObject // Scan existing stock to prefill the inventory $sql = "SELECT ps.rowid, ps.fk_entrepot as fk_warehouse, ps.fk_product, ps.reel,"; if (isModEnabled('productbatch')) { - $sql .= " pb.batch as batch, pb.qty as qty,"; + $sql .= " COALESCE(pb.batch, '') as batch, pb.qty as qty,"; } else { $sql .= " '' as batch, 0 as qty,"; } From 0fe484ecd6ceec5eb3a284f4d2f875b31522f62d Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 10 Jan 2025 13:00:11 +0100 Subject: [PATCH 062/243] better fix --- htdocs/core/class/translate.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 905ccf9349b..2e7db582b5f 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -699,7 +699,7 @@ class Translate $str ); - $str = preg_replace('/%\)/', '__percent__)', $str); + $str = preg_replace('/%\)/', '__percent_parentesis__', $str); if (strpos($key, 'Format') !== 0) { try { @@ -710,7 +710,7 @@ class Translate } } - $str = str_replace('__percent__', '%', $str); + $str = str_replace('__percent_parentesis__', '%)', $str); // Encode string into HTML $str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are embraced by "). Use dol_escape_htmltag around text in HTML content From 49af0a49dd1bf71996bf468ff0a11088fd3a96f5 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 10 Jan 2025 14:14:00 +0100 Subject: [PATCH 063/243] Remove price2num on GETPOSTFLOAT --- htdocs/loan/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 02e44ce2e73..f806f9d6f84 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -106,7 +106,7 @@ if (empty($reshook)) { if (!$cancel) { $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOSTFLOAT('capital')); + $capital = GETPOSTFLOAT('capital'); $rate = price2num(GETPOST('rate')); if (!$capital) { @@ -181,7 +181,7 @@ if (empty($reshook)) { $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOSTFLOAT('capital')); + $capital = GETPOSTFLOAT('capital'); if (!$capital) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); @@ -192,7 +192,7 @@ if (empty($reshook)) { $object->capital = $capital; $object->nbterm = GETPOSTINT("nbterm"); $object->rate = price2num(GETPOST("rate", 'alpha')); - $object->insurance_amount = price2num(GETPOSTFLOAT('insurance_amount')); + $object->insurance_amount = GETPOSTFLOAT('insurance_amount'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); From 30168c5445c7af9be332c4ddb0622175ac9e0d28 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 10 Jan 2025 15:09:20 +0100 Subject: [PATCH 064/243] fix tipo --- htdocs/core/class/translate.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 2e7db582b5f..0560bd5be94 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -699,7 +699,7 @@ class Translate $str ); - $str = preg_replace('/%\)/', '__percent_parentesis__', $str); + $str = preg_replace('/%\)/', '__percent_parenthesis__', $str); if (strpos($key, 'Format') !== 0) { try { @@ -710,7 +710,7 @@ class Translate } } - $str = str_replace('__percent_parentesis__', '%)', $str); + $str = str_replace('__percent_parenthesis__', '%)', $str); // Encode string into HTML $str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are embraced by "). Use dol_escape_htmltag around text in HTML content From 1cdcf9beb452430587e2570ccb92e0dfb719b09e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Jan 2025 15:17:06 +0100 Subject: [PATCH 065/243] FIX #32611 --- htdocs/user/bank.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index c7dcfc05cc3..8f534756aa4 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -94,6 +94,8 @@ $permissiontoreadhr = $user->hasRight('hrm', 'read_personal_information', 'read' $permissiontowritehr = $user->hasRight('hrm', 'write_personal_information', 'write'); $permissiontosimpleedit = ($selfpermission || $canadduser); +$childids = $user->getAllChildIds(1); + // Ok if user->hasRight('salaries', 'readall') or user->hasRight('hrm', 'read') //$result = restrictedArea($user, 'salaries|hrm', $object->id, 'user&user', $feature2); $ok = false; @@ -106,9 +108,13 @@ if ($user->hasRight('salaries', 'readall')) { if ($user->hasRight('hrm', 'read')) { $ok = true; } -if ($user->hasRight('expensereport', 'lire') && ($user->id == $object->id || $user->hasRight('expensereport', 'readall'))) { +if ($user->hasRight('expensereport', 'readall') || ($user->hasRight('expensereport', 'readall') && in_array($object->id, $childids))) { $ok = true; } +if ($user->hasRight('holiday', 'readall') || ($user->hasRight('holiday', 'read') && in_array($object->id, $childids))) { + $ok = true; +} +var_dump($ok); if (!$ok) { accessforbidden(); } @@ -277,8 +283,6 @@ if (getDolGlobalString('MAIN_USE_EXPENSE_IK')) { $form = new Form($db); $formcompany = new FormCompany($db); -$childids = $user->getAllChildIds(1); - $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; $title = $person_name." - ".$langs->trans('BankAccounts'); $help_url = ''; From 796b8552e3a713afdb064db128ea4846eb51d120 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Jan 2025 15:23:26 +0100 Subject: [PATCH 066/243] Fix var_dump --- htdocs/user/bank.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 8f534756aa4..15117a5daec 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -114,7 +114,6 @@ if ($user->hasRight('expensereport', 'readall') || ($user->hasRight('expenserepo if ($user->hasRight('holiday', 'readall') || ($user->hasRight('holiday', 'read') && in_array($object->id, $childids))) { $ok = true; } -var_dump($ok); if (!$ok) { accessforbidden(); } From 77f982d1a8c3fa490c40c95e06d39f51731da055 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 10 Jan 2025 16:25:27 +0100 Subject: [PATCH 067/243] FIX 17.0 - collisions in cache for dol_getIdFromCode --- htdocs/core/lib/functions.lib.php | 49 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7fe94ff83c4..61bb1c78a2e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8876,12 +8876,13 @@ function dol_osencode($str) * @param string $fieldid Field to get * @param int $entityfilter Filter by entity * @param string $filters Filters to add. WARNING: string must be escaped for SQL and not coming from user input. + * @param bool $useCache If true (default), cache will be queried and updated. * @return int <0 if KO, Id of code if OK * @see $langs->getLabelFromKey */ -function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '') +function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '', $useCache = true) { - global $cache_codes; + static $cache_codes = array(); // If key empty if ($key == '') { @@ -8889,8 +8890,8 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = } // Check in cache - if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or '' - return $cache_codes[$tablename][$key][$fieldid]; // Found in cache + if ($useCache && isset($cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key])) { // Can be defined to 0 or '' + return $cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key]; // Found in cache } dol_syslog('dol_getIdFromCode (value for field '.$fieldid.' from key '.$key.' not found into cache)', LOG_DEBUG); @@ -8908,13 +8909,15 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); + $valuetoget = ''; if ($obj) { - $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; - } else { - $cache_codes[$tablename][$key][$fieldid] = ''; + $valuetoget = $obj->valuetoget; } $db->free($resql); - return $cache_codes[$tablename][$key][$fieldid]; + if ($useCache) { + $cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key] = $valuetoget; + } + return $valuetoget; } else { return -1; } @@ -10839,21 +10842,21 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * @param int|boolean $userRight User action right * // phpcs:disable * @param array $params = [ // Various params for future : recommended rather than adding more function arguments - * 'attr' => [ // to add or override button attributes - * 'xxxxx' => '', // your xxxxx attribute you want - * 'class' => 'reposition', // to add more css class to the button class attribute - * 'classOverride' => '' // to replace class attribute of the button - * ], - * 'confirm' => [ - * 'url' => 'http://', // Overide Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. - * 'title' => '', // Overide title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key - * 'action-btn-label' => '', // Overide label of action button, if empty default label use "Confirm" lang key - * 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key - * 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key - * 'modal' => true, // true|false to display dialog as a modal (with dark background) - * 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background) - * ], - * ] + * 'attr' => [ // to add or override button attributes + * 'xxxxx' => '', // your xxxxx attribute you want + * 'class' => 'reposition', // to add more css class to the button class attribute + * 'classOverride' => '' // to replace class attribute of the button + * ], + * 'confirm' => [ + * 'url' => 'http://', // Overide Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. + * 'title' => '', // Overide title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key + * 'action-btn-label' => '', // Overide label of action button, if empty default label use "Confirm" lang key + * 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key + * 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key + * 'modal' => true, // true|false to display dialog as a modal (with dark background) + * 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background) + * ], + * ] * // phpcs:enable * @return string html button */ From ef4697cba31b703933eb8ac640edd14534fe7369 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 16:54:21 +0100 Subject: [PATCH 068/243] FIX phpstan: wrong case --- htdocs/public/payment/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index fcff7afc7d6..78f321ba802 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -232,7 +232,7 @@ $urlko = $urlwithroot.'/public/payment/paymentko.php?'; if ($ws && !defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { // So defined('USEEXTERNALSERVER') should be set but is not always include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; - $tmpwebsite = new WebSite($db); + $tmpwebsite = new Website($db); $tmpwebsite->fetch(0, $ws); $urlok = $tmpwebsite->virtualhost.'/public/payment/paymentok.php?'; $urlko = $tmpwebsite->virtualhost.'/public/payment/paymentko.php?'; From ba2dab2a443bb0b1e94780aaf524d4ce1b22cec3 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 10 Jan 2025 16:56:14 +0100 Subject: [PATCH 069/243] =?UTF-8?q?NEW=20:=20auto-detect=20country=20from?= =?UTF-8?q?=20code=20in=20creation=09(follow-up=E2=81=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/adherents/class/adherent.class.php | 5 +++++ htdocs/compta/bank/class/account.class.php | 10 ++++++++++ htdocs/contact/class/contact.class.php | 5 +++++ htdocs/product/class/product.class.php | 4 ++++ htdocs/product/stock/class/entrepot.class.php | 9 +++++++++ htdocs/societe/class/societe.class.php | 10 +++++----- htdocs/user/class/user.class.php | 5 +++++ 7 files changed, 43 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0e168adddb2..78d9e15da87 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -761,6 +761,11 @@ class Adherent extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $nbrowsaffected = 0; $error = 0; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index d3d0c3c2ddf..45a30fdef82 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -760,6 +760,11 @@ class Account extends CommonObject $this->status = $this->clos; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + // Load the library to validate/check a BAN account require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -900,6 +905,11 @@ class Account extends CommonObject { global $langs, $conf; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; $this->db->begin(); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index f6acb419e47..83693e150ae 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -605,6 +605,11 @@ class Contact extends CommonObject { global $conf; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; $this->id = $id; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 0862b6b1d93..bc6f1df89f2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1423,6 +1423,10 @@ class Product extends CommonObject if (empty($this->country_id)) { $this->country_id = 0; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } if (empty($this->state_id)) { $this->state_id = 0; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 3ca48bbd39d..76ddc84ecfb 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -255,6 +255,10 @@ class Entrepot extends CommonObject $this->error = "ErrorFieldRequired"; return 0; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } $now = dol_now(); @@ -325,6 +329,11 @@ class Entrepot extends CommonObject */ public function update($id, $user, $notrigger = 0) { + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; if (empty($id)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1d7278399d1..26ec7f44992 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1010,11 +1010,6 @@ class Societe extends CommonObject $this->fk_multicurrency = 0; } - if (empty($this->country_id) && !empty($this->country_code)) { - $country_id = getCountry($this->country_code, '3'); - $this->country_id = is_int($country_id) ? $country_id : 0; - } - dol_syslog(get_class($this)."::create ".$this->name); $now = dol_now(); @@ -1441,6 +1436,11 @@ class Societe extends CommonObject $id = $this->id; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1ea16d01c17..549bbb4454d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2096,6 +2096,11 @@ class User extends CommonObject { global $conf, $langs; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $nbrowsaffected = 0; $error = 0; From 762e4ec8d1c720785a4f4adb309798acd7f12959 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 10 Jan 2025 17:01:59 +0100 Subject: [PATCH 070/243] updated local pre-commit hook -> fix typo --- htdocs/core/lib/functions.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 61bb1c78a2e..610e19b293a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10848,11 +10848,11 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * 'classOverride' => '' // to replace class attribute of the button * ], * 'confirm' => [ - * 'url' => 'http://', // Overide Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. - * 'title' => '', // Overide title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key - * 'action-btn-label' => '', // Overide label of action button, if empty default label use "Confirm" lang key - * 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key - * 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key + * 'url' => 'http://', // Override Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. + * 'title' => '', // Override title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key + * 'action-btn-label' => '', // Override label of action button, if empty default label use "Confirm" lang key + * 'cancel-btn-label' => '', // Override label of cancel button, if empty default label use "CloseDialog" lang key + * 'content' => '', // Override text of content, if empty default content use "ConfirmBtnCommonContent" lang key * 'modal' => true, // true|false to display dialog as a modal (with dark background) * 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background) * ], From 62c543ef1782c7d26ae91785ddea1e3f75c54eda Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 10 Jan 2025 23:34:45 +0100 Subject: [PATCH 071/243] FIX remove specific hook return --- htdocs/user/card.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e2992a25f46..d535cc0ddc6 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2043,9 +2043,9 @@ if ($action == 'create' || $action == 'adduserldap') { // Other form for user password $parameters = array('valuetoshow' => $valuetoshow, 'caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook === 1) { + if ($reshook > 0) { $valuetoshow = $hookmanager->resPrint; // to replace - } elseif (empty($reshook)) { + } else { $valuetoshow .= $hookmanager->resPrint; // to add } @@ -2057,11 +2057,6 @@ if ($action == 'create' || $action == 'adduserldap') { print ''."\n"; } - // for compatibility with externals modules - if ($reshook > 1) { - print $hookmanager->resPrint; - } - // API key if (isModEnabled('api') && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) { print ''.$langs->trans("ApiKey").''; From 39fe6c20b61df23e14eba9664ad886cdc5aa95c1 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 11 Jan 2025 04:55:51 +0100 Subject: [PATCH 072/243] FIX #32339 Delete a loan settlement is partial --- htdocs/loan/class/paymentloan.class.php | 41 ++++++++----------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 08346ad502b..4ba09c30bd4 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2023 Frederic France - * Copyright (C) 2020 Maxime DEMAREST +/* Copyright (C) 2014-2025 Alexandre Spangaro + * Copyright (C) 2015-2023 Frederic France + * Copyright (C) 2020 Maxime DEMAREST * * 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 @@ -102,6 +102,10 @@ class PaymentLoan extends CommonObject public $label; public $paymenttype; public $bank_account; + + /** + * @var int + */ public $bank_line; @@ -386,20 +390,17 @@ class PaymentLoan extends CommonObject */ public function delete($user, $notrigger = 0) { - global $conf, $langs; $error = 0; $this->db->begin(); - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql .= " WHERE type='payment_loan' AND url_id=".((int) $this->id); - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { + if ($this->bank_line > 0) { + $accline = new AccountLine($this->db); + $accline->fetch($this->bank_line); + $result = $accline->delete($user); + if ($result < 0) { + $this->errors[] = $accline->error; $error++; - $this->errors[] = "Error ".$this->db->lasterror(); } } @@ -430,22 +431,6 @@ class PaymentLoan extends CommonObject } } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { From eebea4ad80c698f3d9fd79820949ef781d4bc532 Mon Sep 17 00:00:00 2001 From: PsyCrow <93346975+PsyCrow-code@users.noreply.github.com> Date: Sat, 11 Jan 2025 00:22:47 -0600 Subject: [PATCH 073/243] Update modAdherent.class.php PHP Warning: Deprecated dynamic property $enabled --- htdocs/core/modules/modAdherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index fa4289e3174..0994133905a 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -414,7 +414,7 @@ class modAdherent extends DolibarrModules 'unitfrequency'=> 3600 * 24, 'priority'=>50, 'status'=>1, - 'test'=>'$conf->adherent->enabled', + 'test'=>'isModEnabled("adherent")', 'datestart'=>$datestart ), ); From e53260c00b129d5ad63c91eabf338bb48f570d7e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 11 Jan 2025 07:55:52 +0100 Subject: [PATCH 074/243] VAT - Edit look --- htdocs/admin/dict.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 360488a2410..fdd05bfcb00 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2786,12 +2786,11 @@ function dictFieldList($fieldlist, $obj = null, $tabname = '', $context = '') print ''; } elseif ($value == 'department_buyer') { if ($context == 'edit') { - print ''; + print ''; // show department buyer list $country_code = (!empty($obj->country_code) ? $obj->country_code : ''); $department_buyer_id = (!empty($obj->department_buyer_id) ? (int) $obj->department_buyer_id : 0); if ($country_code != '') { - print img_picto('', 'state', 'class="pictofixedwidth"'); print $formcompany->select_state($department_buyer_id, $country_code, 'department_buyer_id', 'minwidth100 maxwidth150 maxwidthonsmartphone'); } print ''; From 2b77879297be45bff7111c6043ef9914b5a3598d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 11 Jan 2025 10:34:01 +0100 Subject: [PATCH 075/243] FIX missing edit extrafields inline for member card --- htdocs/adherents/card.php | 21 +++++++++++++++++++++ htdocs/core/tpl/extrafields_view.tpl.php | 3 +++ 2 files changed, 24 insertions(+) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index ab5fe37bff3..53aa27fe069 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -846,6 +846,27 @@ if (empty($reshook)) { } } + if ($action == 'update_extras' && $user->hasRight('adherent', 'creer')) { + $object->oldcopy = dol_clone($object, 2); + $attribute_name = GETPOST('attribute', 'restricthtml'); + + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name); + if ($ret < 0) { + $error++; + } + if (!$error) { + $result = $object->updateExtraField($attribute_name, 'MEMBER_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + if ($error) { + $action = 'edit_extras'; + } + } + // SPIP Management if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_del_spip' && $confirm == 'yes') { if (!count($object->errors)) { diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 0c9bac901b7..10481b4ad10 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -197,6 +197,9 @@ if (empty($reshook) && !empty($object->table_element) && isset($extrafields->att if ($object->element == 'salary') { $permok = $user->hasRight('salaries', 'read'); } + if ($object->element == 'member') { + $permok = $user->hasRight('adherent', 'creer'); + } $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0)); if (($isdraft || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$tmpkeyextra])) From b0b02794ee5df988347faed59e2bc3ebfdcdb89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 11 Jan 2025 11:55:12 +0100 Subject: [PATCH 076/243] fix phpstan and phan --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 6a0e5de24da..b5ed5542749 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -245,7 +245,7 @@ function dolDecrypt($chain, $key = '') * Use 'md5' if hash is not needed for security purpose. For security need, prefer 'auto'. * @param int $nosalt Do not include any salt * @param int $mode 0=Return encoded password, 1=Return array with encoding password + encoding algorithm - * @return string|array Hash of string or array with pass_encrypted and pass_encoding + * @return string|array{pass_encrypted:string,pass_encoding:string} Hash of string or array with pass_encrypted and pass_encoding * @see getRandomPassword(), dol_verifyHash() */ function dol_hash($chain, $type = '0', $nosalt = 0, $mode = 0) From 56efa6743248743872739379e24b8adb4a650a7c Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Sun, 12 Jan 2025 03:31:01 +0200 Subject: [PATCH 077/243] Update box_graph_product_distribution.php --- htdocs/core/boxes/box_graph_product_distribution.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 8724b16b02a..f6a8b850b93 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -165,7 +165,7 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($data2)) { $showpointvalue = 0; $nocolor = 1; - $data2 = array(array(0=>$langs->trans("None"), 1=>1)); + $data2 = array(array(0=>$langs->transnoentitiesnoconv("None"), 1=>1)); } $filenamenb = $dir."/prodserforpropal-".$year.".png"; @@ -228,7 +228,7 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($data3)) { $showpointvalue = 0; $nocolor = 1; - $data3 = array(array(0=>$langs->trans("None"), 1=>1)); + $data3 = array(array(0=>$langs->transnoentitiesnoconv("None"), 1=>1)); } $filenamenb = $dir."/prodserfororder-".$year.".png"; @@ -293,7 +293,7 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($data1)) { $showpointvalue = 0; $nocolor = 1; - $data1 = array(array(0=>$langs->trans("None"), 1=>1)); + $data1 = array(array(0=>$langs->transnoentitiesnoconv("None"), 1=>1)); } $filenamenb = $dir."/prodserforinvoice-".$year.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; From 24eef4d54c38648b1df2c70051a8906a8aadba1e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 12 Jan 2025 05:34:53 +0100 Subject: [PATCH 078/243] Fix phpstan & phan --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 6a0e5de24da..c5208330d5f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -245,7 +245,7 @@ function dolDecrypt($chain, $key = '') * Use 'md5' if hash is not needed for security purpose. For security need, prefer 'auto'. * @param int $nosalt Do not include any salt * @param int $mode 0=Return encoded password, 1=Return array with encoding password + encoding algorithm - * @return string|array Hash of string or array with pass_encrypted and pass_encoding + * @return string|array{pass_encrypted:string,pass_encoding:string} Hash of string or array with pass_encrypted and pass_encoding * @see getRandomPassword(), dol_verifyHash() */ function dol_hash($chain, $type = '0', $nosalt = 0, $mode = 0) From be6869f388c1ea7029a2df6b180b6ce953a89725 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 13 Jan 2025 01:05:34 +0100 Subject: [PATCH 079/243] Fix date selector html --- htdocs/core/class/html.form.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d148f8fd784..7a7ebef6936 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7287,7 +7287,7 @@ class Form // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' $usecalendar = 'combo'; if (!empty($conf->use_javascript_ajax) && (!getDolGlobalString('MAIN_POPUP_CALENDAR') || getDolGlobalString('MAIN_POPUP_CALENDAR') != "none")) { - $usecalendar = ((!getDolGlobalString('MAIN_POPUP_CALENDAR') || getDolGlobalString('MAIN_POPUP_CALENDAR') == 'eldy') ? 'jquery' : $conf->global->MAIN_POPUP_CALENDAR); + $usecalendar = ((!getDolGlobalString('MAIN_POPUP_CALENDAR') || getDolGlobalString('MAIN_POPUP_CALENDAR') == 'eldy') ? 'jquery' : getDolGlobalString("MAIN_POPUP_CALENDAR")); } if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { // If we use a text browser or screen reader, we use the 'combo' date selector @@ -7317,7 +7317,7 @@ class Form if (!$disabled) { $retstringbuttom = ''; } else { $retstringbuttom = ''; @@ -7364,7 +7364,7 @@ class Form // Input area to enter date manually $retstring .= '
'; - $retstring .= 'trans("FormatDateShortJavaInput")) . '\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript From 0a80d437dec235b3796a2d51014846e0237dcef3 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 13 Jan 2025 12:31:08 +0100 Subject: [PATCH 080/243] Doc --- htdocs/theme/eldy/badges.inc.php | 3 +++ htdocs/theme/eldy/btn.inc.php | 3 ++- htdocs/theme/eldy/dropdown.inc.php | 4 +++- htdocs/theme/eldy/emaillayout.inc.php | 2 ++ htdocs/theme/eldy/flags-sprite.inc.php | 2 +- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/eldy/info-box.inc.php | 2 +- htdocs/theme/eldy/main_menu_fa_icons.inc.php | 2 +- htdocs/theme/eldy/manifest.json.php | 1 + htdocs/theme/eldy/progress.inc.php | 5 +++-- htdocs/theme/eldy/timeline.inc.php | 3 ++- htdocs/theme/md/badges.inc.php | 4 +++- htdocs/theme/md/btn.inc.php | 3 ++- htdocs/theme/md/dropdown.inc.php | 4 +++- htdocs/theme/md/flags-sprite.inc.php | 3 ++- htdocs/theme/md/info-box.inc.php | 3 ++- htdocs/theme/md/main_menu_fa_icons.inc.php | 3 ++- htdocs/theme/md/progress.inc.php | 3 --- htdocs/theme/md/style.css.php | 3 ++- 19 files changed, 36 insertions(+), 19 deletions(-) diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index afd7e020886..01a3f1d4824 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -28,6 +28,9 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { @phan-var-force string $colorblind_deuteranopes_badgeWarning '; ?> + +/* IDE Hack '; $out .= '