Prise en compte des nouvelles options pour le format du fichier en sortie
This commit is contained in:
parent
996db51afc
commit
eaf4d1c699
@ -117,7 +117,12 @@ if ( $id === null ) {
|
||||
|
||||
// --- Read SIRETs from order
|
||||
$commandesM = new Application_Model_CiblageEnrichissementIdentifiants();
|
||||
try {
|
||||
$commande = $commandesM->find(intval($id))->current();
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
echo date('Y-m-d H:i:s') . " - Erreur chargement commande...\n";
|
||||
exit;
|
||||
}
|
||||
$identifiants = json_decode($commande->identifiants, true);
|
||||
|
||||
// --- Read profil for data extract
|
||||
@ -125,7 +130,17 @@ $profilM = new Application_Model_CiblageEnrichissementProfils();
|
||||
$profil = $profilM->find(intval($commande->idProfil))->current();
|
||||
$dataProfil = json_decode($profil->criteres, true);
|
||||
|
||||
// --- Options du fichier
|
||||
$fileFormat = 'csv';
|
||||
$fileSeparator = ',';
|
||||
$fileDbParams = $commande->fichierParams;
|
||||
if ( !empty($fileDbParams) ) {
|
||||
$options = json_decode($fileDbParams);
|
||||
$fileFormat = $options->type;
|
||||
if ( $fileFormat == 'csv' && isset($options->separator) ) {
|
||||
$fileSeparator = $options->separator;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Something is needed
|
||||
if ( count($identifiants)==0 || count($dataProfil)==0 ) {
|
||||
@ -195,10 +210,17 @@ if ($fileFormat == 'csv')
|
||||
{
|
||||
$outFile = $profil->login.'_'.$id.'_'.date('YmdHis').'.csv';
|
||||
$fp = fopen($path.'/'.$outFile, 'w');
|
||||
// ---- Ecrire l'entete
|
||||
if ($fp === false) {
|
||||
echo "Erreur création fichier.\n";
|
||||
exit;
|
||||
}
|
||||
if ($opts->verbose) {
|
||||
echo "Ecriture fichier : $outFile\n";
|
||||
}
|
||||
// --- Ecrire l'entete
|
||||
if (count($tabEnteteLabel) > 0)
|
||||
{
|
||||
fputcsv($fp, $tabEnteteLabel, $fileOptions['separator'], '"');
|
||||
fputcsv($fp, $tabEnteteLabel, $fileSeparator, '"');
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +320,7 @@ foreach ($identifiants as $siret)
|
||||
|
||||
// --- Ecriture dans le fichier
|
||||
if ($fileFormat == 'csv') {
|
||||
fputcsv($fp, $tabSortie, ',', '"');
|
||||
fputcsv($fp, $tabSortie, $fileSeparator, '"');
|
||||
}
|
||||
|
||||
if ($fileFormat == 'xlsx') {
|
||||
|
Loading…
Reference in New Issue
Block a user