issue #0001889 : Graph and display
This commit is contained in:
parent
06f76b6727
commit
fc6cda9dcb
@ -55,68 +55,92 @@ class EvaluationController extends Zend_Controller_Action
|
||||
$this->view->assign('min', $bornes[$score]['min']);
|
||||
$this->view->assign('max', $bornes[$score]['max']);
|
||||
}
|
||||
|
||||
/**
|
||||
* graphique de l'historique des scores
|
||||
* @param array $infos
|
||||
* @param string $siren
|
||||
* @param string $type
|
||||
* @return array $dates
|
||||
*/
|
||||
protected function scoresHistoChart($infos, $siren, $type)
|
||||
{
|
||||
require_once("Vendors/ChartDirector/phpchartdir.php");
|
||||
|
||||
$hChart = 240;
|
||||
$labels = range(1, count($infos));
|
||||
|
||||
$c = new XYChart($hChart*2, $hChart);
|
||||
$c->setPlotArea($hChart/10, $hChart/20, $hChart*18/10, $hChart*8/10);
|
||||
$c->xAxis->setLabels($labels);
|
||||
$c->xAxis->setLabelStep(1);
|
||||
|
||||
$textBoxObj = $c->addText($hChart*18/10, $hChart/15, $type, "arialbi.ttf", 11, 0xaaaaaa);
|
||||
$textBoxObj->setAlignment(TopRight);
|
||||
|
||||
$layer = $c->addSplineLayer();
|
||||
$layer->setDataLabelFormat("{value}");
|
||||
$layer->setLineWidth(2);
|
||||
|
||||
$dataSetObj = $layer->addDataSet($infos, 0xFF8888, "Target Group");
|
||||
$dataSetObj->setDataSymbol(CircleSymbol, 5, 0xFF5555);
|
||||
|
||||
$fChart = fopen('themes/default/images/charts/scoresHisto-'.$siren.'-'.$type.'.png', "w");
|
||||
fwrite($fChart, $c->makeChart2('png'));
|
||||
fclose($fChart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Historique des scores
|
||||
*/
|
||||
public function indiscorehistoAction()
|
||||
{
|
||||
$user = new Scores_Utilisateur();
|
||||
$ws = new WsScores();
|
||||
$sessionEntreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
||||
$siren = substr($this->siret,0,9);
|
||||
|
||||
$user = new Scores_Utilisateur();
|
||||
|
||||
$this->view->headTitle()->prepend('Historique indiScore');
|
||||
$this->view->headTitle()->prepend('Siret '.$this->siret);
|
||||
|
||||
$ws = new WsScores();
|
||||
$histoScores = $ws->getScoresHisto($this->siret, 'indiscore');
|
||||
|
||||
$histoScores = $ws->getScoresHisto($this->siret, 'indiscore');
|
||||
$infos = $ws->getIdentiteLight($this->siret);
|
||||
if ( $histoScores->nbReponses>1 ) {
|
||||
|
||||
$data = array();
|
||||
$data['unite'] = '';
|
||||
foreach ($histoScores->result->item as $item) {
|
||||
$d = array(
|
||||
'date' => $item->date,
|
||||
'value' => $item->value,
|
||||
);
|
||||
$data['data'][] = $d;
|
||||
}
|
||||
|
||||
//Make the graph - Ready to create a class for this char
|
||||
require_once 'Vendors/ChartDirector/phpchartdir.php';
|
||||
require_once 'Scores/Cache.php';
|
||||
$c = Zend_Registry::get('config');
|
||||
$path = $c->profil->path->pages . '/imgcache/';
|
||||
$file = 'indiscorehisto-'.$this->siret.'-'.$this->id.'.png';
|
||||
$cache = new Cache();
|
||||
$return = null;
|
||||
if( $cache->exist($path.$file) ){
|
||||
$return = $file;
|
||||
} else {
|
||||
if( count($data)<=1 ){
|
||||
$return = null;
|
||||
} else {
|
||||
$labelsX = array();
|
||||
$labelsY = array();
|
||||
$dataX1 = array();
|
||||
$dataX2 = array();
|
||||
foreach($data['data'] as $value){
|
||||
$dataX1[] = $value['value'];
|
||||
$labelsX[] = $value['date'];
|
||||
}
|
||||
$i=-100; while($i>100){
|
||||
$labelsY[] = $i;
|
||||
}
|
||||
$c = new XYChart(500, 250);
|
||||
$c->setPlotArea(70, 10, 450, 200);
|
||||
$c->yAxis->setTitle($data['unite']);
|
||||
$c->xAxis->setTitle("Date");
|
||||
$c->xAxis->setWidth(2);
|
||||
$c->yAxis->setTitle("Score");
|
||||
$c->yAxis->setWidth(2);
|
||||
$legendObj = $c->addLegend(50, 10, false, "times.ttf", 9);
|
||||
$legendObj->setBackground(Transparent);
|
||||
$c->addLineLayer($dataX1, 0x0000ff, "Evolution");
|
||||
$c->yAxis->setLabels($labelsY);
|
||||
$c->yAxis->setLabelStep(10);
|
||||
$c->xAxis->setLabels($labelsX);
|
||||
if( $c->makeChart($path.$file ) === true){
|
||||
$return = $file;
|
||||
} else {
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->view->assign('graph', $return);
|
||||
|
||||
if ($histoScores->nbReponses>1)
|
||||
{
|
||||
foreach($histoScores->result->item as $score)
|
||||
{
|
||||
$scoreVals[] = $score->value;
|
||||
}
|
||||
|
||||
$this->scoresHistoChart($scoreVals, substr($this->siret, 0,9), $histoScores->type);
|
||||
|
||||
$this->view->assign('scores', $histoScores->result->item);
|
||||
//Assign vars
|
||||
$this->view->assign('scores', $histoScores->result->item);
|
||||
$this->view->assign('type', $histoScores->type);
|
||||
}
|
||||
|
||||
$this->view->assign('infos', $infos);
|
||||
}
|
||||
|
||||
$this->view->assign('siret', $this->siret);
|
||||
$this->view->assign('id', $this->id);
|
||||
$this->view->assign('siren', $siren);
|
||||
$this->view->assign('raisonSociale', $sessionEntreprise->getRaisonSociale());
|
||||
$this->view->assign('typeScore', $user->getTypeScore());
|
||||
$this->view->assign('AutrePage', $autrePage);
|
||||
$this->view->assign('exportObjet', $histoScores);
|
||||
}
|
||||
|
||||
|
@ -6,51 +6,59 @@
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td width="200" class="StyleInfoLib"><?=$this->translate('Numéro identifiant Siren')?></td>
|
||||
<td width="350" class="StyleInfoData"><?=$this->SirenTexte($this->infos->Siren)?></td>
|
||||
<td width="350" class="StyleInfoData"><?=$this->SirenTexte($this->siren)?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td width="200" class="StyleInfoLib"><?=$this->translate('Dénomination sociale')?></td>
|
||||
<td width="350" class="StyleInfoData"><?=$this->infos->Nom?></td>
|
||||
<td width="350" class="StyleInfoData"><?=$this->raisonSociale?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h2><?=$this->translate('Historique des scores');?></h2>
|
||||
<h2><?=$this->translate('Historique des scores')?></h2>
|
||||
|
||||
<?php if ( count($this->scores)> 0 ) {?>
|
||||
|
||||
<div class="paragraph">
|
||||
<?php if($this->scores) {?>
|
||||
<style>
|
||||
.indiScore td{padding: 3px; text-align: center;}
|
||||
.indiScore tr:nth-child(even) {background-color: #FCFCFC;}
|
||||
.indiScore tr:nth-child(odd) {background-color: #F2F2F2;}
|
||||
.indiScore tr:nth-child(1) {color: #444; background-color: #bfbfcc; text-align: center; font-weight: bold;}
|
||||
.indiScore td.txt {text-align: left; padding-left: 30px;}
|
||||
</style>
|
||||
<table class="indiScore" align="center" style="width: 440px;">
|
||||
<tr>
|
||||
<td width="20px"><?=$this->translate('No'); ?></td>
|
||||
<td width="80px"><?=$this->translate('Date'); ?></td>
|
||||
<td width="80px"><?=$this->translate('IndiScore'); ?></td>
|
||||
<td><?=$this->translate('Motif de changement'); ?></td>
|
||||
<table id="synthese">
|
||||
<thead>
|
||||
<tr class="head">
|
||||
<th align="center"><?=$this->translate('Date')?></td>
|
||||
<th align="center"><?=$this->translate('IndiScore')?></td>
|
||||
<th><?=$this->translate('Motif du changement')?></td>
|
||||
</tr>
|
||||
<?php foreach($this->scores as $score){?>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($this->scores as $score) {?>
|
||||
<tr>
|
||||
<td class="StyleInfoData"><?=++$count; ?></td>
|
||||
<td class="StyleInfoData">
|
||||
<td align="center">
|
||||
<?php $date = new Zend_Date($score->date, 'yyyy-MM-dd');?>
|
||||
<?=$date->toString('dd/MM/yyyy');?>
|
||||
<?=$date->toString('dd/MM/yyyy')?>
|
||||
</td>
|
||||
<td class="StyleInfoData"><?=$score->value;?> </td>
|
||||
<td class="StyleInfoData txt"><?=($score->motif!='')?$score->motif:'';?></td>
|
||||
<td align="center"><?=$score->value?> </td>
|
||||
<td><?=$score->motif?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<?php }?>
|
||||
</table>
|
||||
<p style="text-align: center;">
|
||||
<!-- img src="/themes/default/images/charts/scoresHisto-<?=$this->infos->Siren;?>-<?=$this->type;?>.png" / --></p>
|
||||
</div>
|
||||
|
||||
<div class="paragraph">
|
||||
<?php if ( $this->graph ) {?>
|
||||
<img src="/fichier/imgcache/<?=$this->graph?>">
|
||||
<?php } else {?>
|
||||
<div class="StyleInfoData"><?=$this->translate('Aucune information sur l\'historique disponible.');?></div>
|
||||
<b><?=$this->translate('Impossible de générer le graphique')?></b>
|
||||
<?php }?>
|
||||
</div>
|
||||
|
||||
<?=$this->render('cgu.phtml', $this->cgu);?>
|
||||
</div>
|
||||
<?php } else {?>
|
||||
|
||||
<div class="paragraph">
|
||||
<?=$this->translate("Aucune information sur l'historique disponible.")?>
|
||||
</div>
|
||||
|
||||
<?php }?>
|
||||
|
||||
<?=$this->render('cgu.phtml', $this->cgu)?>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user