Merge pull request #17789 from aspangaro/14b10

NEW Add field date from/to in customer payment list
This commit is contained in:
Laurent Destailleur 2021-06-29 19:54:12 +02:00 committed by GitHub
commit 04148dd5fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
@ -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 '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
@ -331,11 +379,12 @@ if (!empty($arrayfields['p.ref']['checked'])) {
// Filter: Date
if (!empty($arrayfields['p.datep']['checked'])) {
print '<td class="liste_titre center">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">';
}
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.dol_escape_htmltag($month).'">';
$formother->select_year($year ? $year : -1, 'year', 1, 20, 5);
print '<div class="nowrap">';
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
print '</td>';
}