diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 1e99cf8676f..ee847603954 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -5,7 +5,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Juanjo Menent - * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2017-2021 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Charlene Benke * Copyright (C) 2020 Tobias Sekan @@ -56,16 +56,22 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'p $facid = GETPOST('facid', 'int'); $socid = GETPOST('socid', 'int'); $userid = GETPOST('userid', 'int'); -$day = GETPOST('day', 'int'); -$month = GETPOST('month', 'int'); -$year = GETPOST('year', 'int'); $search_ref = GETPOST("search_ref", "alpha"); -$search_company = GETPOST("search_company", 'alpha'); -$search_paymenttype = GETPOST("search_paymenttype"); -$search_account = GETPOST("search_account", "int"); -$search_payment_num = GETPOST('search_payment_num', 'alpha'); +$search_date_startday = GETPOST('search_date_startday', 'int'); +$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); +$search_date_startyear = GETPOST('search_date_startyear', 'int'); +$search_date_endday = GETPOST('search_date_endday', 'int'); +$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); +$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver +$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); +$search_company = GETPOST("search_company", 'alpha'); +$search_paymenttype = GETPOST("search_paymenttype"); +$search_account = GETPOST("search_account", "int"); +$search_payment_num = GETPOST('search_payment_num', 'alpha'); $search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x" +$search_status = GETPOST('search_status', 'intcomma'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -130,14 +136,20 @@ if (empty($reshook)) { // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $search_ref = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; + $search_date_start = ''; + $search_date_end = ''; $search_account = ''; $search_amount = ''; $search_paymenttype = ''; $search_payment_num = ''; $search_company = ''; - $day = ''; - $year = ''; - $month = ''; + $search_status = ''; $option = ''; $toselect = ''; $search_array_options = array(); @@ -211,10 +223,15 @@ if (GETPOST("orphelins", "alpha")) { } // Search criteria - $sql .= dolSqlDateFilter("p.datep", $day, $month, $year); if ($search_ref) { $sql .= natural_search('p.ref', $search_ref); } + if ($search_date_start) { + $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'"; + } + if ($search_date_end) { + $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'"; + } if ($search_account > 0) { $sql .= " AND b.fk_account=".((int) $search_account); } @@ -273,11 +290,40 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } -$param .= (GETPOST("orphelins") ? "&orphelins=1" : ''); -$param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : ''); -$param .= ($search_company ? "&search_company=".urlencode($search_company) : ''); -$param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : ''); -$param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : ''); + +if (GETPOST("orphelins")) { + $param .= '&orphelins=1'; +} +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); +} +if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); +} +if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); +} +if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); +} +if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); +} +if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); +} +if ($search_company) { + $param .= '&search_company='.urlencode($search_company); +} +if ($search_amount != '') { + $param .= '&search_amount='.urlencode($search_amount); +} +if ($search_payment_num) { + $param .= '&search_payment_num='.urlencode($search_payment_num); +} if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -305,10 +351,12 @@ if ($search_all) { $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$massactionbutton = ''; if ($massactionbutton) { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } +$moreforfilter = ''; print '
'; print ''; @@ -331,11 +379,12 @@ if (!empty($arrayfields['p.ref']['checked'])) { // Filter: Date if (!empty($arrayfields['p.datep']['checked'])) { print ''; }
'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { - print ''; - } - print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print '