1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Fix for group by week on the dashboard

This commit is contained in:
Hillel Coren 2017-02-18 23:19:53 +02:00
parent 1619e893fa
commit f5e7d380a4

View File

@ -62,8 +62,15 @@ class DashboardRepository
foreach ($period as $d) {
$dateFormat = $groupBy == 'DAYOFYEAR' ? 'z' : ($groupBy == 'WEEK' ? 'W' : 'n');
// MySQL returns 1-366 for DAYOFYEAR, whereas PHP returns 0-365
$date = $groupBy == 'DAYOFYEAR' ? $d->format('Y').($d->format($dateFormat) + 1) : $d->format('Y'.$dateFormat);
if ($groupBy == 'DAYOFYEAR') {
// MySQL returns 1-366 for DAYOFYEAR, whereas PHP returns 0-365
$date = $d->format('Y') . ($d->format($dateFormat) + 1);
} elseif ($groupBy == 'WEEK' && ($d->format($dateFormat) < 10)) {
// PHP zero pads the week
$date = $d->format('Y') . round($d->format($dateFormat));
} else {
$date = $d->format('Y'.$dateFormat);
}
$records[] = isset($data[$date]) ? $data[$date] : 0;
if ($entityType == ENTITY_INVOICE) {