When creating a PDF report and setting the email schedule the text says
Weekly schedule: report will be sent the first Monday of each week.
Monthly schedule: report will be sent the first day of each month.
This doesn’t seem to happen.
I have set up a cron job to run every hour and found that:
a new pdf report is emailed when the cron job is next run
then, for a weekly report, it seems to be scheduled for one week later, not on the next Monday
for a monthly report, seems to be scheduled for one month later, not on the first day of the month
I have looked at the code in plugins/PDFReports/PDFReports.php at method getScheduledTasks()
[size=8pt] function getScheduledTasks ( $notification )
{
$tasks = &$notification->getNotificationObject();
$tasks[] = new Piwik_ScheduledTask ( $this, ‘dailySchedule’, new Piwik_ScheduledTime_Daily() );
$tasks[] = new Piwik_ScheduledTask ( $this, ‘weeklySchedule’, new Piwik_ScheduledTime_Weekly() );
$tasks[] = new Piwik_ScheduledTask ( $this, ‘monthlySchedule’, new Piwik_ScheduledTime_Monthly() );
}[/size]
I think that the scheduled tasks need to set hour/day/week so that the PDF reports are generated at the expected times.
set Hour to be 1 (for 1:00 am) for each scheduled task
set Day to be 1 (this is actually day of week, 1 = Monday) for the weekly task
But it is not clear how to make the monthly task run on the first day of the month, as Piwik_ScheduledTime_Monthly does not provide a method to set that. We can set only the hour/day of week/week of month. The lines below for $daily and $weekly have the correct effect but $monthly doesn’t.
[size=8pt] function getScheduledTasks ( $notification )
{
$tasks = &$notification->getNotificationObject();[/size]
[size=8pt] $daily = new Piwik_ScheduledTime_Daily();
$daily->setHour(1);
$tasks[] = new Piwik_ScheduledTask ( $this, ‘dailySchedule’, $daily);[/size]
[size=8pt] $weekly = new Piwik_ScheduledTime_Weekly();
$weekly->setHour(1);
$weekly->setDay(1);
$tasks[] = new Piwik_ScheduledTask ( $this, ‘weeklySchedule’, $weekly);[/size]
[size=8pt] $monthly = new Piwik_ScheduledTime_Monthly();
$monthly->setHour(1);
$monthly->setDay(1);
$monthly->setWeek(1);
$tasks[] = new Piwik_ScheduledTask ( $this, ‘monthlySchedule’, $monthly);
}[/size]
I have looked in the forums and also in Trac and cannot see any issue addressing this problem.