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 ( INCLUDE_PATH . 'bodacc/classMBodacc.php' );
include_once ( FWK_PATH . 'mail/sendMail.php' );
error_reporting ( E_ALL ^ E_NOTICE );
$iDb = new WDB ( 'tmp' );
$iDb2 = new WDB ( 'tmp' );
$iInsee = new MInsee ();
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - D<> but... " . EOL ;
2012-10-16 07:44:31 +00:00
$tmp = $iDb -> select ( 'jo.annonces' , 'DISTINCT siren' , " typeEven IN (2720,2721,2725,2726,2730) AND siren>0 AND dateJugement>='2009-01-01' " , true , MYSQL_ASSOC );
foreach ( $tmp as $tabTmp ) {
$tabAbs [] = $tabTmp [ 'siren' ];
}
$nbAbs = count ( $tabAbs );
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - Nombre d'entit<69> es absorb<72> es : " . $nbAbs . EOL ;
2012-10-16 07:44:31 +00:00
//die();
//$nbTot=$iDb->select('`adecco-201107`', 'SIREN, NIC', "sirenValide IS NULL OR nicValide IS NULL", true, MYSQL_ASSOC, true);
$nbTot = $iDb -> select ( '`adecco-201107`' , 'SIREN, NIC' , " sirenValide=1 AND nicValide=1 AND actif=0 AND demenage IN (NULL,0) " , true , MYSQL_ASSOC , true );
echo mysql_error () . EOL ;
2013-06-19 08:24:49 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - Nombre d'entit<69> es <20> traiter : " . $nbTot . EOL ;
2012-10-16 07:44:31 +00:00
$k = $nbDem = 0 ;
while ( $entrep = $iDb -> fetch ( MYSQL_ASSOC )) {
2013-06-19 08:24:49 +00:00
if ( $k % 1000 == 0 ) echo date ( 'Y/m/d - H:i:s' ) . " - $k / $nbTot : $nbDem d<> m<EFBFBD> nag<61> s " . EOL ;
2012-10-16 07:44:31 +00:00
$k ++ ;
$siren = $entrep [ 'SIREN' ];
$nic = $entrep [ 'NIC' ];
if ( in_array ( $siren , $tabAbs )) {
$iDb2 -> update ( 'adecco-201107' ,
array ( 'fusion' => 1 ),
" SIREN= $siren AND NIC= $nic " , false ) or die ( mysql_error ());
echo date ( 'Y/m/d - H:i:s' ) . " - $k / $nbTot : Absorption ! " . EOL ;
} /*
continue ;
$tabAssoc = $iInsee -> getSiretAssoc ( $siren , $nic );
if ( count ( $tabAssoc ) > 0 ) {
if ( isset ( $tabAssoc [ 'suc' ])) {
// Il y a un successeur
$nbDem ++ ;
$iDb2 -> update ( 'adecco-201107' ,
array ( 'demenage' => 1 ),
" SIREN= $siren AND NIC= $nic " , false ) or die ( mysql_error ());
continue ;
}
}
$iDb2 -> update ( 'adecco-201107' ,
array ( 'demenage' => 0 ),
" SIREN= $siren AND NIC= $nic " , false ) or die ( mysql_error ());
/* $siretValide = $iInsee -> valideSiren ( $siren , $nic );
if ( $siretValide ) {
$sirenValide = $nicValide = true ;
} else {
$sirenValide = $iInsee -> valideSiren ( $siren );
$nicValide = false ;
}
$iDb2 -> update ( 'adecco-201107' ,
array ( 'sirenValide' => $sirenValide ,
'nicValide' => $nicValide ),
" SIREN= $siren AND NIC= $nic " , false ) or die ( mysql_error ());
*/
}
echo date ( 'Y/m/d - H:i:s' ) . " - FIN des $k lignes. " . EOL ;
die ();
?>