Beispiel #1
0
 /**
  * Broadcast the transaction to admin dash & devices included via config
  * @param $curdeviceid
  * @param bool $updatedsaleflag
  * @param bool $delete
  * @return bool
  */
 private function broadcastSale($curdeviceid, $updatedsaleflag = false, $delete = false)
 {
     $socket = new WposSocketIO();
     $wposConfig = new WposAdminSettings();
     $config = $wposConfig->getSettingsObject("pos");
     $devices = [];
     switch ($config->saledevice) {
         case "device":
             return true;
             // no need to do anything, the device will already get the updated record
         // no need to do anything, the device will already get the updated record
         case "all":
             // get all device id's
             $devMdl = new DevicesModel();
             $devices = $devMdl->getDeviceIds();
             break;
         case "location":
             // get location device id array
             $devMdl = new DevicesModel();
             $devices = $devMdl->getLocationDeviceIds($curdeviceid);
             break;
     }
     // put devices into object, node.js array functions suck
     $dobject = new stdClass();
     foreach ($devices as $value) {
         if ($curdeviceid != $value) {
             // remove the current device from broadcast
             $dobject->{$value} = $value;
         }
     }
     if ($updatedsaleflag == true) {
         $this->jsonobj->isupdate = 1;
     }
     $socket->sendSaleUpdate($dobject, $delete ? $this->jsonobj->ref : $this->jsonobj);
     return true;
 }