975 lines
38 KiB
PHP
975 lines
38 KiB
PHP
<?php
|
|
class FinanceController extends Zend_Controller_Action
|
|
{
|
|
protected $siret = null;
|
|
protected $id = 0;
|
|
|
|
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');
|
|
}
|
|
|
|
public function indexAction()
|
|
{
|
|
$this->_forward('index', 'index');
|
|
}
|
|
|
|
/**
|
|
* Affichage de la synthese
|
|
*/
|
|
public function syntheseAction()
|
|
{
|
|
$user = new Utilisateur();
|
|
$session = new SessionEntreprise($this->siret, $this->id);
|
|
|
|
$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');
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
} else {
|
|
$infos = $request->getParam('infos');
|
|
}
|
|
|
|
$tabRatio = array(
|
|
'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
|
|
$ratiosData = new RatiosData($infos);
|
|
|
|
$nbBilanN = $ratiosData->getNbBilan('N');
|
|
$nbBilanC = $ratiosData->getNbBilan('C');
|
|
|
|
if ($typeBilan == 'N' && $nbBilanN==0){
|
|
$typeBilan = 'C';
|
|
}
|
|
|
|
if ($nbBilanN!=0 || $nbBilanC!=0)
|
|
{
|
|
foreach($tabRatio as $idRatio => $valRatio){
|
|
$tabRatio[$idRatio]['comment'] = $ratiosData->wrapComment($idRatio);
|
|
}
|
|
$this->view->assign('tabRatio', $tabRatio);
|
|
|
|
$infosAnnee = $ratiosData->getBilansInfo($typeBilan);
|
|
$annees = array_keys($infosAnnee);
|
|
sort($annees);
|
|
if (count($annees)>1){
|
|
//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){
|
|
$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++;
|
|
}
|
|
$graphLineCompare = $ratiosGraph->syntheseGraphLineCompare($dataGraph, $typeBilan);
|
|
$this->view->assign('graph', true);
|
|
} else {
|
|
$this->view->assign('graph', false);
|
|
}
|
|
|
|
|
|
//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,
|
|
);
|
|
}
|
|
$this->view->assign('tabResult', $tabResult);
|
|
}
|
|
|
|
$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);
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Affichage des graphiques d'évolution (synthese)
|
|
*/
|
|
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";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Affichage du graphique de comparaison (synthese)
|
|
*/
|
|
public function synthesegraphcompareAction()
|
|
{
|
|
$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";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Fonction qui affiche les bilan (actif, passif, SIG).
|
|
* Le principe est d'utiliser le mapping de données.
|
|
* @todo : RatiosData, RatiosGraph
|
|
*/
|
|
public function bilanAction()
|
|
{
|
|
$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');
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
} else {
|
|
$infos = $this->getRequest()->getParam('infos');
|
|
}
|
|
|
|
$ratiosData = new RatiosData($infos);
|
|
|
|
$nbBilanN = $ratiosData->getNbBilan('N');
|
|
$nbBilanC = $ratiosData->getNbBilan('C');
|
|
|
|
if ($typeBilan == 'N' && $nbBilanN==0){
|
|
$typeBilan = 'C';
|
|
}
|
|
|
|
if ($nbBilanN!=0 || $nbBilanC!=0)
|
|
{
|
|
$infosAnnee = $ratiosData->getBilansInfo($typeBilan);
|
|
$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' ),
|
|
);
|
|
$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);
|
|
|
|
}
|
|
|
|
$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'));
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Affichage des graphiques 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');
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
} else {
|
|
$infos = $this->getRequest()->getParam('infos');
|
|
}
|
|
|
|
$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] );
|
|
}
|
|
|
|
$ratiosData = new RatiosData($infos);
|
|
|
|
$nbBilanN = $ratiosData->getNbBilan('N');
|
|
$nbBilanC = $ratiosData->getNbBilan('C');
|
|
|
|
if ($typeBilan == 'N' && $nbBilanN==0){
|
|
$typeBilan = 'C';
|
|
}
|
|
|
|
if ($nbBilanN!=0 || $nbBilanC!=0)
|
|
{
|
|
//Génération Graphique evolution
|
|
$ratiosGraph = new RatiosGraph($this->siret, $this->id);
|
|
|
|
$infosAnnee = $ratiosData->getBilansInfo($typeBilan);
|
|
$annees = array_keys($infosAnnee);
|
|
rsort($annees);
|
|
|
|
$mil = $request->getParam('mil', $annees[0]);
|
|
|
|
$tabAnnees = array();
|
|
foreach($annees as $annee){
|
|
$tabAnnees[$annee] = WDate::dateT('Ymd', 'd/m/Y', $annee);
|
|
}
|
|
|
|
$tabResult = array();
|
|
foreach($tabRatio as $item ) {
|
|
if (isset($item['ratio'])){
|
|
$dataGraph = $ratiosData->dGraph($typeBilan, $item['ratio']);
|
|
$ratiosGraph->ratiosgraph($item['ratio'], $dataGraph);
|
|
$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']);
|
|
$item['comment'] = $ratiosData->wrapComment($item['ratio']);
|
|
}
|
|
$tabResult[] = $item;
|
|
}
|
|
$this->view->assign('tabResult', $tabResult);
|
|
|
|
$this->view->assign('annees', $tabAnnees);
|
|
$this->view->assign('mil', $mil);
|
|
$this->view->assign('typeBilan', $typeBilan);
|
|
$this->view->assign('duree', $infosAnnee[$mil]->duree);
|
|
}
|
|
$this->view->assign('nbBilanN', $nbBilanN);
|
|
$this->view->assign('nbBilanC', $nbBilanC);
|
|
|
|
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('id', $this->id);
|
|
$this->view->assign('naf', $infos->NafEnt);
|
|
$this->view->assign('nafLib', $infos->NafEntLib);
|
|
$this->view->assign('AutrePage', $request->getParam('apage'));
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Affichage des graphiques d'évolutions (ratios)
|
|
*/
|
|
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";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Export d'une liasse au format XLS
|
|
*/
|
|
public function liassexlsAction()
|
|
{
|
|
//@todo : Gestion des unités dans l'export XLS
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
$unite = $request->getParam('unit', '€');
|
|
$type = $request->getParam('type', '');
|
|
$date = $request->getParam('date', '');
|
|
$entreprise = new SessionEntreprise($this->siret, $this->id);
|
|
|
|
switch($type)
|
|
{
|
|
case 'C':
|
|
case 'N':
|
|
$model = 'liasse_2050';
|
|
break;
|
|
case 'S':
|
|
$model = 'liasse_2033';
|
|
break;
|
|
}
|
|
|
|
$ws = new WsScores();
|
|
$liasses = $ws->getBilan(substr($this->siret, 0, 9), $date, $type, '');
|
|
$data = array();
|
|
$data['DATE_CLOTURE'] = $liasses->DATE_CLOTURE;
|
|
$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;
|
|
|
|
$path = APPLICATION_PATH . '/../cache/liasse/';
|
|
$file = 'liasse-'.substr($this->siret, 0, 9).'-'.$this->id.'-'.$type.$date.'.xls';
|
|
|
|
require_once 'Finance/LiasseXLS.php';
|
|
$liasse = new LiasseXLS($model);
|
|
$liasse->dataModel(substr($this->siret, 0, 9), $entreprise->getRaisonSociale(), $data);
|
|
$liasse->dataFile($file);
|
|
|
|
if( file_exists($path.$file) ){
|
|
$ws = new WsScores();
|
|
$ws->setLog('liassexls', $siren, 0, '');
|
|
$this->view->assign('file', $file);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Envoi de bilan pour saisie
|
|
* L'envoi se déroule en plusieurs étapes
|
|
* 1 - Saisie des informations
|
|
* 2 - Validation du formulaire
|
|
* 3 -
|
|
*/
|
|
public function saisiebilanAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
$user = new Utilisateur();
|
|
$params = $request->getParams();
|
|
|
|
$bilanSaisie = new Application_Model_BilanSaisie();
|
|
|
|
$this->view->assign('email', $user->getEmail());
|
|
$this->view->assign('siren', $params['siren']);
|
|
Zend_Registry::get('firebug')->info($params);
|
|
|
|
$ref = $params['ref'];
|
|
|
|
//Annulation de la saisie
|
|
if ($params['annule']){
|
|
$data = array( 'fichier' => '' );
|
|
$bilanSaisie->update($data, "ref='$ref'");
|
|
echo 'Saisie bilan annulé';
|
|
exit;
|
|
}
|
|
//Envoi du fichier @todo ça passe pas
|
|
elseif ($params['upload'])
|
|
{
|
|
if ( count($_FILES)==1 ){
|
|
$n = $_FILES['fichier']['name'];
|
|
$s = $_FILES['fichier']['size'];
|
|
$tmp_name = $_FILES['fichier']['tmp_name'];
|
|
//Vérifier que l'extension du fichier est bien correcte
|
|
$extValide = array('pdf', 'tiff');
|
|
$extension = strrchr($n,'.');
|
|
$extension = substr($extension,1);
|
|
if ( in_array($extension, $extValide) ){
|
|
//Lecture dans la bdd des informations
|
|
$infos = $bilanSaisie->getInfosBilan($ref);
|
|
$name = $infos['ref'].'-'.$infos['siren'].'.'.$extension;
|
|
$configuration = Zend_Registry::get('configuration');
|
|
if ( move_uploaded_file($tmp_name, realpath($configuration->path->data).'/bilanclient/'.$name) ){
|
|
$bilanSaisie->setFilename($ref, $name);
|
|
switch($infos['format']){
|
|
case 'C':
|
|
$type = 'consolidé';
|
|
break;
|
|
case 'N':
|
|
$type = 'réel normal ou simplifié';
|
|
break;
|
|
}
|
|
$session = new SessionEntreprise($params['siren']);
|
|
$this->view->assign('raisonSociale', $session->getRaisonSociale());
|
|
$this->view->assign('size', $size);
|
|
$this->view->assign('name', $name);
|
|
$this->view->assign('infos', $infos);
|
|
$this->view->assign('ref', $ref);
|
|
$this->view->assign('upload', true);
|
|
} else {
|
|
$this->view->assign('upload', false);
|
|
$this->view->assign('errMsg', "<br/>Erreur lors de l'envoi du fichier!");
|
|
}
|
|
} else {
|
|
$this->view->assign('upload', false);
|
|
$this->view->assign('errMsg', "Extension de fichier invalide.");
|
|
}
|
|
} else {
|
|
$this->view->assign('upload', false);
|
|
$this->view->assign('errMsg', "<br/>Erreur.");
|
|
}
|
|
$this->renderScript('finance/saisiebilan-upload.phtml');
|
|
}
|
|
//Validation du formulaire
|
|
elseif (isset($params['method']))
|
|
{
|
|
$valideField = true;
|
|
if ( empty($params['email'])) {
|
|
$valideField = false;
|
|
}
|
|
if ( empty($params['method'])) {
|
|
$valideField = false;
|
|
}
|
|
if ( empty($params['siren'])) {
|
|
$valideField = false;
|
|
}
|
|
if ( empty($params['dateCloture']) && !preg_match('/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}/', $params['dateCloture']) ){
|
|
$valideField = false;
|
|
}
|
|
if ( empty($params['dureeExercice'])) {
|
|
$valideField = false;
|
|
}
|
|
if ($valideField){
|
|
$ref = $bilanSaisie->setInformations(
|
|
$user->getIdClient(),
|
|
$user->getId(),
|
|
$user->getLogin(),
|
|
$params['email'],
|
|
$params['method'],
|
|
$params['confidentiel'],
|
|
$params['siren'],
|
|
$params['dateCloture'],
|
|
$params['format'],
|
|
$params['dureeExercice']
|
|
);
|
|
$this->view->assign('ref', $ref);
|
|
if ($params['method']=='courrier'){
|
|
$this->renderScript('finance/saisiebilan-courrier.phtml');
|
|
} elseif ($params['method']=='fichier') {
|
|
$this->renderScript('finance/saisiebilan-upload.phtml');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Affichage des liasses.
|
|
* @todo :
|
|
* Afficher les liasses Simplifiées
|
|
* 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
|
|
*/
|
|
public function liasseAction()
|
|
{
|
|
$user = new Utilisateur();
|
|
|
|
/** Les ancres pour les liens **/
|
|
$ancres = array(
|
|
'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',
|
|
),
|
|
);
|
|
|
|
/** La liste des types de bilan existant **/
|
|
$liste = array (
|
|
'N' => array(),
|
|
'S' => array(),
|
|
'C' => array(),
|
|
'B' => array(),
|
|
'A' => array());
|
|
|
|
/** Le nom des types pour le select */
|
|
$type = array (
|
|
'A' => 'Assurance',
|
|
'B' => 'Banque',
|
|
'C' => 'Consolidé',
|
|
'S' => 'Simplifié',
|
|
'N' => ''
|
|
);
|
|
|
|
/** Liste des unités que l'ont proposent **/
|
|
$unit = array (
|
|
'E' => '€',
|
|
'K' => 'K€',
|
|
'M' => 'M€',
|
|
);
|
|
$liasse = array ();
|
|
$request = $this->getRequest();
|
|
$unite = $request->getParam('unit','K');
|
|
|
|
$ws = new WsScores();
|
|
$listBilan = $ws->getListeBilans(substr($this->siret, 0, 9));
|
|
if ($listBilan === false) $this->_forward('soap', 'error');
|
|
|
|
$entreprise = new SessionEntreprise($this->siret, $this->id);
|
|
|
|
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;
|
|
|
|
if (!empty($date))
|
|
{
|
|
$dateAndType = explode(':', $date);
|
|
|
|
$infos = $ws->getBilan(substr($this->siret, 0, 9), $dateAndType[0], $dateAndType[1], true);
|
|
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
|
|
$infoLiasse = new Liasse($infos, $unite);
|
|
$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]);
|
|
$this->view->assign('liasse', $infoLiasse->getPostes());
|
|
$this->view->assign('ancres', $ancres[$dateAndType[1]]);
|
|
|
|
//Gestion export de la liasse au format XLS
|
|
if (in_array($user->getIdClient(), array(1,86))
|
|
&& in_array($dateAndType[1],array('C', 'N', 'S')) ) {
|
|
$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);
|
|
$this->view->assign('unite', $unite);
|
|
$this->view->assign('unit', $unit);
|
|
}
|
|
|
|
//Gestion saisie bilan
|
|
if ( $user->checkPerm('UPLOADBILAN') ) {
|
|
$this->view->assign('saisiebilan', true);
|
|
}
|
|
|
|
/** 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));
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Fonction qui gére la cotation en bourse.
|
|
*/
|
|
public function bourseAction()
|
|
{
|
|
$siren = substr($this->siret, 0, 9);
|
|
|
|
$sessionEntreprise = new SessionEntreprise($this->siret, $this->id);
|
|
|
|
$ws = new WsScores();
|
|
$infos = $ws->getInfosBourse($siren);
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
|
|
$this->view->assign('InfosBourse', $infos);
|
|
|
|
$this->view->assign('id', $this->id);
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('raisonSociale', $sessionEntreprise->getRaisonSociale());
|
|
$this->view->assign('siren', $siren);
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Fonction qui gére les etablissements bancaires.
|
|
*/
|
|
public function banqueAction()
|
|
{
|
|
$autrePage = $this->getRequest()->getParam('apage');
|
|
//Récupération des informations
|
|
if (empty($autrePage)) {
|
|
$ws = new WsScores();
|
|
$infos = $ws->getBanques(substr($this->siret, 0, 9));
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
} else {
|
|
$infos = $this->getRequest()->getParam('infos');
|
|
}
|
|
|
|
$entreprise = new SessionEntreprise($this->siret, $this->id);
|
|
$this->view->assign('banques', $infos->result->item);
|
|
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
|
|
$this->view->assign('siren', substr($this->siret, 0, 9));
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
} |