extranet/includes/export/genexport.php
2011-07-04 07:31:10 +00:00

328 lines
10 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;
$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);
FB::log($tabForExport,'tabForExport');
//@TODO a tester
if (($siret*1)==0 || ($siren*1)<100) {
$fileName = 'etablissements-'.$idEntreprise;
} else {
$fileName = 'etablissements-'.$siret;
}
if(count($tabForExport)>0) {
$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) {
$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)
{
$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){
$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;}
$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)));
}
$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));
$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);
$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);
$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']);
$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;
}
$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;
}
$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;
}
$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;
}
$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']);
}
$array2xml = new ExportXML();
$array2xml->rootName = $page;
$array2xml->defaultTagName = substr($page, 0 , -1);
$array2xml->records = $marques;
$array2xml->writeXML($fileName);
}
break;
}