Ejemplo n.º 1
0
 /**
  * Statically update customer data
  * @param $data
  * @return bool|string
  */
 public static function updateCustomerData($data)
 {
     $settings = WposAdminSettings::getSettingsObject('general');
     $custMdl = new CustomerModel();
     $gid = null;
     if ($settings->gcontact == 1) {
         // get google id
         $gid = $custMdl->get($data->id)[0]['googleid'];
         if ($gid) {
             // edit google
             $gres = GoogleIntegration::setGoogleContact($settings, $data, $gid);
         } else {
             // add google
             $gres = GoogleIntegration::setGoogleContact($settings, $data);
         }
         if ($gres[0] == true) {
             $gid = $gres[1];
         }
     }
     $qresult = $custMdl->edit($data->id, $data->email, $data->name, $data->phone, $data->mobile, $data->address, $data->suburb, $data->postcode, $data->state, $data->country, $data->notes, $gid);
     if ($qresult === false) {
         return "Could not edit the customer: " . $custMdl->errorInfo;
     } else {
         // get full customer record
         $data = self::getCustomerData($qresult);
         // broadcast to devices
         $WposSocketIO = new WposSocketIO();
         $WposSocketIO->sendCustomerUpdate($data);
         // log data
         Logger::write("Customer updated with id:" . $data->id, "CUSTOMER", json_encode($data));
         return $data;
     }
 }