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 index() { $this->autoRender = false; $userId = $this->request->query("userId"); $restaurantId = $this->request->query("restaurantId"); \Cake\Log\Log::debug("Download request come with userId :- " . $userId . ' restaurantId :- ' . $restaurantId); if (empty($userId) or empty($restaurantId)) { $this->response->body(DTO\ErrorDto::prepareError(101)); \Cake\Log\Log::error("userId or restaurantID is blank "); return; } $restaurantController = new RestaurantController(); if (!$restaurantController->isValidate($restaurantId)) { $this->response->body(DTO\ErrorDto::prepareError(100)); \Cake\Log\Log::error("request with incorrect restaurantId :- " . $restaurantId); return; } $userController = new UserController(); if (!$userController->isUserValid($userId, $restaurantId)) { $this->response->body(DTO\ErrorDto::prepareError(102)); \Cake\Log\Log::error("request with incorrect userId :- " . $userId); return; } \Cake\Log\Log::debug('Download request is validate successfully '); $syncController = new SyncController(); $syncController->download($userId, $restaurantId); }
public function error() { $this->autoRender = false; $url = $this->request->url; \Cake\Log\Log::error('User hit with unknown api Endpoint : ' . $url); $this->response->body(DTO\ErrorDto::prepareError(404)); }
public function download($userId, $restaurantId) { $this->autoRender = false; \Cake\Log\Log::info("in Sync controller download method"); $Update = $this->getTableObj()->getUpdate($userId, $restaurantId); if ($Update) { $this->response->body(json_encode($Update)); $this->response->send(); \Cake\Log\Log::debug("Update send to User : "******" Update json for this user" . json_encode($Update)); $this->getTableObj()->deleteUpdate($userId); } else { $this->response->body(DTO\ErrorDto::prepareError(103)); $this->response->send(); } }
private function addDelivery($operationData, $userInfo) { $addDeliveryRequest = UploadDTO\DeliveryUploadDto::Deserialize($operationData); $deliveryController = new DeliveryController(); $addDeliveryRequest->deliveryNo = $deliveryController->getDeliveryNo($userInfo->restaurantId); $addDeliveryRequest->userId = $userInfo->userId; $takeawayResult = $deliveryController->addDeliveryEntry($addDeliveryRequest, $userInfo); if ($takeawayResult) { $this->response->body(DTO\ErrorDto::prepareSuccessMessage($takeawayResult)); return; } $this->response->body(DTO\ErrorDto::prepareError(120)); return; }
public function cancelOrder() { $this->autoRender = FALSE; $orderId = parent::readCookie('cancel_order_id'); $orderStatus = $this->getTableObj()->getOrderStatus($orderId); if (!$orderStatus) { $this->response->body(json_encode(DTO\ErrorDto::prepareError(143))); } elseif ($orderStatus == 3) { $this->response->body(json_encode(DTO\ErrorDto::prepareError(144))); } else { if ($this->getTableObj()->deleteOrder($orderId)) { $menuRecipeController = new MenuRecipeController(); $menuRecipeController->restoreMenuRecipeItemQty($orderId); $this->response->body(json_encode(DTO\ErrorDto::prepareSuccessMessage("Order has been canceled."))); } else { Log::debug('Current cancel orderid :-' . $orderId); $this->response->body(json_encode(DTO\ErrorDto::prepareError(142))); } } }
public function getCurrentTableCustomer() { $this->autoRender = FALSE; if (!$this->isLogin()) { $this->response->body(DTO\ErrorDto::prepareError(141)); } if ($this->request->is('post')) { $restaurantId = parent::readCookie('cri'); $data = $this->request->data; if ($data['table']) { Log::debug($data); $cust = $this->getTableObj()->getCustomer($data['table'], $restaurantId); $response['custId'] = $cust; } elseif ($data['takeaway']) { $takeawayController = new TakeawayController(); $response['custId'] = $takeawayController->getTakeawayCustomer($data['takeaway'], $restaurantId); } elseif ($data['delivery']) { $deliveryController = new DeliveryController(); $response['custId'] = $deliveryController->getCurrentCustomer($data['delivery'], $restaurantId); } $this->response->body(json_encode($response)); } }
public function getLatestBill() { $this->autoRender = FALSE; if (!$this->isLogin()) { $this->response->body(DTO\ErrorDto::prepareError(104)); return; } else { if ($this->request->is('post')) { $restaurantId = parent::readCookie('cri'); $data = $this->request->data; Log::debug($data); $result = $this->getTableObj()->getBillInfo($data['table'], $data['takeaway'], $data['delivery'], $restaurantId); if (is_null($result)) { $this->response->body(0); } else { $this->response->body(json_encode($result)); } Log::debug('data :- ' . json_encode($result)); } } }