67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?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;
|
|
}
|
|
|
|
public function indexAction(){}
|
|
|
|
public function entrepriseAction(){
|
|
|
|
}
|
|
|
|
public function economiqueAction(){}
|
|
|
|
public function geographiqueAction(){
|
|
$this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js');
|
|
}
|
|
|
|
public function juridiqueAction(){}
|
|
|
|
public function financiereAction(){}
|
|
|
|
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);
|
|
}
|
|
|
|
}
|