/** * Returns an singleton instance of this class * * @param object $config * @param object $args * @return */ public static function getInstance() { if (self::$instance == null) { self::$instance = new DeviceCounterHistoryManager(); } return self::$instance; }
public function service() { $deviceId = intval($_REQUEST['device_id']); $devicesManager = DevicesManager::getInstance(); $deviceDto = $devicesManager->selectByPK($deviceId); if (isset($deviceDto)) { $deviceCounterHistoryManager = DeviceCounterHistoryManager::getInstance(); $devicePendingActionsManager = DevicePendingActionsManager::getInstance(); $jasonAction = new stdClass(); $jasonAction->action = "reset_counter"; $devicePendingActionsManager->addDeviceAction($deviceId, json_encode($jasonAction)); $deviceCounterHistoryManager->addRow($deviceId, $deviceDto->getAmd100Qty(), $deviceDto->getAmd200Qty(), $deviceDto->getAmd500Qty()); $devicesManager->resetDeviceCounter($deviceId); $this->ok(); } $this->error(); }
public function load() { $devicesManager = DevicesManager::getInstance(); $carwashDevicesManager = CarwashDevicesManager::getInstance(); $carwashDeviceDtos = $carwashDevicesManager->selectByField('carwash_id', $this->getUserId()); $deviceIds = array(); foreach ($carwashDeviceDtos as $carwashDeviceDto) { $deviceId = $carwashDeviceDto->getDeviceId(); $deviceIds[] = $deviceId; } $devicesDtos = $devicesManager->selectByPKs($deviceIds); $this->addParam('devicesDtos', $devicesDtos); $selectedDeviceId = 0; if (isset($this->args[0])) { $selectedDeviceId = intval($this->args[0]); $selectedDevicesDto = $devicesManager->selectByPK($selectedDeviceId); $this->addParam("selectedDeviceDto", $selectedDevicesDto); $deviceCounterHistoryManager = DeviceCounterHistoryManager::getInstance(); $deviceCounterHistory = $deviceCounterHistoryManager->selectByField('device_id', $selectedDeviceId, "datetime", false); $this->addParam('deviceCounterHistory', $deviceCounterHistory); } }