From 37c09295612d716b2538086ed865b53ba41841b4 Mon Sep 17 00:00:00 2001 From: Claire DELBOS Date: Fri, 14 Apr 2017 16:58:37 +0200 Subject: [PATCH] SD-36 --- library/Application/Model/Sdv1Banques.php | 9 +++ library/WsScore/Saisie/v0.2/Service.php | 88 +++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 library/Application/Model/Sdv1Banques.php diff --git a/library/Application/Model/Sdv1Banques.php b/library/Application/Model/Sdv1Banques.php new file mode 100644 index 00000000..0ae61f22 --- /dev/null +++ b/library/Application/Model/Sdv1Banques.php @@ -0,0 +1,9 @@ +authenticate(); + $data = (array) json_decode($infos, true); + $where='1'; + foreach($data as $k => $v){ + if(!empty($v)){ + $where .= ' AND '.$k.' = "'.$v.'"'; + } + } + $db=new Application_Model_Sdv1Banques(); + $select=$db->select()->from('sdv1.banques')->where($where); + $stmt = $select->query(); + $result=$stmt->fetch(); + //$result=$db->query('SELECT * FROM sdv1.banques where '. $where); + + return json_encode($result); + } + /** + * Définition d'un rib + * @param string $infos + * @throws SoapFault + * @return int + */ + public function setRib($infos) + { + $this->authenticate(); + $data = (array) json_decode($infos, true); + $mode=$data['mode']; + unset($data['mode']); + $oldvals=(array)json_decode($data['oldvals']); + unset($data['oldvals']); + if(isset($data['banqueID'])){ + $id=$data['banqueID']; + unset($data['banqueID']); + } + $db=new Application_Model_Sdv1Banques(); + if($mode=='add'){ + $data['dateInsert']=Date('Y-m-d H:i:s'); + $data['dateUpdate']=Date('Y-m-d H:i:s'); + $db->insert($data); + return true; + } + if($mode=='edit'){ + if(!isset($oldvals['siren'])){ + return __LINE__; + } + $data['dateUpdate']=Date('Y-m-d H:i:s'); + $where='1'; + foreach($oldvals as $k => $v){ + if(!empty($v)){ + $where.=' AND '.$k.' = "'.$v.'"'; + } + } + try{ + $db->update($data,$where); + }catch(Exception $e){ + $this->logger->error($e->getMessage()); + return __LINE__; + } + + return true; + //$mode='delete'; + } + if($mode=='delete'){ + if(!isset($oldvals['siren'])){ + return __LINE__; + } + $values['dateUpdate']=Date('Y-m-d H:i:s'); + $values['dateSuppr']=Date('Y-m-d H:i:s'); + $where='dateSuppr="0000-00-00 00:00:00"'; + foreach($oldvals as $k => $v){ + if(!empty($v)){ + $where.=' AND '.$k.' = "'.$v.'"'; + } + } + $db->update($values,$where); + return true; + } + return __LINE__; + + } protected function getLienUser($id, $type = null) { $this->authenticate();