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();
$position = $page * $nbAffichage;
//Pagination
$page = $request->getParam('page', 1);
if ( $page <= 0 ) $page = 1;
@ -375,7 +373,7 @@ class SurveillanceController extends Zend_Controller_Action
$nbReponses = $infos->nbReponses;
$nbReponsesTotal = $infos->nbReponsesTotal;
if ($nbReponses < $nbReponsesTotal) {
$pageTotal = ceil( $nbReponsesTotal / $nbReponses );
$pageTotal = ceil( $nbReponsesTotal / $nbAffichage );
$pageCurrent = $page;
$pagePrev = $page - 1;
if ($pagePrev < 1) {
@ -419,11 +417,11 @@ class SurveillanceController extends Zend_Controller_Action
$request = $this->getRequest();
//Pagination
$page = $request->getParam('page', 1);
if ( $page == 0 ) $page = 1;
$page = $page - 1;
$nbAffichage = 100;
$position = $page * $nbAffichage;
if ( $page <= 0 ) $page = 1;
$nbAffichage = 50;
$position = ($page - 1 ) * $nbAffichage;
$siren = $request->getParam('siren', null);
if ( $siren == 'Siren' ) { $siren = null; }
@ -587,16 +585,31 @@ class SurveillanceController extends Zend_Controller_Action
}
}
//Calcul pagination
$nbReponses = $infos->nbReponses;
$nbSurveillances = $infos->nbReponsesTotal;
$totPage = ceil($nbSurveillances/$nbAffichage);
$curPage = ceil($position/$nbAffichage)+1;
//Calcul pagination
$nbReponses = $infos->nbReponses;
$nbReponsesTotal = $infos->nbReponsesTotal;
if ($nbReponses < $nbReponsesTotal) {
$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);
}

View File

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