Set email after order

This commit is contained in:
Michael RICOIS 2014-05-24 09:02:11 +00:00
parent e5265a6524
commit bdfbd47f6d

View File

@ -627,4 +627,154 @@ class Pieces extends WsScore
return $output;
}
/**
* Set an email associated to the command
* @param string $id
* @param string $email
* @throws SoapFault
* @return boolean
*/
public function setActeCmdEmail($id, $email)
{
$this->authenticate();
$this->permission('actes');
$validator = new Zend_Validate_EmailAddress();
if ( !$validator->isValid($email) ){
throw new SoapFault('ERR', "Adresse email invalide.");
}
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
$sql = $commandeM->select()
->where('login=?', $this->tabInfoUser['login'])
->where('refCommande=?', $id);
try {
$result = $commandeM->fetchRow($sql);
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']==1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Application error");
}
}
if ( $result !== null ) {
if ( is_int($email) ) {
//Id of secondary email
} else {
$dataUpdate = array('email' => $email);
try {
$commandeM->update($dataUpdate, "refCommande='".$id."'");
return true;
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']==1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Application error");
}
}
}
}
return false;
}
/**
* Set an email associated to the command
* @param string $id
* @param string $email
* @throws SoapFault
* @return boolean
*/
public function setBilanCmdEmail($id, $email)
{
$this->authenticate();
$this->permission('actes');
$validator = new Zend_Validate_EmailAddress();
if ( !$validator->isValid($email) ){
throw new SoapFault('ERR', "Adresse email invalide.");
}
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
$sql = $commandeM->select()
->where('login=?', $this->tabInfoUser['login'])
->where('refCommande=?', $id);
try {
$result = $commandeM->fetchRow($sql);
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']==1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Application error");
}
}
if ( $result !== null ) {
if ( is_int($email) ) {
//Id of secondary email
} else {
$dateUpdate = array('email' => $email);
try {
$commandeM->update($dataUpdate, "refCommande='".$id."'");
return true;
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']==1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Application error");
}
}
}
}
return false;
}
/**
* Set an email associated to the command
* @param string $id
* @param string $email
* @throws SoapFault
* @return boolean
*/
public function setKbisCmdEmail($id, $email)
{
$this->authenticate();
$this->permission('KBIS');
$validator = new Zend_Validate_EmailAddress();
if ( !$validator->isValid($email) ){
throw new SoapFault('ERR', "Adresse email invalide.");
}
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
$sql = $commandeM->select()
->where('login=?', $this->tabInfoUser['login'])
->where('refCommande=?', $id);
try {
$result = $commandeM->fetchRow($sql);
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']==1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Application error");
}
}
if ( $result !== null ) {
if ( is_int($email) ) {
//Id of secondary email
} else {
$dateUpdate = array('email' => $email);
try {
$commandeM->update($dataUpdate, "refCommande='".$id."'");
return true;
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']==1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Application error");
}
}
}
}
return false;
}
}