public function editRecipeItem()
 {
     $this->autoRender = FALSE;
     $menuId = parent::readCookie('current-mid');
     $data = $this->request->data;
     if (!$this->isLogin()) {
         $this->redirect('../login');
     } elseif ($this->request->is('post') and isset($data['save'])) {
         $item = new \stdClass();
         foreach ($data as $key => $value) {
             $item->{$key} = $value;
         }
         $item->menuId = $menuId;
         $result = $this->getTableObj()->update($item);
         if ($result) {
             $this->redirect('menu/editrecipe');
         }
     } elseif ($this->request->is('post') and isset($data['delete'])) {
         $item = new \stdClass();
         foreach ($data as $key => $value) {
             $item->{$key} = $value;
         }
         $item->menuId = $menuId;
         $result = $this->getTableObj()->remove($item);
         if ($result) {
             $this->redirect('menu/editrecipe');
         }
     } else {
         $this->redirect('menu/editrecipe');
     }
 }
 public function addNewTableCategory()
 {
     if (!$this->isLogin()) {
         $this->redirect('login');
     }
     $data = $this->request->data;
     $restaurantId = parent::readCookie('cri');
     if ($this->request->is('post') and isset($this->request->data['bulk'])) {
         $fileName = $data['file-upload']['name'];
         if (!$this->isImage($fileName)) {
             $this->set([MESSAGE => INCORRECT_FILE_MESSAGE . '"png, jpg, jpeg"', COLOR => ERROR_COLOR]);
             return;
         }
         $uploadedFile = $data['file-upload']['tmp_name'];
         $imgDir = new Folder(IMAGE_UPLOAD, true);
         $destination = $imgDir->path . $this->getGUID() . $fileName;
         $uploadResult = move_uploaded_file($uploadedFile, $destination);
         if ($uploadResult) {
             $tableCategoryDto = new DownloadDTO\TableCategoryDownloadDto(null, $data['categoryTitle'], $destination);
             $insertResult = $this->getTableObj()->insert($tableCategoryDto);
             $newTableCategory = $this->getTableObj()->getSingleCategory($insertResult);
             $syncController = new SyncController();
             $syncController->tableCategoryEntry(json_encode($newTableCategory), INSERT_OPERATION, $restaurantId);
             if ($insertResult) {
                 $this->set(['message' => 'Table Category added successfully', 'color' => 'green', 'bulk' => 1]);
             } else {
                 $this->set(['message' => 'ERROR occured...', 'color' => 'red', 'bulk' => 1]);
             }
         }
     } elseif ($this->request->is('post') and isset($this->request->data['single'])) {
         $file = $data['image']['tmp_name'];
         $fileName = $data['image']['name'];
         $dir = new Folder(CATE_IMG_PATH, TRUE);
         $destination = $dir->path . $fileName;
         $extenstion = $this->getExtension($fileName);
         if (empty($file)) {
             $this->set([MESSAGE => SELECT_FILE_MESSAGE, 'color' => 'red', 'single' => 1]);
         } elseif (!in_array($extenstion, $this->img_valid_ext)) {
             Log::debug('File extention :-' . $file);
             $this->set([MESSAGE => INCORRECT_FILE_MESSAGE, 'color' => 'red', 'single' => 1]);
         } else {
             if (move_uploaded_file($file, $destination)) {
                 $tableCategoryDto = new DownloadDTO\TableCategoryDownloadDto(null, $data['title'], $destination);
                 $result = $this->getTableObj()->insert($tableCategoryDto);
                 $newTableCategory = $this->getTableObj()->getSingleCategory($result);
                 $syncController = new SyncController();
                 $syncController->tableCategoryEntry(json_encode($newTableCategory), INSERT_OPERATION, $restaurantId);
                 if ($result) {
                     $this->redirect('tablecategory');
                 } else {
                     $this->set([MESSAGE => 'Error ! please try again.', 'color' => 'red', 'single' => 1]);
                 }
             } else {
                 $this->set([MESSAGE => 'Error in image upload ! please try again.', 'color' => 'red', 'single' => 1]);
             }
         }
     }
 }
 public function rushHourReport()
 {
     if (!$this->isLogin()) {
         $this->redirect('login');
     }
     if ($this->request->is('get')) {
         $this->set(['limit' => 1]);
     }
     $this->set(['rest' => parent::readCookie('cri')]);
 }
 public function addNewPrinter()
 {
     $data = $this->request->data;
     $restaurantId = parent::readCookie('cri');
     if ($this->request->is('post') and isset($data['save'])) {
         $active = 1;
         $newPrinter = new DownloadDTO\RPrinterDownloadDto(null, $data['ip'], $data['name'], $data['model'], $data['company'], $data['mac'], $active);
         $result = $this->getTableObj()->addPrinter($newPrinter, $restaurantId);
         if ($result) {
             $this->set(['suc_msg' => 'SUCCESS ! Pinter Has Added. ', 'color' => SUCCESS_COLOR]);
         } else {
             $this->set(['suc_msg' => 'ERROR ! Unable to perform operation. ', 'color' => ERROR_COLOR]);
         }
     }
 }
 public function getBrandWiserequisitionReport()
 {
     $this->autoRender = FALSE;
     if ($this->request->is('ajax') and $this->isLogin()) {
         $restaurantId = parent::readCookie('cri');
         $response = $this->getTableObj()->getItems($restaurantId);
         if ($response) {
             $this->response->body(json_encode($response));
         } else {
             $this->response->body(0);
         }
     } else {
         $this->response->body(0);
     }
 }
 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 reportsNew()
 {
     if (!$this->isLogin()) {
         $this->redirect('login');
     }
     $this->set(['rest' => parent::readCookie('cri')]);
 }
