diff --git a/application/controllers/HomeController.php b/application/controllers/HomeController.php index b43b6e9429cc117a9e18f9f69186d244ec2e2218..15efab75bb7b3a2d11e237d1e870f127fbe35007 100644 --- a/application/controllers/HomeController.php +++ b/application/controllers/HomeController.php @@ -77,6 +77,14 @@ class HomeController extends Nmc_Controller_Action $rolesData[] = $roleData; } + $requestOrder = array(); + foreach($rolesData as $roleData) { + foreach($roleData['requests'] as $request) { + $requestOrder[] = $request->getPrimaryKey(); + } + } + Nmc_Registry_Session::getInstance('requests')->order = $requestOrder; + $out = new Application_View(); $out->user = $user; $out->roles = $rolesData; diff --git a/application/controllers/RequestController.php b/application/controllers/RequestController.php index bfdda601c3902efcc22f9336cb3b941f365bc228..a50b0723e9e0a348f9a6458f0e914c80a0908c51 100755 --- a/application/controllers/RequestController.php +++ b/application/controllers/RequestController.php @@ -165,12 +165,30 @@ class RequestController extends Nmc_Controller_Action $time = new Zend_Date(); RequestViewTimes::getInstance()->setViewTimeForUserAndRequest($user, $request, $time); + $requestOrder = Nmc_Registry_Session::getInstance('requests')->order; + $currentRequestIndex = array_search($request->getPrimaryKey(), $requestOrder); + if ($currentRequestIndex !== false) { + $nextRequestId = $requestOrder[$currentRequestIndex+1]; + $prevRequestId = $requestOrder[$currentRequestIndex-1]; + + if ($currentRequestIndex == 0) { + $prevRequestId = -1; + } else if ($currentRequestIndex == count($requestOrder)) { + $nextRequestId = -1; + } + } else { + $nextRequestId = -1; + $prevRequestId = -1; + } + $view = new Application_View(); $view->page = 'request/view'; $view->request = $request; $view->currentGeneration = $currentGeneration; $view->proposedGeneration = $proposedGeneration; $view->comments = $comments; + $view->nextRequestId = $nextRequestId; + $view->prevRequestId = $prevRequestId; $view->tagline = 'View Request'; $view->addHelperPath(APPLICATION_PATH . '/library/View/Helper', 'Application_View_Helper'); diff --git a/application/views/request/view.xhtml b/application/views/request/view.xhtml index 472ad49bb84abb101befd120444bb8ef8caa70e6..a3d2a1a8b3af1bd8b8e6e3b13a2a007710d190b0 100644 --- a/application/views/request/view.xhtml +++ b/application/views/request/view.xhtml @@ -154,6 +154,12 @@ </form> </div> </div> + <?php if ($this->prevRequestId > 0) { ?> + <a id="prevRequestLink" href="/Request/View/<?php echo $this->prevRequestId; ?>"><--Prev</a> + <?php } ?> + <?php if ($this->nextRequestId > 0) { ?> + <a id="nextRequestLink" href="/Request/View/<?php echo $this->nextRequestId; ?>">Next--></a> + <?php } ?> <?php } ?> <div class="clear"></div> diff --git a/document_root/css/request/view.oss b/document_root/css/request/view.oss index 06f55f1b07689bc35a9bfbbdb4dab660e9809018..ba4e361bce98f2d3a4b7b5787e58a5ac61096f36 100644 --- a/document_root/css/request/view.oss +++ b/document_root/css/request/view.oss @@ -94,3 +94,10 @@ div#comments { display: none; } } + +#prevRequestLink { + float: left; +} +#nextRequestLink { + float: right; +} \ No newline at end of file