Merge from branche 1.2
This commit is contained in:
commit
3cf10adb90
@ -15,6 +15,15 @@ class ComptageController extends Zend_Controller_Action
|
||||
$cle = $request->getParam('cle');
|
||||
$valeur = $request->getParam('valeur');
|
||||
|
||||
/**
|
||||
* Error code
|
||||
* 0 : OK
|
||||
* 1 : Error from sphinx
|
||||
* 2 : Error when insert critere
|
||||
* @var int
|
||||
*/
|
||||
$error = 0;
|
||||
|
||||
//Set the flag for exclusion
|
||||
$exclude = $request->getParam('exclude');
|
||||
$ex = false;
|
||||
@ -23,34 +32,48 @@ class ComptageController extends Zend_Controller_Action
|
||||
}
|
||||
|
||||
$fields = new Scores_Fields();
|
||||
$fields->setCritere($cle, $valeur, $ex);
|
||||
$insert = $fields->setCritere($cle, $valeur, $ex);
|
||||
|
||||
//Informations utilisateur
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$user = $auth->getIdentity();
|
||||
|
||||
//Comptage
|
||||
require_once 'Scores/Ciblage.php';
|
||||
$ciblage = new Ciblage($fields->getValues(), $user->globalRNCS);
|
||||
|
||||
//@todo : if $total = false then an error occured ?
|
||||
$total = $ciblage->execute();
|
||||
$fields->setNb('total', $total);
|
||||
|
||||
if ($user->preferences['interface']['insee']==1) {
|
||||
$insee = $ciblage->calculRedevanceInsee();
|
||||
if ($insert) {
|
||||
//Informations utilisateur
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$user = $auth->getIdentity();
|
||||
|
||||
//Comptage
|
||||
require_once 'Scores/Ciblage.php';
|
||||
$ciblage = new Ciblage($fields->getValues(), $user->globalRNCS);
|
||||
|
||||
//@todo : if $total = false then an error occured ?
|
||||
// et si nous avons une erreur alors faut-il retirer les critères de la session
|
||||
$total = $ciblage->execute();
|
||||
|
||||
//Define value return after counting
|
||||
$fields->setNb('total', $total);
|
||||
if ( $user->preferences['interface']['insee'] == 1 ) {
|
||||
$insee = $ciblage->calculRedevanceInsee();
|
||||
} else {
|
||||
$insee = null;
|
||||
}
|
||||
$fields->setNb('insee', $insee);
|
||||
|
||||
if ( $total !== false ) {
|
||||
//All is ok, save criteres and result to session
|
||||
$fields->setCritereSession();
|
||||
} else {
|
||||
$error = 1;
|
||||
}
|
||||
} else {
|
||||
$insee = null;
|
||||
$error = 2;
|
||||
}
|
||||
$fields->setNb('insee', $insee);
|
||||
|
||||
|
||||
//@todo : Ajouter les critères sous forme json_encode
|
||||
|
||||
//Retour comptage, unité Insee
|
||||
$result = array(
|
||||
'count' => number_format($total, 0, '', ' '),
|
||||
'insee' => ($insee!==null) ? number_format($insee, 0, '', ' ') : null,
|
||||
);
|
||||
'count' => number_format($total, 0, '', ' '),
|
||||
'insee' => ($insee!==null) ? number_format($insee, 0, '', ' ') : null,
|
||||
'error' => $error,
|
||||
);
|
||||
|
||||
$this->view->assign('result', $result);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,8 @@ class IndexController extends Zend_Controller_Action
|
||||
} else {
|
||||
$insee = null;
|
||||
}
|
||||
$fields->setNb('insee', $insee);
|
||||
$fields->setNb('insee', $insee);
|
||||
$fields->setCritereSession();
|
||||
|
||||
$this->_redirect('/');
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ Erreur ! Le moteur de ciblage n'est pas disponible !
|
||||
</div>
|
||||
|
||||
<?php } else {?>
|
||||
<div id="actionMessage"></div>
|
||||
<div id="panel"><?=$this->action('criteres', 'index')?></div>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
|
@ -53,6 +53,7 @@ class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abst
|
||||
$insee = null;
|
||||
}
|
||||
$session->setNb('insee', $insee);
|
||||
$session->setCritereSession();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,6 +177,7 @@ class Ciblage
|
||||
/**
|
||||
*
|
||||
* @param boolean $need
|
||||
* @param int $nbReturn
|
||||
*/
|
||||
public function execute($need = false, $nbReturn = 0)
|
||||
{
|
||||
|
@ -733,21 +733,41 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
$this->ciblage['NB']['insee'] = $this->insee;
|
||||
$session->ciblage = $this->ciblage;
|
||||
}
|
||||
|
||||
/**
|
||||
* After define criteres and no error return, set the session externaly
|
||||
* @return void
|
||||
*/
|
||||
public function setCritereSession()
|
||||
{
|
||||
$this->setSession();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enregistre un critère et sa valeur
|
||||
* Enregistre un critère et sa valeur en effectuant les controls nécesaire
|
||||
* @param string $key
|
||||
* Critere key
|
||||
* @param mixed $value
|
||||
* Value(s)
|
||||
* @param boolean $ex
|
||||
* true for an exclude value
|
||||
* @return boolean
|
||||
* true if all is ok, false if the key doesn't exist or value is not correct
|
||||
*/
|
||||
public function setCritere($key, $value, $ex = false)
|
||||
{
|
||||
//Remove critere for these values on all type of fields
|
||||
//Check if the key exist
|
||||
if ( !in_array($key, $this->fields) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Remove critere for these values on all type of fields
|
||||
if ( in_array($value, array('', '-', null)) ) {
|
||||
unset($this->ciblage[$key]);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
//Do some operation on value
|
||||
$types = array_keys($this->fields[$key]['fields']);
|
||||
|
||||
if ( !is_array($value) && !in_array($types[0], array('select', 'checkbox', 'interval')) ) {
|
||||
@ -792,7 +812,7 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
}
|
||||
break;
|
||||
case 'tree':
|
||||
//Check values
|
||||
//@todo : Check if values exist
|
||||
break;
|
||||
}
|
||||
|
||||
@ -806,7 +826,8 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
Zend_Registry::get('firebug')->info('Include: ');
|
||||
Zend_Registry::get('firebug')->info($value);
|
||||
}
|
||||
$this->setSession();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -884,7 +905,6 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
|
||||
public function setNb($element, $nb)
|
||||
{
|
||||
$this->{$element} = $nb;
|
||||
$this->setSession();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,40 +227,49 @@ $(document).ready(function()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
function set(key, value, ex)
|
||||
{
|
||||
ex = typeof ex !== 'undefined' ? ex : 0;
|
||||
|
||||
$('#comptage').css('display', 'none');
|
||||
$('#attente').css('display', 'block');
|
||||
$('#panel').html('<img src="/themes/default/images/ajax.gif" />');
|
||||
|
||||
$.post('/comptage/index', { cle:key, valeur:value, exclude:ex }, function(data, status) {
|
||||
var html = 'Nombre sélectionnées : <span class="valeur">'+data.count+'</span>';
|
||||
if (data.insee>0) {
|
||||
html = html + ' (dont <span class="valeur">'+data.insee +'</span> unité(s) insee)';
|
||||
}
|
||||
$('#attente').css('display', 'none');
|
||||
$('#comptage').html(html).css('display','block');
|
||||
$.post('/comptage/index', { cle:key, valeur:value, exclude:ex }, function(data, status) {
|
||||
//
|
||||
if (data.error==0) {
|
||||
//Count html result
|
||||
var html = 'Nombre sélectionnées : <span class="valeur">'+data.count+'</span>';
|
||||
if (data.insee>0) {
|
||||
html = html + ' (dont <span class="valeur">'+data.insee +'</span> unité(s) insee)';
|
||||
}
|
||||
//
|
||||
$('#attente').css('display', 'none');
|
||||
$('#comptage').html(html).css('display','block');
|
||||
|
||||
$.ajax({
|
||||
type : "GET",
|
||||
cache : false,
|
||||
url : '/index/criteres/ajax/1',
|
||||
data : $(this).serializeArray(),
|
||||
success: function(data) {
|
||||
$('#panel').html(data);
|
||||
}
|
||||
});
|
||||
|
||||
}, 'json')
|
||||
.error(function(){ alert('error'); });
|
||||
//Resume criteres content
|
||||
$.get('/index/criteres/ajax/1', function(data){
|
||||
$('#panel').html(data);
|
||||
});
|
||||
}
|
||||
|
||||
if (data.error==2) {
|
||||
$('div#actionMessage').html(
|
||||
'<div class="ui-state-highlight ui-corner-all" style="padding: .7em;">'+
|
||||
'<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>'+
|
||||
'<strong>Information </strong> Valeur saisi incorrecte.</p>'+
|
||||
'</div>');
|
||||
}
|
||||
|
||||
if (data.error==1) {
|
||||
$('div#actionMessage').html(
|
||||
'<div class="ui-state-error ui-corner-all" style="padding: .7em;">'+
|
||||
'<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>'+
|
||||
'<strong>Erreur:</strong> Un problème technique est survenu.</p>'+
|
||||
'</div>');
|
||||
}
|
||||
|
||||
}, 'json').error(function(){ alert('Erreur inconnue'); });
|
||||
}
|
||||
|
||||
function split( val ) {
|
||||
|
Loading…
Reference in New Issue
Block a user