5e86bfe64f
J'ai donné la possibilité d'enregistrer plusieur historique grace au plugin.
137 lines
5.1 KiB
PHP
137 lines
5.1 KiB
PHP
<?php
|
|
Class Zend_View_Helper_LineBilan extends Zend_View_Helper_Abstract
|
|
{
|
|
private $sig = false;
|
|
private $elementSIG = array();
|
|
public $column;
|
|
|
|
/**
|
|
* Calcule les valeurs des bilans.
|
|
*
|
|
* @param unknown_type $element
|
|
* @param unknown_type $reference
|
|
*/
|
|
public function Tb($element, $reference)
|
|
{
|
|
if($element != 'NS') {
|
|
if ($element != 0 and $reference != 0) {
|
|
return (round(($element * 100) / $reference, 2));
|
|
}
|
|
}
|
|
return (0);
|
|
}
|
|
|
|
/**
|
|
* Construit les elements graphique des bilans.
|
|
*
|
|
* @param unknown_type $data
|
|
* @param unknown_type $name
|
|
* @param unknown_type $date
|
|
*/
|
|
public function GraphLineBilan($data, $name, $date)
|
|
{
|
|
$file = $name.'.png';
|
|
|
|
if(file_exists(APPLICATION_PATH.'/../cache/pages/imgcache/'.$file))
|
|
return;
|
|
$labelX = $date;
|
|
$labelY = array();
|
|
$c = new XYChart(350, 250);
|
|
$c->setPlotArea(55, 10, 280, 200);
|
|
$c->yAxis->setTitle('Keuros');
|
|
$c->xAxis->setTitle("Années");
|
|
$c->xAxis->setWidth(2);
|
|
$c->yAxis->setWidth(2);
|
|
$legendObj = $c->addLegend(50, 10, false, "times.ttf", 9);
|
|
$legendObj->setBackground(Transparent);
|
|
$c->addLineLayer($data, 0xff0000, "Entreprise");
|
|
$c->yAxis->setLabels($labelY);
|
|
$c->yAxis->setLabelStep(10);
|
|
$c->xAxis->setLabels($labelX);
|
|
$c->makeChart('../cache/pages/imgcache/'.$file);
|
|
}
|
|
|
|
/**
|
|
* verifie les balise heads pour la couleur.
|
|
*
|
|
* @param unknown_type $id
|
|
*/
|
|
public function ifIsHead($id)
|
|
{
|
|
$head = array('r59', 'r69', 'r22','r79', 'r90', 'r101',
|
|
'r110', 'r120', 'r122', 'r130', 'r140',
|
|
'r150', 'r170', 'r199'
|
|
);
|
|
|
|
if (in_array($id, $head))
|
|
return (true);
|
|
return (false);
|
|
}
|
|
|
|
public function createlementForGraphique($id)
|
|
{
|
|
$element = array('r51', 'r52', 'r53', 'r60', 'r61', 'r62', 'r63',
|
|
'r70', 'r71', 'r72', 'r83', 'r84', 'r85', 'r86', 'r87',
|
|
'');
|
|
|
|
if (in_array($id, $element))
|
|
return (true);
|
|
return (false);
|
|
}
|
|
|
|
public function specialSIG($id, $partial)
|
|
{
|
|
if ($id == 'r101')
|
|
return self::Tb(end($partial['r101']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r122']['item']), end($partial['r101']['item']));
|
|
else if ($id == 'r122')
|
|
return self::Tb(end($partial['r122']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r130']['item']), end($partial['r101']['item']));
|
|
else if ($id == 'r130')
|
|
return self::Tb(end($partial['r130']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r140']['item']), end($partial['r101']['item']));
|
|
else if ($id == 'r140')
|
|
return self::Tb(end($partial['r140']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r150']['item']), end($partial['r101']['item']));
|
|
else if ($id == 'r150')
|
|
return self::Tb(end($partial['r150']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r170']['item']), end($partial['r101']['item']));
|
|
else if ($id == 'r170')
|
|
return self::Tb(end($partial['r170']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r199']['item']), end($partial['r101']['item']));
|
|
else if ($id == 'r199')
|
|
return self::Tb(end($partial['r199']['item']), end($partial['r101']['item']));
|
|
}
|
|
|
|
/**
|
|
* Ecrit chaque ligne du bilan.
|
|
*
|
|
* @param unknown_type $id
|
|
* @param unknown_type $Graphdate
|
|
* @param unknown_type $partial
|
|
* @param unknown_type $reference
|
|
* @param unknown_type $url
|
|
* @param unknown_type $name
|
|
* @param unknown_type $tb_reference
|
|
*/
|
|
public function LineBilan($id, $Graphdate, $partial, $reference, $url, $name, $tb_reference, $siren, $sig = false)
|
|
{
|
|
$this->column = 0;
|
|
echo '<tr '.((self::ifIsHead($id))?'class="subhead"':'class="bilanDatas"').'>';
|
|
echo '<td>'.$name.'</td>';
|
|
foreach($partial[$id]['item'] as $element) {
|
|
if($element != 'NS'){ $GraphLine[] = $number = $element; }else{$number = 0; $GraphLine[] = 0;};
|
|
echo '<td align="right">' . (($element != 'NS') ? number_format($element, 0, '', ' ') . ' K€':$element).'</td>';
|
|
if($sig)$gr = self::specialSIG($id, $partial);
|
|
if(self::createlementForGraphique($id))$gr = $number;
|
|
}
|
|
if($id != 'r22' and $id != 'r101')
|
|
echo '<td align="right">' . self::Tb($element, (!$this->sig)?$partial[$tb_reference]['item'][key($partial[$tb_reference]['item'])]:$this->sig) . '</td>';
|
|
else
|
|
echo '<td align="right">'.self::Tb($element, (($this->sig)?$this->sig = $element:$element)).'</td>';
|
|
self::GraphLineBilan($GraphLine, $id.'-'.$siren, $Graphdate);
|
|
echo '<td>';
|
|
echo '<a name="Actif Immobilisé Net" class="rTip"
|
|
rel="'.$url.'
|
|
">
|
|
<img src="/themes/default/images/finance/char_bar.png" />
|
|
</a>';
|
|
echo '</td>';
|
|
echo '</tr>';
|
|
return ($gr != 0)? $gr : false;
|
|
}
|
|
} |