144 lines
4.3 KiB
PHP
144 lines
4.3 KiB
PHP
|
<?php
|
||
|
require_once 'export/ExportCSV.php';
|
||
|
|
||
|
if (isset($_SESSION['formR'])) {
|
||
|
$formR = $_SESSION['formR'];
|
||
|
} else {
|
||
|
echo "Erreur : les paramètres de recherche n'ont pas pu être récupérer !";
|
||
|
}
|
||
|
|
||
|
if ($typeRech == 'ent') {
|
||
|
// Type de recherche = entreprises
|
||
|
$telFax = trim(preg_replace('/[^0-9]/', '', $formR['telFax']));
|
||
|
$naf = trim(preg_replace('/[^0-9A-Z]/i', '', $formR['naf']));
|
||
|
//if ($telFax<>'') $typeId='T';
|
||
|
|
||
|
// Traitement des données formulaire
|
||
|
$raisonSociale =
|
||
|
preg_replace('/[^0-9A-Z]/', ' ',
|
||
|
strtoupper(cleanstring($formR['raisonSociale'])));
|
||
|
$numVoie = preg_replace('/[^0-9]/', '', $formR['numVoie']);
|
||
|
if ($numVoie > 9999) {
|
||
|
die('Numéro de voie incorrecte !');
|
||
|
}
|
||
|
$libVoie = preg_replace('/[^0-9A-Z]/', ' ',
|
||
|
strtoupper(cleanstring($formR['voie'])));
|
||
|
$cpVille =
|
||
|
preg_replace('/ +/',' ',
|
||
|
preg_replace('/[^0-9A-Z]/', ' ',
|
||
|
strtoupper(cleanstring($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);
|
||
|
}
|
||
|
} else if ($typeRech == 'dir') {
|
||
|
// Type de recherche = dirigeants
|
||
|
$dirNom = preg_replace('/[^0-9A-Z]/', ' ',
|
||
|
strtoupper(trimAccent($formR['dirNom']))
|
||
|
);
|
||
|
$dirPrenom = preg_replace('/[^0-9A-Z]/', ' ',
|
||
|
strtoupper(trimAccent($formR['dirPrenom']))
|
||
|
);
|
||
|
$dirDateNaissJJ = preg_replace('/[^0-9]/', '',
|
||
|
$formR['dirDateNaissJJ'])*1;
|
||
|
if ($dirDateNaissJJ<0 || $dirDateNaissJJ>31)
|
||
|
die('Jour de naissance incorrect !');
|
||
|
$dirDateNaissMM = preg_replace('/[^0-9]/', '',
|
||
|
$formR['dirDateNaissMM'])*1;
|
||
|
if ($dirDateNaissMM<0 || $dirDateNaissMM>12)
|
||
|
die('Mois de naissance incorrect !');
|
||
|
$dirDateNaissAAAA = preg_replace('/[^0-9]/', '',
|
||
|
$formR['dirDateNaissAAAA'])*1;
|
||
|
$year = date('Y')-18;
|
||
|
if ($dirDateNaissAAAA<0 || $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);
|
||
|
}
|
||
|
} elseif ($typeRech == 'act') {
|
||
|
|
||
|
$actNomRs = trim($formR['actNomRs']);
|
||
|
$pays = $formR['pays'];
|
||
|
$pctMin = preg_replace('/[^0-9]/', '', trim($formR['pctMin']));
|
||
|
$pctMax = preg_replace('/[^0-9]/', '', trim($formR['pctMax']));
|
||
|
$cpVille = preg_replace('/ +/',' ', preg_replace('/[^0-9A-Z]/', ' ',strtoupper(cleanstring($formR['cpVille']))));
|
||
|
|
||
|
}
|
||
|
|
||
|
//Type de recherche = entreprise
|
||
|
if ($typeRech=='ent' && $siret<>'') {
|
||
|
try {
|
||
|
$O = $client->searchSiren($siret, $position, $tabInfo['nbReponses'], 200, $cp);
|
||
|
} catch (SoapFault $fault) {
|
||
|
require_once 'soaperror.php';
|
||
|
processSoapFault($client,$fault,$tabInfo);
|
||
|
}
|
||
|
} elseif ($typeRech=='ent' && $telFax<>'') {
|
||
|
try {
|
||
|
$O = $client->searchTelFax($telFax, $position, $tabInfo['nbReponses'], 200);
|
||
|
} catch (SoapFault $fault) {
|
||
|
require_once 'soaperror.php';
|
||
|
processSoapFault($client,$fault,$tabInfo);
|
||
|
}
|
||
|
} elseif ($typeRech=='ent' && ($typeId=='R' || $typeId=='W' || $typeId=='I') ) {
|
||
|
try {
|
||
|
$O = $client->searchAutreId($typeId, $autreId, $position, $tabInfo['nbReponses'], 200, $cp);
|
||
|
} catch (SoapFault $fault) {
|
||
|
require_once 'soaperror.php';
|
||
|
processSoapFault($client,$fault,$tabInfo);
|
||
|
}
|
||
|
} elseif ($typeRech=='ent' && $siret=='') {
|
||
|
try {
|
||
|
$O = $client->searchNomAdr(
|
||
|
$raisonSociale, $numVoie.' '.$libVoie, $cp, $ville, false, false,
|
||
|
$position, $tabInfo['nbReponses'], 200, false, false,
|
||
|
$naf
|
||
|
);
|
||
|
} catch (SoapFault $fault) {
|
||
|
require_once 'soaperror.php';
|
||
|
processSoapFault($client,$fault,$tabInfo);
|
||
|
}
|
||
|
} elseif ($typeRech=='dir') {
|
||
|
try {
|
||
|
$O = $client->searchDir(
|
||
|
$dirNom, $dirPrenom, $dirDateNaiss, $dirVille,
|
||
|
$position, $tabInfo['nbReponses'], 200, false
|
||
|
);
|
||
|
} catch (SoapFault $fault) {
|
||
|
require_once 'soaperror.php';
|
||
|
processSoapFault($client,$fault,$tabInfo);
|
||
|
}
|
||
|
} elseif ($typeRech=='act') {
|
||
|
try {
|
||
|
$O = $client->searchAct(
|
||
|
$actNomRs, $cpVille, $siret, $pays, $pctMin, $pctMax,
|
||
|
$position, $tabInfo['nbReponses'], 200, false
|
||
|
);
|
||
|
} catch (SoapFault $fault) {
|
||
|
require_once 'soaperror.php';
|
||
|
processSoapFault($client,$fault,$tabInfo);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$etabs = $O['results']['reponses'];
|
||
|
|
||
|
$export = new ExportCSV($etabs, 'rechercheEntreprise');
|
||
|
$export->writeFile(PATH_DATA . '/../cache/pages/marecherche.csv');
|
||
|
|
||
|
|