odea/application/controllers/IndexController.php

112 lines
2.9 KiB
PHP

<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
if ($user->customisation) {
$this->view->assign('preferences', $user->customisation);
}
}
public function criteresAction()
{
$ajax = $this->getRequest()->getParam('ajax');
if($ajax)
$this->_helper->layout()->disableLayout();
$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;
}
public function criterelistAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$critere = $request->getParam('key');
$fields = new Scores_Fields();
$values = $fields->getCritere($critere);
$this->view->assign('critereName', $critere);
//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);
}
}
public function removeAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$nameCritereToDelete = $request->getParam('critere');
$posInList = $request->getParam('in', false);
$posExList = $request->getParam('ex', false);
$fields = new Scores_Fields();
if ($posInList!==false) {
$fields->unsetCritereValue($nameCritereToDelete, $posInList);
} elseif ($posExList!==false) {
$fields->unsetCritereValue($nameCritereToDelete, $posExList, true);
} else {
$fields->unsetCritere($nameCritereToDelete);
}
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
//Comptage
require_once 'Scores/Ciblage.php';
$ciblage = new Ciblage($fields->getValues(), $user->globalRNCS);
$total = $ciblage->execute();
$fields->setNb('total', $total);
if ($user->preferences['interface']['insee']==1) {
$insee = $ciblage->calculRedevanceInsee();
} else {
$insee = null;
}
$fields->setNb('insee', $insee);
$fields->setCritereSession();
$this->_redirect('/');
}
}