Пример #1
0
 /**
  * Get POS device specific configuration and aux values
  * @param array $result current result array
  * @return array API result array
  */
 public function getDeviceRecord($result)
 {
     // Get device info using the uuid
     $devMdl = new DevicesModel();
     $deviceInfo = $devMdl->getUuidInfo($this->data->uuid);
     if ($deviceInfo === false) {
         $result['error'] = "DB Error fetching your device settings";
         return $result;
     } else {
         if ($deviceInfo === null) {
             // device removed or not found
             $result['data'] = "removed";
             $result['warning'] = "This device has been removed from the system, please contact your Administrator";
             return $result;
         }
     }
     if ($deviceInfo['disabled'] == 1) {
         // check if device is disabled
         $result['data'] = "disabled";
         $result['warning'] = "This device has been disabled, please contact your Administrator";
         return $result;
     }
     // add device specific info
     $result['data'] = new stdClass();
     $result['data']->deviceid = $deviceInfo["deviceid"];
     $result['data']->devicename = $deviceInfo["devicename"];
     $result['data']->locationid = $deviceInfo["locationid"];
     $result['data']->locationname = $deviceInfo["locationname"];
     $result['data']->deviceconfig = $deviceInfo["deviceconfig"];
     // Get general & global pos configuration
     $WposConfig = new WposAdminSettings();
     $general = $WposConfig->getSettingsObject("general");
     $pos = $WposConfig->getSettingsObject("pos");
     if ($general === false || $pos === false) {
         $result['error'] = "Global config could not be retrieved!";
     }
     $result['data']->general = $general;
     $result['data']->pos = $pos;
     // get devices and locations
     if (($result['data']->devices = $this->getDevices()) === false || ($result['data']->locations = $this->getLocations()) === false) {
         $result['error'] = "Device or Location info could not be retrieved!";
     }
     if (($result['data']->users = $this->getUsers()) === false) {
         $result['error'] = "User info could not be retrieved!";
     }
     // get tax
     $tax = WposPosData::getTaxes();
     if (is_null($tax['error'])) {
         $result['data']->tax = $tax['data'];
     } else {
         $result['error'] = $tax['error'];
     }
     return $result;
 }