view->headLink()->appendStylesheet('/themes/default/styles/recherche.css', 'all'); } public function indexAction() { $this->_forward('entreprise'); } public function entrepriseAction() { $this->view->headTitle()->append('Recherche Entreprise'); //@todo : champs definis avec les valeurs en sessions ou en get, post require_once 'Web/Forms/RechercheEntreprise.php'; $form = new Form_RechercheEntreprise(); $this->view->form = $form; } public function dirigeantAction() { $this->view->headTitle()->append('Recherche Dirigeant'); require_once 'Web/Forms/RechercheDirigeant.php'; $form = new Form_RechercheDirigeant(); $this->view->assign('form', $form); } public function annonceAction() { $this->view->headTitle()->append('Recherche Annonce'); } public function internationaleAction(){} public function lastAction() { $this->view->headTitle()->append('Liste des dernières recherches'); } public function enqueteAction() { $this->view->headTitle()->append('Enquête'); require_once 'Scores/Utilisateur.php'; $user = new Utilisateur(); if (!$user->checkPerm('INVESTIG')){ $this->renderScript('error/error-perms.phtml'); } $request = $this->getRequest(); if ($request->isPost()){ //Erreur pas d'adresse email //Ok - email envoyé //Ok - email non envoyé } //Affichage formulaire require_once 'Web/Forms/RechercheEnquete.php'; require_once 'Scores/Utilisateur.php'; $form = new Form_RechercheEnquete(); $user = new Utilisateur(); $data = array( 'email' => $user->getEmail(), ); $form->populate($data); $this->view->assign('form', $form); } public function listeAction() { $request = $this->getRequest(); $params = $request->getParams(); //Giant $pays = $request->getParam('pays'); if( !empty($pays) ) $this->_forward('index', 'giant'); $type = $request->getParam('type'); //Criteres recherche entreprise if ($type=='ent'){ // Type de recherche = entreprises $telFax = trim(preg_replace('/[^0-9]/', '', $params['telFax'])); $naf = trim(preg_replace('/[^0-9A-Z]/i', '', $params['naf'])); // Traitement des données formulaire $raisonSociale = preg_replace('/[^0-9A-Z]/', ' ', strtoupper($params['raisonSociale'])); $numVoie = preg_replace('/[^0-9]/', '', $params['numero']); if ($numVoie > 9999) { die('Numéro de voie incorrecte !'); } $libVoie = preg_replace('/[^0-9A-Z]/', ' ', strtoupper($params['voie'])); $cpVille = preg_replace('/ +/',' ', preg_replace('/[^0-9A-Z]/', ' ', strtoupper($formR['cpVille']))); if (preg_match("/^([0-9]{2,5})([\D]*)/i", $cpVille, $matches)) { $cp = trim($matches[1]); $ville = trim($matches[2]); } else { $cp = ''; $ville = trim($cpVille); } $criteres = array(); $criteres['identifiant'] = $params['siret']; $criteres['raisonSociale'] = $raisonSociale; $criteres['adresse'] = $numVoie.' '.$libVoie; $criteres['codePostal']= $cp; $criteres['ville'] = $ville; $criteres['telFax'] = $telFax; $criteres['naf'] = $naf; $criteres['siege'] = false; $criteres['actif'] = false; //Criteres recherche dirigeants } else if ($type=='dir') { // Type de recherche = dirigeants $dirNom = preg_replace('/[^0-9A-Z]/', ' ', strtoupper($params['dirNom'])); $dirPrenom = preg_replace('/[^0-9A-Z]/', ' ', strtoupper($params['dirPrenom'])); $dirDateNaissJJ = preg_replace('/[^0-9]/', '', $params['dirDateNaissJJ']); if (intval($dirDateNaissJJ)<0 || intval($dirDateNaissJJ>31)){ //die('Jour de naissance incorrect !'); } $dirDateNaissMM = preg_replace('/[^0-9]/', '', $params['dirDateNaissMM']); if (intval($dirDateNaissMM)<0 || intval($dirDateNaissMM>31)){ //die('Mois de naissance incorrect !'); } $dirDateNaissAAAA = preg_replace('/[^0-9]/', '', $params['dirDateNaissAAAA']); $year = date('Y')-18; if (intval($dirDateNaissAAAA)<0 || intval($dirDateNaissAAAA)>$year){ //die('Année de naissance incorrecte !'); } $dirDateNaiss = $dirDateNaissJJ.'/'.$dirDateNaissMM.'/'.$dirDateNaissAAAA; $dirCpVille = preg_replace('/ +/',' ', preg_replace('/[^0-9A-Z]/', ' ', strtoupper($formR['dirCpVille'])) ); if (preg_match('/^([0-9]{2,5})([\D]+)/i', $dirCpVille, $matches)) { $dirCp = trim($matches[1]); $dirVille = trim($matches[2]); } else { $dirVille = trim($dirCpVille); } $criteres = array(); $criteres['dirNom'] = $dirNom; $criteres['dirPrenom'] = $dirPrenom; $criteres['dirDateNaiss'] = $dirDateNaiss; $criteres['lieuNaiss'] = $dirVille; Zend_Registry::get('firebug')->info($criteres); } require_once 'Scores/WsScores.php'; $ws = new WsScores(); //@todo : Set position $reponse = $ws->rechercheEntreprise($type, $criteres, 0); Zend_Registry::get('firebug')->info($reponse); if ($reponse !== false) { $etabs = $reponse->results->reponses->item; $criteresTexte = ''; //@todo : selection des critères à afficher foreach ($reponse->results->criteres as $value){ if (!empty($value)) $criteresTexte.= $value.' '; } $criteresTexte = trim($criteresTexte); $criteresLien = $this->view->url($params); $info = $reponse->results->info; $nbReponses = $reponse->results->nbReponses; $nbReponsesTotal = $reponse->results->nbReponsesTotal; if ($nbReponses < $nbReponsesTotal) { $position = 0; $totPage = ceil($nbReponsesTotal/$nbReponses); $curPage = ceil($position/$nbReponses)+1; } else { $totPage = $curPage = 1; } $liste = array(); foreach($etabs as $i => $etab) { $item = array(); $item['position'] = (($curPage-1)*$nbReponses)+$i+1; $item['id'] = $etab->id; $item['siren'] = $etab->Siren; $item['siret'] = $etab->Siren.$etab->Nic; $item['InfoSiret'] = $etab->Siren.' '.$etab->Nic; $item['InfoNom'] = $etab->Nom; $nomDetail = ''; if ($etab->Nom2<>'' || $etab->Enseigne<>'' || $etab->Sigle<>'') { $nomDetail.= ''; if ($etab->Nom2!='') $nomDetail.= $etab->Nom2.'
'; if ($etab->Enseigne<>'') $nomDetail.= 'Enseigne : '.$etab->Enseigne.'    '; if ($etab->Sigle<>'') $nomDetail.= 'Sigle : '.$etab->Sigle; $nomDetail.= '

'; } $item['InfoNomDetail'] = $nomDetail; $item['InfoSiret'] = substr($etab->Siren,0,3).' '. substr($etab->Siren,3,3).' '. substr($etab->Siren,6,3).' '. $etab->Nic; $infoEtab = ''; if ($etab->Siege==1){ $infoEtab.= 'Établissement siège '; } else { $infoEtab.= 'Établissement secondaire '; } if ($etab->Actif==1){ $infoEtab.= 'actif'; } else { $infoEtab.= 'inactif'; } if (intval($etab->Nic)==0 || intval($item->Nic)>=99990) { $infoEtab.=' provisoire'; } if ($etab->Siege!=1 || ($etab->Siege==1 && $etab->Actif!=1)) { $url = $this->view->url(array( 'controller'=>'identite', 'action'=>'fiche', 'id' => $etab->id, 'siren' => $etab->Siren, )); $infoEtab.= ' (Accès siège)'; } $item['InfoEtab'] = $infoEtab; $adresse = $etab->Adresse.'
'; if (isset($etab->Adresse2) && $etab->Adresse2 != '') { $adresse.= $etab->Adresse2.'
'; } $adresse.= "".$etab->CP." ".$etab->Ville.""; $item['InfoAdresse'] = $adresse; $forme = ''; if (trim($etab->FJ)!='') { $forme = 'Forme : '.$etab->FJLib.' ('.$etab->FJ.')
'; } $item['InfoForme'] = $forme; $activite = ''; if (trim($item->NafEnt)!='') { $activite = 'Activité : '.$item->NafEntLib.' ('.$item->NafEnt.')
'; } $item['InfoActivite'] = $activite; $liste[] = $item; } } require_once 'Scores/Utilisateur.php'; $user = new Utilisateur(); $this->view->assign('blockInvestig', $user->checkPerm('INVESTIG')); if ($type=='dir') { $this->view->assign('blockDirToEntreprise', true); $this->view->assign('searchDirToEntrepriseTxt', trim($critere['nom'].' '.$criteres['prenom'])); $this->view->assign('searchDirToEntrepriseLien', $this->view->url(array( 'action' => 'list', 'type' => 'ent', 'raisonSociale' => trim($critere['nom'].' '.$criteres['prenom']) ))); } else { $this->view->assign('blockDirToEntreprise', false); } $this->view->assign('liste', $liste); $this->view->assign('totPage', $totPage); $this->view->assign('curPage', $curPage); $this->view->assign('nbReponses', $nbReponses); $this->view->assign('nbReponsesTotal', $nbReponsesTotal); $this->view->assign('criteresTexte', $criteresTexte); $this->view->assign('criteresLien', $criteresLien); $this->view->assign('info', $info); } public function ipariAction() { } public function nafAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $q = strtolower($this->getRequest()->getParam('q', '')); $dbConfig = new Zend_Config_Ini(APPLICATION_PATH.'/configs/databases.ini'); $db = Zend_Db::factory($dbConfig->db->sdv1); Zend_Db_Table_Abstract::setDefaultAdapter($db); $naf = new Application_Model_Naf5(); $rowset = $naf->select('codNaf5, libNaf5') ->where("codNaf5 LIKE '%$q%' OR libNaf5 LIKE '%$q%'") ->order('poids DESC'); $rows = $naf->fetchAll($rowset); $output = array(); if (count($rows)>0){ $separator = " , "; foreach ($rows as $item) { if (strpos(strtolower($item->codNaf5), $q) !== false || strpos(strtolower($item->libNaf5), $q) !== false ) { $output[] = array( 'label' => $item->codNaf5 . $separator . $item->libNaf5, 'value' => $item->codNaf5, ); } } } echo json_encode($output); } }