Page 1 of 1

Reports Screen Shows Current Month as Last Month Under Specific Circumstances

Posted: Sun Nov 05, 2017 4:16 pm
by mkoch227
This issue was originally reported on the Mods for HESK issue tracker (https://gitlab.com/mike-koch/Mods-for-HESK/issues/587); however it applies to HESK as well.

When viewing the reports page, "Last Month" will be the current month if you are accessing the page on the 31st day of the month and the previous month does not have 31 days (i.e. viewing the reports page on October 31st will show last month as October as PHP tries to get the month for 2017-09-31, which rolls over to 2017-10-01).

A possible solution would be to set the current date to the first of the month, and then use strtotime('last month').

Re: Reports Screen Shows Current Month as Last Month Under Specific Circumstances

Posted: Sun Nov 05, 2017 8:25 pm
by Klemen
Thanks for the heads up.

It's a display issue only, the report date is then generated correctly. I will fix it by simply changing date('d') to 1 in the code:

Old:

Code: Select all

<option value="4" <?php echo $selected['time'][4]; ?>><?php echo $hesklang['r4']; ?> (<?php echo $hesklang['m'.date('n',mktime(0, 0, 0, date('m')-1, date('d'), date('Y')))]; ?>)</option>
New:

Code: Select all

<option value="4" <?php echo $selected['time'][4]; ?>><?php echo $hesklang['r4']; ?> (<?php echo $hesklang['m'.date('n',mktime(0, 0, 0, date('m')-1, 1, date('Y')))]; ?>)</option>
Same in export.php