It's in the latest, Version 1.0.. Drupal 5.8.. All of tje July sales are showing up under August 2008, is there any more info you need to help diagnose this?
And oddly enough, when you click the August 2008 month which has totals besides it, no orders show up, but clicking the July 2008 column, the July orders show up.. it's just on the Sales Per Year page I'm seeing this behavior..
Turns out, the default time zone in Drupal wasn't set on this site, no idea why that was causing sales to be off by a month for that one report though..
Aye, that is weird... seems it should've been off uniformly. Honestly, there's some strange code-fu going on in the reports module. I have a hunch the way data is collected and organized needs to be reworked during the D6 development. I am glad you got to the bottom of this issue, though.
Aye, that is weird... seems it should've been off uniformly. Honestly, there's some strange code-fu going on in the reports module. I have a hunch the way data is collected and organized needs to be reworked during the D6 development. I am glad you got to the bottom of this issue, though.
The voodoo code from the reports.module file, from the uc_reports_sales_year callback function:
for ($i = 1; $i <= 12; $i++) {
// Calculate the start and end timestamps for the month in local time.
$month_start = gmmktime(0, 0, 0, $i, 1, $year) - $timezone_offset;
$month_end = gmmktime(23, 59, 59, $i + 1, 0, $year) - $timezone_offset;
// Get the sales report for the month.
$month_sales = _uc_reports_get_sales($month_start, 'month');
// Calculate the average order total for the month.
if ($month_sales['total'] != 0) {
$month_average = round($month_sales['income'] / $month_sales['total'], 2);
}
else {
$month_average = 0;
}
// Add the month's row to the report table.
$rows[] = array(
l(gmdate('M Y', $month_start), 'admin/store/orders/search/results/0/0/0/0/0/0/'. $month_start .'/'. $month_end),
$month_sales['total'],
uc_currency_format($month_sales['income']),
uc_currency_format($month_average),
);
// Add the data to the CSV export.
$csv_rows[] = array(
gmdate('M Y', $month_start),
$month_sales['total'],
uc_currency_format($month_sales['income']),
uc_currency_format($month_average),
);
}
===================
I suspect the glitch comes about from these lines:
the 2nd line seems to reference a day 0 on the next monh (which could be month 13 when the $month_start is in December..) so what does gmmktime do with a 0 day and a 13th month, would be the question here.. =)
Would the 13th month show the first month of the next year..?
Since the time zone not being set DID cause things to display in the next month, is there a better way we can call those functions so things don't jump a whole month if the time zone isn't set? =)
Would the 13th month show the first month of the next year..?
Just found this while googling the functions, in the php manual:
mktime() is useful for doing date arithmetic and validation, as it will automatically calculate the correct value for out-of-range input. For example, each of the following lines produces the string "Jan-01-1998".
"The last day of any given month can be expressed as the "0" day of the next month, not the -1 day. Both of the following will produce the string "The last day in Feb 2000 is: 29".
<?php $lastday = mktime(0, 0, 0, 3, 0, 2000); echo strftime("Last day in Feb 2000 is: %d", $lastday); $lastday = mktime(0, 0, 0, 4, -31, 2000); echo strftime("Last day in Feb 2000 is: %d", $lastday); ?>
According to what I've read, the 0th day of the next month is the last day of the month.. so the could SHOULD be working as far as I can tell.. Any ideas?
I'm seeing my reports off by one. My Month to Date label shows November (and this is December). Below that line it says Daily Average for November and it and should say December.
The sales dates are also off by a number of hours that I have not yet discerned the pattern to.
I'm seeing nearly all the issues reported above. I'm in 5.19. Are you all sure this is fixed? I tried to look in the demo but that site is down.