97 lines
2.2 KiB
PHP
97 lines
2.2 KiB
PHP
|
<?php
|
||
|
class ArborescenceController extends Zend_Controller_Action
|
||
|
{
|
||
|
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* Enter description here ...
|
||
|
*/
|
||
|
public function nafAction()
|
||
|
{
|
||
|
$this->_helper->layout()->disableLayout();
|
||
|
|
||
|
$this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js');
|
||
|
|
||
|
$request = $this->getRequest();
|
||
|
$niveau = $request->getParam('niveau', 1);
|
||
|
|
||
|
$nafM = new Application_Model_Naf();
|
||
|
$sql = $nafM->select()->where('niveau = ?', $niveau)->order('code ASC');
|
||
|
$result = $nafM->fetchAll($sql)->toArray();
|
||
|
|
||
|
$tabNaf = array();
|
||
|
foreach($result as $item){
|
||
|
$tabNaf[] = array(
|
||
|
'data' => $item['code'].' - '.$item['lib'],
|
||
|
'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']),
|
||
|
'state' => 'closed',
|
||
|
'children' => array(),
|
||
|
);
|
||
|
}
|
||
|
$this->view->assign('naf', json_encode($tabNaf));
|
||
|
}
|
||
|
|
||
|
public function nafajaxAction()
|
||
|
{
|
||
|
$this->_helper->layout()->disableLayout();
|
||
|
$this->_helper->viewRenderer->setNoRender();
|
||
|
|
||
|
$request = $this->getRequest();
|
||
|
$niveau = $request->getParam('niveau', 1);
|
||
|
$niveau++;
|
||
|
$parent = $request->getParam('parent', '');
|
||
|
$nafM = new Application_Model_Naf();
|
||
|
$sql = $nafM->select();
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* Enter description here ...
|
||
|
*/
|
||
|
public function geographiqueAction()
|
||
|
{
|
||
|
$this->_helper->layout()->disableLayout();
|
||
|
$this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js');
|
||
|
|
||
|
$regionsM = new Application_Model_Regions();
|
||
|
//$sql = $regionsM->select();
|
||
|
$this->view->assign('regions', $regionsM->fetchAll()->toArray());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* Enter description here ...
|
||
|
*/
|
||
|
public function juridqueAction()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|