From 64e4b61dd2fb63f56b2a9d62e9fd8cf67325dfff Mon Sep 17 00:00:00 2001 From: liedekef Date: Fri, 5 Jan 2007 15:01:39 +0000 Subject: [PATCH] added code to check if an order is already validated, so it doesn't get validated again and no stock problems arise --- htdocs/expedition/expedition.class.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index 1bd19856b52..ef93477cdc8 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2007 Franky Van Liedekerke * * 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 @@ -303,8 +304,19 @@ class Expedition extends CommonObject { $this->ref = "EXP".$this->id; - // \todo Tester si non dejà au statut validé. Si oui, on arrete afin d'éviter - // de décrémenter 2 fois le stock. + // Tester si non dejà au statut validé. Si oui, on arrete afin d'éviter + // de décrémenter 2 fois le stock. + $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."expedition where ref='".$this->ref."' AND fk_statut='1'"; + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + if ($num >0) { + return 0; + } + } + $num = $this->db->num_rows($resql); + $sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;"; $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='".$this->ref."', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id"; $sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;";