2012-02-02 17:29:14 +00:00
|
|
|
<?php
|
2012-05-02 18:19:07 +00:00
|
|
|
class DashboardController extends Zend_Controller_Action
|
2012-02-02 17:29:14 +00:00
|
|
|
{
|
|
|
|
public function init()
|
|
|
|
{
|
2013-10-10 11:49:08 +00:00
|
|
|
$this->view->headLink()
|
2014-07-16 19:02:47 +00:00
|
|
|
->appendStylesheet('/themes/default/styles/dashboard.css', 'all');
|
2013-10-10 11:49:08 +00:00
|
|
|
$this->view->headScript()
|
2014-07-16 19:02:47 +00:00
|
|
|
->appendFile('/themes/default/scripts/dashboard.js', 'text/javascript');
|
2012-02-02 17:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function indexAction()
|
|
|
|
{
|
2012-05-16 15:52:34 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
2013-03-19 08:45:27 +00:00
|
|
|
$criteresM = new Application_Model_CiblageCriteres();
|
2012-05-16 15:52:34 +00:00
|
|
|
$sql = $criteresM->select()
|
|
|
|
->from($criteresM, array('id', 'reference', 'dateAjout'))
|
|
|
|
->where("idClient = ?", $user->idClient)
|
|
|
|
->where("login = ?", $user->username)
|
|
|
|
->order('dateAjout DESC')
|
|
|
|
->limit(5);
|
|
|
|
|
|
|
|
$rows = $criteresM->fetchAll($sql);
|
|
|
|
|
2012-05-17 19:44:16 +00:00
|
|
|
//
|
2012-05-16 15:52:34 +00:00
|
|
|
$results = array();
|
2013-03-19 08:45:27 +00:00
|
|
|
$comptagesM = new Application_Model_CiblageComptages();
|
2012-05-16 15:52:34 +00:00
|
|
|
foreach($rows->toArray() as $item)
|
|
|
|
{
|
|
|
|
$info = array(
|
|
|
|
'id' => $item['id'],
|
|
|
|
'reference' => $item['reference'],
|
|
|
|
'dateCriteres' => $item['dateAjout'],
|
|
|
|
);
|
|
|
|
//Recherche des comptages
|
|
|
|
$sql = $comptagesM->select()
|
|
|
|
->from($comptagesM, array('resultat', 'uniteInsee', "DATE_FORMAT(dateAjout, '%Y/%m/%d %H:%i:%s') as 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;
|
|
|
|
}
|
2012-05-02 18:19:07 +00:00
|
|
|
|
2012-05-16 15:52:34 +00:00
|
|
|
$this->view->comptages = $results;
|
|
|
|
|
2012-05-17 19:44:16 +00:00
|
|
|
//
|
2013-03-19 08:45:27 +00:00
|
|
|
$enrichissements = new Application_Model_CiblageEnrichissementIdentifiants();
|
2012-05-16 15:52:34 +00:00
|
|
|
$sql = $enrichissements->select()
|
|
|
|
->setIntegrityCheck(false)
|
|
|
|
->from(
|
|
|
|
array('i' => 'enrichissement_identifiants'),
|
|
|
|
array('id', 'reference', 'fichier', 'nbLigneTotales', 'nbLigneTraites', 'error', 'dateAdded', 'dateStart', 'dateStop')
|
|
|
|
)
|
|
|
|
->join(
|
2012-06-29 10:15:12 +00:00
|
|
|
array('c' => 'ciblage_criteres'), 'i.idCriteres = c.id',
|
2012-05-16 15:52:34 +00:00
|
|
|
array('')
|
|
|
|
)
|
2012-05-17 19:44:16 +00:00
|
|
|
->where('c.idClient = ?', $user->idClient)
|
|
|
|
->where('c.login = ?', $user->username)
|
|
|
|
->order('i.dateAdded DESC');
|
2012-05-16 15:52:34 +00:00
|
|
|
|
|
|
|
$this->view->enrichissements = $enrichissements->fetchAll($sql);
|
2014-07-01 13:53:58 +00:00
|
|
|
|
2012-02-02 17:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function ciblagesAction()
|
|
|
|
{
|
2012-05-16 15:52:34 +00:00
|
|
|
|
2012-02-02 17:29:14 +00:00
|
|
|
$request = $this->getRequest();
|
2012-05-16 15:52:34 +00:00
|
|
|
$page = $request->getParam('page', 1);
|
|
|
|
|
|
|
|
|
|
|
|
$offset = 20;
|
|
|
|
//Liste des ciblages par paquet de n
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
2013-03-19 08:45:27 +00:00
|
|
|
$criteresM = new Application_Model_CiblageCriteres();
|
2012-05-16 15:52:34 +00:00
|
|
|
|
|
|
|
//Compter le nombre de page
|
|
|
|
$sql = $criteresM->select()
|
2013-01-09 13:40:11 +00:00
|
|
|
->from($criteresM, array('nb' => 'COUNT(*)'))
|
|
|
|
->where("idClient = ?", $user->idClient)
|
|
|
|
->where("login = ?", $user->username);
|
2012-05-16 15:52:34 +00:00
|
|
|
$count = $criteresM->fetchRow($sql);
|
|
|
|
$nbCiblage = $count->nb;
|
|
|
|
|
|
|
|
//Récupérer les informations
|
|
|
|
$position = ($page-1)*$offset+1;
|
|
|
|
$sql = $criteresM->select()
|
2013-10-10 11:49:08 +00:00
|
|
|
->from($criteresM, array('id', 'reference', 'dateAjout'))
|
|
|
|
->where("idClient = ?", $user->idClient)
|
|
|
|
->where("login = ?", $user->username)
|
|
|
|
->order('dateAjout DESC')
|
|
|
|
->limitPage($position, $offset);
|
2012-05-16 15:52:34 +00:00
|
|
|
|
|
|
|
$rows = $criteresM->fetchAll($sql);
|
|
|
|
$results = array();
|
2013-03-19 08:45:27 +00:00
|
|
|
$comptagesM = new Application_Model_CiblageComptages();
|
2012-05-16 15:52:34 +00:00
|
|
|
foreach($rows->toArray() as $item)
|
|
|
|
{
|
|
|
|
$info = array(
|
|
|
|
'id' => $item['id'],
|
|
|
|
'reference' => $item['reference'],
|
|
|
|
'dateCriteres' => $item['dateAjout'],
|
|
|
|
);
|
|
|
|
//Recherche des comptages
|
|
|
|
$sql = $comptagesM->select()
|
|
|
|
->from($comptagesM, array('resultat', 'uniteInsee', "DATE_FORMAT(dateAjout, '%d/%m/%Y %H:%i:%s') as 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->ciblages = $results;
|
|
|
|
$this->view->nbCiblage = $nbCiblage;
|
2012-02-02 17:29:14 +00:00
|
|
|
|
2013-10-10 11:49:08 +00:00
|
|
|
$this->view->page = $page;
|
|
|
|
$this->view->nbPages = ceil($nbCiblage/$offset);
|
2012-02-02 17:29:14 +00:00
|
|
|
}
|
|
|
|
|
2012-02-27 08:31:19 +00:00
|
|
|
public function ciblageAction()
|
2012-02-02 17:29:14 +00:00
|
|
|
{
|
|
|
|
$request = $this->getRequest();
|
2015-01-23 14:39:25 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
2012-05-15 11:38:51 +00:00
|
|
|
|
|
|
|
$comptageId = $request->getParam('id');
|
|
|
|
|
|
|
|
//Lecture des paramètres du ciblage
|
2013-03-19 08:45:27 +00:00
|
|
|
$criteresM = new Application_Model_CiblageCriteres();
|
2012-05-15 11:38:51 +00:00
|
|
|
$sql = $criteresM->select()
|
|
|
|
->where('idClient = ?', $user->idClient)
|
|
|
|
->where('login = ?', $user->username)
|
|
|
|
->where('id = ?', $comptageId);
|
|
|
|
$criteres = $criteresM->fetchRow($sql)->toArray();
|
2013-01-09 13:40:11 +00:00
|
|
|
|
2012-05-15 11:38:51 +00:00
|
|
|
$infosCriteres = array();
|
|
|
|
if ($criteres != null) {
|
2012-06-26 14:25:43 +00:00
|
|
|
$comptageRef = $criteres['reference'];
|
2013-01-09 13:40:11 +00:00
|
|
|
|
2012-05-15 11:38:51 +00:00
|
|
|
$decodeCriteres = json_decode($criteres['criteres'], true);
|
|
|
|
|
2014-07-01 13:53:58 +00:00
|
|
|
$fields = new Scores_Ciblage_FieldList();
|
|
|
|
$sessionValue = new Scores_Ciblage_Session($fields);
|
|
|
|
$sessionValue->setSelectedValues($decodeCriteres, false);
|
|
|
|
|
|
|
|
//Construction affichage des critères
|
|
|
|
$infosCriteres = array();
|
|
|
|
$allFields = $fields->getItems(true);
|
2015-01-23 14:39:25 +00:00
|
|
|
foreach ( $allFields as $key => $params )
|
|
|
|
{
|
2014-07-01 13:53:58 +00:00
|
|
|
$valueSelected = $sessionValue->getSelectedValue($key);
|
2015-01-23 14:39:25 +00:00
|
|
|
if ( $valueSelected !== null ) {
|
|
|
|
|
|
|
|
$isMultiple = $fields->isMultiple($key);
|
|
|
|
|
|
|
|
$inValue = array();
|
|
|
|
if ( array_key_exists('in', $valueSelected) ) {
|
|
|
|
$inValue = $valueSelected['in'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$exValue = array();
|
|
|
|
if ( array_key_exists('in', $valueSelected) ) {
|
|
|
|
$exValue = $valueSelected['ex'];
|
|
|
|
}
|
|
|
|
|
|
|
|
Zend_Registry::get('firebug')->info($key);
|
|
|
|
Zend_Registry::get('firebug')->info($inValue);
|
|
|
|
|
2014-07-01 13:53:58 +00:00
|
|
|
$inLabel = array();
|
2015-01-23 14:39:25 +00:00
|
|
|
if ( is_array($inValue) && count($inValue) > 0 ) {
|
2014-07-01 13:53:58 +00:00
|
|
|
foreach ( $inValue as $value ) {
|
2015-01-23 14:39:25 +00:00
|
|
|
if ( $isMultiple === true ) {
|
|
|
|
$inLabel[] = $fields->labelValueDetail($key, $value);
|
|
|
|
}
|
|
|
|
else if ( array_key_exists($value, $params['values']) ) {
|
2014-07-01 13:53:58 +00:00
|
|
|
$inLabel[] = $params['values'][$value];
|
|
|
|
}
|
|
|
|
}
|
2015-01-23 14:39:25 +00:00
|
|
|
} else {
|
|
|
|
if ( array_key_exists($inValue, $params['values']) ) {
|
|
|
|
$inLabel[] = $params['values'][$inValue];
|
|
|
|
}
|
2014-07-01 13:53:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$exLabel = array();
|
2015-01-23 14:39:25 +00:00
|
|
|
if ( is_array($exValue) && count($exValue)>0 ) {
|
2014-07-01 13:53:58 +00:00
|
|
|
foreach ( $exValue as $value ) {
|
2015-01-23 14:39:25 +00:00
|
|
|
if ( $isMultiple === true ) {
|
|
|
|
$inLabel[] = $fields->labelValueDetail($key, $value);
|
|
|
|
}
|
|
|
|
else if ( array_key_exists($value, $params['values']) ) {
|
2014-07-01 13:53:58 +00:00
|
|
|
$exLabel[] = $params['values'][$value];
|
|
|
|
}
|
|
|
|
}
|
2015-01-23 14:39:25 +00:00
|
|
|
} else {
|
|
|
|
if ( array_key_exists($exValue, $params['values']) ) {
|
|
|
|
$exLabel[] = $params['values'][$inValue];
|
|
|
|
}
|
2014-07-01 13:53:58 +00:00
|
|
|
}
|
2015-01-23 14:39:25 +00:00
|
|
|
|
2014-07-01 13:53:58 +00:00
|
|
|
|
|
|
|
$infosCriteres[$key] = array(
|
|
|
|
'label' => $params['label'],
|
|
|
|
'in' => $inLabel,
|
|
|
|
'ex' => $exLabel,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2012-05-15 11:38:51 +00:00
|
|
|
|
|
|
|
//Lecture des comptages
|
2013-03-19 08:45:27 +00:00
|
|
|
$comptageM = new Application_Model_CiblageComptages();
|
2012-05-15 11:38:51 +00:00
|
|
|
$sql = $comptageM->select()
|
|
|
|
->where('idDefinition = ?', $comptageId)
|
|
|
|
->order('dateAjout DESC');
|
|
|
|
$comptages = $comptageM->fetchAll($sql)->toArray();
|
|
|
|
|
|
|
|
//Lecture enrichissement existe
|
2013-03-19 08:45:27 +00:00
|
|
|
$enrichissementsM = new Application_Model_CiblageEnrichissementIdentifiants();
|
2012-06-26 14:25:43 +00:00
|
|
|
$sql = $enrichissementsM->select()
|
|
|
|
->where('idCriteres = ?', $comptageId);
|
2013-01-09 13:40:11 +00:00
|
|
|
|
2012-06-26 14:25:43 +00:00
|
|
|
$enrichissements = $enrichissementsM->fetchAll($sql);
|
2013-01-09 13:40:11 +00:00
|
|
|
|
2012-05-15 11:38:51 +00:00
|
|
|
//Affichage
|
2012-06-26 14:25:43 +00:00
|
|
|
$this->view->comptageId = $comptageId;
|
|
|
|
$this->view->comptageRef = $comptageRef;
|
2012-05-15 11:38:51 +00:00
|
|
|
$this->view->criteres = $infosCriteres;
|
|
|
|
$this->view->comptages = $comptages;
|
2012-06-26 14:25:43 +00:00
|
|
|
$this->view->enrichissements = $enrichissements;
|
2012-05-15 11:38:51 +00:00
|
|
|
}
|
2012-02-02 17:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function rcomptageAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
2012-05-02 18:19:07 +00:00
|
|
|
|
2012-02-02 17:29:14 +00:00
|
|
|
$request = $this->getRequest();
|
2012-02-15 10:35:07 +00:00
|
|
|
$q = $request->getParam('q');
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
2012-05-02 18:19:07 +00:00
|
|
|
|
2013-03-19 08:45:27 +00:00
|
|
|
$criteresM = new Application_Model_CiblageCriteres();
|
2012-02-15 10:35:07 +00:00
|
|
|
$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,
|
2012-02-27 08:31:19 +00:00
|
|
|
'url' => $this->view->url(array('controller'=>'dashboard', 'action'=>'ciblage', 'id'=>$item->id)),
|
2012-02-15 10:35:07 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo json_encode($output);
|
2012-02-02 17:29:14 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 11:35:18 +00:00
|
|
|
/**
|
|
|
|
* Liste des enrichissements
|
|
|
|
*/
|
|
|
|
public function enrichissementsAction()
|
2012-02-02 17:29:14 +00:00
|
|
|
{
|
2012-02-24 16:26:20 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
//Criteres => Comptages (last) => enrichissement_identifiants => enrichissement_commandes
|
2013-03-19 08:45:27 +00:00
|
|
|
$enrichissementsM = new Application_Model_CiblageEnrichissementIdentifiants();
|
2012-02-24 15:32:15 +00:00
|
|
|
|
2012-05-16 15:52:34 +00:00
|
|
|
// Pending
|
2012-02-24 15:32:15 +00:00
|
|
|
$sql = $enrichissementsM->select()
|
|
|
|
->setIntegrityCheck(false)
|
|
|
|
->from(
|
2012-02-24 16:26:20 +00:00
|
|
|
array('i' => 'enrichissement_identifiants'),
|
2012-02-27 09:36:49 +00:00
|
|
|
array('id', 'reference', 'fichier', 'nbLigneTotales', 'nbLigneTraites', 'error', 'dateAdded', 'dateStart', 'dateStop')
|
2012-02-24 15:32:15 +00:00
|
|
|
)
|
2012-04-05 08:19:57 +00:00
|
|
|
->join(
|
2012-09-10 08:08:53 +00:00
|
|
|
array('c' => 'ciblage_comptages'), 'i.idComptage = c.id',
|
2012-02-24 16:26:20 +00:00
|
|
|
array('')
|
|
|
|
)
|
2012-04-05 08:19:57 +00:00
|
|
|
->join(
|
2012-09-10 08:08:53 +00:00
|
|
|
array('criteres' => 'ciblage_criteres'), 'i.idCriteres = criteres.id',
|
2012-02-24 16:26:20 +00:00
|
|
|
array('')
|
2012-02-24 17:11:41 +00:00
|
|
|
);
|
2012-02-27 09:36:49 +00:00
|
|
|
$sql->where('i.dateStop = ?', 0)
|
2012-02-24 16:26:20 +00:00
|
|
|
->where('criteres.idClient = ?', $user->idClient)
|
|
|
|
->where('criteres.login = ?', $user->username);
|
2012-02-24 15:32:15 +00:00
|
|
|
$encours = $enrichissementsM->fetchAll($sql);
|
2012-04-05 08:19:57 +00:00
|
|
|
$this->view->encours = $encours;
|
2012-05-02 18:19:07 +00:00
|
|
|
|
2012-04-05 08:19:57 +00:00
|
|
|
$sql = $enrichissementsM->select()
|
|
|
|
->setIntegrityCheck(false)
|
|
|
|
->from(
|
|
|
|
array('i' => 'enrichissement_identifiants'),
|
|
|
|
array('id', 'reference', 'fichier', 'nbLigneTotales', 'nbLigneTraites', 'error', 'dateAdded', 'dateStart', 'dateStop')
|
|
|
|
)
|
|
|
|
->join(
|
2012-09-10 08:08:53 +00:00
|
|
|
array('c' => 'ciblage_comptages'), 'i.idComptage = c.id',
|
2012-04-05 08:19:57 +00:00
|
|
|
array('')
|
|
|
|
)
|
|
|
|
->join(
|
2012-09-10 08:08:53 +00:00
|
|
|
array('criteres' => 'ciblage_criteres'), 'i.idCriteres = criteres.id',
|
2012-04-05 08:19:57 +00:00
|
|
|
array('')
|
|
|
|
);
|
|
|
|
$sql->where('criteres.idClient = ?', $user->idClient)
|
|
|
|
->where('criteres.login = ?', $user->username)
|
|
|
|
->where('i.dateStart != ?', '0000-00-00 00:00:00');
|
|
|
|
$fini = $enrichissementsM->fetchAll($sql)->toArray();
|
|
|
|
$this->view->fini = $fini;
|
2012-04-12 09:25:37 +00:00
|
|
|
$this->view->pathfile = $config->path->data;
|
2012-02-02 17:29:14 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 11:35:18 +00:00
|
|
|
/**
|
|
|
|
* Détail d'un enrichissment
|
|
|
|
*/
|
|
|
|
public function enrichissementAction()
|
|
|
|
{
|
2012-05-02 18:19:07 +00:00
|
|
|
|
|
|
|
}
|
2012-05-25 13:24:30 +00:00
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
/**
|
|
|
|
* Display information about user's profil
|
|
|
|
*/
|
2012-05-25 13:24:30 +00:00
|
|
|
public function configurationAction()
|
|
|
|
{
|
2012-06-12 10:00:42 +00:00
|
|
|
|
|
|
|
//User's params
|
2012-05-28 15:17:18 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
|
|
|
if (array_key_exists('filter', $user->preferences) && count($user->preferences['filter'])>0) {
|
|
|
|
$liste = $user->preferences['filter'];
|
|
|
|
foreach ( $liste as $name => $value ){
|
|
|
|
$this->view->assign('prefFilter'.ucfirst($name), $value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_key_exists('interface', $user->preferences) && count($user->preferences['interface'])>0) {
|
|
|
|
$liste = $user->preferences['interface'];
|
|
|
|
foreach ( $liste as $name => $value ){
|
|
|
|
$this->view->assign('prefInterface'.ucfirst($name), $value);
|
|
|
|
}
|
|
|
|
}
|
2013-01-09 13:40:11 +00:00
|
|
|
|
2012-09-10 09:34:14 +00:00
|
|
|
$timestamp = strtotime( $user->dateContrat );
|
|
|
|
$dateBegin = date( 'd/m/Y', $timestamp );
|
2013-01-09 13:40:11 +00:00
|
|
|
|
2012-09-10 09:34:14 +00:00
|
|
|
$timestamp = mktime(0,0,0,substr($dateBegin,3,2)+$user->periodContrat,substr($dateBegin,0,2), substr($dateBegin,6,4));
|
|
|
|
$dateEnd = date( 'd/m/Y', $timestamp );
|
|
|
|
|
|
|
|
$this->view->assign('dateBegin', $dateBegin);
|
|
|
|
$this->view->assign('dateEnd', $dateEnd);
|
2013-01-09 13:40:11 +00:00
|
|
|
|
2012-06-11 14:40:07 +00:00
|
|
|
//Customer params have an option on the RNCS filter
|
|
|
|
$this->view->assign('filterRNCS', $user->filterRNCS);
|
2012-09-10 09:34:14 +00:00
|
|
|
$this->view->assign('licenceINSEE', $user->licenceINSEE);
|
|
|
|
$this->view->assign('immediatExtract', $user->immediatExtract);
|
2013-01-09 13:40:11 +00:00
|
|
|
|
2012-09-10 09:34:14 +00:00
|
|
|
$tarifText = '';
|
|
|
|
//Tarifs
|
|
|
|
if ($user->forfait!=0) {
|
|
|
|
//Forfait de
|
|
|
|
$tarifText = 'Forfait de '.$user->forfait.' euros';
|
|
|
|
} else {
|
|
|
|
$tarifText = 'Tarif unitaire à la ligne de '.$user->priceLine.' euros';
|
|
|
|
}
|
2013-01-09 13:40:11 +00:00
|
|
|
|
2012-09-10 09:34:14 +00:00
|
|
|
//Paramètres
|
|
|
|
if ( $user->limitFiles!=0 && $user->limitLines!=0 ) {
|
|
|
|
$tarifText.= ' limité à '.$user->limitFiles.' fichiers et à '.$user->limitLines.' lignes par fichier.';
|
|
|
|
} elseif ( $user->limitFiles!=0 && $user->limitLines==0 ) {
|
|
|
|
$tarifText.= ' limité à '.$user->limitFiles.' fichiers';
|
|
|
|
} elseif ( $user->limitFiles==0 && $user->limitLines!=à ) {
|
|
|
|
$tarifText.= ' limité à '.$user->limitLines.' lignes par fichier.';
|
|
|
|
}
|
|
|
|
$this->view->assign('tarifText', $tarifText);
|
2012-06-12 10:00:42 +00:00
|
|
|
|
|
|
|
//List of data to extract
|
2013-03-19 08:45:27 +00:00
|
|
|
$profilsM = new Application_Model_CiblageEnrichissementProfils();
|
2012-06-12 10:00:42 +00:00
|
|
|
$sql = $profilsM->select()
|
|
|
|
->where('login = ?', $user->username)
|
|
|
|
->where('idClient = ?', $user->idClient);
|
|
|
|
$result = $profilsM->fetchRow($sql);
|
|
|
|
if ($result) {
|
|
|
|
$criteres = json_decode($result['criteres'], true);
|
2014-07-16 19:02:47 +00:00
|
|
|
$enrichissement = new Scores_Ciblage_Extract();
|
|
|
|
$data = $enrichissement->getFields();
|
2012-06-12 10:00:42 +00:00
|
|
|
$profilLabels = array();
|
|
|
|
foreach ( $data as $key => $item ) {
|
|
|
|
if (in_array($key, $criteres)) {
|
|
|
|
$profilLabels[] = $item['label'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$profil = new stdClass();
|
|
|
|
$profil->labels = $profilLabels;
|
|
|
|
$profil->reference = $result['reference'];
|
|
|
|
$this->view->assign('profil', $profil);
|
|
|
|
}
|
|
|
|
|
2012-05-25 13:24:30 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
/**
|
|
|
|
* Set preferences
|
|
|
|
*/
|
|
|
|
public function prefAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
2012-02-02 17:29:14 +00:00
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$user = $auth->getIdentity();
|
2012-02-02 17:29:14 +00:00
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
//Read prefs table to load actual config
|
2013-03-19 08:45:27 +00:00
|
|
|
$prefsM = new Application_Model_CiblagePrefs();
|
2012-06-01 14:36:43 +00:00
|
|
|
$userPrefs = $prefsM->find($user->username);
|
2012-02-02 17:29:14 +00:00
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
if ($userPrefs) {
|
2012-06-01 14:36:43 +00:00
|
|
|
$data = json_decode($userPrefs->current()->json, true);
|
2012-05-28 12:46:52 +00:00
|
|
|
} else {
|
2012-06-12 10:00:42 +00:00
|
|
|
$data = array('interface'=>array(),'filter'=>array());
|
2012-05-28 12:46:52 +00:00
|
|
|
$prefsM->insert(array('login'=>$user->username, 'json'=>json_encode($data)));
|
|
|
|
}
|
2012-02-02 17:29:14 +00:00
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$sendParam = $request->getParams();
|
2012-02-02 17:29:14 +00:00
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
$prefsFilter = array('rncs');
|
|
|
|
$prefsInterface = array('insee');
|
2012-02-02 17:29:14 +00:00
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
$filter = array();
|
2012-06-12 10:00:42 +00:00
|
|
|
foreach ( $prefsFilter as $item ) {
|
2012-05-28 12:46:52 +00:00
|
|
|
if (array_key_exists($item, $sendParam)) {
|
2012-05-28 15:17:18 +00:00
|
|
|
$filter = array($item => $sendParam[$item]);
|
2012-05-28 12:46:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (array_key_exists('filter', $data)) {
|
|
|
|
$filter = array_merge($data['filter'], $filter);
|
|
|
|
}
|
|
|
|
$data['filter'] = $filter;
|
|
|
|
|
|
|
|
$interface = array();
|
2012-06-12 10:00:42 +00:00
|
|
|
foreach ( $prefsInterface as $item ) {
|
2012-05-28 12:46:52 +00:00
|
|
|
if (array_key_exists($item, $sendParam)) {
|
2012-05-28 15:17:18 +00:00
|
|
|
$interface = array($item => $sendParam[$item]);
|
2012-05-28 12:46:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (array_key_exists('interface', $data)) {
|
|
|
|
$interface = array_merge($data['interface'], $interface);
|
|
|
|
}
|
|
|
|
$data['interface'] = $interface;
|
|
|
|
$newjson = json_encode($data);
|
|
|
|
|
|
|
|
$nbRow = $prefsM->update(array('json'=>$newjson), "login='".$user->username."'");
|
|
|
|
|
2012-06-11 14:40:07 +00:00
|
|
|
//Don't forget to save new preferences in session
|
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
$this->view->assign('nbRow', $nbRow);
|
|
|
|
}
|
2012-02-02 17:29:14 +00:00
|
|
|
|
|
|
|
|
2012-05-28 12:46:52 +00:00
|
|
|
}
|