From a6072f5d9fb7b0920554dcac406a0fbc8cba4f33 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Wed, 16 Dec 2009 17:09:50 +0000 Subject: [PATCH] Added an annual csv report to the UCC module. --- .../ucc/controllers/ReportsController.php | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/application/modules/ucc/controllers/ReportsController.php b/application/modules/ucc/controllers/ReportsController.php index f930d03e..567e08a8 100644 --- a/application/modules/ucc/controllers/ReportsController.php +++ b/application/modules/ucc/controllers/ReportsController.php @@ -48,13 +48,53 @@ class Ucc_ReportsController extends App_Controller_Action } } + public function annualAction() + { + $year = $this->_getParam('year'); + + $startDate = new Zend_Date(); + $startDate->setYear($year); + $startDate->setMonth(1); + $startDate->setDay(1); + $startDate->setHour(0); + $startDate->setMinute(0); + $startDate->setSecond(0); + + $endDate = clone $startDate; + $endDate->addMonth(1); + + $data = new Unl_Model_Collection('Unl_Model_Array'); + for ($i = 0; $i < 12; $i++) { + $data->merge($this->_getSummaryData($startDate, $endDate, 31), TRUE); + $data->merge($this->_getSummaryData($startDate, $endDate, 313), TRUE); + $data->merge($this->_getSummaryData($startDate, $endDate, 325), TRUE); + + $startDate->addMonth(1); + $endDate->addMonth(1); + } + + echo '"Date","College","Course Code","Type","Result"'. PHP_EOL; + + foreach ($data as $row) { + echo '"' . date('m-d-y', $row->getTime()) . '",' + . '"' . $row->getCollege() . '",' + . '"' . $row->getCourseCode() . '",' + . '"' . $row->getType() . '",' + . '"' . ($row->getVoteResult() == 'Approve' ? 'Approved' : 'Not Approved') . '"' + . PHP_EOL; + } + + header('Content-Disposition: attachment; filename="UCC ' . $year . ' Report.csv"'); + + exit; + } + protected function _monthlySummaryReport($startDate, $endDate) { $this->view->data = $this->_getSummaryData($startDate, $endDate, 31); $this->view->aceData = $this->_getSummaryData($startDate, $endDate, 313); $this->view->aceData->merge($this->_getSummaryData($startDate, $endDate, 325), TRUE); - $this->render('monthly-summary'); } @@ -109,7 +149,8 @@ class Ucc_ReportsController extends App_Controller_Action 'esAreas' => $originalCourse->getEssentialStudiesAreas(), 'crosslist' => $originalCourse->getCrosslistingsText(), 'course' => $originalCourse->getCourseId(), - 'voteResult' => $voteResult + 'voteResult' => $voteResult, + 'type' => $request->getTypeDescription() )); } -- GitLab