Préparation mode verbeux
This commit is contained in:
parent
80388d6e64
commit
d0b6af7b1f
@ -28,7 +28,8 @@ try {
|
||||
array(
|
||||
'help|?' => "Aide.",
|
||||
'id=s' => "Identifiant du traitement",
|
||||
'file=s' => "Identifiant pour les traitements par fichier"
|
||||
'file=s' => "Identifiant pour les traitements par fichier",
|
||||
'verbose' => "Mode verbeux",
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
@ -45,15 +46,6 @@ if(isset($opts->help) || !isset($opts->id) && !isset($opts->file) )
|
||||
|
||||
$config = new Zend_Config($application->getOptions());
|
||||
|
||||
//MetadataCache pour la base de données
|
||||
$frontendOptions = array(
|
||||
'lifetime' => 14400,
|
||||
'automatic_serialization' => true
|
||||
);
|
||||
$backendOptions = array();
|
||||
$cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions);
|
||||
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
|
||||
|
||||
//Définition bdd
|
||||
try {
|
||||
$db = Zend_Db::factory($config->profil->db->metier);
|
||||
@ -94,8 +86,6 @@ $path = $config->profil->path->data.'/'.$mois;
|
||||
if(!file_exists($path))
|
||||
mkdir($path);
|
||||
|
||||
$outFile = $profil->login.'_'.$opts->id.'_'.date('YmdHis').'.csv';
|
||||
|
||||
require_once 'Scores/Enrichissement.php';
|
||||
$dico = new Enrichissement();
|
||||
$fields = $dico->getFields();
|
||||
@ -144,8 +134,7 @@ $columns[] = 'presentRcs';
|
||||
$tabEntete[] = 'presentRcs';
|
||||
$tabEnteteLabel[] = 'RCS';
|
||||
|
||||
//Pour chaque identifiant traiter les données
|
||||
$row = 0;
|
||||
$outFile = $profil->login.'_'.$opts->id.'_'.date('YmdHis').'.csv';
|
||||
$fp = fopen($path.'/'.$outFile, 'w');
|
||||
//Ecrire l'entete
|
||||
if (count($tabEnteteLabel)>0){
|
||||
@ -154,19 +143,22 @@ if (count($tabEnteteLabel)>0){
|
||||
//Mise à jour des éléments
|
||||
if ($opts->id) {
|
||||
$commandesM->update(array(
|
||||
'dateStart'=>date('Y-m-d H:i:s'),
|
||||
'dateStart'=> date('Y-m-d H:i:s'),
|
||||
'fichier' => basename($outFile)
|
||||
),
|
||||
"id = ".$commande->id);
|
||||
), "id = ".$commande->id);
|
||||
}
|
||||
|
||||
$traite = 0;
|
||||
//Date de debut de traitement.
|
||||
$dateStart = date('YmdHms');
|
||||
foreach ($identifiants as $siret )
|
||||
{
|
||||
//Pour chaque identifiant traiter les données
|
||||
$row = 1;
|
||||
|
||||
$sql = $db->select()->from('etablissements_act', $columns, 'jo');
|
||||
//Date de debut de traitement.
|
||||
$dateStart = date('YmdHis');
|
||||
if ($opts->verbose) echo "Nb Lines :".count($identifiants)."\n";
|
||||
foreach ($identifiants as $siret)
|
||||
{
|
||||
if ($opts->verbose) echo "Line $row.\n";
|
||||
|
||||
$sql = $db->select()->from('etablissements_act', $columns, 'jo');
|
||||
$sql->where("siren='".substr($siret,0,9)."' AND nic='".substr($siret,9,5)."'");
|
||||
if (count($joins)) {
|
||||
foreach ( $joins as $join ) {
|
||||
@ -176,10 +168,9 @@ foreach ($identifiants as $siret )
|
||||
|
||||
try {
|
||||
$result = $db->fetchRow($sql, null, Zend_Db::FETCH_ASSOC);
|
||||
$traite++;
|
||||
} catch(Exception $e) {
|
||||
echo $sql;
|
||||
}
|
||||
echo $sql."\n";
|
||||
}
|
||||
|
||||
$tabData = $result;
|
||||
//Trier pour la sortie
|
||||
@ -190,7 +181,7 @@ foreach ($identifiants as $siret )
|
||||
if ( array_key_exists('values', $fields[$key]) ) {
|
||||
$values = $fields[$key]['values'];
|
||||
//Remplace value if exist
|
||||
if ( in_array($tabData[$key], $values) ) {
|
||||
if ( array_key_exists($tabData[$key], $values) ) {
|
||||
$tabData[$key] = $values[$tabData[$key]];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user