From 7788157b199a9c61397bb8fa582a14aa1040c2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Tue, 1 Dec 2020 16:55:43 +0100 Subject: [PATCH 1/4] API orders: Update demand reason on order update --- htdocs/commande/class/api_orders.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 71a26eea698..2f4eb6ea996 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -623,6 +623,12 @@ class Orders extends DolibarrApi throw new RestException(400, 'Error while updating availability'); } + // Update demand reason + if (!empty($this->commande->demand_reason_id) && $this->commande->demand_reason_id > 0) { + if ($this->commande->demand_reason($this->commande->demand_reason_id) < 0) + throw new RestException(400, 'Error while updating demand reason'); + } + if ($this->commande->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); From dcc3ecf0129a771d4f20b280384ee33140d85dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 3 Dec 2020 16:01:17 +0100 Subject: [PATCH 2/4] Update commande.class.php --- htdocs/commande/class/commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 506cf84c8fd..0b68095c5d0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3273,6 +3273,7 @@ class Commande extends CommonOrder $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; $sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").","; $sql .= " fk_account=".($this->fk_account > 0 ? $this->fk_account : "null").","; + $sql .= " fk_input_reason=".($this->demand_reason_id > 0 ? $this->demand_reason_id : "null").","; $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; From 2751d5cefdcc63703a549d04fe6c6161115b6971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 3 Dec 2020 16:02:49 +0100 Subject: [PATCH 3/4] Update api_orders.class.php --- htdocs/commande/class/api_orders.class.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2f4eb6ea996..3442b9316f7 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -622,13 +622,7 @@ class Orders extends DolibarrApi if ($this->commande->availability($this->commande->availability_id) < 0) throw new RestException(400, 'Error while updating availability'); } - - // Update demand reason - if (!empty($this->commande->demand_reason_id) && $this->commande->demand_reason_id > 0) { - if ($this->commande->demand_reason($this->commande->demand_reason_id) < 0) - throw new RestException(400, 'Error while updating demand reason'); - } - + if ($this->commande->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); From 9875e73ee2169d0ed9dca59f91cb25e203438b49 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 3 Dec 2020 15:04:48 +0000 Subject: [PATCH 4/4] Fixing style errors. --- htdocs/commande/class/api_orders.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 3442b9316f7..71a26eea698 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -622,7 +622,7 @@ class Orders extends DolibarrApi if ($this->commande->availability($this->commande->availability_id) < 0) throw new RestException(400, 'Error while updating availability'); } - + if ($this->commande->update(DolibarrApiAccess::$user) > 0) { return $this->get($id);