Skip to content
Snippets Groups Projects
Commit a6e66c68 authored by Tim Steiner's avatar Tim Steiner
Browse files

Added ucc reports to /ucc/reports/monthly/

parent d6eb36ec
No related branches found
No related tags found
No related merge requests found
......@@ -2727,5 +2727,100 @@ class Courses_CourseModel extends Unl_Model
$db->query($sql);
}
}
public function getDifferenceSummary(Courses_CourseModel $original = null, Requests_RequestModel $request = null)
{
if (!$original || $original == $this) {
if ($request && $request->getType() == 'NewCourseWithIS' ) {
return 'New Course With IS';
} else {
return 'New Course';
}
}
if ($this->getRemoved() && !$original->getRemoved()) {
return 'Remove Course';
}
$summary = array();
if ($this->getSubject() != $original->getSubject()) {
$summary[] = 'subject code';
}
if ($this->getCourseNumber() . $this->getCourseLetter() != $original->getCourseNumber() . $original->getCourseLetter()) {
$summary[] = '#';
}
if ($this->getTitle() != $original->getTitle()) {
$summary[] = 'title';
}
if ($this->getCrosslistingsText() != $original->getCrosslistingsText()) {
$summary[] = 'crosslist';
}
if ($this->getCreditsText() != $original->getCreditsText()) {
$summary[] = 'credit';
}
if ($this->getPrerequisite() != $original->getPrerequisite()) {
$summary[] = 'prereq';
}
if ($this->getDescription() != $original->getDescription()) {
$summary[] = 'descrip';
}
if ($this->getNotes() != $original->getNotes()) {
$summary[] = 'note';
}
$myGradTieIn = $this->getGradTieIn();
$originalGradTieIn = $original->getGradTieIn();
if ($myGradTieIn['credits'] != $originalGradTieIn['credits'] ||
$myGradTieIn['notes'] != $originalGradTieIn['notes'] ||
$myGradTieIn['prerequisites'] != $originalGradTieIn['prerequisites']) {
$summary[] = 'grad tie-in';
}
if ($this->getAceOutcomes() != $original->getAceOutcomes()) {
$summary[] = 'ace';
}
if ($this->getDeliveryMethods() != $original->getDeliveryMethods()) {
$summary[] = 'delivery';
}
if ($this->getTermsOffered() != $original->getTermsOffered()) {
$summary[] = 'terms';
}
if ($this->getCampuses() != $original->getCampuses()) {
$summary[] = 'campuses';
}
if ($this->getGradingType() != $original->getGradingType()) {
$summary[] = 'grading type';
}
if ($this->getActivityText() != $original->getActivityText()) {
$summary[] = 'activity';
}
if ($request && $request->getType() == 'AddISToCourse') {
$summary[] = 'IS';
}
$summary = implode('/', $summary);
$summary = ucfirst($summary);
return $summary;
}
}
......@@ -80,6 +80,34 @@ class Requests_ApprovalHistoryModel extends Unl_Model
return array_pop($objects);
}
}
static public function findRequestsWithinTimeRangeAndApprovalAction(Zend_Date $startTime,
Zend_Date $endTime,
Requests_ApprovalActionModel $action = null,
$decision = '')
{
$db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db);
$select->from(array('h' => 'creqApprovalHistories'), array('request'));
$select->where('h.time >= ?', $startTime->getTimestamp());
$select->where('h.time <= ?', $endTime->getTimestamp());
if ($action) {
$select->where('approvalAction = ?', $action->getId());
}
if ($decision) {
$select->where('decision = ?', $decision);
}
$records = $select->query()->fetchAll();
$requestIds = array();
foreach($records as $record) {
$requestIds[] = $record['request'];
}
return Requests_RequestModel::find($requestIds);
}
/**
* Gets a freshly created model object
......@@ -99,31 +127,31 @@ class Requests_ApprovalHistoryModel extends Unl_Model
'time' => null
);
$new = new self($data);
$new = new self($data);
$new->_setClean();
return $new;
return $new;
}
static public function save($models)
{
$modelsToInsert = new Unl_Model_Collection(__CLASS__);
$modelsToUpdate = new Unl_Model_Collection(__CLASS__);
if (!Unl_Util::isArray($models)) {
$model = $models;
$models = new Unl_Model_Collection(__CLASS__);
$models[$model->getId()] = $model;
}
foreach ($models as $model) {
if ($model->getId()) {
if ($model->_cleanData != $model->_data) {
$modelsToUpdate[] = $model;
}
} else {
$modelsToInsert[] = $model;
}
}
$modelsToUpdate = new Unl_Model_Collection(__CLASS__);
if (!Unl_Util::isArray($models)) {
$model = $models;
$models = new Unl_Model_Collection(__CLASS__);
$models[$model->getId()] = $model;
}
foreach ($models as $model) {
if ($model->getId()) {
if ($model->_cleanData != $model->_data) {
$modelsToUpdate[] = $model;
}
} else {
$modelsToInsert[] = $model;
}
}
if (count($modelsToInsert) > 0) {
self::_insert($modelsToInsert);
......@@ -141,7 +169,7 @@ class Requests_ApprovalHistoryModel extends Unl_Model
static protected function _update(Unl_Model_Collection $models)
{
$db = Zend_Registry::get('db');
$db = Zend_Registry::get('db');
$sql = 'CREATE TEMPORARY TABLE creqApprovalHistoriesUpdate '
. 'SELECT * FROM creqApprovalHistories LIMIT 0';
......@@ -149,8 +177,8 @@ class Requests_ApprovalHistoryModel extends Unl_Model
$sql = 'INSERT INTO creqApprovalHistoriesUpdate VALUES ';
$sqlParts = array();
foreach ($models as $model) {
$sqlParts[] = $db->quoteInto('(?, ', $model->_data['approvalHistoryId'])
foreach ($models as $model) {
$sqlParts[] = $db->quoteInto('(?, ', $model->_data['approvalHistoryId'])
. $db->quoteInto('?, ' , $model->_data['request'])
. $db->quoteInto('?, ' , $model->_data['approvalBody'])
. $db->quoteInto('?, ' , $model->_data['approvalBodyName'])
......@@ -158,13 +186,13 @@ class Requests_ApprovalHistoryModel extends Unl_Model
. $db->quoteInto('?, ' , $model->_data['approvalActionName'])
. $db->quoteInto('?, ' , $model->_data['decision'])
. $db->quoteInto('?)' , $model->_data['time']);
}
$sql .= implode(', ', $sqlParts);
$db->query($sql);
}
$sql .= implode(', ', $sqlParts);
$db->query($sql);
$sql = 'UPDATE creqApprovalHistories AS a, '
. ' creqApprovalHistoriesUpdate AS b '
. 'SET a.request = b.request, '
$sql = 'UPDATE creqApprovalHistories AS a, '
. ' creqApprovalHistoriesUpdate AS b '
. 'SET a.request = b.request, '
. ' a.approvalBody = b.approvalBody, '
. ' a.approvalBodyName = b.approvalBodyName, '
. ' a.approvalAction = b.approvalAction, '
......@@ -179,7 +207,7 @@ class Requests_ApprovalHistoryModel extends Unl_Model
{
$db = Zend_Registry::get('db');
$sql = 'INSERT INTO creqApprovalHistories (request, approvalBody, approvalBodyName, approvalAction, approvalActionName, decision, time) VALUES ';
$sql = 'INSERT INTO creqApprovalHistories (request, approvalBody, approvalBodyName, approvalAction, approvalActionName, decision, time) VALUES ';
$sqlParts = array();
foreach ($models as $model) {
$sqlParts[] = $db->quoteInto('(?, ', $model->_data['request'])
......@@ -218,7 +246,7 @@ class Requests_ApprovalHistoryModel extends Unl_Model
public function getId()
{
return $this->_data['approvalHistoryId'];
return $this->_data['approvalHistoryId'];
}
public function getRequest()
......@@ -228,7 +256,7 @@ class Requests_ApprovalHistoryModel extends Unl_Model
public function setRequest(Requests_RequestModel $request)
{
$this->_data['request'] = $request->getId();
$this->_data['request'] = $request->getId();
}
public function getApprovalBody()
......@@ -279,13 +307,13 @@ class Requests_ApprovalHistoryModel extends Unl_Model
*/
public function getTime()
{
$time = new Zend_Date($this->_data['time']);
return $time;
$time = new Zend_Date($this->_data['time']);
return $time;
}
public function getUnixtime()
{
return $this->_data['time'];
return $this->_data['time'];
}
/**
......@@ -295,6 +323,6 @@ class Requests_ApprovalHistoryModel extends Unl_Model
*/
public function setTime(Zend_Date $time)
{
$this->_data['time'] = $time->getTimestamp();
$this->_data['time'] = $time->getTimestamp();
}
}
<?php
class Ucc_ReportsController extends App_Controller_Action
{
public function indexAction()
{
$this->_redirect('/ucc/reports/monthly');
}
public function monthlyAction()
{
$year = $this->_getParam('year');
$month = $this->_getParam('month');
if (!$year && !$month) {
$startDate = new Zend_Date();
$startDate->setYear(2008);
$startDate->setMonth(9);
$startDate->setDay(15);
$startDate->setHour(0);
$startDate->setMinute(0);
$startDate->setSecond(0);
$endDate = new Zend_Date();
$this->view->startDate = $startDate;
$this->view->endDate = $endDate;
$this->render('select-date');
return;
}
$startDate = new Zend_Date();
$startDate->setYear($year);
$startDate->setMonth($month);
$startDate->setDay(1);
$startDate->setHour(0);
$startDate->setMinute(0);
$startDate->setSecond(0);
$endDate = clone $startDate;
$endDate->addMonth(1);
$approvalAction = Requests_ApprovalActionModel::find(31);
$requests = Requests_ApprovalHistoryModel::findRequestsWithinTimeRangeAndApprovalAction($startDate, $endDate, $approvalAction);
$histories = Requests_ApprovalHistoryModel::findByRequest($requests);
$currentCourses = Courses_CourseModel::findLatestOfRequest($requests);
$originalCourses = Courses_CourseModel::findParentOfRequest($requests);
$data = new Unl_Model_Collection('Unl_Model_Array');
foreach ($requests as $request) {
$currentCourse = $currentCourses[$request->getId()];
$originalCourse = $originalCourses[$request->getId()];
$history = $histories[$request->getId()];
foreach ($history as $aHistory) {
if ($aHistory->getApprovalAction() != 31) {
continue;
}
if ($startDate->isLater($aHistory->getTime()) ||
$endDate->isEarlier($aHistory->getTime())) {
continue;
}
$time = $aHistory->getTime();
}
if (!$originalCourse) {
$originalCourse = $currentCourse;
}
$difference = $currentCourse->getDifferenceSummary($originalCourse, $request);
$data[] = new Unl_Model_Array(array(
'time' => $time->getTimestamp(),
'college' => $originalCourse->getCollege(),
'courseCode' => $originalCourse->getCourseCode(),
'title' => $originalCourse->getTitle(),
'difference' => $difference,
'IS' => $originalCourse->isIntegratedStudies(),
'crosslist' => $originalCourse->getCrosslistingsText()
));
}
$session = new Zend_Session_Namespace(__CLASS__);
$sortBy = $session->sortBy;
if (!Unl_Util::isArray($sortBy)) {
$sortBy = array();
}
if ($this->_getParam('sort')) {
if (($key = array_search($in->sort, $sortBy)) !== FALSE) {
unset($sortBy[$key]);
}
$sortBy[] = $this->_getParam('sort');
}
$session->sortBy = $sortBy;
foreach ($sortBy as $sortKey) {
$data->orderBy('get' . $sortKey);
}
$this->view->data = $data;
}
}
<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/iace/reports/weekly.css', 'all'); ?>
<table>
<tr>
<th><a href="<?php echo $this->url(array('sort' => 'time')); ?>">Date Approved</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'college')); ?>">College</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'courseCode')); ?>">Dept/Course #</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'title')); ?>">title</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'difference')); ?>">Action Requested</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'is')); ?>">IS</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'es')); ?>">ES Section</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'SF')); ?>">SF</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'crosslist')); ?>">X-list</a></th>
</tr>
<?php foreach ($this->data as $row) { ?>
<tr>
<td><?php echo date('m/d/Y', $row->getTime())?></td>
<td><?php echo $row->getCollege(); ?></td>
<td><?php echo $row->getCourseCode(); ?></td>
<td><?php echo $row->getTitle(); ?></td>
<td><?php echo $row->getDifference(); ?></td>
<td><?php if($row->getIS()) echo 'Yes'; ?></td>
<td>?</td>
<td>?</td>
<td><?php echo $row->getCrosslist(); ?></td>
</tr>
<?php } ?>
</table>
\ No newline at end of file
<h2>Please select a month to report on</h2>
<ul>
<?php for(; $this->startDate->isEarlier($this->endDate); $this->startDate->addMonth(1)) { ?>
<li>
<a href="<?php echo $this->url(array('month' => date('n', $this->startDate->getTimestamp()),
'year' => date('Y', $this->startDate->getTimestamp()))); ?>">
<?php echo date('n/Y', $this->startDate->getTimestamp()); ?>
</a>
</li>
<?php } ?>
</ul>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment