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); }
public function index() { $this->autoRender = false; //$tempUserId = null; $tempUserId = $this->request->query("userid"); $info = base64_decode($this->request->query('info')); $ip = "113.193.128.35"; //$this->request->clientIp(); \Cake\Log\Log::debug('DownloadDb request input querystring info : ' . $info); if (empty($tempUserId) or empty($info)) { $this->response->body(DTO\ClsErrorDto::prepareError(101)); \Cake\Log\Log::error("User requested with blank user id :" . $tempUserId); return; } $networkDeviceInfoDto = DTO\ClsNetworkDeviceInfoDto::Deserialize($info); $ipInfo = new Component\Ipinfo(); $fullDetails = $ipInfo->getFullIpDetails($tempUserId, $networkDeviceInfoDto, $ip); $networkDeviceInfoTable = new Table\NetworkDeviceInfoTable(); $networkDeviceInfoTable->saveNetworkDeviceInfo($fullDetails); $userDto = new DTO\ClsUserDto($tempUserId); \Cake\Log\Log::debug('TempUserId is send to Validate' . $tempUserId . " userIP : " . $ip); if ($this->isValid($userDto->userId)) { \Cake\Log\Log::debug("User validate"); $sqliteController = new SqliteController(); $sqliteController->getDB($userDto->userId); \Cake\Log\Log::debug("Sqlite database sended to user"); } else { $userController = new UserController(); \Cake\Log\Log::debug('UserId send to save in database'); if ($userController->userSignUp($userDto->userId)) { $sqliteController = new SqliteController(); $sqliteController->getDB($userDto->userId); \Cake\Log\Log::debug("sqlite file sended to user after userid saving"); } } }
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]); } }
public function deliveryEntry($userId, $json, $operation, $restaurantId) { $UserObj = new UserController(); $allUser = $UserObj->getUsers($restaurantId); if ($allUser) { foreach ($allUser as $user) { if ($user->userId != $userId) { $this->getTableObj()->Insert($user->userId, $json, $this->deliveryTable, $operation, $restaurantId); } else { $this->getTableObj()->Insert($user->userId, $json, $this->deliveryTable, UPDATE_OPERATION, $restaurantId); } } } }
public function index() { $this->autoRender = false; date_default_timezone_set('GMT'); $jsonData = $this->request->input(); Log::debug($jsonData); if (empty($jsonData)) { $this->response->body(DTO\ErrorDto::prepareError(104)); Log::error('Upload request data is empty'); return; } $result = UploadDTO\MainUploadDto::Deserialize($jsonData); $userData = UploadDTO\UserUploadDto::Deserialize($result->user); $restaurantController = new RestaurantController(); if (!$restaurantController->isValidate($userData->restaurantId)) { $this->response->body(DTO\ErrorDto::prepareError(100)); \Cake\Log\Log::error("request with incorrect restaurantId :- " . $userData->restaurantId); return; } $restaurantIMEIController = new RestaurantImeiController(); if (!$restaurantIMEIController->isPresent($userData->restaurantId, $userData->imei, $this->isNull($userData->macId))) { $this->response->body(DTO\ErrorDto::prepareError(116)); \Cake\Log\Log::error("request with incorrect restaurantId :- " . $userData->restaurantId); return; } $userController = new UserController(); $userValidateResult = $userController->validateUserForUpload($userData->userId, $userData->password, $userData->restaurantId); if (is_null($userValidateResult)) { $this->response->body(DTO\ErrorDto::prepareError(102)); \Cake\Log\Log::error("request with incorrect userId :- " . $userData->userId); return; } $uploadResult = false; if (!$result->data) { Log::error("No data found for the request, data is blank"); return; } foreach ($result->data as $index => $record) { switch ($record->operation) { case $this->operations['PO']: $operationData = $record->operationData; $orderResponse = $this->placeOrder($operationData, $userData); if ($orderResponse) { $this->response->body(DTO\ErrorDto::prepareSuccessMessage($orderResponse)); } else { $this->response->body(DTO\ErrorDto::prepareError(129)); } break; case $this->operations['TO']: $operationData = $record->operationData; $result = $this->tableOccupy($operationData, $userData); if ($result) { $this->response->body(DTO\ErrorDto::prepareSuccessMessage($result)); } else { $this->response->body(DTO\ErrorDto::prepareError(110)); } break; case $this->operations['GB']: $operationData = $record->operationData; $result = $this->generateBill($operationData, $userData); break; case $this->operations['PB']: $operationData = $record->operationData; $this->payedBill($operationData, $userData); break; case $this->operations['OFF']: $operationData = $record->operationData; $this->orderFullfiled($operationData, $userData); break; case $this->operations['AC']: $operationData = $record->operationData; $this->addCustomer($operationData, $userData); break; case $this->operations['AWC']: $operationData = $record->operationData; $this->addWaitingCustomer($operationData, $userData); break; case $this->operations['DWC']: $operationData = $record->operationData; $this->deleteWaitingCustomer($operationData, $userData); break; case $this->operations['CF']: $operationData = $record->operationData; $this->addCustomerFeedback($operationData, $userData); break; case $this->operations['CT']: $operationData = $record->operationData; $this->closeTable($operationData, $userData); break; case $this->operations['P']: $operationData = $record->operationData; $this->printBill($operationData, $userData); break; case $this->operations['ATA']: $operationData = $record->operationData; $this->addTakeaway($operationData, $userData); break; case $this->operations['UC']: $operationData = $record->operationData; $this->updateCustomer($operationData, $userData); break; case $this->operations['AAE']: $operationData = $record->operationData; $this->addApplicationError($operationData, $userData); break; case $this->operations['AD']: $operationData = $record->operationData; $this->addDelivery($operationData, $userData); break; default: $this->response->body(DTO\ErrorDto::prepareError(108)); break; } } }
<?php namespace App; session_start(); require_once 'vendor/autoload.php'; require_once 'app/config.php'; require_once 'app/capsule.php'; use App\Controller\ThreadController; use App\Controller\UserController; use Illuminate\Database\Capsule\Manager as Capsule; $con = mysqli_connect($hostname, $dbusername, $dbpassword, $db); $UserController = new UserController(); $ThreadController = new ThreadController(); $User = UserController::User(); if (!isset($_GET['C'], $_GET['add_thread'])) { header('Location:/index.php'); } elseif ($_GET['add_thread'] != 'true') { header('Location:/index.php'); } if (isset($_GET['logout'])) { if ($_GET['logout'] == true) { $UserController->logout(); } } if (isset($_SESSION['username'], $_SESSION['id'])) { $loggedin = true; } if (isset($_GET['C'])) { $category_id = $_GET['C']; $threads = $ThreadController->show($category_id);
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); }
public function imagesEntry($userId, $json, $operation) { $UserObj = new UserController(); $allUser = $UserObj->getAllUser(); \Cake\Log\Log::debug("New image enrty in sync table json : " . $json); if ($allUser) { foreach ($allUser as $user) { if ($user->userId != $userId) { $this->getTableObj()->Insert($user->userId, $json, $this->imageTable, $operation); } } } }
public function getDB($userId) { $this->autoRender = false; $tableObject = new Table\SqliteTable(); if ($tableObject->Create($userId)) { //Destination Table $destinationController = new DestinationController(); $destinationPreparedStatement = $destinationController->prepareInsertStatement(); if ($tableObject->excutePreparedStatement($destinationPreparedStatement)) { \Cake\Log\Log::info('Record is inserted into Destination SQLite table for id ' . $userId); } else { \Cake\Log\Log::error('Record is not inserted into Destination SQLite table'); } //User Table $userController = new UserController(); $userPreparedStatement = $userController->prepareInsertStatement(); if ($tableObject->excutePreparedStatement($userPreparedStatement)) { \Cake\Log\Log::info('Record is inserted into User SQLite table for id ' . $userId); } else { \Cake\Log\Log::error('Record is not inserted into User SQLite table'); } //Question Table $questionController = new QuestionController(); $questionPreparedStatement = $questionController->prepareInsertStatement(); if ($tableObject->excutePreparedStatement($questionPreparedStatement)) { \Cake\Log\Log::debug('Record is inserted into Question sQLite table for id' . $userId); } else { \Cake\Log\Log::debug('Record is not inserted into Question sQLite table for id'); } //Options Table $optionController = new OptionsController(); $optionPreparedStatement = $optionController->prepareInsertStatement(); if ($tableObject->excutePreparedStatement($optionPreparedStatement)) { \Cake\Log\Log::debug('Record is inserted into Options sQLite table for id' . $userId); } else { \Cake\Log\Log::debug('Record is not inserted into Options sQLite table for id'); } //Answer Table $answerController = new AnswerController(); $answerPreparedStatement = $answerController->prepareInsertStatement(); if ($tableObject->excutePreparedStatement($answerPreparedStatement)) { \Cake\Log\Log::debug('Record is inserted into Answer sQLite table for id' . $userId); } else { \Cake\Log\Log::debug('Record is not inserted into Answer sQLite table for id'); } //Comment And Like Table $commentAndLikeController = new CommentAndLikeController(); $commentAndLikePreparedStatement = $commentAndLikeController->prepareInsertStatement(); if ($tableObject->excutePreparedStatement($commentAndLikePreparedStatement)) { \Cake\Log\Log::debug('Record is inserted into commentAndLike sQLite table for id' . $userId); } else { \Cake\Log\Log::debug('Record is not inserted into commentAndLike sQLite table for id'); } //Images Table $imagesController = new ImagesController(); $imagesPreparedStatement = $imagesController->prepareInsertStatement(); if ($tableObject->excutePreparedStatement($imagesPreparedStatement)) { \Cake\Log\Log::debug('Record is inserted into Images sQLite table for id' . $userId); } else { \Cake\Log\Log::debug('Record is not inserted into Images sQLite table for id'); } //Stat_Config Table $statconfController = new StatConfController(); $statconfPreparedStatement = $statconfController->prepareInsertStatement(); if ($tableObject->excutePreparedStatement($statconfPreparedStatement)) { \Cake\Log\Log::debug('Record is inserted into stat_conf sQLite table for id' . $userId); } else { \Cake\Log\Log::debug('Record is not inserted into stat_conf SQLite table for id'); } $this->response->type('class'); $this->response->file(SQLITE_DB_DIR . 'TravelDb' . $userId . '.sqlite', ['download' => true]); $this->response->send(); $retult = unlink(SQLITE_DB_DIR . 'TravelDb' . $userId . '.sqlite'); \Cake\Log\Log::info('TravelDb.' . $userId . '.sqlite File deleted successfully'); $userTable = new Table\UserTable(); //$userTable->update($userId); } }
<?php session_start(); require_once 'vendor/autoload.php'; require_once 'app/config.php'; require_once 'app/capsule.php'; use App\Controller\CategoryController; use App\Controller\UserController; use Illuminate\Database\Capsule\Manager as Capsule; $con = mysqli_connect($hostname, $dbusername, $dbpassword, $db); $UserController = new UserController(); $CatController = new CategoryController(); $User = UserController::User(); if (isset($_GET['logout'])) { if ($_GET['logout'] == true) { $UserController->logout(); } } if (isset($_SESSION['username'], $_SESSION['id'])) { $loggedin = true; } else { header('Location:/index.php'); } if (isset($_POST['submit'])) { $username = $con->real_escape_string($_POST['username']); $password = $con->real_escape_string($_POST['password']); if ($UserController->login($username, $password)) { header('Location:/index.php'); } else { echo 'Login Failed'; }
public function displayBill() { $this->autoRender = FALSE; $restId = parent::readCookie('cri'); $request = $this->request->query; Log::debug($request); Log::debug('Current restaurantId in order controller :- ' . $restId); if (isset($restId)) { $tableId = $request['table']; $takeawayNo = $request['takeaway']; $deliveryNo = $request['delivery']; Log::debug('Now bill list shows for table :-' . $tableId . 'or for takeawayNo :- ' . $takeawayNo); $latestBill = $this->getTableObj()->getTableBill($tableId, $takeawayNo, $deliveryNo, $restId); if (is_null($latestBill)) { $this->response->body(json_encode([MESSAGE => DTO\ErrorDto::prepareMessage(126)])); return; } $userController = new UserController(); $rtableController = new RTablesController(); foreach ($latestBill as $bill) { $user = $userController->getUserName($bill->user); $bill->user = $user->userName; $bill->tableNo = $rtableController->getBillTableNo($bill->tableNo); $bill->date = date('d-m-Y H:i', strtotime('+330 minutes', strtotime($bill->date))); } if ($this->request->is('ajax')) { $response = json_encode($latestBill); Log::debug($response); $this->response->body($response); } } else { if ($this->request->is('ajax')) { $this->response->body(json_encode([MESSAGE => DTO\ErrorDto::prepareMessage(126)])); } } }