Issue #0001850: [Evolution des scores] afficher tous les scores dans la table et grafique

This commit is contained in:
Aram HARUTYUNYAN 2014-05-08 13:14:22 +00:00
parent b55d4e9f08
commit da90944620
5 changed files with 200 additions and 29 deletions

View File

@ -59,10 +59,37 @@ class EvaluationController extends Zend_Controller_Action
/**
* Historique des scores
*/
public function indiscorehistoAction()
public function scoreshistoAction()
{
$sessionEntreprise = new Scores_Session_Entreprise($this->siret, $this->id);
$siren = substr($this->siret,0,9);
$types = array (
'indiScore' => 'IndiScore',
'scoreDir' => 'Dirigeance',
'scoreConf' => 'Conformité',
'scoreZ' => 'Score Z',
'scoreCH' => 'Conan & Holder',
'scoreAfdcc1' => 'Afdcc1',
'scoreAfdcc2' => 'Afdcc2',
'scoreAltman' => 'Altman',
'scoreCCF' => 'CCF',
);
$bornes = array(
'indiScore' => array('min'=>0, 'max'=>20, 'rouge'=>8, 'orange'=>12),
'scoreDir' => array('min'=>0, 'max'=>100, 'rouge'=>45, 'orange'=>56),
'scoreConf' => array('min'=>0, 'max'=>100, 'rouge'=>45, 'orange'=>56),
'scoreZ' => array('min'=>-3, 'max'=>3, 'rouge'=>-0.25, 'orange'=>0.125),
'scoreCH' => array('min'=>-4.5,'max'=>16, 'rouge'=>3.75, 'orange'=>10),
'scoreAfdcc1' => array('min'=>-7, 'max'=>7, 'rouge'=>0, 'orange'=>1),
'scoreAfdcc2' => array('min'=>-3, 'max'=>2, 'rouge'=>-1, 'orange'=>0.5),
'scoreAltman' => array('min'=>-2, 'max'=>8, 'rouge'=>0, 'orange'=>2.7),
'scoreCCF' => array('min'=>500,'max'=>1500,'rouge'=>850, 'orange'=>1200), //corriger les bornes de CCF
);
$request = $this->getRequest();
$type = $request->getParam('type', 'indiScore');
$user = new Scores_Utilisateur();
@ -70,7 +97,7 @@ class EvaluationController extends Zend_Controller_Action
$this->view->headTitle()->prepend('Siret '.$this->siret);
$ws = new WsScores();
$histoScores = $ws->getScoresHisto($this->siret, 'indiscore');
$histoScores = $ws->getScoresHisto($this->siret, $type);
if ( $histoScores->nbReponses>1 ) {
@ -79,6 +106,7 @@ class EvaluationController extends Zend_Controller_Action
$d = array(
'date' => $item->date,
'value' => $item->value,
'encours' =>$item->encours,
);
$data['data'][] = $d;
}
@ -88,7 +116,7 @@ class EvaluationController extends Zend_Controller_Action
require_once 'Scores/Cache.php';
$c = Zend_Registry::get('config');
$path = $c->profil->path->pages . '/imgcache/';
$file = 'indiscorehisto-'.$this->siret.'-'.$this->id.'.png';
$file = 'indiscorehisto-'.$this->siret.'-'.$this->id.'-'.$type.'.png';
$cache = new Cache();
$return = null;
if( $cache->exist($path.$file) ){
@ -98,55 +126,66 @@ class EvaluationController extends Zend_Controller_Action
$return = null;
} else {
$labelsX = array();
$labelsY = array();
$dataX = array();
$encours = array();
foreach($data['data'] as $value){
$dataX[] = $value['value'];
$encours[] = $value['encours'];
$date = new Zend_Date($value['date'], 'yyyy-MM-dd');
$labelsX[] = $date->toString('dd/MM/yyyy');
}
$labelsX[] = chartTime($date->toString('yyyy'), $date->toString('MM'), $date->toString('dd'));
}
$c = new XYChart(600, 300);
$c->setPlotArea(40, 10, 540, 200, 0xE9EDFF, 0xFFFFFF, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0);
$c->xAxis->setTitle("Date");
$c->setPlotArea(50, 10, $c->getWidth() - 60, $c->getHeight() - 60, 0xFFFFFF, -1, 0xC0C0C0, $c->dashLineColor(0x808080, DotLine), -1);
$c->xAxis->setTitle($this->view->translate("Année"));
$c->xAxis->setColors(0x777777, 0x444444, 0x777777);
$c->xAxis->setWidth(2);
$c->xAxis->setLabelStyle("arial.ttf", 8, 0x444444, 90);
$c->xAxis->setLabels($labelsX);
$c->yAxis->setTitle("Score");
$c->yAxis->setTitle($this->view->translate("Score"));
$c->yAxis->setColors(0x777777, 0x444444, 0x777777);
$c->yAxis->setWidth(2);
$c->yAxis->setLabels($labelsY);
$textBoxObj = $c->addText(550, 15, 'IndiScore', "arialbi.ttf", 11, 0xAAAAAA);
$textBoxObj->setAlignment(TopRight);
$layer = $c->addSplineLayer();
$layer->setDataLabelFormat("{value}");
$c->yAxis->addZone(abs($bornes[$type]['min'])*(-5), $bornes[$type]['rouge'], 0xFFE2E2);
$c->yAxis->addZone($bornes[$type]['rouge'], $bornes[$type]['orange'], 0xFFF2E2);
$c->yAxis->addZone($bornes[$type]['orange'], abs($bornes[$type]['max'])*5, 0xE2FFE2);
// If real value is not between min max scores, enlarge Y of graphic and mark limits
$maxY = (max($dataX) >= $bornes[$type]['max']) ? max($dataX)*1.1 : $bornes[$type]['max'];
$minY = (min($dataX) <= $bornes[$type]['min']) ? min($dataX)*1.1 : $bornes[$type]['min'];
$c->yAxis->setLinearScale($minY, $maxY);
$textBox = $c->addText(550, 15, $types[$type], "arialbi.ttf", 11, 0xAAAAAA);
$textBox->setAlignment(TopRight);
$layer = $c->addSplineLayer();
$layer->setXData($labelsX);
$layer->setLineWidth(1);
$dataSetObj = $layer->addDataSet($dataX, 0x0000FF, "Target Group");
$dataSetObj->setDataSymbol(CircleSymbol, 3, 0x5555FF);
$layer->addExtraField($encours);
$dataSet = $layer->addDataSet($dataX, 0x0000FF);
$dataSet->setDataSymbol(CircleSymbol, 4, 0x5555FF);
if( $c->makeChart($path.$file ) === true){
$return = $file;
$graphMap = $c->getHTMLImageMap("", "", "title='{x|dd/mm/yyyy}\nScore: {value}\nEncours: {field0} K&euro;' style='cursor:pointer;'");
} else {
$return = false;
}
}
}
$this->view->assign('graphMap', $graphMap);
$this->view->assign('graph', $return);
//Assign vars
$this->view->assign('scores', $histoScores->result->item);
$this->view->assign('type', $histoScores->type);
//Assign vars
$this->view->assign('scores', $histoScores->result->item);
if ($histoScores->type == 'indiScore20') $histoScores->type = 'indiScore';
$this->view->assign('type', $histoScores->type);
$this->view->assign('bornes', $bornes);
}
$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('types', $types);
$this->view->assign('exportObjet', $histoScores);
}

