From 18bd65b9911fc96b5b2c17cd862b557288ac3317 Mon Sep 17 00:00:00 2001 From: Damien LASSERRE Date: Tue, 3 Apr 2012 13:49:38 +0000 Subject: [PATCH] modification de l'enrichissement + recomptage (actualisation du comptage) et rapelle des criteres --- .../controllers/EnrichissementController.php | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/application/modules/frontend/controllers/EnrichissementController.php b/application/modules/frontend/controllers/EnrichissementController.php index bedfd611..e838a92c 100644 --- a/application/modules/frontend/controllers/EnrichissementController.php +++ b/application/modules/frontend/controllers/EnrichissementController.php @@ -64,7 +64,6 @@ class EnrichissementController extends Zend_Controller_Action } } - /** * Enregistrement de la commande pour l'ennrichissement */ @@ -103,7 +102,6 @@ class EnrichissementController extends Zend_Controller_Action $criteres = $criteresRow->current(); $structure = json_decode($criteres->criteres, true); - require_once 'Scores/Field.php'; $field = new Fields(); $values = $field->getValues($structure); @@ -129,6 +127,7 @@ class EnrichissementController extends Zend_Controller_Action 'error' => '', 'dateAdded' => date('YmdHis'), ); + $identifiantsM = new Table_EnrichissementIdentifiants(); $idIdentifiant = $identifiantsM->insert($data); } @@ -165,10 +164,28 @@ class EnrichissementController extends Zend_Controller_Action ->order('dateAjout DESC') ->limit(1); $comptages = $comptagesM->fetchAll($sql); + $old = $comptages; + $oldResultat = $old[0]->resultat; + $oldResultatInsee = $old[0]->uniteInsee; if ( $comptages->count()>0 ) { $item = $comptages[0]; - //@todo : Si le ciblage n'est pas du jour, refaire le comptage par rapport aux critères de ciblage - + $date = explode(' ', $item->dateAjout); + $date = $date[0]; + if($date != '0000-00-00') { + if($date != date('Y-m-d')) { + $criteres = new Table_Criteres(); + $sql = $criteres->select()->where('id = ?', $idCritere); + $result = $criteres->fetchRow($sql)->toArray(); + $criteres = json_decode($result['criteres'], true); + require_once('Scores/Field.php'); + require_once('Scores/Ciblage.php'); + $field = new Fields(); + $count = new Ciblage($field->getValues($criteres)); + $item['resultat'] = $count->execute(); + $item['uniteInsee'] = $count->calculRedevanceInsee(); + } + } + $this->view->assign('resultat', $item['resultat']); $this->view->assign('uniteInsee', $item['uniteInsee']); @@ -182,10 +199,18 @@ class EnrichissementController extends Zend_Controller_Action } $prix = $item['resultat'] * $profil->tarifLigne + $prixInsee; - $this->view->assign('prix', $prix); - $this->view->assign('prixInsee', $prixInsee); - $this->view->assign('infoInsee', $infoInsee); - $this->view->assign('id', $item['id']); + $this->view->prix = round($prix, 2); + $this->view->prixInsee = round($prixInsee, 2); + $this->view->infoInsee = $infoInsee; + $this->view->id = $item['id']; + + $this->view->oldDate = $date; + $this->view->oldResult = $oldResultat; + $this->view->oldResultInsee = $oldResultatInsee; + $this->view->oldPrice = round($oldResultat* $profil->tarifLigne + $oldResultatInsee, 2); + $this->view->oldPriceInsee = round($oldResultatInsee*$redevanceInsee, 2); + + $this->view->criteres = $criteres; } }