From 9051e411d074a300686868724831f150e099c2c1 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 18 Dec 2023 12:00:41 +0100 Subject: [PATCH 01/42] 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 02/42] 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 03/42] 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 04/42] 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 05/42] 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 06/42] 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 07/42] 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 08/42] 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 a4785adb3df9cf7162b21814c4e4204a67ce7ad6 Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 12 Dec 2024 15:28:19 +0100 Subject: [PATCH 09/42] 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 10/42] 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 11/42] 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 f60f34cdf8cd3c5f67afb7facd8391e389cfde09 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 2 Jan 2025 14:07:46 +0100 Subject: [PATCH 12/42] 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 13/42] 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 14/42] 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 112220da86222ba4cf9054ac53685c735cc4502d Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 3 Jan 2025 10:08:56 +0100 Subject: [PATCH 15/42] 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 16/42] 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 17/42] 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 18/42] 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 c218eaa6ed6ca5e97ddbdaa6c68a8934bede5831 Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Tue, 7 Jan 2025 12:10:40 +0100 Subject: [PATCH 19/42] 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 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 20/42] 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 21/42] 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 22/42] 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 7e82f70c77aa42718cb6009d72cb5d806ca7175e Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 9 Jan 2025 11:05:45 +0100 Subject: [PATCH 23/42] 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 77f982d1a8c3fa490c40c95e06d39f51731da055 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 10 Jan 2025 16:25:27 +0100 Subject: [PATCH 24/42] 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 762e4ec8d1c720785a4f4adb309798acd7f12959 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 10 Jan 2025 17:01:59 +0100 Subject: [PATCH 25/42] 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 ac1077bfe32712d293527f9b22dc4c8f2d934041 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 14 Jan 2025 09:48:13 +0100 Subject: [PATCH 26/42] FIX : There were many status indicator in the invoice linked object block (propal card) --- htdocs/compta/facture/tpl/linkedobjectblock.tpl.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index c002e5a7e5f..071403509dd 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -89,11 +89,8 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $totalallpayments = 0; $totalcalculated = false; if (method_exists($objectlink, 'getSommePaiement')) { - print $objectlink->getLibStatut(3, $objectlink->getSommePaiement()); $totalcalculated = true; $totalallpayments += $objectlink->getSommePaiement(); - } else { - print $objectlink->getLibStatut(3); } if (method_exists($objectlink, 'getSumDepositsUsed')) { $totalcalculated = true; From 79c55149b2ffc99b7f7178087bb305f77b736cd7 Mon Sep 17 00:00:00 2001 From: Florian Mortgat <50440633+atm-florianm@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:00:38 +0100 Subject: [PATCH 27/42] Update htdocs/core/lib/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 610e19b293a..621b0987b08 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8882,7 +8882,7 @@ function dol_osencode($str) */ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '', $useCache = true) { - static $cache_codes = array(); + global $cache_codes; // If key empty if ($key == '') { From df992477be752c137e09a3ff9b5455292972c7fd Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 14 Jan 2025 14:34:09 +0100 Subject: [PATCH 28/42] Apply suggestion by @mdeweerd to ensure pre-commit will pass. --- .../DataCollector/PDO/TraceablePDO.php | 88 +++++++++++-------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/htdocs/includes/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDO.php b/htdocs/includes/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDO.php index e448a794ad3..753964a343c 100644 --- a/htdocs/includes/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDO.php +++ b/htdocs/includes/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDO.php @@ -23,13 +23,13 @@ class TraceablePDO extends PDO $this->pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, [TraceablePDOStatement::class, [$this]]); } - /** - * Initiates a transaction - * - * @link http://php.net/manual/en/pdo.begintransaction.php - * @return bool TRUE on success or FALSE on failure. - */ - public function beginTransaction() + /** + * Initiates a transaction + * + * @link http://php.net/manual/en/pdo.begintransaction.php + * @return bool TRUE on success or FALSE on failure. + */ + public function beginTransaction() : bool { return $this->pdo->beginTransaction(); } @@ -40,7 +40,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.commit.php * @return bool TRUE on success or FALSE on failure. */ - public function commit() + public function commit() : bool { return $this->pdo->commit(); } @@ -51,6 +51,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.errorinfo.php * @return array PDO::errorInfo returns an array of error information */ + #[\ReturnTypeWillChange] public function errorCode() { return $this->pdo->errorCode(); @@ -62,7 +63,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.errorinfo.php * @return array PDO::errorInfo returns an array of error information */ - public function errorInfo() + public function errorInfo() : array { return $this->pdo->errorInfo(); } @@ -77,6 +78,7 @@ class TraceablePDO extends PDO * return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. * Please read the section on Booleans for more information */ + #[\ReturnTypeWillChange] public function exec($statement) { return $this->profileCall('exec', $statement, func_get_args()); @@ -90,6 +92,7 @@ class TraceablePDO extends PDO * @return mixed A successful call returns the value of the requested PDO attribute. * An unsuccessful call returns null. */ + #[\ReturnTypeWillChange] public function getAttribute($attribute) { return $this->pdo->getAttribute($attribute); @@ -101,7 +104,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.intransaction.php * @return bool TRUE if a transaction is currently active, and FALSE if not. */ - public function inTransaction() + public function inTransaction() : bool { return $this->pdo->inTransaction(); } @@ -114,36 +117,41 @@ class TraceablePDO extends PDO * @return string If a sequence name was not specified for the name parameter, PDO::lastInsertId * returns a string representing the row ID of the last row that was inserted into the database. */ + #[\ReturnTypeWillChange] public function lastInsertId($name = null) { return $this->pdo->lastInsertId($name); } - /** - * Prepares a statement for execution and returns a statement object - * - * @link http://php.net/manual/en/pdo.prepare.php - * @param string $statement This must be a valid SQL statement template for the target DB server. - * @param array $driver_options [optional] This array holds one or more key=>value pairs to - * set attribute values for the PDOStatement object that this method returns. - * @return TraceablePDOStatement|bool If the database server successfully prepares the statement, - * PDO::prepare returns a PDOStatement object. If the database server cannot successfully prepare - * the statement, PDO::prepare returns FALSE or emits PDOException (depending on error handling). - */ + /** + * Prepares a statement for execution and returns a statement object + * + * @link http://php.net/manual/en/pdo.prepare.php + * @param string $statement This must be a valid SQL statement template for the target DB server. + * @param array $driver_options [optional] This array holds one or more key=>value pairs to + * set attribute values for the PDOStatement object that this method returns. + * @return TraceablePDOStatement|bool If the database server successfully prepares the statement, + * PDO::prepare returns a PDOStatement object. If the database server cannot successfully prepare + * the statement, PDO::prepare returns FALSE or emits PDOException (depending on error handling). + */ + #[\ReturnTypeWillChange] public function prepare($statement, $driver_options = []) { return $this->pdo->prepare($statement, $driver_options); } - /** - * Executes an SQL statement, returning a result set as a PDOStatement object - * - * @link http://php.net/manual/en/pdo.query.php - * @param string $statement - * @return TraceablePDOStatement|bool PDO::query returns a PDOStatement object, or FALSE on - * failure. - */ - public function query($statement) + /** + * Executes an SQL statement, returning a result set as a PDOStatement object + * + * @link http://php.net/manual/en/pdo.query.php + * @param string $statement + * @param int $fetchMode + * @param mixed ...$fetchModeArgs + * @return TraceablePDOStatement|bool PDO::query returns a PDOStatement object, or FALSE on + * failure. + */ + #[\ReturnTypeWillChange] + public function query($statement, $fetchMode = null, ...$fetchModeArgs) { return $this->profileCall('query', $statement, func_get_args()); } @@ -158,6 +166,7 @@ class TraceablePDO extends PDO * @return string|bool A quoted string that is theoretically safe to pass into an SQL statement. * Returns FALSE if the driver does not support quoting in this way. */ + #[\ReturnTypeWillChange] public function quote($string, $parameter_type = PDO::PARAM_STR) { return $this->pdo->quote($string, $parameter_type); @@ -169,7 +178,7 @@ class TraceablePDO extends PDO * @link http://php.net/manual/en/pdo.rollback.php * @return bool TRUE on success or FALSE on failure. */ - public function rollBack() + public function rollBack() : bool { return $this->pdo->rollBack(); } @@ -182,7 +191,7 @@ class TraceablePDO extends PDO * @param mixed $value * @return bool TRUE on success or FALSE on failure. */ - public function setAttribute($attribute, $value) + public function setAttribute($attribute, $value) : bool { return $this->pdo->setAttribute($attribute, $value); } @@ -195,6 +204,7 @@ class TraceablePDO extends PDO * @param array $args * @return mixed The result of the call */ + #[\ReturnTypeWillChange] protected function profileCall($method, $sql, array $args) { $trace = new TracedStatement($sql); @@ -226,7 +236,7 @@ class TraceablePDO extends PDO * * @param TracedStatement $stmt */ - public function addExecutedStatement(TracedStatement $stmt) + public function addExecutedStatement(TracedStatement $stmt) : void { $this->executedStatements[] = $stmt; } @@ -234,9 +244,9 @@ class TraceablePDO extends PDO /** * Returns the accumulated execution time of statements * - * @return int + * @return float */ - public function getAccumulatedStatementsDuration() + public function getAccumulatedStatementsDuration() : float { return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getDuration(); }); } @@ -246,7 +256,7 @@ class TraceablePDO extends PDO * * @return int */ - public function getMemoryUsage() + public function getMemoryUsage() : int { return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getMemoryUsage(); }); } @@ -256,7 +266,7 @@ class TraceablePDO extends PDO * * @return int */ - public function getPeakMemoryUsage() + public function getPeakMemoryUsage() : int { return array_reduce($this->executedStatements, function ($v, $s) { $m = $s->getEndMemory(); return $m > $v ? $m : $v; }); } @@ -266,7 +276,7 @@ class TraceablePDO extends PDO * * @return TracedStatement[] */ - public function getExecutedStatements() + public function getExecutedStatements() : array { return $this->executedStatements; } @@ -276,7 +286,7 @@ class TraceablePDO extends PDO * * @return TracedStatement[] */ - public function getFailedExecutedStatements() + public function getFailedExecutedStatements() : array { return array_filter($this->executedStatements, function ($s) { return !$s->isSuccess(); }); } From 79ed9c7e370cec7000434bcc7c6fdfccc4d55d40 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 14 Jan 2025 16:08:40 +0100 Subject: [PATCH 29/42] fix: add entity in where for fetch when fetch by ref --- htdocs/expensereport/class/expensereport.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 8af62d14736..32dc9b9a25b 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -619,6 +619,7 @@ class ExpenseReport extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d"; if ($ref) { $sql .= " WHERE d.ref = '".$this->db->escape($ref)."'"; + $sql .= " WHERE d.entity IN (".getEntity('expensereport').")"; } else { $sql .= " WHERE d.rowid = ".((int) $id); } From a34eaa07ed7a7491c82ddb92246c429487ccdf85 Mon Sep 17 00:00:00 2001 From: Irvine Fleith Date: Tue, 14 Jan 2025 16:19:52 +0100 Subject: [PATCH 30/42] fix(services-list): search thirdparty by name --- htdocs/contrat/services_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 21f49ebc789..7b75c4aa9d3 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -281,7 +281,7 @@ if ($filter == "notexpired") { $sql .= " AND cd.date_fin_validite >= '".$db->idate($now)."'"; } if ($search_name) { - $sql .= natural_search("c.ref", $search_name); + $sql .= natural_search("s.nom", $search_name); } if ($search_contract) { $sql .= natural_search("c.ref", $search_contract); From 2d1d6f13c9b4fe4c0fe3fb705fd9e17a071b3f26 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 15 Jan 2025 09:10:11 +0100 Subject: [PATCH 31/42] chore: review --- htdocs/expensereport/class/expensereport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 32dc9b9a25b..0a4e590ca79 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -619,7 +619,7 @@ class ExpenseReport extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d"; if ($ref) { $sql .= " WHERE d.ref = '".$this->db->escape($ref)."'"; - $sql .= " WHERE d.entity IN (".getEntity('expensereport').")"; + $sql .= " AND d.entity IN (".getEntity('expensereport').")"; } else { $sql .= " WHERE d.rowid = ".((int) $id); } From 748dcd088136882906f855de955e1d4a882721d5 Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Wed, 15 Jan 2025 10:12:16 +0100 Subject: [PATCH 32/42] FIX selectcontact is loading all contacts if socid is empty and MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT is not set --- htdocs/comm/action/card.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 0310ac0b225..681a977adb1 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1670,7 +1670,12 @@ if ($id > 0) { // related contact print ''.$langs->trans("ActionOnContact").''; print '
'; - print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); + 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"').$form->selectcontacts(!empty($object->socid) ? $object->socid : $select_contact_default, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); print '
'; print ''; print ''; From 628189f57f6ecdd89d27d29df65ee35d5a9fd627 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 00:49:59 +0200 Subject: [PATCH 33/42] Backport of #00e65eb Fix bad management when inserting contacts of actioncomm --- htdocs/comm/action/class/actioncomm.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9b006c83ab6..9e1e471bbd3 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1203,11 +1203,14 @@ class ActionComm extends CommonObject if (!empty($this->socpeopleassigned)) { $already_inserted = array(); - foreach (array_keys($this->socpeopleassigned) as $id) { + foreach (array_keys($this->socpeopleassigned) as $key => $val) { + if (!is_array($val)) { // For backward compatibility when val=id + $val = array('id'=>$val); + } if (!empty($already_inserted[$val['id']])) continue; $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql .= " VALUES(".((int) $this->id).", 'socpeople', ".((int) $val['id']).", 0, 0, 0)"; $resql = $this->db->query($sql); if (!$resql) { From 351a7bd6bb81b07b058585e852cbce1bc386c5f2 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 15 Jan 2025 19:01:18 +0100 Subject: [PATCH 34/42] FIX: #26250 fatal error on kit --- htdocs/product/class/product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e289762d2a5..ea9c7f6b830 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5016,7 +5016,8 @@ class Product extends CommonObject //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); if (empty($firstlevelonly)) { - $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, array_push($parents, $rec['rowid'])); + array_push($parents, $rec['rowid']); + $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, $parents); foreach ($listofchilds as $keyChild => $valueChild) { $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; } From bd35af136098dc6a6881110ee07b284c4945b233 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 20:07:31 +0100 Subject: [PATCH 35/42] Fix phpunit --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d6a22f64de5..44ff8a217c9 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -36,7 +36,7 @@ */ include_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - + /** * Return array head with list of tabs to view object informations. From 8b7eaf360e58693a9365544cb1520f28ced7e626 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 20:08:13 +0100 Subject: [PATCH 36/42] Fix phpunit --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 42fee8bfa7b..163fdefb2b0 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1426,7 +1426,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, //id $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); - if($idprod) { + if ($idprod) { $prodser->fetch($idprod); //load multilangs if($multilangsactive){ From c4529ed9869b59d4f34865e79dd5ad419a45c204 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 00:35:38 +0100 Subject: [PATCH 37/42] Clean file --- 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 163fdefb2b0..c2078f2c74a 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -36,7 +36,7 @@ */ include_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - + /** * Return array head with list of tabs to view object informations. @@ -1412,8 +1412,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS'); - if ($issupplierline) { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + 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'; @@ -1429,7 +1429,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if ($idprod) { $prodser->fetch($idprod); //load multilangs - if($multilangsactive){ + if ($multilangsactive) { $prodser->getMultiLangs(); $object->lines[$i]->multilangs = $prodser->multilangs; } From c2c3879032ac2fe80e397835b2d784168b0f5d57 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 00:36:56 +0100 Subject: [PATCH 38/42] Clean php file --- htdocs/core/lib/pdf.lib.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index c2078f2c74a..7bb8e4d8a1e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1414,26 +1414,26 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, 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); + $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 (!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; - } - } + 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; From ba4e97f07bb69031deefd9f5fffbb86869bcf609 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Thu, 16 Jan 2025 10:37:29 +0100 Subject: [PATCH 39/42] FIX 17.0 API endpoints "PUT": prevent overwriting all extrafields if only some are supplied in the request cf. PR #29237 + security for Tickets API: disable updating rowid --- htdocs/adherents/class/api_members.class.php | 6 ++++++ htdocs/adherents/class/api_memberstypes.class.php | 6 ++++++ htdocs/adherents/class/api_subscriptions.class.php | 6 ++++++ htdocs/bom/class/api_boms.class.php | 6 ++++++ htdocs/categories/class/api_categories.class.php | 6 ++++++ htdocs/comm/action/class/api_agendaevents.class.php | 6 ++++++ htdocs/comm/propal/class/api_proposals.class.php | 6 ++++++ htdocs/commande/class/api_orders.class.php | 6 ++++++ htdocs/compta/bank/class/api_bankaccounts.class.php | 6 ++++++ htdocs/compta/facture/class/api_invoices.class.php | 6 ++++++ htdocs/contrat/class/api_contracts.class.php | 6 ++++++ htdocs/don/class/api_donations.class.php | 6 ++++++ htdocs/expedition/class/api_shipments.class.php | 6 ++++++ htdocs/expensereport/class/api_expensereports.class.php | 6 ++++++ htdocs/fourn/class/api_supplier_invoices.class.php | 6 ++++++ htdocs/fourn/class/api_supplier_orders.class.php | 6 ++++++ .../class/api_knowledgemanagement.class.php | 6 ++++++ .../modulebuilder/template/class/api_mymodule.class.php | 6 ++++++ htdocs/mrp/class/api_mos.class.php | 6 ++++++ htdocs/partnership/class/api_partnership.class.php | 6 ++++++ htdocs/product/class/api_products.class.php | 6 ++++++ htdocs/product/stock/class/api_warehouses.class.php | 6 ++++++ htdocs/projet/class/api_projects.class.php | 6 ++++++ htdocs/projet/class/api_tasks.class.php | 6 ++++++ htdocs/reception/class/api_receptions.class.php | 6 ++++++ htdocs/societe/class/api_contacts.class.php | 6 ++++++ htdocs/societe/class/api_thirdparties.class.php | 6 ++++++ htdocs/ticket/class/api_tickets.class.php | 9 +++++++++ htdocs/user/class/api_users.class.php | 6 ++++++ 29 files changed, 177 insertions(+) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 4ecf79d9079..a224bbdda44 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -348,6 +348,12 @@ class Members extends DolibarrApi } } } else { + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $member->array_options[$index] = $this->_checkValForAPI($field, $val, $member); + } + continue; + } $member->$field = $value; } } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 8179612d769..46443b7b063 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -193,6 +193,12 @@ class MembersTypes extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $membertype->array_options[$index] = $this->_checkValForAPI($field, $val, $membertype); + } + continue; + } // Process the status separately because it must be updated using // the validate(), resiliate() and exclude() methods of the class AdherentType. $membertype->$field = $value; diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index dfde21dc5a1..be97312280c 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -186,6 +186,12 @@ class Subscriptions extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $subscription->array_options[$index] = $this->_checkValForAPI($field, $val, $subscription); + } + continue; + } $subscription->$field = $value; } diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 57b0d26e80a..255934368a8 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -237,6 +237,12 @@ class Boms extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->bom->array_options[$index] = $this->_checkValForAPI($field, $val, $this->bom); + } + continue; + } $this->bom->$field = $value; } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 77356ba2a87..44aefd694ba 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -237,6 +237,12 @@ class Categories extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->category->array_options[$index] = $this->_checkValForAPI($field, $val, $this->category); + } + continue; + } $this->category->$field = $value; } diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 058de48542d..cfb933ed695 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -270,6 +270,12 @@ class AgendaEvents extends DolibarrApi continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->actioncomm->array_options[$index] = $this->_checkValForAPI($field, $val, $this->actioncomm); + } + continue; + } $this->actioncomm->$field = $this->_checkValForAPI($field, $value, $this->actioncomm); } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index bbdc3cab71d..14ba90aef18 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -696,6 +696,12 @@ class Proposals extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->propal->array_options[$index] = $this->_checkValForAPI($field, $val, $this->propal); + } + continue; + } $this->propal->$field = $value; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index af460b3b459..b1571052a2b 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -652,6 +652,12 @@ class Orders extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->commande->array_options[$index] = $this->_checkValForAPI($field, $val, $this->commande); + } + continue; + } $this->commande->$field = $value; } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 052c45fbc56..1da37b2c760 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -332,6 +332,12 @@ class BankAccounts extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $account->array_options[$index] = $this->_checkValForAPI($field, $val, $account); + } + continue; + } $account->$field = $this->_checkValForAPI($field, $value, $account); } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 47fd0263d7e..4dfd1f023aa 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -627,6 +627,12 @@ class Invoices extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->invoice->array_options[$index] = $this->_checkValForAPI($field, $val, $this->invoice); + } + continue; + } $this->invoice->$field = $value; } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 2becf6fcfb7..5bbdf7d1525 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -510,6 +510,12 @@ class Contracts extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->contract->array_options[$index] = $this->_checkValForAPI($field, $val, $this->contract); + } + continue; + } $this->contract->$field = $value; } diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index fee513f2ed7..472c5f8d4b2 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -231,6 +231,12 @@ class Donations extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->don->array_options[$index] = $this->_checkValForAPI($field, $val, $this->don); + } + continue; + } $this->don->$field = $value; } diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index fea57fbea10..23e1b1d0c84 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -447,6 +447,12 @@ class Shipments extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->shipment->array_options[$index] = $this->_checkValForAPI($field, $val, $this->shipment); + } + continue; + } $this->shipment->$field = $value; } diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index c3bfeb2264d..c985c5fe813 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -420,6 +420,12 @@ class ExpenseReports extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->expensereport->array_options[$index] = $this->_checkValForAPI($field, $val, $this->expensereport); + } + continue; + } $this->expensereport->$field = $value; } diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index cb7072fdca1..84568f2b13c 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -263,6 +263,12 @@ class SupplierInvoices extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->invoice->array_options[$index] = $this->_checkValForAPI($field, $val, $this->invoice); + } + continue; + } $this->invoice->$field = $value; } diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 4ad1f951883..b56c5195ee7 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -277,6 +277,12 @@ class SupplierOrders extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->order->array_options[$index] = $this->_checkValForAPI($field, $val, $this->order); + } + continue; + } $this->order->$field = $value; } diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index 6d5c15c0dc6..7d777530166 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -298,6 +298,12 @@ class KnowledgeManagement extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->knowledgerecord->array_options[$index] = $this->_checkValForAPI($field, $val, $this->knowledgerecord); + } + continue; + } $this->knowledgerecord->$field = $this->_checkValForAPI($field, $value, $this->knowledgerecord); } diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index fdb56ff3c67..19bb4f50781 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -255,6 +255,12 @@ class MyModuleApi extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->myobject->array_options[$index] = $this->_checkValForAPI($field, $val, $this->myobject); + } + continue; + } $this->myobject->$field = $this->_checkValForAPI($field, $value, $this->myobject); } diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 2312f4bd636..c524d5533d6 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -238,6 +238,12 @@ class Mos extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->mo->array_options[$index] = $this->_checkValForAPI($field, $val, $this->mo); + } + continue; + } $this->mo->$field = $value; } diff --git a/htdocs/partnership/class/api_partnership.class.php b/htdocs/partnership/class/api_partnership.class.php index 13bc447c51d..f5cb7293081 100644 --- a/htdocs/partnership/class/api_partnership.class.php +++ b/htdocs/partnership/class/api_partnership.class.php @@ -255,6 +255,12 @@ class PartnershipApi extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->partnership->array_options[$index] = $this->_checkValForAPI($field, $val, $this->partnership); + } + continue; + } $this->partnership->$field = $this->_checkValForAPI($field, $value, $this->partnership); } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index e95db77d0cc..eeb8427596a 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -361,6 +361,12 @@ class Products extends DolibarrApi if ($field == 'stock_reel') { throw new RestException(400, 'Stock reel cannot be updated here. Use the /stockmovements endpoint instead'); } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->product->array_options[$index] = $this->_checkValForAPI($field, $val, $this->product); + } + continue; + } $this->product->$field = $value; } diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index a0646598d96..f39a9fa88d8 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -206,6 +206,12 @@ class Warehouses extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->warehouse->array_options[$index] = $this->_checkValForAPI($field, $val, $this->warehouse); + } + continue; + } $this->warehouse->$field = $value; } diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index f5c23f4b040..9eed224e99a 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -462,6 +462,12 @@ class Projects extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->project->array_options[$index] = $this->_checkValForAPI($field, $val, $this->project); + } + continue; + } $this->project->$field = $value; } diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 80fede57563..bb65cfa31e5 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -460,6 +460,12 @@ class Tasks extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->task->array_options[$index] = $this->_checkValForAPI($field, $val, $this->task); + } + continue; + } $this->task->$field = $value; } diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index 55e3fa59165..70088db3455 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -447,6 +447,12 @@ class Receptions extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->reception->array_options[$index] = $this->_checkValForAPI($field, $val, $this->reception); + } + continue; + } $this->reception->$field = $value; } diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index d8839c9a122..efbc1625ea0 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -330,6 +330,12 @@ class Contacts extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->contact->array_options[$index] = $this->_checkValForAPI($field, $val, $this->contact); + } + continue; + } $this->contact->$field = $value; } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index ef54c3a2299..f35521689da 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -301,6 +301,12 @@ class Thirdparties extends DolibarrApi if ($field == 'id') { continue; } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->company->array_options[$index] = $this->_checkValForAPI($field, $val, $this->company); + } + continue; + } $this->company->$field = $value; } diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index c27d9195683..d07687ff192 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -381,6 +381,15 @@ class Tickets extends DolibarrApi } foreach ($request_data as $field => $value) { + if ($field == 'id') { + continue; + } + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->ticket->array_options[$index] = $this->_checkValForAPI($field, $val, $this->ticket); + } + continue; + } $this->ticket->$field = $value; } diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 781de4d23cd..fadcde59d53 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -406,6 +406,12 @@ class Users extends DolibarrApi throw new RestException(500, 'Error when updating status of user: '.$this->useraccount->error); } } else { + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->useraccount->array_options[$index] = $this->_checkValForAPI($field, $val, $this->useraccount); + } + continue; + } $this->useraccount->$field = $value; } } From a52a218ae42f0e8114ec44591780026855391f02 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 16 Jan 2025 19:17:47 +0100 Subject: [PATCH 40/42] Use same patch like in #26454 --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ea9c7f6b830..4860fe9c34a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5016,7 +5016,7 @@ class Product extends CommonObject //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); if (empty($firstlevelonly)) { - array_push($parents, $rec['rowid']); + $parents[] = $rec['rowid']; $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, $parents); foreach ($listofchilds as $keyChild => $valueChild) { $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; From a9ff78528a5f9dbc9c5988028126eb0870d538da Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 17 Jan 2025 11:36:41 +0100 Subject: [PATCH 41/42] FIX missing default values if $objsrc or $soc fields are empty --- htdocs/compta/facture/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4b60fdacff5..9f0301f3c06 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3179,9 +3179,9 @@ if ($action == 'create') { $expesrc->fetch_optionals(); $object->array_options = $expesrc->array_options; } else { - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); - $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : (!empty($cond_reglement_id) ? $cond_reglement_id : 0))); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : (!empty($mode_reglement_id) ? $mode_reglement_id : 0))); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : (!empty($fk_account) ? $fk_account : 0))); //$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); //$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); From 736890b244e3de3d6c397310cf339d8ced9604fe Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 20 Jan 2025 10:15:31 +0100 Subject: [PATCH 42/42] Merge --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 68d17fe99f6..cf1898daa07 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -619,7 +619,7 @@ class ActionComm extends CommonObject foreach ($this->userassigned as $key => $val) { // Common value with new behavior is to have $val = array('id'=>iduser, 'transparency'=>0|1) and $this->userassigned is an array of iduser => $val. if (!is_array($val)) { // For backward compatibility when $val='id'. - $val = array('id'=>$val); + $val = array('id' => $val); } if ($val['id'] > 0) {