Mise à jour du comptage

This commit is contained in:
Michael RICOIS 2012-02-22 15:55:16 +00:00
parent c1c655d84b
commit 843bb1fb5b

View File

@ -53,31 +53,38 @@ class ComptageController extends Libs_Controller
public function updateAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$idCriteres = $request->getParam('id');
//@todo : comment envoyé la structure de la bdd dans fields
//Récupération des critères du ciblage
$criteresM = new Table_Criteres();
$criteresRow = $criteresM->find($idCriteres);
$criteres = $criteresRow->current();
$structure = json_decode($criteres->criteres, true);
require_once 'Scores/Field.php';
$field = new Fields();
$values = $field->getValues($structure);
//Comptage
require_once 'Scores/Ciblage.php';
$ciblage = new Ciblage($field->getValues());
$total = $ciblage->execute();
$insee = $ciblage->calculRedevanceInsee();
$data = array(
'idDefinition' => $idCriteres,
'resultat' => $ciblage->execute(),
'uniteInsee' => $ciblage->calculRedevanceInsee(),
'dateAjout' => date('YmdHis'),
);
//Enregistrement
//Lecture de la base à nouveau
$comptageM = new Table_Comptages();
$comptageM->insert($data);
//Retour comptage, unité Insee
$result = array(
'resultat' => number_format($item['resultat'], 0, '', ' '),
'uniteInsee' => number_format($item['dateAjout'], 0, '', ' '),
'dateAjout' => $item['dateAjout'],
'resultat' => number_format($data['resultat'], 0, '', ' '),
'uniteInsee' => number_format($data['dateAjout'], 0, '', ' '),
'dateAjout' => $data['dateAjout'],
);
$this->view->assign('result', $result);
}