Example #1
0
 public function placeOrder()
 {
     if (!$this->isLogin()) {
         $this->redirect('login');
     }
     $data = explode('/', $this->request->url);
     Log::debug($data);
     $userController = new UserController();
     $restaurantId = $this->readCookie('cri');
     $users = $userController->getUsers($restaurantId);
     $menuCategoryController = new MenuCategoryController();
     $categories = $menuCategoryController->getMenuCategories();
     $menuController = new MenuController();
     $menus = $menuController->getMenus($restaurantId);
     $tableId = $this->readCookie('cti');
     $takeawayNo = $this->readCookie('ctn');
     $deliveryNo = $this->readCookie('cdn');
     $rtableController = new RTablesController();
     if ($tableId) {
         $tableTransactionController = new TableTransactionController();
         $custId = $tableTransactionController->getCurrentCustomer($tableId, $restaurantId);
     } else {
         if ($takeawayNo) {
             $takeawayController = new TakeawayController();
             $custId = $takeawayController->getTakeawayCustomer($takeawayNo, $restaurantId);
         } else {
             if ($deliveryNo) {
                 $deliverycontroller = new DeliveryController();
                 $custId = $deliverycontroller->getCurrentCustomer($deliveryNo, $restaurantId);
             }
         }
     }
     $rconfigSettingcontroller = new RConfigSettingsController();
     $set = ['users' => $users, 'menus' => $menus, 'categories' => $categories, 'option' => $data[0], 'tableId' => $tableId, 'takeawayNo' => $takeawayNo, 'deliveryNo' => $deliveryNo, 'custId' => $custId, 'kot_permission' => $rconfigSettingcontroller->allow($restaurantId, KOT_CONFIG_KEY)];
     if ($tableId) {
         $set['isOccupied'] = $rtableController->isOccupied($tableId);
         $set['tableNo'] = $rtableController->getBillTableNo($tableId);
     }
     $this->set($set);
 }
Example #2
0
 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');
     }
 }