Merge
This commit is contained in:
commit
49b174cc27
@ -9,7 +9,6 @@ class ComptageController extends Zend_Controller_Action
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
@ -32,19 +31,26 @@ 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,
|
||||
);
|
||||
echo json_encode($result);
|
||||
$this->view->assign('result', $result);
|
||||
}
|
||||
|
||||
public function resetAction()
|
||||
@ -63,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;
|
||||
}
|
||||
@ -73,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', '');
|
||||
|
||||
@ -103,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,
|
||||
@ -204,8 +217,8 @@ class ComptageController extends Zend_Controller_Action
|
||||
$profil = json_decode($result['criteres'], true);
|
||||
|
||||
$extractSql = $extractLabel = array();
|
||||
$extractSql[] = "CONCAT(LPAD(siren, 9, '000000000'), LPAD(nic, 5, '00000')) AS siret";
|
||||
$extractLabel[] = 'SIRET';
|
||||
//$extractSql[] = "CONCAT(LPAD(siren, 9, '000000000'), LPAD(nic, 5, '00000')) AS siret";
|
||||
//$extractLabel[] = 'SIRET';
|
||||
|
||||
require_once 'Scores/Enrichissement.php';
|
||||
$enrichissement = new Enrichissement();
|
||||
|
@ -281,22 +281,84 @@ class DashboardController extends Zend_Controller_Action
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display information about user's profil
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set preferences
|
||||
*/
|
||||
public function prefAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$user = $auth->getIdentity();
|
||||
|
||||
//Read prefs table to load actual config
|
||||
$prefsM = new Application_Model_Prefs();
|
||||
$userPrefs = $prefsM->find($user->username)->current();
|
||||
|
||||
$data = array('interface'=>array(),'filter'=>array());
|
||||
if ($userPrefs) {
|
||||
$data = json_decode($userPrefs->json, true);
|
||||
} else {
|
||||
$prefsM->insert(array('login'=>$user->username, 'json'=>json_encode($data)));
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
$sendParam = $request->getParams();
|
||||
|
||||
$prefsFilter = array('rncs');
|
||||
$prefsInterface = array('insee');
|
||||
|
||||
$filter = array();
|
||||
foreach ( $prefsFilter as $item ){
|
||||
if (array_key_exists($item, $sendParam)) {
|
||||
$filter = array($item => $sendParam[$item]);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('filter', $data)) {
|
||||
$filter = array_merge($data['filter'], $filter);
|
||||
}
|
||||
$data['filter'] = $filter;
|
||||
|
||||
$interface = array();
|
||||
foreach ( $prefsInterface as $item ){
|
||||
if (array_key_exists($item, $sendParam)) {
|
||||
$interface = array($item => $sendParam[$item]);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('interface', $data)) {
|
||||
$interface = array_merge($data['interface'], $interface);
|
||||
}
|
||||
$data['interface'] = $interface;
|
||||
$newjson = json_encode($data);
|
||||
|
||||
$nbRow = $prefsM->update(array('json'=>$newjson), "login='".$user->username."'");
|
||||
|
||||
$this->view->assign('nbRow', $nbRow);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,4 +1 @@
|
||||
<br /><br />
|
||||
<div id="view-content">
|
||||
<p>View script for controller <b>Comptage</b> and script/action name <b>index</b></p>
|
||||
</div>
|
||||
<?=json_encode($this->result)?>
|
@ -21,7 +21,7 @@ disponible.
|
||||
</p>
|
||||
<br/>
|
||||
|
||||
<p>Cas profil défini pas S&D</p>
|
||||
<p>Cas profil défini par S&D</p>
|
||||
<p>- Aucun profil d'enrichissement (Contacter le support)</p>
|
||||
<p>- Liste des profils avec référence, tarifs à la ligne</p>
|
||||
|
||||
@ -46,11 +46,30 @@ utilisation correspondant à vos besoins.
|
||||
<p>Des préférences d'affichage ont été définies pour votre profil utilisateur.</p>
|
||||
<br/>
|
||||
|
||||
<ul>
|
||||
<li>Limiter le ciblage au seul périmètre RNCS</li>
|
||||
<li>Afficher le nombre d'unité INSEE à chaque comptage</li>
|
||||
</ul>
|
||||
<div>
|
||||
<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" <?php if ($this->prefInterfaceInsee==1) echo ' checked="checked"';?> />
|
||||
</div>
|
||||
<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" <?php if ($this->prefFilterRncs==1) echo ' checked="checked"';?> />
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('input[type=checkbox]').click(function(){
|
||||
if($(this).is(':checked')) {
|
||||
$.post('/dashboard/pref/'+$(this).attr('name')+'/1' , function(data, status) {});
|
||||
} else {
|
||||
$.post('/dashboard/pref/'+$(this).attr('name')+'/0' , function(data, status) {});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<p>
|
||||
Afin de choisir les critères à masquer :
|
||||
|
5
application/views/default/scripts/dashboard/pref.phtml
Normal file
5
application/views/default/scripts/dashboard/pref.phtml
Normal file
@ -0,0 +1,5 @@
|
||||
<?php if ($this->nbRow>0) { ?>
|
||||
Préférence enregistrée.
|
||||
<?php } else {?>
|
||||
Erreur lors de l'enregistrement de la préférence.
|
||||
<?php } ?>
|
@ -18,8 +18,10 @@
|
||||
<div id="comptage" >
|
||||
<?php if ( $this->total!==null ) {?>
|
||||
Nombre sélectionnées :
|
||||
<span class="valeur"><?=$this->total?></span>
|
||||
(dont <span class="valeur"><?=$this->insee?></span> unité(s) insee)
|
||||
<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,14 +46,18 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
$view->total = number_format($session->getNb('total'), 0, '', ' ');
|
||||
$view->insee = number_format($session->getNb('insee'), 0, '', ' ');
|
||||
$view->total = $session->getNb('total');
|
||||
$view->insee = $session->getNb('insee');
|
||||
$view->msgComptage = true;
|
||||
}
|
||||
}
|
||||
|
@ -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