extranet/includes/liasse/liasse.php

82 lines
1.9 KiB
PHP

<?php
isset($_REQUEST['q']) ? $q = $_REQUEST['q'] : $q = '';
$params = explode('/', $q);
$action = $params[0];
require_once realpath(dirname(__FILE__)).'/functions.php';
require_once 'cache/cache.php';
$mil = false;
if (($siret*1)==0 || ($siren*1)<100){ $fileName = $page.'-'.$idEntreprise;
}else{ $fileName = $page.'-'.$siret; }
if(isset($_REQUEST['mil']))
{
$mil = explode(',',$_REQUEST['mil']);
$annee = substr($mil[0],-10);
$annee = str_replace('/', '', $annee);
$indice = str_replace('/', '', substr($mil[0], 0, 11));
$fileName.= '-'.$indice;
}
isset($_REQUEST['unit']) ? $unite = $_REQUEST['unit'] : $unite = '';
$typBil = array(
'C'=>'Consolidé',
'N'=>'',
'S'=>'Réel Simplifié',
'B'=> 'Banque',
'A'=>'Assurance'
);
cache_filename($fileName);
if( cache_exist() && !hasModeEdition() )
{
$tabBilans = cache_get('tabBilans');
$tabBilan = cache_get('tabBilan');
}else{
try {
$O = $client->getListeBilans($siren);
$tabBilans = $O['result'];
//Tri du tableau
if(count($tabBilans)>0)
{
foreach($tabBilans as $key => $bilan)
{
$cle[$key] = $key[0].substr($key, -4);
$dateProvPartenaire[$key] = $bilan['dateProvPartenaire'];
$dateInsert[$key] = $bilan['dateInsert'];
$dureeExercice[$key] = $bilan['dureeExercice'];
$dateExercicePre[$key] = $bilan['dateExercicePre'];
$monnaie[$key] = $bilan['monnaie'];
$source[$key] = $bilan['source'];
}
array_multisort($cle, SORT_DESC, $tabBilans);
}
cache_delete();
cache_add('tabBilans', $tabBilans);
if (isset($_REQUEST['mil']))
{
$O = $client->getBilan($siren, substr($mil[0],-10), substr($mil[0],0,1), $mil[1]);
$tabBilan = $O['result'];
cache_add('tabBilan',$tabBilan);
}
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$_SESSION['tabInfo']);
die();
}
}
switch ($action)
{
case 'export':
require_once realpath(dirname(__FILE__)).'/liassexls.php';
exit; break;
default :
break;
}