2012-02-02 17:29:14 +00:00
|
|
|
<?php
|
|
|
|
Class Object_Dashboard
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
|
|
|
$criteresM = new Table_Criteres();
|
|
|
|
$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 Table_Comptages();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return ($results);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function menu()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function ciblage($page)
|
|
|
|
{
|
|
|
|
$offset = 20;
|
|
|
|
//Liste des ciblages par paquet de n
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
|
|
|
$db = Zend_Registry::get('db');
|
|
|
|
|
|
|
|
$criteresM = new Table_Criteres($db);
|
|
|
|
|
|
|
|
//Compter le nombre de page
|
|
|
|
$sql = $criteresM->select()
|
2012-02-15 09:25:21 +00:00
|
|
|
->from($criteresM, array('nb' => 'COUNT(*)'))
|
|
|
|
->where("idClient = ?", $user->idClient)
|
|
|
|
->where("login = ?", $user->username);
|
2012-02-02 17:29:14 +00:00
|
|
|
$count = $criteresM->fetchRow($sql);
|
|
|
|
$nbCiblage = $count->nb;
|
|
|
|
|
|
|
|
//Récupérer les informations
|
|
|
|
$position = ($page-1)*$offset+1;
|
|
|
|
$sql = $criteresM->select()
|
2012-02-15 09:25:21 +00:00
|
|
|
->from($criteresM, array('id', 'reference', 'dateAjout'))
|
|
|
|
->where("idClient = ?", $user->idClient)
|
|
|
|
->where("login = ?", $user->username)
|
|
|
|
->order('dateAjout DESC')
|
|
|
|
->limitPage($position, $offset);
|
2012-02-02 17:29:14 +00:00
|
|
|
|
|
|
|
$rows = $criteresM->fetchAll($sql);
|
|
|
|
$results = array();
|
|
|
|
$comptagesM = new Table_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (array('ciblages' => $results, 'nbCiblage' => $nbCiblage));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function ciblagedetail($id)
|
|
|
|
{
|
2012-02-15 09:25:21 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
$table = new Table_Criteres();
|
|
|
|
$sql = $table->select()
|
|
|
|
->where('idClient = ?', $user->idClient)
|
|
|
|
->where('login = ?', $user->username)
|
|
|
|
->where('id = ?', $id);
|
2012-02-02 17:29:14 +00:00
|
|
|
|
2012-02-15 09:25:21 +00:00
|
|
|
$criteres = $table->fetchRow($sql)->toArray();
|
2012-02-02 17:29:14 +00:00
|
|
|
if ($criteres != null){
|
2012-02-15 09:25:21 +00:00
|
|
|
$comptage = new Table_Comptages();
|
|
|
|
$sql = $comptage->select()
|
2012-02-02 17:29:14 +00:00
|
|
|
->where('idDefinition = ?', $id);
|
2012-02-15 09:25:21 +00:00
|
|
|
$comptages = $comptage->fetchAll($sql)->toArray();
|
2012-02-02 17:29:14 +00:00
|
|
|
}
|
2012-02-15 09:25:21 +00:00
|
|
|
return (array_merge(array('comptages' => $comptages), array('criteres' => $criteres)));
|
2012-02-02 17:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function rcomptage($q)
|
|
|
|
{
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
|
|
|
$criteresM = new Table_Criteres($db);
|
|
|
|
$sql = $criteresM->select()
|
|
|
|
->from($criteresM, array('id', 'reference', "DATE_FORMAT(dateAjout, '%d/%m/%Y') as date"))
|
|
|
|
->where("idClient = ?", $user->idClient)
|
|
|
|
->where("login = ?", $user->username)
|
|
|
|
->where("reference LIKE ?", $q.'%');
|
|
|
|
$rows = $criteresM->fetchAll($sql);
|
|
|
|
if (count($rows)>0){
|
|
|
|
$separator = " , ";
|
|
|
|
foreach ($rows as $item) {
|
|
|
|
$output[] = array(
|
|
|
|
'label' => $item->reference . $separator . $item->date,
|
|
|
|
'value' => $item->reference,
|
|
|
|
'url' => $this->view->url(array('controller'=>'dashboard', 'action'=>'ciblagedetail', 'id'=>$item->id)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (json_encode($output));
|
|
|
|
}
|
|
|
|
}
|