2012-10-16 07:44:31 +00:00
#!/usr/bin/php -c/var/www/batch/config/php_batch_sd.ini
< ? php
include_once ( INCLUDE_PATH . 'insee/classMInsee.php' );
include_once ( FWK_PATH . 'mail/sendMail.php' );
error_reporting ( E_ALL ^ E_NOTICE );
$strInfoScript = 'Usage : ' . basename ( $argv [ 0 ]) . " [OPTION]
2013-06-19 08:24:49 +00:00
R<EFBFBD> cup<EFBFBD> ration des informations de contact issues des march<EFBFBD> s publics
2012-10-16 07:44:31 +00:00
Options :
2013-06-19 08:24:49 +00:00
- a Ne pas traiter les administrations des March<EFBFBD> s Publics
- e Ne pas traiter les entreprises des March<EFBFBD> s Publics
2012-10-16 07:44:31 +00:00
- v Mode verbose
- m Ne pas envoyer le mail d ' informations
" ;
$mInsee = new MInsee ();
$tabSrc = array ( 'adm' => array ( 'lib' => 'Administrations' ,
'db' => 'jo' ,
'table' => 'boamp_detail' ,
2013-06-19 08:24:49 +00:00
'zones' => " id, siren, nic, poste, email AS mail, web, DATE(dateInsert)*1 AS dateInsert, dateUpdate,
2012-10-16 07:44:31 +00:00
REPLACE ( REPLACE ( REPLACE ( REPLACE ( tel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( fax , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " siren>1000 AND nic>9 AND recupTel=0 AND (poste<>'' OR tel<>'' OR fax<>'' OR email<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 131 ),
'ent' => array ( 'lib' => 'Entreprises' ,
'db' => 'jo' ,
'table' => 'boamp_lots' ,
2013-06-19 08:24:49 +00:00
'zones' => " id, siren, nic, poste, email AS mail, web, DATE(dateInsert)*1 AS dateInsert, dateUpdate,
2012-10-16 07:44:31 +00:00
REPLACE ( REPLACE ( REPLACE ( REPLACE ( tel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( fax , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " siren>1000 AND nic>9 AND recupTel=0 AND (poste<>'' OR tel<>'' OR fax<>'' OR email<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 131 ),
'asso' => array ( 'lib' => 'Associations' ,
'db' => 'jo' ,
'table' => 'asso' ,
2013-06-19 08:24:49 +00:00
'zones' => " id, siren, nic, '' AS poste, Assoc_Mail AS mail, Assoc_Web AS web, DATE(dateInsert)*1 AS dateInsert, dateUpdate " ,
2012-10-16 07:44:31 +00:00
'where' => " siren>1000 AND nic>9 AND recupTel=0 AND (Assoc_Mail<>'' OR Assoc_Web<>'') " ,
'go' => 1 ,
'idSrc' => 3 ),
'mand' => array ( 'lib' => 'Mandataires' ,
'db' => 'jo' ,
'table' => 'tabMandataires' ,
'zones' => " id, sirenMand AS siren, nicMand AS nic, '' AS poste, email AS mail, web, DATE(dateInsert)*1 AS dateInsert,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( tel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( fax , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " sirenMand>1000 AND nicMand>9 AND recupTel=0 AND (tel<>'' OR fax<>'' OR email<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 176 ),
'mandGrp' => array ( 'lib' => 'MandatairesGrp' ,
'db' => 'jo' ,
'table' => 'tabMandataires' ,
'zones' => " id, sirenGrp AS siren, nicGrp AS nic, '' AS poste, email AS mail, web, DATE(dateInsert)*1 AS dateInsert,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( tel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( fax , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " sirenGrp>1000 AND nicGrp>9 AND recupTel=0 AND (tel<>'' OR fax<>'' OR email<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 176 ),
'annuWeb' => array ( 'lib' => 'Annuaire.com Web' ,
'db' => 'telephonie' ,
'table' => 'societe_ent' ,
'zones' => " id, siren, 0 AS nic, '' AS poste, web, DATE(dateInsert)*1 AS dateInsert " ,
'where' => " siren>1000 AND recupTel=0 AND web<>'' " ,
'go' => 1 ,
'idSrc' => 251 ),
'annuTel' => array ( 'lib' => 'Annuaire.com Tel' ,
'db' => 'telephonie' ,
'table' => 'societe_tel' ,
2013-06-19 08:24:49 +00:00
'zones' => " id, siren, NULL AS nic, infoTel AS poste, DATE(dateInsert)*1 AS dateInsert,
2012-10-16 07:44:31 +00:00
REPLACE ( REPLACE ( REPLACE ( REPLACE ( numTel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel " ,
2013-06-19 08:24:49 +00:00
'where' => " siren>1000 AND recupTel=0 AND libTel='T<> l<EFBFBD> phone' " ,
2012-10-16 07:44:31 +00:00
'go' => 1 ,
'idSrc' => 251 ),
'insee' => array ( 'lib' => 'Insee Even' ,
'db' => 'insee' ,
'table' => 'insee_even' ,
2013-06-19 08:24:49 +00:00
'zones' => " id, insSIREN as siren, insNIC as nic, '' AS poste, DATE(dateInsert)*1 AS dateInsert,
2012-10-16 07:44:31 +00:00
REPLACE ( REPLACE ( REPLACE ( REPLACE ( insTEL , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel " ,
'where' => " insTEL<>'' AND recupTel=0 " ,
'go' => 1 ,
'idSrc' => 2 ),
'annuFax' => array ( 'lib' => 'Annuaire.com Fax' ,
'db' => 'telephonie' ,
'table' => 'societe_tel' ,
'zones' => " id, siren, NULL AS nic, infoTel AS poste, DATE(dateInsert)*1 AS dateInsert,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( numTel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " siren>1000 AND recupTel=0 AND libTel='Fax' " ,
'go' => 1 ,
'idSrc' => 251 ),
'tourisme' => array ( 'lib' => 'Hotels/Campings' ,
'db' => 'jo' ,
'table' => 'tourisme' ,
'zones' => " id, siren, nic, '' AS poste, mail, web, DATE(dateInsert)*1 AS dateInsert,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( tel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( fax , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " siren>1000 AND nic>9 AND recupTel=0 AND (tel<>'' OR fax<>'' OR mail<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 200 ),
'qualifelec' => array ( 'lib' => 'Qualifelec' ,
'db' => 'sdv1' ,
'table' => 'qualifelec' ,
'zones' => " id, SUBSTRING(siret,1,9) AS siren, SUBSTRING(siret,10,5) AS nic, '' AS poste, mail, web, DATE(dateInsert)*1 AS dateInsert, tel, fax " ,
'where' => " siret>100000000 AND recupTel=0 AND (tel<>'' OR fax<>'' OR mail<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 211 ),
'qualipaysage' => array ( 'lib' => 'Qualipaysage' ,
'db' => 'sdv1' ,
'table' => 'qualipaysage' ,
'zones' => " id, SUBSTRING(siret,1,9) AS siren, SUBSTRING(siret,10,5) AS nic, '' AS poste, mail, web, DATE(dateInsert)*1 AS dateInsert, tel, fax " ,
'where' => " siret>100000000 AND recupTel=0 AND (tel<>'' OR fax<>'' OR mail<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 212 ),
'qualibat' => array ( 'lib' => 'Qualibat' ,
'db' => 'sdv1' ,
'table' => 'qualibat' ,
'zones' => " id, siren, NULL AS nic, '' AS poste, email AS mail, web, DATE(dateInsert)*1 AS dateInsert,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( tel , ')' , '' ), '(' , '' ), '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( fax , ')' , '' ), '(' , '' ), '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " siren>1000 AND recupTel=0 AND (tel<>'' OR fax<>'' OR email<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 213 ),
'ecoartisan' => array ( 'lib' => 'EcoArtisan' ,
'db' => 'sdv1' ,
'table' => 'ecoartisan' ,
'zones' => " id, SUBSTRING(siret,1,9) AS siren, SUBSTRING(siret,10,5) AS nic, '' AS poste, mail, web, DATE(dateInsert)*1 AS dateInsert,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( tel , ')' , '' ), '(' , '' ), '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( fax , ')' , '' ), '(' , '' ), '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( mob , ')' , '' ), '(' , '' ), '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS mob " ,
'where' => " siret>100000000 AND recupTel=0 AND (tel<>'' OR fax<>'' OR mob<>'' OR mail<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 214 ),
'finess' => array ( 'lib' => 'Finess' ,
'db' => 'sante' ,
'table' => 'finess' ,
'zones' => " id, SUBSTRING(SIRET,1,9) AS siren, SUBSTRING(SIRET,10,5) AS nic, '' AS poste, '' AS mail, '' AS web, DATE(NOW())*1 AS dateInsert,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( Tel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( Fax , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " SIRET>1000 AND recupTel=0 AND (Tel<>'' OR Fax<>'') " ,
'go' => 1 ,
'idSrc' => 210 ),
2013-06-19 08:24:49 +00:00
'cncc' => array ( 'lib' => 'CNCC' ,
'db' => 'sdv1' ,
'table' => 'tabCNCC' ,
'zones' => " id, siren, nic, '' AS poste, mail, web, dateInsert,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( Tel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( Fax , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " siren>100 AND nic>9 AND recupTel=0 AND (tel<>'' OR fax<>'' OR mail<>'' OR web<>'') " ,
'go' => 1 ,
'idSrc' => 300 ),
2012-10-16 07:44:31 +00:00
);
$tabZones = array ( 'tel' , 'fax' , 'mob' , 'mail' , 'web' );
$verbose = $noMail = false ;
$argv = $_SERVER [ 'argv' ];
if ( $_SERVER [ 'argc' ] > 1 ) {
for ( $i = 1 ; isset ( $argv [ $i ]); $i ++ ) {
if ( substr ( $argv [ $i ], 0 , 1 ) == '-' ) {
switch ( substr ( $argv [ $i ], 1 , 1 )) {
case 'a' :
$tabSrc [ 'adm' ][ 'go' ] = 0 ;
break ;
case 'e' :
$tabSrc [ 'ent' ][ 'go' ] = 0 ;
break ;
case 'v' :
$verbose = true ;
break ;
case 'm' :
$noMail = true ;
break ;
/* case 'i' :
$index = trim ( substr ( $argv [ $i ], 3 ));
break ; */
case '-' :
case '?' :
die ( $strInfoScript );
break ;
default :
die ( 'Option ' . $argv [ $i ] . " inconnue ! \n " );
break ;
}
}
}
}
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT du programme de r<> cup<75> ration des Tel, Fax, Mel et Web issus des diff<66> rentes sources... " . EOL ;
2012-10-16 07:44:31 +00:00
$iDb = new WDB ( 'jo' );
$iDb2 = new WDB ( 'jo' );
foreach ( $tabSrc as $src => $tabSrcDet ) {
if ( $tabSrcDet [ 'go' ] == 0 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - On ne traite pas les contacts ' " . $tabSrcDet [ 'lib' ] . " ' " . EOL ;
continue ;
}
echo date ( 'Y/m/d - H:i:s' ) . " - Traitement des contacts ' " . $tabSrcDet [ 'lib' ] . " ' (Source " . $tabSrcDet [ 'idSrc' ] . " ) " . EOL ;
unset ( $iDb );
$iDb = new WDB ( $tabSrcDet [ 'db' ]);
//enum('an8', 'domaines', 'fax', 'logo', '', 'mob', 'tel', 'web')
$nb = $iDb -> select ( $tabSrcDet [ 'table' ], $tabSrcDet [ 'zones' ], $tabSrcDet [ 'where' ], false , MYSQL_ASSOC , true );
if ( mysql_errno () <> 0 ) die ( mysql_error () . EOL );
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - Il y a $nb ligne(s) de contacts ' " . $tabSrcDet [ 'lib' ] . " ' <20> mettre <20> jour... " . mysql_error () . EOL ;
2012-10-16 07:44:31 +00:00
$j = 0 ;
while ( $tabTel = $iDb -> fetch ( MYSQL_ASSOC )) {
$j ++ ;
$siren = $tabTel [ 'siren' ];
$nic = $tabTel [ 'nic' ];
foreach ( $tabZones as $zone ) {
2013-06-19 08:24:49 +00:00
// Si la zone n'existe pas dans la table o<> on lit les infos de contacts
2012-10-16 07:44:31 +00:00
if ( ! isset ( $tabTel [ $zone ])) continue ;
2013-06-19 08:24:49 +00:00
// Le t<> l<EFBFBD> phone doit faire 10 chiffres
2012-10-16 07:44:31 +00:00
if (( $zone == 'tel' || $zone == 'fax' || $zone == 'mob' ) && strlen ( $tabTel [ $zone ]) < 10 && $tabTel [ $zone ] * 1 < 100000000 ) continue ;
if ( $zone <> 'tel' && $zone <> 'fax' && $zone <> 'mob' ) {
if ( strlen ( $tabTel [ $zone ]) < 4 ) continue ;
$tel = 0 ;
$infoTel = preg_replace ( '/(\s|,|\.|;)+$/' , '' , trim ( $tabTel [ $zone ]));
$infoTel = preg_replace ( '/ ou .*| et .*| \(ou\) .*| \(et\) .*| ; .*| \/ .*/' , '' , trim ( $infoTel ));
if ( $verbose ) echo $tabSrcDet [ 'lib' ] . " $j / $nb - " . $tabTel [ 'id' ] . " , $siren $nic - $zone : " . $tabTel [ $zone ] . ' ==> ' . $infoTel . EOL ;
} else {
$tel = $tabTel [ $zone ];
$infoTel = '' ;
if ( $verbose ) echo $tabSrcDet [ 'lib' ] . " $j / $nb - " . $tabTel [ 'id' ] . " , $siren $nic - $zone : " . $tabTel [ $zone ] . ' ==> ' . $tel . EOL ;
}
//continue;
if ( $iDb2 -> insert ( 'telephonie' , array ( 'siren' => $siren ,
'nic' => $nic ,
'dateProvPartenaire' => $tabTel [ 'dateInsert' ],
'typeTel' => $zone ,
'actif' => 1 ,
'infoTel' => $infoTel ,
'telephone' => $tel ,
'partenaire' => $tabSrcDet [ 'idSrc' ])) || $iDb2 -> getLastErrorNum () == 1062 ) {
if ( $iDb2 -> getLastErrorNum () <> 1062 ) @ $nbInsert [ $zone ] ++ ;
@ $nbTot [ $zone ] ++ ;
2013-06-19 08:24:49 +00:00
$tabUpdate = array ( 'recupTel' => 1 );
if ( isset ( $tabTel [ 'dateUpdate' ])) $tabUpdate [ 'dateUpdate' ] = $tabTel [ 'dateUpdate' ];
$iDb -> update ( $tabSrcDet [ 'table' ], $tabUpdate , " id= " . $tabTel [ 'id' ]);
2012-10-16 07:44:31 +00:00
} else die ( $iDb2 -> getLastError ());
}
}
}
print_r ( $nbInsert );
print_r ( $nbTot );
if ( ! $noMail ) {
2013-06-19 08:24:49 +00:00
$message = date ( 'Y/m/d - H:i:s' ) . " - Fin de la r<> cup<75> ration des Tel, Fax, Mel et Web issus des diff<66> rentes sources : " . EOL ;
2012-10-16 07:44:31 +00:00
foreach ( $tabZones as $zone )
$message .= " Nombre de nouveaux ' $zone ' = " .@ $nbInsert [ $zone ] . ' ajouts / ' .@ $nbTot [ $zone ] . ' lignes' . EOL ;
2013-06-19 08:24:49 +00:00
sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com,support@scores-decisions.com' , " R<EFBFBD> cup<EFBFBD> ration des Tel, Fax, Mel et Web " , $message );
2012-10-16 07:44:31 +00:00
}
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - FIN du programme de r<> cup<75> ration des Tel, Fax, Mel et Web issus des diff<66> rentes sources. " . EOL ;
2012-10-16 07:44:31 +00:00
die ();
2013-06-19 08:24:49 +00:00
/** Mise <20> jour des fonctions de direction **/
2012-10-16 07:44:31 +00:00
$tabFonctions = array ( 'maire' ,
'directeur' ,
2013-06-19 08:24:49 +00:00
'pr<70> sident' ,
'd<> put<75> ' ,
2012-10-16 07:44:31 +00:00
'directrice' ,
2013-06-19 08:24:49 +00:00
's<> nateur' ,
2012-10-16 07:44:31 +00:00
'proviseur' ,
2013-06-19 08:24:49 +00:00
'secr<63> taire' ,
'pr<70> fet' ,
2012-10-16 07:44:31 +00:00
'adjoint' ,
'chef' ,
'conseiller' ,
2013-06-19 08:24:49 +00:00
'ing<6E> nieur' ,
2012-10-16 07:44:31 +00:00
);
$strFct = '' ;
foreach ( $tabFonctions as $iFct => $fct ) {
if ( $iFct > 0 ) $strFct .= ' OR ' ;
$strFct .= " destinataire LIKE '% $fct %' " ;
}
$tabSrc = array ( 'adm' => array ( 'lib' => 'Administrations' ,
'db' => 'jo' ,
'table' => 'boamp_detail' ,
'zones' => " id, siren, nic, destinataire, poste, email AS mail, web, DATE(dateInsert)*1 AS dateInsert,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( tel , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS tel ,
REPLACE ( REPLACE ( REPLACE ( REPLACE ( fax , '-' , '' ), ' ' , '' ), ',' , '' ), '.' , '' ) AS fax " ,
'where' => " siren>1000 AND nic>9 AND recupDir=0 AND LENGTH(destinataire)>18 AND ( $strFct ) " ,
'go' => 1 ,
'idSrc' => 131 ),
);
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT du programme de r<> cup<75> ration des Dirigeants issus de March<63> s Publics... " . EOL ;
2012-10-16 07:44:31 +00:00
$iDb = new WDB ( 'jo' );
$iDb2 = new WDB ( 'jo' );
foreach ( $tabSrc as $src => $tabSrcDet ) {
if ( $tabSrcDet [ 'go' ] == 0 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - On ne traite pas les contacts ' " . $tabSrcDet [ 'lib' ] . " ' " . EOL ;
continue ;
}
echo date ( 'Y/m/d - H:i:s' ) . " - Traitement des contacts ' " . $tabSrcDet [ 'lib' ] . " ' " . EOL ;
unset ( $iDb );
$iDb = new WDB ( $tabSrcDet [ 'db' ]);
//enum('an8', 'domaines', 'fax', 'logo', '', 'mob', 'tel', 'web')
$nb = $iDb -> select ( $tabSrcDet [ 'table' ], $tabSrcDet [ 'zones' ], $tabSrcDet [ 'where' ], false , MYSQL_ASSOC , true );
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - Il y a $nb ligne(s) de contacts ' " . $tabSrcDet [ 'lib' ] . " ' <20> mettre <20> jour... " . mysql_error () . EOL ;
2012-10-16 07:44:31 +00:00
while ( $tabTel = $iDb -> fetch ( MYSQL_ASSOC )) {
$siren = $tabTel [ 'siren' ];
$nic = $tabTel [ 'nic' ];
print_r ( $tabTel );
continue ;
foreach ( $tabZones as $zone ) {
2013-06-19 08:24:49 +00:00
// Si la zone n'existe pas dans la table o<> on lit les infos de contacts
2012-10-16 07:44:31 +00:00
if ( ! isset ( $tabTel [ $zone ])) continue ;
2013-06-19 08:24:49 +00:00
// Le t<> l<EFBFBD> phone doit faire 10 chiffres
2012-10-16 07:44:31 +00:00
if (( $zone == 'tel' || $zone == 'fax' ) && strlen ( $tabTel [ $zone ]) < 10 ) continue ;
if ( $zone <> 'tel' && $zone <> 'fax' ) {
$tel = 0 ;
$infoTel = preg_replace ( '/(\s|,|\.|;)+$/' , '' , trim ( $tabTel [ $zone ]));
echo $tabTel [ 'id' ] . " , $siren : " . $tabTel [ $zone ] . ' ==> ' . $infoTel . EOL ;
} else {
$tel = $tabTel [ $zone ];
$infoTel = '' ;
}
//continue;
if ( $iDb2 -> insert ( 'telephonie' , array ( 'siren' => $siren ,
'nic' => $nic ,
'dateProvPartenaire' => $tabTel [ 'dateInsert' ],
'typeTel' => $zone ,
'actif' => 1 ,
'infoTel' => $infoTel ,
'telephone' => $tel ,
'partenaire' => $tabSrcDet [ 'idSrc' ])) || $iDb2 -> getLastErrorNum () == 1062 ) {
@ $nbInsert [ $zone ] ++ ;
$iDb -> update ( $tabSrcDet [ 'table' ], array ( 'recupTel' => 1 ), " id= " . $tabTel [ 'id' ]);
} else die ( $iDb2 -> getLastError ());
}
}
}
die ();
$nbAvecMaj = $nbSansMaj = $nbErr = 0 ;
while ( $tabTel = $iDbSel -> fetch ( MYSQL_ASSOC )) {
$siren = $tabTel [ 'siren' ];
$tel = trim ( strtr ( $tabTel [ 'tel' ], array ( '.' => '' , ' ' => '' , '-' => '' )));
$fax = trim ( strtr ( $tabTel [ 'fax' ], array ( '.' => '' , ' ' => '' , '-' => '' )));
$tabTmp = $iDbMaj -> select ( 'identite' , 'id, SIREN, NIC, ACTIF, SIEGE, TEL, FAX' , " SIREN= $siren ORDER BY SIEGE DESC, ACTIF DESC LIMIT 0,1 " , false , MYSQL_ASSOC );
if ( count ( $tabTmp ) > 0 ) {
$tabUpdate = array ();
$etab = $tabTmp [ 0 ];
$id = $etab [ 'id' ];
$telPrev = $etab [ 'TEL' ];
$faxPrev = $etab [ 'FAX' ];
if ( $telPrev == '' && $tel <> '' ) $tabUpdate [ 'TEL' ] = $tel ;
if ( $faxPrev == '' && $fax <> '' ) $tabUpdate [ 'FAX' ] = $fax ;
if ( count ( $tabUpdate ) > 0 ) {
$iDbMaj -> update ( 'identite' , $tabUpdate , " id= $id " );
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - Siren $siren , Tel $tel , Fax $fax : Mise <20> jour OK " . EOL ;
2012-10-16 07:44:31 +00:00
$nbAvecMaj ++ ;
}
else {
$nbSansMaj ++ ;
2013-06-19 08:24:49 +00:00
// echo date ('Y/m/d - H:i:s')." - Siren $siren, Tel $tel, Fax $fax : PAS de mise <20> jour".EOL;
2012-10-16 07:44:31 +00:00
}
} else {
echo date ( 'Y/m/d - H:i:s' ) . " - Siren $siren , Tel $tel , Fax $fax : Pas de fiche identite ! " . EOL ;
$nbErr ++ ;
// die();
}
/* print_r ( $tabTel );
print_r ( $tabTmp );
die (); */
}
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - FIN de la mise <20> jour des TEL/FAX des entreprises ( $nbAvecMaj MAJ/ $nbTel avec $nbErr erreurs). " . EOL ;
2012-10-16 07:44:31 +00:00
die ();
?>