Surveillance, Portefeuille

This commit is contained in:
Michael RICOIS 2011-04-20 07:26:17 +00:00
parent 1bbd6f8826
commit ae57ec6ab1
3 changed files with 716 additions and 13 deletions

View File

@ -4,7 +4,7 @@ class SurveillanceController extends Zend_Controller_Action
public function init()
{
require_once 'Scores/Utilisateur.php';
}
public function indexAction()
@ -14,10 +14,148 @@ class SurveillanceController extends Zend_Controller_Action
public function listeAction()
{
$this->view->headLink()->appendStylesheet('/themes/default/styles/surveillance.css', 'all');
$this->view->headScript()
->appendFile('/themes/default/scripts/jquery.qtip.js', 'text/javascript')
->appendFile('/themes/default/scripts/jquery.tablesorter.js', 'text/javascript')
->appendFile('/themes/default/scripts/surveillance.js', 'text/javascript');
$firebug = Zend_Registry::get('firebug');
$request = $this->getRequest();
$page = $request->getParam('page', 0);
$source = $request->getParam('source', '');
$tri = $request->getParam('tri', 'siren');
$detail = true;
$nbAffichage = 100;
$position = $page*$nbAffichage;
switch($tri){
default:
case 'siren': $triws = 'siren'; break;
case 'rs': $triws = 'rs'; break;
case 'reference': $triws = 'ref'; break;
case 'dateajout': $triws = 'dateAjout'; break;
case 'datederenvoi': $triws = 'dateDerEnvoi'; break;
}
// Source => Permission
$tabSource = array(
'annonces' => 'annonce',
'insee' => 'insee',
'bilans' => 'bilan',
'score' => 'score',
'actes' => 'actes',
'dirigeants' => 'dirigeants',
'privileges' => 'priv',
);
$user = new Utilisateur();
//Select Tri + Liste des sources autorisée
$selectTri = '';
$permSource = array();
foreach ($tabSource as $s => $perm) {
if ($user->checkPerm('surv'.$perm)) {
$permSource[] = $s;
$selectTri.= '<option value="'.$s.'"';
if ($source == $s) {
$selectTri.= 'selected';
}
$selectTri.= '>'.$s.'</option>';
}
}
require_once 'Scores/WsScores.php';
$ws = new WsScores();
$infos = $ws->getSurveillances();
$this->view->assign('infos',$infos);
$infos = $ws->getSurveillances($tri, $source, '', $detail, $position);
$surveillances = $infos->result->item;
//Tri si nécessaire
if (empty($source)){
$i=0;
$tabIndex = array();
$listTrier = array();
if (count($surveillances)>0) {
foreach($surveillances as $item) {
if(!array_key_exists($item->siren, $tabIndex)) {
//Création du tableau trier
$listTrier[$i]['siren'] = $item->siren;
$listTrier[$i]['nic'] = $item->nic;
$listTrier[$i]['rs'] = $item->rs;
$listTrier[$i]['cp'] = $item->cp;
$listTrier[$i]['ville'] = $item->ville;
$listTrier[$i]['sources'][$item->source][0] = array(
'email' => $item->email,
'ref' => $item->ref,
'dateAjout' => $item->dateAjout,
'dateDerEnvoi' => $item->dateDerEnvoi,
);
//Tableau d'index
$tabIndex[$item->siren] = $i;
} else {
$key = $tabIndex[$item->siren];
$source = array(
'email' => $item->email,
'ref' => $item->ref,
'dateAjout' => $item->dateAjout,
'dateDerEnvoi'=> $item->dateDerEnvoi,
);
if ( array_key_exists( $item->source, $listTrier[$key]['sources'] ) ){
$nbSource = count($listTrier[$key]['sources'][$item->source]);
}else{
$nbSource = 0;
}
$listTrier[$key]['sources'][$item->source][$nbSource] = $source;
}
$i++;
}
}
} else {
$listTrier = array();
if (count($surveillances)>0) {
foreach ($surveillances as $item) {
$listTrier[]['source'] = $item->source;
$listTrier[]['email'] = $item->email;
$listTrier[]['siren'] = $item->siren;
$listTrier[]['nic'] = $item->nic;
$listTrier[]['ref'] = $item->ref;
$listTrier[]['dateAjout'] = $item->dateAjout;
$listTrier[]['encoursClient'] = $item->encoursClient;
$listTrier[]['rs'] = $item->rs;
$listTrier[]['cp'] = $item->cp;
$listTrier[]['ville'] = $item->ville;
$listTrier[]['dateDerEnvoi'] = $item->dateDerEnvoi;
}
}
}
//Calcul pagination
$nbReponses = $infos->nbReponses;
$nbSurveillances = $infos->nbReponsesTotal;
$totPage = ceil($nbSurveillances/$nbAffichage);
$curPage = ceil($position/$nbAffichage);
$firebug->info($listTrier);
$this->view->assign('selectTri', $selectTri);
$this->view->assign('listSources', $permSource);
$this->view->assign('nbReponses', $nbReponses);
$this->view->assign('nbSurveillances', $nbSurveillances);
$this->view->assign('totPage', $totPage);
$this->view->assign('curPage', $curPage);
$this->view->assign('surveillances',$listTrier);
$this->view->assign('source', $source);
}
public function ajouterAction()
{
}
public function listecsvAction(){}
@ -25,16 +163,198 @@ class SurveillanceController extends Zend_Controller_Action
public function portefeuilleAction()
{
$this->view->headLink()->appendStylesheet('/themes/default/styles/surveillance.css', 'all');
$this->view->headScript()
->appendFile('/themes/default/scripts/jquery.qtip.js', 'text/javascript')
->appendFile('/themes/default/scripts/jquery.tablesorter.js', 'text/javascript')
->appendFile('/themes/default/scripts/portefeuille.js', 'text/javascript');
$request = $this->getRequest();
$page = $request->getParam('page', 0);
$tri = $request->getParam('tri', 'siren');
$nbAffichage = 100;
$position = $page*$nbAffichage;
switch ( $tri ){
default:
case 'siren': $triws = 'siren'; break;
case 'rs': $triws = 'rs'; break;
case 'reference': $triws = 'ref'; break;
case 'dateajout': $triws = 'dateAjout'; break;
case 'datederenvoi': $triws = 'dateDerEnvoi'; break;
case 'score' : $triws = 'indiScore'; break;
}
$user = new Utilisateur();
$maxIndiscore = $user->getTypeScore();
$typeScore = ($maxIndiscore == '100') ? '' : '20';
$dicoSource = array(
'ajout' => '',
'bilans1' => 'publication bilan',
'bilans2' => 'publication bilan',
'bodacc' => 'publication bodacc',
'collecte' => 'publication légale',
'dirigeants' => 'modification de l\'administration',
'insee' => 'modification identitaire',
'liens' => 'mise à jour de la structure du groupe',
'default' => 'modification identitaire',
);
$couleurRisque100 = array(
'rouge' => array('min'=>0, 'max'=>40),
'orange' => array('min'=>41, 'max'=>50),
'vert' => array('min'=>51, 'max'=>100),
);
$couleurRisque20 = array(
'rouge' => array('min'=>0, 'max'=>6),
'orange' => array('min'=>7, 'max'=>10),
'vert' => array('min'=>11, 'max'=>20),
);
require_once 'Scores/WsScores.php';
$ws = new WsScores();
$filtre = new stdClass();
$filtre->tri = '';
$filtre->tri = $triws;
$filtre->siret = '';
$filtre->ref = '';
$filtre->rs = '';
$infos = $ws->getPortefeuille($filtre);
$this->view->assign('infos',$infos);
$infos = $ws->getPortefeuille($filtre, $position, $nbAffichage);
$firebug = Zend_Registry::get('firebug');
$firebug->info($infos);
$portefeuille = $infos->result->item;
$tabResult = array();
if ( count($portefeuille)>0 ) {
foreach ( $portefeuille as $item ) {
$result = new stdClass();
$result = $item;
//Classe de risque
$couleurV = ${'couleurRisque'.$maxIndiscore};
foreach($couleurV as $couleur => $intervalle)
{
if($item->{'indiScore'.$typeScore}>=$intervalle['min'] &&
$item->{'indiScore'.$typeScore}<=$intervalle['max']){
break;
}
}
$indiScore = $item->{'indiScore'.$typeScore};
$indiScorePre = empty($item->{'indiScore'.$typeScore.'Pre'}) ?
0 : $item->{'indiScore'.$typeScore.'Pre'};
//Variation du risque
$variation = abs($item->indiScore-$item->indiScorePre);
if($variation>=5 && $variation<=9){
$deg = '45';
}else{
$deg = '';
}
//Tooltip
$tooltip = '';
if($item->procol=='P'){
$tooltip.= 'En procédure collective.<br/>';
}
if($item->actif==0){
$tooltip.= '&Eacute;tablissement inactif.<br/>';
}
$tooltip.= '- Dernier exercice pris en compte : ';
if ($item->dateBilan=='0000-00-00') {
$tooltip.= 'Néant';
} else {
//$tooltip.= 'le '.WDate::dateT('Y-m-d', 'd/m/Y',$item->dateBilan);
}
$tooltip.= '<br/>';
if ($item->sourceModif!='ajout') {
if (!empty($item->sourceModif)) {
$tooltip.= '- Dernière modification ';
if( $item->indiScoreDate=='0000-00-00') {
$tooltip.= '';
} else {
//$tooltip.= 'le '.WDate::dateT('Y-m-d', 'd/m/Y',$item->indiScoreDate);
}
if (!empty($item->sourceModif)) {
if (in_array($item->sourceModif, $dicoSource)) {
$sourceModif = $item->sourceModif;
} else {
$sourceModif = 'default';
}
$tooltip.= ', suite à '.$dicoSource[$sourceModif];
}
$tooltip.= '<br/>';
}
if ($item->indiScoreDatePre!='0000-00-00') {
$tooltip.= '- Précédent score : '.$indiScorePre.'/'.$maxIndiscore;
}
}
$result->tooltip = $tooltip;
//Affichage score
$colScore = '';
if( $item->indiScoreDate!='0000-00-00' &&
$item->procol!='P' && $item->actif!=0)
{
$colScore.= '<span>'.$indiScore.'/'.$maxIndiscore.'</span>';
//Procols
if ($item->procol=='P') {
$colScore.= '<img src="/themes/default/images/portefeuille/score_alert.gif"/>';
//Constant
} elseif($indiScore==$indiScorePre || $item->sourceModif=='ajout') {
$colScore.= '<img src="/themes/default/images/portefeuille/score_'.$couleur.'constant.gif"/>';
//Hausse
} elseif($indiScore>$indiScorePre) {
$colScore.= '<img src="/themes/default/images/portefeuille/score_'.$couleur.'hausse'.$deg.'.gif"/>';
//Baisse
}elseif($indiScore<$indiScorePre){
$colScore.= '<img src="/themes/default/images/portefeuille/score_'.$couleur.'baisse'.$deg.'.gif"/>';
}
} else {
if ($item->procol=='P') {
$colScore.= '<img src="/themes/default/images/portefeuille/score_alert.gif"/>';
} else {
$colScore.= '-';
}
}
$result->colScore = $colScore;
$tabResult[] = $result;
}
}
//Calcul pagination
$nbReponses = $infos->nbReponses;
$nbSurveillances = $infos->nbReponsesTotal;
$totPage = ceil($nbSurveillances/$nbAffichage);
$curPage = ceil($position/$nbAffichage)+1;
$firebug->info($totPage);
$firebug->info($curPage);
$this->view->assign('nbReponses', $nbReponses);
$this->view->assign('nbSurveillances', $nbSurveillances);
$this->view->assign('totPage', $totPage);
$this->view->assign('curPage', $curPage);
$this->view->assign('portefeuille',$tabResult);
}
public function encoursAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
$params = $request->getParams();
}
}

