public function index() { $this->autoRender = false; $restaurantId = $this->request->query('restaurantId'); $imei = $this->request->query('imei'); $macAddress = $this->isNull($this->request->query('macId')); $info = base64_decode($this->request->query('info')); $ipAddress = $this->request->clientIp(); $restaurantIMEIController = new RestaurantImeiController(); if (!$restaurantIMEIController->isPresent($restaurantId, $imei, $macAddress)) { $this->response->body(DTO\ErrorDto::prepareError(116)); \Cake\Log\Log::error("request with incorrect restaurantId :- " . $restaurantId); return; } $restaurantController = new RestaurantController(); \Cake\Log\Log::info('Request is in Download Controller'); if ($restaurantController->isValidate($restaurantId) and !empty($info)) { $networkDeviceDto = UploadDTO\NetworkDeviceInfoDto::Deserialize($info); $ipInfo = new Component\Ipinfo(); $ipDetails = $ipInfo->getFullIpDetails($imei, $networkDeviceDto, $ipAddress); $networkDeviceController = new NetworkDeviceController(); $addNetworkDeviceInfo = $networkDeviceController->addNetworkDeviceInfo($ipDetails, $restaurantId, $macAddress); $sqliteController = new SqliteController(); $sqliteController->getDB($restaurantId); } else { $this->response->body(DTO\ErrorDto::prepareError(100)); } }
public function addNetworkDeviceInfo(UploadDTO\NetworkDeviceInfoDto $networkDeviceInfoDto, $restaurantId, $macId) { $restaurantIMEIController = new RestaurantImeiController(); if ($restaurantIMEIController->isPresent($restaurantId, $networkDeviceInfoDto->imei, $macId)) { return $this->getTableObj()->insert($networkDeviceInfoDto); } return false; }
public function index() { $this->autoRender = false; date_default_timezone_set('GMT'); $jsonData = $this->request->input(); Log::debug($jsonData); if (empty($jsonData)) { $this->response->body(DTO\ErrorDto::prepareError(104)); Log::error('Upload request data is empty'); return; } $result = UploadDTO\MainUploadDto::Deserialize($jsonData); $userData = UploadDTO\UserUploadDto::Deserialize($result->user); $restaurantController = new RestaurantController(); if (!$restaurantController->isValidate($userData->restaurantId)) { $this->response->body(DTO\ErrorDto::prepareError(100)); \Cake\Log\Log::error("request with incorrect restaurantId :- " . $userData->restaurantId); return; } $restaurantIMEIController = new RestaurantImeiController(); if (!$restaurantIMEIController->isPresent($userData->restaurantId, $userData->imei, $this->isNull($userData->macId))) { $this->response->body(DTO\ErrorDto::prepareError(116)); \Cake\Log\Log::error("request with incorrect restaurantId :- " . $userData->restaurantId); return; } $userController = new UserController(); $userValidateResult = $userController->validateUserForUpload($userData->userId, $userData->password, $userData->restaurantId); if (is_null($userValidateResult)) { $this->response->body(DTO\ErrorDto::prepareError(102)); \Cake\Log\Log::error("request with incorrect userId :- " . $userData->userId); return; } $uploadResult = false; if (!$result->data) { Log::error("No data found for the request, data is blank"); return; } foreach ($result->data as $index => $record) { switch ($record->operation) { case $this->operations['PO']: $operationData = $record->operationData; $orderResponse = $this->placeOrder($operationData, $userData); if ($orderResponse) { $this->response->body(DTO\ErrorDto::prepareSuccessMessage($orderResponse)); } else { $this->response->body(DTO\ErrorDto::prepareError(129)); } break; case $this->operations['TO']: $operationData = $record->operationData; $result = $this->tableOccupy($operationData, $userData); if ($result) { $this->response->body(DTO\ErrorDto::prepareSuccessMessage($result)); } else { $this->response->body(DTO\ErrorDto::prepareError(110)); } break; case $this->operations['GB']: $operationData = $record->operationData; $result = $this->generateBill($operationData, $userData); break; case $this->operations['PB']: $operationData = $record->operationData; $this->payedBill($operationData, $userData); break; case $this->operations['OFF']: $operationData = $record->operationData; $this->orderFullfiled($operationData, $userData); break; case $this->operations['AC']: $operationData = $record->operationData; $this->addCustomer($operationData, $userData); break; case $this->operations['AWC']: $operationData = $record->operationData; $this->addWaitingCustomer($operationData, $userData); break; case $this->operations['DWC']: $operationData = $record->operationData; $this->deleteWaitingCustomer($operationData, $userData); break; case $this->operations['CF']: $operationData = $record->operationData; $this->addCustomerFeedback($operationData, $userData); break; case $this->operations['CT']: $operationData = $record->operationData; $this->closeTable($operationData, $userData); break; case $this->operations['P']: $operationData = $record->operationData; $this->printBill($operationData, $userData); break; case $this->operations['ATA']: $operationData = $record->operationData; $this->addTakeaway($operationData, $userData); break; case $this->operations['UC']: $operationData = $record->operationData; $this->updateCustomer($operationData, $userData); break; case $this->operations['AAE']: $operationData = $record->operationData; $this->addApplicationError($operationData, $userData); break; case $this->operations['AD']: $operationData = $record->operationData; $this->addDelivery($operationData, $userData); break; default: $this->response->body(DTO\ErrorDto::prepareError(108)); break; } } }