diff --git a/application/models/JoTabFJur.php b/application/models/JoTabFJur.php new file mode 100644 index 00000000..60fedb14 --- /dev/null +++ b/application/models/JoTabFJur.php @@ -0,0 +1,5 @@ +authenticate(); + try { + $db = Zend_Db::factory($this->dbConfig->db->jo); + $db->getConnection(); + } catch (Zend_Db_Adapter_Exception $e) { + if ($this->tabInfoUser['idClient']==1) { + throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); + } + } catch (Zend_Exception $e) { + throw new SoapFault('ERR', "Application error"); + } + + $columnsDisplay = array('codNaf5', 'libNaf5', 'codNaf4', 'codNaf3', 'codNaf2', 'codNaf1'); + try { + $model = new Application_Model_JoTabNaf5($db); + $sql = $model->select()->from($model, $columnsDisplay); + if ( $id!==null ) { + $sql->where('codNaf5=?', $id); + } + $result = $model->fetchAll($sql); + } catch (Zend_Db_Adapter_Exception $e) { + if ($this->tabInfoUser['idClient']==1) { + throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); + } + } catch (Zend_Exception $e) { + throw new SoapFault('ERR', $e->getMessage()); + } + + $tab = array(); + if ( $result->count()>0 ) { + foreach ( $result as $item ) { + $tab[$item->codEven] = $item->toArray(); + } + } + + return json_encode($tab); + } - protected function getLegalForm() + protected function getLegalForm($id) { $this->authenticate(); + try { + $db = Zend_Db::factory($this->dbConfig->db->jo); + $db->getConnection(); + } catch (Zend_Db_Adapter_Exception $e) { + if ($this->tabInfoUser['idClient']==1) { + throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); + } + } catch (Zend_Exception $e) { + throw new SoapFault('ERR', "Application error"); + } + + $columnsDisplay = array('code', 'libelle'); + try { + $model = new Application_Model_JoTabNaf5($db); + $sql = $model->select()->from($model, $columnsDisplay); + if ( $id!==null ) { + $sql->where('code=?', $id); + } + $result = $model->fetchAll($sql); + } catch (Zend_Db_Adapter_Exception $e) { + if ($this->tabInfoUser['idClient']==1) { + throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); + } + } catch (Zend_Exception $e) { + throw new SoapFault('ERR', $e->getMessage()); + } + + $tab = array(); + if ( $result->count()>0 ) { + foreach ( $result as $item ) { + $tab[$item->code] = $item->toArray(); + } + } + + return json_encode($tab); } protected function getEvent($id=null)