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
|
<?php
|
||||||
class IndexController extends Zend_Controller_Action
|
class IndexController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
protected $fields;
|
public function init(){}
|
||||||
|
|
||||||
public function indexAction()
|
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 selectionAction(){}
|
public function selectionAction(){}
|
||||||
|
|
||||||
public function historiqueAction(){}
|
public function historiqueAction(){}
|
||||||
|
|
||||||
public function init(){}
|
|
||||||
|
|
||||||
public function criteresAction()
|
public function criteresAction()
|
||||||
{
|
{
|
||||||
$this->view->headScript()->appendFile('/themes/default/scripts/fields.js', 'text/javascript');
|
$this->view->headScript()->appendFile('/themes/default/scripts/fields.js', 'text/javascript');
|
||||||
|
@ -1,17 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abstract
|
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();
|
$layout = Zend_Layout::getMVCInstance();
|
||||||
if ($layout->isEnabled()) {
|
if ($layout->isEnabled()) {
|
||||||
$controller = $this->_request->getControllerName();
|
$controller = $request->getControllerName();
|
||||||
$action = $this->_request->getActionName();
|
$action = $request->getActionName();
|
||||||
|
|
||||||
if ($controller == 'index' && $action == 'index') {
|
if ($controller == 'index' && $action == 'index') {
|
||||||
require_once 'Scores/SessionCiblage.php';
|
require_once 'Scores/SessionCiblage.php';
|
||||||
$session = new SessionCiblage();
|
$session = new SessionCiblage();
|
||||||
$view = $layout->getView();
|
$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->total = number_format($session->getNb('total'), 0, '', ' ');
|
||||||
$view->insee = number_format($session->getNb('insee'), 0, '', ' ');
|
$view->insee = number_format($session->getNb('insee'), 0, '', ' ');
|
||||||
$view->msgComptage = true;
|
$view->msgComptage = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user