示例#1
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');
     }
 }
 public function setCookie()
 {
     $this->autoRender = FALSE;
     $data = $this->request->data;
     if ($this->request->is('post')) {
         $name = $data['name'];
         $value = $data['value'];
         Log::debug('name of cookie: ' . $name . 'and value is :' . $value);
         parent::writeCookie($name, $value);
         //parent::readCookie($name);
         $this->response->body(1);
     }
 }
 public function stockUpload()
 {
     $data = $this->request->data;
     if ($this->request->is('post') and isset($data['add-m'])) {
         parent::writeCookie('msu-message', 'Material Stock Updated');
         $this->redirect('inventory/stockupload');
     } elseif ($this->request->is('post') and isset($data['add-mb'])) {
         parent::writeCookie('mbsu-message', 'Material Brand Stock Updated');
         $this->redirect('inventory/stockupload');
     } elseif ($this->request->is('post') and isset($data['su'])) {
         $this->redirect('inventory/stockupload');
     }
     $message = parent::readCookie('msu-message');
     parent::deleteCookie('msu-message');
     $message1 = parent::readCookie('mbsu-message');
     parent::deleteCookie('mbsu-message');
     if ($message) {
         \Cake\Log\Log::debug('message:- ' . $message);
         $this->set(['message', $message]);
     } else {
         \Cake\Log\Log::debug('message:- ' . $message1);
         $this->set(['message', $message1]);
     }
 }