From ea7f2055459d63bbe1b57c5b412f0879ad3f87ee Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 11 Jan 2012 19:51:54 +0000 Subject: [PATCH] =?UTF-8?q?Le=20comptage=20lors=20du=20rechargement=20est?= =?UTF-8?q?=20maintenant=20plac=C3=A9=20dans=20le=20plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/IndexController.php | 31 ++---------------- .../Controller/Plugin/Comptage.php | 32 +++++++++++++++++-- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 3a98e9a7..c1f4c9ee 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -1,41 +1,14 @@ getRequest(); - - $auth = Zend_Auth::getInstance(); - $user = $auth->getIdentity(); - - // Chargement des critères de ciblage à partir de l'enregistrement en bdd - $id = $request->getParam('id', 0); - if (!empty($id)) { - $db = Zend_Registry::get('db'); - $criteresM = new Application_Model_Criteres(); - $sql = $criteresM->select() - ->from($criteresM, array('criteres')) - ->where('login = ?', $user->username) - ->where('id = ?', $id); - - $row = $criteresM->fetchRow($sql); - if ($row != null) { - require_once 'Scores/SessionCiblage.php'; - $session = new SessionCiblage(); - $session->setCriteres(json_decode($row->criteres, 'true')); - } - } - - } + public function indexAction(){} public function selectionAction(){} public function historiqueAction(){} - public function init(){} - public function criteresAction() { $this->view->headScript()->appendFile('/themes/default/scripts/fields.js', 'text/javascript'); diff --git a/library/Application/Controller/Plugin/Comptage.php b/library/Application/Controller/Plugin/Comptage.php index 67835df5..afa6c89f 100644 --- a/library/Application/Controller/Plugin/Comptage.php +++ b/library/Application/Controller/Plugin/Comptage.php @@ -1,17 +1,43 @@ isEnabled()) { - $controller = $this->_request->getControllerName(); - $action = $this->_request->getActionName(); + $controller = $request->getControllerName(); + $action = $request->getActionName(); if ($controller == 'index' && $action == 'index') { require_once 'Scores/SessionCiblage.php'; $session = new SessionCiblage(); $view = $layout->getView(); + + $auth = Zend_Auth::getInstance(); + $user = $auth->getIdentity(); + + // Chargement des critères de ciblage à partir de l'enregistrement en bdd + $id = $request->getParam('id', 0); + if (!empty($id)) { + $db = Zend_Registry::get('db'); + $criteresM = new Application_Model_Criteres(); + $sql = $criteresM->select() + ->from($criteresM, array('criteres')) + ->where('login = ?', $user->username) + ->where('id = ?', $id); + $row = $criteresM->fetchRow($sql); + if ($row != null) { + //On charge les critères + $session->setCriteres(json_decode($row->criteres, 'true')); + //Réalise le comptage + require_once 'Scores/Ciblage.php'; + $ciblage = new Ciblage($session->getCriteres()); + $total = $ciblage->execute(); + $insee = $ciblage->calculeRedevanceInsee(); + $session->setNb('total', $total); + $session->setNb('insee', $insee); + } + } $view->total = number_format($session->getNb('total'), 0, '', ' '); $view->insee = number_format($session->getNb('insee'), 0, '', ' '); $view->msgComptage = true;