issue #0001575: encoding UTF-8
This commit is contained in:
parent
4c30dae316
commit
1f1e217a45
@ -45,14 +45,14 @@ 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);
|
||||
//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 {
|
||||
@ -67,13 +67,13 @@ $liste = array();
|
||||
if ($opts->id)
|
||||
{
|
||||
//Read SIRETs
|
||||
$commandesM = new Application_Model_CiblageEnrichissementIdentifiants();
|
||||
$commandesM = new Application_Model_CiblageEnrichissementIdentifiants();
|
||||
$commande = $commandesM->find(intval($opts->id))->current();
|
||||
$identifiants = json_decode($commande->identifiants, true);
|
||||
|
||||
//Read profil for data extract
|
||||
$profilM = new Application_Model_CiblageEnrichissementProfils();
|
||||
$profil = $profilM->find(intval($commande->idProfil))->current();
|
||||
$profilM = new Application_Model_CiblageEnrichissementProfils();
|
||||
$profil = $profilM->find(intval($commande->idProfil))->current();
|
||||
$dataProfil = json_decode($profil->criteres, true);
|
||||
}
|
||||
else if ($opts->file)
|
||||
@ -147,26 +147,27 @@ $tabEntete[] = 'teff_etabLib';
|
||||
$tabEntete[] = 'teff_entrepLib';
|
||||
$tabEnteteLabel[] = 'Libelle Tranche Effectif Etablissement ';
|
||||
$tabEnteteLabel[] = 'Libelle Tranche Effectif Entreprise';
|
||||
//Convert
|
||||
$tabEnteteLabel = array_map('utf8_decode',array_values($tabEnteteLabel));
|
||||
//Pour chaque identifiant traiter les données
|
||||
$row = 0;
|
||||
$fp = fopen($path.'/'.$outFile, 'w');
|
||||
$row = 0;
|
||||
$fp = fopen($path.'/'.$outFile, 'w');
|
||||
//Ecrire l'entete
|
||||
if (count($tabEnteteLabel)>0){
|
||||
fputcsv($fp, $tabEnteteLabel, ',', '"');
|
||||
if (count($tabEnteteLabel)>0){
|
||||
fputcsv($fp, $tabEnteteLabel, ',', '"');
|
||||
}
|
||||
//Mise à jour des éléments
|
||||
if ($opts->id) {
|
||||
$commandesM->update(array(
|
||||
'dateStart'=>date('Y-m-d H:i:s'),
|
||||
//Mise à jour des éléments
|
||||
if ($opts->id) {
|
||||
$commandesM->update(array(
|
||||
'dateStart'=>date('Y-m-d H:i:s'),
|
||||
'fichier' => basename($outFile)
|
||||
),
|
||||
"id = ".$commande->id);
|
||||
),
|
||||
"id = ".$commande->id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$model = $sql;
|
||||
//print_r($model);exit;
|
||||
//Date de debut de traitement.
|
||||
$dateStart = date('YmdHms');
|
||||
$db = Zend_Db_Table::getDefaultAdapter();
|
||||
@ -190,7 +191,6 @@ foreach ($identifiants as $key=>$siret )
|
||||
$sql->where($where);
|
||||
try {
|
||||
$result = $db->fetchAll($sql);
|
||||
//print_r($result);exit;
|
||||
} catch(Exception $e) {
|
||||
echo $e;
|
||||
}
|
||||
@ -204,24 +204,26 @@ foreach ($result as $tabData) {
|
||||
if (array_key_exists('siege', $tabData)) {
|
||||
($tabData[siege])?$tabData[siege]='Siège':$tabData[siege]='Secondaire';
|
||||
}
|
||||
|
||||
//Trier pour la sortie
|
||||
$tabSortie = array();
|
||||
foreach($tabEntete as $key){
|
||||
//Trier pour la sortie
|
||||
$tabSortie = array();
|
||||
foreach($tabEntete as $key){
|
||||
$tabSortie[] = isset($tabData[$key]) ? $tabData[$key] : '';
|
||||
}
|
||||
fputcsv($fp, $tabSortie, ',', '"');
|
||||
|
||||
//Mise à jour des lignes traitées dans la base
|
||||
if ($opts->id) {
|
||||
$commandesM->update(array('nbLigneTraites'=>$row), "id = ".$commande->id);
|
||||
}
|
||||
|
||||
//Convert
|
||||
$tabSortie = array_map('utf8_decode',array_values($tabSortie));
|
||||
|
||||
fputcsv($fp, $tabSortie, ',', '"');
|
||||
|
||||
//Mise à jour des lignes traitées dans la base
|
||||
if ($opts->id) {
|
||||
$commandesM->update(array('nbLigneTraites'=>$row), "id = ".$commande->id);
|
||||
}
|
||||
|
||||
$row++;
|
||||
}
|
||||
fclose($fp);
|
||||
if ($opts->id) {
|
||||
$commandesM->update( array('dateStop' => date('Y-m-d H:i:s')) , "id = ".$commande->id);
|
||||
if ($opts->id) {
|
||||
$commandesM->update( array('dateStop' => date('Y-m-d H:i:s')) , "id = ".$commande->id);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user