extranet/includes/export/genexport.php
2011-02-25 14:50:45 +00:00

460 lines
14 KiB
PHP

<?php
require_once realpath(dirname(__FILE__)).'/export.php';
function htmldecode($value){
$value = is_array($value) ?
array_map('htmldecode', $value) :
html_entity_decode($value, ENT_QUOTES, 'UTF-8');
return $value;
}
switch ($page)
{
case 'identite':
if (($siret*1)==0 || ($siren*1)<100){
$fileName = 'identite-'.$idEntreprise;
} else {
$fileName = 'identite-'.$siret;
}
$tabTemp = htmldecode($etab);
$tabForExport[0] = $tabTemp;
$array2csv = new ExportCSV();
$array2csv->records = $tabForExport;
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML();
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
$array2xml->records = $tabForExport;
$array2xml->writeXML($fileName);
break;
case 'etablissements':
if (count($etabs>0)) {
$tabForExport = htmldecode($etabs);
//@TODO a tester
if (($siret*1)==0 || ($siren*1)<100) {
$fileName = 'etablissements-'.$idEntreprise;
} else {
$fileName = 'etablissements-'.$siret;
}
if(count($tabForExport)>0) {
$array2csv = new ExportCSV();
$array2csv->records = $tabForExport;
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML();
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
$array2xml->records = $tabForExport;
$array2xml->writeXML($fileName);
}
}
break;
case 'liens':
if (($siret*1)==0 || ($siren*1)<100) {
$fileName = 'liens-'.$idEntreprise;
} else {
$fileName = 'liens-'.$siret;
}
$tabForExport = htmldecode($liens['actionnaires']);
if(count($tabForExport)>0){
require_once 'export.php';
$array2csv = new ExportCSV();
$array2csv->records = $tabForExport;
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML();
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
$array2xml->records = $tabForExport;
$array2xml->writeXML($fileName);
}
break;
case 'evenements':
if (count($evens)>0) {
$tabForExport = htmldecode($evens);
if (($siret*1)==0 && ($siren*1)<100){
$fileName = $page2.'-'.$idEntreprise;
}else{
$fileName = $page2.'-'.$siret;
}
$tabForExport = htmldecode($evens);
if(count($tabForExport)>0)
{
$array2csv = new ExportCSV();
$array2csv->records = $tabForExport;
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML();
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
$array2xml->records = $tabForExport;
$array2xml->writeXML($fileName);
}
}
break;
case 'dirigeants':
if (($siret*1)==0 && ($siren*1)<100) {
$fileName = 'dirigeants-'.$idEntreprise;
} else {
$fileName = 'dirigeants-'.$siret;
}
if ( isset($_REQUEST['vue']) && $_REQUEST['vue']=='histo' ){
$fileName .= '-histo';
}
$tabForExport = htmldecode($dirs);
if(count($tabForExport)>0){
$array2csv = new ExportCSV();
$array2csv->records = $tabForExport;
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML();
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
if ( isset($_REQUEST['vue']) && $_REQUEST['vue']=='histo'){
$array2xml->rootName = 'historique'.$page.'s';
$array2xml->defaultTagName = 'historique'.$page;
}
$array2xml->records = $tabForExport;
$array2xml->writeXML($fileName);
}
break;
case 'annonces':
if ( count($annonces)>0 )
{
if (($siret*1)==0 || ($siren*1)<100){
$fileName = $page.'-'.$idEntreprise;
} else {
$fileName = $page.'-'.$siret;
}
if($vue!=''){$fileName.= '-'.$idan;}
$parseTab = new tabExport();
$parseTab->tab = $annonces;
$parseTab->notdisplay = array('id');
$parseTab->title = array('BodaccCode' => 'Code Bodacc',
'BodaccNum' => 'Numéro Bodacc',
'NumAnnonce' => 'Numéro annonce',
'DateParution' => 'Date de parution',
'TribunalSiret' => 'Siret du tribunal',
'typeAnnonce' => 'Type annonce',
'texteRectificatif' => 'Texte rectificatif',
'texteAnnonce' => 'Texte annonce',
'dateEffet' => 'Date effet',
'dateJugement' => 'Date jugement',
'dateInsertionSD' => 'Date insertion',
'evenements' => 'Evenements');
$parseTab->type = array();
$tabForExport = $parseTab->convertTable();
$array2csv = new ExportCSV();
$array2csv->records = $tabForExport;
$array2csv->writeCSV($fileName);
$tabForExport = $annonces;
$array2xml = new ExportXML();
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
$array2xml->records = $tabForExport;
$array2xml->writeXML($fileName);
}
break;
case 'synthese':
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
$export = array('siren' => $siren,
'raisonSociale' => $raisonSociale,
'type' => $typeBilan);
$tabRatio = syntheseRatio($ratio);
foreach ($tabRatio as $ratio => $info) {
$titre = str_replace(' ', '_', $info['titre']);
$titre = str_replace('\'', '_', $titre);
$export[$titre] =
array(array('date' => $bilansInfos[2]['dateCloture'],
'duree' => $bilansInfos[2]['duree'],
'valeur' => dRatio(2, $ratio)),
array('date' => $bilansInfos[1]['dateCloture'],
'duree' => $bilansInfos[1]['duree'],
'valeur' => dRatio(1, $ratio)),
array('date' => $bilansInfos[0]['dateCloture'],
'duree' => $bilansInfos[0]['duree'],
'valeur' => dRatio(0, $ratio)));
}
$parseTab = new tabExport;
$parseTab->tab = array($export);
$parseTab->type = array();
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page;
$array2xml->defaultTagName = 'elem';
$array2xml->records = $export;
$array2xml->writeXML($fileName);
break;
case 'bilans':
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
$export = array('siren' => $siren,
'raisonSociale' => $raisonSociale,
'type' => $typeBilan,
'actif' => ajouteExport($actif),
'passif' => ajouteExport($passif),
'sig' => ajouteExport($sig));
$parseTab = new tabExport;
$parseTab->tab = array($export);
$parseTab->type = array();
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page;
$array2xml->defaultTagName = 'elem';
$array2xml->records = $export;
$array2xml->writeXML($fileName);
break;
case 'ratios':
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
$export = ratiosExport($siren, $raisonSociale,
$_SESSION['tabInfo']['entrep']['nafEn'],
$typeBilan,
$bilansInfos[$bilan]['dateCloture'],
$bilansInfos[$bilan]['duree'],
$ratiosInfos, $bilan, $result['nbEntNaf'], $ratio);
$parseTab = new tabExport;
$parseTab->tab = array($export);
$parseTab->type = array();
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page;
$array2xml->defaultTagName = 'elem';
$array2xml->records = $export;
$array2xml->writeXML($fileName);
break;
case 'liasse':
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
$liasse['Liasse']['raisonSociale'] = $raisonSociale;
$liasse['Liasse']['type'] = $mil[0];
$liasse['Liasse']['date'] = $annee;
liasse2xml($tabLiasseN, $liasse, $tableTexteBilan);
$parseTab = new tabExport;
$parseTab->tab = array($liasse['Liasse']);
$parseTab->type = array();
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page;
$array2xml->defaultTagName = 'elem';
$array2xml->records = $liasse['Liasse'];
$array2xml->writeXML($fileName);
break;
case 'indiscore':
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
$export = array('siren' => $etab['Siren'],
'siretSiege' => $etab['Siret'],
'raisonSociale' => $etab['Nom'],
'analyseConformite' => $etab['AnalyseConfor'],
'scoreConformite' => $etab['ScoreConfor'],
'analyseDirigeance' => $etab['AnalyseDirigeance'],
'scoreDirigeance' => $etab['ScoreDirigeance'],
'analyseSolvabilite' => $etab['AnalyseSolvabilite'],
'scoreSolvabilite' => $etab['ScoreSolvabilite'],
'situationFinanciere' =>
$etab['tabInfosNotations']['SituationFinanciere'],
'probabiliteDefaut' =>
$etab['tabInfosNotations']['ProbabiliteDefaut'],
'conanHolder' => $etab['scores']['ConanH'],
'afdcc2' => $etab['scores']['Afdcc2'],
'scoreZ' => $etab['scores']['Z'],
'paiement' => $etab['infoPaiement'],
'classeRisque' => $etab['classeRisque'],
'indiscore' => $indiscore,
'indiscoreMax' => $maxIndiscore,
'tendance' => $etab['TendanceIndiscore'],
'encoursMaxConseille' => $etab['encours']);
$parseTab = new tabExport;
$parseTab->tab = array($export);
$parseTab->type = array();
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page;
$array2xml->records = $export;
$array2xml->writeXML($fileName);
break;
case 'bourse':
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
$parseTab = new tabExport;
$parseTab->tab = array($etab);
$parseTab->type = array();
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
$array2xml->records = $etab;
$array2xml->writeXML($fileName);
break;
case 'banque':
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
$parseTab = new tabExport;
$parseTab->tab = array($rbanque);
$parseTab->type = array();
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page.'s';
$array2xml->defaultTagName = $page;
$array2xml->records = $rbanque;
$array2xml->writeXML($fileName);
break;
case 'scorescf':
//
break;
case 'competences':
if (empty($competences) == false) {
if (isset($siret) == true) {
$fileName = $page.'-'.$siret.'-'.$type;
} else {
$fileName = $page.'-'.$idEntreprise.'-'.$type;
}
$parseTab = new tabExport;
$parseTab->tab = array($competences);
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page.$type;
$array2xml->defaultTagName = substr($page, 0 , -1).$type;
$array2xml->records = $competences;
$array2xml->writeXML($fileName);
}
break;
case 'conventions':
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
$parseTab = new tabExport;
$parseTab->tab = array($conventions);
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page;
$array2xml->defaultTagName = substr($page, 0 , -1);
$array2xml->records = $conventions;
$array2xml->writeXML($fileName);
break;
case 'marques':
if ($id == 0 && count($marques)>0) {
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
for ($i = 0; $i < count($marques); ++$i) {
unset($marques[$i]['IdLien']);
}
$parseTab = new tabExport;
$parseTab->tab = $marques;
$array2csv = new ExportCSV;
$array2csv->records = $parseTab->convertTable();
$array2csv->writeCSV($fileName);
$array2xml = new ExportXML;
$array2xml->rootName = $page;
$array2xml->defaultTagName = substr($page, 0 , -1);
$array2xml->records = $marques;
$array2xml->writeXML($fileName);
}
break;
}