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;