forked from Dolibarr/dolibarr
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW : add date value filter on account records list
- Loading branch information
Showing
1 changed file
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ca53d3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace test on date using sql function MONTH and YEAR with something like this
if ($month > 0)
{
if ($year > 0)
$sql.= " AND d.dated BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else
$sql.= " AND date_format(d.dated, '%m') = '".$month."'";
}
else if ($year > 0)
{
$sql.= " AND d.dated BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
We must not use SQL date function (this creates bugs like timezone errors and is not portable). All dates search functions must be used by formatting on PHP side.
ca53d3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I change input by real date input.
The way I use to do was more "user friendly" because they can input in month 1,3,4 or/and a year. YEAR and MONTH are ported into pgsql function.
Anyway with two date input it's better because always compatible whatever database engine and more Dolibarr UX respectfull