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

Add vote result to UCC extended report.

parent dd0776c2
No related branches found
No related tags found
No related merge requests found
<?php
class Ucc_ReportsController extends App_Controller_Action
class Ucc_ReportsController extends App_Controller_Action
{
public function indexAction()
{
......@@ -84,26 +84,7 @@ class Ucc_ReportsController extends App_Controller_Action
$difference = $currentCourse->getDifferenceSummary($originalCourse, $request);
$voteTally = array();
$voteResult = '';
$voteCount = 0;
foreach ($votes as $vote) {
if ($vote->getTime()->isLater($endDate)) {
continue;
}
if ($vote->getTime()->isEarlier($startDate)) {
continue;
}
$voteTally[$vote->getVote()]++;
$voteCount++;
if ($voteTally[$vote->getVote()] == max($voteTally)) {
$voteResult = $vote->getVote();
}
}
if ($voteCount < 7 || $voteTally['Table'] >= 2) {
$voteResult = 'Table';
}
$voteResult = $this->_tallyVotes($votes, $startDate, $endDate);
$data[] = new Unl_Model_Array(array(
'time' => $time->getTimestamp(),
......@@ -148,12 +129,13 @@ class Ucc_ReportsController extends App_Controller_Action
$histories = Requests_ApprovalHistoryModel::findByRequest($requests);
$this->view->requests = $requests;
$this->view->requests = $requests;
$this->view->currentCourses = Courses_CourseModel::findLatestOfRequest($requests);
$this->view->originalCourses = Courses_CourseModel::findParentOfRequest($requests);
$requestVotes = Requests_ApproverVoteModel::findVotesForRequests($requests, $approvalAction);
$requestVoteTally = array();
$requestVoteResults = array();
foreach ($requestVotes as $requestId => $votes) {
foreach ($votes as $vote) {
if ($vote->getTime()->isLater($endDate)) {
......@@ -164,9 +146,39 @@ class Ucc_ReportsController extends App_Controller_Action
}
$requestVoteTally[$requestId][$vote->getVote()]++;
}
$requestVoteResults[$requestId] = $this->_tallyVotes($votes, $startDate, $endDate);
}
$this->view->requestVoteTally = $requestVoteTally;
$this->view->requestVoteTally = $requestVoteTally;
$this->view->requestVoteResults = $requestVoteResults;
$this->render('monthly-extended');
}
protected function _tallyVotes($votes, $startDate, $endDate)
{
$voteTally = array();
$voteResult = '';
$voteCount = 0;
foreach ($votes as $vote) {
if ($vote->getTime()->isLater($endDate)) {
continue;
}
if ($vote->getTime()->isEarlier($startDate)) {
continue;
}
$voteTally[$vote->getVote()]++;
$voteCount++;
if ($voteTally[$vote->getVote()] == max($voteTally)) {
$voteResult = $vote->getVote();
}
}
if ($voteCount < 7 || $voteTally['Table'] >= 2) {
$voteResult = 'Table';
}
return $voteResult;
}
}
......@@ -6,7 +6,7 @@
</div>
<?php foreach ($this->requests as $request) { ?>
<div class="request"
<div class="request">
<h2>Request Type: <?php echo $request->getTypeDescription(); ?></h2>
<?php echo $this->partial('view/course-info.phtml',
'courses',
......@@ -23,5 +23,6 @@
<li><?php echo $voteLabel . ': ' . $voteCount; ?></li>
<?php } ?>
</ul>
<div>Result: <?php echo $this->requestVoteResults[$request->getId()]; ?></div>
</div>
<?php } ?>
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