Affichage du tableau de bord

This commit is contained in:
Michael RICOIS 2012-01-05 13:59:50 +00:00
parent b30e19af3d
commit 34c3e028cd
2 changed files with 118 additions and 3 deletions

View File

@ -13,17 +13,92 @@ class DashboardController extends Zend_Controller_Action
public function indexAction()
{
//Liste des derniers comptages
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$db = Zend_Registry::get('db');
$criteresM = new Application_Model_Criteres($db);
$sql = $criteresM->select(true)
->columns(array('id', 'reference', 'dateAjout'))
->where("idClient = ?", $user->idClient)
->where("login = ?", $user->username)
->order('dateAjout DESC')
->limit(5);
$rows = $criteresM->fetchAll($sql);
$results = array();
$comptagesM = new Application_Model_Comptages($db);
foreach($rows->toArray() as $item)
{
$info = array(
'id' => $item['id'],
'reference' => $item['reference'],
'dateCriteres' => $item['dateAjout'],
);
//Recherche des comptages
$sql = $comptagesM->select(true)
->columns(array('resultat', 'uniteInsee', 'dateAjout'))
->where('idDefinition = ?', $item['id'])
->order('dateAjout DESC')->limit(1);
$comptage = $comptagesM->fetchAll($sql)->toArray();
if (count($comptage)>0){
$info['resultat'] = $comptage[0]['resultat'];
$info['uniteInsee'] = $comptage[0]['uniteInsee'];
$info['dateComptage'] = $comptage[0]['dateAjout'];
}
$results[] = $info;
}
$this->view->assign('comptages', $results);
//Rechercher un comptage
}
public function menuAction()
{
}
/**
* Affiche la liste des comptages
* Enter description here ...
*/
public function comptagesAction(){}
public function comptagesAction()
{
$request = $this->getRequest();
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$db = Zend_Registry::get('db');
$criteresM = new Application_Model_Criteres($db);
$sql = $criteresM->select()
->columns(array('id', 'reference', 'dateAjout'))
->where("idClient = ? AND login = ?", array($user->idClient, $user->username))
->order('dateAjout DESC')
->limit(1,5);
$rows = $criteresM->fetchAll($sql);
$results = array();
$comptagesM = new Application_Model_Comptages();
foreach($rows->toArray() as $item) {
//Recherche des comptages
$sql = $comptagesM->select()
->columns(array('resultat', 'uniteInsee', 'tarif', 'dateAjout'))
->where('idDefinition = ?', $item['id'])
->order('dateAjout DESC')->limit(1);
$comptage = $comptagesM->fetchRow($sql)->toArray();
$results = array_merge($item, $comptage);
}
$this->view->assign('comptages', $results);
}
/**
* Affiche le détail du comptage

View File

@ -1,8 +1,48 @@
<div style="background-color:#ffffff;padding:5px;">
<div class="chemin">
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>''))?>">Tableau de bord</a>
</div>
<div>
Historique de vos ciblages - Profil d'exportation - Préférences et configuration de l'application
</div>
<div style="margin:5px 0;">
<h2>Vos 5 derniers ciblages</h2>
<p>Aucune ciblage.<p>
<h2>Vos derniers ciblages</h2>
<?php if(count($this->comptages)>0):?>
<table class="ciblage">
<thead>
<tr>
<th>Référence</th>
<th>Nombre d'entité</th>
<th>Unité Insee</th>
<th>Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($this->comptages as $item):?>
<tr>
<td><?=$item['reference']?></td>
<td><?=number_format($item['resultat'], 0, ',', ' ')?></td>
<td><?=number_format($item['uniteInsee'], 0, ',', ' ')?></td>
<td><?=$item['dateComptage']?></td>
<td>
[<a href="<?=$this->url(array('controller'=> 'index','action'=>'criteres', 'id'=>$item['id']))?>">Recharger les critères de ciblage</a>] -
[<a href="<?=$this->url(array('controller'=> 'comptage','action'=>'update', 'id'=>$item['id']))?>">Actualiser le comptage</a>]
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php else:?>
<p>Aucun ciblage.<p>
<?php endif;?>
</div>
<div style="margin:5px 0;">