Пример #1
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]);
     }
 }
Пример #2
0
 private function payedBill($operationData, $userInfo)
 {
     $payedBillRequest = UploadDTO\BillPaymentUploadDto::Deserialize($operationData);
     $billController = new BillController();
     $this->transBegin();
     $payedBillResult = $billController->changeBillPaymetStatus($payedBillRequest, $userInfo);
     if ($payedBillResult) {
         $this->response->body(DTO\ErrorDto::prepareSuccessMessage('Bill payment has been done'));
         $transactionController = new TransactionMasterController();
         $reportResult = $transactionController->createTransactionReport($payedBillRequest->payedBy, $payedBillResult, $userInfo->restaurantId);
         $conditionText = $billController->getBillDetails($payedBillRequest->billNo);
         if (!is_null($conditionText['DeliveryNo'])) {
             $delivery = new DeliveryController();
             $delivery->closeDelivery($conditionText['DeliveryNo']);
         } else {
             if (!is_null($conditionText['TakeawayNo'])) {
                 $takeaway = new TakeawayController();
                 $takeaway->closeTakeway($conditionText['TakeawayNo']);
             }
         }
         if ($reportResult) {
             $this->transCommit();
         } else {
             $this->transRollback();
         }
         return;
     }
     $this->transRollback();
     $this->response->body(DTO\ErrorDto::prepareError(111));
     return;
 }