示例#1
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);
 }
 private function makeSyncEntry($userInfo, $orderDetailsId)
 {
     $newOrderDetails = $this->getTableObj()->getOrderDetails($orderDetailsId);
     if ($newOrderDetails) {
         $syncController = new SyncController();
         $orderDetailsEntry = $syncController->orderDetailsEntry($userInfo->userId, json_encode($newOrderDetails), $this->insert, $userInfo->restaurantId);
     }
 }
示例#3
0
 public function deleteEntry($deleteEntryRequest, $userInfo)
 {
     $deleteResult = $this->getTableObj()->deleteCustomer($deleteEntryRequest, $userInfo);
     if ($deleteResult) {
         $syncController = new SyncController();
         $syncEntryResult = $syncController->customerEntry($userInfo->userId, json_encode($deleteEntryRequest), DELETE_OPERATION, $userInfo->restaurantId);
     }
     return $deleteResult;
 }
示例#4
0
 public function addTakeawayEntry($takeawayRequest, $userInfo)
 {
     $takeawayResult = $this->getTableObj()->takeawayInsert($takeawayRequest, $userInfo->restaurantId);
     if ($takeawayResult) {
         $takeawayEntry = $this->getTableObj()->getSingleTakeaway($takeawayResult, $userInfo->restaurantId);
         $syncController = new SyncController();
         $syncResult = $syncController->takeawayEntry($takeawayRequest->userId, json_encode($takeawayEntry), INSERT_OPERATION, $userInfo->restaurantId);
     }
     return $takeawayResult;
 }
示例#5
0
 public function changeOrderStatus($orderId, $status, $restaurantId)
 {
     $statusResult = $this->getTableObj()->changeStatus($orderId, $status);
     if ($statusResult) {
         $orderStatusDto = new DownloadDTO\OrderStatusDto($orderId, $status);
         $syncController = new SyncController();
         $result = $syncController->orderEntry(NULL, json_encode($orderStatusDto), UPDATE_OPERATION, $restaurantId);
     }
     return $statusResult;
 }
示例#6
0
 public function addDeliveryEntry($deliveryRequest, $userInfo)
 {
     $deliveryResult = $this->getTableObj()->insert($deliveryRequest, $userInfo->restaurantId);
     if ($deliveryResult) {
         $deliveryEntry = $this->getTableObj()->getSingleDelivery($deliveryResult, $userInfo->restaurantId);
         $syncController = new SyncController();
         $syncResult = $syncController->deliveryEntry($deliveryRequest->userId, json_encode($deliveryEntry), INSERT_OPERATION, $userInfo->restaurantId);
     }
     return $deliveryResult;
 }
