From 6768697497420f8cdb8b426b0581319b187c6a80 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Sat, 26 Nov 2022 00:13:15 +0100 Subject: [PATCH 1/3] Fix #21357 --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c0ff43083eb..d1cd74099ae 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3505,7 +3505,7 @@ if ($action == 'create') { } print ''; print ''; - print ''.(!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency).' '.price(price2num($object->multicurrency_tx*$resteapayeraffiche, 'MT')).' '; + print ''.(!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency).' '.price(price2num($multicurrency_resteapayer, 'MT')).' '; } } else // Credit note { From b98eaa4d45a615ac1700cd2af2cc57a4ea342d21 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Sat, 26 Nov 2022 01:01:22 +0100 Subject: [PATCH 2/3] #FIX: #22509 default value on integer fields don't retrieve by setSaveQuery --- htdocs/core/class/commonobject.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0fb5bcedae0..3e10ea82eaa 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8829,7 +8829,11 @@ abstract class CommonObject // $this->{$field} may be null, '', 0, '0', 123, '123' if ((isset($this->{$field}) && $this->{$field} != '') || !empty($info['notnull'])) { if (!isset($this->{$field})) { - $queryarray[$field] = 0; + if (!empty($info['default'])) { + $queryarray[$field] = $info['default']; + } else { + $queryarray[$field] = 0; + } } else { $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 } From b15fda8d9a761fec13f177bf9646ab318e9b2f5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Nov 2022 14:38:25 +0100 Subject: [PATCH 3/3] Debug edit actioncomm --- htdocs/comm/action/card.php | 2 ++ htdocs/comm/action/class/actioncomm.class.php | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 63647e9d308..0b169d846e9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -550,7 +550,9 @@ if (empty($reshook) && $action == 'update') { } } else { $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm'); + $object->type_code = GETPOST("actioncode", 'aZ09'); } + $object->label = GETPOST("label", "alphanohtml"); $object->datep = $datep; $object->datef = $datef; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index e31e6023210..7947afa71ab 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1150,12 +1150,8 @@ class ActionComm extends CommonObject $userownerid = ($this->userownerid ? $this->userownerid : 0); $userdoneid = ($this->userdoneid ? $this->userdoneid : 0); - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; - $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; + // If a type_id is set, we must also have the type_code set if ($this->type_id > 0) { - $sql .= ", fk_action = ".(int) $this->type_id; if (empty($this->type_code)) { $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($this->type_id); @@ -1164,7 +1160,18 @@ class ActionComm extends CommonObject } } } - $sql .= ", code = " . (isset($this->type_code)? "'".$this->db->escape($this->type_code) . "'":"null"); + + $code = $this->code; + if (empty($code) || (!empty($this->oldcopy) && $this->oldcopy->type_code != $this->type_code)) { // If code unknown or if change the type, we reset $code too + $code = $this->type_code; + } + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; + $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; + $sql .= ", fk_action = ".(int) $this->type_id; + $sql .= ", code = " . ($code ? "'".$this->db->escape($code)."'" : "null"); $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null');