View File

@ -1,7 +1,257 @@
<div id="center">
<pre>
<h1 class="titre">SURVEILLANCE</h1>
<div class="paragraph">
<?php
print_r($this->infos);
if ( $source == '' ){
?>
</pre>
</div>
<table id="info">
<tr>
<td width="200" class="StyleInfoLib">Nombre d'entités affichées</td>
<td><?=$nbEtab?></td>
</tr>
<tr>
<td class="StyleInfoLib">Nombre de surveillances</td>
<td><?=$nbSurveillances?></td>
</tr>
</table>
<?php
} else {
?>
<table id="info">
<tr>
<td class="StyleInfoLib">Nombre de surveillances <?=$source?></td>
<td><?=$nbSurveillances?></td>
</tr>
</table>
<?php
}
?>
</div>
<h2>Extraction des surveillances</h2>
<h2>Options de tri</h2>
<div class="paragraph">
<label>Afficher uniquement les suveillances de type</label>
<select name="type">
<option value="">toutes</option>
<?=$this->selectTri?>
</select>
</div>
<h2>Liste des surveillances</h2>
<div class="paragraph">
<?php if ($this->curPage>1) { ?>
<a href="<?=$this->url(array(
'action' => 'liste',
'page' => $this->curPage-1))
?>" title="Page précédente..."> << </a>
<?php } ?>
<?php if ($this->curPage!=$this->totPage) { ?>
<span>Page <?=$this->curPage+1?>/<?=$this->totPage?></span>
<?php } ?>
<?php if ($this->curPage+1<$this->totPage) { ?>
<a href="<?=$this->url(array(
'action' => 'liste',
'page' => $this->curPage+1))
?>" title="Page suivante..."> >> </a>
<?php } ?>
</div>
<div class="paragraph">
<table class="tablesorter" id="surveillance" width="570">
<thead>
<tr>
<th width="75">Siren</th>
<th width="150">Raison Sociale</th>
<th width="90">Référence</th>
<th width="150">Surveillance</th>
<th width="75">Ajout le</th>
<th width="75">Envoyé le</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->surveillances as $item) {?>
<tr>
<td class="aleft">
<a href="<?=$this->url(array(
'controller' => 'identite',
'action' => 'fiche',
'siret' => $item['siren'].$item['nic'],
))?>"><?=$item['siren']?></a>
</td>
<td>
<?=$item['rs']?><br/><i><?=$item['cp']?> <?=$item['ville']?></i>
</td>
<td>
<?php
foreach ($this->listSources as $source) {
if (isset($item['sources'][$source])) {
foreach ($item['sources'][$source] as $surveillance) {
if ($surveillance['ref'] != '') {
?><p><?=$surveillance['ref']?></p><?php
} else {
?><p>-</p><?php
}
}
} else {
?><p>-</p><?php
}
}
?>
</td>
<td>
<?php
foreach ($this->listSources as $source) {
if (array_key_exists($source, $item['sources'])) {
foreach ($item['sources'][$source] as $surveillance) {
?>
<div class="action">
<p><?=ucfirst($source)?></p>
<a class="dialogsurv"
href="<?=$this->url(array(
'action' => 'ajouter',
'siret' => $item['siren'].$item['nic'],
'source' => $source,
))?>"
title="Ajouter la surveillance <?=$source?>">
<img src="/themes/default/images/interfaces/ajouter.png"/>
</a>
<a class="dialogsurv"
href="<?=$this->url(array(
'action' => 'ajouter',
'siret' => $item['siren'].$item['nic'],
'ref' => $surveillance['ref'],
'email' => $surveillance['email'],
'source' => $source
))?>"
title="Editer la surveillance <?=$source?>">
<img src="/themes/default/images/interfaces/editer.png"/>
</a>
<a href="<?=$this->url(array(
'action' => 'supprimer',
'siret' => $item['siren'].$item['nic'],
'ref' => $surveillance['ref'],
'email' => $surveillance['email'],
'source' => $source
))?>"
title="Supprimer la surveillance <?=$source?>">
<img src="/themes/default/images/interfaces/supprimer.png"/>
</a>
</div>
<?php
}
} else {
?>
<div class="action">
<p><?=ucfirst($source)?></p>
<a class="dialogsurv"
href="<?=$this->url(array(
'action' => 'ajouter',
'siret' => $item['siren'].$item['nic'],
'source' => $source
))?>"
title="Ajouter la surveillance <?=$source?>">
<img src="/themes/default/images/interfaces/ajouter.png"/>
</a>
</div>
<?php
}
?>
<br/>
<?php
}
?>
</td>
<td>
<?php
foreach ($this->listSources as $source) {
if (array_key_exists($source, $item['sources'])) {
foreach ($item['sources'][$source] as $surveillance) {
?>
<p><?=substr($surveillance['dateAjout'], 8, 2).'/'.
substr($surveillance['dateAjout'], 5, 2).'/'.
substr($surveillance['dateAjout'], 0, 4)?></p>
<?php
}
} else {
?><p>-</p><?php
}
}
?>
</td>
<td>
<?php
foreach ($this->listSources as $source) {
if (array_key_exists($source, $item['sources'])) {
foreach ($item['sources'][$source] as $surveillance) {
$pDate = substr($surveillance['dateDerEnvoi'], 8, 2).'/'.
substr($surveillance['dateDerEnvoi'], 5, 2).'/'.
substr($surveillance['dateDerEnvoi'], 0, 4);
if ($pDate != '00/00/0000') {
echo '<p>'.$pDate.'</p>';
} else {
echo '<p>-</p>';
}
}
} else {
echo '<p>-</p>';
}
}
?>
</td>
<?php } ?>
</tbody>
</table>
</div>
<div class="paragraph">
<?php if ($this->curPage>1) { ?>
<a href="<?=$this->url(array(
'action' => 'liste',
'page' => $this->curPage-1))
?>" title="Page précédente..."> << </a>
<?php } ?>
<?php if ($this->curPage!=$this->totPage) { ?>
<span>Page <?=$this->curPage+1?>/<?=$this->totPage?></span>
<?php } ?>
<?php if ($this->curPage+1<$this->totPage) { ?>
<a href="<?=$this->url(array(
'action' => 'liste',
'page' => $this->curPage+1))
?>" title="Page suivante..."> >> </a>
<?php } ?>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('select[name=type]').change(function() {
var value = $(this).val();
window.location.href = '<?=$this->url(array('action'=>'liste'))?>/source/' + value;
});
<?php
if ($source == '') {
?>
$('#surveillance').tablesorter({
headers: {
2: { sorter: false },
3: { sorter: false },
4: { sorter: false },
5: { sorter: false }
}
});
<?php
} else {
?>
$('#surveillance').tablesorter({
headers: {
3: { sorter: false }
}
});
<?php
}
?>
});
</script>

