Le comptage lors du rechargement est maintenant placé dans le plugin
This commit is contained in:
parent
74f98623f2
commit
ea7f205545
@ -1,41 +1,14 @@
|
||||
<?php
|
||||
class IndexController extends Zend_Controller_Action
|
||||
{
|
||||
protected $fields;
|
||||
public function init(){}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$request = $this->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');
|
||||
|
@ -1,17 +1,43 @@
|
||||
<?php
|
||||
class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
public function preDispatch(Zend_Controller_Request_Abstract $request)
|
||||
public function preDispatch($request)
|
||||
{
|
||||
$layout = Zend_Layout::getMVCInstance();
|
||||
if ($layout->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;
|
||||
|
Loading…
Reference in New Issue
Block a user