Amélioration methode setClient

This commit is contained in:
Michael RICOIS 2015-06-19 14:08:43 +00:00
parent 5a2acfd4a9
commit d945f9d2b3

View File

@ -888,6 +888,7 @@ class Gestion extends Scores_Ws_Server
{
$this->authenticate();
$result = false;
$nb = 0;
//Pas SuperAdministrateur
if ($this->User->profil!='SuperAdministrateur') {
throw new SoapFault(1, 'Profil insuffisant pour cette méthode');
@ -1076,11 +1077,21 @@ class Gestion extends Scores_Ws_Server
$iDbCrm = new WDB();
if (empty($idClient)){
//Ajout
// --- Ajout
$tabInfos['dateInsert'] = date('Y-m-d H:i:s');
$result = $iDbCrm->insert('sdv1.clients', $tabInfos, true);
try {
$clientM = new Application_Model_Sdv1Clients();
$nb = $clientM->insert($tabInfos);
} catch (Zend_Db_Exception $e) {
if ($this->User->id == 1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Création impossible");
}
}
} else {
//Droits client actuel avant modification
// --- Droits client actuel avant modification
if ( isset($tabInfos['droits']) ) {
$rep = $iDbCrm->select('sdv1.clients', 'droits', "id='$idClient'", false, MYSQL_ASSOC);
$droitsPre = explode(' ', $rep[0]['droits']);
@ -1094,13 +1105,26 @@ class Gestion extends Scores_Ws_Server
}
}
}
//Modification
// --- Modification
$tabInfos['dateUpdate'] = date('Y-m-d H:i:s');
if ($iDbCrm->update('sdv1.clients', $tabInfos, "id='$idClient'", true)){
$result = true;
try {
$clientM = new Application_Model_Sdv1Clients();
$nb = $clientM->update($tabInfos, "id='$idClient'");
} catch (Zend_Db_Exception $e) {
if ($this->User->id == 1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Création impossible");
}
}
}
}
if ($nb > 0) {
$result = true;
}
$output = new ClientReturn();
$output->error = $error;
$output->result = $result;