From d1462e543c077708858f09bd13ec0c6478b929d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Oct 2005 23:22:21 +0000 Subject: [PATCH] Fix: La saisie de la ref commande client sur commande ne s'enregistrait pas pour certains etats de commande --- htdocs/commande/commande.class.php | 25 ++++++++++++++++++------- htdocs/commande/fiche.php | 9 ++++++--- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 734d5c8beae..509c83a7697 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -421,6 +421,7 @@ class Commande $obj = $this->db->fetch_object(); $this->id = $obj->rowid; $this->ref = $obj->ref; + $this->ref_client = $obj->ref_client; $this->soc_id = $obj->fk_soc; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; @@ -432,7 +433,6 @@ class Commande $this->source = $obj->source; $this->facturee = $obj->facture; $this->note = $obj->note; - $this->ref_client = $obj->ref_client; $this->projet_id = $obj->fk_projet; $this->db->free(); if ($this->statut == 0) @@ -591,16 +591,20 @@ class Commande } } - /** - * - * - */ + /** + * \brief Positionne numero reference commande client + * \param user Utilisateur qui modifie + * \param ref_client Reference commande client + * \return int <0 si ko, >0 si ok + */ function set_ref_client($user, $ref_client) { if ($user->rights->commande->creer) { + dolibarr_syslog('Commande::set_ref_client this->id='.$this->id.', ref_client='.$ref_client); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.addslashes($ref_client).'\''); - $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; + $sql.= ' WHERE rowid = '.$this->id; if ($this->db->query($sql) ) { $this->ref_client = $ref_client; @@ -608,10 +612,17 @@ class Commande } else { - dolibarr_syslog('Commande::set_ref_client Erreur SQL'); + $this->error=$this->db->error(); + dolibarr_syslog('Commande::set_ref_client Erreur '.$this->error.' - '.$sql); + return -2; } } + else + { + return -1; + } } + /** * * diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 650f6145d64..e98e4ba8576 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -46,6 +46,7 @@ require_once(DOL_DOCUMENT_ROOT.'/propal.class.php'); require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); // Sécurité accés client +$socidp=0; if ($user->societe_id > 0) { $action = ''; @@ -56,15 +57,16 @@ if ($user->societe_id > 0) /* * Actions */ + +// Categorisation dans projet if ($_POST['action'] == 'classin' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $commande->classin($_POST['projetid']); } -/* - * - */ + +// Ajout commande if ($_POST['action'] == 'add' && $user->rights->commande->creer) { $datecommande = mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); @@ -95,6 +97,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) $action = ''; } +// Positionne ref commande client if ($_POST['action'] == 'set_ref_client' && $user->rights->commande->creer) { $commande = new Commande($db);