Exemplo n.º 1
0
 /**
  * Update customer
  * @param $result
  * @return mixed
  */
 public function updateContact($result)
 {
     $jsonval = new JsonValidate($this->data, '{"id":1, "customerid":1, "name":"name"}');
     if (($errors = $jsonval->validate()) !== true) {
         $result['error'] = $errors;
         return $result;
     }
     $custMdl = new CustomerModel();
     $qresult = $custMdl->editContact($this->data->id, $this->data->email, $this->data->name, $this->data->phone, $this->data->mobile, $this->data->position, $this->data->receivesinv);
     if ($qresult === false) {
         $result['error'] = "Could not edit the contact: " . $custMdl->errorInfo;
     } else {
         $result['data'] = $this->getCustomerData($this->data->customerid);
         // broadcast to devices
         $WposSocketIO = new WposSocketIO();
         $WposSocketIO->sendCustomerUpdate($result['data']);
         // log data
         Logger::write("Contact updated with id:" . $this->data->id, "CUSTOMER", json_encode($this->data));
     }
     return $result;
 }