From b1ab4180f1fc42d4d1b9cb4c00edef96d4e9a363 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 28 May 2012 12:46:52 +0000 Subject: [PATCH 1/3] Modification diverses --- .../controllers/ComptageController.php | 3 +- .../controllers/DashboardController.php | 70 +++++++++++++++---- .../default/scripts/comptage/index.phtml | 5 +- .../scripts/dashboard/configuration.phtml | 30 ++++++-- .../default/scripts/dashboard/pref.phtml | 5 ++ .../views/default/scripts/header.phtml | 4 +- .../Controller/Plugin/Comptage.php | 4 +- 7 files changed, 94 insertions(+), 27 deletions(-) create mode 100644 application/views/default/scripts/dashboard/pref.phtml diff --git a/application/controllers/ComptageController.php b/application/controllers/ComptageController.php index 2a7d7776..22e4b537 100644 --- a/application/controllers/ComptageController.php +++ b/application/controllers/ComptageController.php @@ -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(); @@ -44,7 +43,7 @@ class ComptageController extends Zend_Controller_Action 'count' => number_format($total, 0, '', ' '), 'insee' => number_format($insee, 0, '', ' ') ); - echo json_encode($result); + $this->view->assign('result', $result); } public function resetAction() diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 45627484..d8063713 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -281,22 +281,68 @@ class DashboardController extends Zend_Controller_Action } + /** + * Display information about user's profil + */ public function configurationAction() { } -} - - - - - - - - - - - + /** + * 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); + } +} \ No newline at end of file diff --git a/application/views/default/scripts/comptage/index.phtml b/application/views/default/scripts/comptage/index.phtml index 6aff263c..ec3fd5be 100644 --- a/application/views/default/scripts/comptage/index.phtml +++ b/application/views/default/scripts/comptage/index.phtml @@ -1,4 +1 @@ -

-
-

View script for controller Comptage and script/action name index

-
\ No newline at end of file +result)?> \ No newline at end of file diff --git a/application/views/default/scripts/dashboard/configuration.phtml b/application/views/default/scripts/dashboard/configuration.phtml index c4a8d7c6..7bd80923 100644 --- a/application/views/default/scripts/dashboard/configuration.phtml +++ b/application/views/default/scripts/dashboard/configuration.phtml @@ -21,7 +21,7 @@ disponible.


-

Cas profil défini pas S&D

+

Cas profil défini par S&D

- Aucun profil d'enrichissement (Contacter le support)

- Liste des profils avec référence, tarifs à la ligne

@@ -46,11 +46,31 @@ utilisation correspondant à vos besoins.

Des préférences d'affichage ont été définies pour votre profil utilisateur.


- +
+
+Pour permettre une estimation du cout de la redevance INSEE, en activant cette option, +le nombre d'unité insee est affiché à chaque comptage
+prefInterfaceINSEE?> +
+

+
+
+Les éléments soumis à redevance INSEE sont automatiquement retirer du ciblage
+prefFilterRNCS?> +
+ + +

Afin de choisir les critères à masquer : diff --git a/application/views/default/scripts/dashboard/pref.phtml b/application/views/default/scripts/dashboard/pref.phtml new file mode 100644 index 00000000..3e780a2e --- /dev/null +++ b/application/views/default/scripts/dashboard/pref.phtml @@ -0,0 +1,5 @@ +nbRow>0) { ?> +Préférence enregistrée. + +Erreur lors de l'enregistrement de la préférence. + \ No newline at end of file diff --git a/application/views/default/scripts/header.phtml b/application/views/default/scripts/header.phtml index e05d47e8..f1958397 100644 --- a/application/views/default/scripts/header.phtml +++ b/application/views/default/scripts/header.phtml @@ -18,8 +18,8 @@

total!==null ) {?> Nombre sélectionnées : - total?> - (dont insee?> unité(s) insee) + total, 0, '', ' ')?> + (dont insee, 0, '', ' ')?> unité(s) insee) Aucune sélection. diff --git a/library/Application/Controller/Plugin/Comptage.php b/library/Application/Controller/Plugin/Comptage.php index 6599723d..b7e20a41 100644 --- a/library/Application/Controller/Plugin/Comptage.php +++ b/library/Application/Controller/Plugin/Comptage.php @@ -52,8 +52,8 @@ class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abst } } - $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; } } From 5ab91eb8c7adc83f2d7f4a67a20ad03a70192de8 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 28 May 2012 12:49:45 +0000 Subject: [PATCH 2/3] Delete SIRETs column during preview --- application/controllers/ComptageController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/controllers/ComptageController.php b/application/controllers/ComptageController.php index 22e4b537..95501ebf 100644 --- a/application/controllers/ComptageController.php +++ b/application/controllers/ComptageController.php @@ -203,8 +203,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(); From 1cd65fb0ab391b8243e8a6c707c0efccae0e2d9d Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 28 May 2012 15:17:18 +0000 Subject: [PATCH 3/3] Preferences --- .../controllers/ComptageController.php | 30 ++++++++++++++----- .../controllers/DashboardController.php | 20 +++++++++++-- .../scripts/dashboard/configuration.phtml | 13 ++++---- .../views/default/scripts/header.phtml | 2 ++ .../Controller/Plugin/Comptage.php | 6 +++- library/Scores/AuthAdapter.php | 6 ++++ public/themes/default/scripts/fields.js | 8 ++--- 7 files changed, 63 insertions(+), 22 deletions(-) diff --git a/application/controllers/ComptageController.php b/application/controllers/ComptageController.php index 95501ebf..fce668a2 100644 --- a/application/controllers/ComptageController.php +++ b/application/controllers/ComptageController.php @@ -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, diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index d8063713..22fe00b6 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -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)) { diff --git a/application/views/default/scripts/dashboard/configuration.phtml b/application/views/default/scripts/dashboard/configuration.phtml index 7bd80923..527dda33 100644 --- a/application/views/default/scripts/dashboard/configuration.phtml +++ b/application/views/default/scripts/dashboard/configuration.phtml @@ -50,22 +50,21 @@ utilisation correspondant à vos besoins.
Pour permettre une estimation du cout de la redevance INSEE, en activant cette option, le nombre d'unité insee est affiché à chaque comptage
-prefInterfaceINSEE?> +prefInterfaceInsee==1) echo ' checked="checked"';?> />
-

+

Les éléments soumis à redevance INSEE sont automatiquement retirer du ciblage
-prefFilterRNCS?> +prefFilterRncs==1) echo ' checked="checked"';?> />
diff --git a/application/views/default/scripts/header.phtml b/application/views/default/scripts/header.phtml index f1958397..c869c927 100644 --- a/application/views/default/scripts/header.phtml +++ b/application/views/default/scripts/header.phtml @@ -19,7 +19,9 @@ total!==null ) {?> Nombre sélectionnées : total, 0, '', ' ')?> + insee!==null ) {?> (dont insee, 0, '', ' ')?> unité(s) insee) + Aucune sélection. diff --git a/library/Application/Controller/Plugin/Comptage.php b/library/Application/Controller/Plugin/Comptage.php index b7e20a41..4982f327 100644 --- a/library/Application/Controller/Plugin/Comptage.php +++ b/library/Application/Controller/Plugin/Comptage.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); } } diff --git a/library/Scores/AuthAdapter.php b/library/Scores/AuthAdapter.php index aa52e179..cb64bf00 100644 --- a/library/Scores/AuthAdapter.php +++ b/library/Scores/AuthAdapter.php @@ -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); diff --git a/public/themes/default/scripts/fields.js b/public/themes/default/scripts/fields.js index 9623dfbd..dd81e457 100644 --- a/public/themes/default/scripts/fields.js +++ b/public/themes/default/scripts/fields.js @@ -242,10 +242,10 @@ function set(key, value, ex) $('#panel').html(''); $.post('/comptage/index', { cle:key, valeur:value, exlcude:ex }, function(data, status) { - var html = 'Nombre sélectionnées : ' + - data.count + ' (dont ' + - data.insee +' unité(s) insee)'; - + var html = 'Nombre sélectionnées : '+data.count+''; + if (data.insee>0) { + html = html + ' (dont '+data.insee +' unité(s) insee)'; + } $('#attente').css('display', 'none'); $('#comptage').html(html).css('display','block');