From d945f9d2b3422708d22575f4671361c7cdcd30ca Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 19 Jun 2015 14:08:43 +0000 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20methode=20setClient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/WsScore/Gestion/v0.3/Service.php | 36 ++++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/library/WsScore/Gestion/v0.3/Service.php b/library/WsScore/Gestion/v0.3/Service.php index f8cf2cc2..80c48d9c 100644 --- a/library/WsScore/Gestion/v0.3/Service.php +++ b/library/WsScore/Gestion/v0.3/Service.php @@ -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;