Path file

This commit is contained in:
Michael RICOIS 2013-01-16 14:36:56 +00:00
parent 0383b4d1f8
commit 58495b61df

View File

@ -95,10 +95,10 @@ if ( count($identifiants)==0 || count($dataProfil)==0 ) {
//Let's go
$mois = substr($commande->dateAdded,0,4).substr($commande->dateAdded,5,2);
if(!file_exists($config->path->data.'/'.$mois))
mkdir($config->path->data.'/'.$mois);
$path = $config->profil->path->data.'/'.$mois;
if(!file_exists($path))
mkdir($path);
$path = $config->path->data.'/'.$mois;
$outFile = $profil->login.'_'.$opts->id.'_'.date('YmdHis').'.csv';
require_once 'Scores/Enrichissement.php';
@ -109,6 +109,8 @@ $fields = $dico->getFields();
$tabEntete = array('siren', 'nic');
$tabEnteteLabel = array('SIREN', 'NIC');
$sql = 'SELECT LPAD(siren, 9, 000000000) AS siren, LPAD(nic,5,00000) AS nic,';
$from = 'etablissements_act';
$addWhere = '';
foreach ( $dataProfil as $item ) {
//Définition de l'entete
$tabEnteteLabel[] = $fields[$item]['label'];
@ -120,6 +122,21 @@ foreach ( $dataProfil as $item ) {
} else {
$sql.= ' '.$fields[$item]['column'].' AS '.$item.',';
}
//Pour les champs de type "code", ajouter le libellé
if ( array_key_exists('join', $fields[$item]) ) {
//Automatic column name .Lib
$joinColumn = $item.'Lib';
$tabEntete[] = $joinColumn;
//label
$tabEnteteLabel[] = $fields[$item]['join']['label'];
//Sql
$tableAlias = $item.'T';
$sql.= $tableAlias.'.'.$fields[$item]['join']['column'].' AS '.$joinColumn;
$from.= ','.$fields[$item]['join']['column'].' AS '.$tableAlias;
$addWhere = ' AND WHERE '.$fields[$item]['column'].'='.$tableAlias.'.'.$fields[$item]['join']['column'];
}
}
//Ajouter le champ presentRcs
$tabEntete[] = 'presentRcs';