issue #0001384 : Définition identifiant locaux

This commit is contained in:
Michael RICOIS 2012-10-09 07:14:48 +00:00
parent e75d83c058
commit a1fbf91740

View File

@ -1523,4 +1523,79 @@ class Saisie extends WsScore
}
}
/**
* Créer un identifiant local pour un pays
* @param string $infos
* @param string $id
* @throws SoapFault
* @return int
*/
public function setCountryId($infos, $id = null)
{
$this->authenticate();
$data = json_decode($infos, true);
//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");
}
$countryIdM = new Application_Model_JoTabIdLocal($db);
if ($id!==null) {
//Update
try {
$id = $countryIdM->update($data, 'id = '.$id);
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']!=1) {
throw new SoapFault('ERR', "Application error");
} else {
throw new SoapFault('ERR', $e->getMessage());
}
}
} else {
//Insert
try {
$id = $countryIdM->insert($data);
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']!=1) {
throw new SoapFault('ERR', "Application error");
} else {
throw new SoapFault('ERR', $e->getMessage());
}
}
}
return $id;
}
protected function setLien($infos, $action)
{
$this->authenticate();
$data = json_decode($infos, true);
//Enregistrer les infos
//
}
}