Preferences
This commit is contained in:
parent
5ab91eb8c7
commit
1cd65fb0ab
@ -31,17 +31,24 @@ class ComptageController extends Zend_Controller_Action
|
||||
|
||||
//@todo : if $total = false then an error occured ?
|
||||
$total = $ciblage->execute();
|
||||
$insee = $ciblage->calculRedevanceInsee();
|
||||
|
||||
$fields->setNb('total', $total);
|
||||
$fields->setNb('insee', $insee);
|
||||
$fields->setNb('total', $total);
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$user = $auth->getIdentity();
|
||||
Zend_Registry::get('firebug')->info($user);
|
||||
if ($user->preferences['interface']['insee']==1) {
|
||||
$insee = null;
|
||||
} else {
|
||||
$insee = $ciblage->calculRedevanceInsee();
|
||||
}
|
||||
$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' => number_format($insee, 0, '', ' ')
|
||||
'insee' => ($insee!==null) ? number_format($insee, 0, '', ' ') : null,
|
||||
);
|
||||
$this->view->assign('result', $result);
|
||||
}
|
||||
@ -62,7 +69,7 @@ class ComptageController extends Zend_Controller_Action
|
||||
$this->_helper->layout()->disableLayout();
|
||||
//Récupération de la session pour le profil et les valeurs du comptage
|
||||
$fields = new Scores_Fields();
|
||||
$criteres = $fields->getCriteres();
|
||||
$criteres = $fields->getCriteres();
|
||||
if (count($criteres) == 0) {
|
||||
$this->view->noSelection = true;
|
||||
}
|
||||
@ -72,6 +79,7 @@ class ComptageController extends Zend_Controller_Action
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$request = $this->getRequest();
|
||||
$ref = $request->getParam('ref', '');
|
||||
|
||||
@ -102,8 +110,14 @@ class ComptageController extends Zend_Controller_Action
|
||||
);
|
||||
$id = $criteresM->insert($data);
|
||||
|
||||
if ($id){
|
||||
//Enregistrement des valeurs du comptage
|
||||
if ($id) {
|
||||
//If nbInsee == null, need to count again
|
||||
if ($nbInsee===null) {
|
||||
$ciblage = new Ciblage($criteres);
|
||||
$nbInsee = $ciblage->calculRedevanceInsee();
|
||||
}
|
||||
|
||||
//Enregistrement des valeurs du comptage
|
||||
$comptageM = new Application_Model_Comptages();
|
||||
$data = array(
|
||||
'idDefinition' => $id,
|
||||
|
@ -286,6 +286,22 @@ class DashboardController extends Zend_Controller_Action
|
||||
*/
|
||||
public function configurationAction()
|
||||
{
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$user = $auth->getIdentity();
|
||||
|
||||
if (array_key_exists('filter', $user->preferences) && count($user->preferences['filter'])>0) {
|
||||
$liste = $user->preferences['filter'];
|
||||
foreach ( $liste as $name => $value ){
|
||||
$this->view->assign('prefFilter'.ucfirst($name), $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('interface', $user->preferences) && count($user->preferences['interface'])>0) {
|
||||
$liste = $user->preferences['interface'];
|
||||
foreach ( $liste as $name => $value ){
|
||||
$this->view->assign('prefInterface'.ucfirst($name), $value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -319,7 +335,7 @@ class DashboardController extends Zend_Controller_Action
|
||||
$filter = array();
|
||||
foreach ( $prefsFilter as $item ){
|
||||
if (array_key_exists($item, $sendParam)) {
|
||||
$filter = array($item, $sendParam[$item]);
|
||||
$filter = array($item => $sendParam[$item]);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('filter', $data)) {
|
||||
@ -330,7 +346,7 @@ class DashboardController extends Zend_Controller_Action
|
||||
$interface = array();
|
||||
foreach ( $prefsInterface as $item ){
|
||||
if (array_key_exists($item, $sendParam)) {
|
||||
$interface = array($item, $sendParam[$item]);
|
||||
$interface = array($item => $sendParam[$item]);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('interface', $data)) {
|
||||
|
@ -50,22 +50,21 @@ utilisation correspondant à vos besoins.
|
||||
<label>Afficher le nombre d'unité INSEE</label><br/>
|
||||
<span><i>Pour permettre une estimation du cout de la redevance INSEE, en activant cette option,
|
||||
le nombre d'unité insee est affiché à chaque comptage</i></span><br/>
|
||||
<input type="checkbox" name="insee" value="1" <?=$this->prefInterfaceINSEE?>
|
||||
<input type="checkbox" name="insee" value="1" <?php if ($this->prefInterfaceInsee==1) echo ' checked="checked"';?> />
|
||||
</div>
|
||||
<br/><br/>
|
||||
<br/>
|
||||
<div>
|
||||
<label>Filtrer au seul périmètre RNCS </label><br/>
|
||||
<span>Les éléments soumis à redevance INSEE sont automatiquement retirer du ciblage</span><br/>
|
||||
<input type="checkbox" name="rncs" value="1" <?=$this->prefFilterRNCS?>
|
||||
<input type="checkbox" name="rncs" value="1" <?php if ($this->prefFilterRncs==1) echo ' checked="checked"';?> />
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('input[type=checkbox]').click(function(e){
|
||||
e.preventDefault();
|
||||
$('input[type=checkbox]').click(function(){
|
||||
if($(this).is(':checked')) {
|
||||
$.post('/dashboard/pref'+$(this).attr('name')+'1' , function(data, status) {});
|
||||
$.post('/dashboard/pref/'+$(this).attr('name')+'/1' , function(data, status) {});
|
||||
} else {
|
||||
$.post('/dashboard/pref'+$(this).attr('name')+'0' , function(data, status) {});
|
||||
$.post('/dashboard/pref/'+$(this).attr('name')+'/0' , function(data, status) {});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -19,7 +19,9 @@
|
||||
<?php if ( $this->total!==null ) {?>
|
||||
Nombre sélectionnées :
|
||||
<span class="valeur"><?=number_format($this->total, 0, '', ' ')?></span>
|
||||
<?php if ( $this->insee!==null ) {?>
|
||||
(dont <span class="valeur"><?=number_format($this->insee, 0, '', ' ')?></span> unité(s) insee)
|
||||
<?php }?>
|
||||
<?php } else {?>
|
||||
Aucune sélection.
|
||||
<?php }?>
|
||||
|
@ -46,8 +46,12 @@ class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abst
|
||||
$fields = new Scores_Fields();
|
||||
$ciblage = new Ciblage($fields->getValues());
|
||||
$total = $ciblage->execute();
|
||||
$insee = $ciblage->calculRedevanceInsee();
|
||||
$session->setNb('total', $total);
|
||||
if ($user->preferences['interface']['insee']==1) {
|
||||
$insee = null;
|
||||
} else {
|
||||
$insee = $ciblage->calculRedevanceInsee();
|
||||
}
|
||||
$session->setNb('insee', $insee);
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,12 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
|
||||
$message = $InfosLogin;
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array($message));
|
||||
} elseif ($this->_username == $InfosLogin->result->login) {
|
||||
//Get user's preference
|
||||
$prefsM = new Application_Model_Prefs();
|
||||
$pref = $prefsM->find($this->_username)->current();
|
||||
if ($pref) {
|
||||
$identity->preferences = json_decode($pref->json, true);
|
||||
}
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
|
||||
} else {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity);
|
||||
|
@ -242,10 +242,10 @@ function set(key, value, ex)
|
||||
$('#panel').html('<img src="/themes/default/images/ajax.gif" />');
|
||||
|
||||
$.post('/comptage/index', { cle:key, valeur:value, exlcude:ex }, function(data, status) {
|
||||
var html = 'Nombre sélectionnées : <span class="valeur">' +
|
||||
data.count + '</span> (dont <span class="valeur">' +
|
||||
data.insee +'</span> unité(s) insee)';
|
||||
|
||||
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');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user