diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index ac6f7f721f5..0bb542b9b79 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -89,7 +89,7 @@ if ($user->rights->facture->lire) $sql .= ",".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; $sql .= " WHERE f.fk_soc = s.idp"; - $sql .= " AND f.paye = 0"; + $sql .= " AND f.paye = 0 AND f.fk_statut > 0"; if ($socidp) $sql .= " AND s.idp = $socidp"; @@ -144,7 +144,7 @@ if ($user->rights->facture->lire) } $sql .= " f.rowid DESC "; - $sql .= $db->plimit($limit+1,$offset); + //$sql .= $db->plimit($limit+1,$offset); $result = $db->query($sql); @@ -188,71 +188,51 @@ if ($user->rights->facture->lire) print ''; print "\n"; print ''; - - + if ($num > 0) { $var=True; $total=0; $totalrecu=0; - while ($i < min($num,$limit)) + while ($i < $num) { $objp = $db->fetch_object($result); - $var=!$var; if ($objp->am == 0) { + $var=!$var; - print ""; - if ($objp->paye) - { - $class = "normal"; - } - else - { - if ($objp->fk_statut == 0) + print ""; + $class = "impayee"; + + print ''.img_file()." \n"; + print ''.$objp->facnumber.''.$objp->increment."\n"; + + if ($objp->df > 0 ) { - $class = "normal"; + print ""; + $y = strftime("%Y",$objp->df); + $m = strftime("%m",$objp->df); + + print strftime("%d",$objp->df)."\n"; + print ' '; + print substr(strftime("%B",$objp->df),0,3)."\n"; + print ' '; + print strftime("%Y",$objp->df)."\n"; } else { - $class = "impayee"; + print "!!!\n"; } - } + print ''.$objp->nom.''; + + print "".price($objp->total).""; + print "".price($objp->total_ttc).""; + print "".price($objp->am).""; + // Affiche statut de la facture - print ''.img_file()." \n"; - print ''.$objp->facnumber.''.$objp->increment."\n"; - - if ($objp->df > 0 ) - { - print ""; - $y = strftime("%Y",$objp->df); - $m = strftime("%m",$objp->df); - - print strftime("%d",$objp->df)."\n"; - print ' '; - print substr(strftime("%B",$objp->df),0,3)."\n"; - print ' '; - print strftime("%Y",$objp->df)."\n"; - } - else - { - print "!!!\n"; - } - print ''.$objp->nom.''; - - print "".price($objp->total).""; - print "".price($objp->total_ttc).""; - print "".price($objp->am).""; - // Affiche statut de la facture - if (! $objp->paye) - { - if ($objp->fk_statut == 0) - { - print 'brouillon'; - } - elseif ($objp->fk_statut == 3) + if ($objp->fk_statut == 3) { print 'abandonnée'; } @@ -260,30 +240,21 @@ if ($user->rights->facture->lire) { print ''.($objp->am?"commencé":"impayée").''; } - } - else - { - print 'payée'; - } - - print "\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$objp->am; + + print "\n"; + $total+=$objp->total; + $total_ttc+=$objp->total_ttc; + $totalrecu+=$objp->am; } $i++; } - - if ($num <= $limit) { - // Print total - print ""; - print "".$langs->trans("Total").": "; - print "".price($total).""; - print "".price($total_ttc).""; - print "".price($totalrecu).""; - print ' '; - print "\n"; - } + print ""; + print "".$langs->trans("Total").": "; + print "".price($total).""; + print "".price($total_ttc).""; + print "".price($totalrecu).""; + print ' '; + print "\n"; } print "";