function executeCron($includeList = array()) { $this->loadCronJobTools($includeList); $lastGenerated = date('Y-m-d 00:00:00'); $userCtrler = new UserController(); $userList = $userCtrler->__getAllUsers(); foreach ($userList as $userInfo) { // create report controller $reportCtrler = new ReportController(); $lastGenerated = mktime(0, 0, 0, date('m'), date('d'), date('Y')); // check for user report schedule $repSetInfo = $reportCtrler->isGenerateReportsForUser($userInfo['id']); if (!empty($repSetInfo['generate_report'])) { $websiteCtrler = new WebsiteController(); $websiteList = $websiteCtrler->__getAllWebsites($userInfo['id']); // if websites are available if (count($websiteList) > 0) { foreach ($websiteList as $websiteInfo) { $this->websiteInfo = $websiteInfo; $this->routeCronJob($websiteInfo['id'], '', true); } // save report generated time $reportCtrler->updateUserReportSetting($userInfo['id'], 'last_generated', $lastGenerated); // send email notification if enabled if (SP_REPORT_EMAIL_NOTIFICATION && $repSetInfo['email_notification']) { $reportCtrler->sentEmailNotificationForReportGen($userInfo, $repSetInfo['last_generated'], $lastGenerated); } } } } }