diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 4536cb98520..63e7adcc4c2 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -7,6 +7,7 @@ * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2018 Charlene Benke * * 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 @@ -163,19 +164,8 @@ 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))."'"; - } + $sql.= dol_sql_datefilter("p.datep", $day, $month, $year); + if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'";