view->headLink()->appendStylesheet('/themes/default/styles/recherche.css', 'all'); } public function indexAction() { $this->_forward('entreprise'); } /** * Affiche le formulaire de recherche entreprise */ public function entrepriseAction() { $request = $this->getRequest(); $this->view->headTitle()->append('Recherche Entreprise'); require_once 'Web/Forms/RechercheEntreprise.php'; $form = new Form_RechercheEntreprise(); if ( $request->isPost() || $request->isGet() ){ $form->populate($request->getParams()); } $this->view->form = $form; } /** * Affiche le formulaire de recherche dirigeants */ public function dirigeantAction() { $this->view->headTitle()->append('Recherche Dirigeant'); require_once 'Web/Forms/RechercheDirigeant.php'; $form = new Form_RechercheDirigeant(); $this->view->assign('form', $form); } /** * Affiche le formulaire de recherche annonces * Enter description here ... */ public function annonceAction() { $this->view->headTitle()->append('Recherche Annonce'); } public function internationaleAction(){} public function lastAction() { $this->view->headTitle()->append('Liste des dernières recherches'); $session = new Zend_Session_Namespace('Historique'); $this->view->assign('historique', $session->historique['entreprise']); } public function listAction() { $this->view->headTitle()->append('Liste des dernières recherches'); $rechercheSession = new RechercheHistorique(); $this->view->assign('historique', $rechercheSession->liste()); } public function enqueteAction() { $this->view->headTitle()->append('Enquête'); require_once 'Scores/Utilisateur.php'; require_once 'Web/Forms/RechercheEnquete.php'; $user = new Utilisateur(); if (!$user->checkPerm('INVESTIG')){ $this->renderScript('error/error-perms.phtml'); } $form = new Form_RechercheEnquete(); $user = new Utilisateur(); $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getParams())) { Zend_Registry::get('firebug')->info($form->getValues()); $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)."\n"); fclose($fp); $message = "Détail de la demande d'investigation
"; foreach($form->getValues() as $key => $value) { $message.= ucwords($key)." : ".$value."
"; } $message.= "
"; $message.= "Identité du demandeur
"; $message.= "Login : ".$user->getLogin()."
"; $message.= "Email : ".$user->getEmail()."
"; $message.= "Nom : ".$user->getNom()."
"; $message.= "Prénom : ".$user->getPrenom()."
"; $objet = "Demande d'investigation"; require_once 'Scores/Mail.php'; $mail = new Mail(); $mail->setFrom('contact'); $mail->addToKey('production'); $mail->setSubject($objet); $mail->setBodyHtml($message); $mail->send(); } else { //Affichage formulaire $data = array( 'email' => $user->getEmail() ); if ($request->isPost()){ $data = $form->getValues(); } $form->populate($data); $this->view->assign('form', $form); } } /** * Affiche les résultats d'une recherche */ public function listeAction() { $request = $this->getRequest(); $params = $request->getParams(); $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'); } //On selectionne en session if (count($rechercheParams->liste())>0){ $recherche = $rechercheParams->item(0); $type = $recherche['type']; $params = $recherche['params']; } //Giant if( isset($params['pays']) && !empty($params['pays']) ){ $this->_forward('index', 'giant'); } $page = $request->getParam('page', 1); //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($params['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); } // 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; $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(); $position = $page-1; $reponse = $ws->rechercheEntreprise($type, $criteres, $position); 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) { $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); } }