From 2e22f9e75afcd264162275c24411513232eea087 Mon Sep 17 00:00:00 2001
From: Eric - CAP-REL <1468823+rycks@users.noreply.github.com>
Date: Sat, 27 Dec 2025 23:04:40 +0100
Subject: [PATCH 1/8] fix concat for a undef entry of array (#36754)
---
htdocs/core/class/timespent.class.php | 2 +-
htdocs/modulebuilder/template/class/myobject.class.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php
index 256077fa40f..711aa8e25e9 100755
--- a/htdocs/core/class/timespent.class.php
+++ b/htdocs/core/class/timespent.class.php
@@ -725,7 +725,7 @@ class TimeSpent extends CommonObject
if (isset($this->status)) {
$datas['picto'] .= ' '.$this->getLibStatut(5);
}
- $datas['ref'] .= '
'.$langs->trans('Ref').': '.$this->ref;
+ $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref;
return $datas;
}
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index b4f41e00b2f..52587f1b7d9 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -774,7 +774,7 @@ class MyObject extends CommonObject
if (isset($this->status)) {
$datas['picto'] .= ' '.$this->getLibStatut(5);
}
- $datas['ref'] .= '
'.$langs->trans('Ref').': '.$this->ref;
+ $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref;
return $datas;
}
From 70348f8c85173c2be57b6e7425b8595c86741117 Mon Sep 17 00:00:00 2001
From: atm-lucas <121817516+atm-lucasmantegari@users.noreply.github.com>
Date: Tue, 30 Dec 2025 11:09:38 +0100
Subject: [PATCH 2/8] Supplier Proposal line option (#36753)
---
htdocs/fourn/commande/card.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 29f547e5da1..74fea9a945b 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -1311,7 +1311,7 @@ if (empty($reshook)) {
$num = count($lines);
for ($i = 0; $i < $num; $i++) {
- if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0 || !in_array($lines[$i]->id, $selectedLines)) {
+ if (empty($lines[$i]->subprice) || $lines[$i]->qty < 0 || !in_array($lines[$i]->id, $selectedLines)) {
continue;
}
From bfe8f57c03293dcc92cdad630c253629505e75ef Mon Sep 17 00:00:00 2001
From: Maxime Kohlhaas
Date: Mon, 5 Jan 2026 18:44:55 +0100
Subject: [PATCH 3/8] Fix : updateline was not possible because of wrong status
test (#36802)
* Fix : updateline was not possible because of wrong status test
* Fix : better fix, remove useless test to work like on customer facrec
---
.../class/fournisseur.facture-rec.class.php | 475 +++++++++---------
1 file changed, 233 insertions(+), 242 deletions(-)
diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php
index 3927fe1ae1d..5bb7d935981 100644
--- a/htdocs/fourn/class/fournisseur.facture-rec.class.php
+++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php
@@ -899,152 +899,146 @@ class FactureFournisseurRec extends CommonInvoice
return -1;
}
- if ($this->suspended == self::STATUS_NOTSUSPENDED) {
- $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
+ $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
- // Clean vat code
- $reg = array();
- $vat_src_code = '';
- if (preg_match('/\((.*)\)/', $txtva, $reg)) {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
+ // Clean vat code
+ $reg = array();
+ $vat_src_code = '';
+ if (preg_match('/\((.*)\)/', $txtva, $reg)) {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
- // Clean parameters
- $fk_product = empty($fk_product) ? 0 : $fk_product;
- $label = empty($label) ? '' : $label;
- $remise_percent = empty($remise_percent) ? 0 : price2num($remise_percent);
- $qty = price2num($qty);
- $pu_ht = price2num($pu_ht);
- $pu_ttc = price2num($pu_ttc);
- if (!preg_match('/\((.*)\)/', $txtva)) {
- $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
- }
- $txlocaltax1 = price2num($txlocaltax1);
- $txlocaltax2 = price2num($txlocaltax2);
- $txtva = !empty($txtva) ? $txtva : 0;
- $txlocaltax1 = !empty($txlocaltax1) ? $txlocaltax1 : 0;
- $txlocaltax2 = !empty($txlocaltax2) ? $txlocaltax2 : 0;
- $info_bits = !empty($info_bits) ? $info_bits : 0;
- $info_bits = !empty($info_bits) ? $info_bits : 0;
- $pu = $price_base_type == 'HT' ? $pu_ht : $pu_ttc;
+ // Clean parameters
+ $fk_product = empty($fk_product) ? 0 : $fk_product;
+ $label = empty($label) ? '' : $label;
+ $remise_percent = empty($remise_percent) ? 0 : price2num($remise_percent);
+ $qty = price2num($qty);
+ $pu_ht = price2num($pu_ht);
+ $pu_ttc = price2num($pu_ttc);
+ if (!preg_match('/\((.*)\)/', $txtva)) {
+ $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
+ }
+ $txlocaltax1 = price2num($txlocaltax1);
+ $txlocaltax2 = price2num($txlocaltax2);
+ $txtva = !empty($txtva) ? $txtva : 0;
+ $txlocaltax1 = !empty($txlocaltax1) ? $txlocaltax1 : 0;
+ $txlocaltax2 = !empty($txlocaltax2) ? $txlocaltax2 : 0;
+ $info_bits = !empty($info_bits) ? $info_bits : 0;
+ $info_bits = !empty($info_bits) ? $info_bits : 0;
+ $pu = $price_base_type == 'HT' ? $pu_ht : $pu_ttc;
- // Calcul du total TTC et de la TVA pour la ligne a partir de qty, pu, remise_percent et txtva
- // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
- // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ // Calcul du total TTC et de la TVA pour la ligne a partir de qty, pu, remise_percent et txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
- $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
- $total_ht = $tabprice[0];
- $total_tva = $tabprice[1];
- $total_ttc = $tabprice[2];
- $total_localtax1 = $tabprice[9];
- $total_localtax2 = $tabprice[10];
- $pu_ht = $tabprice[3];
+ $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
+ $pu_ht = $tabprice[3];
- // MultiCurrency
- $multicurrency_total_ht = $tabprice[16];
- $multicurrency_total_tva = $tabprice[17];
- $multicurrency_total_ttc = $tabprice[18];
- $pu_ht_devise = $tabprice[19];
-
- $this->db->begin();
- $product_type = $type;
- if ($fk_product) {
- $product = new Product($this->db);
- $result = $product->fetch($fk_product);
- if ($result < 0) {
- return -1;
- }
- $product_type = $product->type;
- if (empty($label)) {
- $label = $product->label;
- }
- }
-
- $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec (';
- $sql .= 'fk_facture_fourn';
- $sql .= ', fk_product';
- $sql .= ', ref';
- $sql .= ', label';
- $sql .= ', description';
- $sql .= ', pu_ht';
- $sql .= ', pu_ttc';
- $sql .= ', qty';
- $sql .= ', remise_percent';
- $sql .= ', fk_remise_except';
- $sql .= ', vat_src_code';
- $sql .= ', tva_tx';
- $sql .= ', localtax1_tx';
- $sql .= ', localtax1_type';
- $sql .= ', localtax2_tx';
- $sql .= ', localtax2_type';
- $sql .= ', total_ht';
- $sql .= ', total_tva';
- $sql .= ', total_localtax1';
- $sql .= ', total_localtax2';
- $sql .= ', total_ttc';
- $sql .= ', product_type';
- $sql .= ', date_start';
- $sql .= ', date_end';
- $sql .= ', info_bits';
- $sql .= ', special_code';
- $sql .= ', rang';
- $sql .= ', fk_unit';
- $sql .= ', fk_user_author';
- $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
- $sql .= ') VALUES (';
- $sql .= ' ' . (int) $facid; // source supplier invoice id
- $sql .= ', ' . (!empty($fk_product) ? "'" . $this->db->escape($fk_product) . "'" : 'null');
- $sql .= ', ' . (!empty($ref) ? "'" . $this->db->escape($ref) . "'" : 'null');
- $sql .= ', ' . (!empty($label) ? "'" . $this->db->escape($label) . "'" : 'null');
- $sql .= ", '" . $this->db->escape($desc) . "'";
- $sql .= ', ' . price2num($pu_ht);
- $sql .= ', ' . price2num($pu_ttc);
- $sql .= ', ' . price2num($qty);
- $sql .= ', ' . price2num($remise_percent);
- $sql .= ', null';
- $sql .= ", '" . $this->db->escape($vat_src_code) . "'";
- $sql .= ', ' . price2num($txtva);
- $sql .= ', ' . price2num($txlocaltax1);
- $sql .= ", '" . $this->db->escape(isset($localtaxes_type[0]) ? $localtaxes_type[0] : '') . "'";
- $sql .= ', ' . price2num($txlocaltax2);
- $sql .= ", '" . $this->db->escape(isset($localtaxes_type[2]) ? $localtaxes_type[2] : '') . "'";
- $sql .= ', ' . price2num($total_ht);
- $sql .= ', ' . price2num($total_tva);
- $sql .= ', ' . price2num($total_localtax1);
- $sql .= ', ' . price2num($total_localtax2);
- $sql .= ', ' . price2num($total_ttc);
- $sql .= ', ' . (int) $product_type;
- $sql .= ', ' . ($date_start > 0 ? (int) $date_start : 'NULL');
- $sql .= ', ' . ($date_end > 0 ? (int) $date_end : 'NULL');
- $sql .= ', ' . (int) $info_bits;
- $sql .= ', ' . (int) $special_code;
- $sql .= ', ' . (int) $rang;
- $sql .= ', ' . ($fk_unit ? (int) $fk_unit : 'NULL');
- $sql .= ', ' . (int) $user->id;
- $sql .= ', ' . (int) $this->fk_multicurrency;
- $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'";
- $sql .= ', ' . price2num($pu_ht_devise, 'CU');
- $sql .= ', ' . price2num($multicurrency_total_ht, 'CT');
- $sql .= ', ' . price2num($multicurrency_total_tva, 'CT');
- $sql .= ', ' . price2num($multicurrency_total_ttc, 'CT');
- $sql .= ')';
-
- dol_syslog(get_class($this). '::addline', LOG_DEBUG);
- if ($this->db->query($sql)) {
- $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX. 'facture_fourn_det_rec');
- $this->update_price();
- $this->id = $facid;
- $this->db->commit();
- return $lineId;
- } else {
- $this->db->rollback();
- $this->error = $this->db->lasterror();
+ // MultiCurrency
+ $multicurrency_total_ht = $tabprice[16];
+ $multicurrency_total_tva = $tabprice[17];
+ $multicurrency_total_ttc = $tabprice[18];
+ $pu_ht_devise = $tabprice[19];
+ $this->db->begin();
+ $product_type = $type;
+ if ($fk_product) {
+ $product = new Product($this->db);
+ $result = $product->fetch($fk_product);
+ if ($result < 0) {
return -1;
}
+ $product_type = $product->type;
+ if (empty($label)) {
+ $label = $product->label;
+ }
+ }
+
+ $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec (';
+ $sql .= 'fk_facture_fourn';
+ $sql .= ', fk_product';
+ $sql .= ', ref';
+ $sql .= ', label';
+ $sql .= ', description';
+ $sql .= ', pu_ht';
+ $sql .= ', pu_ttc';
+ $sql .= ', qty';
+ $sql .= ', remise_percent';
+ $sql .= ', fk_remise_except';
+ $sql .= ', vat_src_code';
+ $sql .= ', tva_tx';
+ $sql .= ', localtax1_tx';
+ $sql .= ', localtax1_type';
+ $sql .= ', localtax2_tx';
+ $sql .= ', localtax2_type';
+ $sql .= ', total_ht';
+ $sql .= ', total_tva';
+ $sql .= ', total_localtax1';
+ $sql .= ', total_localtax2';
+ $sql .= ', total_ttc';
+ $sql .= ', product_type';
+ $sql .= ', date_start';
+ $sql .= ', date_end';
+ $sql .= ', info_bits';
+ $sql .= ', special_code';
+ $sql .= ', rang';
+ $sql .= ', fk_unit';
+ $sql .= ', fk_user_author';
+ $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
+ $sql .= ') VALUES (';
+ $sql .= ' ' . (int) $facid; // source supplier invoice id
+ $sql .= ', ' . (!empty($fk_product) ? "'" . $this->db->escape($fk_product) . "'" : 'null');
+ $sql .= ', ' . (!empty($ref) ? "'" . $this->db->escape($ref) . "'" : 'null');
+ $sql .= ', ' . (!empty($label) ? "'" . $this->db->escape($label) . "'" : 'null');
+ $sql .= ", '" . $this->db->escape($desc) . "'";
+ $sql .= ', ' . price2num($pu_ht);
+ $sql .= ', ' . price2num($pu_ttc);
+ $sql .= ', ' . price2num($qty);
+ $sql .= ', ' . price2num($remise_percent);
+ $sql .= ', null';
+ $sql .= ", '" . $this->db->escape($vat_src_code) . "'";
+ $sql .= ', ' . price2num($txtva);
+ $sql .= ', ' . price2num($txlocaltax1);
+ $sql .= ", '" . $this->db->escape(isset($localtaxes_type[0]) ? $localtaxes_type[0] : '') . "'";
+ $sql .= ', ' . price2num($txlocaltax2);
+ $sql .= ", '" . $this->db->escape(isset($localtaxes_type[2]) ? $localtaxes_type[2] : '') . "'";
+ $sql .= ', ' . price2num($total_ht);
+ $sql .= ', ' . price2num($total_tva);
+ $sql .= ', ' . price2num($total_localtax1);
+ $sql .= ', ' . price2num($total_localtax2);
+ $sql .= ', ' . price2num($total_ttc);
+ $sql .= ', ' . (int) $product_type;
+ $sql .= ', ' . ($date_start > 0 ? (int) $date_start : 'NULL');
+ $sql .= ', ' . ($date_end > 0 ? (int) $date_end : 'NULL');
+ $sql .= ', ' . (int) $info_bits;
+ $sql .= ', ' . (int) $special_code;
+ $sql .= ', ' . (int) $rang;
+ $sql .= ', ' . ($fk_unit ? (int) $fk_unit : 'NULL');
+ $sql .= ', ' . (int) $user->id;
+ $sql .= ', ' . (int) $this->fk_multicurrency;
+ $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'";
+ $sql .= ', ' . price2num($pu_ht_devise, 'CU');
+ $sql .= ', ' . price2num($multicurrency_total_ht, 'CT');
+ $sql .= ', ' . price2num($multicurrency_total_tva, 'CT');
+ $sql .= ', ' . price2num($multicurrency_total_ttc, 'CT');
+ $sql .= ')';
+
+ dol_syslog(get_class($this). '::addline', LOG_DEBUG);
+ if ($this->db->query($sql)) {
+ $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX. 'facture_fourn_det_rec');
+ $this->update_price();
+ $this->id = $facid;
+ $this->db->commit();
+ return $lineId;
} else {
- $this->error = 'Recurring Invoice is suspended. adding lines not allowed.';
+ $this->db->rollback();
+ $this->error = $this->db->lasterror();
return -1;
}
@@ -1091,113 +1085,110 @@ class FactureFournisseurRec extends CommonInvoice
return -1;
}
- if ($this->status == self::STATUS_SUSPENDED) {
- // Clean parameters
- $fk_product = empty($fk_product) ? 0 : $fk_product;
- $label = empty($label) ? '' : $label;
- $remise_percent = empty($remise_percent) ? 0 : price2num($remise_percent);
- $qty = price2num($qty);
- $info_bits = empty($info_bits) ? 0 : $info_bits;
- $pu_ht = price2num($pu_ht);
- $pu_ttc = price2num($pu_ttc);
- $pu_ht_devise = price2num($pu_ht_devise);
+ // Clean parameters
+ $fk_product = empty($fk_product) ? 0 : $fk_product;
+ $label = empty($label) ? '' : $label;
+ $remise_percent = empty($remise_percent) ? 0 : price2num($remise_percent);
+ $qty = price2num($qty);
+ $info_bits = empty($info_bits) ? 0 : $info_bits;
+ $pu_ht = price2num($pu_ht);
+ $pu_ttc = price2num($pu_ttc);
+ $pu_ht_devise = price2num($pu_ht_devise);
- if (!preg_match('/\((.*)\)/', $txtva)) {
- $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
- }
-
- $txlocaltax1 = empty($txlocaltax1) ? 0 : price2num($txlocaltax1);
- $txlocaltax2 = empty($txlocaltax2) ? 0 : price2num($txlocaltax2);
- $this->multicurrency_total_ht = empty($this->multicurrency_total_ht) ? 0 : $this->multicurrency_total_ht;
- $this->multicurrency_total_tva = empty($this->multicurrency_total_tva) ? 0 : $this->multicurrency_total_tva;
- $this->multicurrency_total_ttc = empty($this->multicurrency_total_ttc) ? 0 : $this->multicurrency_total_ttc;
-
- $pu = $price_base_type == 'HT' ? $pu_ht : $pu_ttc;
-
-
- // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva
- // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
- // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
-
- $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
-
- // Clean vat code
- $vat_src_code = '';
- $reg = array();
- if (preg_match('/\((.*)\)/', $txtva, $reg)) {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
-
- $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
-
- $total_ht = $tabprice[0];
- $total_tva = $tabprice[1];
- $total_ttc = $tabprice[2];
- $total_localtax1 = $tabprice[9];
- $total_localtax2 = $tabprice[10];
- $pu_ht = $tabprice[3];
- $pu_tva = $tabprice[4];
- $pu_ttc = $tabprice[5];
-
- // MultiCurrency
- $multicurrency_total_ht = $tabprice[16];
- $multicurrency_total_tva = $tabprice[17];
- $multicurrency_total_ttc = $tabprice[18];
- $pu_ht_devise = $tabprice[19];
-
- $product_type = $type;
- if ($fk_product) {
- $product = new Product($this->db);
- $result = $product->fetch($fk_product);
- $product_type = $product->type;
- }
-
- $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec SET';
- $sql .= ' fk_facture_fourn = ' . ((int) $facid);
- $sql .= ', fk_product = ' . ($fk_product > 0 ? ((int) $fk_product) : 'null');
- $sql .= ", ref = '" . $this->db->escape($ref) . "'";
- $sql .= ", label = '" . $this->db->escape($label) . "'";
- $sql .= ", description = '" . $this->db->escape($desc) . "'";
- $sql .= ', pu_ht = ' . price2num($pu_ht);
- $sql .= ', qty = ' . price2num($qty);
- $sql .= ", remise_percent = '" . price2num($remise_percent) . "'";
- $sql .= ", vat_src_code = '" . $this->db->escape($vat_src_code) . "'";
- $sql .= ', tva_tx = ' . price2num($txtva);
- $sql .= ', localtax1_tx = ' . (float) $txlocaltax1;
- $sql .= ", localtax1_type = '" . $this->db->escape($localtaxes_type[0]) . "'";
- $sql .= ', localtax2_tx = ' . (float) $txlocaltax2;
- $sql .= ", localtax2_type = '" . $this->db->escape($localtaxes_type[2]) . "'";
- $sql .= ", total_ht = '" . price2num($total_ht) . "'";
- $sql .= ", total_tva = '" . price2num($total_tva) . "'";
- $sql .= ", total_localtax1 = '" . price2num($total_localtax1) . "'";
- $sql .= ", total_localtax2 = '" . price2num($total_localtax2) . "'";
- $sql .= ", total_ttc = '" . price2num($total_ttc) . "'";
- $sql .= ', product_type = ' . (int) $product_type;
- $sql .= ', date_start = ' . (empty($date_start) ? 'NULL' : (int) $date_start);
- $sql .= ', date_end = ' . (empty($date_end) ? 'NULL' : (int) $date_end);
- $sql .= ', info_bits = ' . (int) $info_bits;
- $sql .= ', special_code = ' . (int) $special_code;
- $sql .= ', rang = ' . (int) $rang;
- $sql .= ', fk_unit = ' . ($fk_unit ? "'" . $this->db->escape($fk_unit) . "'" : 'null');
- $sql .= ', fk_user_modif = ' . (int) $user;
- $sql .= ', multicurrency_subprice = '.price2num($pu_ht_devise);
- $sql .= ', multicurrency_total_ht = '.price2num($multicurrency_total_ht);
- $sql .= ', multicurrency_total_tva = '.price2num($multicurrency_total_tva);
- $sql .= ', multicurrency_total_ttc = '.price2num($multicurrency_total_ttc);
- $sql .= ' WHERE rowid = ' . (int) $rowid;
-
- dol_syslog(get_class($this). '::updateline', LOG_DEBUG);
- if ($this->db->query($sql)) {
- $this->id = $facid;
- $this->update_price();
- return 1;
- } else {
- $this->error = $this->db->lasterror();
- return -1;
- }
+ if (!preg_match('/\((.*)\)/', $txtva)) {
+ $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
+ }
+
+ $txlocaltax1 = empty($txlocaltax1) ? 0 : price2num($txlocaltax1);
+ $txlocaltax2 = empty($txlocaltax2) ? 0 : price2num($txlocaltax2);
+ $this->multicurrency_total_ht = empty($this->multicurrency_total_ht) ? 0 : $this->multicurrency_total_ht;
+ $this->multicurrency_total_tva = empty($this->multicurrency_total_tva) ? 0 : $this->multicurrency_total_tva;
+ $this->multicurrency_total_ttc = empty($this->multicurrency_total_ttc) ? 0 : $this->multicurrency_total_ttc;
+
+ $pu = $price_base_type == 'HT' ? $pu_ht : $pu_ttc;
+
+
+ // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+
+ $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
+
+ // Clean vat code
+ $vat_src_code = '';
+ $reg = array();
+ if (preg_match('/\((.*)\)/', $txtva, $reg)) {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
+
+ $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
+
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
+ $pu_ht = $tabprice[3];
+ $pu_tva = $tabprice[4];
+ $pu_ttc = $tabprice[5];
+
+ // MultiCurrency
+ $multicurrency_total_ht = $tabprice[16];
+ $multicurrency_total_tva = $tabprice[17];
+ $multicurrency_total_ttc = $tabprice[18];
+ $pu_ht_devise = $tabprice[19];
+
+ $product_type = $type;
+ if ($fk_product) {
+ $product = new Product($this->db);
+ $result = $product->fetch($fk_product);
+ $product_type = $product->type;
+ }
+
+ $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec SET';
+ $sql .= ' fk_facture_fourn = ' . ((int) $facid);
+ $sql .= ', fk_product = ' . ($fk_product > 0 ? ((int) $fk_product) : 'null');
+ $sql .= ", ref = '" . $this->db->escape($ref) . "'";
+ $sql .= ", label = '" . $this->db->escape($label) . "'";
+ $sql .= ", description = '" . $this->db->escape($desc) . "'";
+ $sql .= ', pu_ht = ' . price2num($pu_ht);
+ $sql .= ', qty = ' . price2num($qty);
+ $sql .= ", remise_percent = '" . price2num($remise_percent) . "'";
+ $sql .= ", vat_src_code = '" . $this->db->escape($vat_src_code) . "'";
+ $sql .= ', tva_tx = ' . price2num($txtva);
+ $sql .= ', localtax1_tx = ' . (float) $txlocaltax1;
+ $sql .= ", localtax1_type = '" . $this->db->escape($localtaxes_type[0]) . "'";
+ $sql .= ', localtax2_tx = ' . (float) $txlocaltax2;
+ $sql .= ", localtax2_type = '" . $this->db->escape($localtaxes_type[2]) . "'";
+ $sql .= ", total_ht = '" . price2num($total_ht) . "'";
+ $sql .= ", total_tva = '" . price2num($total_tva) . "'";
+ $sql .= ", total_localtax1 = '" . price2num($total_localtax1) . "'";
+ $sql .= ", total_localtax2 = '" . price2num($total_localtax2) . "'";
+ $sql .= ", total_ttc = '" . price2num($total_ttc) . "'";
+ $sql .= ', product_type = ' . (int) $product_type;
+ $sql .= ', date_start = ' . (empty($date_start) ? 'NULL' : (int) $date_start);
+ $sql .= ', date_end = ' . (empty($date_end) ? 'NULL' : (int) $date_end);
+ $sql .= ', info_bits = ' . (int) $info_bits;
+ $sql .= ', special_code = ' . (int) $special_code;
+ $sql .= ', rang = ' . (int) $rang;
+ $sql .= ', fk_unit = ' . ($fk_unit ? "'" . $this->db->escape($fk_unit) . "'" : 'null');
+ $sql .= ', fk_user_modif = ' . (int) $user;
+ $sql .= ', multicurrency_subprice = '.price2num($pu_ht_devise);
+ $sql .= ', multicurrency_total_ht = '.price2num($multicurrency_total_ht);
+ $sql .= ', multicurrency_total_tva = '.price2num($multicurrency_total_tva);
+ $sql .= ', multicurrency_total_ttc = '.price2num($multicurrency_total_ttc);
+ $sql .= ' WHERE rowid = ' . (int) $rowid;
+
+ dol_syslog(get_class($this). '::updateline', LOG_DEBUG);
+ if ($this->db->query($sql)) {
+ $this->id = $facid;
+ $this->update_price();
+ return 1;
+ } else {
+ $this->error = $this->db->lasterror();
+ return -1;
}
- return 0;
}
From 2dbc4c5e01eeb2321788133f8cc250a41753bb2f Mon Sep 17 00:00:00 2001
From: HENRY Florian
Date: Wed, 7 Jan 2026 11:08:40 +0100
Subject: [PATCH 4/8] fix: if holiday type have bock if negative, it is ignored
when balance is 0 (#36817)
* fix: backport of holiday approval if block_if_negative
* fix: backport of holiday approval if block_if_negative
---
htdocs/holiday/card.php | 6 +++---
htdocs/holiday/class/holiday.class.php | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php
index 7bd30263504..fab3b802ae7 100644
--- a/htdocs/holiday/card.php
+++ b/htdocs/holiday/card.php
@@ -687,13 +687,13 @@ if (empty($reshook)) {
if (!$error) {
$db->commit();
-
- header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
- exit;
} else {
$db->rollback();
$action = '';
}
+
+ header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
+ exit;
}
}
diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php
index 1102ed53dc7..8d817661d9b 100644
--- a/htdocs/holiday/class/holiday.class.php
+++ b/htdocs/holiday/class/holiday.class.php
@@ -882,8 +882,9 @@ class Holiday extends CommonObject
if ($checkBalance > 0) {
$balance = $this->getCPforUser($this->fk_user, $this->fk_type);
+ $daysAsked = num_open_day($this->date_debut, $this->date_fin, 0, 1);
- if ($balance < 0) {
+ if (($balance - $daysAsked) < 0) {
$this->error = 'LeaveRequestCreationBlockedBecauseBalanceIsNegative';
return -1;
}
From 4d26c3c553d679d2c55f792cf880d2f871a2aaf5 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Wed, 7 Jan 2026 11:42:51 +0100
Subject: [PATCH 5/8] Fix pb with a bad file
---
htdocs/install/upgrade2.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 5019f8ddf4c..a851f071aab 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -4217,6 +4217,7 @@ function migrate_delete_old_files($db, $langs, $conf)
'/core/modules/modCommercial.class.php',
'/core/modules/modProduit.class.php',
'/core/modules/modSkype.class.php',
+ '/core/modules/modactivite.class.php', // A file from external module that should not be here
'/core/triggers/interface_modWebcalendar_Webcalsynchro.class.php',
'/core/triggers/interface_modCommande_Ecotax.class.php',
'/core/triggers/interface_modCommande_fraisport.class.php',
From 103d350fb89c3723395ac11d95c380f6223444b0 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Wed, 7 Jan 2026 15:10:47 +0100
Subject: [PATCH 6/8] Merge branch '22.0' of
git@github.com:Dolibarr/dolibarr.git into 22.0
---
htdocs/admin/system/security.php | 4 ++++
htdocs/api/index.php | 4 ++++
htdocs/core/class/conf.class.php | 5 +++++
3 files changed, 13 insertions(+)
diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php
index 827aaf07d8d..46227c62ddc 100644
--- a/htdocs/admin/system/security.php
+++ b/htdocs/admin/system/security.php
@@ -937,6 +937,10 @@ print '
';
print 'MAIN_DISALLOW_STRING_OBFUSCATION_IN_DOL_EVAL = '.(getDolGlobalString('MAIN_DISALLOW_STRING_OBFUSCATION_IN_DOL_EVAL') ? '1' : ''.$langs->trans("Undefined").'');
print ' ('.$langs->trans("Recommended").": 1 - may break use of concatenation function like . or dol_concatdesc into extra fields conditions or formula)
";
+
+print 'MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = '.getDolGlobalString('MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER', ''.$langs->trans("Undefined").'');
+print ' ('.$langs->trans("Recommended").": 1 - The value 0 allows the use of subrequests into extrafields conditions. It remains not possible in API filters to avoid bind SQL injections whatever is this value)
";
+
print '
';
diff --git a/htdocs/api/index.php b/htdocs/api/index.php
index 3f0edace5c2..85a8c771925 100644
--- a/htdocs/api/index.php
+++ b/htdocs/api/index.php
@@ -116,6 +116,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
*/
+// In API context, we force the protection to avoid forging of criteria including bind SQL injection
+$conf->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = 1;
+
+
$url = $_SERVER['PHP_SELF'];
if (preg_match('/api\/index\.php$/', $url)) { // sometimes $_SERVER['PHP_SELF'] is 'api\/index\.php' instead of 'api\/index\.php/explorer.php' or 'api\/index\.php/method'
$url = $_SERVER['PHP_SELF'].(empty($_SERVER['PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']);
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index da8874ec011..41f7bc17947 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -1344,6 +1344,11 @@ class Conf extends stdClass
$this->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
}
+ if (!isset($this->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER)) {
+ // Note value is always forced to 1 in API context to avoid bind SQL injection into API filters.
+ $this->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = 0; // TODO Move this into 1 by default
+ }
+
// For backward compatibility
if (!empty($this->global->LDAP_SYNCHRO_ACTIVE)) {
if ($this->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
From 224aab4265a679d3e875fd48e67f2f5bb16957e6 Mon Sep 17 00:00:00 2001
From: atm-corentin <165782689+atm-corentin@users.noreply.github.com>
Date: Wed, 7 Jan 2026 18:28:58 +0100
Subject: [PATCH 7/8] FIX - Add validation for manufacturing order date
changes (#36823)
* Add validation for manufacturing order date changes and update translations
* Fix indentation in manufacturing order date handling logic
---
htdocs/langs/en_US/mrp.lang | 4 ++-
htdocs/langs/fr_FR/mrp.lang | 6 +++--
htdocs/mrp/mo_list.php | 49 ++++++++++++++++++++-----------------
3 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang
index f68fd0a912f..9d07db64a01 100644
--- a/htdocs/langs/en_US/mrp.lang
+++ b/htdocs/langs/en_US/mrp.lang
@@ -165,8 +165,10 @@ ModifyDateEnd = New planned end date
ModifyMoDate = Date modification validated for %s
ErrorEmptyChangeDate = Please define a date
ConfirmMassChangeDateEnd = Confirmation of mass modification of the planned end date
-ErrorModifyMoDateStart = You must choose a start date earlier than the current start date. %s
+ErrorModifyMoDateStart = You must choose a start date earlier than the current end date. %s
ErrorModifyMoDateEnd = You must choose an end date later than the start date. %s
ErrorCancelMo=Error updating cancellation
ErrorModifyMoDate=Error updating date modification
+ErrorObjectMustNotBeFinishedToModifyDateEnd = Object %s must not be finished to modify the end date.
+ErrorObjectMustNotBeFinishedToModifyDateStart = Object %s must not be finished to modify the start date.
UseSearchToSelectBom=Wait until a key is pressed before loading content of Boms combo list.
This may improve performance if you have a large number of projects, but it is less convenient.
diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang
index 79599a5504d..eb0ce7645a2 100644
--- a/htdocs/langs/fr_FR/mrp.lang
+++ b/htdocs/langs/fr_FR/mrp.lang
@@ -165,8 +165,10 @@ ModifyDateEnd = Nouvelle date de fin prévue
ModifyMoDate = Modification de la date validée pour %s
ErrorEmptyChangeDate = Veuillez définir une date
ConfirmMassChangeDateEnd = Confirmation de la modification massive de la date de fin prévue
-ErrorModifyMoDateStart = Vous devez choisir une date de début antérieure à la date de début actuelle. %s
+ErrorModifyMoDateStart = Vous devez choisir une date de début antérieure à la date de fin actuelle. %s
ErrorModifyMoDateEnd = Vous devez choisir une date de fin postérieure à la date de début. %s
ErrorCancelMo=Erreur lors de la mise à jour de l'annulation
ErrorModifyMoDate=Erreur lors de la mise à jour de la modification de la date
-UseSearchToSelectBom=Attendre que vous ayez appuyé sur une touche avant de charger le contenu de la liste déroulante des nomenclatures (Cela peut augmenter les performances si vous avez un grand nombre de nomenclatures, mais cela est moins convivial)
\ No newline at end of file
+ErrorObjectMustNotBeFinishedToModifyDateEnd = L'objet %s ne doit pas être fabriqué pour modifier la date de fin.
+ErrorObjectMustNotBeFinishedToModifyDateStart = L'objet %s ne doit pas être fabriqué pour modifier la date de début.
+UseSearchToSelectBom=Attendre que vous ayez appuyé sur une touche avant de charger le contenu de la liste déroulante des nomenclatures (Cela peut augmenter les performances si vous avez un grand nombre de nomenclatures, mais cela est moins convivial)
diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php
index a739892f109..c871940c220 100644
--- a/htdocs/mrp/mo_list.php
+++ b/htdocs/mrp/mo_list.php
@@ -253,34 +253,37 @@ if (empty($reshook)) {
if (!empty($toselect)) {
foreach ($toselect as $key => $idMo) {
if ($objMo->fetch($idMo)) {
- if ($objMo->status == Mo::STATUS_DRAFT) {
- if (!empty($changeDate)) {
- if ($action == 'changedatestart_confirm') { // Test on permission not required
- if ($newDate < $objMo->date_end_planned) {
- $objMo->date_start_planned = $newDate;
- } else {
- setEventMessages($langs->trans('ErrorModifyMoDateStart', $objMo->ref), null, 'errors');
- break;
- }
- } elseif ($action == 'changedateend_confirm') { // Test on permission not required
- if ($newDate > $objMo->date_start_planned) {
- $objMo->date_end_planned = $newDate;
- } else {
- setEventMessages($langs->trans('ErrorModifyMoDateEnd', $objMo->ref), null, 'errors');
- break;
- }
- }
- if ($objMo->update($user)) {
- setEventMessages($langs->trans('ModifyMoDate', $objMo->ref), null, 'mesgs');
+ if (in_array($action, array('changedatestart_confirm', 'changedateend_confirm'), true) && $objMo->status == Mo::STATUS_PRODUCED) {
+ $errorKey = $action == 'changedatestart_confirm'
+ ? 'ErrorObjectMustNotBeFinishedToModifyDateStart'
+ : 'ErrorObjectMustNotBeFinishedToModifyDateEnd';
+ setEventMessages($langs->trans($errorKey, $objMo->ref), null, 'errors');
+ continue;
+ }
+ if (!empty($changeDate)) {
+ if ($action == 'changedatestart_confirm') { // Test on permission not required
+ if (empty($objMo->date_end_planned) || $newDate < $objMo->date_end_planned) {
+ $objMo->date_start_planned = $newDate;
} else {
- setEventMessages($langs->trans('ErrorModifyMoDate', $objMo->ref), null, 'errors');
+ setEventMessages($langs->trans('ErrorModifyMoDateStart', $objMo->ref), null, 'errors');
+ break;
}
+ } elseif ($action == 'changedateend_confirm') { // Test on permission not required
+ if ($newDate > $objMo->date_start_planned) {
+ $objMo->date_end_planned = $newDate;
+ } else {
+ setEventMessages($langs->trans('ErrorModifyMoDateEnd', $objMo->ref), null, 'errors');
+ break;
+ }
+ }
+ if ($objMo->update($user)) {
+ setEventMessages($langs->trans('ModifyMoDate', $objMo->ref), null, 'mesgs');
} else {
- setEventMessages($langs->trans('ErrorEmptyChangeDate'), null, 'errors');
- break;
+ setEventMessages($langs->trans('ErrorModifyMoDate', $objMo->ref), null, 'errors');
}
} else {
- setEventMessages($langs->trans('ErrorObjectMustHaveStatusDraftToModifyDate', $objMo->ref), null, 'errors');
+ setEventMessages($langs->trans('ErrorEmptyChangeDate'), null, 'errors');
+ break;
}
}
}
From 05c11e71e2471e6ac16a4455e4cf1e5ddfba7c8f Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Wed, 7 Jan 2026 18:33:22 +0100
Subject: [PATCH 8/8] Fix CI
---
.pre-commit-config.yaml | 2 +-
.scrutinizer.yml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 82eb45c1d0b..74510a21197 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -82,7 +82,7 @@ repos:
pass_filenames: false # Run on all files
- id: php-lint
exclude:
- (?x)^(htdocs/includes/symfony/var-dumper/Tests/.*)$
+ (?x)^(htdocs/includes/symfony/var-dumper/Tests/.*)$
- id: php-stan
stages: [manual]
files: \.(php)$
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 058a0ba8b48..6a04407eadb 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -128,7 +128,7 @@ tools:
enabled: true
# Disabled unused code. In most cases, we want to keep it.
unused_code:
- enabled: false
+ enabled: false
deprecation_checks:
enabled: true
useless_function_calls: