From d14f3d7e2b05088b994345a08a0e3f8b2244d9ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 16:59:08 +0200 Subject: [PATCH] FIX When deleting last shipment, status "shipment in progress" of order must move back to status "validated". --- htdocs/commande/class/commande.class.php | 8 ++++++-- htdocs/expedition/class/expedition.class.php | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f167a344c8b..275f42452a6 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -166,9 +166,13 @@ class Commande extends CommonOrder */ const STATUS_VALIDATED = 1; /** - * Accepted/On process not managed for customer orders + * Accepted (supplier orders) */ const STATUS_ACCEPTED = 2; + /** + * Shipment on process (customer orders) + */ + const STATUS_SHIPMENTONPROCESS = 2; /** * Closed (Sent/Received, billed or not) */ @@ -1833,7 +1837,7 @@ class Commande extends CommonOrder } /** - * Load array this->expeditions of nb of products sent by line in order + * Load array this->expeditions of lines of shipments with nb of products sent for each order line * * @param int $filtre_statut Filter on status * @return int <0 if KO, Nb of lines found if OK diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 0978688f3f3..317b71bde99 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1204,6 +1204,22 @@ class Expedition extends CommonObject if ($result < 0) { $error++; } // End call triggers + if (! empty($this->origin) && $this->origin_id > 0) + { + $this->fetch_origin(); + $origin=$this->origin; + if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) // If order source of shipment is "shipment in progress" + { + // Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress" + $this->$origin->loadExpeditions(); + //var_dump($this->$origin->expeditions);exit; + if (count($this->$origin->expeditions) <= 0) + { + $this->$origin->setStatut(Commande::STATUS_VALIDATED); + } + } + } + if (! $error) { $this->db->commit();