issue #0000930 : Gestion des services
This commit is contained in:
parent
b618d69952
commit
f77496f078
@ -322,7 +322,7 @@ class Gestion extends WsScore
|
||||
|
||||
case 'update':
|
||||
|
||||
//Don't update password if nothind is send
|
||||
//Don't update password if nothing is send
|
||||
if (!empty($infos['password'])){
|
||||
$tabUpdate['password'] = stripslashes($infos['password']);
|
||||
}
|
||||
@ -1333,10 +1333,10 @@ class Gestion extends WsScore
|
||||
$db = Zend_Db::factory($this->dbConfig->db->sdv1);
|
||||
$db->getConnection();
|
||||
} catch (Zend_Db_Adapter_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
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");
|
||||
@ -1352,10 +1352,10 @@ class Gestion extends WsScore
|
||||
$sql->order('dateDebut DESC');
|
||||
$rows = $tarifM->fetchAll($sql);
|
||||
} catch (Zend_Db_Adapter_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
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");
|
||||
@ -1385,11 +1385,11 @@ class Gestion extends WsScore
|
||||
$db = Zend_Db::factory($this->dbConfig->db->sdv1);
|
||||
$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());
|
||||
}
|
||||
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");
|
||||
}
|
||||
@ -1410,11 +1410,11 @@ class Gestion extends WsScore
|
||||
|
||||
$row = $tarifM->fetchRow($sql);
|
||||
} catch (Zend_Db_Adapter_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
}
|
||||
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");
|
||||
}
|
||||
@ -1587,12 +1587,11 @@ class Gestion extends WsScore
|
||||
/**
|
||||
* Define a Service in Client
|
||||
* @param int $idClient
|
||||
* @param string $code
|
||||
* @param string $label
|
||||
* @param string $infos
|
||||
* @throws SoapFault
|
||||
* @return int
|
||||
*/
|
||||
public function setService($idClient, $code, $label)
|
||||
public function setService($idClient, $infos=null)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
@ -1617,6 +1616,11 @@ class Gestion extends WsScore
|
||||
try {
|
||||
$serviceM = new Application_Model_Sdv1ClientsServices($db);
|
||||
|
||||
$dataIn = json_decode($infos, true);
|
||||
$code = $dataIn['code'];
|
||||
$label = $dataIn['label'];
|
||||
$droits = $dataIn['droits'];
|
||||
|
||||
//Check if code exist in idClient
|
||||
$sql = $serviceM->select()
|
||||
->where('idClient=?',$idClient)
|
||||
@ -1627,21 +1631,23 @@ class Gestion extends WsScore
|
||||
if ($row->count()>0) {
|
||||
$data = array(
|
||||
'label' => $label,
|
||||
'droits' => $droits
|
||||
);
|
||||
$result = $serviceM->update($data, array('idClient='.$idClient, 'code='.$code));
|
||||
} else {
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
'label' => $label,
|
||||
'droits' => $droits,
|
||||
'idClient' => $idClient
|
||||
);
|
||||
$result = $serviceM->insert($data);
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
if ($this->tabInfoUser['idClient']==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1668,10 +1674,10 @@ class Gestion extends WsScore
|
||||
$db = Zend_Db::factory($this->dbConfig->db->sdv1);
|
||||
$db->getConnection();
|
||||
} catch (Zend_Db_Adapter_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
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");
|
||||
@ -1698,10 +1704,10 @@ class Gestion extends WsScore
|
||||
$result = $serviceM->insert($data);
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
if ($this->tabInfoUser['idClient']==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1772,4 +1778,49 @@ class Gestion extends WsScore
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function getService($idClient, $code)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
if ($this->tabInfoUser['profil']!='SuperAdministrateur') {
|
||||
$this->sendError('0902');
|
||||
}
|
||||
|
||||
//Connect to the database
|
||||
try {
|
||||
$db = Zend_Db::factory($this->dbConfig->db->sdv1);
|
||||
$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");
|
||||
}
|
||||
|
||||
try {
|
||||
$serviceM = new Application_Model_Sdv1ClientsServices($db);
|
||||
$sql = $serviceM->select()
|
||||
->where('idClient=?', $idClient)
|
||||
->where('serviceCode=?', $code);
|
||||
$row = $serviceM->fetchRow($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', "Application error");
|
||||
}
|
||||
|
||||
if (null !== $row) {
|
||||
return json_encode($row->toArray());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user