odea/application/controllers/CriteresController.php

67 lines
1.5 KiB
PHP
Raw Normal View History

2011-09-28 10:44:27 +02:00
<?php
class CriteresController extends Zend_Controller_Action
{
protected $field;
public function init()
{
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$field = new Fields($user->username);
$this->view->fields = $field;
}
2012-01-02 20:14:04 +01:00
public function indexAction(){}
public function entrepriseAction(){
2011-09-28 10:44:27 +02:00
}
public function economiqueAction(){}
2011-11-08 20:51:54 +01:00
public function geographiqueAction(){
2011-11-07 14:20:19 +01:00
$this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js');
2011-09-28 10:44:27 +02:00
}
public function juridiqueAction(){}
2011-09-28 10:44:27 +02:00
public function financiereAction(){}
2011-09-28 10:44:27 +02:00
2012-01-02 20:14:04 +01:00
public function nafAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
$niveau = $request->getParam('niveau', 1);
$parent = $request->getParam('parent', '');
$nafM = new Application_Model_Naf();
$sql = $nafM->select();
$niveau++;
if (!empty($parent) && $niveau==2) {
$sql->where('parent = ?', $parent);
} elseif (!empty($parent) && $niveau>2) {
$sql->where("code LIKE '".$parent."%'");
}
$sql->where('niveau = ?', $niveau)->order('code ASC');
$result = $nafM->fetchAll($sql)->toArray();
$tabNaf = array();
foreach($result as $item){
$naf = array(
'data' => $item['code'].' - '.$item['lib'],
'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']),
);
if ($niveau<5){
$naf['state'] = 'closed';
$naf['children'] = array();
}
$tabNaf[] = $naf;
}
echo json_encode($tabNaf);
}
2011-09-28 10:44:27 +02:00
}