View File

@ -69,6 +69,11 @@ class PrintController extends Zend_Controller_Action
case 'evaluation':
$params['siret'] = $elements[2];
$params['id'] = $elements[3];
switch($action){
case 'scoreshisto':
$params['type'] = $elements[4];
break;
}
break;
case 'giant':
$params['Pays'] = $elements[2];

View File

@ -37,7 +37,7 @@
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">&nbsp;</td>
<td width="350" class="StyleInfoData">
<a href=<?=$this->url(array('controller'=>'evaluation', 'action'=>'indiscorehisto', 'siret' => $this->siret)); ?>>
<a href=<?=$this->url(array('controller'=>'evaluation', 'action'=>'scoreshisto', 'siret' => $this->siret)); ?>>
<?=$this->translate("Consulter l'historique des IndiScore");?></a>
</td>
</tr>

View File

@ -0,0 +1,127 @@
<div id="center">
<h1><?=$this->translate('HISTORIQUE').' '.strtoupper($this->types[$this->type]);?></h1>
<div class="paragraph">
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib"><?=$this->translate('Numéro identifiant Siren')?></td>
<td width="350" class="StyleInfoData"><?=$this->SirenTexte($this->siren)?></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib"><?=$this->translate('Dénomination sociale')?></td>
<td width="350" class="StyleInfoData"><?=$this->raisonSociale?></td>
</tr>
</table>
</div>
<h2><?=$this->translate('Historique des scores')?></h2>
<div class="paragraph" style="text-align: right;">
<select name="type">
<?php foreach($this->types as $key=>$val) {?>
<?php $selected = ($key == $this->type)?'selected':'';?>
<option value="<?=$this->url(array('siret'=>$this->siret, 'id'=>$this->id, 'type'=>$key))?>" <?=$selected; ?>><?=$val ?></option>
<?php }?>
</select>
<script>
$('select[name=type]').change(function(e){
window.location = $(this).val();
});
</script>
</div>
<?php if ( count($this->scores)> 0 ) {?>
<?php $bornes = $this->bornes[$this->type];?>
<div class="paragraph">
<table id="synthese">
<thead>
<tr class="head">
<th align="center" style="cursor:pointer;" onclick=sortTable(0)><?=$this->translate('Date')?> &#8593;&#8595;</th>
<th align="center" style="cursor:pointer;" onclick=sortTable(1)><?=$this->types[$this->type]?> &#8593;&#8595;</th>
<th align="center" style="cursor:pointer;" onclick=sortTable(2)><?=$this->translate('Encours')?> (K&euro;) &#8593;&#8595;</th>
<th><?=$this->translate('Motif du changement')?></th>
</tr>
</thead>
<tbody>
<?php foreach($this->scores as $score) {?>
<tr>
<td align="center">
<?php $date = new Zend_Date($score->date, 'yyyy-MM-dd');?>
<?=$date->toString('dd/MM/yyyy')?>
</td>
<td align="center"><?=$score->value?> </td>
<td align="center"><?=$score->encours?> </td>
<td><?=$score->motif?></td>
</tr>
<?php }?>
</tbody>
</table>
</div>
<script>
$(document).ready(function(){
$("#synthese tbody tr").each(function(){
if ($(this).find('td:eq(1)').text() < <?=$bornes['rouge']?>) {
$(this).find('td:eq(1)').css("color", "red");
} else if ($(this).find('td:eq(1)').text() < <?=$bornes['orange']?>) {
$(this).find('td:eq(1)').css("color", "orange");
} else {
$(this).find('td:eq(1)').css("color", "green");
}
});
});
function sortTable(column){
var t;
if (!$("thead tr th").attr("class")) {
t = 1;
$("thead tr th").addClass("DESC");
} else if ($("thead tr th").attr("class")=='DESC') {
t = -1;
$("thead tr th").removeClass("DESC")
}
var rows = $('#synthese tbody tr').get();
rows.sort(function(a, b) {
var A = $(a).children('td').eq(column).text();
var B = $(b).children('td').eq(column).text();
if (column===0)
{
A = $.datepicker.parseDate('dd/mm/yy', $.trim(A));
B = $.datepicker.parseDate('dd/mm/yy', $.trim(B));
}
if((A - B) < 0) {
return -1*t;
}
if((A - B) > 0) {
return t;
}
return 0;
});
$.each(rows, function(index, row) {
$('#synthese').children('tbody').append(row);
});
}
</script>
<div class="paragraph">
<?php if ( $this->graph ) {?>
<img src="/fichier/imgcache/<?=$this->graph?>" usemap="#graphMap">
<map name="graphMap">
<?=$this->graphMap;?>
</map>
<?php } else {?>
<b><?=$this->translate('Impossible de générer le graphique')?></b>
<?php }?>
</div>
<?php } else {?>
<div class="paragraph">
<?=$this->translate("Aucune information sur l'historique disponible.")?>
</div>
<?php }?>
<?=$this->render('cgu.phtml', $this->cgu)?>
</div>

