From 65eefc1e4149b29145c41acc605527c4c73e3ab7 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 26 Jan 2005 17:09:15 +0000 Subject: [PATCH] =?UTF-8?q?Mets=20=E0=20jour=20les=20informations=20des=20?= =?UTF-8?q?lignes=20rattach=E9es=20au=20contrat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../telephonie/telephonie.contrat.class.php | 64 ++++++++++++++----- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/htdocs/telephonie/telephonie.contrat.class.php b/htdocs/telephonie/telephonie.contrat.class.php index 0087ac7de84..7ee4d03e972 100644 --- a/htdocs/telephonie/telephonie.contrat.class.php +++ b/htdocs/telephonie/telephonie.contrat.class.php @@ -73,7 +73,7 @@ class TelephonieContrat { else { $this->error_message = "Echec de la création du contrat"; - dolibarr_syslog("LigneTel::Create Error -1"); + dolibarr_syslog("TelephonieContrat::Create Error -1"); dolibarr_syslog($this->db->error()); return -1; } @@ -84,26 +84,60 @@ class TelephonieContrat { */ function update($user) { + $error = 0 ; - $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_contrat"; - $sql .= " SET "; - $sql .= " fk_client_comm = ".$this->client_comm; - $sql .= ", fk_soc = ".$this->client ; - $sql .= ", fk_soc_facture = ".$this->client_facture; - $sql .= ", fk_commercial_suiv = ".$this->commercial_suiv_id; - $sql .= ", mode_paiement = '".$this->mode_paiement."'"; - $sql .= ", note = '$this->note'"; - - $sql .= " WHERE rowid = ".$this->id; - - if ( $this->db->query($sql) ) + if (!$this->db->begin()) { + $error++; + dolibarr_syslog("TelephonieContrat::Update Error -1"); + } + + if (!$error) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_contrat"; + $sql .= " SET "; + $sql .= " fk_client_comm = ".$this->client_comm; + $sql .= ", fk_soc = ".$this->client ; + $sql .= ", fk_soc_facture = ".$this->client_facture; + $sql .= ", fk_commercial_suiv = ".$this->commercial_suiv_id; + $sql .= ", mode_paiement = '".$this->mode_paiement."'"; + $sql .= ", note = '$this->note'"; + + $sql .= " WHERE rowid = ".$this->id; + + if (! $this->db->query($sql) ) + { + $error++; + dolibarr_syslog("TelephonieContrat::Update Error -2"); + } + } + + + if (!$error) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_societe_ligne"; + $sql .= " SET "; + $sql .= " mode_paiement = '".$this->mode_paiement."'"; + $sql .= " WHERE fk_contrat = ".$this->id; + + + if (! $this->db->query($sql) ) + { + $error++; + dolibarr_syslog("TelephonieContrat::Update Error -3"); + } + } + + + if (!$error) + { + $this->db->commit(); return 0; } else { - print $this->db->error(); - print $sql ; + $this->db->rollback(); return -1; } }