From bf4ad53075975fae21cc3905883111211bed8d39 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 29 Nov 2011 15:53:05 +0000 Subject: [PATCH] Ajout --- application/Bootstrap.php | 3 +- .../controllers/ArborescenceController.php | 97 +++++++++++++++ .../controllers/CriteresController.php | 18 --- .../controllers/DashboardController.php | 8 ++ .../controllers/RechercheController.php | 30 +++++ .../scripts/arborescence/geographique.phtml | 23 ++++ .../default/scripts/arborescence/naf.phtml | 24 ++++ .../default/scripts/criteres/economique.phtml | 36 ++---- .../default/scripts/criteres/entreprise.phtml | 8 +- .../default/scripts/criteres/financiere.phtml | 6 +- .../scripts/criteres/geographique.phtml | 27 +---- .../default/scripts/criteres/juridique.phtml | 6 +- .../views/default/scripts/index/index.phtml | 4 +- batch/getDataCSV.php | 110 ++++++++++++++++++ .../themes/default/scripts/jquery.cookie.js | 41 +++++++ public/themes/default/styles/main.css | 4 +- 16 files changed, 369 insertions(+), 76 deletions(-) create mode 100644 application/controllers/ArborescenceController.php create mode 100644 application/controllers/DashboardController.php create mode 100644 application/controllers/RechercheController.php create mode 100644 application/views/default/scripts/arborescence/geographique.phtml create mode 100644 application/views/default/scripts/arborescence/naf.phtml create mode 100644 batch/getDataCSV.php create mode 100644 public/themes/default/scripts/jquery.cookie.js diff --git a/application/Bootstrap.php b/application/Bootstrap.php index bd5497aa..6dd579a9 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -29,16 +29,15 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap ->appendStylesheet($pathStyle.'/jquery.qtip.css', 'all') ->appendStylesheet($pathStyle.'/main.css', 'all') ->appendStylesheet('/themes/jstree/default/style.css'); - $view->headScript() ->appendFile($pathScript.'/jquery.js', 'text/javascript') ->appendFile($pathScript.'/jquery.bgiframe.js', 'text/javascript') + ->appendFile($pathScript.'/jquery.cookie.js', 'text/javascript') ->appendFile($pathScript.'/jquery-ui.js', 'text/javascript') ->appendFile($pathScript.'/jquery.qtip.js', 'text/javascript') ->appendFile($pathScript.'/scripts.js', 'text/javascript'); - $view->headTitle()->setSeparator(' - '); $view->headTitle('Odea'); } diff --git a/application/controllers/ArborescenceController.php b/application/controllers/ArborescenceController.php new file mode 100644 index 00000000..800d006d --- /dev/null +++ b/application/controllers/ArborescenceController.php @@ -0,0 +1,97 @@ +_helper->layout()->disableLayout(); + + $this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js'); + + $request = $this->getRequest(); + $niveau = $request->getParam('niveau', 1); + + $nafM = new Application_Model_Naf(); + $sql = $nafM->select()->where('niveau = ?', $niveau)->order('code ASC'); + $result = $nafM->fetchAll($sql)->toArray(); + + $tabNaf = array(); + foreach($result as $item){ + $tabNaf[] = array( + 'data' => $item['code'].' - '.$item['lib'], + 'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']), + 'state' => 'closed', + 'children' => array(), + ); + } + $this->view->assign('naf', json_encode($tabNaf)); + } + + public function nafajaxAction() + { + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $request = $this->getRequest(); + $niveau = $request->getParam('niveau', 1); + $niveau++; + $parent = $request->getParam('parent', ''); + $nafM = new Application_Model_Naf(); + $sql = $nafM->select(); + if (!empty($parent) && $niveau==2) { + $sql->where('parent = ?', $parent); + } elseif (!empty($parent) && $niveau>2) { + $sql->where("code LIKE '".$parent."%'"); + } + $sql->where('niveau = ?', $niveau)->order('code ASC'); + + $result = $nafM->fetchAll($sql)->toArray(); + $tabNaf = array(); + foreach($result as $item){ + $naf = array( + 'data' => $item['code'].' - '.$item['lib'], + 'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']), + ); + if ($niveau<5){ + $naf['state'] = 'closed'; + $naf['children'] = array(); + } + $tabNaf[] = $naf; + } + echo json_encode($tabNaf); + } + + + + /** + * + * Enter description here ... + */ + public function geographiqueAction() + { + $this->_helper->layout()->disableLayout(); + $this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js'); + + $regionsM = new Application_Model_Regions(); + //$sql = $regionsM->select(); + $this->view->assign('regions', $regionsM->fetchAll()->toArray()); + } + + /** + * + * Enter description here ... + */ + public function juridqueAction() + { + + } + + + + +} \ No newline at end of file diff --git a/application/controllers/CriteresController.php b/application/controllers/CriteresController.php index d599af78..ccec6b33 100644 --- a/application/controllers/CriteresController.php +++ b/application/controllers/CriteresController.php @@ -11,25 +11,7 @@ class CriteresController extends Zend_Controller_Action public function economiqueAction() { $this->_helper->layout()->disableLayout(); - $this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js'); - $request = $this->getRequest(); - $niveau = 1; - - $nafM = new Application_Model_Naf(); - $sql = $nafM->select()->where('niveau = ?', $niveau)->order('code ASC'); - $result = $nafM->fetchAll($sql)->toArray(); - - $tabNaf = array(); - foreach($result as $item){ - $tabNaf[] = array( - 'data' => $item['code'].' - '.$item['lib'], - 'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']), - 'state' => 'closed', - 'children' => array(), - ); - } - $this->view->assign('naf', json_encode($tabNaf)); } public function nafAction() diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php new file mode 100644 index 00000000..e67c208c --- /dev/null +++ b/application/controllers/DashboardController.php @@ -0,0 +1,8 @@ + + + + + +inlineScript()?> + \ No newline at end of file diff --git a/application/views/default/scripts/arborescence/naf.phtml b/application/views/default/scripts/arborescence/naf.phtml new file mode 100644 index 00000000..7a36ffbf --- /dev/null +++ b/application/views/default/scripts/arborescence/naf.phtml @@ -0,0 +1,24 @@ +

