From 86774941a061b8eb23ade9954bbeeba9b9f93400 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 6 Apr 2004 10:16:42 +0000 Subject: [PATCH] =?UTF-8?q?R=E9=E9criture=20de=20l'insertion=20dans=20la?= =?UTF-8?q?=20base=20des=20infos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/fourn/facture/paiementfourn.class.php | 51 ++++++-------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/htdocs/fourn/facture/paiementfourn.class.php b/htdocs/fourn/facture/paiementfourn.class.php index 4f77d2f5e1e..2ddcfca4b88 100644 --- a/htdocs/fourn/facture/paiementfourn.class.php +++ b/htdocs/fourn/facture/paiementfourn.class.php @@ -68,46 +68,23 @@ class PaiementFourn $label = "Règlement facture $this->facnumber - $this->societe"; - // Portion de code qui mériterait de se baser sur la table des types - // de paiement, mais comme cette portion est aussi en dur dans l'ajout - // des factures clients, je fais pareil pour les factures fournisseurs - switch ($this->paiementid) - { - case 1: - $this->paiementid = 'TIP'; - break; - case 2: - $this->paiementid = 'VIR'; - break; - case 3: - $this->paiementid = 'PRE'; - break; - case 4: - $this->paiementid = 'LIQ'; - break; - case 5: - $this->paiementid = 'WWW'; - break; - case 6: - $this->paiementid = 'CB'; - break; - case 7: - $this->paiementid = 'CHQ'; - break; - } - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, dateo, amount, author, label, fk_type, fk_account, num_chq)"; - $sql .= " VALUES (now(), '$this->datepaye', -$this->amount, '$this->author', '$label', '$this->paiementid', '$this->accountid', '$this->num_paiement')"; - $result = $this->db->query($sql); + $account = new Account($this->db, $this->accountid); + + $result = $account->addline($this->datepaye, + $this->paiementid, + $label, + -$this->amount, + $this->num_paiement); + // Mise a jour fk_bank dans llx_paiement_fourn - if ($result) { - $this->bankid = $this->db->last_insert_id(); + if ($result) + { + $this->bankid = $this->db->last_insert_id(); - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn SET fk_bank=$this->bankid WHERE rowid=$this->id"; - $result = $this->db->query($sql); - } - + $sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn SET fk_bank=$this->bankid WHERE rowid=$this->id"; + $result = $this->db->query($sql); + } } else {