diff --git a/application/configs/application.ini b/application/configs/application.ini index 03ebffd5a..61c9fc81e 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -14,7 +14,6 @@ resources.frontController.plugins.Menu = "Application_Controller_Plugin_Menu" resources.frontController.plugins.Pdf = "Application_Controller_Plugin_Pdf" resources.frontController.plugins.Pdf = "Application_Controller_Plugin_Xml" resources.frontController.plugins.Cgu = "Application_Controller_Plugin_Cgu" -resources.frontController.plugins.Historique = "Application_Controller_Plugin_Historique" resources.layout.layout = "main" resources.layout.layoutPath = APPLICATION_PATH "/views/default" resources.view.basePath = APPLICATION_PATH "/views/default" diff --git a/application/controllers/RechercheController.php b/application/controllers/RechercheController.php index e137e5be4..c526152ac 100644 --- a/application/controllers/RechercheController.php +++ b/application/controllers/RechercheController.php @@ -7,7 +7,9 @@ class RechercheController extends Zend_Controller_Action /** Pour Giant **/ if(isset($_SESSION['recherche']['giant'])) unset($_SESSION['recherche']['giant']); - + + require_once 'Scores/RechercheHistorique.php'; + $this->view->headLink()->appendStylesheet('/themes/default/styles/recherche.css', 'all'); } @@ -16,6 +18,9 @@ class RechercheController extends Zend_Controller_Action $this->_forward('entreprise'); } + /** + * Affiche le formulaire de recherche entreprise + */ public function entrepriseAction() { $request = $this->getRequest(); @@ -27,6 +32,9 @@ class RechercheController extends Zend_Controller_Action $this->view->form = $form; } + /** + * Affiche le formulaire de recherche dirigeants + */ public function dirigeantAction() { $this->view->headTitle()->append('Recherche Dirigeant'); @@ -35,9 +43,12 @@ class RechercheController extends Zend_Controller_Action $this->view->assign('form', $form); } + /** + * Affiche le formulaire de recherche annonces + * Enter description here ... + */ public function annonceAction() { - $this->view->headTitle()->append('Recherche Annonce'); } @@ -53,8 +64,8 @@ class RechercheController extends Zend_Controller_Action public function listAction() { $this->view->headTitle()->append('Liste des dernières recherches'); - $session = new Zend_Session_Namespace('Historique'); - $this->view->assign('historique', $session->historique); + $rechercheSession = new RechercheHistorique(); + $this->view->assign('historique', $rechercheSession->liste()); } public function enqueteAction() @@ -79,7 +90,7 @@ class RechercheController extends Zend_Controller_Action $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path'); $path = realpath($config->data).'/'.$config->log; $fp = fopen($path.'/enquetes.csv', 'a'); - fwrite($fp, date('Y/m/d H:i:s').' - '.print_r($form->getValues(),true).print_r($tabInfo,true)."\n"); + fwrite($fp, date('Y/m/d H:i:s').' - '.print_r($form->getValues(),true)."\n"); fclose($fp); $message = "Détail de la demande d'investigation
"; foreach($form->getValues() as $key => $value) { @@ -112,6 +123,9 @@ class RechercheController extends Zend_Controller_Action } } + /** + * Affiche les résultats d'une recherche + */ public function listeAction() { $request = $this->getRequest(); @@ -121,8 +135,22 @@ class RechercheController extends Zend_Controller_Action $pays = $request->getParam('pays'); if( !empty($pays) ) $this->_forward('index', 'giant'); + + $type = $request->getParam('type', ''); - $type = $request->getParam('type'); + $rechercheParams = new RechercheHistorique(); + //Si le formulaire a été soumis alors on enregistre en session et on redirige + if ($request->isPost() && !empty($type)) { + $rechercheParams->save($type, $params); + $this->_redirect('recherche/liste'); + } + + $page = $request->getParam('page', 1); + + $recherche = $rechercheParams->item(0); + $type = $recherche['type']; + $params = $recherche['params']; + //Criteres recherche entreprise if ($type=='ent'){ @@ -138,7 +166,7 @@ class RechercheController extends Zend_Controller_Action } $libVoie = preg_replace('/[^0-9A-Z]/', ' ', strtoupper($params['voie'])); $cpVille = preg_replace('/ +/',' ', - preg_replace('/[^0-9A-Z]/', ' ', strtoupper($formR['cpVille']))); + preg_replace('/[^0-9A-Z]/', ' ', strtoupper($params['cpVille']))); if (preg_match("/^([0-9]{2,5})([\D]*)/i", $cpVille, $matches)) { $cp = trim($matches[1]); @@ -148,7 +176,9 @@ class RechercheController extends Zend_Controller_Action $ville = trim($cpVille); } - $criteres = array(); + // Zend_Registry::get('firebug')->info('CP'); Zend_Registry::get('firebug')->info($cp); + + $criteres = array(); $criteres['identifiant'] = $params['siret']; $criteres['raisonSociale'] = $raisonSociale; $criteres['adresse'] = $numVoie.' '.$libVoie; @@ -202,8 +232,8 @@ class RechercheController extends Zend_Controller_Action require_once 'Scores/WsScores.php'; $ws = new WsScores(); - //@todo : Set position - $reponse = $ws->rechercheEntreprise($type, $criteres, 0); + $position = $page-1; + $reponse = $ws->rechercheEntreprise($type, $criteres, $position); Zend_Registry::get('firebug')->info($reponse); if ($reponse !== false) { @@ -219,7 +249,6 @@ class RechercheController extends Zend_Controller_Action $nbReponses = $reponse->results->nbReponses; $nbReponsesTotal = $reponse->results->nbReponsesTotal; if ($nbReponses < $nbReponsesTotal) { - $position = 0; $totPage = ceil($nbReponsesTotal/$nbReponses); $curPage = ceil($position/$nbReponses)+1; } else { @@ -315,7 +344,7 @@ class RechercheController extends Zend_Controller_Action } else { $this->view->assign('blockDirToEntreprise', false); } - + $this->view->assign('liste', $liste); $this->view->assign('totPage', $totPage); $this->view->assign('curPage', $curPage); diff --git a/application/views/default/scripts/recherche/list.phtml b/application/views/default/scripts/recherche/list.phtml index 8d0f3fbc2..dee23b51d 100644 --- a/application/views/default/scripts/recherche/list.phtml +++ b/application/views/default/scripts/recherche/list.phtml @@ -1,32 +1,70 @@
-
- historique)):?> - historique as $key => $historique):?> - -

