From 2999d0b37a5ee28c51a8bee93c0175ba37d74a45 Mon Sep 17 00:00:00 2001 From: a-schild Date: Wed, 8 Jul 2015 08:58:30 +0200 Subject: [PATCH] Show due days in not payed supplier bills --- htdocs/fourn/facture/impayees.php | 32 +++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php index 826393970b8..b9fb072f437 100644 --- a/htdocs/fourn/facture/impayees.php +++ b/htdocs/fourn/facture/impayees.php @@ -56,6 +56,7 @@ $search_ref_supplier = GETPOST('search_ref_supplier','alpha'); $search_company = GETPOST('search_company','alpha'); $search_amount_no_tax = GETPOST('search_amount_no_tax','alpha'); $search_amount_all_tax = GETPOST('search_amount_all_tax','alpha'); +$search_duedays = GETPOST('search_duedays','alpha'); $op1month=GETPOST('op1month'); $op1day=GETPOST('op1day'); @@ -90,6 +91,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $op2day=""; $op2year=""; $filter_op2=""; + $duedays=""; } /* @@ -111,6 +113,7 @@ if ($user->rights->fournisseur->facture->lire) $sql = "SELECT s.rowid as socid, s.nom as name,"; $sql.= " f.rowid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc,"; $sql.= " f.datef as df, f.date_lim_reglement as datelimite, "; + $sql.= " DATEDIFF(f.date_lim_reglement, NOW()) as duedays, "; $sql.= " f.paye as paye, f.rowid as facid, f.fk_statut"; $sql.= " ,sum(pf.amount) as am"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; @@ -153,11 +156,16 @@ if ($user->rights->fournisseur->facture->lire) $sql .= " AND s.nom LIKE '%".$search_company."%'"; } + if ($search_duedays) + { + $sql .= " AND DATEDIFF(f.date_lim_reglement, NOW()) = '".$search_duedays."'"; + } + if ($search_amount_no_tax) { $sql .= " AND f.total_ht = '".$search_amount_no_tax."'"; } - + if ($search_amount_all_tax) { $sql .= " AND f.total_ttc = '".$search_amount_all_tax."'"; @@ -196,6 +204,7 @@ if ($user->rights->fournisseur->facture->lire) if ($filter_date1 != '') $param.='&op1day='.$op1day.'&op1month='.$op1month.'&op1year='.$op1year; if (! empty($filter_op2) && $filter_op2 != -1) $param.='&filter_op2='.urlencode($filter_op2); if ($filter_date2 != '') $param.='&op2day='.$op2day.'&op2month='.$op2month.'&op2year='.$op2year; + if ($search_duedays) $param.='&search_duedays='.urlencode($search_duedays); $param.=($option?"&option=".$option:""); if (! empty($late)) $param.='&late='.urlencode($late); @@ -221,6 +230,7 @@ if ($user->rights->fournisseur->facture->lire) print_liste_field_titre($langs->trans("RefSupplier"),$_SERVER["PHP_SELF"],"f.ref_supplier","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DueDays"),$_SERVER["PHP_SELF"],"duedays","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total_ht","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); @@ -248,6 +258,9 @@ if ($user->rights->fournisseur->facture->lire) $filter_date2=dol_mktime(0,0,0,$op2month,$op2day,$op2year); print $form->select_date($filter_date2,'op2',0,0,1); print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -274,6 +287,16 @@ if ($user->rights->fournisseur->facture->lire) print ""; $classname = "impayee"; + if ($objp->duedays <0) + { + $overdueclassstart=""; + $overdueclassend=""; + } + else + { + $overdueclassstart=""; + $overdueclassend=""; + } print ''; $facturestatic->id=$objp->facid; @@ -284,9 +307,10 @@ if ($user->rights->fournisseur->facture->lire) print ''.dol_trunc($objp->ref_supplier,12).''; print ''.dol_print_date($db->jdate($objp->df),'day')."\n"; - print ''.dol_print_date($db->jdate($objp->datelimite),'day'); + print ''.$overdueclassstart.dol_print_date($db->jdate($objp->datelimite),'day'); if ($objp->datelimite && $db->jdate($objp->datelimite) < ($now - $conf->facture->fournisseur->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late")); - print "\n"; + print $overdueclassend."\n"; + print "".$overdueclassstart.$objp->duedays.$overdueclassend.""; print ''; $companystatic->id=$objp->socid; @@ -312,7 +336,7 @@ if ($user->rights->fournisseur->facture->lire) } print ''; - print "".$langs->trans("Total").": "; + print "".$langs->trans("Total").": "; print "".price($total_ht).""; print "".price($total_ttc).""; print "".price($total_paid)."";