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

iACE Weekly Reports, now with sorting!

parent 639a4573
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,8 @@ class Iace_ReportsController extends App_Controller_Action
$validators = array(
'year' => 'Digits',
'month' => 'Digits',
'day' => 'Digits'
'day' => 'Digits',
'sort' => 'Alpha'
);
$in = new Zend_Filter_Input($filters, $validators, $this->_getAllParams());
if ($in->isValid()) {
......@@ -53,23 +54,40 @@ class Iace_ReportsController extends App_Controller_Action
$requests = Requests_RequestModel::find($requestIds);
$courses = Courses_CourseModel::findLatestOfRequest($requests);
$courses->orderBy('getCourseCode');
//$courses->orderBy('getCourseCode');
$data = array();
$data = new Unl_Model_Collection('Unl_Model_Array');
foreach ($courses as $requestId => $course) {
$request = $requests[$requestId];
$finalizeTime = $finalizeTimes[$request->getId()];
foreach ($course->getAceOutcomes() as $aceOutcome) {
$data[] = array(
$data[] = new Unl_Model_Array(array(
'slo' => substr($aceOutcome['slo'], 3),
'courseCode' => $course->getCourseCode(),
'college' => $course->getCollege(),
'title' => $course->getTitle(),
'finalizeTime' => $finalizeTime
);
));
}
}
$session = new Zend_Session_Namespace(__CLASS__);
$sortBy = $session->sortBy;
if (!Unl_Util::isArray($sortBy)) {
$sortBy = array();
}
if ($in->sort) {
if (($key = array_search($in->sort, $sortBy)) !== FALSE) {
unset($sortBy[$key]);
}
$sortBy[] = $in->sort;
}
$session->sortBy = $sortBy;
foreach ($sortBy as $sortKey) {
$data->orderBy('get' . $sortKey);
}
//$this->_helper->layout->disableLayout();
$this->_helper->layout->setLayout('naked-layout');
$this->view->data = $data;
......
......@@ -10,19 +10,19 @@
<table>
<tr>
<th>SLO</th>
<th>Course</th>
<th>College</th>
<th>Title</th>
<th>Certified</th>
<th><a href="<?php echo $this->url(array('sort' => 'slo')); ?>">SLO</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'course')); ?>">Course</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'college')); ?>">College</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'title')); ?>">Title</a></th>
<th><a href="<?php echo $this->url(array('sort' => 'finalizeTime')); ?>">Certified</a></th>
</tr>
<?php foreach ($this->data as $record) { ?>
<tr <?php if ($rowCount++ % 2) { ?>class="even"<?php } ?>>
<td><?php echo $record['slo']; ?></td>
<td><?php echo $record['courseCode']; ?></td>
<td><?php echo $record['college']; ?></td>
<td><?php echo $record['title']; ?></td>
<td><?php echo date('n/j/Y', $record['finalizeTime']); ?></td>
<td><?php echo $record->getSlo(); ?></td>
<td><?php echo $record->getCourseCode(); ?></td>
<td><?php echo $record->getCollege(); ?></td>
<td><?php echo $record->getTitle(); ?></td>
<td><?php echo date('n/j/Y', $record->getFinalizeTime()); ?></td>
</tr>
<? } ?>
</table>
\ No newline at end of file
<?php
class Unl_Model_Array extends Unl_Model
{
public function __construct($data)
{
$filteredData = array();
foreach ($data as $key => $value) {
$filteredData[strtolower($key)] = $value;
}
parent::__construct($filteredData);
}
public function getId()
{
return null;
}
public function __call($name, $arguments) {
if (substr($name, 0, 3) == 'get') {
$key = strtolower(substr($name, 3));
return $this->_data[$key];
}
throw new Zend_Exception('Call to undefined method');
}
}
\ No newline at end of file
......@@ -123,7 +123,7 @@ class Unl_Model_Collection implements Iterator, Countable, ArrayAccess
$valuesToSortOn[] = $model->$method();
$modelKeys[] = $key;
}
$valuesToSortOn = array_map('strtolower', $valuesToSortOn);
$valuesToSortOn = array_map('strtolower', $valuesToSortOn);;
array_multisort($valuesToSortOn, $modelKeys);
$sortedModels = array();
foreach ($modelKeys as $modelKey) {
......@@ -131,7 +131,7 @@ class Unl_Model_Collection implements Iterator, Countable, ArrayAccess
}
$this->_models = $sortedModels;
}
public function arrayFromMethod($method)
{
$data = array();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment