extranet/www/pages/liasse.php
2010-04-27 08:09:23 +00:00

213 lines
5.3 KiB
PHP

<?php
if (!page_checkParams()) die('Paramètres incorrects !');
$mil = false;
require_once 'partenaires/classMTva.php';
require_once 'partenaires/classMMap.php';
require_once 'common/dates.php';
require_once 'cache/cache.php';
require_once 'liasse/liasse.php';
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() && !( preg_match('/\bsaisie\b/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) )
{
$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();
}
}
?>
<style type="text/css">
.tabLiasse { font-size:1em;}
</style>
<div id="center">
<h1 class="titre">&Eacute;L&Eacute;MENTS FINANCIERS - BILANS</h1>
<form action="./" method="get">
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Num&eacute;ro identifiant Siren</td>
<td width="350" class="StyleInfoData"><?=substr($siren,0,3).' '.substr($siren,3,3).' '.substr($siren,6,3)?></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Raison Sociale</td>
<td width="350" class="StyleInfoData"><?=$raisonSociale?></td>
</tr>
<?php
if (count($tabBilans)>0)
{
$tabUnit = array(
0 => array('lib'=>'€', 'val'=>''),
1 => array('lib'=>'K€', 'val'=>'K'),
2 => array('lib'=>'M€', 'val'=>'M'),
)
?>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Valeurs exprimées en</td>
<td width="350" class="StyleInfoData">
<select name="unit">
<?php
foreach($tabUnit as $unit)
{
$select = '';
if($unite == $unit['val']) $select = ' selected';
?><option value="<?=$unit['val']?>"<?=$select?>><?=$unit['lib']?></option><?php
}
?>
</select>
</td>
</tr>
<?php
}
?>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Millesime</td>
<td width="350" class="StyleInfoData">
<?
if (count($tabBilans)>0)
{
?>
<input type="hidden" name="page" value="liasse"/>
<input type="hidden" name="siret" value="<?=$siren?>"/>
<select name="mil">
<?php
//Tri de l'affichage des bilans en fonction de leurs types
foreach($typBil as $keyType => $type)
{
$numBil=0;
foreach ($tabBilans as $millesime => $bilan)
{
if($numBil>=5){ break; }
if( $millesime[0] == $keyType )
{
echo '<option value="'.$millesime.','.$bilan['ref'].'"';
if ($mil[0]==$millesime) echo ' selected';
$str=' '. $typBil[substr($millesime,0,1)];
echo '>'. substr($millesime,-10) . $str .'</option>';
$numBil++;
}
}
}
?>
</select>&nbsp;
<input type="submit" value="Ok"/>
<?php
} else {
?>
<b>Aucun bilan disponible pour cette entreprise !</b>
<?php
}
?>
</td>
</tr>
</table>
</form>
<div class="blockh2">
<?php
/** Si un bilan est sélectionné dans la liste, on affiche le bilan **/
if(isset($_REQUEST['mil']) == true) {
$mil = $_REQUEST['mil'];
if ($mil[0] == 'A') {
include 'liasse/bilan_assurance.php';
} else if ($mil[0] == 'B') {
include 'liasse/bilan_banque.php';
} else {
include 'liasse/bilan_normal.php';
} // Fin test bilan banque ou assurance et autres
// Export
require_once 'export.php';
if (isset($siret) == true) {
$fileName = $page.'-'.$siret;
} else {
$fileName = $page.'-'.$idEntreprise;
}
$parseTab = new tabExport;
$parseTab->tab = array($tabBilans);
$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 = $tabBilans;
$array2xml->writeXML($fileName);
} // Fin if "pas de bilan choisit"
?>
</div>
<table>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2" width="550" class="StyleInfoData">
<?php
require_once 'surveillance/surveillance.php';
echo getSurveillance('bilans', $siret);
?>
</td>
</tr>
</table>
<p class="confidentiel blockh2">
<?php
require_once 'cgu/cgu.php';
echo afficheCgu();
?>
</p>
</div>