From 74d4d1c5ebac42bdb809042c94476bd6951aa25e Mon Sep 17 00:00:00 2001
From: Michael RICOIS
Date: Tue, 25 Feb 2014 19:59:14 +0000
Subject: [PATCH] issue #0001870 : Pagination control
---
.../controllers/IdentiteController.php | 31 +++++++----
.../controllers/RechercheController.php | 51 ++++++++++++-------
.../controllers/SurveillanceController.php | 41 ++++++++++-----
.../default/scripts/identite/evenements.phtml | 10 ++--
.../default/scripts/recherche/liste.phtml | 39 ++++++--------
.../default/scripts/surveillance/liste.phtml | 22 ++++----
6 files changed, 115 insertions(+), 79 deletions(-)
diff --git a/application/controllers/IdentiteController.php b/application/controllers/IdentiteController.php
index 7acba9724..70fae46ae 100644
--- a/application/controllers/IdentiteController.php
+++ b/application/controllers/IdentiteController.php
@@ -979,11 +979,11 @@ class IdentiteController extends Zend_Controller_Action
$siren = substr($this->siret,0,9);
$this->view->headTitle()->prepend('Evènements - Siren '.$siren);
- $nbReponses = 50;
+ //Pagination
$page = $request->getParam('page', 1);
- if ($page == 0) $page = 1;
- $page = $page - 1;
- $position = $page * $nbReponses;
+ if ( $page <= 0 ) $page = 1;
+ $nbAffichage = 50;
+ $position = ($page - 1 ) * $nbAffichage;
$session = new Scores_Session_Entreprise($this->siret, $this->id);
@@ -998,15 +998,28 @@ class IdentiteController extends Zend_Controller_Action
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$this->view->assign('exportObjet', $evens);
+ //Calcul pagination
+ $nbReponses = count($evens);
$nbReponsesTotal = $infos->nbReponses;
if ($nbReponses < $nbReponsesTotal) {
- $totPage = ceil($nbReponsesTotal/$nbReponses);
- $curPage = $page + 1;
+ $pageTotal = ceil( $nbReponsesTotal / $nbAffichage );
+ $pageCurrent = $page;
+ $pagePrev = $page - 1;
+ if ($pagePrev < 1) {
+ $pagePrev = 1;
+ }
+ $pageNext = $page + 1;
+ if( $pageNext > $pageTotal ) {
+ $pageNext = $pageTotal;
+ }
} else {
- $totPage = $curPage = 1;
+ $pageTotal = $pageCurrent = 1;
}
- $this->view->assign('totPage', $totPage);
- $this->view->assign('curPage', $curPage);
+ $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('nbReponsesTotal', empty($nbReponsesTotal) ? 0 : $nbReponsesTotal);
}
diff --git a/application/controllers/RechercheController.php b/application/controllers/RechercheController.php
index 80a95af63..e3d41a834 100644
--- a/application/controllers/RechercheController.php
+++ b/application/controllers/RechercheController.php
@@ -411,10 +411,11 @@ class RechercheController extends Zend_Controller_Action
$user = new Scores_Utilisateur();
$this->view->assign('IDENTITE', $user->checkPerm('IDENTITE'));
- $page = $request->getParam('page', 1);
- if ($page==0) $page = 1;
- $page = $page-1;
- $position = $page*$user->getNbRep();
+ //Pagination
+ $page = $request->getParam('page', 1);
+ if ( $page <= 0 ) $page = 1;
+ $nbAffichage = $user->getNbRep();
+ $position = ($page - 1 ) * $nbAffichage;
require_once 'Scores/WsScores.php';
$ws = new WsScores();
@@ -584,15 +585,6 @@ class RechercheController extends Zend_Controller_Action
}
$criteresLien = $this->view->url($params, null, true);
- $info = $reponse->info;
- $nbReponses = $reponse->nbReponses;
- $nbReponsesTotal = $reponse->nbReponsesTotal;
- if ($nbReponses < $nbReponsesTotal) {
- $totPage = ceil($nbReponsesTotal/$user->getNbRep());
- $curPage = $page+1;
- } else {
- $totPage = $curPage = 1;
- }
$liste = array();
if (count($etabs)>0) {
@@ -793,15 +785,38 @@ class RechercheController extends Zend_Controller_Action
$this->view->assign('blockDirToEntreprise', false);
}
- $this->view->assign('token', $token);
- $this->view->assign('liste', $liste);
- $this->view->assign('totPage', $totPage);
- $this->view->assign('curPage', $curPage);
+ $this->view->assign('liste', $liste);
+
+ //Calcul pagination
+ $nbReponses = $reponse->nbReponses;
+ $nbReponsesTotal = $reponse->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('nbReponsesTotal', empty($nbReponsesTotal) ? 0 : $nbReponsesTotal);
+
+ $this->view->assign('token', $token);
+
$this->view->assign('criteresTexte', $criteresTexte);
$this->view->assign('criteresLien', $criteresLien);
- $this->view->assign('info', $info);
+ $this->view->assign('info', $reponse->info);
}
}
diff --git a/application/controllers/SurveillanceController.php b/application/controllers/SurveillanceController.php
index c6e51ea18..0a9c0cadd 100644
--- a/application/controllers/SurveillanceController.php
+++ b/application/controllers/SurveillanceController.php
@@ -274,12 +274,14 @@ class SurveillanceController extends Zend_Controller_Action
$request = $this->getRequest();
- $page = $request->getParam('page', 1);
- if ( $page == 0 ) $page = 1;
- $page = $page - 1;
- $nbAffichage = 50;
$position = $page * $nbAffichage;
+ //Pagination
+ $page = $request->getParam('page', 1);
+ if ( $page <= 0 ) $page = 1;
+ $nbAffichage = 50;
+ $position = ($page - 1 ) * $nbAffichage;
+
$source = $request->getParam('source', '');
$tri = $request->getParam('tri', 'siren');
@@ -370,18 +372,33 @@ class SurveillanceController extends Zend_Controller_Action
}
//Calcul pagination
- $nbReponses = $infos->nbReponses;
- $nbSurveillances = $infos->nbReponsesTotal;
- $totPage = ceil($nbSurveillances/$nbAffichage);
- $curPage = ceil($position/$nbAffichage)+1;
+ $nbReponses = $infos->nbReponses;
+ $nbReponsesTotal = $infos->nbReponsesTotal;
+ if ($nbReponses < $nbReponsesTotal) {
+ $pageTotal = ceil( $nbReponsesTotal / $nbReponses );
+ $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('source', $source);
$this->view->assign('selectTri', $selectTri);
$this->view->assign('listSources', $permSource);
- $this->view->assign('nbReponses', $nbReponses);
- $this->view->assign('nbSurveillances', $nbSurveillances);
- $this->view->assign('totPage', $totPage);
- $this->view->assign('curPage', $curPage);
$this->view->assign('surveillances', $listTrier);
$this->view->assign('source', $source);
}
diff --git a/application/views/default/scripts/identite/evenements.phtml b/application/views/default/scripts/identite/evenements.phtml
index 1534cf9d8..deb0d5065 100644
--- a/application/views/default/scripts/identite/evenements.phtml
+++ b/application/views/default/scripts/identite/evenements.phtml
@@ -76,14 +76,14 @@
-totPage>1) {?>
+PageTotal>1) {?>
diff --git a/application/views/default/scripts/recherche/liste.phtml b/application/views/default/scripts/recherche/liste.phtml
index b4a8ec951..355248c1d 100644
--- a/application/views/default/scripts/recherche/liste.phtml
+++ b/application/views/default/scripts/recherche/liste.phtml
@@ -6,9 +6,9 @@
=$this->nbReponsesTotal?> réponsenbReponsesTotal>1){?>s
avec les critères "
=$this->criteresTexte?>".
-totPage!=1) {?>
+PageTotal!=1) {?>
=$this->nbReponses?> résultats affichés.
-Page =$this->curPage.'/'.$this->totPage.'.';?>
+Page =$this->PageCurrent.'/'.$this->PageTotal.'.';?>
filtres) { ?>
@@ -27,9 +27,7 @@ $('select[name=filtre]').change(function(e){
-info)) {
-?>
+info)) { ?>
=$this->info?>
@@ -73,26 +71,19 @@ if (!empty($this->info)) {
-
-curPage>1) { ?>
-
-
-
-
-}
-if ($this->curPage!=$this->totPage) {
-?>
-
Page =$this->curPage?>/=$this->totPage?>
-curPage<$this->totPage) {
-?>
-
-
-
-
+PageTotal>1) {?>
+
+
-
+
+
+
+
rechCsv) { ?>
diff --git a/application/views/default/scripts/surveillance/liste.phtml b/application/views/default/scripts/surveillance/liste.phtml
index 0a608eaba..fc7061258 100644
--- a/application/views/default/scripts/surveillance/liste.phtml
+++ b/application/views/default/scripts/surveillance/liste.phtml
@@ -65,14 +65,14 @@ par
Liste des surveillances
-totPage>1) {?>
+PageTotal>1) {?>
@@ -223,14 +223,14 @@ par
-totPage>1) {?>
+PageTotal>1) {?>