Example #8
0
 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)));
         }
     }
 }
Example #9
0
 public function getWebUser()
 {
     $this->autoRender = FALSE;
     if (!$this->isLogin()) {
         $this->redirect('login');
     }
     $restaurantId = parent::readCookie('cri');
     $userRole = 4;
     $userinfo = $this->getTbaleObj()->getUserInfo($restaurantId, $userRole);
     $this->response->body(json_encode($userinfo));
 }
Example #10
0
 public function editRecipe()
 {
     $menuId = parent::readCookie('current-mid');
     $menuRecipeController = new MenuRecipeController();
     $data = $this->request->data;
     $result = TRUE;
     if ($this->request->is('post') and isset($data['save'])) {
         //$this->autoRender = FALSE;
         $menurecipeDto = new UploadDTO\MenuRecipeInsertDto($menuId, $data['recipeItem'], $data['qty'], $data['itemUnit']);
         $result = $menuRecipeController->addNewRecipeItem($menurecipeDto);
     }
     $recipe = $menuRecipeController->getMenuRecipe($menuId);
     $menuInfo = $this->getMenuItemList(null, array($menuId));
     $menu = null;
     foreach ($menuInfo as $menui) {
         if (is_null($menu)) {
             $menu = $menui;
         }
     }
     Log::debug($recipe);
     $this->set(['menurecipe' => $recipe, 'menu' => $menu]);
 }
Example #11
0
 public function tableNoValidation()
 {
     $this->autoRender = FALSE;
     $data = $this->request->data;
     $restaurantId = parent::readCookie('cri');
     $response = $this->getTableObj()->tableNoValidator($data['tableNo'], $restaurantId);
     $this->response->body($response);
 }
 public function materialStockUpload()
 {
     if (!$this->isLogin()) {
         $this->redirect('login');
     }
     $data = $this->request->data;
     $restaurantId = parent::readCookie('cri');
     $allow = 5;
     if ($this->request->is('post') and isset($data['upload'])) {
         $file = $data['file-upload']['tmp_name'];
         $filename = $data['file-upload']['name'];
         $extenstion = $this->getExtension($filename);
         if (empty($file)) {
             $this->set(['suc_msg' => SELECT_FILE_MESSAGE, 'color' => 'red']);
         } elseif ($extenstion != CSV_EXT) {
             $this->set(['suc_msg' => INCORRECT_FILE_MESSAGE, 'color' => 'red']);
         } else {
             if (($handle = fopen($file, "r")) !== FALSE) {
                 $counter = 0;
                 $allItems = null;
                 $fileCount = count(fgetcsv($handle));
                 Log::debug('File COunt:' . $fileCount);
                 if ($fileCount != $allow) {
                     $this->set(['suc_msg' => 'Please verify file data and try again..! ', 'color' => 'red']);
                     fclose($handle);
                     return;
                 }
                 while (($filesop = fgetcsv($handle, 1000, ",")) !== false) {
                     $allItems[$counter++] = new UploadDTO\RecipeItemMaterInsertDto($filesop[0], $filesop[1], $filesop[2], $filesop[3], $filesop[4]);
                 }
                 fclose($handle);
                 $result = $this->getTableObj()->insert($allItems);
                 if ($result) {
                     $this->set(['suc_msg' => 'You database has imported successfully. You have inserted ' . count($result) . ' recoreds', 'color' => 'green']);
                 } else {
                     $this->set(['suc_msg' => DB_FILE_ERROR, 'color' => 'red']);
                 }
             }
         }
     }
 }
 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));
     }
 }
Example #14
0
 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));
         }
     }
 }