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

Add a page listing withdrawn requests.

parent 994a44eb
No related branches found
No related tags found
No related merge requests found
<?php
class Requests_WithdrawnController extends App_Controller_Action
{
public function preDispatch()
{
$user = Auth_UserModel::findCurrentUser();
$roles = Auth_GroupModel::findByUser($user);
if (!in_array(1, $roles->getId())) {
throw new Exception('You must be logged in to view this page.');
}
}
public function indexAction()
{
$requests = Requests_RequestModel::findByState('Withdraw');
$requestCourses = Courses_CourseModel::findLatestOfRequest($requests);
$this->view->requests = $requests;
$this->view->requestCourses = $requestCourses;
}
}
......@@ -284,6 +284,23 @@ class Requests_RequestModel extends Unl_Model
return $objects[$userId];
}
}
static public function findByState($state)
{
$db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db);
$select->from(array('r' => 'creqRequests'), 'requestId');
$select->where('r.state = ?', $state);
$data = $select->query()->fetchAll();
$requestIds = array();
foreach ($data as $row) {
$requestIds[] = $row['requestId'];
}
return self::find($requestIds);
}
static protected function _loadTypeMap()
{
......
<?php $this->layout()->breadcrumbs = array('Withdrawn Requests'); ?>
<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/requests/withdrawn.css', 'all'); ?>
<table>
<tr>
<th>Course</th>
<th>Submitter</th>
<th>Date</th>
</tr>
<?php
$this->requests->orderBy('getLastApprovalTimestamp', SORT_DESC);
foreach ($this->requests as $request) {
$course = $this->requestCourses[$request->getId()];
?>
<tr>
<td>
<a href="<?php echo $this->baseUrl(); ?>/requests/view/index/id/<?php echo $request->getId(); ?>">
<?php echo $course->getCourseCode(); ?>
</a>
</td>
<td><?php echo $request->getOwnerModel()->getFirstName() . ' ' . $request->getOwnerModel()->getLastName(); ?></td>
<td><?php echo date('Y-m-d', $request->getLastApprovalTimestamp()); ?></td>
</tr>
<?php } ?>
</table>
\ No newline at end of file
@CHARSET "UTF-8";
#maincontent table {border: 1px solid #000;}
#maincontent th,
#maincontent td {border: 1px solid #000; padding: 0.25em;}
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