376 lines
12 KiB
PHP
376 lines
12 KiB
PHP
<?php
|
||
define('NB_BILANS', 5);
|
||
|
||
$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');
|
||
|
||
$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> </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>±</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),
|
||
'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';
|
||
require_once 'scoresws/scoresws.php';
|
||
|
||
$result = scoresws_ratios($siret, $siren, $idEntreprise);
|
||
$bilansInfos = $result['bilansInfos'];
|
||
$ratiosInfos = $result['ratiosInfos'];
|
||
$ratiosEntrep = $result['ratiosEntrep'];
|
||
$ratiosEntrepEvol = $result['ratiosEntrepEvol'];
|
||
$ratiosSecteur = $result['ratiosSecteur'];
|
||
$dataActif = $result['dataActif'];
|
||
$dataPassif = $result['dataPassif'];
|
||
$dataSIG = $result['dataSIG'];
|
||
|
||
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'];
|
||
list($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol, $ratiosSecteur,
|
||
$dataActif, $dataPassif, $dataSIG) =
|
||
filtreTypeBilans($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol,
|
||
$ratiosSecteur, $dataActif, $dataPassif, $dataSIG,
|
||
$typeBilan);
|
||
?>
|
||
|
||
<div id="center">
|
||
<h1>ÉLÉMENTS FINANCIERS - BILANS</h1>
|
||
<table>
|
||
<tr>
|
||
<td width="30"> </td>
|
||
<td width="200" class="StyleInfoLib">Numé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"> </td>
|
||
<td width="200" class="StyleInfoLib">Raison Sociale</td>
|
||
<td width="340" class="StyleInfoData"><?php print $raisonSociale; ?></td>
|
||
</tr>
|
||
<?php
|
||
if ($numBilanN > 0 || $numBilanC > 0) {
|
||
print '<tr>';
|
||
print '<td width="30"> </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>';
|
||
}
|
||
?>
|
||
</table>
|
||
|
||
<?php
|
||
if ($numBilanN == 0 && $numBilanC == 0 &&
|
||
$numBilanB == 0 && $numBilanA == 0) {
|
||
?>
|
||
<table>
|
||
<tr>
|
||
<td width="30"> </td>
|
||
<td><b>Aucun bilan disponible pour cette entreprise !</b></td>
|
||
</tr>
|
||
</table>
|
||
<?php
|
||
} else if ($numBilanN == 0 && $numBilanC == 0 &&
|
||
($numBilanB > 0 || $numBilanA > 0)) {
|
||
?>
|
||
<table>
|
||
<tr>
|
||
<td width="30"> </td>
|
||
<td><b>Bilan de banque/assurance non gérés</b></td>
|
||
</tr>
|
||
</table>
|
||
<?php
|
||
} else {
|
||
?>
|
||
|
||
<h2>Bilan actif - passif</h2>
|
||
<div class="blockh2">
|
||
|
||
<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/>
|
||
|
||
<table class="bilans">
|
||
<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/>
|
||
|
||
<h2>Soldes Intermédiaire de Gestion</h2>
|
||
|
||
<table class="bilans">
|
||
<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>
|
||
|
||
</div>
|
||
<?php
|
||
}
|
||
|
||
// --------------------------------------------------------------------------- //
|
||
// Export
|
||
// --------------------------------------------------------------------------- //
|
||
require_once 'export.php';
|
||
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);
|
||
|
||
require_once 'cgu/cgu.php';
|
||
print '<p class="confidentiel blockh2">'.afficheCgu();
|
||
?>
|
||
</p>
|
||
</div>
|