From 81dd2007db738f1e1aa801b9c59e33902a8661e5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 15 Feb 2006 17:00:59 +0000 Subject: [PATCH] Ajout mode_reglement et cond_reglement --- htdocs/commande/commande.class.php | 67 ++++++++++++++++++++++++++++++ htdocs/commande/fiche.php | 16 +++++++ 2 files changed, 83 insertions(+) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 001675053ef..c59d8e68ebd 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -787,6 +787,73 @@ class Commande } } + /** + * \brief Change les conditions de réglement de la commande + * \param cond_reglement_id Id de la nouvelle condition de réglement + * \return int >0 si ok, <0 si ko + */ + function cond_reglement($cond_reglement_id) + { + dolibarr_syslog('Commande::cond_reglement('.$cond_reglement_id.')'); + if ($this->statut >= 0) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; + $sql .= ' SET fk_cond_reglement = '.$cond_reglement_id; + $sql .= ' WHERE rowid='.$this->id; + if ( $this->db->query($sql) ) + { + $this->cond_reglement_id = $cond_reglement_id; + return 1; + } + else + { + dolibarr_syslog('Commande::cond_reglement Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dolibarr_syslog('Commande::cond_reglement, etat commande incompatible'); + $this->error='Etat commande incompatible '.$this->statut; + return -2; + } + } + + + /** + * \brief Change le mode de réglement + * \param mode Id du nouveau mode + * \return int >0 si ok, <0 si ko + */ + function mode_reglement($mode_reglement_id) + { + dolibarr_syslog('Commande::mode_reglement('.$mode_reglement_id.')'); + if ($this->statut >= 0) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; + $sql .= ' SET fk_mode_reglement = '.$mode_reglement_id; + $sql .= ' WHERE rowid='.$this->id; + if ( $this->db->query($sql) ) + { + $this->mode_reglement_id = $mode_reglement_id; + return 1; + } + else + { + dolibarr_syslog('Commande::mode_reglement Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dolibarr_syslog('Commande::mode_reglement, etat facture incompatible'); + $this->error='Etat commande incompatible '.$this->statut; + return -2; + } + } + /** * \brief Positionne numero reference commande client * \param user Utilisateur qui modifie diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 196fbb69bb7..c284ad4f0fd 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -127,6 +127,22 @@ if ($_POST['action'] == 'setnote' && $user->rights->commande->creer) $commande->set_note($user, $_POST['note']); } +if ($_POST['action'] == 'setmode' && $user->rights->commande->creer) +{ + $commande = new Commande($db); + $commande->fetch($_GET['id']); + $result=$commande->mode_reglement($_POST['mode_reglement_id']); + if ($result < 0) dolibarr_print_error($db,$commande->error); +} + +if ($_POST['action'] == 'setconditions' && $user->rights->commande->creer) +{ + $commande = new Commande($db); + $commande->fetch($_GET['id']); + $result=$commande->cond_reglement($_POST['cond_reglement_id']); + if ($result < 0) dolibarr_print_error($db,$commande->error); +} + if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) { /*