From f535161d620228ac84a4c0d5b88b9da2871297de Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 14 Dec 2012 12:31:15 +0000 Subject: [PATCH] issue #0001456 : Forme juridique, Naf5 --- application/models/JoTabFJur.php | 5 ++ application/models/JoTabNaf5.php | 5 ++ library/WsScore/Catalog/v0.1/Catalog.php | 83 +++++++++++++++++++++++- 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 application/models/JoTabFJur.php create mode 100644 application/models/JoTabNaf5.php 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)