Réécriture de l'insertion dans la base des infos

This commit is contained in:
Rodolphe Quiedeville 2004-04-06 10:16:42 +00:00
parent 1b7d8b69a4
commit 86774941a0

View File

@ -68,46 +68,23 @@ class PaiementFourn
$label = "Règlement facture $this->facnumber - $this->societe"; $label = "Règlement facture $this->facnumber - $this->societe";
// Portion de code qui mériterait de se baser sur la table des types $account = new Account($this->db, $this->accountid);
// de paiement, mais comme cette portion est aussi en dur dans l'ajout
// des factures clients, je fais pareil pour les factures fournisseurs $result = $account->addline($this->datepaye,
switch ($this->paiementid) $this->paiementid,
{ $label,
case 1: -$this->amount,
$this->paiementid = 'TIP'; $this->num_paiement);
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);
// Mise a jour fk_bank dans llx_paiement_fourn // Mise a jour fk_bank dans llx_paiement_fourn
if ($result) { if ($result)
$this->bankid = $this->db->last_insert_id(); {
$this->bankid = $this->db->last_insert_id();
$sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn SET fk_bank=$this->bankid WHERE rowid=$this->id"; $sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn SET fk_bank=$this->bankid WHERE rowid=$this->id";
$result = $this->db->query($sql); $result = $this->db->query($sql);
} }
} }
else else
{ {