View File

@ -25,11 +25,11 @@ class Scores_Export_Print
'juridique-competences' => 'siret,id,type',
'juridique-marques' => 'siret,id,idObject',
'evaluation-indiscore' => 'siret,id',
'evaluation-indiscorehisto' => 'siret,id',
'evaluation-indiscore2' => 'siret,id',
'evaluation-indiscore3' => 'siret,id',
'evaluation-scoring' => 'siret,id',
'evaluation-valorisation' => 'siret,id',
'evaluation-scoreshisto' => 'siret,id,type',
'pieces-bilans' => 'siret,id',
'pieces-actes' => 'siret,id',
'giant-full' => 'Pays,Type,CompanyId,Language',
@ -60,11 +60,11 @@ class Scores_Export_Print
'juridique-competences' => 'siret,id,type',
'juridique-marques' => 'siret,id,idObject',
'evaluation-indiscore' => 'siret,id',
'evaluation-indiscorehisto' => 'siret,id',
'evaluation-indiscore2' => 'siret,id',
'evaluation-indiscore3' => 'siret,id',
'evaluation-scoring' => 'siret,id',
'evaluation-valorisation' => 'siret,id',
'evaluation-scoreshisto' => 'siret,id,type',
'pieces-bilans' => 'siret,id',
'pieces-actes' => 'siret,id',
'giant-full' => 'Pays,Type,CompanyId,Language',
@ -93,10 +93,10 @@ class Scores_Export_Print
'juridique-competences' => 'siret,id,type',
'juridique-marques' => 'siret,id,idObject',
'evaluation-indiscore' => 'siret,id',
'evaluation-indiscorehisto' => 'siret,id',
'evaluation-indiscore2' => 'siret,id',
'evaluation-indiscore3' => 'siret,id',
'evaluation-valorisation' => 'siret,id',
'evaluation-scoreshisto' => 'siret,id,type',
'giant-full' => 'Pays,Type,CompanyId,Language',
'giant-compact' => 'Pays,Type,CompanyId,Language',
'giant-creditrecommendation' => 'Pays,Type,CompanyId,Language',