- - -
- - - - -
+historique)>0) {?> +
+ +historique as $histo) {?> +
  • + +

    RECHERCHE ENTREPRISE :

    + + + Afficher la fiche identite consulter + + + Lancer la recherche + + Afficher le formulaire + + +

    RECHERCHE DIRIGEANT :

    + + + Afficher la fiche identite consulter + + + Lancer la recherche + + Afficher le formulaire + + + +
  • + +
    + +
    +Aucune recherche enregistrée. +
    +
    \ No newline at end of file diff --git a/library/Application/Controller/Plugin/Historique.php b/library/Application/Controller/Plugin/Historique.php deleted file mode 100644 index 8227514fb..000000000 --- a/library/Application/Controller/Plugin/Historique.php +++ /dev/null @@ -1,35 +0,0 @@ - $params['type'], - 'siret' => $params['siret'], - 'raisonSociale' => $params['raisonSociale'], - 'numero' => $params['numero'], - 'voie' => $params['voie'], - 'cpVille' => $params['cpVille'], - 'telFax' => $params['telFax'], - 'naf' => $params['naf'], - 'pays' => $params['pays'] - ); - return ($informations); - } - - public function postDispatch(Zend_Controller_Request_Abstract $request) { - $session = new Zend_Session_Namespace('Historique'); - if ($request->getControllerName() == 'recherche') { - if ($request->getActionName() == 'liste') { - if ($request->isPost()) { - $session->historique['entreprise'][] = self::formatInformations($request->getParams()); - } - } - } else if ($request->getControllerName() == 'identite') { - if ($request->getActionName() == 'fiche') { - $session->historique['entreprise'][count($session->historique['entreprise'])-1]['siret'] = $request->getParam('siret'); - } - } - } -} diff --git a/library/Scores/RechercheHistorique.php b/library/Scores/RechercheHistorique.php new file mode 100644 index 000000000..1534f71bc --- /dev/null +++ b/library/Scores/RechercheHistorique.php @@ -0,0 +1,80 @@ + array('siret', 'raisonSociale', 'numero', 'voie', 'cpVille', 'telFax', 'naf', 'pays'), + 'dir' => array('dirNom', 'dirPrenom', 'dirDateNaissJJ', 'dirDateNaissMM', 'dirDateNaissAAAA', 'dirCpVille'), + ); + + public function __construct(){ + $session = new Zend_Session_Namespace($this->index); + $this->listeRecherche = $session->liste; + Zend_Registry::get('firebug')->info($this->listeRecherche); + } + + public function save($type, $params) + { + //Controle des éléments + $elements = array(); + foreach($params as $key => $value){ + Zend_Registry::get('firebug')->info($key); + if (in_array($key, $this->listParams[$type])){ + $elements[$key] = $value; + } + } + //Vérification du nombre d'éléments + if (count($this->listeRecherche)>=$this->rechercheMax){ + array_shift($this->listeRecherche); + } + + $this->listeRecherche[] = array( + 'type' => $type, + 'params' => $elements, + ); + $session = new Zend_Session_Namespace($this->index); + $session->liste = $this->listeRecherche; + } + + public function assignInfo($siret, $id, $raisonSociale) + { + $rindex = count($this->listeRecherche)-1; + $this->listeRecherche[$rindex]['consult'] = array( + 'siret' => $siret, + 'id' => $id, + 'raisonSociale' => $raisonSociale, + ); + $session = new Zend_Session_Namespace($this->index); + $session->liste = $this->listeRecherche; + } + + /** + * Retourne la liste des éléments de la session dans le bon ordre + */ + public function liste() + { + if (count($this->listeRecherche)>0) { + return array_reverse($this->listeRecherche); + } else { + return array(); + } + } + + public function item($index) + { + $rindex = count($this->listeRecherche)-1-$index; + return $this->listeRecherche[$rindex]; + } + +} \ No newline at end of file diff --git a/library/Scores/historique.php b/library/Scores/historique.php deleted file mode 100644 index 7f860c9d5..000000000 --- a/library/Scores/historique.php +++ /dev/null @@ -1,74 +0,0 @@ -lastRequest = new RequestHistorique(); - $this->vide = true; - } - - public function setLastRequest($parametres) - { - $this->vide = false; - $this->lastRequest = new RequestHistorique(); - if (is_array($parametres)) { - $this->lastRequest->siret = $parametres['siret']; - $this->lastRequest->raisonSociale = $parametres['raisonSociale']; - $this->lastRequest->Adress = $parametres['numero'].':'.$parametres['voie'].':'.$parametres['cpVille']; - $this->lastRequest->telFax = $parametres['telFax']; - $this->lastRequest->naf = $parametres['naf']; - $this->lastRequest->pays = $parametres['pays']; - } else { - throw new Exception('"$parametres" : n\'est pas une instance de "Zend_Controller_Action"'); - } - return ($this->lastRequest); - } - - public function isExists() - { - if(count($this->listRequest) > 0) - return (true); - return (false); - } - - public function setSiret($siret) - { - $this->lastRequest->siret = $siret; - } - - public function getPage() - { - return ($this->lastRequest->page); - } - - public function setListRequest($parametres) - { - $this->listRequest[] = self::setLastRequest($parametres); - } - - public function getLastRequest() - { - return ($this->lastRequest); - } - - public function getListRequest() - { - return ($this->listRequest); - } - -} \ No newline at end of file