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 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 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 orderPrintPreview() { $result = isset($_COOKIE['coi']); if (1) { $orderId = parent::readCookie('coi'); $orderNo = parent::readCookie('cono'); $tableNo = parent::readCookie('ctno'); $takeawayNo = parent::readCookie('ctkno'); $deliveryNo = parent::readCookie('cdno'); $userName = parent::readCookie('csb'); $orderTime = parent::readCookie('cot'); $orderDetails = $this->getTableObj()->getKotDetails($orderId); Log::debug('letest order details :-' . json_encode($orderDetails)); $this->set(['orderNo' => $orderNo, 'tableNo' => $tableNo, 'takeawayNo' => $takeawayNo, 'deliveryNo' => $deliveryNo, 'user' => $userName, 'time' => $orderTime, 'menus' => $orderDetails]); } else { $this->set([MESSAGE => DTO\ErrorDto::prepareMessage(126)]); } }
public function printPreview() { $tableId = parent::readCookie('cti'); $takeawayNo = parent::readCookie('ctn'); $deliveryNo = parent::readCookie('cdn'); Log::debug('Current tableId :-' . $tableId); Log::debug('Current takeawayNo :- ' . $takeawayNo); Log::debug('Current delivery number :- ' . $takeawayNo); if (!$tableId and !$takeawayNo and !$deliveryNo) { $this->redirect('login'); } $billController = new BillController(); $billInfo = $billController->getBill($tableId, $takeawayNo, $deliveryNo); if (is_null($billInfo)) { Log::error('Bill has not generated for this table'); $this->set([MESSAGE => DTO\ErrorDto::prepareMessage(124), COLOR => ERROR_COLOR]); return; } Log::debug('Bill has generated for this table'); $billDetailsController = new BillDetailsController(); $billDeatilsInfo = $billDetailsController->getOrderId($billInfo->billNo); $orders = array(); foreach ($billDeatilsInfo as $info) { array_push($orders, $info->orderId); } $orderDetailsController = new OrderDetailsController(); $billOrderDetails = $orderDetailsController->getbillOrderDetails($orders); $billPrintInfo = array(); $indexCounter = 0; $menuTitleList = array(); foreach ($billOrderDetails as $menu) { if (!key_exists($menu->menuTitle, $menuTitleList)) { $menuTitleList[$menu->menuTitle] = $menu; } else { foreach ($menuTitleList as $key => $value) { if ($value->menuId == $menu->menuId and $value->subMenuId == $menu->subMenuId) { $value->qty += $menu->qty; $value->orderPrice += $menu->orderPrice; } } } } foreach ($menuTitleList as $key => $value) { $billPrintDto = new DownloadDTO\BillPrintDwnldDto($indexCounter + 1, $value->menuId, $value->menuTitle, $value->qty, $value->orderPrice / $menu->qty, $value->orderPrice); $billPrintInfo[$indexCounter++] = $billPrintDto; } $restId = parent::readCookie('cri'); $restaurantController = new RestaurantController(); $restaurantInfo = $restaurantController->getAdminRestaurants(array($restId)); $userController = new UserController(); $userInfo = $userController->getUserName($billInfo->userId); $rtableController = new RTablesController(); $tableNo = $rtableController->getBillTableNo($tableId); if (isset($billInfo) and isset($restaurantInfo) and isset($billPrintInfo)) { $this->set(['table' => $tableNo, 'bill' => $billInfo, 'restaurants' => $restaurantInfo, 'printInfo' => $billPrintInfo, 'user' => $userInfo->userName]); } else { $this->set([MESSAGE => DTO\ErrorDto::prepareMessage(124), COLOR => ERROR_COLOR]); } }
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 editUser() { $restaurantId = parent::readCookie('cri'); $requestData = $this->request->data; $userRoleController = new UserRoleController(); $userRoles = $userRoleController->getUserRole(); $permissionSetController = new PermissionSetController(); $permission = $permissionSetController->getPermissionSet(); if ($this->request->is('post') and isset($requestData['edit'])) { $stdUser = new \stdClass(); foreach ($requestData as $key => $value) { $stdUser->{$key} = $value; } $this->set(['userInfo' => $stdUser, 'roles' => $userRoles, 'permissions' => $permission]); } elseif ($this->request->is('post') and isset($requestData['save'])) { $user_permission = $requestData['permi']; Log::debug('permission from form' . $user_permission); $data = explode(',', $user_permission); $saparator = '|'; $userPermission = implode($saparator, $data); $userUploadDto = new DownloadDTO\UserDownloadDto($requestData['uid'], $requestData['userName'], $requestData['password'], ACTIVE, $requestData['userRole'], $restaurantId, $userPermission); Log::debug('User Permission :-' . $userPermission); $insertResult = $this->getTbaleObj()->insert($userUploadDto); if ($insertResult) { $newUser = $this->getTbaleObj()->getNewUser($userUploadDto->userId); $this->makeSyncEntry($userUploadDto->userId, json_encode($newUser), UPDATE_OPERATION, $restaurantId); $this->redirect('manage/users'); } else { $this->set([MESSAGE => DTO\ErrorDto::prepareMessage(133), COLOR => ERROR_COLOR, 'permissions' => $permission, 'roles' => $userRoles]); } } }
public function editMenu() { $restaurantId = parent::readCookie('cri'); $data = $this->request->data; if ($this->request->is('post') and isset($data['edit'])) { $stdMenu = new \stdClass(); Log::debug($data); foreach ($data as $k => $v) { $stdMenu->{$k} = $v; } $menuCategoryController = new MenuCategoryController(); $category = json_decode(json_encode($menuCategoryController->getStdMenuCategory(), true)); $roomCategoryController = new RRoomsController(); $rooms = json_decode(json_encode($roomCategoryController->getStdRooms($restaurantId), true)); $fbTypeController = new FbTypeController(); $fbType = json_decode(json_encode($fbTypeController->getStdFbTypes())); $this->set(['menuInfo' => $stdMenu, 'category' => $category, 'room' => $rooms, 'fbType' => $fbType]); } elseif ($this->request->is('post') and isset($data['save'])) { $updateRequest = new UploadDTO\MenuInsertDto($data['ttl'], $data['img'], $data['prc'], $data['igt'], $data['tags'], $this->getValue('avl', $data), $this->getValue('act', $data), null, $this->getValue('spy', $data), $data['category'], $restaurantId, $data['room'], $data['mid'], $data['fbType']); $updateResult = $this->getTableObj()->update($updateRequest); if ($updateResult) { $menuUpdate = $this->getTableObj()->getUpdateMenu($updateRequest->menuId); $this->makeSyncEntry(json_encode($menuUpdate), UPDATE_OPERATION, $restaurantId); $this->redirect('menu'); } else { $this->set([MESSAGE => DTO\ErrorDto::prepareMessage(136), COLOR => ERROR_COLOR]); } } elseif ($this->request->is('post') and isset($data['edit-recipe'])) { parent::writeCookie('current-mid', $data['mid']); $this->redirect('menu/editrecipe'); } }
public function editTable() { if (!$this->isLogin()) { $this->redirect('login'); } $restaurantId = parent::readCookie('cri'); $data = $this->request->data; if ($this->request->is('post') and isset($data['edit'])) { $tableInfo = new \stdClass(); foreach ($data as $k => $v) { $tableInfo->{$k} = $v; } $tableCategoryController = new TableCategoryController(); $category = json_decode(json_encode($tableCategoryController->getStdTableCategory())); $this->set(['tableInfo' => $tableInfo, 'category' => $category]); } elseif ($this->request->is('post') and isset($data['save'])) { Log::debug('table status:' . $data['iopd']); $updateRequest = new UploadDTO\RTablesInsertDto($data['tno'], $data['category'], $data['cpty'], $data['iopd'], $restaurantId, $data['tid']); $updateResult = $this->getTableObj()->update($updateRequest); if ($updateResult) { $tableUpdate = $this->getTableObj()->getUpdatedTable($updateRequest->tableId); $this->makeSyncEntry(json_encode($tableUpdate), UPDATE_OPERATION, $restaurantId); $this->redirect('rtables'); } else { $this->set([MESSAGE => DTO\ErrorDto::prepareMessage(137), COLOR => ERROR_COLOR]); } } }
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)); } } }