NEW filter on reception dates (from / to) in cheque paiement card

This commit is contained in:
lvessiller 2022-08-08 14:56:28 +02:00
parent f56abb1e5f
commit 0e0c297ed5

View File

@ -59,8 +59,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits";
$filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear'));
// filter by dates from / to
$search_date_start_day = GETPOST('search_date_start_day', 'int');
$search_date_start_month = GETPOST('search_date_start_month', 'int');
$search_date_start_year = GETPOST('search_date_start_year', 'int');
$search_date_end_day = GETPOST('search_date_end_day', 'int');
$search_date_end_month = GETPOST('search_date_end_month', 'int');
$search_date_end_year = GETPOST('search_date_end_year', 'int');
$search_date_start = dol_mktime(0, 0, 0, $search_date_start_month, $search_date_start_day, $search_date_start_year);
$search_date_end = dol_mktime(23, 59, 59, $search_date_end_month, $search_date_end_day, $search_date_end_year);
$filteraccountid = GETPOST('accountid', 'int');
// Security check
@ -265,7 +272,15 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) {
*/
if (GETPOST('removefilter')) {
$filterdate = '';
// filter by dates from / to
$search_date_start_day = '';
$search_date_start_month = '';
$search_date_start_year = '';
$search_date_end_day = '';
$search_date_end_month = '';
$search_date_end_year = '';
$search_date_start = '';
$search_date_end = '';
$filteraccountid = 0;
}
@ -352,7 +367,13 @@ if ($action == 'new') {
//print '<tr><td width="30%">'.$langs->trans('Date').'</td><td width="70%">'.dol_print_date($now,'day').'</td></tr>';
// Filter
print '<tr><td class="titlefieldcreate">'.$langs->trans("DateChequeReceived").'</td><td>';
print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1);
// filter by dates from / to
print '<div class="nowrap">';
print $form->selectDate($search_date_start, 'search_date_start_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_end, 'search_date_end_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
print '</td></tr>';
print '<tr><td>'.$langs->trans("BankAccount").'</td><td>';
$form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1);
@ -363,7 +384,7 @@ if ($action == 'new') {
print '<div class="center">';
print '<input type="submit" class="button" name="filter" value="'.dol_escape_htmltag($langs->trans("ToFilter")).'">';
if ($filterdate || $filteraccountid > 0) {
if ($search_date_start || $search_date_end || $filteraccountid > 0) {
print ' &nbsp; ';
print '<input type="submit" class="button" name="removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
}
@ -382,8 +403,11 @@ if ($action == 'new') {
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.fk_bordereau = 0";
$sql .= " AND b.amount > 0";
if ($filterdate) {
$sql .= " AND b.dateo = '".$db->idate($filterdate)."'";
if ($search_date_start) {
$sql .= " AND b.dateo >= '".$db->idate($search_date_start)."'";
}
if ($search_date_end) {
$sql .= " AND b.dateo <= '".$db->idate($search_date_end)."'";
}
if ($filteraccountid > 0) {
$sql .= " AND ba.rowid = ".((int) $filteraccountid);