View File

@ -1,7 +1,140 @@
<div id="center">
<pre>
<h1 class="titre">PORTEFEUILLE</h1>
<div class="paragraph">
<table id="info">
<tr>
<td width="200" class="StyleInfoLib">Nombre d'entités affichées</td>
<td><?=$this->nbReponses?></td>
</tr>
<tr>
<td class="StyleInfoLib">Nombre de surveillances</td>
<td><?=$this->nbSurveillances?></td>
</tr>
</table>
</div>
<h2>Exportation de votre portefeuille</h2>
<div class="paragraph"></div>
<h2>Options de tri</h2>
<div class="paragraph"></div>
<h2>Surveillance Score</h2>
<div class="paragraph">
<?php if ($this->curPage>1) { ?>
<a href="<?=$this->url(array(
'action' => 'portefeuille',
'page' => $this->curPage-1))
?>" title="Page précédente..."> << </a>
<?php } ?>
<?php if ($this->curPage!=$this->totPage) { ?>
<span>Page <?=$this->curPage+1?>/<?=$this->totPage+1?></span>
<?php } ?>
<?php if ($this->curPage<$this->totPage) { ?>
<a href="<?=$this->url(array(
'action' => 'portefeuille',
'page' => $this->curPage+1))
?>" title="Page suivante..."> >> </a>
<?php } ?>
</div>
<div class="paragraph">
<?php
print_r($this->infos);
if (count($this->portefeuille)>0) {
?>
</pre>
<table class="tablesorter" id="surveillance">
<thead>
<tr>
<th>Siren</th>
<th>Raison Sociale</th>
<th>Référence</th>
<th class="score">Score</th>
<th>Encours demandé</th>
<th>Encours conseillé</th>
</tr>
</thead>
<tbody>
<?php foreach ( $this->portefeuille as $item ){ ?>
<tr>
<td>
<a href="<?=$this->url(array(
'controller' => 'identite',
'action' => 'fiche',
'siret' => $item->siren));?>">
<?=$item->siren?>
</a>
</td>
<td width="110">
<?=$item->rs?><br/>
<i><?=$item->cp.' '.$item->ville?></i>
</td>
<td>
<p><?=$item->ref?></p>
</td>
<td class="tooltip" title="<?=$item->tooltip?>">
<div class="align_image"><?=$item->colScore?></div>
</td>
<td class="encours set">
<div class="valign">
<?php
if( $item->indiScoreDate!='0000-00-00' &&
$item->procol!='P' && $item->actif!=0)
{
?>
<a class="dialogsurv editencours" href="<?=$this->url(array(
'action' => 'encours',
'siret' => $item->siren.$item->nic,
'ref' => $item->ref,
'email' => $item->email));
?>" title="Editer encours">
<img src="/themes/default/images/interfaces/editer.png"/>
</a>
<span>
<?php if(!empty($item->encoursClient)) { ?>
<?=number_format(round($item->encoursClient/1000), 0, ',', ' ')?> K&euro;
<?php }else{ ?> - <?php }
}else{ ?> - <?php }
?>
</span>
</div>
</td>
<?php
if( $item->indiScoreDate!='0000-00-00' && $item->procol!='P' && $item->actif!=0) {
?>
<td class="encours" title="Précédent :
<?=number_format(round($item->encoursPre/1000), 0, ',', ' ')?>
K&euro;">
<?=number_format(round($item->encours/1000), 0, ',', ' ')?> K&euro;
</td>
<?php }else{ ?>
<td class="encours">-</td>
<?php } ?>
</tr>
<?php }?>
</tbody>
</table>
<?php } else {?>
Aucune surveillance Score.
<?php }?>
</div>
<div class="paragraph">
<?php if ($this->curPage>1) { ?>
<a href="<?=$this->url(array(
'action' => 'portefeuille',
'page' => $this->curPage-1))
?>" title="Page précédente..."> << </a>
<?php } ?>
<?php if ($this->curPage!=$this->totPage) { ?>
<span>Page <?=$this->curPage+1?>/<?=$this->totPage+1?></span>
<?php } ?>
<?php if ($this->curPage<$this->totPage) { ?>
<a href="<?=$this->url(array(
'action' => 'portefeuille',
'page' => $this->curPage+1))
?>" title="Page suivante..."> >> </a>
<?php } ?>
</div>
</div>