diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 3585750094b..8e39e2cbde3 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -172,62 +172,6 @@ if ($HTTP_POST_VARS["action"] == 'add') $action = ''; } -/* - * - */ -if ($action == 'add_paiement') -{ - $datepaye = $db->idate(mktime(12, 0 , 0, $HTTP_POST_VARS["remonth"], $HTTP_POST_VARS["reday"], $HTTP_POST_VARS["reyear"])); - - $paiement = new Paiement($db); - - $paiement->facid = $HTTP_POST_VARS["facid"]; - $paiement->datepaye = $datepaye; - $paiement->amount = $HTTP_POST_VARS["amount"]; - $paiement->author = $HTTP_POST_VARS["author"]; - $paiement->paiementid = $HTTP_POST_VARS["paiementid"]; - $paiement->num_paiement = $HTTP_POST_VARS["num_paiement"]; - $paiement->note = $HTTP_POST_VARS["note"]; - - //A ne pas mélanger avec paiementid ! - $paiement_id = $paiement->create(); - - $action = ''; - - $fac = new Facture($db); - $fac->fetch($HTTP_POST_VARS["facid"]); - $fac->fetch_client(); - - $label = "Règlement facture"; - - //On ajoute une ligne dans la table llx_bank pour qu'ensuite on puisse rapprocher le compte ! - $acc = new Account($db, $HTTP_POST_VARS["accountid"]); - //paiementid est correct, il contient "CHQ ou VIR par exemple" - $bank_line_id = $acc->addline($datepaye, $paiementid, $label, $amount, $num_paiement); - - // TODO - // Mise a jour fk_bank dans llx_paiement - // $acc->update_fk_bank($paiement_id,$bank_line_id); - - $acc->add_url_line($bank_line_id, $fac->id, DOL_URL_ROOT.'/compta/facture.php?facid=', $fac->ref); - $acc->add_url_line($bank_line_id, $fac->client->id, DOL_URL_ROOT.'/compta/fiche.php?socid=', $fac->client->nom); -} -/* - * - */ -if ($action == 'del_paiement' && $user->rights->facture->paiement) -{ - $paiement = new Paiement($db); - $paiement->id = $paiementid; - $paiement->delete(); - - $action = ''; - //Attention: bug 18.01.2004 on oublie d'effacer la ligne correspondante dans llx_bank ! - - $acc = new Account($db, $HTTP_POST_VARS["accountid"]); - //paiementid est correct, il contient "CHQ ou VIR par exemple" - $acc->deleteline($paiementid); -} /* * */ @@ -767,8 +711,10 @@ else /* * Paiements */ - $sql = "SELECT ".$db->pdate("datep")." as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as c WHERE p.fk_facture = ".$fac->id." AND p.fk_paiement = c.id"; + $sql = "SELECT ".$db->pdate("datep")." as dp, pf.amount,"; + $sql .= "c.libelle as paiement_type, p.num_paiement, p.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf"; + $sql .= " WHERE pf.fk_facture = ".$fac->id." AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid"; $result = $db->query($sql); if ($result) @@ -777,26 +723,18 @@ else $i = 0; $total = 0; echo ''; print ''; - print ""; - if (! $fac->paye) - { - print ""; - } - print "\n"; + print ""; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; - print ""; - print "\n"; + print "\n"; print "\n"; print '\n"; - if (! $fac->paye && $user->rights->facture->paiement) - { - print '"; $total = $total + $objp->amount; $i++; @@ -807,10 +745,10 @@ else print "\n"; print "\n"; - $resteapayer = price($fac->total_ttc - $total); + $resteapayer = abs($fac->total_ttc - $total); print ""; - print "\n"; + print "\n"; } print "
DateTypeMontant  
Montant 
".strftime("%d %B %Y",$objp->dp)."
"; + print ''.img_file().''; + print " ".strftime("%d %B %Y",$objp->dp)."$objp->paiement_type $objp->num_paiement'.price($objp->amount)."$_MONNAIE'.img_delete().''; - } print "
Total :".price($total)."$_MONNAIE
Facturé :".price($fac->total_ttc)."$_MONNAIE
Reste à payer :".price($fac->total_ttc - $total)."$_MONNAIE
".price($resteapayer)."$_MONNAIE
"; $db->free();