Ejemplo n.º 1
0
 /**
  * Add customer
  * @param $result
  * @return mixed
  */
 public function addContact($result)
 {
     $jsonval = new JsonValidate($this->data, '{"customerid":1, "name":"name"}');
     if (($errors = $jsonval->validate()) !== true) {
         $result['error'] = $errors;
         return $result;
     }
     $custMdl = new CustomerModel();
     $qresult = $custMdl->createContact($this->data->customerid, $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 add the contact: " . $custMdl->errorInfo;
     } else {
         $result['data'] = $this->getCustomerData($this->data->customerid);
         // log data
         Logger::write("Contact added with id:" . $this->data->id . " to customer id: " . $this->data->customerid, "CUSTOMER", json_encode($this->data));
     }
     return $result;
 }