Skip to content

Commit

Permalink
New: Add due date filter on invoices lists
Browse files Browse the repository at this point in the history
  • Loading branch information
fmarcet committed Jun 11, 2015
1 parent 0de3f8a commit 42b0410
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
23 changes: 22 additions & 1 deletion htdocs/compta/facture/list.php
Expand Up @@ -10,6 +10,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
*
* 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
Expand Down Expand Up @@ -88,6 +89,9 @@
$day = GETPOST('day','int');
$month = GETPOST('month','int');
$year = GETPOST('year','int');
$day_lim = GETPOST('day_lim','int');
$month_lim = GETPOST('month_lim','int');
$year_lim = GETPOST('year_lim','int');
$filtre = GETPOST('filtre');

// Security check
Expand Down Expand Up @@ -213,6 +217,19 @@
{
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($month_lim > 0)
{
if ($year_lim > 0 && empty($day_lim))
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,$month_lim,false))."' AND '".$db->idate(dol_get_last_day($year_lim,$month_lim,false))."'";
else if ($year_lim > 0 && ! empty($day_lim))
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'";
else
$sql.= " AND date_format(f.date_lim_reglement, '%m') = '".$month_lim."'";
}
else if ($year_lim > 0)
{
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'";
}
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
if ($search_user > 0)
{
Expand Down Expand Up @@ -322,7 +339,11 @@
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>';
print '<td class="liste_titre" align="left">&nbsp;</td>';
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_lim" value="'.$day_lim.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_lim" value="'.$month_lim.'">';
$formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5);
print '</td>';
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.$search_societe.'"></td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="6" name="search_montant_ht" value="'.$search_montant_ht.'"></td>';
print '<td class="liste_titre" align="right">&nbsp;</td>';
Expand Down
36 changes: 30 additions & 6 deletions htdocs/fourn/facture/list.php
Expand Up @@ -8,7 +8,8 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Abbes Bahfir <bafbes@gmail.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
*
* 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 3 of the License, or
Expand Down Expand Up @@ -74,8 +75,12 @@
$search_amount_no_tax = GETPOST("search_amount_no_tax","alpha");
$search_amount_all_tax = GETPOST("search_amount_all_tax","alpha");
$search_status=GETPOST('search_status','alpha');
$day = GETPOST("day","int");
$month = GETPOST("month","int");
$year = GETPOST("year","int");
$day_lim = GETPOST('day_lim','int');
$month_lim = GETPOST('month_lim','int');
$year_lim = GETPOST('year_lim','int');
$filter = GETPOST("filtre");

if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test must be present to be compatible with all browsers
Expand Down Expand Up @@ -163,15 +168,30 @@
}
if ($month > 0)
{
if ($year > 0)
if ($year > 0 && empty($day))
$sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else if ($year > 0 && ! empty($day))
$sql.= " AND fac.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
else
$sql.= " AND date_format(fac.datef, '%m') = '$month'";
$sql.= " AND date_format(fac.datef, '%m') = '".$month."'";
}
else if ($year > 0)
{
$sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($month_lim > 0)
{
if ($year_lim > 0 && empty($day_lim))
$sql.= " AND fac.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,$month_lim,false))."' AND '".$db->idate(dol_get_last_day($year_lim,$month_lim,false))."'";
else if ($year_lim > 0 && ! empty($day_lim))
$sql.= " AND fac.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'";
else
$sql.= " AND date_format(fac.date_lim_reglement, '%m') = '".$month_lim."'";
}
else if ($year_lim > 0)
{
$sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'";
}
if ($search_label)
{
$sql .= natural_search('fac.libelle', $search_label);
Expand Down Expand Up @@ -260,11 +280,15 @@
print '</td>';
}
print '<td class="liste_titre" colspan="1" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$syear = $year;
$formother->select_year($syear?$syear:-1,'year',1, 20, 5);
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>';
print '<td class="liste_titre" colspan="1" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_lim" value="'.$day_lim.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_lim" value="'.$month_lim.'">';
$formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5);
print '</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="left">';
print '<input class="flat" size="16" type="text" name="search_label" value="'.$search_label.'">';
print '</td>';
Expand Down

0 comments on commit 42b0410

Please sign in to comment.