2012-02-02 18:29:14 +01:00
|
|
|
<?php
|
2012-05-17 20:12:55 +02:00
|
|
|
class IndexController extends Zend_Controller_Action
|
2012-02-02 18:29:14 +01:00
|
|
|
{
|
|
|
|
public function indexAction()
|
|
|
|
{
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
2012-05-25 11:19:42 +02:00
|
|
|
|
2012-02-02 18:29:14 +01:00
|
|
|
if ($user->customisation) {
|
|
|
|
$this->view->assign('preferences', $user->customisation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-15 10:25:21 +01:00
|
|
|
public function criteresAction()
|
|
|
|
{
|
2012-03-08 16:25:27 +01:00
|
|
|
$ajax = $this->getRequest()->getParam('ajax');
|
|
|
|
if($ajax)
|
|
|
|
$this->_helper->layout()->disableLayout();
|
2012-05-04 20:21:51 +02:00
|
|
|
|
2012-05-22 08:10:32 +02:00
|
|
|
$fields = new Scores_Fields();
|
|
|
|
|
|
|
|
$infosCriteres = array();
|
|
|
|
|
|
|
|
$decodeCriteres = $fields->getCriteres();
|
|
|
|
|
|
|
|
//Construction affichage des critères
|
|
|
|
foreach ( $decodeCriteres as $key => $item ) {
|
|
|
|
|
|
|
|
$inValue = $fields->getValueLabel($key, $item['in']);
|
|
|
|
$exValue = $fields->getValueLabel($key, $item['ex']);
|
|
|
|
|
|
|
|
$infosCriteres[$key] = array(
|
|
|
|
'label' => $fields->getLabel($key),
|
|
|
|
'in' => $inValue,
|
|
|
|
'ex' => $exValue,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->view->infos = $infosCriteres;
|
|
|
|
}
|
2012-05-02 20:19:07 +02:00
|
|
|
|
2012-05-22 08:10:32 +02:00
|
|
|
public function criterelistAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$critere = $request->getParam('key');
|
|
|
|
|
|
|
|
$fields = new Scores_Fields();
|
|
|
|
$values = $fields->getCritere($critere);
|
|
|
|
|
2012-05-29 11:58:15 +02:00
|
|
|
$this->view->assign('critereName', $critere);
|
|
|
|
|
2012-05-22 08:10:32 +02:00
|
|
|
//Inclusion
|
|
|
|
if (count($values['in'])>0) {
|
|
|
|
$inLabels = $fields->getValueLabel($critere, $values['in']);
|
|
|
|
$inValues = array_values($values['in']);
|
|
|
|
$this->view->assign('inLabels', $inLabels);
|
|
|
|
$this->view->assign('inValues', $inValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Exclusion
|
|
|
|
if (count($values['ex'])>0) {
|
|
|
|
$exLabels = $fields->getValueLabel($critere, $values['ex']);
|
|
|
|
$exValues = array_values($values['ex']);
|
|
|
|
$this->view->assign('exLabels', $exLabels);
|
|
|
|
$this->view->assign('exValues', $exValues);
|
|
|
|
}
|
2012-02-15 10:25:21 +01:00
|
|
|
}
|
2012-05-02 20:19:07 +02:00
|
|
|
|
2012-05-22 08:10:32 +02:00
|
|
|
|
2012-03-08 16:04:08 +01:00
|
|
|
public function removeAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
2012-05-11 22:25:55 +02:00
|
|
|
|
2012-05-29 11:58:15 +02:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
$nameCritereToDelete = $request->getParam('critere');
|
|
|
|
$posInList = $request->getParam('in', false);
|
|
|
|
$posExList = $request->getParam('ex', false);
|
2012-05-11 22:25:55 +02:00
|
|
|
|
|
|
|
$fields = new Scores_Fields();
|
2012-05-29 11:58:15 +02:00
|
|
|
|
2012-05-29 17:44:15 +02:00
|
|
|
if ($posInList!==false) {
|
2012-05-29 11:58:15 +02:00
|
|
|
$fields->unsetCritereValue($nameCritereToDelete, $posInList);
|
2012-05-29 17:44:15 +02:00
|
|
|
} elseif ($posExList!==false) {
|
2012-05-29 11:58:15 +02:00
|
|
|
$fields->unsetCritereValue($nameCritereToDelete, $posExList, true);
|
|
|
|
} else {
|
|
|
|
$fields->unsetCritere($nameCritereToDelete);
|
2012-06-11 16:40:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
2012-05-13 15:59:15 +02:00
|
|
|
|
|
|
|
//Comptage
|
|
|
|
require_once 'Scores/Ciblage.php';
|
2012-06-12 12:00:42 +02:00
|
|
|
$ciblage = new Ciblage($fields->getValues(), $user->globalRNCS);
|
2012-05-13 15:59:15 +02:00
|
|
|
|
|
|
|
$total = $ciblage->execute();
|
2012-05-29 11:58:15 +02:00
|
|
|
$fields->setNb('total', $total);
|
|
|
|
|
|
|
|
if ($user->preferences['interface']['insee']==1) {
|
|
|
|
$insee = $ciblage->calculRedevanceInsee();
|
2012-05-29 17:51:16 +02:00
|
|
|
} else {
|
|
|
|
$insee = null;
|
2012-05-29 11:58:15 +02:00
|
|
|
}
|
2012-07-24 17:33:46 +02:00
|
|
|
$fields->setNb('insee', $insee);
|
|
|
|
$fields->setCritereSession();
|
2012-05-11 22:25:55 +02:00
|
|
|
|
2012-03-08 16:04:08 +01:00
|
|
|
$this->_redirect('/');
|
|
|
|
}
|
2012-05-13 15:59:15 +02:00
|
|
|
}
|