From 833cb77b7605b1f933e7881659d383aa4fe16046 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2005 12:18:30 +0000 Subject: [PATCH] Uniformisation du code --- htdocs/compta/recap-client.php | 172 +++++++++++++++++---------------- 1 file changed, 91 insertions(+), 81 deletions(-) diff --git a/htdocs/compta/recap-client.php b/htdocs/compta/recap-client.php index 318b13eca68..8a095fb340b 100644 --- a/htdocs/compta/recap-client.php +++ b/htdocs/compta/recap-client.php @@ -151,103 +151,113 @@ if ($socid > 0) * */ print "\n"; - + print '
'; + print ''; if ($conf->facture->enabled && $user->rights->facture->lire) - { + { + // Factures + print_fiche_titre("Bills"); + print ''; $sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, ".$db->pdate("f.datef")." as df"; - $sql .= " , f.paye as paye, f.fk_statut as statut, f.rowid as facid "; + $sql .= " , f.paye as paye, f.fk_statut as statut, f.rowid as facid "; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_soc = s.idp AND s.idp = ".$societe->id; $sql .= " ORDER BY f.datef DESC"; - if ( $db->query($sql) ) - { - $var=true; - $num = $db->num_rows(); $i = 0; - if ($num > 0) + $resql=$db->query($sql); + if ($resql) + { + $var=true; + $num = $db->num_rows($resql); + if ($num > 0) { - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; } - - while ($i < $num) - { - $objp = $db->fetch_object(); - $facs[$i] = $objp->facid; - $i++; - } - $db->free(); - - - $solde = 0; - - for ($i = 0 ; $i < $num ; $i++) - { - $var=!$var; - - $fac = new Facture($db); - $fac->fetch($facs[$i]); - - print ""; - - print "\n"; - print "\n"; - - print '\n"; - $solde = $solde + $fac->total_ttc; - - print ''; - print '\n"; - print "\n"; - - - $sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, pf.amount, p.statut"; - - $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; - $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; - $sql .= " WHERE pf.fk_paiement = p.rowid"; - $sql .= " AND pf.fk_facture = ".$fac->id; - - $result = $db->query($sql); - - if ($result) - { - $nump = $db->num_rows(); - $j = 0; - - while ($j < $nump) - { - $objp = $db->fetch_object(); - //$var=!$var; - print ""; - print '\n"; - print ''; - print "\n"; - print ''; - $solde = $solde - $objp->amount; - print '\n"; - print ''; - - $j++; - } - } - } - } + else + { + print $langs->trans("NoBills"); + } + + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $facs[$i] = $objp->facid; + $i++; + } + $db->free($resql); + + + $solde = 0; + + // Boucle sur chaque facture + for ($i = 0 ; $i < $num ; $i++) + { + $var=!$var; + + $fac = new Facture($db); + $fac->fetch($facs[$i]); + + print ""; + + print "\n"; + print "\n"; + + print '\n"; + $solde = $solde + $fac->total_ttc; + + print ''; + print '\n"; + print "\n"; + + // Paiements + $sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, pf.amount, p.statut"; + + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; + $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; + $sql .= " WHERE pf.fk_paiement = p.rowid"; + $sql .= " AND pf.fk_facture = ".$fac->id; + + $resql = $db->query($sql); + if ($resql) + { + $nump = $db->num_rows($resql); + $j = 0; + + while ($j < $nump) + { + $objp = $db->fetch_object($resql); + //$var=!$var; + print ""; + print '\n"; + print ''; + print "\n"; + print ''; + $solde = $solde - $objp->amount; + print '\n"; + print ''; + + $j++; + } + } + } + } else - { + { dolibarr_print_error($db); - } + } print "
 '.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Solde").'
 '.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Solde").'
".dolibarr_print_date($fac->date)."id\">".img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."'.number_format($fac->total_ttc, 2, ',', ' ')." '.number_format($solde, 2, ',', ' ')."
'.dolibarr_print_date($objp->dp)."'.img_file().' Paiement '.$objp->rowid.' '.price($objp->amount).''.number_format($solde, 2, ',', ' ')."
".dolibarr_print_date($fac->date)."id\">".img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."'.number_format($fac->total_ttc, 2, ',', ' ')." '.number_format($solde, 2, ',', ' ')."
'.dolibarr_print_date($objp->dp)."'.img_file().' Paiement '.$objp->rowid.' '.price($objp->amount).''.number_format($solde, 2, ',', ' ')."
"; - } + } } else {