98 lines
3.1 KiB
PHP
98 lines
3.1 KiB
PHP
<?php
|
|
class FieldsController extends Zend_Controller_Action
|
|
{
|
|
/**
|
|
* Display fields
|
|
*/
|
|
public function indexAction()
|
|
{
|
|
$this->view->headLink()
|
|
->appendStylesheet('/libs/tree-3.0.9/themes/default/style.css', 'all')
|
|
->appendStylesheet('/libs/nouislider/jquery.nouislider.min.css', 'all')
|
|
->appendStylesheet('/libs/daterangepicker/daterangepicker-bs3.css', 'all');
|
|
|
|
$this->view->headScript()
|
|
->appendFile('/libs/moment.min.js', 'text/javascript')
|
|
->appendFile('/libs/tree-3.0.9/jstree.min.js', 'text/javascript')
|
|
->appendFile('/libs/nouislider/jquery.nouislider.all.min.js')
|
|
->appendFile('/libs/daterangepicker/daterangepicker.js')
|
|
->appendFile('/themes/default/scripts/scripts.js', 'text/javascript')
|
|
->appendFile('/themes/default/scripts/fields.js', 'text/javascript');
|
|
|
|
$families = array(
|
|
'entreprise',
|
|
'economique',
|
|
'geographique',
|
|
'juridique',
|
|
'financier',
|
|
'chiffrescles',
|
|
);
|
|
|
|
$fields = array();
|
|
|
|
$scoresFields = new Scores_Ciblage_FieldList();
|
|
foreach ( $families as $family ) {
|
|
$fields = $scoresFields->getItemsByFamily($family);
|
|
$this->view->{'Fields'.ucfirst($family)} = $fields;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Manage tag
|
|
*/
|
|
public function tagAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$request = $this->getRequest();
|
|
|
|
//Nom de la clé de ciblage
|
|
$name = $request->getParam('name');
|
|
//Clé pour le lancement de la fonction de recherche
|
|
$key = $request->getParam('key');
|
|
//Query
|
|
$q = strtolower(trim($request->getParam('q')));
|
|
|
|
$scoresFields = new Scores_Ciblage_FieldList();
|
|
$values = $scoresFields->searchValues($name, $q);
|
|
Zend_Registry::get('firebug')->info($values);
|
|
if (count($values) == 0) {
|
|
$values[] = array('label' => 'Aucun résultat.', 'value' => '');
|
|
}
|
|
$this->view->values = $values;
|
|
}
|
|
|
|
/**
|
|
* Manage Tree
|
|
*/
|
|
public function treeAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
$key = $request->getParam('key');
|
|
$this->view->key = $key;
|
|
|
|
$parent = $request->getParam('id');
|
|
$level = $request->getParam('level');
|
|
|
|
//Init
|
|
if ( $parent === null ) {
|
|
$this->view->init = true;
|
|
}
|
|
// First level
|
|
elseif ( $parent == '#' ) {
|
|
$scoresFields = new Scores_Ciblage_FieldList();
|
|
$session = new Scores_Ciblage_Session($scoresFields);
|
|
$values = $session->getTreeValues($key, null, $level);
|
|
$this->view->values = $values;
|
|
}
|
|
// Get level
|
|
else {
|
|
$scoresFields = new Scores_Ciblage_FieldList();
|
|
$session = new Scores_Ciblage_Session($scoresFields);
|
|
$values = $session->getTreeValues($key, $parent, $level);
|
|
$this->view->values = $values;
|
|
}
|
|
|
|
}
|
|
} |