예제 #1
0
 /**
  * This method is used for create a Representative
  *
  * @url GET representative/{RepresentativeID}/{ClientID}/{ProviderID}/{name}/{email}/{phone}/{cphone}/{ref}
  */
 public function representative($RepresentativeID, $ClientID, $ProviderID, $name, $email = "null", $phone = "null", $cphone = "null", $ref = "null")
 {
     $Utils = new Utils();
     $Client = new Client();
     $Provider = new Provider();
     if ($Client->findClient($ClientID) && $Provider->findProvider($ProviderID)) {
         $Representative = new Representative();
         /* Formantando Telefone */
         if (strpos($phone, '(') !== false && strpos($phone, ')') !== false && strpos($phone, ' ') !== false && strpos($phone, '-') !== false) {
             $phoneArr = $Utils->phoneFormatMysql($phone);
             $phone = $phoneArr['DDD'] . $phoneArr['Phone'];
         }
         if (strpos($cphone, '(') !== false && strpos($cphone, ')') !== false && strpos($cphone, ' ') !== false && strpos($cphone, '-') !== false) {
             $cphoneArr = $Utils->phoneFormatMysql($cphone);
             $cphone = $cphoneArr['DDD'] . $cphoneArr['Phone'];
         }
         $Representative->Representative_ID = $RepresentativeID;
         $Representative->Client_ID = $Client->Client_ID;
         $Representative->Provider_ID = $Provider->Provider_ID;
         $Representative->Name = $name;
         $Representative->Email = $email;
         $Representative->Phone = $phone;
         $Representative->CPhone = $cphone;
         $Representative->Ref = $ref;
         if ($Representative->gravarDados()) {
             return array('Success' => true, "Msg" => "Representative has been alter");
         }
         return array('Success' => false, "Msg" => "Can't alter representative");
     }
     return array('Success' => false, "Msg" => "Client Or Provider not found");
 }