128 lines
4.1 KiB
PHP
128 lines
4.1 KiB
PHP
#!/usr/bin/php -c/var/www/batch/config/php_batch_sd.ini
|
|
<?php
|
|
function wsLog() {}
|
|
|
|
include_once(FWK_PATH.'common/chiffres.php');
|
|
include_once(FWK_PATH.'common/dates.php');
|
|
include_once(INCLUDE_PATH.'insee/classMInsee.php');
|
|
include_once(INCLUDE_PATH.'scores/classMRegression.php');
|
|
include_once('/var/www/html/ws2/WsEntreprise.php');
|
|
include_once(FWK_PATH.'mail/sendMail.php');
|
|
|
|
$strInfoScript='Usage : '.basename($argv[0]). " <option> [FICHIERS]
|
|
Génération du cache des variables courantes si nécessaire.
|
|
|
|
Options :
|
|
-d Mode debug (Verbosité au maximum)
|
|
-f Forcer la re-Génération du cache
|
|
";
|
|
|
|
$modeDebug=$modeGeneration=false;
|
|
$argv=$_SERVER['argv'];
|
|
|
|
for ($i=1,$j=0; isset($argv[$i]); $i++) {
|
|
if (substr($argv[$i],0,1)=='-') {
|
|
switch (substr($argv[$i],1,1)) {
|
|
case 'd': $modeDebug=true; break;
|
|
case 'f': $modeGeneration=true; break;
|
|
case '-':
|
|
case '?': die($strInfoScript); break;
|
|
default: die('Option '. $argv[$i] . ' inconnue !'.EOL); break;
|
|
}
|
|
}// else $tabFichLigneCmd[]=$argv[$i];
|
|
}
|
|
|
|
$iDb=new WDB('insee');
|
|
|
|
$row = 1;
|
|
if (($handle = fopen("/root/nace.txt", "r")) !== FALSE) {
|
|
while (($data = fgetcsv($handle, 10000, "\t")) !== FALSE) {
|
|
$num = count($data);
|
|
echo "<p> $num champs à la ligne $row: <br /></p>\n";
|
|
$row++;
|
|
$naf=trim($data[0]);
|
|
for ($c=1; $c < $num; $c++) {
|
|
//echo $data[$c] . "<br />\n";
|
|
$cpf=trim(str_replace('.','',$data[$c]));
|
|
$tabInsert=array('naf'=>$naf,
|
|
'cpf'=>$cpf);
|
|
$iDb->insert('tabNafCpf', $tabInsert);
|
|
}
|
|
}
|
|
fclose($handle);
|
|
}
|
|
|
|
die();
|
|
|
|
|
|
|
|
|
|
|
|
$iInsee=new MInsee();
|
|
die(print_r($iInsee->getAdresse(479974115,12)));
|
|
|
|
/**
|
|
*
|
|
*/
|
|
//SELECT `` FROM `identite` WHERE CONCAT(SIREN,NIC) IN (SELECT DISTINCT CONCAT(insSIREn, insNIC) FROM `` WHERE `i
|
|
|
|
$iDb=new WDB('insee');
|
|
|
|
echo date('Y/m/d - H:i:s') ." - Recherche de tous les Cedex enregistrés à l'INSEE... ";
|
|
|
|
// Recherche de tous les Cedex enregistrés à l'INSEE
|
|
$ret=$iDb->select( 'identite i LEFT JOIN insee_notices n ON (n.insSIREN=i.SIREN AND n.insNIC=i.NIC)',
|
|
'i.SIREN, i.NIC, i.NOM, i.ADR_NUMVOIE, i.ADR_BTQ, i.ADR_TYPVOIE, i.ADR_LIBVOIE, i.ADR_LIBCOM, i.ADR_CP, i.ADR_COMP, i.ACTIF, i.ADR_DISTSP, n.insL6_POST',
|
|
"n.insL6_POST LIKE '%cedex%'", false, MYSQL_ASSOC);
|
|
$nbCedexInsee=count($ret);
|
|
echo date('Y/m/d - H:i:s') ." - Recherche de tous les Cedex enregistrés à l'INSEE... $nbCedexInsee cedex.".EOL;
|
|
|
|
foreach ($ret as $i=>$siretCedex) {
|
|
//print_r($siretCedex);
|
|
$siren= $siretCedex['SIREN'];
|
|
$nic= $siretCedex['NIC'];
|
|
$nom= $siretCedex['NOM'];
|
|
$adr1= $siretCedex['ADR_NUMVOIE'].' '.$siretCedex['ADR_BTQ'].' '.$siretCedex['ADR_TYPVOIE'].' '.$siretCedex['ADR_LIBVOIE'];
|
|
$adr2= $siretCedex['ADR_COMP'];
|
|
$distSP=$siretCedex['ADR_DISTSP'];
|
|
$achPos=$siretCedex['insL6_POST'];
|
|
$tmp=preg_split('/ +/', $distSP);
|
|
$msNum=trim($tmp[1])*1;
|
|
$msTyp=$tmp[0];
|
|
$msVil=$tmp[2];
|
|
$cedex=substr($achPos,0,5)*1;
|
|
echo date('Y/m/d - H:i:s') ." - $i/$nbCedexInsee : $siren $nic - $nom, $adr1, $distSP, $achPos :";
|
|
// => BP 167 SAINT NAZAIRE
|
|
// => 44603 ST NAZAIRE CEDEX
|
|
|
|
$contrat=$sirCed=$nicCed='';
|
|
if ($msNum<>0) $strMS=" AND l5_numMS=$msNum ";
|
|
else $strMS="";
|
|
$ret2=$iDb->select( 'cedexa',
|
|
'contrat, codePostal, siren, nic, l1_nom, l2_nomComp, l3_compGeo, l4_numVoie, l4_indRep, l4_libVoie, l5_distrib, l5_numMS, l5_libCom, l6_codCedex, l6_achCedex, codeInsee',
|
|
"l6_codCedex=$cedex $strMS", false, MYSQL_ASSOC);
|
|
$nbCedex=count($ret2);
|
|
$contrat=$ret2[0]['contrat'];
|
|
$sirCed=$ret2[0]['siren']*1;
|
|
$nicCed=$ret2[0]['nic']*1;
|
|
echo "$nbCedex cedex : $contrat ($sirCed $nicCed) ";
|
|
if ($nbCedex==1 && $sirCed==0) {
|
|
if ($iDb->update('cedexa',array('siren'=>$siren, 'nic'=>$nic), "contrat=$contrat", false))
|
|
echo 'maj OK';
|
|
else {
|
|
echo 'MAJ ERREUR !';
|
|
die (EOL.mysql_error().EOL);
|
|
}
|
|
}
|
|
echo EOL;
|
|
//print_r($ret2);
|
|
//echo "========================";
|
|
//die();
|
|
}
|
|
|
|
die(print_r($iInsee->getAdresse(306782434,97)));
|
|
|
|
die(print_r($iInsee->getAdresse(479974115,12)));
|
|
|
|
?>
|