From a22421825d044a34c2525e91c11a96f2086aa64e Mon Sep 17 00:00:00 2001 From: Damien LASSERRE Date: Wed, 4 Jan 2012 11:29:07 +0000 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20de=20la=20structure=20de=20donn?= =?UTF-8?q?=C3=A9e=20des=20fields=20+=20mise=20a=20jours=20de=20la=20struc?= =?UTF-8?q?ture=20des=20pr=C3=A9f=C3=A9rences=20avec=20l'interfacage=20des?= =?UTF-8?q?=20deux=20dans=20un=20helper,=20les=20prefs=20sont=20charg?= =?UTF-8?q?=C3=A9s=20au=20predispatche=20de=20Zend=20pour=20chaque=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/Bootstrap.php | 1 - application/configs/application.ini | 1 + .../controllers/CriteresController.php | 89 +--- .../controllers/PreferencesController.php | 98 +++++ application/controllers/UserController.php | 4 +- application/views/default/helpers/Field.php | 122 ++++-- .../views/default/helpers/Interval.php | 32 -- application/views/default/helpers/Select.php | 32 -- application/views/default/helpers/Text.php | 33 -- .../views/default/helpers/Textarea.php | 34 -- .../default/scripts/criteres/entreprise.phtml | 38 +- .../Application/Controller/Plugin/Prefs.php | 87 ++++ library/Scores/Field.php | 410 ++++++++++++++++++ 13 files changed, 708 insertions(+), 273 deletions(-) create mode 100644 application/controllers/PreferencesController.php delete mode 100644 application/views/default/helpers/Interval.php delete mode 100644 application/views/default/helpers/Select.php delete mode 100644 application/views/default/helpers/Text.php delete mode 100644 application/views/default/helpers/Textarea.php create mode 100644 library/Application/Controller/Plugin/Prefs.php create mode 100644 library/Scores/Field.php diff --git a/application/Bootstrap.php b/application/Bootstrap.php index b3a556dd..42205418 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -62,5 +62,4 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap } Zend_Registry::set('db', $db); } - } \ No newline at end of file diff --git a/application/configs/application.ini b/application/configs/application.ini index 9a74e8e2..5e4bf8ed 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -10,6 +10,7 @@ resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.params.displayExceptions = 0 autoloaderNamespaces[] = "Application_" resources.frontController.plugins.Auth = "Application_Controller_Plugin_Auth" +resources.frontController.plugins.Auth = "Application_Controller_Plugin_Prefs" resources.frontController.plugins.Comptage = "Application_Controller_Plugin_Comptage" resources.layout.layout = "main" resources.layout.layoutPath = APPLICATION_PATH "/views/default" diff --git a/application/controllers/CriteresController.php b/application/controllers/CriteresController.php index c39d3cd6..1215ebed 100644 --- a/application/controllers/CriteresController.php +++ b/application/controllers/CriteresController.php @@ -1,12 +1,6 @@ 'siege', 'libelle' => 'Siège', 'type' => 'select', 'parametres' => array('Etablissement' => '0', 'Siege' => '1')), - array('name' => 'sirenGrp', 'libelle' => 'Siren de groupe', 'type' => 'select', 'parametres' => array('Oui' => '1', 'Non' => '0')), - array('name' => 'tel', 'libelle' => 'Téléphone', 'type' => 'select', 'parametres' => array('Oui' => 1, 'Non' => '0')), - array('name' => 'fax', 'libelle' => 'Télécopie', 'type' => 'select', 'parametres' => array('Oui' => 1, 'Non' => '0')), - array('name' => 'web', 'libelle' => 'Site Internet', 'type' => 'select', 'parametres' => array('Oui' => '1', 'Non' => '0')), - array('name' => 'mail', 'libelle' => 'Email', 'type' => 'select', 'parametres' => array('Oui' => '1', 'Non' => '0')), - array('name' => 'presentRcs', 'libelle' => 'Etablissement présent au RNCS', 'type' => 'select', 'parametres' => array('Oui' => '1', 'Non' => '0')), - array('name' => 'adrDom', 'libelle' => 'Adresse de domiciliation', 'type' => 'select', 'parametres' => array('Oui' => '1', 'Non' => '0')), - array('name' => 'dirNom', 'libelle' => 'Nom du principal dirigeant', 'type' => 'select', 'parametres' => array('Oui' => '1', 'Non' => '0')), - array('name' => 'lieuAct', 'libelle' => 'Lieu d\'activté', 'type' => 'select', 'parametres' => array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '91' => '91', '92' => '92', '93' => '93', '99' => '99')), - array('name' => 'nbMPubli', 'libelle' => 'Nombre de marchés publiques remportés', 'type' => 'interval:regle'), - array('name' => 'dateCrea_ent', 'libelle' => 'Date de création de l\'entreprose', 'type' => 'interval:date'), - array('name' => 'dateCrea_etab', 'libelle' => 'Date de création de l\'etablissement', 'type' => 'interval:date'), - array('name' => 'nbActio', 'libelle' => 'Nombre d\'actionnaires connus', 'type' => 'interval:regle'), - array('name' => 'nbPart', 'libelle' => 'Nombre de participations connues', 'type' => 'interval:regle') - ); - $select['entreprise'] = $this->entreprise; - $this->view->selectRow = $select; + /*$champs = Zend_Registry::get('entreprise');*/ $this->view->champs = $champs; } public function economiqueAction() { - $champs = array(array('name' => 'ape_etab', 'libelle' => 'Code NAF Etablissement', 'type' => 'text'), - array('name' => 'ou'), - array('name' => 'ape_etab', 'libelle' => 'Liste Code NAF Etablissement', 'type' => 'textarea'), - array('name' => 'ape_entrep', 'libelle' => 'Code NAF Entreprise', 'type' => 'text'), - array('name' => 'ou'), - array('name' => 'ape_entrep', 'libelle' => 'Liste Code NAF Entreprise', 'type' => 'textarea'), - array('name' => 'NaceEtab', 'libelle' => 'Code NACE de l\'établissement', 'type' => 'text'), - array('name' => 'ou'), - array('name' => 'NaceEtab', 'libelle' => 'Liste Code NACE de l\'établissement', 'type' => 'textarea'), - array('name' => 'NaceEntrep', 'libelle' => 'Code NACE de l\'entreprise', 'type' => 'text'), - array('name' => 'ou'), - array('name' => 'NaceEntrep', 'libelle' => 'Liste Code NACE de l\'entreprise', 'type' => 'textarea'), - array('name' => 'age_etab', 'libelle' => 'Code AGE Etablissement', 'type' => 'text'), - array('name' => 'age_entrep', 'libelle' => 'Code AGE Entreprise', 'type' => 'text'), - array('name' => 'teff_entrep', 'libelle' => 'Tranche d\'effectif de l\'entreprise', 'type' => 'interval:regle'), - array('name' => 'teff_etab', 'libelle' => 'Tranche d\'effectif de l\'etablissement', 'type' => 'interval:regle'), - array('name' => 'nbEtab', 'libelle' => 'Nombre d\'établissements', 'type' => 'interval'), - array('name' => 'eff_entrep', 'libelle' => 'Effectif réel de l\'entreprise', 'type' => 'interval'), - array('name' => 'eff_etab', 'libelle' => 'Effectif réel de l\'établissement', 'type' => 'interval'), - array('name' => 'capital', 'libelle' => 'Capital de l\'entreprise', 'type' => 'interval:regle'), - ); + /*$champs = Zend_Registry::get('economique');*/ $this->view->champs = $champs; } public function geographiqueAction() { - //$this->_helper->layout()->disableLayout(); $this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js'); - $champs = array(array('name' => 'adr_cp', 'libelle' => 'Code postal', 'type' => 'text'), - array('name' => 'ou'), - array('name' => 'adr_cp', 'libelle' => 'Liste Code postal', 'type' => 'textarea'), - array('name' => 'adr_dep', 'libelle' => 'Département', 'type' => 'text'), - array('name' => 'ou'), - array('name' => 'adr_dep', 'libelle' => 'Liste Département', 'type' => 'textarea'), - array('name' => 'adr_com', 'libelle' => 'Code commune Insee', 'type' => 'text'), - array('name' => 'ou'), - array('name' => 'adr_com', 'libelle' => 'Liste Code commune Insee', 'type' => 'textarea'), - ); + /*$champs = Zend_Registry::get('geographique');*/ $this->view->champs = $champs; } public function juridiqueAction() { - $champs = array(array('name' => 'cj', 'libelle' => 'Forme Juridique', 'type' => 'select', 'parametres' => array('1' => '1', '2' => '2', '3' => '3')), - array('name' => 'actifEco', 'libelle' => 'Établissement économiquement actif', 'type' => 'select', 'parametres' => array('Oui' => '1', 'Non' => '0')), - array('name' => 'procolHisto', 'libelle' => 'Présence d\'une procédure collective dans l\'histo.', 'type' => 'select', 'parametres' => array('Oui' => '1', 'Non' => '0')), - array('name' => 'tvaIntraValide', 'libelle' => 'Numéro de TVA Valide', 'type' => 'select', 'parametres' => array('Oui' => '1', 'Non' => '0')), - array('name' => 'dateImmat', 'libelle' => 'Date d\'immatriculation de l\'entreprise', 'type' => 'interval:date') - - ); + /*$champs = Zend_Registry::get('juridique');*/ $this->view->champs = $champs; } public function financiereAction() { - $champs = array(array('name' => 'bilType', 'libelle' => 'Type du dernier bilan', 'type' => 'select', 'parametres' => array('Inconnue' => 'I', 'Estimé' => 'E', 'Réel' => 'R')), - array('name' => 'avisCs', 'libelle' => 'Informations de paiements', 'type' => 'select', 'parametres' => $this->createSelectProvisoir(50)), - array('name' => 'bilDuree', 'libelle' => 'Durée du dernier bilan en mois', 'type' => 'select', 'parametres' => $this->createSelectProvisoir(9)), - array('name' => 'bilTca', 'libelle' => 'Tranche de CA issue du bilan', 'type' => 'select', 'parametres' => $this->createSelectProvisoir(23)), - array('name' => 'bilAnnee', 'libelle' => 'Dernière année de bilan', 'type' => 'interval'), - array('name' => 'bilCloture', 'libelle' => 'Dernière date de clôture du bilan', 'type' => 'interval'), - array('name' => 'bilEE', 'libelle' => 'Total bilan', 'type' => 'interval'), - array('name' => 'bilFL', 'libelle' => 'CA total', 'type' => 'interval'), - array('name' => 'bilFK', 'libelle' => 'Chiffre d\'affaires Export', 'type' => 'interval'), - array('name' => 'bilFR', 'libelle' => 'Produits d\'Exploitation', 'type' => 'interval'), - array('name' => 'bilGF', 'libelle' => 'Charges d\'Exploitation', 'type' => 'interval'), - array('name' => 'bilGP', 'libelle' => 'Produits Financiers', 'type' => 'interval'), - array('name' => 'bilGU', 'libelle' => 'Charges Financières', 'type' => 'interval'), - array('name' => 'bilGW', 'libelle' => 'RCAI (résultat courant avant impôt)', 'type' => 'interval'), - array('name' => 'bilHD', 'libelle' => 'Produits Exceptionnels', 'type' => 'interval'), - array('name' => 'bilHH', 'libelle' => 'Charges Exceptionnels', 'type' => 'interval'), - array('name' => 'bilHL', 'libelle' => 'Total des Produits', 'type' => 'interval'), - array('name' => 'bilHM', 'libelle' => 'Total des Charges', 'type' => 'interval'), - array('name' => 'bilHN', 'libelle' => 'Résultat', 'type' => 'interval'), - array('name' => 'bilYP', 'libelle' => 'Effectif de l\'entreprise au dernier bilan (poste YP)', 'type' => 'interval') - ); + /*$champs = Zend_Registry::get('financier');*/ $this->view->champs = $champs; } diff --git a/application/controllers/PreferencesController.php b/application/controllers/PreferencesController.php new file mode 100644 index 00000000..b87945fa --- /dev/null +++ b/application/controllers/PreferencesController.php @@ -0,0 +1,98 @@ +hasIdentity()) + { + $this->db = Zend_Registry::get('db'); + $this->prefs = Zend_Registry::get($registre); + $this->prefs->$name = true; + + $this->update(); + } + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + } + + public function removeAction($registre, $name) + { + $auth = Zend_Auth::getInstance(); + + if($auth->hasIdentity()) + { + $this->db = Zend_Registry::get('db'); + $this->prefs = Zend_Registry::get($registre); + $this->prefs->$name = false; + + $this->update(); + } + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + } + + public function checkAction($registre, $name) + { + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $auth = Zend_Auth::getInstance(); + + if($auth->hasIdentity()) + { + $this->prefs = Zend_Registry::get($registre); + if($this->prefs->$name) + return (true); + } + return (false); + } + + public function save() + { + $auth = Zend_Auth::getInstance(); + + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $registre = array('login' => $user->username, + 'entreprise' => Zend_Registry::get('entreprise'), + 'economique' => Zend_Registry::get('economique'), + 'geographique' => Zend_Registry::get('geographique'), + 'juridique' => Zend_Registry::get('juridique'), + 'financier' => Zend_Registry::get('juridique') + ); + $this->db = Zend_Registry::get('db'); + $db->insert('prefs',$registre); + } + } + + public function update($registre) + { + $auth = Zend_Auth::getInstance(); + + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $this->db = Zend_Registry::get('db'); + $db->update('prefs', array($registre => json_encode(Zend_Registry::get($registre))), 'login = "'.$user->username.'"'); + } + } + + public function getFormulaire($registre, $prefs) { + $formulaire = array(); + + foreach($prefs as $pref) { + foreach($this->champs[$registre] as $champ) { + if($champ['name'] == $pref and $pref) { + $formulaire[] = $champ; + } + } + } + return ($formulaire); + } + +} \ No newline at end of file diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index 86425a21..ea35bdc2 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -83,11 +83,9 @@ class UserController extends Zend_Controller_Action 'action' => 'login', )); } - + $this->view->assign('url', $url); $this->view->headMeta()->appendHttpEquiv('refresh', '5; url='.$url); $this->render('logout'); } - - } \ No newline at end of file diff --git a/application/views/default/helpers/Field.php b/application/views/default/helpers/Field.php index 49b1f838..fb9048f0 100644 --- a/application/views/default/helpers/Field.php +++ b/application/views/default/helpers/Field.php @@ -1,42 +1,102 @@ array( - 'label' => - 'fields' => array( - 0 => array( - type => {select, text, slider, autocomplete}, - value => - ) - ... multiple champs possible, 0 est le primaire ... - ) -)) - - - Défintion de la structure HTML -
- -
- - Texte, bouton de validation, lien pour afficher, switcher vers un autre formulaire -
-
- */ - Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract { - /** - * Affiche la structure d'un champ en fonction de sa définition - * @param string $name - */ - public function field($name) + public function Field($name) { + $prefs = Zend_Registry::get('prefs'); - + if($prefs[$name]['activated']) + { + require_once 'Scores/SessionCiblage.php'; + require_once 'Scores/Field.php'; + + $session = new SessionCiblage(); + $field = new Fields(); + $field = $field->get($name); + + foreach($field['fields'] as $item) { + if($item['type'] == $prefs[$name]['type']) + { + switch($item['type']) + { + case 'select': + return ($this->selectHTML($name, $field, $item)); + case 'interval': + return ($this->intervalHTML($name, $field, $item)); + case 'date': + return ($this->dateHTML($name, $field, $item)); + case 'text': + return ($this->textHTML($name, $field, $item)); + case 'textarea': + return ($this->textareaHTML($name, $field, $item)); + case 'radio': + return ($this->radioHTML($name, $field, $item)); + } + } + } + } + return (false); } + private function selectHTML($name, $field, $item) + { + $return .= '
'; + $return .= '
'; + $return .= '
'; + return ($return); + } + private function intervalHTML($name, $field, $item) + { + $return = '
'; + $return .= '
'; + $return .= '
'; + $return .= ''; + $return .= '
'; + + return ($return); + } + private function dateHTML($name, $field, $item) + { + $return = '
'; + $return .= '
'; + $return .= '
a '; + $return .= '
'; + $return .= '
'; + + return ($return); + } + + private function textHTML($name, $field, $item) + { + $return .= '
'; + $return .= '
'; + $return .= '
'; + $return .= '
'; + + return ($return); + } + + private function textareaHTML($name, $field, $item) + { + $return .= '
'; + $return .= '
'; + $return .= '
'; + $return .= '

'; + $return .= '
'; + + return ($return); + } + + private function radioHTML($name, $field, $item) + { + // en cours. + } } \ No newline at end of file diff --git a/application/views/default/helpers/Interval.php b/application/views/default/helpers/Interval.php deleted file mode 100644 index eaeb3f99..00000000 --- a/application/views/default/helpers/Interval.php +++ /dev/null @@ -1,32 +0,0 @@ -getCritere($name); - if (is_array($values)){ - return $values; - } - return array(0,0); - } - - public function Interval($name, $libelle, $date = false) - { - $minMax = $this->getMinMax($name); - - $champ = '
'; - $champ .= '
- -
'; - $champ .= '
- -
-
'; - $champ .= '
'; - - return ($champ); - } -} \ No newline at end of file diff --git a/application/views/default/helpers/Select.php b/application/views/default/helpers/Select.php deleted file mode 100644 index c8c98922..00000000 --- a/application/views/default/helpers/Select.php +++ /dev/null @@ -1,32 +0,0 @@ -getCritere($name); - - $champ .= '
'; - - $champ .= '
- -
'; - $champ .= '
- -
'; - $champ .= '
'; - - return ($champ); - } -} \ No newline at end of file diff --git a/application/views/default/helpers/Text.php b/application/views/default/helpers/Text.php deleted file mode 100644 index 02978327..00000000 --- a/application/views/default/helpers/Text.php +++ /dev/null @@ -1,33 +0,0 @@ -getCritere($name); - $val = !empty($value) ? $this->printHistorique($value) : null; - - $champ = '
'; - $champ .= '
- -
'; - $champ .= '
- -
'; - $champ .= '
- -
'; - $champ .= '
'; - - return ($champ); - } -} \ No newline at end of file diff --git a/application/views/default/helpers/Textarea.php b/application/views/default/helpers/Textarea.php deleted file mode 100644 index 4ab1edf7..00000000 --- a/application/views/default/helpers/Textarea.php +++ /dev/null @@ -1,34 +0,0 @@ -getCritere($name); - $val = !empty($value) ? $this->printHistorique($value) : 'Code séparé par des virgules...'; - - $champ = '
'; - $champ .= '
- -
'; - $champ .= '
- -
-
'; - $champ .= '
-
-
'; - $champ .= '
'; - - return ($champ); - } -} \ No newline at end of file diff --git a/application/views/default/scripts/criteres/entreprise.phtml b/application/views/default/scripts/criteres/entreprise.phtml index 338cc3ac..4d16ba92 100644 --- a/application/views/default/scripts/criteres/entreprise.phtml +++ b/application/views/default/scripts/criteres/entreprise.phtml @@ -11,29 +11,21 @@
diff --git a/library/Application/Controller/Plugin/Prefs.php b/library/Application/Controller/Plugin/Prefs.php new file mode 100644 index 00000000..6834e8d2 --- /dev/null +++ b/library/Application/Controller/Plugin/Prefs.php @@ -0,0 +1,87 @@ + array('activated' => true, 'type' => 'select'), + 'sirenGrp' => array('activated' => true, 'type' => 'select'), + 'tel' => array('activated' => true, 'type' => 'select'), + 'fax' => array('activated' => true, 'type' => 'select'), + 'web' => array('activated' => true, 'type' => 'select'), + 'mail' => array('activated' => true, 'type' => 'select'), + 'presentRcs' => array('activated' => true, 'type' => 'select'), + 'adrDom' => array('activated' => true, 'type' => 'select'), + 'dirNom' => array('activated' => true, 'type' => 'select'), + 'lieuAct' => array('activated' => true, 'type' => 'select'), + 'nbMPubli' => array('activated' => true, 'type' => 'interval'), + 'dateCrea_ent' => array('activated' => true, 'type' => 'date'), + 'dateCrea_etab' => array('activated' => true, 'type' => 'date'), + 'nbActio' => array('activated' => true, 'type' => 'interval'), + 'nbPart' => array('activated' => true, 'type' => 'interval'), + 'ape_etab' => array('activated' => true, 'type' => 'text'), + 'ape_etab' => array('activated' => true, 'type' => 'text'), + 'ape_entrep' => array('activated' => true, 'type' => 'text'), + 'ape_entrep' => array('activated' => true, 'type' => 'text'), + 'NaceEtab' => array('activated' => true, 'type' => 'text'), + 'NaceEntrep' => array('activated' => true, 'type' => 'text'), + 'age_etab' => array('activated' => true, 'type' => 'text'), + 'age_entrep' => array('activated' => true, 'type' => 'text'), + 'teff_entrep' => array('activated' => true, 'type' => 'interval'), + 'teff_etab' => array('activated' => true, 'type' => 'interval'), + 'nbEtab' => array('activated' => true, 'type' => 'interval'), + 'eff_entrep' => array('activated' => true, 'type' => 'interval'), + 'eff_etab' => array('activated' => true, 'type' => 'interval'), + 'capital' => array('activated' => true, 'type' => 'interval'), + 'adr_cp' => array('activated' => true, 'type' => 'text'), + 'adr_dep' => array('activated' => true, 'type' => 'text'), + 'adr_com' => array('activated' => true, 'type' => 'text'), + 'cj' => array('activated' => true, 'type' => 'select'), + 'actifEco' => array('activated' => true, 'type' => 'select'), + 'procolHisto' => array('activated' => true, 'type' => 'select'), + 'tvaIntraValide'=> array('activated' => true, 'type' => 'select'), + 'dateImmat' => array('activated' => true, 'type' => 'date'), + 'bilType' => array('activated' => true, 'type' => 'select'), + 'avisCs' => array('activated' => true, 'type' => 'select'), + 'bilDuree' => array('activated' => true, 'type' => 'date'), + 'bilTca' => array('activated' => true, 'type' => 'interval'), + 'bilAnnee' => array('activated' => true, 'type' => 'interval'), + 'bilCloture' => array('activated' => true, 'type' => 'interval'), + 'bilEE' => array('activated' => true, 'type' => 'interval'), + 'bilFL' => array('activated' => true, 'type' => 'interval'), + 'bilFK' => array('activated' => true, 'type' => 'interval'), + 'bilFR' => array('activated' => true, 'type' => 'interval'), + 'bilGF' => array('activated' => true, 'type' => 'interval'), + 'bilGP' => array('activated' => true, 'type' => 'interval'), + 'bilGU' => array('activated' => true, 'type' => 'interval'), + 'bilGW' => array('activated' => true, 'type' => 'interval'), + 'bilHD' => array('activated' => true, 'type' => 'interval'), + 'bilHH' => array('activated' => true, 'type' => 'interval'), + 'bilHL' => array('activated' => true, 'type' => 'interval'), + 'bilHM' => array('activated' => true, 'type' => 'interval'), + 'bilHN' => array('activated' => true, 'type' => 'interval'), + 'bilYP' => array('activated' => true, 'type' => 'interval'), + ); + + //Pre dispatch pour recuperer les préférence de l'utilisateur avant chaque page. + public function preDispatch(Zend_Controller_Request_Abstract $request) + { + $auth = Zend_Auth::getInstance(); + $this->db = Zend_Registry::get('db'); + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $this->login = $user->username; + $database = Zend_Registry::get('db'); + $select = $database->select() + ->from('prefs') + ->where('login = ?', $user->username); + $result = $this->db->query($select); + $json = $result->fetchAll(); + if(!empty($json)) + $prefs = json_decode($json[0]['prefs']); + else + $prefs = $this->preferences; + + Zend_Registry::set('prefs', $prefs); + } + } +} \ No newline at end of file diff --git a/library/Scores/Field.php b/library/Scores/Field.php new file mode 100644 index 00000000..ae595eca --- /dev/null +++ b/library/Scores/Field.php @@ -0,0 +1,410 @@ + array( + 'label' => 'Siege', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui', 'Non')) + ), + 'famille' => 'entreprise' + ), + 'sirenGrp' => array( + 'label' => 'Siren de groupe', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui', 'Non')) + ), + 'famille' => 'entreprise' + ), + 'tel' => array( + 'label' => 'Telephone', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui', 'Non')) + ), + 'famille' => 'entreprise' + ), + 'fax' => array( + 'label' => 'Telecopie', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui', 'Non')) + ), + 'famille' => 'entreprise' + ), + 'web' => array( + 'label' => 'Site Internet', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui', 'Non')) + ), + 'famille' => 'entreprise' + ), + 'mail' => array( + 'label' => 'Email', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui', 'Non')) + ), + 'famille' => 'entreprise' + ), + 'presentRcs' => array( + 'label' => 'Etablissement présent au RNCS', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui', 'Non')) + ), + 'famille' => 'entreprise' + ), + 'adrDom' => array( + 'label' => 'Adresse de domiciliation', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui', 'Non')) + ), + 'famille' => 'entreprise' + ), + 'dirNom' => array( + 'label' => 'Nom du principal dirigeant', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui', 'Non')) + ), + 'famille' => 'entreprise' + ), + 'lieuAct' => array( + 'label' => 'Lieu d\'activté', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '1000')) + ), + 'famille' => 'entreprise' + ), + 'nbMPubli' => array( + 'label' => 'Nombre de marches publiques remportes', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '1000')) + ), + 'famille' => 'entreprise' + ), + 'dateCrea_ent' => array( + 'label' => 'Date de création de l\'entreprose', + 'fields' => array( + array('type' => 'date') + ), + 'famille' => 'entreprise' + ), + 'dateCrea_etab' => array( + 'label' => 'Date de création de l\'etablissement', + 'fields' => array( + array('type' => 'date') + ), + 'famille' => 'entreprise' + ), + 'nbActio' => array( + 'label' => 'Nombre d\'actionnaires connus', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '1000')) + ), + 'famille' => 'entreprise' + ), + 'nbPart' => array( + 'label' => 'Nombre de participations connues', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '1000')) + ), + 'famille' => 'entreprise' + ), + // economique + 'ape_etab' => array( + 'label' => 'Code NAF Etablissement', + 'fields' => array( + array('type' => 'text', 'value' => null), + array('type' => 'textarea', 'value' => null) + ), + 'famille' => 'economique' + ), + 'ape_entrep' => array( + 'label' => 'Code NAF Entreprise', + 'fields' => array( + array('type' => 'text', 'value' => null), + array('type' => 'textarea', 'value' => null) + ), + 'famille' => 'economique' + ), + 'NaceEtab' => array( + 'label' => 'Code NACE de l\'établissement', + 'fields' => array( + array('type' => 'text', 'value' => null), + array('type' => 'textarea', 'value' => null) + ), + 'famille' => 'economique' + ), + 'NaceEntrep' => array( + 'label' => 'Code NACE de l\'entreprise', + 'fields' => array( + array('type' => 'text', 'value' => null), + array('type' => 'textarea', 'value' => null) + ), + 'famille' => 'economique' + ), + 'age_etab' => array( + 'label' => 'Code AGE Etablissement', + 'fields' => array( + array('type' => 'text', 'value' => null), + array('type' => 'textarea', 'value' => null) + ), + 'famille' => 'economique' + ), + 'age_entrep' => array( + 'label' => 'Code AGE Entreprise', + 'fields' => array( + array('type' => 'text', 'value' => null), + array('type' => 'textarea', 'value' => null) + ), + 'famille' => 'economique' + ), + 'teff_entrep' => array( + 'label' => 'Tranche d\'effectif de l\'Entreprise', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '1000')) + ), + 'famille' => 'economique' + ), + 'teff_etab' => array( + 'label' => 'Tranche d\'effectif de l\'etablissement', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '1000')) + ), + 'famille' => 'economique' + ), + 'nbEtab' => array( + 'label' => 'Tranche d\'effectif de l\'etablissement', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '100000')) + ), + 'famille' => 'economique' + ), + 'eff_entrep' => array( + 'label' => 'Effectif réel de l\'entreprise', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '1000')) + ), + 'famille' => 'economique' + ), + 'eff_etab' => array( + 'label' => 'Effectif réel de l\'établissement', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '1000')) + ), + 'famille' => 'economique' + ), + 'capital' => array( + 'label' => 'Capital de l\'entreprise', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'economique' + ), + //geographique + 'adr_cp' => array( + 'label' => 'Code postal', + 'fields' => array( + array('type' => 'text', 'value' => null), + array('type' => 'textarea', 'value' => null) + ), + 'famille' => 'geographique' + ), + 'adr_dep' => array( + 'label' => 'Département', + 'fields' => array( + array('type' => 'text', 'value' => null), + array('type' => 'textarea', 'value' => null) + ), + 'famille' => 'geographique' + ), + 'adr_com' => array( + 'label' => 'Code commune Insee', + 'fields' => array( + array('type' => 'text', 'value' => null), + array('type' => 'textarea', 'value' => null) + ), + 'famille' => 'geographique' + ), + //juridique + 'cj' => array( + 'label' => 'Forme Juridique', + 'fields' => array( + array('type' => 'select', 'value' => array('1' => '1', '2' => '2', '3' => '3')), + ), + 'famille' => 'geographique' + ), + 'actifEco' => array( + 'label' => 'Établissement économiquement actif', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui' => '1', 'Non' => '0')), + ), + 'famille' => 'geographique' + ), + 'procolHisto' => array( + 'label' => 'Présence d\'une procédure collective dans l\'histo.', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui' => '1', 'Non' => '0')), + ), + 'famille' => 'geographique' + ), + 'tvaIntraValide' => array( + 'label' => 'Numéro de TVA Valide', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui' => '1', 'Non' => '0')), + ), + 'famille' => 'geographique' + ), + 'dateImmat' => array( + 'label' => 'Numéro de TVA Valide', + 'fields' => array( + array('type' => 'date', 'value' => null), + ), + 'famille' => 'geographique' + ), + //financier + 'bilType' => array( + 'label' => 'Type du dernier bilan', + 'fields' => array( + array('type' => 'select', 'value' => array('Inconnue' => 'I', 'Estimé' => 'E', 'Réel' => 'R')), + ), + 'famille' => 'financier' + ), + 'avisCs' => array( + 'label' => 'Informations de paiements', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui' => '1', 'Non' => '0')), + ), + 'famille' => 'financier' + ), + 'bilDuree' => array( + 'label' => 'Durée du dernier bilan en mois', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui' => '1', 'Non' => '0')), + ), + 'famille' => 'financier' + ), + 'bilTca' => array( + 'label' => 'Tranche de CA issue du bilan', + 'fields' => array( + array('type' => 'select', 'value' => array('Oui' => '1', 'Non' => '0')), + ), + 'famille' => 'financier' + ), + 'bilAnnee' => array( + 'label' => 'Dernière année de bilan', + 'fields' => array( + array('type' => 'date', 'value' => null), + ), + 'famille' => 'financier' + ), + 'bilCloture' => array( + 'label' => 'Dernière date de clôture du bilan', + 'fields' => array( + array('type' => 'date', 'value' => null), + ), + 'famille' => 'financier' + ), + 'bilEE' => array( + 'label' => 'Total bilan', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilFL' => array( + 'label' => 'CA total', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilFK' => array( + 'label' => 'Chiffre d\'affaires Export', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilFR' => array( + 'label' => 'Produits d\'Exploitation', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilGF' => array( + 'label' => 'Charges d\'Exploitation', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilGP' => array( + 'label' => 'Produits Financiers', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilGP' => array( + 'label' => 'Charges Financières', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilGW' => array( + 'label' => 'RCAI (résultat courant avant impôt)', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilHD' => array( + 'label' => 'Produits Exceptionnels', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilHH' => array( + 'label' => 'Charges Exceptionnels', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilHL' => array( + 'label' => 'Total des Produits', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilHM' => array( + 'label' => 'Total des Charges', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilHN' => array( + 'label' => 'Résultat', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ), + 'bilYP' => array( + 'label' => 'Effectif de l\'entreprise au dernier bilan (poste YP)', + 'fields' => array( + array('type' => 'interval', 'value' => array('0', '10000000')) + ), + 'famille' => 'financier' + ) + ); + + public function get($name) + { + return ($this->fields[$name]); + } +} \ No newline at end of file