示例#7
0
 private function makeSyncEntry(UploadDTO\BillEntryDto $billEntryDto)
 {
     $newBillEntry = $this->getTableObj()->getNewBill($billEntryDto->billNo, $billEntryDto->restaurantId, $billEntryDto->userId);
     if (!is_null($newBillEntry)) {
         $syncController = new SyncController();
         $syncResult = $syncController->billEntry($billEntryDto->userId, json_encode($newBillEntry), $this->insert, $billEntryDto->restaurantId);
         Log::debug(' New bill entry successfully place in sync table');
         return $syncResult;
     }
     Log::error('Error occured in sync entry of new bill');
     return;
 }
 private function updateUserInfo($userDto)
 {
     if (is_null($userDto->userId) or is_null($userDto->emailId) or is_null($userDto->userName)) {
         $this->response->body(DTO\ClsErrorDto::prepareError(114));
         \Cake\Log\Log::error("User information is empty");
         return FAIL;
     }
     if ($this->getTableObj()->update($userDto)) {
         $this->response->body(DTO\ClsErrorDto::prepareSuccessMessage("User updated successfully for userid " . $userDto->userId));
         $syncController = new SyncController();
         $downloadUserDto = new DownloadDto\UserDto($userDto->userId, $userDto->userName, $userDto->photoUrl);
         $syncController->userEntry($userDto->userId, json_encode($downloadUserDto), INSERT);
     } else {
         $this->response->body(DTO\ClsErrorDto::prepareError(108));
     }
 }
 private function makeSyncEntry($billNo, $userId, $restaurantId)
 {
     $newBillDetailsEntryList = $this->getTableObj()->getNewDetails($billNo);
     if (!is_null($newBillDetailsEntryList)) {
         $syncController = new SyncController();
         foreach ($newBillDetailsEntryList as $newBillDetails) {
             $syncResult = $syncController->billDetailsEntry($userId, json_encode($newBillDetails), INSERT_OPERATION, $restaurantId);
             if (!$syncResult) {
                 return $syncResult;
             }
         }
         Log::debug(' New bill Details entry successfully place in sync table');
         return $syncResult;
     }
     Log::error('Error occured in sync entry of new bill Details ');
     return;
 }
 public function index()
 {
     $this->autoRender = false;
     $userId = $this->request->query("userid");
     \Cake\Log\Log::debug("Download request input querystring userId is : " . $userId);
     if (empty($userId)) {
         $this->response->body(DTO\ClsErrorDto::prepareError(101));
         \Cake\Log\Log::error("userId is blank " . $userId);
         return;
     }
     $userDto = new DTO\ClsUserDto($userId);
     if ($this->isValied($userDto->userId)) {
         \Cake\Log\Log::debug("User validate");
         $syncController = new SyncController();
         $syncController->download($userDto->userId);
     } else {
         $this->response->body(DTO\ClsErrorDto::prepareError(102));
         \Cake\Log\Log::error("User requested with invalid userid : " . $userId);
     }
 }
 public function add($optionText, $questionId)
 {
     if (empty($optionText)) {
         echo 'Empty Option';
         return;
     }
     try {
         $entity = $this->connect()->newEntity();
         $entity->OptionText = $optionText;
         $entity->QuestionId = $questionId;
         if ($this->connect()->save($entity)) {
             $optionDto = new DownloadDto\OptionsDto($entity->OptionId, $optionText, $questionId);
             $syncController = new Controller\SyncController();
             $syncController->optionEntry(json_encode($optionDto), INSERT);
             return $entity->optionId;
         }
         return FAIL;
     } catch (Exception $ex) {
         return FAIL;
     }
 }
 private function saveImage(DTO\ClsImagesDto $imageDto)
 {
     if ($this->getTableObj()->insertImage($imageDto->imageId, $imageDto->userId, $imageDto->destId, $imageDto->imagePath)) {
         $syncController = new SyncController();
         $syncController->imagesEntry($imageDto->userId, json_encode($imageDto), INSERT);
         return SUCCESS;
     }
     return FAIL;
 }
 public function edit()
 {
     $statconfTable = new Table\StatConfTable();
     if ($this->request->is('get')) {
         $query = $this->request->query;
         //$this->autoRender = false;
         $this->set(['config' => $query]);
     } elseif ($this->request->is('post')) {
         $data = $this->request->data;
         $key = $data['key'];
         $value = $data['value'];
         $updateConfig = $statconfTable->updateConfig($key, $value);
         if ($updateConfig) {
             $statConfDto = new DTO\ClsStatConfigDto($key, $value);
             $syncController = new SyncController();
             $syncController->statConfEntry(json_encode($statConfDto), UPDATE);
         }
         $this->redirect(['controller' => 'ConfigurationForm', 'action' => 'index']);
     } else {
         die('Request Error Occured !! please try later');
     }
 }
 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]);
             }
         }
     }
 }
示例#15
0
 private function makeSyncEntry($json, $operation, $restaurantId)
 {
     $syncController = new SyncController();
     $syncController->rtableEntry($json, $operation, $restaurantId);
 }
示例#16
0
 private function makeSyncEntry($userId, $json, $operation, $restaurantId)
 {
     $syncController = new SyncController();
     $result = $syncController->usersEntry($userId, $json, $operation, $restaurantId);
     return $result;
 }
 private function addQuestion($questionText, $status)
 {
     $questionTable = new Table\QuestionTable();
     $id = $questionTable->add($questionText, $status);
     if ($id) {
         $questionDto = new DownloadDto\QuestionDto($id, $questionText);
         $syncController = new SyncController();
         $syncController->questionEntry(json_encode($questionDto), INSERT);
         return $id;
     } else {
     }
 }
 private function makeSyncEntry($userInfo, $json, $operation)
 {
     $syncController = new SyncController();
     $syncController->tableTransactionEntry($userInfo->userId, $json, $operation, $userInfo->restaurantId);
     Log::debug('Sync update save for table_transaction table deletion');
 }
 private function makeSyncUpdate($active, $json, $operation)
 {
     if ($active or $operation == 'Update') {
         $syncController = new Controller\SyncController();
         $syncController->destEntry($json, $operation);
     }
 }
示例#20
0
 private function makeSyncEntry($update, $operation, $restaurantId)
 {
     $synController = new SyncController();
     $synController->MenuEntry($update, $operation, $restaurantId);
 }