/** * Set a device disabled * @param $result * @return mixed */ public function setDeviceDisabled($result) { // validate input if (!is_numeric($this->data->id)) { $result['error'] = "A valid id must be supplied"; return $result; } // get location id $devMdl = new DevicesModel(); if ($this->data->disable == false) { // we don't want to enable a device with a disabled location $dev = $devMdl->get($this->data->id)[0]; if (!$this->doesLocationExist($dev['locationid'])) { $result['error'] = "The devices location is disabled, pick a new location or enable it."; return $result; } } if ($devMdl->setDisabled($this->data->id, boolval($this->data->disable)) === false) { $result['error'] = "Could not enable/disable the device"; } // log data Logger::write("Device " . ($this->data->disable == true ? "disabled" : "enabled") . " with id:" . $this->data->id, "CONFIG"); return $result; }
private function getRecords() { // get items $itemMdl = new StoredItemsModel(); $this->items = $itemMdl->get(); // get items $authMdl = new AuthModel(); $this->users = $authMdl->get(null, null, null, false); // get locations $devMdl = new DevicesModel(); $this->devices = $devMdl->get(null, null, false); }
/** * @param array $result * * @return array of POS device records */ public function getPosDevices($result) { $devMdl = new DevicesModel(); $locMdl = new LocationsModel(); $devices = $devMdl->get(); if (is_array($devices)) { $data = []; foreach ($devices as $device) { $data[$device['id']] = $device; } $data[0] = ["id" => 0, "name" => "Admin dash", "locationname" => "Admin dash", "locationid" => 0]; $result['data'] = $data; } else { $result['error'] = $devMdl->errorInfo; } return $result; }