batch/old/exportTel.php
2013-06-19 08:24:49 +00:00

121 lines
3.8 KiB
PHP

#!/usr/bin/php -c/var/www/batch/config/php_batch_sd.ini
<?php
/** @todo Faire tourner le premier lundi du mois
**/
function exporte($txt, $lon=-1, $sep="|") {
$txt=strtr(trim($txt),array('&#039;'=>"'",'&amp;'=>'&', '&sup2;'=>'²', "\r"=>'', "\n"=>'', "\t"=>''));
if ($lon==-1) return $txt.$sep;
elseif ($sep=='') return sprintf("%-".$lon.'.'.$lon."s", $txt);
else return trim(sprintf("%-".$lon.'.'.$lon."s", $txt)).$sep;
}
function choixAdr($bodEtab, $bodSiege, $insee) {
if (strlen(trim($bodSiege))>0) $adr=trim($bodSiege);
elseif (strlen(trim($bodEtab))>0) $adr=trim($bodEtab);
else $adr='';
if (isset($insee) && trim($insee)<>'') return $insee;
else return $adr;
}
error_reporting(E_ALL);
include_once(FWK_PATH.'common/chiffres.php');
include_once(FWK_PATH.'common/dates.php');
include_once(INCLUDE_PATH.'partenaires/classMBilans.php');
include_once(INCLUDE_PATH.'insee/classMInsee.php');
include_once(INCLUDE_PATH.'scores/classMFinancier.php');
include_once(INCLUDE_PATH.'scores/classMScores.php');
include_once(FWK_PATH.'mail/sendMail.php');
include_once(INCLUDE_PATH.'partenaires/classMLiens.php');
$iDb=new WDB('jo');
$iInsee=new MInsee();
$strInfoScript='Usage : '.basename($argv[0]). " [OPTION] [Stock Adecco à charger]
Traitement spécifique Kompass.
Options :
-1 Prestation 1 Mise à disposition du stock des Entrep Risques Fort
-3 Prestation 3 Transformation de la surveillance Bodacc en spécifique Kompass
-4 Prestation 4 Mise à disposition de la base Liens
-5 Prestation 5 Mise à disposition de la base Ratios
-v Verbosité maximum
";
$argv=$_SERVER['argv'];
if ($_SERVER['argc']>1)
{
for ($i=1; isset($argv[$i]); $i++) {
if (substr($argv[$i],0,1)=='-') {
switch (strtolower(substr($argv[$i],1,1))) {
case '1': $presta=1; break;
case '3': $presta=3; break;
case '4': $presta=4; break;
case '5': $presta=5; break;
case '-':
case '?': die($strInfoScript); break;
default: die('Option '. $argv[$i] . " inconnue !\n");
break;
}
} else $tabFichier[]=$argv[$i];
}
}
$tabLignes=file($tabFichier[0]);
$iTel=new MTel(false);
foreach ($tabLignes as $i=>$ligne) {
$tmp1=explode("\t", $ligne);
$siren=trim($tmp1[0]);
$nic=trim($tmp1[1]);
//$tmp1=$iTel->getTel($siren);
$tmp=$iTel->getTel($siren, $nic);
//echo "$siren $nic".EOL;
if (count($tmp)==0) echo "$siren,$nic".EOL;
else {
$tel=$mob=$ttel='';
foreach ($tmp as $tmp2) {
if ($tmp2['typeTel']=='tel' && $tmp2['telephone']>=600000000 && $tmp2['telephone']<800000000) {
$mob=implode('.', str_split($tmp2['telephone'],2));
$ttel='M';
} elseif ($tmp2['typeTel']=='tel') {
$tel=implode('.', str_split($tmp2['telephone'],2));
$ttel='F';
} elseif ($tmp2['typeTel']=='mob' && $tmp2['telephone']>=600000000 && $tmp2['telephone']<800000000) {
$mob=implode('.', str_split($tmp2['telephone'],2));
$ttel='M';
} elseif ($tmp2['typeTel']=='mob') {
$tel=implode('.', str_split($tmp2['telephone'],2));
$ttel='F';
} elseif ($tmp2['typeTel']=='fax' && $tmp2['telephone']>=600000000 && $tmp2['telephone']<800000000) {
$mob=implode('.', str_split($tmp2['telephone'],2));
$ttel='M';
}
//if ($tmp2['typeTel']=='fax')
// $fax=implode('.', str_split($tmp2['telephone'],2));
/*if ($tmp2['typeTel']=='web' && $tab['web']=='') $tab['web']=$tmp2['infoTel'];
if ($tmp2['typeTel']=='mail' && $tab['mail']=='') $tab['mail']=$tmp2['infoTel'];
if ($tmp2['typeTel']=='an8') $activitePJ_An8=$tmp2['infoTel'];*/
if ($tel<>'' && $mob<>'') break;//$ttel<>'')
}
echo "$siren,$nic,$tel,$mob".EOL;
}
//print_r($tmp);
//die();
}
/* $activitePJ_An8='';
*/
die();
?>