From e8cee154068962823387816f204ba1c1f9b801cf Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 8 Apr 2005 15:22:36 +0000 Subject: [PATCH] Gestion de l'annulation des commandes --- htdocs/fournisseur.commande.class.php | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/htdocs/fournisseur.commande.class.php b/htdocs/fournisseur.commande.class.php index ac08d34ca5f..9f595264455 100644 --- a/htdocs/fournisseur.commande.class.php +++ b/htdocs/fournisseur.commande.class.php @@ -52,6 +52,7 @@ class CommandeFournisseur $this->statuts[3] = "Commandée"; $this->statuts[4] = "Reçu partiellement"; $this->statuts[5] = "Clotûrée"; + $this->statuts[6] = "Annulée"; $this->statuts[9] = "Refusée"; $this->products = array(); @@ -172,6 +173,38 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm } return $result ; } + /** + * Annule la commande + * L'annulation se fait après la validation + * + */ + function Cancel($user) + { + //dolibarr_syslog("CommandeFournisseur::Cancel"); + $result = 0; + if ($user->rights->fournisseur->commande->annuler) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 6"; + $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 1 ;"; + + if ($this->db->query($sql) ) + { + $result = 0; + $this->log($user, 1, time()); + } + else + { + dolibarr_syslog("CommandeFournisseur::Cancel Error -1"); + $result = -1; + } + } + else + { + dolibarr_syslog("CommandeFournisseur::Cancel Not Authorized"); + } + return $result ; + } /* * *