_helper->layout()->disableLayout(); $request = $this->getRequest(); $key = $request->getParam('key'); $object = new Object_Naf(); $this->view->key = $key; $this->view->naf = $object->naf($request->getParam('niveau', 1), $key); } public function nafajaxAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $request = $this->getRequest(); $key = $request->getParam('key'); $object = new Object_Naf(); echo $object->ajax($request->getParam('parent', ''), $request->getParam('niveau', 1), $request->getParam('key') ); } /* Geographiques */ public function geographiqueAction() { $this->_helper->layout()->disableLayout(); $object = new Object_Codepostaux(); $key = $this->getRequest()->getParam('key'); $this->view->key = $key; $this->view->regions = $object->_getRegions(); } public function geographiqueajaxAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $request = $this->getRequest(); $id = $request->getParam('id'); $niveau = $request->getParam('niveau'); $object = new Object_Codepostaux(); if($niveau == 0) { echo ($object->_getDepartements($id)); } else if ($niveau == 1) { echo ($object->_getCommunes($id)); } } /* Forme Juridique */ public function juridiqueAction() { $this->_helper->layout()->disableLayout(); $fields = new Scores_Fields(); $val = $fields->getCritere('cj'); $valuesChecked = array(); $valuesUndetermined = array(); if ($val != null){ $valuesChecked = $val['in']; Zend_Registry::get('firebug')->info($val); Zend_Registry::get('firebug')->info($valuesChecked); if (count($valuesChecked)>0) { foreach($valuesChecked as $value){ if (strlen($value)>1) { $valuesUndetermined = array_merge($valuesUndetermined, array(substr($value,0,1))); } } } } $FormeJuridiqueM = new Application_Model_FormeJuridique(); $sql = $FormeJuridiqueM->select() ->where('LENGTH(fjCode) = 1') ->order('fjLibelle ASC'); $formes = $FormeJuridiqueM->fetchAll($sql)->toArray(); $tabFJ = array(); foreach($formes as $forme) { $structure = array( 'data' => $forme['fjLibelle'], 'attr' => array( 'id' => $forme['fjCode'] ), 'state' => 'closed', 'children' => array(), ); if (in_array($forme['fjCode'], $valuesChecked)){ $structure['attr']['class'] = 'jstree-checked'; } if (in_array($forme['fjCode'], $valuesUndetermined)){ $structure['attr']['class'] = 'jstree-undetermined'; } $tabFJ[] = $structure; } $key = $this->getRequest()->getParam('key'); $this->view->key = $key; $this->view->formejuridiques = json_encode($tabFJ); } public function juridiqueajaxAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $request = $this->getRequest(); $id = $request->getParam('id'); $length = strlen($id); $followingLevel = 5; if ( $length==1 ) { $followingLevel = 2; } elseif ( $length==2 ) { $followingLevel = 4; } $fields = new Scores_Fields(); $val = $fields->getCritere('cj'); $valuesChecked = array(); $valuesUndetermined = array(); if ($val != null){ $valuesChecked = $val['in']; if (count($valuesChecked)>0) { foreach($valuesChecked as $value){ if (strlen($value)>$followingLevel) { $valuesUndetermined = array_merge($valuesUndetermined, substr($value,0,$followingLevel)); } } } } Zend_Registry::get('firebug')->info($valuesChecked); if ($length<4) { $FormeJuridiqueM = new Application_Model_FormeJuridique(); $sql = $FormeJuridiqueM->select() ->where('fjCode LIKE "'.$id.'%"') ->where('LENGTH(fjCode)=?', $followingLevel); $formes = $FormeJuridiqueM->fetchAll($sql)->toArray(); $tabFJ = array(); foreach($formes as $forme) { $data = $forme['fjLibelle']; if ( $followingLevel==4 ) { $data = $forme['fjLibelle'].' ('.$forme['fjCode'].')'; } $structure = array( 'data' => $data, 'attr' => array( 'id' => $forme['fjCode'] ), ); if ( $length<2 ) { $structure['state'] = 'closed'; $structure['children'] = array(); } if (in_array($forme['fjCode'], $valuesChecked)){ $structure['attr']['class'] = 'jstree-checked'; } if (in_array($forme['fjCode'], $valuesUndetermined)){ $structure['attr']['class'] = 'jstree-undetermined'; } $tabFJ[] = $structure; } echo json_encode($tabFJ); } } }