Liste des NAF

+
+
+ +inlineScript()?> + \ No newline at end of file diff --git a/application/views/default/scripts/criteres/economique.phtml b/application/views/default/scripts/criteres/economique.phtml index 8f4ad493..91571608 100644 --- a/application/views/default/scripts/criteres/economique.phtml +++ b/application/views/default/scripts/criteres/economique.phtml @@ -4,34 +4,16 @@
-

Liste des NAF

-
+
+
+ +
+Intégrer dans les critères +

-
-
- + +
+Réinitialiser les critères économiques
- -inlineScript()?> - - diff --git a/application/views/default/scripts/criteres/entreprise.phtml b/application/views/default/scripts/criteres/entreprise.phtml index 5fa07003..1dde1b0d 100644 --- a/application/views/default/scripts/criteres/entreprise.phtml +++ b/application/views/default/scripts/criteres/entreprise.phtml @@ -1,3 +1,4 @@ +

-Intervalle Effectif (Tranches ou Réel) - Entreprise, Etablissement \ No newline at end of file +Intervalle Effectif (Tranches ou Réel) - Entreprise, Etablissement +
+ +
+Réinitialiser les critères entreprises +
\ No newline at end of file diff --git a/application/views/default/scripts/criteres/financiere.phtml b/application/views/default/scripts/criteres/financiere.phtml index 3b123456..7aec9994 100644 --- a/application/views/default/scripts/criteres/financiere.phtml +++ b/application/views/default/scripts/criteres/financiere.phtml @@ -9,4 +9,8 @@ Intervalle CA - Selection (Moins de 15000 euros, de 15000 à 30000, de 30000 à

Intervalle CA à l'export

ACTIF - PASSIF - COMPTE DE RESULTAT - ANNEXES

Ratios

-

Scores (Risques de défaillance)

\ No newline at end of file +

Scores (Risques de défaillance)

+ +
+Réinitialiser les critères financiers +
\ No newline at end of file diff --git a/application/views/default/scripts/criteres/geographique.phtml b/application/views/default/scripts/criteres/geographique.phtml index 78a40e69..d997a0b1 100644 --- a/application/views/default/scripts/criteres/geographique.phtml +++ b/application/views/default/scripts/criteres/geographique.phtml @@ -18,27 +18,6 @@
-

Sélection Interactive

-
-
    -regions as $region): ?> -
  • -  -  -
  • - -
