extranet/www/pages/bilans.php

346 lines
11 KiB
PHP
Raw Normal View History

<?php
2010-05-21 12:47:17 +00:00
define('NB_BILANS', 5);
2010-05-21 12:47:17 +00:00
$actif = array(59 => 'Actif Immobilisé Net',
51 => 'Incorporelles',
52 => 'Corporelles',
53 => 'Financières',
69 => 'Actif Circulant Net',
60 => 'Stock et encours',
61 => 'Créances Clients',
62 => 'Autres Créances',
00 => '',
63 => 'Trésorerie Active',
22 => 'TOTAL ACTIF');
2010-05-21 12:47:17 +00:00
$passif = array(79 => 'Ressources Propres',
70 => 'Fonds Propres',
71 => 'Provisions Risques',
72 => 'Comptes Courants',
90 => 'Ressources Externes',
83 => 'Dettes Financières',
84 => 'Dettes Fournisseurs',
85 => 'Dettes Fiscales',
86 => 'Autres Dettes',
87 => 'Trésorerie Passive',
22 => 'TOTAL PASSIF');
$sig = array(101 => 'CHIFFRE D\'AFFAIRES HORS TAXE',
102 => '-Achat de marchandises, de matières premières',
110 => 'MARGE COMMERCIALE',
111 => '+Production vendue',
112 => '+Production immobilisée et stockée',
120 => 'PRODUCTION DE L\'EXERCICE',
121 =>'Variation de stock de marchandises et matières premières',
122 => 'MARGE BRUTE',
123 => '-Autres charges externes',
130 => 'VALEUR AJOUTÉE',
132 => '-Charges de personnel',
133 => '-Impôts, taxes & versements assimilés',
131 => '+Subventions d\'exploitation',
140 => 'EXCÉDENT BRUT D\'EXPLOITATION (EBE)',
141 => '+Autres produits d\'exploitation',
142 => '-Autres charges d\'exploitation',
143 => '+Reprise sur dotations & transferts de charges',
144 => '+70% Loyer de crédit bail',
145 => '-Dotations d\'exploitation & provisions d\'exploitation',
150 => 'RÉSULTAT D\'EXPLOITATION',
151 => '+Produits financiers',
152 => '+30% Loyer de crédit bail',
153 => '+Charges financières',
170 => 'RÉSULTAT COURANT AVANT IMPOTS',
171 => '+Produits exceptionnels',
172 => '-Charges exceptionnelles',
181 => '-Impôts sur les bénéfices',
182 => '-Participation salariale',
199 => 'RÉSULTAT NET');
// --------------------------------------------------------------------------- //
// afficheDates
// --------------------------------------------------------------------------- //
function afficheDates(&$bilansInfos)
{
for ($i = 1; $i <= NB_BILANS; ++$i) {
print '<th class="date">';
if (isset($bilansInfos[NB_BILANS - $i]['dateCloture'])) {
print substr($bilansInfos[NB_BILANS - $i]['dateCloture'], 6, 2).'/'.
substr($bilansInfos[NB_BILANS - $i]['dateCloture'], 4, 2).'/'.
substr($bilansInfos[NB_BILANS - $i]['dateCloture'], 0, 4);
print '<br>';
print $bilansInfos[NB_BILANS - $i]['duree'];
print 'mois';
} else {
print '-';
}
print '</th>';
}
}
// --------------------------------------------------------------------------- //
// afficheBilan
// --------------------------------------------------------------------------- //
function afficheBilan(&$liste, $total)
{
foreach ($liste as $num => $label) {
if ($num == 00) {
print '<tr><td>&nbsp;</td>'.
'<td></td><td></td><td></td>'.
'<td></td><td></td><td></td></tr>';
continue;
}
if ($num == 101 || $num == 110 || $num == 120 ||
$num == 122 || $num == 130 || $num == 140 ||
$num == 150 || $num == 170 || $num == 199) {
print '<tr class="subhead">';
print '<td class="center" colspan="2">';
} else if ($num > 100) {
print '<tr>';
$c = substr($label, 0, 1);
if ($c == '+' ||
$c == '-') {
print '<td>'.$c.'</td><td>';
$label = substr($label, 1);
} else {
print '<td>&plusmn;</td><td>';
}
} else {
if ($num == 59 || $num == 69 || $num == 79 ||
$num == 90 || $num == 22) {
print '<tr class="subhead">';
} else {
print '<tr>';
}
print '<td>';
}
print $label.'</td>';
for ($i = 1; $i <= NB_BILANS; ++$i) {
print '<td class="right">'.dRatio(NB_BILANS - $i,'r'.$num).'</td>';
}
print '<td class="right">'.dPercent(0,'r'.$num,'r'.$total).'</td>';
print '</tr>';
}
}
// --------------------------------------------------------------------------- //
// ajouteExport
// --------------------------------------------------------------------------- //
function ajouteExport(&$liste)
{
global $bilansInfos;
$export = array();
foreach ($liste as $num => $label) {
if ($num == 00) {
continue;
}
$valeurs = array();
for ($i = 1; $i <= NB_BILANS; ++$i) {
if (isset($bilansInfos[NB_BILANS - $i]['dateCloture']) == false) {
continue;
}
$date = $bilansInfos[NB_BILANS - $i]['dateCloture'];
$duree = $bilansInfos[NB_BILANS - $i]['duree'];
$valeur = dRatio(NB_BILANS - $i,'r'.$num);
$valeurs[] = array('date' => $date,
'duree' => $duree,
'valeur' => $valeur);
}
$c = substr($label, 0, 1);
if ($c == '+' ||
$c == '-') {
$export[] = array('label' => substr($label, 1),
2010-05-21 12:47:17 +00:00
'signe' => $c,
'valeurs' => $valeurs);
} else {
$export[] = array('label' => $label,
'valeurs' => $valeurs);
}
}
return $export;
}
// --------------------------------------------------------------------------- //
// Main
// --------------------------------------------------------------------------- //
if (page_checkParams() == false) {
die('Paramètres incorrects !');
}
if (isset($_REQUEST['type']) == true) {
$typeBilan = $_REQUEST['type'];
} else {
$typeBilan = '';
}
require_once 'cache/cache.php';
require_once 'ratios/ratios.php';
2009-10-08 13:20:51 +00:00
require_once 'scoresws/scoresws.php';
2009-10-23 13:34:42 +00:00
$result = scoresws_ratios($siret, $siren, $idEntreprise);
2010-05-21 12:47:17 +00:00
$bilansInfos = $result['bilansInfos'];
$ratiosInfos = $result['ratiosInfos'];
$ratiosEntrep = $result['ratiosEntrep'];
2009-10-08 13:20:51 +00:00
$ratiosEntrepEvol = $result['ratiosEntrepEvol'];
2010-05-21 12:47:17 +00:00
$ratiosSecteur = $result['ratiosSecteur'];
$dataActif = $result['dataActif'];
$dataPassif = $result['dataPassif'];
$dataSIG = $result['dataSIG'];
2010-05-21 12:47:17 +00:00
if (($siret * 1) == 0 ||
($siren * 1) < 100) {
$fileName = $page.'-'.$idEntreprise;
} else {
$fileName = $page.'-'.$siren;
}
list($typeBilan, $numBilan) = countBilans($bilansInfos, $typeBilan);
$numBilanN = $numBilan['N'];
$numBilanC = $numBilan['C'];
$numBilanB = $numBilan['B'];
$numBilanA = $numBilan['A'];
2010-05-21 12:47:17 +00:00
list($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol, $ratiosSecteur,
$dataActif, $dataPassif, $dataSIG) =
filtreTypeBilans($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol,
$ratiosSecteur, $dataActif, $dataPassif, $dataSIG,
$typeBilan);
?>
2010-05-21 12:47:17 +00:00
<div id="center">
<h1>&Eacute;L&Eacute;MENTS FINANCIERS - BILANS</h1>
<table>
2010-05-21 12:47:17 +00:00
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Num&eacute;ro identifiant Siren</td>
<td width="340" class="StyleInfoData">
<?php
print 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="340" class="StyleInfoData"><?php print $raisonSociale; ?></td>
</tr>
<?php
2010-05-21 12:47:17 +00:00
if ($numBilanN > 0 || $numBilanC > 0) {
print '<tr>';
print '<td width="30">&nbsp;</td>';
print '<td width="200" class="StyleInfoLib">Type de bilans</td>';
print '<td width="340" class="StyleInfoData">';
if ($numBilanN > 0 && $numBilanC > 0) {
print '<input type="radio" name="typeBilan" value="index.php?page='.
$page.'&siret='.$siret.'&idEntreprise='.$idEntreprise.'&type=N"';
if ($typeBilan == 'N') {
print ' checked';
}
print '/><label>Réel normal ou Simplifié</label>';
print '<input type="radio" name="typeBilan" value="index.php?page='.
$page.'&siret='.$siret.'&idEntreprise='.$idEntreprise.'&type=C"';
if ($typeBilan == 'C') {
print ' checked';
}
print '/><label>Consolidé</label>';
} else if ($numBilanN > 0 && $numBilanC == 0) {
print 'Réel normal ou Simplifié';
} else if ($numBilanN == 0 && $numBilanC > 0) {
print 'Consolidé';
}
print '</td>';
print '</tr>';
2009-10-09 14:27:01 +00:00
}
?>
</table>
<?php
2010-05-21 12:47:17 +00:00
if ($numBilanN == 0 && $numBilanC == 0 &&
$numBilanB == 0 && $numBilanA == 0) {
?>
<table>
2010-05-21 12:47:17 +00:00
<tr>
<td width="30">&nbsp;</td>
<td><b>Aucun bilan disponible pour cette entreprise !</b></td>
</tr>
</table>
<?php
2010-05-21 12:47:17 +00:00
} else if ($numBilanN == 0 && $numBilanC == 0 &&
($numBilanB > 0 || $numBilanA > 0)) {
?>
<table>
2010-05-21 12:47:17 +00:00
<tr>
<td width="30">&nbsp;</td>
<td><b>Bilan de banque/assurance non gérés</b></td>
</tr>
</table>
<?php
2010-05-21 12:47:17 +00:00
} else {
?>
2009-08-10 16:54:43 +00:00
<h2>Bilan actif - passif</h2>
<div class="blockh2">
2009-06-22 06:56:42 +00:00
2010-05-21 12:47:17 +00:00
<table class="bilans">
<thead>
<tr>
<th>ACTIF</th>
<?php afficheDates($bilansInfos); ?>
<th>% T.B.</th>
</tr>
</thead>
<tbody>
<?php afficheBilan($actif, 22); ?>
<tr><td colspan="7" class="graph">
<?php print bilans_graph_actif($dataActif[0], $fileName.$typeBilan); ?>
</td></tr>
</tbody>
</table> 
<br/><br/>
2009-06-22 06:56:42 +00:00
<table class="bilans">
2010-05-21 12:47:17 +00:00
<thead>
<tr>
<th>PASSIF</th>
<?php afficheDates($bilansInfos); ?>
<th>% T.B.</th>
</tr>
</thead>
<tbody>
<?php afficheBilan($passif, 22); ?>
<tr><td colspan="7" class="graph">
<?php print bilans_graph_passif($dataPassif[0], $fileName.$typeBilan); ?>
</td></tr>
</tbody>
</table> 
<br/><br/>
2009-06-22 06:56:42 +00:00
2009-12-16 10:15:57 +00:00
<h2>Soldes Interm&eacute;diaire de Gestion</h2>
2009-06-22 06:56:42 +00:00
<table class="bilans">
2010-05-21 12:47:17 +00:00
<thead>
<tr>
<th colspan="2">SOLDES INTERMEDIAIRES DE GESTION</th>
<?php afficheDates($bilansInfos); ?>
<th>% C.A.</th>
</tr>
</thead>
<tbody>
<?php afficheBilan($sig, 101); ?>
<tr><td colspan="8" class="graph">
<?php print bilans_graph_sig($dataSIG[0], $fileName.$typeBilan); ?>
</td></tr>
</tbody>
</table> 
2010-05-21 12:47:17 +00:00
</div>
2009-06-22 06:56:42 +00:00
<?php
}
2010-05-21 12:47:17 +00:00
2011-02-21 17:09:22 +00:00
require_once 'export/genexport.php';
2010-04-12 14:49:55 +00:00
require_once 'cgu/cgu.php';
2010-05-21 12:47:17 +00:00
print '<p class="confidentiel blockh2">'.afficheCgu();
2010-04-12 14:49:55 +00:00
?>
</p>
</div>