extranet/application/controllers/RechercheController.php

981 lines
33 KiB
PHP
Raw Normal View History

2011-01-06 08:37:20 +00:00
<?php
class RechercheController extends Zend_Controller_Action
{
public function init()
{
/** Pour Giant **/
if(isset($_SESSION['recherche']['giant']))
unset($_SESSION['recherche']['giant']);
require_once 'Scores/RechercheHistorique.php';
2011-09-13 20:14:10 +00:00
require_once 'Scores/WsScores.php';
$this->view->headLink()->appendStylesheet('/themes/default/styles/recherche.css', 'all');
2011-09-30 09:51:09 +00:00
$this->view->headScript()->appendFile('/themes/default/scripts/recherche.js', 'text/javascript');
}
2011-01-06 08:37:20 +00:00
public function indexAction()
{
$this->_forward('entreprise');
}
/**
* Affiche le formulaire de recherche entreprise
*/
2011-01-07 17:16:07 +00:00
public function entrepriseAction()
{
2011-05-19 13:55:35 +00:00
$request = $this->getRequest();
2011-01-07 17:16:07 +00:00
$this->view->headTitle()->append('Recherche Entreprise');
2011-04-11 14:32:37 +00:00
require_once 'Web/Forms/RechercheEntreprise.php';
2011-01-07 17:16:07 +00:00
$form = new Form_RechercheEntreprise();
if ( $request->isPost() || $request->isGet() ){
$form->populate($request->getParams());
}
$this->view->assign('message', $request->getParam('message'));
$this->view->assign('form', $form);
2011-12-09 15:27:22 +00:00
require_once 'Scores/Utilisateur.php';
$user = new Utilisateur();
$this->view->assign('RefClient', $user->checkPref('rechref'));
2011-01-07 17:16:07 +00:00
}
2011-02-16 15:47:05 +00:00
/**
* Affiche le formulaire de recherche dirigeants
*/
2011-04-11 15:51:41 +00:00
public function dirigeantAction()
{
2011-08-19 14:39:49 +00:00
$request = $this->getRequest();
2011-04-11 14:19:14 +00:00
$this->view->headTitle()->append('Recherche Dirigeant');
2011-04-13 12:53:09 +00:00
require_once 'Web/Forms/RechercheDirigeant.php';
$form = new Form_RechercheDirigeant();
2011-08-19 14:37:17 +00:00
if ( $request->isPost() || $request->isGet() ){
$form->populate($request->getParams());
}
2011-04-13 12:53:09 +00:00
$this->view->assign('form', $form);
2011-04-11 14:19:14 +00:00
}
/**
* Affiche le formulaire de recherche actionnaire
* @todo : style pour les pourcentages
*/
public function actionnaireAction()
{
2012-01-24 15:50:09 +00:00
$request = $this->getRequest();
$this->view->headTitle()->append('Recherche Actionnaire');
require_once 'Web/Forms/RechercheActionnaire.php';
$form = new Form_RechercheActionnaire();
2012-01-24 15:50:09 +00:00
if ( $request->isPost() || $request->isGet() ){
$form->populate($request->getParams());
}
$this->view->assign('form', $form);
}
/**
* Affiche le formulaire de recherche annonces
*/
2011-04-11 15:51:41 +00:00
public function annonceAction()
{
2011-04-11 14:19:14 +00:00
$this->view->headTitle()->append('Recherche Annonce');
$session = new RechercheHistorique();
$recherche = $session->item(0);
if ($recherche['type']=='annonce') {
$params = $recherche['params']['formA'];
} else {
$params = array();
}
$this->view->assign('recherche', $params);
2011-04-11 14:19:14 +00:00
}
2011-08-12 13:01:39 +00:00
public function annoncelisteAction()
{
$request = $this->getRequest();
$params = $request->getParams();
$token = $request->getParam('token', null);
2011-08-12 13:01:39 +00:00
$session = new RechercheHistorique();
if (array_key_exists('formA', $params)) {
2012-02-08 10:21:47 +00:00
$token = $session->save('annonce', $params);
} else {
$recherche = $session->get($token);
$params = $recherche['params'];
}
2011-08-12 13:01:39 +00:00
if( !isset($params['formA']['annee']) && isset($params['formA']['dateparution']) )
{
$dateparution = str_replace('/', '', $dateparution);
$jj = substring($annee, 0, 2);
$mm = substring($annee, 2, 2);
$aa = substring($annee, 4, 4);
$dateparution = $aa.$mm.$jj;
}
$p = $request->getParam('p', 0);
if($params['formA']['histo']!='on')
{
$ra = array();
$ra['dateAnnee'] = $params['formA']['annee'];
$ra['numParution'] = $params['formA']['nparution'];
if($params['formA']['source']=='bodacc')
{
$ra['source'] = strtoupper('bod'.$params['formA']['bodacc']);
$ra['numAnnonce'] = $params['formA']['nannonce'];
}
elseif($params['formA']['source']=='balo')
{
$ra['source'] = strtoupper($params['formA']['source']);
$ra['numAnnonce'] = $params['formA']['naffaire'];
}
elseif($params['source']=='asso')
{
$ra['source'] = strtoupper($params['formA']['source']);
$ra['numAnnonce'] = $params['formA']['nannonce'];
}
2011-09-13 20:14:10 +00:00
$ws = new WsScores();
$result = $ws->rechercheAnnonce($ra['source'], $ra['dateAnnee'], $ra['numParution'], $ra['numAnnonce']);
$infos = $result->result->item;
2011-08-12 13:01:39 +00:00
$parametresTxt = array(
'source'=>'Source',
'annee'=>'Année',
'dateparution'=>'Date de parution',
'nparution'=>'Numéro de parution',
'bpage'=>'Page',
'nannonce'=>'Numéro d\'annonce',
'naffaire'=>'Numéro d\'affaire',
'txt'=>'Recherche');
$strCriteres = '';
foreach ($parametresTxt as $key => $param) {
if($params['formA'][$key]!='' && $param!='') {
$strCriteres.= $param.' : '.$params['formA'][$key].'&nbsp;';
}
}
2011-09-13 20:14:10 +00:00
$this->view->assign('criteres', $result->criteres);
$this->view->assign('infos', $infos);
} else {
2011-08-12 13:01:39 +00:00
require_once 'i18n/cleanchar.php';
//Suppression des caractères accentués
$txt = cleanstring($params['formA']['txt']);
//Remplacement du caractère § par ~
$txt = str_replace('$', '~', $txt);
// Recherche siren tenant compte des anomalies d'OCR
$txt = preg_replace('/([0-9]{3})([0-9]{3})([0-9]{3})/','"$1$2$3"|"$1 $2$3"|"$1$2 $3"|"$1 $2 $3"', $txt);
2011-09-13 20:14:10 +00:00
$ws = new WsScores();
$result = $ws->rechercheHisto($txt, $params['formA']['annee'], $params['formA']['bodacc'], $p);
$infos = $result->reponses->item;
2011-08-12 13:01:39 +00:00
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$authinfo = '?login='.$identity->username.'&hach='.$identity->password;
$this->view->assign('authinfo', $authinfo);
2011-08-12 13:01:39 +00:00
$parametresTxt = array(
'source'=>'Source',
'bodacc'=>'Type',
'histo'=>'',
'annee'=>'Année',
'dateparution'=>'Date de parution',
'nparution'=>'Numéro de parution',
'bpage'=>'Page',
'nannonce'=>'Numéro d\'annonce',
'naffaire'=>'Numéro d\'affaire',
'txt'=>'Recherche');
$strCriteres = '';
foreach ($parametresTxt as $key => $param) {
if($params['formA'][$key]!='' && $param!='') {
$strCriteres.= $param.' : '.$params['formA'][$key].',&nbsp;';
}
}
2011-09-13 20:14:10 +00:00
$this->view->assign('mots', $result->mots->item);
2011-08-12 13:01:39 +00:00
}
2011-09-13 20:14:10 +00:00
$this->view->assign('p', $p);
$this->view->assign('token', $token);
2011-09-13 20:14:10 +00:00
$this->view->assign('infos', $infos);
require_once 'Scores/Utilisateur.php';
$user = new Utilisateur();
$this->view->assign('userNbReponses', $user->getNbRep());
2011-09-13 20:14:10 +00:00
$this->view->assign('nbReponses', $result->nbReponses);
$this->view->assign('nbReponsesTotal', $result->nbReponsesTotal);
2011-08-12 13:01:39 +00:00
$this->view->assign('strCriteres', $strCriteres);
$this->view->assign('histo', $params['formA']['histo']);
}
2011-02-16 15:47:05 +00:00
public function internationaleAction(){}
2011-04-11 14:19:14 +00:00
public function lastAction()
{
$this->view->headTitle()->append('Liste des dernières recherches');
2012-01-24 15:50:09 +00:00
// @todo : Attention lorsqu'il n'y pas de recherche enregistré
2011-08-12 20:28:22 +00:00
$rechercheSession = new RechercheHistorique();
$derniereRecherche = $rechercheSession->item(0);
$params = array_merge(array('type'=> $derniereRecherche['type']), $derniereRecherche['params']);
$this->_forward('liste', 'recherche', null, $params);
}
2011-01-06 08:37:20 +00:00
public function listAction()
{
$this->view->headTitle()->append('Liste des dernières recherches');
$rechercheSession = new RechercheHistorique();
$this->view->assign('historique', $rechercheSession->liste());
2011-04-11 14:19:14 +00:00
}
public function enqueteAction()
{
$this->view->headTitle()->append('Enquête');
require_once 'Scores/Utilisateur.php';
2011-05-19 13:55:35 +00:00
require_once 'Web/Forms/RechercheEnquete.php';
2011-04-11 14:19:14 +00:00
$user = new Utilisateur();
if (!$user->checkPerm('INVESTIG')){
2011-04-11 15:51:41 +00:00
$this->renderScript('error/error-perms.phtml');
}
$form = new Form_RechercheEnquete();
2011-05-19 13:55:35 +00:00
$user = new Utilisateur();
2011-04-11 14:19:14 +00:00
2011-05-19 13:55:35 +00:00
$request = $this->getRequest();
if ($request->isPost() && $form->isValid($request->getParams())) {
Zend_Registry::get('firebug')->info($form->getValues());
$configuration = Zend_Registry::get('configuration');
$path = realpath($configuration->path->data).'/'.$configuration->path->log;
2011-05-19 13:55:35 +00:00
$fp = fopen($path.'/enquetes.csv', 'a');
fwrite($fp, date('Y/m/d H:i:s').' - '.print_r($form->getValues(),true)."\n");
2011-05-19 13:55:35 +00:00
fclose($fp);
$message = "Détail de la demande d'investigation<br/>";
foreach($form->getValues() as $key => $value) {
$message.= ucwords($key)." : ".$value."<br/>";
}
$message.= "<br/>";
$message.= "Identité du demandeur<br/>";
$message.= "Login : ".$user->getLogin()."<br/>";
$message.= "Email : ".$user->getEmail()."<br/>";
$message.= "Nom : ".$user->getNom()."<br/>";
$message.= "Prénom : ".$user->getPrenom()."<br/>";
$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);
}
2011-04-11 14:19:14 +00:00
}
/**
* Affiche les résultats d'une recherche
*/
2011-04-11 14:19:14 +00:00
public function listeAction()
{
$request = $this->getRequest();
2011-04-11 14:32:37 +00:00
$params = $request->getParams();
$type = $request->getParam('type', '');
$token = $request->getParam('token', null);
//On vérifie que le formulaire ait au moins un des champs rempli
$action = 'entreprise';
switch($type){
case 'ent':
$action = 'entreprise';
$listParams = array('siret', 'raisonSociale', 'numero', 'voie', 'cpVille', 'telFax', 'naf');
break;
case 'dir':
$action = 'dirigeant';
$listParams = array('dirNom', 'dirPrenom', 'dirDateNaissJJ', 'dirDateNaissMM', 'dirDateNaissAAAA', 'dirCpVille');
break;
case 'act':
$action = 'actionnaire';
$listParams = array('siret', 'actNomRs', 'cpVille', 'pays', 'cpVille', 'pctMin', 'pctMax');
break;
}
$nbField = count($listParams);
foreach($listParams as $key){
if(!empty($params[$key])){
$params[$key] = strip_tags($params[$key]);
$nbField--;
}
}
if ($nbField!=0){
$this->_forward($action, 'recherche');
}
$rechercheParams = new RechercheHistorique();
//Si le formulaire a été soumis alors on enregistre en session et on redirige
if ( !empty($type) ) {
$token = $rechercheParams->save($type, $params);
$this->_redirect('recherche/liste/token/'.$token);
}
//On selectionne en session
if (count($rechercheParams->liste())>0){
$recherche = $rechercheParams->get($token);
$type = $recherche['type'];
$params = $recherche['params'];
}
2011-04-15 12:40:29 +00:00
//Giant
if( !empty($params['pays']) && $type == 'ent' ){
2011-08-26 07:27:48 +00:00
Zend_Registry::get('firebug')->info('RECHERCHE GIANT');
$this->_forward('search', 'giant', null, $params);
//Recherche
} else {
2011-08-26 07:27:48 +00:00
2011-09-12 09:20:03 +00:00
require_once 'Scores/Utilisateur.php';
$user = new Utilisateur();
$page = $request->getParam('page', 1);
if ($page==0) $page = 1;
2011-09-12 09:20:03 +00:00
$page = $page-1;
$position = $page*$user->getNbRep();
2011-05-09 12:39:39 +00:00
require_once 'Scores/WsScores.php';
$ws = new WsScores();
2011-09-12 09:20:03 +00:00
//Criteres recherche entreprise
if ($type=='ent'){
2011-10-25 08:21:13 +00:00
require_once 'i18n/cleanchar.php';
// 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']));
2011-10-25 07:31:44 +00:00
$raisonSociale = str_replace(array('(',')'), array('', ''), $params['raisonSociale']);
2011-10-25 08:21:13 +00:00
$numVoie = preg_replace('/[^0-9]/', '', $params['numero']);
if ($numVoie > 9999) {
die('Numéro de voie incorrecte !');
}
$libVoie = cleanutf8($params['voie']);
2011-10-25 08:21:13 +00:00
$cpVille = cleanutf8($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);
}
$criteres = array();
$criteres['identifiant'] = str_replace(array(' ', '.'), array('',''), trim($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;
2011-09-12 09:20:03 +00:00
$reponse = $ws->searchEntreprise($criteres, $position);
2012-01-25 20:08:54 +00:00
$this->view->assign('rechCsv', $user->checkPerm('rechcsv'));
//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;
if ($dirDateNaiss=='//') $dirDateNaiss = '';
$dirCpVille = preg_replace('/ +/',' ', preg_replace('/[^0-9A-Z]/', ' ',
2011-10-25 09:27:37 +00:00
strtoupper($params['dirCpVille']))
);
2011-10-25 09:21:37 +00:00
/*
if (preg_match('/^([0-9]{2,5})([\D]+)/i', $dirCpVille, $matches))
{
$dirCp = trim($matches[1]);
$dirVille = trim($matches[2]);
}
else {
$dirVille = trim($dirCpVille);
2011-10-25 09:27:37 +00:00
}
*/
$criteres = array();
$criteres['dirNom'] = $dirNom;
$criteres['dirPrenom'] = $dirPrenom;
$criteres['dirDateNaiss'] = $dirDateNaiss;
2011-10-25 09:21:37 +00:00
$criteres['lieuNaiss'] = $dirCpVille;
$reponse = $ws->searchDir($criteres, $position, $user->getNbRep());
2011-09-14 15:52:01 +00:00
} elseif ($type == 'act') {
$siret = preg_replace('/[^0-9]/', '',$params['siret']);
$actNomRs = trim($params['actNomRs']);
$pays = $params['pays'];
$pctMin = preg_replace('/[^0-9]/', '', trim($params['pctMin']));
$pctMax = preg_replace('/[^0-9]/', '', trim($params['pctMax']));
$cpVille = preg_replace('/ +/',' ', preg_replace('/[^0-9A-Z]/', ' ',strtoupper($params['cpVille'])));
$criteres = array();
$criteres['siret'] = $siret;
$criteres['actNomRs'] = $actNomRs;
$criteres['pctMin'] = $pctMin;
$criteres['pctMax'] = $pctMax;
$criteres['cpVille'] = $cpVille;
$reponse = $ws->searchAct($actNomRs, $cpVille, $siret, $pays, $pctMin, $pctMax, $position);
}
$nbReponses = 0;
$nbReponsesTotal = 0;
if (is_object($reponse) && $reponse !== false)
{
$etabs = $reponse->result->item;
$criteresTexte = '';
foreach ($criteres as $value){
if (!empty($value)) $criteresTexte.= $value.' ';
}
$criteresTexte = trim($criteresTexte);
2012-02-06 08:33:10 +00:00
$params['controller'] = 'recherche';
if ($type=='ent'){
$params['action'] = 'entreprise';
} elseif ($type=='dir') {
$params['action'] = 'dirigeant';
} elseif ($type=='act'){
$params['action'] = 'actionnaire';
}
$criteresLien = $this->view->url($params, null, true);
$info = $reponse->info;
$nbReponses = $reponse->nbReponses;
$nbReponsesTotal = $reponse->nbReponsesTotal;
if ($nbReponses < $nbReponsesTotal) {
2011-09-12 09:20:03 +00:00
$totPage = ceil($nbReponsesTotal/$user->getNbRep());
$curPage = $page+1;
} else {
$totPage = $curPage = 1;
}
$liste = array();
if (count($etabs)>0) {
foreach($etabs as $i => $etab) {
$item = array();
2011-09-12 09:20:03 +00:00
$item['position'] = ($position)+$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.= '<i>';
if ($etab->Nom2!='') $nomDetail.= $etab->Nom2.'<br/>';
if ($etab->Enseigne<>'') $nomDetail.= 'Enseigne : '.$etab->Enseigne.'&nbsp;&nbsp;&nbsp;&nbsp;';
if ($etab->Sigle<>'') $nomDetail.= 'Sigle : '.$etab->Sigle;
$nomDetail.= '</i><br/>';
}
$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.= '&Eacute;tablissement si&egrave;ge ';
} else {
$infoEtab.= '&Eacute;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,
'siret' => $etab->Siren,
), null, true);
$infoEtab.= ' <a title="Voir la fiche d\'identité du siège de cette entreprise"'.
' href="'.$url.'">(Accès siège)</a>';
}
$item['InfoEtab'] = $infoEtab;
$adresse = $etab->Adresse.'<br/>';
if (isset($etab->Adresse2) && $etab->Adresse2 != '') {
$adresse.= $etab->Adresse2.'<br/>';
}
$adresse.= "<b>".$etab->CP." ".$etab->Ville."</b>";
$item['InfoAdresse'] = $adresse;
$forme = '';
if (trim($etab->FJ)!='')
{
$forme = '<i>Forme : '.$etab->FJLib.' ('.$etab->FJ.')</i><br/>';
}
$item['InfoForme'] = $forme;
$activite = '';
if (trim($etab->NafEnt)!='')
{
$activite = '<i>Activit&eacute; : '.$etab->NafEntLib.' ('.$etab->NafEnt.')</i><br/>';
}
$item['InfoActivite'] = $activite;
if ($type=='dir') {
$item['InfoDirigeant'] = '<u>Dirigeant recherch&eacute; :</u> ';
if ($etab->DirRs!='') {
$item['InfoDirigeant'].= '<b>'.$etab->DirRs.'</b>, repr&eacute;sent&eacute; par ';
}
$item['InfoDirigeant'].= $etab->DirNom .' '. $etab->DirPrenom;
if ($etab->DirNomUsage<>'' && $etab->DirNomUsage<>$etab->DirNom) {
$item['InfoDirigeant'].= ' ('. $etab->DirNomUsage . ')';
}
$item['InfoDirigeant'].= '<i>, '.$etab->DirFonction.'</i><br/>';
} elseif ($type=='act'){
$item['InfoActionnaire'] = '<u>Actionnaire recherch&eacute; :</u> ';
if ($etab->ActNomRs<>'') {
$item['InfoActionnaire'].= '<b>'. $etab->ActNomRs . '</b >';
if ($etab->ActPays!='' && $etab->ActPays!='FRA')
$item['InfoActionnaire'].= ' ('.$etab->ActPays.')';
$preDate = ', le ';
if ($etab->ActActif==0){
$preDate = ', avant le ';
}
2011-09-14 15:52:01 +00:00
require_once 'common/dates.php';
if ($etab->ActDateLien!='') $item['InfoActionnaire'].= $preDate.WDate::dateT('Y-m-d', 'd/m/Y',$etab->ActDateLien);
if ($etab->ActPmin!='') {
if($etab->ActPmin<1){
$item['InfoActionnaire'].= ', minoritaire ';
} else {
$item['InfoActionnaire'].= ', à '.$etab->ActPmin.' %';
}
}
}
$item['InfoActionnaire'].= '<br/>';
}
//Affichage accès directe vers pages
if ($user->getIdClient()==34) {
$liens = array();
$liens[] = array(
'title' => 'Lien fiche procédure collective',
'href' => $this->view->url(array(
'controller'=>'identite',
'action'=>'fichepc',
'siret'=>$etab->Siren.$etab->Nic,
'id'=>$etab->id), null, true),
);
$liens[] = array(
'title' => 'Lien fiche procédure collective',
'href' => $this->view->url(array(
'controller'=>'identite', 'action'=>'fichepc',
'siret'=>$etab->Siren.$etab->Nic, 'id'=>$etab->id), null, true),
);
$item['lien'] = $liens;
}
if ($user->getIdClient()==60){
$liens = array();
$liens[] = array(
2012-01-24 16:05:50 +00:00
'title' => 'Fiche AGS',
'href' => $this->view->url(array(
'controller'=>'identite', 'action'=>'fichepc',
'siret'=>$etab->Siren.$etab->Nic, 'id'=>$etab->id), null, true),
);
$item['lien'] = $liens;
}
$liste[] = $item;
}
2011-06-30 12:14:14 +00:00
}
} elseif (is_string($reponse)){
$this->_forward('entreprise', 'recherche', null, array_merge(
$params, array('message' => $reponse))
);
} else {
$this->_forward('soap', 'error');
2011-04-11 14:19:14 +00:00
}
$this->view->assign('blockInvestig', $user->checkPerm('INVESTIG'));
if ($type=='dir') {
$this->view->assign('blockDirToEntreprise', true);
$this->view->assign('searchDirToEntrepriseTxt', trim($criteres['dirNom'].' '.$criteres['dirPrenom']));
$this->view->assign('searchDirToEntrepriseLien', $this->view->url(array(
2012-02-13 10:23:07 +00:00
'controller' => 'recherche',
'action' => 'liste',
'type' => 'ent',
'raisonSociale' => trim($criteres['dirNom'].' '.$criteres['dirPrenom'])
), null, true));
} else {
$this->view->assign('blockDirToEntreprise', false);
}
$this->view->assign('token', $token);
$this->view->assign('liste', $liste);
$this->view->assign('totPage', $totPage);
$this->view->assign('curPage', $curPage);
$this->view->assign('nbReponses', empty($nbReponses) ? 0 : $nbReponses);
$this->view->assign('nbReponsesTotal', empty($nbReponsesTotal) ? 0 : $nbReponsesTotal);
$this->view->assign('criteresTexte', $criteresTexte);
$this->view->assign('criteresLien', $criteresLien);
$this->view->assign('info', $info);
2011-04-11 14:19:14 +00:00
}
}
public function ipariAction()
{
2011-06-30 14:24:47 +00:00
$user = new Utilisateur();
$url = 'http://ipari.scores-decisions.com/?action=logon&login='.$user->getLogin().
'&hach='.$user->getPassword().'&pass=';
if (!empty($this->siret)){
$url.= '&siret='.$this->siret;
}
$this->_redirect($url);
2011-04-11 14:19:14 +00:00
}
public function nafAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$q = strtolower($this->getRequest()->getParam('q', ''));
$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);
}
2011-12-09 15:27:22 +00:00
public function refclientAction()
{
}
public function refclientlisteAction()
{
$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 ( !empty($type) ) {
$rechercheParams->save($type, $params);
}
//On selectionne en session
if (count($rechercheParams->liste())>0){
$recherche = $rechercheParams->item(0);
$type = $recherche['type'];
$params = $recherche['params'];
}
$user = new Utilisateur();
$this->view->assign('login', $user->getLogin());
2011-12-09 15:27:22 +00:00
$page = $request->getParam('page', 1);
if ($page==0) $page = 1;
$page = $page-1;
$position = $page*$user->getNbRep();
$nbReponses = 0;
$nbReponsesTotal = 0;
$liste = array();
$ws = new WsScores();
$reponses = $ws->searchRefClient($params['ref'], $position, $user->getNbRep());
if ($reponses !== false){
$nbReponses = $reponses->nbReponses;
$nbReponsesTotal = $reponses->nbReponsesTotal;
$etabs = $reponses->result->item;
if (count($etabs)>0) {
foreach($etabs as $i => $etab) {
$item = array();
$item['position'] = ($position)+$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.= '<i>';
if ($etab->Nom2!='') $nomDetail.= $etab->Nom2.'<br/>';
if ($etab->Enseigne<>'') $nomDetail.= 'Enseigne : '.$etab->Enseigne.'&nbsp;&nbsp;&nbsp;&nbsp;';
if ($etab->Sigle<>'') $nomDetail.= 'Sigle : '.$etab->Sigle;
$nomDetail.= '</i><br/>';
}
$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.= '&Eacute;tablissement si&egrave;ge ';
} else {
$infoEtab.= '&Eacute;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,
'siret' => $etab->Siren,
));
$infoEtab.= ' <a title="Voir la fiche d\'identité du siège de cette entreprise"'.
' href="'.$url.'">(Accès siège)</a>';
}
$item['InfoEtab'] = $infoEtab;
$adresse = $etab->Adresse.'<br/>';
if (isset($etab->Adresse2) && $etab->Adresse2 != '') {
$adresse.= $etab->Adresse2.'<br/>';
}
$adresse.= "<b>".$etab->CP." ".$etab->Ville."</b>";
$item['InfoAdresse'] = $adresse;
$forme = '';
if (trim($etab->FJ)!='')
{
$forme = '<i>Forme : '.$etab->FJLib.' ('.$etab->FJ.')</i><br/>';
}
$item['InfoForme'] = $forme;
$activite = '';
if (trim($etab->NafEnt)!='')
{
$activite = '<i>Activit&eacute; : '.$etab->NafEntLib.' ('.$etab->NafEnt.')</i><br/>';
}
$item['InfoActivite'] = $activite;
$item['login'] = $etab->Infos->login;
$item['email'] = $etab->Infos->email;
$item['source'] = $etab->Infos->source;
$item['ref'] = $etab->Infos->ref;
require_once 'common/dates.php';
$item['dateAjout'] = WDate::dateT('Y-m-d','d/m/Y',$etab->Infos->dateAjout);
$item['dateEnvoi'] = ($etab->Infos->dateEnvoi!='0000-00-00') ? WDate::dateT('Y-m-d','d/m/Y',$etab->Infos->dateEnvoi) : '';
2011-12-09 15:27:22 +00:00
$liste[] = $item;
}
}
}
if ($nbReponses < $nbReponsesTotal) {
$totPage = ceil($nbReponsesTotal/$user->getNbRep());
$curPage = $page+1;
} else {
$totPage = $curPage = 1;
}
$this->view->assign('nbReponses', $nbReponses);
$this->view->assign('nbReponsesTotal', $nbReponsesTotal);
$this->view->assign('totPage', $totPage);
$this->view->assign('curPage', $curPage);
$this->view->assign('liste', $liste);
}
2011-12-12 15:58:40 +00:00
public function csvAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$rechercheParams = new RechercheHistorique();
//On selectionne en session
if (count($rechercheParams->liste())>0){
$recherche = $rechercheParams->item(0);
$type = $recherche['type'];
$params = $recherche['params'];
}
require_once 'Scores/WsScores.php';
$ws = new WsScores();
//Criteres recherche entreprise
if ($type=='ent'){
require_once 'i18n/cleanchar.php';
// 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']));
$raisonSociale = str_replace(array('(',')'), array('', ''), $params['raisonSociale']);
$numVoie = preg_replace('/[^0-9]/', '', $params['numero']);
if ($numVoie > 9999) {
die('Numéro de voie incorrecte !');
}
$libVoie = cleanutf8($params['voie']);
$cpVille = cleanutf8($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);
}
$criteres = array();
$criteres['identifiant'] = str_replace(' ', '', $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;
$reponse = $ws->searchEntreprise($criteres, 0, 200);
2011-12-12 15:58:40 +00:00
//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']);
$dirDateNaissMM = preg_replace('/[^0-9]/', '', $params['dirDateNaissMM']);
$dirDateNaissAAAA = preg_replace('/[^0-9]/', '', $params['dirDateNaissAAAA']);
$year = date('Y')-18;
$dirDateNaiss = $dirDateNaissJJ.'/'.$dirDateNaissMM.'/'.$dirDateNaissAAAA;
if ($dirDateNaiss=='//') $dirDateNaiss = '';
$dirCpVille = preg_replace('/ +/',' ', preg_replace('/[^0-9A-Z]/', ' ',
strtoupper($params['dirCpVille']))
);
$criteres = array();
$criteres['dirNom'] = $dirNom;
$criteres['dirPrenom'] = $dirPrenom;
$criteres['dirDateNaiss'] = $dirDateNaiss;
$criteres['lieuNaiss'] = $dirCpVille;
$reponse = $ws->searchDir($criteres, $position);
}
2012-01-17 10:27:01 +00:00
$etabs = $reponse->result->item;
2011-12-12 15:58:40 +00:00
2012-01-17 10:27:01 +00:00
$user = new Utilisateur();
//echo "<pre>"; print_r($etabs); echo "</pre>"; exit;
2011-12-12 15:58:40 +00:00
$file = APPLICATION_PATH . '/../cache/pages/'.$user->getIdClient().'-'.$user->getLogin().'-'.date('YmdHis').'.csv';
2012-01-17 10:27:01 +00:00
require_once 'Scores/ExportCSV.php';
2011-12-12 15:58:40 +00:00
$export = new ExportCSV($etabs, 'rechercheEntreprise');
$export->writeFile($file);
$content_type = 'application/csv-tab-delimited-table';
//Envoi du fichier sur la sortie standard
if ( file_exists($file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($file);
} else {
echo 'Impossible de charger le fichier.';
}
}
2011-01-06 08:37:20 +00:00
}