odea/application/controllers/FieldsController.php

98 lines
3.1 KiB
PHP
Raw Normal View History

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