-
- -inlineScript()?> - - +
+Réinitialiser les critères géographiques +
\ No newline at end of file diff --git a/application/views/default/scripts/criteres/juridique.phtml b/application/views/default/scripts/criteres/juridique.phtml index 115697ba..010672f4 100644 --- a/application/views/default/scripts/criteres/juridique.phtml +++ b/application/views/default/scripts/criteres/juridique.phtml @@ -9,4 +9,8 @@
Consulter la liste des catégories juridiques, ex: 75,78,...

- \ No newline at end of file + + +
+Réinitialiser les critères juridiques +
\ No newline at end of file diff --git a/application/views/default/scripts/index/index.phtml b/application/views/default/scripts/index/index.phtml index 0c8aaf3b..03056bfb 100644 --- a/application/views/default/scripts/index/index.phtml +++ b/application/views/default/scripts/index/index.phtml @@ -1,4 +1,3 @@ -
  • Critères Entreprise
  • @@ -28,6 +27,9 @@ Rappel des critères de selection $(function() { $( "#tabs" ).tabs({ cache: true, + cookie: { + expires: 1 + }, ajaxOptions: { error: function( xhr, status, index, anchor ) { $( anchor.hash ).html("Erreur lors du chargement..."); diff --git a/batch/getDataCSV.php b/batch/getDataCSV.php new file mode 100644 index 00000000..89e3ee4c --- /dev/null +++ b/batch/getDataCSV.php @@ -0,0 +1,110 @@ +#!/usr/bin/php -q + "Affiche l'aide.", + 'all' => "Charge tout les éléments", + 'one' => "Charge un élément", + ) + ); + $opts->parse(); +} catch (Zend_Console_Getopt_Exception $e) { + echo $e->getUsageMessage(); + exit; +} + +//Usage +if(count($opts->getOptions())==0 || isset($opts->help)) +{ + echo "Charge les données nécessaire à l'applicatioon à partir du webservice."; + echo "\n\n"; + echo $opts->getUsageMessage(); + echo "\n"; + exit; +} + +//Utilisateur webservice +define('LOGIN', ''); +define('PASSWORD', ''); + +$args = $opts->getRemainingArgs(); +$elements = array('naf'); + +if ($opts->all || $opts->one){ + require_once 'Scores/WsScores.php'; + $ws = new WsScores(LOGIN, PASSWORD); +} + +if ($opts->all) +{ + foreach($elements as $element) + { + $reponse = $ws->getDataCSV($element); + } + +} elseif ($opts->one) { + //Vérification + $element = $args[0]; + if (!in_array($args[0], $elements)){ + echo 'Element inconnu !'; + } + $reponse = $ws->getDataCSV($element); + +} + + +//Méthodes interne + +function getFichier($url) +{ + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); + curl_setopt($ch, CURLOPT_COOKIEFILE,TRUE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + $output = curl_exec($ch); + curl_close($ch); + return $output; +} + +function saveToDatabase($key, $filename) +{ + //Vider la table + $sql = "TRUNCATE $key"; + + //Sauvegarder toutes les lignes + $cmd = "mysqlimport --ignore-lines=1 --fields-enclosed-by=\\\" --fields-terminated-by=, --user=USERNAME --password=PASSWORD ciblage $filename"; + exec($command); +} + + +?> \ No newline at end of file diff --git a/public/themes/default/scripts/jquery.cookie.js b/public/themes/default/scripts/jquery.cookie.js new file mode 100644 index 00000000..6a3e394b --- /dev/null +++ b/public/themes/default/scripts/jquery.cookie.js @@ -0,0 +1,41 @@ +/** + * jQuery Cookie plugin + * + * Copyright (c) 2010 Klaus Hartl (stilbuero.de) + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ +jQuery.cookie = function (key, value, options) { + + // key and at least value given, set cookie... + if (arguments.length > 1 && String(value) !== "[object Object]") { + options = jQuery.extend({}, options); + + if (value === null || value === undefined) { + options.expires = -1; + } + + if (typeof options.expires === 'number') { + var days = options.expires, t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + value = String(value); + + return (document.cookie = [ + encodeURIComponent(key), '=', + options.raw ? value : encodeURIComponent(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // key and possibly options given, get cookie... + options = value || {}; + var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; + return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; +}; diff --git a/public/themes/default/styles/main.css b/public/themes/default/styles/main.css index 1c167802..1fbbabef 100644 --- a/public/themes/default/styles/main.css +++ b/public/themes/default/styles/main.css @@ -184,4 +184,6 @@ h3 { border-top-left-radius:0; } - +#naf li { width:650px; } +#naf a { } +#naf a ins { }