Пример #1
0
 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));
     }
 }
Пример #2
0
 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);
 }
Пример #3
0
 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]);
     }
 }
Пример #4
0
 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;
         }
     }
 }