public function savereportAction() { // save the edited report or create a new one as of now $model = $this->byId(null, 'ProjectStatus'); $pid = isset($model->projectid) ? $model->projectid : $this->_getParam('projectid'); $project = $this->byId($pid); if ($model == null) { // see if there's a 'to/from' date structure to pass for the status report generation $model = $this->projectService->getProjectStatus($project); } // Save away! $model->bind($this->filterParams($this->_getAllParams())); $this->projectService->saveStatus($model); $this->redirect('project', 'editReport', array('id' => $model->id)); }
public function execute() { return; // go through each project that has reportgeneration = true $projects = $this->projectService->getProjects(array('enablereports=' => 1)); $userProjectMapping = new ArrayObject(); foreach ($projects as $project) { /* @var $project Project */ // Create the status report and notify the manager to go and check it out $report = $this->projectService->getProjectStatus($project); $report->title = "Report generated " . date('Y-m-d'); $report->completednotes = "TO BE FILLED IN BY " . $project->manager; $report->todonotes = "TO BE FILLED IN BY " . $project->manager; $this->projectService->saveStatus($report); // email the manager! $userProjects = ifset($userProjectMapping, $project->manager, array()); $userProjects[] = $project; $userProjectMapping[$project->manager] = $userProjects; } foreach ($userProjectMapping as $user => $projects) { $msg = new TemplatedMessage('status-report-created.php', array('projects' => $projects)); $this->notificationService->notifyUser('Project status reports reminder', $user, $msg); } }