extranet/application/controllers/FinanceController.php

820 lines
33 KiB
PHP
Raw Normal View History

2011-02-21 08:45:13 +00:00
<?php
class FinanceController extends Zend_Controller_Action
2011-04-11 14:19:14 +00:00
{
2011-06-08 15:41:59 +00:00
protected $siret = null;
protected $id = 0;
2011-04-19 15:59:50 +00:00
public function init()
{
require_once 'common/dates.php';
require_once 'Scores/SessionEntreprise.php';
require_once 'Scores/Utilisateur.php';
require_once 'Scores/WsScores.php';
require_once 'Finance/Liasse.php';
require_once 'Finance/RatiosData.php';
require_once 'Finance/RatiosGraph.php';
$request = $this->getRequest();
$this->siret = $request->getParam('siret');
$this->id = $request->getParam('id', 0);
$this->view->headLink()->appendStylesheet('/themes/default/styles/finance.css', 'all');
$this->view->headScript()->appendFile('/themes/default/scripts/finance.js', 'text/javascript');
2011-04-19 15:59:50 +00:00
}
2011-06-13 07:04:46 +00:00
/**
* Affichage de la synthese
*/
2011-04-19 15:59:50 +00:00
public function syntheseAction()
2011-05-04 14:18:22 +00:00
{
$user = new Utilisateur();
$session = new SessionEntreprise($this->siret);
2011-07-04 08:31:42 +00:00
$request = $this->getRequest();
$typeBilan = $request->getParam('typeBilan', 'N');
$ratio = $request->getParam('ratio', '');
$autrePage = $request->getParam('apage');
//Récupération des informations
if (empty($autrePage)) {
$ws = new WsScores();
$infos = $ws->getRatios(substr($this->siret, 0, 9), 'synthese');
} else {
$infos = $request->getParam('infos');
}
$tabRatio = array(
2011-07-05 15:57:26 +00:00
'r5' => array('evol'=>'r6', 'op' => 1000, 'titre'=>'CHIFFRE D\'AFFAIRES'),
'r7' => array('evol'=>'r8', 'op' => 1000, 'titre'=>'RESULTAT COURANT AVANT IMPOTS'),
'r10' => array('evol'=>'r11', 'op' => 1000, 'titre'=>'RESULTAT NET'),
'r18' => array('evol'=>'r19', 'op' => 1000, 'titre'=>'FONDS PROPRES'),
'r22' => array('evol'=>'r23', 'op' => 1000, 'titre'=>'TOTAL BILAN'),
'r231' => array('evol'=>'r235', 'op' => 1000, 'titre'=>'FONDS DE ROULEMENT'),
'r232' => array('evol'=>'r236', 'op' => 1000, 'titre'=>'BESOIN EN FONDS DE ROULEMENT'),
'r249' => array('evol'=>'r254', 'op' => 1000, 'titre'=>'TRESORERIE'),
'r24' => array('evol'=>'r24', 'op' => 1, 'titre'=>'EFFECTIF', 'unite' => 1),
);
$tabRatioGraph = array(
0 => array('ratio'=>'r236', 'op' => 1000),
1 => array('ratio'=>'r235', 'op' => 1000),
2 => array('ratio'=>'r6', 'op' => 1000),
3 => array('ratio'=>'r146', 'op' => 1000)
);
if($ratio!=''){
$tabRatio = array( $ratio => $tabRatio[$ratio] );
}
//Formattage des données
2011-07-06 06:49:05 +00:00
$ratiosData = new RatiosData($infos);
2011-07-06 06:49:05 +00:00
$nbBilanN = $ratiosData->getNbBilan('N');
$nbBilanC = $ratiosData->getNbBilan('C');
2011-07-06 06:49:05 +00:00
if ($typeBilan == 'N' && $nbBilanN==0){
$typeBilan = 'C';
}
2011-07-06 06:49:05 +00:00
if ($nbBilanN!=0 || $nbBilanC!=0)
{
foreach($tabRatio as $idRatio => $valRatio){
$tabRatio[$idRatio]['comment'] = $ratiosData->wrapComment($idRatio);
}
$this->view->assign('tabRatio', $tabRatio);
2011-07-06 15:31:24 +00:00
$infosAnnee = $ratiosData->getBilansInfo($typeBilan);
2011-07-06 06:49:05 +00:00
$annees = array_keys($infosAnnee);
//Générer les différents graphiques d'évolutions
$ratiosGraph = new RatiosGraph($this->siret, $this->id);
$tabGraphEvol = array();
foreach($tabRatio as $idRatio => $infoRatio){
$dataGraphEvol = array();
foreach($annees as $annee){
$dataGraphEvol[] = array(
'date' => $annee,
'value' => ($ratiosData->getRatiosEntrep($typeBilan, $annee, $idRatio)!='NS') ?
$ratiosData->getRatiosEntrep($typeBilan, $annee, $idRatio)/$infoRatio['op'] : 0
);
}
$tabGraphEvol[$idRatio] = $ratiosGraph->syntheseGraphEvol($dataGraphEvol, $idRatio, $unite);
}
//Générer le graphique de comparaison
$dataGraph = array();
$i=0;
foreach($annees as $annee){
2011-07-06 06:49:05 +00:00
$dataGraph[$i]['date'] = $infosAnnee[$annee]->dateCloture;
$dataGraph[$i]['duree'] = $infosAnnee[$annee]->duree;
foreach($tabRatioGraph as $item){
$dataGraph[$i][$item['ratio']] = $ratiosData->getRatiosEntrep($typeBilan, $annee, $item['ratio'])/$item['op'];
}
$i++;
}
2011-07-06 06:49:05 +00:00
$graphLineCompare = $ratiosGraph->syntheseGraphLineCompare($dataGraph, $typeBilan);
//On prend les 3 derniers bilans pour l'affichage
$nbMaxBilan = 3;
rsort($annees);
$annees = array_slice($annees, 0, $nbMaxBilan);
sort($annees);
$tabResult = array();
foreach($annees as $annee){
$data = array();
$dataEvol = array();
//Formatter les données
foreach($tabRatio as $idRatio => $valRatio){
$data[$idRatio] = $ratiosData->dRatio($typeBilan, $annee, $idRatio);
$dataEvol[$idRatio] = $ratiosData->dEvol($typeBilan, $annee, $valRatio['evol']);
}
$tabResult[] = array(
'dateCloture' => WDate::dateT('Ymd','d/m/Y',$annee),
'duree' => $infosAnnee[$annee]->duree.' Mois',
'entrep' => $data,
'entrepEvol' => $dataEvol,
);
}
2011-07-06 06:49:05 +00:00
$this->view->assign('tabResult', $tabResult);
}
2011-07-06 06:49:05 +00:00
$this->view->assign('nbBilanN', $nbBilanN);
$this->view->assign('nbBilanC', $nbBilanC);
$this->view->assign('typeBilan', $typeBilan);
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$this->view->assign('id', $this->id);
$this->view->assign('siret', $this->siret);
$this->view->assign('siren', substr($this->siret, 0, 9));
$this->view->assign('AutrePage', $autrePage);
}
public function synthesegraphevolAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$ratio = $request->getParam('ratio');
$path = APPLICATION_PATH . '/../cache/pages/imgcache/';
$file = 'syntheseEvol-'.$this->siret.'-'.$this->id.'-'.$ratio.'.png';
if (file_exists($path.$file)) {
echo '<img src="/fichier/imgcache/'.$file.'" />';
} else {
echo "Erreur de génération du graphique";
}
}
2011-04-11 14:19:14 +00:00
public function synthesegraphcompareAction()
2011-05-27 16:07:48 +00:00
{
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$typeBilan = $request->getParam('typeBilan');
$path = APPLICATION_PATH . '/../cache/pages/imgcache/';
$file = 'synthese-linecompare-'.$this->siret.'-'.$this->id.'-'.$typeBilan.'.png';
if (file_exists($path.$file)) {
echo '<img src="/fichier/imgcache/'.$file.'" />';
} else {
echo "Erreur de génération du graphique";
}
2011-05-27 16:07:48 +00:00
}
2011-05-06 15:26:56 +00:00
/**
* Fonction qui affiche les bilan (actif, passif, SIG).
* Le principe est d'utiliser le mapping de données.
2011-07-04 10:13:45 +00:00
* @todo : RatiosData, RatiosGraph
2011-05-06 15:26:56 +00:00
*/
public function bilanAction()
2011-04-19 15:59:50 +00:00
{
$user = new Utilisateur();
$request = $this->getRequest();
$autrePage = $request->getParam('apage');
$typeBilan = $request->getParam('typeBilan', 'N');
$entreprise = new SessionEntreprise($this->siret, $this->id);
//Récupération des informations
if (empty($autrePage)) {
$ws = new WsScores();
$infos = $ws->getRatios(substr($this->siret, 0, 9), 'ratios');
} else {
$infos = $this->getRequest()->getParam('infos');
}
2011-06-13 07:04:46 +00:00
2011-07-06 06:49:05 +00:00
$ratiosData = new RatiosData($infos);
2011-06-13 07:04:46 +00:00
2011-07-06 06:49:05 +00:00
$nbBilanN = $ratiosData->getNbBilan('N');
$nbBilanC = $ratiosData->getNbBilan('C');
if ($typeBilan == 'N' && $nbBilanN==0){
$typeBilan = 'C';
}
if ($nbBilanN!=0 || $nbBilanC!=0)
{
2011-07-06 15:31:24 +00:00
$infosAnnee = $ratiosData->getBilansInfo($typeBilan);
2011-07-06 06:49:05 +00:00
$annees = array_keys($infosAnnee);
$ratiosGraph = new RatiosGraph($this->siret, $this->id);
$tabRatioActif = array(
'r59' => array( 'titre' => 'Actif Immobilisé Net', 'class' => 'subhead'),
'r51' => array( 'titre' => 'Incorporelles', 'class' => ''),
'r52' => array( 'titre' => 'Corporelles', 'class' => '' ),
'r53' => array( 'titre' => 'Financières', 'class' => '' ),
'r69' => array( 'titre' => 'Actif Circulant Net', 'class' => 'subhead' ),
'r60' => array( 'titre' => 'Stock et encours', 'class' => '' ),
'r61' => array( 'titre' => 'Créances Clients', 'class' => '' ),
'r62' => array( 'titre' => 'Autres Créances', 'class' => '' ),
'00' => array( 'titre' => '', 'class' => '' ),
'r63' => array( 'titre' => 'Trésorerie Active', 'class' => '' ),
'r22' => array( 'titre' => 'TOTAL ACTIF', 'class' => 'subhead' ),
);
2011-07-06 06:49:05 +00:00
$totalRatioActif = 'r22';
$tabRatioPassif = array(
'r79' => array( 'titre' => 'Ressources Propres', 'class' => 'subhead'),
'r70' => array( 'titre' => 'Fonds Propres', 'class' => ''),
'r71' => array( 'titre' => 'Provisions Risques', 'class' => ''),
'r72' => array( 'titre' => 'Comptes Courants', 'class' => ''),
'r90' => array( 'titre' => 'Ressources Externes', 'class' => 'subhead'),
'r83' => array( 'titre' => 'Dettes Financières', 'class' => ''),
'r84' => array( 'titre' => 'Dettes Fournisseurs', 'class' => ''),
'r85' => array( 'titre' => 'Dettes Fiscales', 'class' => ''),
'r86' => array( 'titre' => 'Autres Dettes', 'class' => ''),
'r87' => array( 'titre' => 'Trésorerie Passive', 'class' => ''),
'r22' => array( 'titre' => 'TOTAL PASSIF', 'class' => 'subhead'),
);
$totalRatioPassif = 'r22';
$tabRatioSig = array(
'r101' => array( 'titre' => 'CHIFFRE D\'AFFAIRES HORS TAXE', 'op' => '', 'class' => 'subhead'),
'r102' => array( 'titre' => 'Achat de marchandises, de matières premières', 'op' => '-', 'class' => ''),
'r110' => array( 'titre' => 'MARGE COMMERCIALE', 'op' => '', 'class' => 'subhead'),
'r111' => array( 'titre' => 'Production vendue', 'op' => '+', 'class' => ''),
'r112' => array( 'titre' => 'Production immobilisée et stockée', 'op' => '+', 'class' => ''),
'r120' => array( 'titre' => 'PRODUCTION DE L\'EXERCICE', 'op' => '', 'class' => 'subhead'),
'r121' => array( 'titre' => 'Variation de stock de marchandises et matières premières', 'op' => '±', 'class' => ''),
'r122' => array( 'titre' => 'MARGE BRUTE', 'op' => '', 'class' => 'subhead'),
'r123' => array( 'titre' => 'Autres charges externes', 'op' => '-', 'class' => ''),
'r130' => array( 'titre' => 'VALEUR AJOUTÉE', 'op' => '', 'class' => 'subhead'),
'r132' => array( 'titre' => 'Charges de personnel', 'op' => '-', 'class' => ''),
'r133' => array( 'titre' => 'Impôts, taxes & versements assimilés', 'op' => '-', 'class' => ''),
'r131' => array( 'titre' => 'Subventions d\'exploitation', 'op' => '+', 'class' => ''),
'r140' => array( 'titre' => 'EXCÉDENT BRUT D\'EXPLOITATION (EBE)', 'op' => '', 'class' => 'subhead'),
'r141' => array( 'titre' => 'Autres produits d\'exploitation', 'op' => '+', 'class' => ''),
'r142' => array( 'titre' => 'Autres charges d\'exploitation', 'op' => '-', 'class' => ''),
'r143' => array( 'titre' => 'Reprise sur dotations & transferts de charges', 'op' => '+', 'class' => ''),
'r144' => array( 'titre' => '70% Loyer de crédit bail', 'op' => '+', 'class' => ''),
'r145' => array( 'titre' => 'Dotations d\'exploitation & provisions d\'exploitation', 'op' => '-', 'class' => ''),
'r150' => array( 'titre' => 'RÉSULTAT D\'EXPLOITATION', 'op' => '', 'class' => 'subhead'),
'r151' => array( 'titre' => 'Produits financiers', 'op' => '+', 'class' => ''),
'r152' => array( 'titre' => '30% Loyer de crédit bail', 'op' => '+', 'class' => ''),
'r153' => array( 'titre' => 'Charges financières', 'op' => '+', 'class' => ''),
'r170' => array( 'titre' => 'RÉSULTAT COURANT AVANT IMPOTS', 'op' => '', 'class' => 'subhead'),
'r171' => array( 'titre' => 'Produits exceptionnels', 'op' => '+', 'class' => ''),
'r172' => array( 'titre' => 'Charges exceptionnelles', 'op' => '-', 'class' => ''),
'r181' => array( 'titre' => 'Impôts sur les bénéfices', 'op' => '-', 'class' => ''),
'r182' => array( 'titre' => 'Participation salariale', 'op' => '-', 'class' => ''),
'r199' => array( 'titre' => 'RÉSULTAT NET', 'op' => '', 'class' => 'subhead'),
);
$totalRatioSig = 'r101';
//On prend les 5 derniers bilans pour l'affichage
$nbMaxBilan = 5;
rsort($annees);
$annees = array_slice($annees, 0, $nbMaxBilan);
sort($annees);
$tabResultActif = array();
$tabResultPassif = array();
$tabResultSig = array();
foreach($annees as $annee){
//Formatter les données Actif
$data = array();
foreach($tabRatioActif as $idRatio => $valRatio){
if ($idRatio == '00'){
$data[$idRatio] = '';
$dataTotal[$idRatio] = '';
} else {
$data[$idRatio] = $ratiosData->dRatio($typeBilan, $annee, $idRatio);
$dataTotal[$idRatio] = $ratiosData->dPercent($typeBilan, $annee, $idRatio, $totalRatioActif);
}
}
//Génération du graphique Actif
$dataGraphActif = array(
$ratiosData->graphPercent($typeBilan, $annee, 'r51', 'r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r52', 'r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r53', 'r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r60', 'r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r61', 'r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r62', 'r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r63', 'r22'),
);
$ratiosGraph->bilansgraphactif($dataGraphActif, $typeBilan, $annee);
$tabResultActif[] = array(
'dateCloture' => WDate::dateT('Ymd','d/m/Y',$annee),
'duree' => $infosAnnee[$annee]->duree.' Mois',
'entrep' => $data,
'total' => $dataTotal,
);
//Formatter les données Passif
$data = array();
foreach($tabRatioPassif as $idRatio => $valRatio){
$data[$idRatio] = $ratiosData->dRatio($typeBilan, $annee, $idRatio);
$dataTotal[$idRatio] = $ratiosData->dPercent($typeBilan, $annee, $idRatio, $totalRatioPassif);
}
//Génération données graphique passif
$dataGraphPassif = array(
$ratiosData->graphPercent($typeBilan, $annee, 'r70','r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r71','r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r72','r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r83','r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r84','r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r85','r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r86','r22'),
$ratiosData->graphPercent($typeBilan, $annee, 'r87','r22'),
);
$ratiosGraph->bilansgraphpassif($dataGraphPassif, $typeBilan, $annee);
$tabResultPassif[] = array(
'dateCloture' => WDate::dateT('Ymd','d/m/Y',$annee),
'duree' => $infosAnnee[$annee]->duree.' Mois',
'entrep' => $data,
'total' => $dataTotal,
);
//Formatter les données Sig
$data = array();
foreach($tabRatioSig as $idRatio => $valRatio){
$data[$idRatio] = $ratiosData->dRatio($typeBilan, $annee, $idRatio);
$dataTotal[$idRatio] = $ratiosData->dPercent($typeBilan, $annee, $idRatio, $totalRatioSig);
}
//Génération données graphique SIG
$dataGraphSIG = array(
$ratiosData->graphPercent($typeBilan, $annee, 'r101','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r122','r101'),
$ratiosData->graphPercent($typeBilan, $annee, 'r122','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r130','r101'),
$ratiosData->graphPercent($typeBilan, $annee, 'r130','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r140','r101'),
$ratiosData->graphPercent($typeBilan, $annee, 'r140','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r150','r101'),
$ratiosData->graphPercent($typeBilan, $annee, 'r150','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r170','r101'),
$ratiosData->graphPercent($typeBilan, $annee, 'r170','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r199','r101'),
$ratiosData->graphPercent($typeBilan, $annee, 'r199','r101'),
);
$ratiosGraph->bilansgraphsig($dataGraphSIG, $typeBilan, $annee);
$tabResultSig[] = array(
'dateCloture' => WDate::dateT('Ymd','d/m/Y',$annee),
'duree' => $infosAnnee[$annee]->duree.' Mois',
'entrep' => $data,
'total' => $dataTotal,
);
}
$this->view->assign('lastDateCloture', $annee);
$this->view->assign('tabRatioActif', $tabRatioActif);
$this->view->assign('tabRatioPassif', $tabRatioPassif);
$this->view->assign('tabRatioSig', $tabRatioSig);
$this->view->assign('tabResultActif', $tabResultActif);
$this->view->assign('tabResultPassif', $tabResultPassif);
$this->view->assign('tabResultSig', $tabResultSig);
2011-07-06 06:49:05 +00:00
}
2011-07-06 06:49:05 +00:00
$this->view->assign('nbBilanN', $nbBilanN);
$this->view->assign('nbBilanC', $nbBilanC);
$this->view->assign('typeBilan', $typeBilan);
$this->view->assign('id', $this->id);
$this->view->assign('siret', $this->siret);
$this->view->assign('siren', substr($this->siret, 0, 9));
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
$this->view->assign('AutrePage', $request->getParam('apage'));
}
/**
* Affichage des graphique bilan Actif/Passif/SIG
*/
public function bilangraphAction()
{
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$type = $request->getParam('type', '');
$typeBilan = $request->getParam('typeBilan');
$dateCloture = $request->getParam('dateCloture');
Zend_Registry::get('firebug')->info($request->getParams());
$path = APPLICATION_PATH . '/../cache/pages/imgcache/';
switch($type){
case 'actif':
$file = 'bilansgraphactif-'.$this->siret.'-'.$this->id.'-'.$typeBilan.$dateCloture.'.png';
break;
case 'passif':
$file = 'bilansgraphpassif-'.$this->siret.'-'.$this->id.'-'.$typeBilan.$dateCloture.'.png';
break;
case 'sig':
$file = 'bilansgraphsig-'.$this->siret.'-'.$this->id.'-'.$typeBilan.$dateCloture.'.png';
break;
}
if (file_exists($path.$file)) {
echo '<img src="/fichier/imgcache/'.$file.'" />';
} else {
echo "Erreur de génération du graphique";
}
}
/**
* Gestion de l'affichage des ratios.
*/
public function ratiosAction()
{
$user = new Utilisateur();
$request = $this->getRequest();
$autrePage = $request->getParam('apage');
//Récupération des informations
if (empty($autrePage)) {
$ws = new WsScores();
$infos = $ws->getRatios(substr($this->siret, 0, 9), 'ratios');
} else {
$infos = $this->getRequest()->getParam('infos');
2011-06-29 12:44:20 +00:00
}
$typeBilan = $request->getParam('typeBilan', 'N');
$entreprise = new SessionEntreprise($this->siret, $this->id);
$tabRatio = array(
array('titre' => 'EQUILIBRE FINANCIER'),
array('titre' => 'MARGE BRUTE D\'AUTOFINANCEMENT',
'stitre'=> '(MBA ou CAF)',
'ratio' => 'r233', 'parent' => 0, 'position' => '>'),
array('titre' => 'COUVERTURE du BFR',
'stitre'=> '(FR/BFR)',
'ratio' => 'r234', 'parent' => 0, 'position' => '>'),
array('titre' => 'COUVERTURE des IMMOS NETTES',
'stitre'=> '(Capitaux permanents / Immobilisations nettes)',
'ratio' => 'r237', 'parent' => 0, 'position' => '>'),
array('titre' => 'COUVERTURE du CA',
'stitre'=> '(Fond de roulement net global sur 12m x 360'.
' / Chiffre d\'affaire)',
'ratio' => 'r238', 'parent' => 0, 'position' => '>'),
array('titre' => 'SOLVABILITE',
'stitre'=> '(Capitaux propres / Ensemble des dettes)',
'ratio' => 'r239', 'parent' => 0, 'position' => '>'),
array('titre' => 'INDEPENDANCE FINANCIERE',
'stitre'=> '(Cap.propres/Capitaux permanents)',
'ratio' => 'r240', 'parent' => 0, 'position' => '>'),
array('titre' => 'PROFITABILITE'),
array('titre' => 'RENTABILITE ECONOMIQUE',
'stitre'=> '(EBE/TOTAL bilan)',
'ratio' => 'r262', 'parent' => 7, 'position' => '>'),
array('titre' => 'RENTABILITE FINANCIERE',
'stitre'=> '(Résult.Net/Cap.propres)',
'ratio' => 'r263', 'parent' => 7, 'position' => '>'),
array('titre' => 'RENTABILITE COMMERCIALE',
'stitre'=> '(Résultat net/CA)',
'ratio' => 'r264', 'parent' => 7, 'position' => '>'),
array('titre' => 'CONTRIBUTION DU CAPITAL',
'stitre'=> '(Capacité d\'autofinancement sur 12 mois'.
' / Capitaux permanents)',
'ratio' => 'r265', 'parent' => 7, 'position' => '>'),
array('titre' => 'CONTRIBUTION DE LA VA',
'stitre'=>'(Capacité d\'autofinancement / Valeur ajoutée)',
'ratio' => 'r266', 'parent' => 7, 'position' => '>'),
array('titre' => 'LIQUIDITE'),
array('titre' => 'LIQUIDITE IMMEDIATE',
'stitre'=> '(Disponibilité / Dettes CT)',
'ratio' => 'r250', 'parent' => 13, 'position' => '>'),
array('titre' => 'LIQUIDITE GENERALE',
'stitre'=> '(Act.circulant net/Dettes CT)',
'ratio' => 'r251', 'parent' => 13, 'position' => '>'),
array('titre' => 'LIQUIDITE REDUITE',
'stitre'=>'(Disponibilité et créances réelles / Dettes CT)',
'ratio' => 'r252', 'parent' => 13, 'position' => '>'),
array('titre' => 'ENDETTEMENT'),
array('titre' => 'ENDETTEMENT',
'stitre'=> '(Dettes a + 1 an / Capitaux propres)',
'ratio' => 'r244', 'parent' => 17, 'position' => '<'),
array('titre' => 'CAPACITE DE REMBOURSEMENT',
'stitre'=> '(Dettes.bancaires.(+MT+LT+C.bail)/CAF)',
'ratio' => 'r247', 'parent' => 17, 'position' => '<'),
array('titre' => 'FINANCEMENT DES STOCKS',
'stitre'=> '(Dettes aux fournisseurs / Stock)',
'ratio' => 'r248', 'parent' => 17, 'position' => '<'),
array('titre' => 'PRODUCTIVITE'),
array('titre' => 'PRODUCTIVITE DE L\'ACTIF',
'stitre'=> '(Chiffre d\'affaire / Actif comptable)',
'ratio' => 'r271', 'parent' => 21, 'position' => '>'),
array('titre' => 'DUREE CLIENT',
'stitre'=> '(Rotation clients en VJ TTC)',
'ratio' => 'r278', 'parent' => 21, 'position' => '<'),
array('titre' => 'DUREE FOURNISSEUR',
'stitre'=> '(Rotation fournisseurs en JA TTC)',
'ratio' => 'r279', 'parent' => 21, 'position' => '<'),
array('titre' => 'POIDS MASSE SALARIALE',
'stitre'=> '(Ch personnel / VA)',
'ratio' => 'r281', 'parent' => 21, 'position' => '<'),
array('titre' => 'RENDEMENT',
'stitre'=> '(Production sur 12mois / Effectif)',
'ratio' => 'r261', 'parent' => 21, 'position' => '>'),
array('titre' => 'PRODUCTIVITE',
'stitre'=> '(CA / Effectif)',
'ratio' => 'r267', 'parent' => 21, 'position' => '>')
);
if($ratio!=''){
$tabRatio = array( $ratio => $tabRatio[$ratio] );
}
2011-07-11 13:26:18 +00:00
$ratiosData = new RatiosData($infos);
2011-07-06 06:49:05 +00:00
$nbBilanN = $ratiosData->getNbBilan('N');
$nbBilanC = $ratiosData->getNbBilan('C');
2011-07-06 06:49:05 +00:00
if ($typeBilan == 'N' && $nbBilanN==0){
$typeBilan = 'C';
}
2011-07-05 15:57:26 +00:00
2011-07-06 06:49:05 +00:00
if ($nbBilanN!=0 || $nbBilanC!=0)
{
//Génération Graphique evolution
$ratiosGraph = new RatiosGraph($this->siret, $this->id);
2011-07-06 15:31:24 +00:00
$infosAnnee = $ratiosData->getBilansInfo($typeBilan);
2011-07-06 06:49:05 +00:00
$annees = array_keys($infosAnnee);
rsort($annees);
2011-07-06 15:31:24 +00:00
$mil = $request->getParam('mil', $annees[0]);
$tabAnnees = array();
foreach($annees as $annee){
$tabAnnees[$annee] = WDate::dateT('Ymd', 'd/m/Y', $annee);
}
2011-07-06 06:49:05 +00:00
$tabResult = array();
2011-07-11 13:26:18 +00:00
foreach($tabRatio as $item ) {
if (isset($item['ratio'])){
$dataGraph = $ratiosData->dGraph($typeBilan, $item['ratio']);
$ratiosGraph->ratiosgraph($item['ratio'], $dataGraph);
2011-07-06 15:31:24 +00:00
$item['entrep'] = $ratiosData->dRatio($typeBilan, $mil, $item['ratio']);
$item['secteur'] = $ratiosData->dSecteur($mil, $item['ratio']);
$item['position'] = $ratiosData->dPosition($typeBilan, $mil, $item['ratio'], $item['position']);
2011-07-06 06:49:05 +00:00
$item['comment'] = $ratiosData->wrapComment($item['ratio']);
}
$tabResult[] = $item;
}
$this->view->assign('tabResult', $tabResult);
2011-07-06 15:31:24 +00:00
2011-07-06 06:49:05 +00:00
$this->view->assign('annees', $tabAnnees);
$this->view->assign('mil', $mil);
2011-07-06 15:31:24 +00:00
$this->view->assign('typeBilan', $typeBilan);
2011-07-06 15:36:03 +00:00
$this->view->assign('duree', $infosAnnee[$mil]->duree);
}
2011-07-06 06:49:05 +00:00
$this->view->assign('nbBilanN', $nbBilanN);
$this->view->assign('nbBilanC', $nbBilanC);
2011-07-05 15:57:26 +00:00
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
$this->view->assign('siret', $this->siret);
$this->view->assign('id', $this->id);
2011-07-06 15:31:24 +00:00
$this->view->assign('naf', $infos->NafEnt);
$this->view->assign('nafLib', $infos->NafEntLib);
$this->view->assign('AutrePage', $request->getParam('apage'));
}
public function ratiosgraphAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$ratio = $request->getParam('ratio');
$path = APPLICATION_PATH . '/../cache/pages/imgcache/';
$file = 'ratiosgraph-'.$this->siret.'-'.$this->id.'-'.$ratio.'.png';
if (file_exists($path.$file)) {
echo '<img src="/fichier/imgcache/'.$file.'" />';
} else {
echo "Erreur de génération du graphique";
}
}
2011-05-18 12:22:08 +00:00
/**
* Export d'une liasse au format XLS
*/
2011-05-18 13:04:29 +00:00
public function liassexlsAction()
{
2011-05-23 09:51:37 +00:00
//@todo : Gestion des unités dans l'export XLS
2011-05-18 13:35:56 +00:00
$this->_helper->layout()->disableLayout();
2011-05-18 13:04:29 +00:00
$request = $this->getRequest();
$unite = $request->getParam('unit', '€');
$type = $request->getParam('type', '');
$date = $request->getParam('date', '');
$entreprise = new SessionEntreprise($this->siret, $this->id);
2011-05-18 13:04:29 +00:00
switch($type)
{
case 'C':
case 'N':
$model = 'liasse_2050';
break;
case 'S':
$model = 'liasse_2033';
break;
}
2011-07-04 08:31:42 +00:00
$ws = new WsScores();
$liasses = $ws->getBilan(substr($this->siret, 0, 9), $date, $type, '');
$data = array();
$data['DATE_CLOTURE'] = $liasses->DATE_CLOTURE;
2011-05-23 09:51:37 +00:00
$data['DATE_CLOTURE_PRE'] = $liasses->DATE_CLOTURE_PRE;
$data['DUREE_MOIS'] = $liasses->DUREE_MOIS;
$data['DUREE_MOIS_PRE'] = $liasses->DUREE_MOIS_PRE;
foreach ($liasses->POSTES->item as $element)
$data[$element->id] = $element->val;
2011-05-18 13:35:56 +00:00
$path = APPLICATION_PATH . '/../cache/liasse/';
$file = 'liasse-'.substr($this->siret, 0, 9).'-'.$this->id.'-'.$type.$date.'.xls';
2011-05-18 13:35:56 +00:00
2011-06-07 09:48:57 +00:00
require_once 'Finance/LiasseXLS.php';
2011-05-18 13:04:29 +00:00
$liasse = new LiasseXLS($model);
$liasse->dataModel(substr($this->siret, 0, 9), $entreprise->getRaisonSociale(), $data);
2011-05-18 13:04:29 +00:00
$liasse->dataFile($file);
2011-05-18 13:35:56 +00:00
if( file_exists($path.$file) ){
2011-06-29 12:44:20 +00:00
$ws = new WsScores();
$ws->setLog('liassexls', $siren, 0, '');
2011-05-18 13:35:56 +00:00
$this->view->assign('file', $file);
2011-05-18 13:04:29 +00:00
}
2011-05-18 12:22:08 +00:00
}
2011-05-06 15:26:56 +00:00
/**
2011-05-18 13:04:29 +00:00
* Affichage des liasses.
* @todo :
2011-07-04 10:13:45 +00:00
* Afficher les liasses Sipmlifiées
2011-07-04 10:02:31 +00:00
* Sélection des unités non fonctionnel
* Sélection de la dernière date, est ce que l'on est sur que c'est la dernière en fonction du type
* Class LiasseList pour la gestion de la liste
2011-05-06 15:26:56 +00:00
*/
2011-04-19 15:59:50 +00:00
public function liasseAction()
{
$user = new Utilisateur();
2011-07-04 08:31:42 +00:00
2011-05-13 16:33:21 +00:00
/** Les ancres pour les liens **/
2011-06-13 07:04:46 +00:00
$ancres = array(
2011-07-07 13:43:22 +00:00
'C' => array(
'actif' => 'Actif',
'passif' => 'Passif',
'compteDeResultat' => 'Compte de résultat',
),
'N' => array(
'actif' => 'Actif',
'passif' => 'Passif',
'compteDeResultat' => 'Compte de résultat',
'immobilisations' => 'Immobilisations',
'amortissements' => 'Amortissements',
'provisions' => 'Provisions',
'creancesDettes' => 'Créances, Dettes',
'affectation' => 'Affectation'
),
'A' => array(
'actif' => 'Actif',
'passif' => 'Passif',
'compteDeResultat' => 'Compte de résultat',
),
'B' => array(
'actif' => 'Actif',
'passif' => 'Passif',
'compteDeResultat' => 'Compte de résultat',
),
2011-04-26 13:39:19 +00:00
);
/** La liste des type de bilan existant **/
2011-05-18 15:10:54 +00:00
$liste = array (
2011-05-18 13:04:29 +00:00
'N' => array(),
'S' => array(),
'C' => array(),
'B' => array(),
'A' => array());
2011-04-26 13:39:19 +00:00
/** Le nom des type pour le select */
2011-05-18 15:10:54 +00:00
$type = array (
2011-05-18 13:04:29 +00:00
'A' => 'Assurance',
'B' => 'Banque',
'C' => 'Consolidé',
'S' => 'Simplifié',
2011-05-18 13:04:29 +00:00
'N' => ''
);
2011-04-26 13:39:19 +00:00
/** Liste des unités que l'ont proposent **/
2011-07-07 14:44:49 +00:00
$unit = array (
'E' => '€',
'K' => 'K€',
'M' => 'M€',
2011-05-18 13:04:29 +00:00
);
2011-04-26 13:39:19 +00:00
$liasse = array ();
2011-05-13 16:33:21 +00:00
$request = $this->getRequest();
2011-07-07 14:44:49 +00:00
$unite = $request->getParam('unit','K');
2011-07-04 10:00:22 +00:00
2011-07-04 08:36:22 +00:00
$ws = new WsScores();
$listBilan = $ws->getListeBilans(substr($this->siret, 0, 9));
$entreprise = new SessionEntreprise($this->siret, $this->id);
2011-07-07 14:44:49 +00:00
if($listBilan->nbReponses > 0)
{
$date = $request->getParam('date',$listBilan->result->item[0]->dateExercice.':'.$listBilan->result->item[0]->typeBilan);
$dateFunction = new WDate();
foreach ($listBilan->result->item as $item)
$liste[$item->typeBilan][] = $item->dateExercice;
2011-07-04 08:49:06 +00:00
2011-07-07 14:44:49 +00:00
if (!empty($date))
{
$dateAndType = explode(':', $date);
2011-07-04 10:00:22 +00:00
$info = $ws->getBilan(substr($this->siret, 0, 9), $dateAndType[0], $dateAndType[1], true);
2011-07-07 14:44:49 +00:00
$infoLiasse = new Liasse($info, $unit[$unite]['div']);
2011-07-04 10:00:22 +00:00
$this->view->assign('dateCloture', $infoLiasse->getInfo('dateCloture'));
$this->view->assign('dateCloturePre', $infoLiasse->getInfo('dateCloturePre'));
$this->view->assign('dureesMois', $infoLiasse->getInfo('dureeMois'));
$this->view->assign('dureesMoisPre', $infoLiasse->getInfo('dureeMoisPre'));
$this->view->assign('date', $dateAndType[0]);
$this->view->assign('champType', $dateAndType[1]);
2011-07-04 10:00:22 +00:00
$this->view->assign('liasse', $infoLiasse->getPostes());
2011-07-07 13:43:22 +00:00
$this->view->assign('ancres', $ancres[$dateAndType[1]]);
//Gestion export de la liasse au format XLS
$user = new Utilisateur();
if (in_array($user->getIdClient(), array(1,86))
&& in_array($dateAndType[1],array('C', 'N', 'S')) ) {
2011-07-04 08:49:06 +00:00
$this->view->assign('exportxls', true);
}
}
$this->view->assign('dateFunction', $dateFunction);
$this->view->assign('liste', $liste);
$this->view->assign('id', $id);
$this->view->assign('type', $type);
2011-07-07 14:44:49 +00:00
$this->view->assign('unite', $unite);
2011-07-04 08:49:06 +00:00
$this->view->assign('unit', $unit);
}
2011-04-26 13:39:19 +00:00
/** Partie vue **/
$this->view->haveLiasse = ($listBilan->nbReponses > 0)?true:false;
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
$this->view->assign('siren', substr($this->siret, 0, 9));
2011-07-04 08:49:06 +00:00
$this->view->assign('siret', $this->siret);
2011-04-19 15:59:50 +00:00
}
2011-05-09 11:43:43 +00:00
/**
* Fonction qui gére la cotation en bourse.
*/
2011-04-19 15:59:50 +00:00
public function bourseAction()
{
2011-06-08 15:41:59 +00:00
$siren = substr($this->siret, 0, 9);
$sessionEntreprise = new SessionEntreprise($this->siret, $this->id);
$ws = new WsScores();
$InfosBourse = $ws->getInfosBourse($siren);
Zend_Registry::get('firebug')->info($InfosBourse);
$this->view->assign('InfosBourse', $InfosBourse);
2011-06-08 15:41:59 +00:00
$this->view->assign('id', $this->id);
$this->view->assign('siret', $this->siret);
$this->view->assign('raisonSociale', $sessionEntreprise->getRaisonSociale());
$this->view->assign('siren', $siren);
2011-04-19 15:59:50 +00:00
}
2011-05-09 11:43:43 +00:00
/**
* Fonction qui gére les etablissements bancaires.
*/
2011-04-19 15:59:50 +00:00
public function banqueAction()
{
$autrePage = $this->getRequest()->getParam('apage');
//Récupération des informations
if (empty($autrePage)) {
$ws = new WsScores();
$banque = $ws->getBanques(substr($this->siret, 0, 9));
} else {
$banque = $this->getRequest()->getParam('infos');
}
$entreprise = new SessionEntreprise($this->siret, $this->id);
$this->view->assign('banques', $banque->result->item);
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
$this->view->assign('siren', substr($this->siret, 0, 9));
2011-04-19 15:59:50 +00:00
}
2011-04-11 14:19:14 +00:00
}