From aaba18bd5147565707658631675e8cc49ef0e98a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Aug 2015 15:40:33 +0200 Subject: [PATCH] Fix filter on date --- htdocs/compta/facture/list.php | 1 + htdocs/compta/paiement/list.php | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index faefe63d9af..b06ea221cf8 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -129,6 +129,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_montant_ht=''; $search_montant_ttc=''; $search_status=''; + $day=''; $year=''; $month=''; } diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index d284a128631..c688ca780d4 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -28,6 +28,8 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("bills"); $langs->load("compta"); @@ -36,6 +38,10 @@ $langs->load("compta"); $facid =GETPOST('facid','int'); $socid =GETPOST('socid','int'); $userid=GETPOST('userid','int'); +$day = GETPOST('day','int'); +$month = GETPOST('month','int'); +$year = GETPOST('year','int'); + if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'facture',$facid,''); @@ -66,6 +72,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_amount=""; $search_paymenttype=""; $search_company=""; + $day=''; + $year=''; + $month=''; } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array @@ -81,6 +90,7 @@ $extrafields = new ExtraFields($db); llxHeader('', $langs->trans('ListPayment')); $form=new Form($db); +$formother=new FormOther($db); if (GETPOST("orphelins")) { @@ -141,6 +151,19 @@ else else $sql.= " AND f.fk_user_author = ".$userid; } // Search criteria + if ($month > 0) + { + if ($year > 0 && empty($day)) + $sql.= " AND p.datep 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 p.datep 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(p.datep, '%m') = '".$month."'"; + } + else if ($year > 0) + { + $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + } if ($search_ref > 0) $sql .=" AND p.rowid=".$search_ref; if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'"; @@ -194,7 +217,11 @@ if ($resql) print ''; print ''; print ''; - print ' '; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; print ''; print ''; print '';