Maj script test

This commit is contained in:
Michael RICOIS 2015-09-22 15:20:30 +00:00
parent 8ebe7c31fa
commit 1585f90861

View File

@ -8,13 +8,13 @@ $dateStopIn = '2015-10-01';
'341762573',
);*/
$options = getopt("f:");
$file = basename($options['f'], '.csv');
$companies = array();
$row = 1;
if (($handle = fopen("liste-01.csv", "r")) !== false) {
if (($handle = fopen(__DIR__.'/'.$file.'.csv', "r")) !== false) {
while (($data = fgetcsv($handle, 0, ",")) !== false) {
if ($row == 1) {
continue;
}
$row++;
$companies[] = $data[0];
}
@ -49,7 +49,7 @@ require_once 'Metier/partenaires/classMBanques.php';
require_once 'Metier/insee/classMInsee.php';
$fp = fopen('retour-'.date('YmdHis').'.csv', 'w');
$fp = fopen($file.'-'.date('YmdHis').'.csv', 'w');
$delimiter = ',';
$fileHeader = array(
'siren',
@ -66,6 +66,7 @@ $fileHeader = array(
);
fputcsv($fp, $fileHeader, $delimiter, '"');
$cpt = 1;
foreach ($companies as $item)
{
// --- Date de création de l'entreprise
@ -83,7 +84,7 @@ foreach ($companies as $item)
}
// DateImma
if ($dateCreaEn === null) {
if ($dateCreaEnSet === null) {
$sql = $db->select()->from('rncs_entrep', array('dateImma'), 'jo')
->where('siren=?', $item)->limit(1);
$result = $db->fetchRow($sql, null, Zend_Db::FETCH_OBJ);
@ -146,6 +147,7 @@ foreach ($companies as $item)
// date +1
$dateCalcul->addMonth(1);
}
$cpt++;
}
fclose($fp);