* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ * */ require("./pre.inc.php3"); require("../paiement.class.php"); llxHeader(); $db = new Db(); if ($action == 'add') { $datepaye = $db->idate(mktime(12, 0 , 0, $pmonth, $pday, $pyear)); $paiement = new Paiement($db); $paiement->facid = $facid; $paiement->datepaye = $datepaye; $paiement->amount = $amount; $paiement->author = $author; $paiement->paiementid = $paiementid; $paiement->num_paiement = $num_paiement; $paiement->note = $note; $paiement->create(); $action = ''; } elseif ($action == 'create') { $sql = "SELECT s.nom,s.idp, f.amount, f.total, f.facnumber"; $sql .= " FROM societe as s, llx_facture as f WHERE f.fk_soc = s.idp"; $sql .= " AND f.rowid = $facid"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); if ($num) { $obj = $db->fetch_object( 0); $total = $obj->total; print_titre("Emettre un paiement"); print "
"; print ''; print ""; print ""; print ""; print ""; $sql = "SELECT sum(p.amount) FROM llx_paiement as p WHERE p.fk_facture = $facid;"; $result = $db->query($sql); if ($result) { $sumpayed = $db->result(0,0); $db->free(); } print ''; print ""; print ""; print ""; print "facnumber\">"; print "idp\">"; print "nom\">"; $strmonth[1] = "Janvier"; $strmonth[2] = "Février"; $strmonth[3] = "Mars"; $strmonth[4] = "Avril"; $strmonth[5] = "Mai"; $strmonth[6] = "Juin"; $strmonth[7] = "Juillet"; $strmonth[8] = "Août"; $strmonth[9] = "Septembre"; $strmonth[10] = "Octobre"; $strmonth[11] = "Novembre"; $strmonth[12] = "Décembre"; print ""; print ""; $author = $GLOBALS["REMOTE_USER"]; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
Facture
Numéro :$obj->facnumber
Société :$obj->nom
Montant :".price($obj->total)." euros TTC
Déjà payé'.price($sumpayed).' euros TTC
Paiement
Date :"; $cday = date("d", time()); print ""; $cmonth = date("n", time()); print ""; print "Commentaires :
"; print "
Type :
"; print "
Numéro :
Num du cheque ou virement
 Reste à payer : ".price($total - $sumpayed)." euros TTC
Montant :
\n"; } } } if ($action == '') { $sql = "SELECT ".$db->pdate("p.datep")." as dp, p.amount, f.amount as fa_amount, f.facnumber, f.rowid as facid, c.libelle as paiement_type, p.num_paiement"; $sql .= " FROM llx_paiement as p, llx_facture as f, c_paiement as c WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id"; $sql .= " ORDER BY datep DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; $total = 0; print_barre_liste("Paiements", $page, $PHP_SELF); print ""; print ''; print ""; print ""; print ""; print ""; print ""; print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; print ''; print ""; $total = $total + $objp->amount; $i++; } print "\n"; print "
FactureDateTypeMontant 
facid\">$objp->facnumber".strftime("%d %B %Y",$objp->dp)."$objp->paiement_type $objp->num_paiement'.price($objp->amount).' 
Total : ".price($total)."Euros HT
"; } } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>