issue #0001391 : getLienDoc

This commit is contained in:
Michael RICOIS 2012-11-09 10:07:32 +00:00
parent 8d0d7b2b61
commit 01223b0073

View File

@ -1782,6 +1782,64 @@ class Saisie extends WsScore
return $id; return $id;
} }
/**
* Liste des documents pour un lien
* @param int $id
* @param string $type Lien|Entreprise
* @throws SoapFault
* @return string
*/
public function getLienDoc($id, $type = 'Lien')
{
$this->authenticate();
//Init
if (empty($type)) $type = 'Lien';
//Connect to the database
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', "Application error");
} else {
throw new SoapFault('ERR', $e->getMessage());
}
} catch (Zend_Exception $e) {
throw new SoapFault('ERR', "Application error");
}
//Type = Entreprise => Search id by Siren
if ($type == 'Entreprise') {
$lienrefM = new Application_Model_JoLiensRef($db);
$sql = $lienrefM->select()->where('siren=?',$id);
$row = $lienrefM->fetchRow($sql);
$idNum = $row->current()->id;
}
//Type = Lien
elseif ($type == 'Lien') {
$idNum = $id;
}
//Get the result
$liendocM = new Application_Model_JoLiensDoc($db);
try {
$sql = $liendocM->select()
->where('idNum=?', $idNum)
->where('idType=?', $type);
$rowset = $liendocM->fetchAll($sql);
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']!=1) {
throw new SoapFault('ERR', "Application error");
} else {
throw new SoapFault('ERR', $e->getMessage());
}
}
$result = $rowset->toArray();
return json_encode($result);
}
/** /**
* Définition d'un document attaché à un lien * Définition d'un document attaché à un lien
* @param string $infos * @param string $infos