981 lines
33 KiB
PHP
981 lines
33 KiB
PHP
<?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';
|
|
require_once 'Scores/WsScores.php';
|
|
|
|
$this->view->headLink()->appendStylesheet('/themes/default/styles/recherche.css', 'all');
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/recherche.js', 'text/javascript');
|
|
}
|
|
|
|
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->assign('message', $request->getParam('message'));
|
|
$this->view->assign('form', $form);
|
|
|
|
require_once 'Scores/Utilisateur.php';
|
|
$user = new Utilisateur();
|
|
$this->view->assign('RefClient', $user->checkPref('rechref'));
|
|
}
|
|
|
|
/**
|
|
* Affiche le formulaire de recherche dirigeants
|
|
*/
|
|
public function dirigeantAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
$this->view->headTitle()->append('Recherche Dirigeant');
|
|
require_once 'Web/Forms/RechercheDirigeant.php';
|
|
$form = new Form_RechercheDirigeant();
|
|
|
|
if ( $request->isPost() || $request->isGet() ){
|
|
$form->populate($request->getParams());
|
|
}
|
|
|
|
$this->view->assign('form', $form);
|
|
}
|
|
|
|
/**
|
|
* Affiche le formulaire de recherche actionnaire
|
|
* @todo : style pour les pourcentages
|
|
*/
|
|
public function actionnaireAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
$this->view->headTitle()->append('Recherche Actionnaire');
|
|
require_once 'Web/Forms/RechercheActionnaire.php';
|
|
$form = new Form_RechercheActionnaire();
|
|
|
|
if ( $request->isPost() || $request->isGet() ){
|
|
$form->populate($request->getParams());
|
|
}
|
|
|
|
$this->view->assign('form', $form);
|
|
}
|
|
|
|
/**
|
|
* Affiche le formulaire de recherche annonces
|
|
*/
|
|
public function annonceAction()
|
|
{
|
|
$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);
|
|
}
|
|
|
|
public function annoncelisteAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
$params = $request->getParams();
|
|
$token = $request->getParam('token', null);
|
|
|
|
$session = new RechercheHistorique();
|
|
|
|
if (array_key_exists('formA', $params)) {
|
|
$token = $session->save('annonce', $params);
|
|
} else {
|
|
$recherche = $session->get($token);
|
|
$params = $recherche['params'];
|
|
}
|
|
|
|
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'];
|
|
}
|
|
|
|
$ws = new WsScores();
|
|
$result = $ws->rechercheAnnonce($ra['source'], $ra['dateAnnee'], $ra['numParution'], $ra['numAnnonce']);
|
|
$infos = $result->result->item;
|
|
|
|
$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].' ';
|
|
}
|
|
}
|
|
$this->view->assign('criteres', $result->criteres);
|
|
$this->view->assign('infos', $infos);
|
|
|
|
} else {
|
|
|
|
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);
|
|
|
|
$ws = new WsScores();
|
|
$result = $ws->rechercheHisto($txt, $params['formA']['annee'], $params['formA']['bodacc'], $p);
|
|
|
|
$infos = $result->reponses->item;
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
$identity = $auth->getIdentity();
|
|
|
|
$authinfo = '?login='.$identity->username.'&hach='.$identity->password;
|
|
$this->view->assign('authinfo', $authinfo);
|
|
|
|
$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].', ';
|
|
}
|
|
}
|
|
$this->view->assign('mots', $result->mots->item);
|
|
}
|
|
|
|
$this->view->assign('p', $p);
|
|
$this->view->assign('token', $token);
|
|
|
|
$this->view->assign('infos', $infos);
|
|
|
|
require_once 'Scores/Utilisateur.php';
|
|
$user = new Utilisateur();
|
|
$this->view->assign('userNbReponses', $user->getNbRep());
|
|
|
|
$this->view->assign('nbReponses', $result->nbReponses);
|
|
$this->view->assign('nbReponsesTotal', $result->nbReponsesTotal);
|
|
|
|
$this->view->assign('strCriteres', $strCriteres);
|
|
$this->view->assign('histo', $params['formA']['histo']);
|
|
|
|
}
|
|
|
|
public function internationaleAction(){}
|
|
|
|
public function lastAction()
|
|
{
|
|
$this->view->headTitle()->append('Liste des dernières recherches');
|
|
// @todo : Attention lorsqu'il n'y pas de recherche enregistré
|
|
$rechercheSession = new RechercheHistorique();
|
|
$derniereRecherche = $rechercheSession->item(0);
|
|
$params = array_merge(array('type'=> $derniereRecherche['type']), $derniereRecherche['params']);
|
|
$this->_forward('liste', 'recherche', null, $params);
|
|
}
|
|
|
|
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());
|
|
|
|
$configuration = Zend_Registry::get('configuration');
|
|
$path = realpath($configuration->path->data).'/'.$configuration->path->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<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);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Affiche les résultats d'une recherche
|
|
*/
|
|
public function listeAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
$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'];
|
|
}
|
|
|
|
//Giant
|
|
if( !empty($params['pays']) && $type == 'ent' ){
|
|
Zend_Registry::get('firebug')->info('RECHERCHE GIANT');
|
|
$this->_forward('search', 'giant', null, $params);
|
|
//Recherche
|
|
} else {
|
|
|
|
require_once 'Scores/Utilisateur.php';
|
|
$user = new Utilisateur();
|
|
|
|
$page = $request->getParam('page', 1);
|
|
if ($page==0) $page = 1;
|
|
$page = $page-1;
|
|
$position = $page*$user->getNbRep();
|
|
|
|
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(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;
|
|
$reponse = $ws->searchEntreprise($criteres, $position);
|
|
|
|
$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]/', ' ',
|
|
strtoupper($params['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'] = $dirCpVille;
|
|
|
|
$reponse = $ws->searchDir($criteres, $position, $user->getNbRep());
|
|
|
|
} 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);
|
|
$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) {
|
|
$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();
|
|
$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.' ';
|
|
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.= 'É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,
|
|
'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é : '.$etab->NafEntLib.' ('.$etab->NafEnt.')</i><br/>';
|
|
}
|
|
$item['InfoActivite'] = $activite;
|
|
|
|
if ($type=='dir') {
|
|
|
|
$item['InfoDirigeant'] = '<u>Dirigeant recherché :</u> ';
|
|
if ($etab->DirRs!='') {
|
|
$item['InfoDirigeant'].= '<b>'.$etab->DirRs.'</b>, représenté 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é :</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 ';
|
|
}
|
|
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(
|
|
'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;
|
|
}
|
|
}
|
|
|
|
} elseif (is_string($reponse)){
|
|
$this->_forward('entreprise', 'recherche', null, array_merge(
|
|
$params, array('message' => $reponse))
|
|
);
|
|
} else {
|
|
$this->_forward('soap', 'error');
|
|
}
|
|
|
|
$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(
|
|
'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);
|
|
}
|
|
}
|
|
|
|
public function ipariAction()
|
|
{
|
|
$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);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
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());
|
|
|
|
$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.' ';
|
|
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.= 'É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,
|
|
'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é : '.$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) : '';
|
|
|
|
$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);
|
|
}
|
|
|
|
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);
|
|
|
|
//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);
|
|
}
|
|
|
|
$etabs = $reponse->result->item;
|
|
|
|
$user = new Utilisateur();
|
|
//echo "<pre>"; print_r($etabs); echo "</pre>"; exit;
|
|
|
|
$file = APPLICATION_PATH . '/../cache/pages/'.$user->getIdClient().'-'.$user->getLogin().'-'.date('YmdHis').'.csv';
|
|
|
|
require_once 'Scores/ExportCSV.php';
|
|
$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.';
|
|
}
|
|
|
|
}
|
|
|
|
} |