issue #0001870 : Pagination control

This commit is contained in:
Michael RICOIS 2014-02-25 20:23:46 +00:00
parent 74d4d1c5eb
commit ac39a8e9ce
2 changed files with 34 additions and 21 deletions

View File

@ -274,8 +274,6 @@ class SurveillanceController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$position = $page * $nbAffichage;
//Pagination //Pagination
$page = $request->getParam('page', 1); $page = $request->getParam('page', 1);
if ( $page <= 0 ) $page = 1; if ( $page <= 0 ) $page = 1;
@ -375,7 +373,7 @@ class SurveillanceController extends Zend_Controller_Action
$nbReponses = $infos->nbReponses; $nbReponses = $infos->nbReponses;
$nbReponsesTotal = $infos->nbReponsesTotal; $nbReponsesTotal = $infos->nbReponsesTotal;
if ($nbReponses < $nbReponsesTotal) { if ($nbReponses < $nbReponsesTotal) {
$pageTotal = ceil( $nbReponsesTotal / $nbReponses ); $pageTotal = ceil( $nbReponsesTotal / $nbAffichage );
$pageCurrent = $page; $pageCurrent = $page;
$pagePrev = $page - 1; $pagePrev = $page - 1;
if ($pagePrev < 1) { if ($pagePrev < 1) {
@ -419,11 +417,11 @@ class SurveillanceController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
//Pagination
$page = $request->getParam('page', 1); $page = $request->getParam('page', 1);
if ( $page == 0 ) $page = 1; if ( $page <= 0 ) $page = 1;
$page = $page - 1; $nbAffichage = 50;
$nbAffichage = 100; $position = ($page - 1 ) * $nbAffichage;
$position = $page * $nbAffichage;
$siren = $request->getParam('siren', null); $siren = $request->getParam('siren', null);
if ( $siren == 'Siren' ) { $siren = null; } if ( $siren == 'Siren' ) { $siren = null; }
@ -587,16 +585,31 @@ class SurveillanceController extends Zend_Controller_Action
} }
} }
//Calcul pagination //Calcul pagination
$nbReponses = $infos->nbReponses; $nbReponses = $infos->nbReponses;
$nbSurveillances = $infos->nbReponsesTotal; $nbReponsesTotal = $infos->nbReponsesTotal;
$totPage = ceil($nbSurveillances/$nbAffichage); if ($nbReponses < $nbReponsesTotal) {
$curPage = ceil($position/$nbAffichage)+1; $pageTotal = ceil( $nbReponsesTotal / $nbAffichage );
$pageCurrent = $page;
$pagePrev = $page - 1;
if ($pagePrev < 1) {
$pagePrev = 1;
}
$pageNext = $page + 1;
if( $pageNext > $pageTotal ) {
$pageNext = $pageTotal;
}
} else {
$pageTotal = $pageCurrent = 1;
}
$this->view->assign('PageTotal', $pageTotal);
$this->view->assign('PagePrev', $pagePrev);
$this->view->assign('PageNext', $pageNext);
$this->view->assign('PageCurrent', $pageCurrent);
$this->view->assign('nbReponses', empty($nbReponses) ? 0 : $nbReponses);
$this->view->assign('nbSurveillances', $nbReponsesTotal);
$this->view->assign('nbReponses', $nbReponses);
$this->view->assign('nbSurveillances', $nbSurveillances);
$this->view->assign('totPage', $totPage);
$this->view->assign('curPage', $curPage);
$this->view->assign('portefeuille',$tabResult); $this->view->assign('portefeuille',$tabResult);
} }

View File

@ -133,14 +133,14 @@ Aucune surveillance Score.
<?php }?> <?php }?>
</div> </div>
<?php if ($this->totPage>1) {?> <?php if ($this->PageTotal>1) {?>
<div class="paragraph"> <div class="paragraph">
<div class="pagination clearfix"> <div class="pagination clearfix">
<a class="first" href="<?=$this->url(array('page'=>1))?>">&laquo;</a> <a class="first" href="<?=$this->url(array('page'=>1))?>">&laquo;</a>
<a class="previous" href="<?=$this->url(array('page'=>$this->curPage-1))?>">&lsaquo;</a> <a class="previous" href="<?=$this->url(array('page'=>$this->PagePrev))?>">&lsaquo;</a>
<span>Page <?=$this->curPage?>/<?=$this->totPage?></span> <span>Page <?=$this->PageCurrent?>/<?=$this->PageTotal?></span>
<a class="next" href="<?=$this->url(array('page'=>$this->curPage+1))?>">&rsaquo;</a> <a class="next" href="<?=$this->url(array('page'=>$this->PageNext))?>">&rsaquo;</a>
<a class="last" href="<?=$this->url(array('page'=>$this->totPage))?>">&raquo;</a> <a class="last" href="<?=$this->url(array('page'=>$this->PageTotal))?>">&raquo;</a>
</div> </div>
</div> </div>
<?php }?> <?php }?>