From 862ad6d4ccf18dd7941500843acc6ced39d5199a Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 9 Nov 2012 16:07:16 +0000 Subject: [PATCH] issue #0001372 : Return type for getLienDoc --- library/WsScore/Saisie/v0.2/Saisie.ini | 1 + library/WsScore/Saisie/v0.2/Saisie.php | 37 ++++++++++++++++++++++---- library/WsScore/Saisie/v0.2/Types.php | 15 ++++++++++- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/library/WsScore/Saisie/v0.2/Saisie.ini b/library/WsScore/Saisie/v0.2/Saisie.ini index 1920b29e..403fe951 100644 --- a/library/WsScore/Saisie/v0.2/Saisie.ini +++ b/library/WsScore/Saisie/v0.2/Saisie.ini @@ -19,3 +19,4 @@ Type[] = "SupprAnnonceReturn" Type[] = "DupliqueAnnonceReturn" Type[] = "BilanInfos" Type[] = "SearchLienRef" +Type[] = "LienDoc" \ No newline at end of file diff --git a/library/WsScore/Saisie/v0.2/Saisie.php b/library/WsScore/Saisie/v0.2/Saisie.php index 425d6d68..cbc177e9 100644 --- a/library/WsScore/Saisie/v0.2/Saisie.php +++ b/library/WsScore/Saisie/v0.2/Saisie.php @@ -1787,7 +1787,7 @@ class Saisie extends WsScore * @param int $id * @param string $type Lien|Entreprise * @throws SoapFault - * @return string + * @return LienDoc[] */ public function getLienDoc($id, $type = 'Lien') { @@ -1815,7 +1815,7 @@ class Saisie extends WsScore $lienrefM = new Application_Model_JoLiensRef($db); $sql = $lienrefM->select()->where('siren=?',$id); $row = $lienrefM->fetchRow($sql); - $idNum = $row->current()->id; + $idNum = $row->id; } //Type = Lien elseif ($type == 'Lien') { @@ -1827,7 +1827,8 @@ class Saisie extends WsScore try { $sql = $liendocM->select() ->where('idNum=?', $idNum) - ->where('idType=?', $type); + ->where('idType=?', $type) + ->where('dateSuppr=?', '0000-00-00 00:00:00'); $rowset = $liendocM->fetchAll($sql); } catch (Zend_Db_Exception $e) { if ($this->tabInfoUser['idClient']!=1) { @@ -1836,8 +1837,34 @@ class Saisie extends WsScore throw new SoapFault('ERR', $e->getMessage()); } } - $result = $rowset->toArray(); - return json_encode($result); + + $output = array(); + if ( $rowset->count()>0 ) { + + $refFileInterne = array( + + ); + foreach ( $rowset as $item ) { + $struct = new LienDoc(); + $struct->perimetre = $item->periDoc; + $params = explode('-', $item->docRef); + switch($params[0]) { + case 'INTERNE' : + $struct->label = $item->docRef; + $struct->url = $item->docRef; + break; + case 'GREFFE' : + $struct->label = $item->docRef; + $struct->url = $item->docRef; + //@todo + break; + } + + $struct->date = $item->dateDocRef; + $output[] = $struct; + } + } + return $output; } /** diff --git a/library/WsScore/Saisie/v0.2/Types.php b/library/WsScore/Saisie/v0.2/Types.php index 9521c2a5..f7cee878 100644 --- a/library/WsScore/Saisie/v0.2/Types.php +++ b/library/WsScore/Saisie/v0.2/Types.php @@ -312,4 +312,17 @@ class SearchLienRef } - +class LienDoc +{ + /** @var string */ + public $perimetre; + + /** @var string */ + public $label; + + /** @var string */ + public $url; + + /** @var string */ + public $date; +}