public function indexAction()
 {
     /*
      * temporary usage for user not to redirect to admin panel dashboard
      */
     $adminModel = Admin_Model_Users::getInstance();
     $result = $adminModel->getAdminDetails();
     // showing image
     if ($result) {
         $this->view->admindetails = $result;
     }
     if ($this->view->auth->hasIdentity()) {
         $this->view->auth->clearIdentity();
         Zend_Session::destroy(true);
         $this->_redirect('/admin/dashboard');
     }
     /////////////////code ends ////////////////
     $objSecurity = Engine_Vault_Security::getInstance();
     if ($this->_request->isPost()) {
         $username = $this->getRequest()->getPost('username');
         $password = sha1(md5($this->getRequest()->getPost('password')));
         if (isset($username) && isset($password)) {
             $authStatus = $objSecurity->authenticate($username, $password);
             if ($authStatus->code == 200) {
                 if ($this->view->session->storage->role == '2') {
                     $this->_redirect('admin/dashboard');
                 }
             } elseif ($authStatus->code == 198) {
                 $this->view->error = "Invalid credentials";
             }
         }
     }
 }
 public function hotelReviewsAction()
 {
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     $agent_id = $this->view->session->storage->agent_id;
     $url = $this->_appSetting->apiLink . '/storedetails?method=getHotelReviewsByAgentId';
     $data['agent_id'] = $agent_id;
     $curlResponse = $objCurlHandler->curlUsingPost($url, $data);
     if ($curlResponse->code == 200) {
         $this->view->reviewdetails = $curlResponse->data;
     }
 }
 public function agentPaymentsAction()
 {
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     $agent_id = $this->view->session->storage->agent_id;
     $url = $this->_appSetting->apiLink . '/agent-transactions';
     $data['agent_id'] = $agent_id;
     $curlResponse = $objCurlHandler->curlUsingPost($url, $data);
     if ($curlResponse->code == 200) {
         $this->view->transactiondetails = $curlResponse->data;
     }
 }
 public function cartAction()
 {
     $mailer = Engine_Mailer_Mailer::getInstance();
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     ////// list of saved products in cookies display for all hotels //////////////////
     if (isset($_COOKIE['user_cartitems_cookie'])) {
         $cartitems = $_COOKIE['user_cartitems_cookie'];
         $cartitems = stripslashes($cartitems);
         $saved_cart_items = json_decode($cartitems, true);
         $ar['cookies_values'] = json_encode($saved_cart_items, true);
         $url = $this->_appSetting->apiLink . '/restaurent-menu-card?method=getproductsForAllHotels';
         $curlResponse = $objCurlHandler->curlUsingPost($url, $ar);
         if ($curlResponse->code == 200) {
             $i = 0;
             $count = count($curlResponse->data);
             foreach ($curlResponse->data as $value) {
                 $hotel_id = $value['hotel_id'];
                 if ($hotel_id) {
                     $arr[$hotel_id]['hotelname'] = $value['hotel_name'];
                     $arr[$hotel_id]['hotel_id'] = $value['id'];
                     $arr[$hotel_id]['hotel_image'] = $value['hotel_image'];
                     $arr[$hotel_id]['notice'] = $value['notice'];
                     $arr[$hotel_id]['minorder'] = $value['minorder'];
                     $arr[$hotel_id]['deliverycharge'] = $value['deliverycharge'];
                     if (!isset($arr[$hotel_id]['totalcost'])) {
                         $arr[$hotel_id]['totalcost'] = 0;
                         $arr[$hotel_id]['totalcost'] += $value['product_cost'];
                     } else {
                         $arr[$hotel_id]['totalcost'] += $value['product_cost'];
                     }
                     $arr[$hotel_id]['products'][$i]['product_name'] = $value['name'];
                     $arr[$hotel_id]['products'][$i]['product_id'] = $value['product_id'];
                     $arr[$hotel_id]['products'][$i]['hotel_id'] = $value['hotel_id'];
                     $arr[$hotel_id]['products'][$i]['total_cost'] = $value['product_cost'];
                     $arr[$hotel_id]['products'][$i]['unit_cost'] = $value['cost'];
                     $arr[$hotel_id]['products'][$i]['quantity'] = $value['quantity'];
                     $arr[$hotel_id]['products'][$i]['imagelink'] = $value['imagelink'];
                 }
                 $i++;
             }
             $this->view->cartdata = $arr;
         }
     } else {
     }
 }
 public function ajaxHandlerAuthAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $mailer = Engine_Mailer_Mailer::getInstance();
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     $method = $this->getRequest()->getParam('ajaxMethod');
     if ($method) {
         switch ($method) {
             case 'validateUsername':
                 $data['uname'] = $this->getRequest()->getParam('name');
                 $url = $this->_appSetting->apiLink . '/web-authentication?method=validateusername';
                 $curlResponse = $objCurlHandler->curlUsingPost($url, $data);
                 if ($curlResponse->code === 200) {
                     echo json_encode(true);
                 } else {
                     $arr = array("Username already exists");
                     echo json_encode($arr);
                 }
                 die;
                 break;
             case 'validateEmail':
                 $data['email'] = $this->getRequest()->getParam('email');
                 $url = $this->_appSetting->apiLink . '/web-authentication?method=validateemail';
                 $curlResponse = $objCurlHandler->curlUsingPost($url, $data);
                 if ($curlResponse->code === 200) {
                     echo json_encode(true);
                 } else {
                     $arr = array("Email already exists");
                     echo json_encode($arr, true);
                 }
                 die;
                 break;
         }
     } else {
         $response->message = 'Invalid Request';
         $response->code = 401;
         $response->data = 'No Method';
         echo json_encode($response, true);
         die;
     }
 }
 public function viewStoreDetailsAction()
 {
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     $store_id = $this->getRequest()->getParam('storeid');
     $url = $this->_appSetting->apiLink . '/storedetails?method=getStoreDetailsByStoreId';
     $data['store_id'] = $store_id;
     $curlResponse1 = $objCurlHandler->curlUsingPost($url, $data);
     if ($curlResponse1->code == 200) {
         $this->view->storedetails = $curlResponse1->data;
     }
 }
 public function setnickAction()
 {
     if ($this->getRequest()->isPost()) {
         $objCore = Engine_Core_Core::getInstance();
         $objSecuity = Engine_Vault_Security::getInstance();
         $this->_appSetting = $objCore->getAppSetting();
         $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
         $userId = $this->session->userId;
         $response = new stdClass();
         $nick = $this->getRequest()->getPost('nick');
         $data = array('uid' => $userId, 'nick' => $nick);
         // print_r($data);die;
         $url = $this->_appSetting->hostlink . '/user/set-nick';
         $response = $objCurlHandler->curlUsingPost($url, $data);
         // print_r($response);die("setnick");
         if ($response) {
             if ($response->code == 200) {
                 if ($response->data == 200) {
                     $response->code = 200;
                     echo json_encode($response);
                     exit;
                     //confirm
                 } else {
                     if ($response->data == 198) {
                         $response->code = 198;
                         echo json_encode($response);
                         exit;
                     }
                 }
             } else {
                 $response->code = 198;
                 echo json_encode($response);
                 exit;
             }
         }
     }
 }
 public function editStoreDetailsAction()
 {
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     $adminModel = Admin_Model_Users::getInstance();
     $locationsModel = Admin_Model_Location::getInstance();
     $result = $adminModel->getAdminDetails();
     // showing image
     if ($result) {
         $this->view->admindetails = $result;
     }
     $storeDetailsModel = Admin_Model_StoreDetails::getInstance();
     $agentid = $this->view->session->storage->user_id;
     $store_id = $this->getRequest()->getParam('storeId');
     $dt['store_id'] = $store_id;
     if ($this->getRequest()->isPost()) {
         $data['store_id'] = $store_id;
         $data['store_contact_number'] = $this->getRequest()->getPost('primary_phone');
         $data['secondary_phone'] = $this->getRequest()->getPost('secondary_phone');
         $data['Store_name'] = $this->getRequest()->getPost('store_name');
         $data['Open_time'] = $this->getRequest()->getPost('open_time');
         $data['Closing_time'] = $this->getRequest()->getPost('closing_time');
         $data['Notice'] = $this->getRequest()->getPost('notice');
         $data['store_status'] = $this->getRequest()->getPost('store_status');
         $data['store_address'] = $this->getRequest()->getPost('address');
         $data['Deliverycharge'] = $this->getRequest()->getPost('deliverycharge');
         $data['store_location'] = $this->getRequest()->getPost('selectlocation');
         $data['category_id'] = json_encode($this->getRequest()->getPost('category_id'));
         //            $data['Minorder'] = $this->getRequest()->getPost('minorder');
         $storelocation = $this->getRequest()->getPost('selectlocation');
         //to add new location while editing hotel details
         if (empty($storelocation)) {
             $data1['select_city'] = $this->getRequest()->getPost('selectcity');
             $location['name'] = $this->getRequest()->getPost('location_name');
             if ($data1['select_city']) {
                 $location['parent_id'] = $data1['select_city'];
                 $location['location_status'] = 1;
                 $location['location_type'] = 3;
                 $countryid = $this->getRequest()->getPost('selectcountry');
                 $stateid = $this->getRequest()->getPost('selectstate');
                 if ($countryid && $stateid && $location['parent_id']) {
                     $storelocation = $locationsModel->addLocationByParentIds($location, $stateid, $countryid);
                     //                            print_r($location_id);die;
                     if ($storelocation) {
                         $this->view->errormessage = 'Successfull';
                     } else {
                         $this->view->errormessage = 'Could not Serve the Response1';
                     }
                 } else {
                     $this->view->errormessage = 'Parametre missing';
                 }
             } else {
                 $this->view->errormessage = 'Could not Serve the Response';
             }
         }
         if (!empty($storelocation)) {
             $data['store_location'] = $storelocation;
             $coverphoto = $_FILES["fileToUpload"]["name"];
             $dirpath = getcwd() . "/themes/agent/skin/groceryimages/{$agentid}/{$store_id}/";
             if (!file_exists($dirpath)) {
                 mkdir($dirpath, 0777, true);
             }
             if (!empty($coverphoto)) {
                 $imagepath = $dirpath . $coverphoto;
                 $savepath = "/themes/agent/skin/groceryimages/{$agentid}/{$store_id}/{$coverphoto}";
                 $imageTmpLoc = $_FILES["fileToUpload"]["tmp_name"];
                 $ext = pathinfo($coverphoto, PATHINFO_EXTENSION);
                 if ($ext != "jpg" && $ext != "png" && $ext != "jpeg" && $ext != "gif") {
                     echo json_encode("Something went wrong image upload");
                     print_r("Something went wrong image upload");
                     die;
                 } else {
                     $imagemoveResult = move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $imagepath);
                     if ($imagemoveResult) {
                         $link = $this->_appSetting->hostLink;
                         $data['store_image'] = $link . $savepath;
                         $result1 = $storeDetailsModel->updateStoreDetails($store_id, $data);
                         if ($result1) {
                             $this->redirect('/admin/store-details');
                         }
                     } else {
                         $this->view->errormessage = 'store details not updated properly';
                         print_r("Something went wrong image upload");
                         die;
                     }
                 }
             } else {
                 $result1 = $storeDetailsModel->updateStoreDetails($store_id, $data);
                 if ($result1) {
                     $this->redirect('/admin/store-details');
                 }
             }
         }
     }
     $result = $storeDetailsModel->getStoreDetailsByID($store_id);
     $storecategoryModel = Admin_Model_StoreCategory::getInstance();
     $store_id = $this->getRequest()->getParam('storeId');
     $dt['store_id'] = $store_id;
     $result = $storeDetailsModel->getStoreDetailsByID($store_id);
     $categoryID = json_decode($result['category_id'], true);
     $i = 0;
     foreach ($categoryID as $categoryid) {
         $cat_id[$i] = $categoryid;
         $categoryname = $storecategoryModel->getCategoryById($categoryid);
         $categorynames[$i] = $categoryname['cat_name'];
         $i++;
     }
     $countrys = $locationsModel->getCountrys();
     if ($result) {
         $this->view->allstoredetails = $result;
         $this->view->countrylist = $countrys;
         $this->view->allStoreCategorynames = $categorynames;
         $this->view->categoryid = $cat_id;
     } else {
         echo 'controller error occured';
     }
 }
 public function editHotelCuisinesAction()
 {
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     if ($this->getRequest()->isPost()) {
         $data['Cuisine_name'] = $this->getRequest()->getPost('cuisine');
         $data['cuisine_id'] = $this->getRequest()->getPost('cuisine_id');
         $url = $this->_appSetting->apiLink . '/settingdetails?method=edithotelcuisines';
         $curlResponse = $objCurlHandler->curlUsingPost($url, $data);
         if ($curlResponse) {
             $this->redirect('/agent/hotel-cuisine');
         } else {
             $this->redirect('/agent/hotel-cuisine');
         }
     }
     $url = $this->_appSetting->apiLink . '/settingdetails?method=getCategories';
     $curlResponse = $objCurlHandler->curlUsingGet($url);
     if ($curlResponse->code == 200) {
         $this->view->categorydetails = $curlResponse->data;
     }
 }
 public function storeMyLocationAction()
 {
     // die("reportACrime");
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     if ($this->getRequest()->isPost()) {
         // die("ok");
         $objCore = Engine_Core_Core::getInstance();
         $objSecuity = Engine_Vault_Security::getInstance();
         $this->_appSetting = $objCore->getAppSetting();
         $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
         $response = new stdClass();
         $userId = $this->session->userId;
         $lat = $this->getRequest()->getPost('lat');
         $lng = $this->getRequest()->getPost('lng');
         $data = array('uid' => $userId, 'lat' => $lat, 'lon' => $lng);
         $url = $this->_appSetting->hostlink . '/user/set-location';
         $response = $objCurlHandler->curlUsingPost($url, $data);
         if ($response) {
             if ($response->code == 200) {
                 $this->session->lat = $lat;
                 $this->session->lon = $lng;
                 $response->code = 200;
                 echo json_encode($response);
                 // exit();
             } else {
                 $response->code = 198;
                 echo json_encode($response);
                 // exit();
             }
         }
     }
 }
 public function editStoreProductDetailsAction()
 {
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     $product_id = $this->getRequest()->getParam('prod_id');
     if ($this->getRequest()->isPost()) {
         $productdata['name'] = $this->getRequest()->getPost('name');
         $productdata['prod_desc'] = $this->getRequest()->getPost('prod_desc');
         $productdata['cost'] = $this->getRequest()->getPost('cost');
         $productdata['prod_status'] = $this->getRequest()->getPost('prod_status');
         $productdata['delivery_time'] = $this->getRequest()->getPost('delivery_time');
         $productdata['product_discount'] = $this->getRequest()->getPost('product_discount');
         $productdata['product_discount_type'] = $this->getRequest()->getPost('product_discount_type');
         $productdata['prod_type'] = $this->getRequest()->getPost('prod_type');
         $productdata['item_type'] = 2;
         $productdata['stock_quantity'] = $this->getRequest()->getPost('stock_quantity');
         $productdata['store_category_id'] = $this->getRequest()->getPost('store_category_id');
         $productdata['servicetax'] = $this->getRequest()->getPost('servicetax');
         $productdata['product_id'] = $product_id;
         $coverphoto = $_FILES["fileToUpload"]["name"];
         $dirpath = getcwd() . "/themes/agent/skin/productimages/{$product_id}/";
         if (!file_exists($dirpath)) {
             mkdir($dirpath, 0777, true);
         }
         if (!empty($coverphoto)) {
             $imagepath = $dirpath . $coverphoto;
             $savepath = "/themes/agent/skin/productimages/{$product_id}/{$coverphoto}";
             $imageTmpLoc = $_FILES["fileToUpload"]["tmp_name"];
             $ext = pathinfo($coverphoto, PATHINFO_EXTENSION);
             if ($ext != "jpg" && $ext != "png" && $ext != "jpeg" && $ext != "gif") {
                 echo json_encode("Something went wrong image upload");
             } else {
                 $imagemoveResult = move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $imagepath);
                 if ($imagemoveResult) {
                     $link = $this->_appSetting->hostLink;
                     $productdata['imagelink'] = $link . $savepath;
                     $url = $this->_appSetting->apiLink . '/restaurent-menu-card?method=updateproductdetails';
                     $curlResponse = $objCurlHandler->curlUsingPost($url, $productdata);
                     if ($curlResponse->code == 200) {
                         $this->redirect('/agent/product-details');
                     }
                 } else {
                     echo "DIE HERE";
                     die;
                 }
             }
         } else {
             $url = $this->_appSetting->apiLink . '/restaurent-menu-card?method=updateproductdetails';
             $curlResponse = $objCurlHandler->curlUsingPost($url, $productdata);
             if ($curlResponse->code == 200) {
                 $this->redirect('/agent/product-details');
             }
         }
     }
     $url = $this->_appSetting->apiLink . '/restaurent-menu-card?method=getproductbyproductId';
     $data['product_id'] = $product_id;
     $curlResponse = $objCurlHandler->curlUsingPost($url, $data);
     if ($curlResponse->code == 200) {
         $this->view->editproductdetails = $curlResponse->data;
     }
     $url = $this->_appSetting->apiLink . '/restaurent-menu-card?method=getstoreproductbyproductId';
     $data['product_id'] = $product_id;
     $curlResponse2 = $objCurlHandler->curlUsingPost($url, $data);
     if ($curlResponse2->code == 200) {
         $this->view->storeproductdetails = $curlResponse2->data;
     }
     $url2 = $this->_appSetting->apiLink . '/storedetails?method=storeCategory';
     $curlResponse5 = $objCurlHandler->curlUsingGet($url2);
     if ($curlResponse5->code == 200) {
         $this->view->storecategorylist = $curlResponse5->data;
     }
 }
 public function restaurantDetailsByCuisinesAction()
 {
     $mailer = Engine_Mailer_Mailer::getInstance();
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     $hotel_location = $this->getRequest()->getParam('hotel_location');
     if ($hotel_location) {
         $loc['hotel_location'] = $hotel_location;
         $this->view->cuisinesList = $hotel_location;
         /*             * **** Display of restaurant  details***** */
         $url = $this->_appSetting->apiLink . '/restaurent-menu-card?method=getcuisines';
         $curlResponse = $objCurlHandler->curlUsingPost($url, $loc);
         if ($curlResponse->code == 200) {
             $this->view->cuisinesList = $curlResponse->data;
         }
         //        $url = $this->_appSetting->apiLink . '/restaurent-menu-card?method=getcuisines';
         //        $curlResponse = $objCurlHandler->curlUsingGet($url);
         //        echo '<pre>';
         //        print_r($curlResponse);
         //        die("Test");
         //        if ($curlResponse->code === 200) {
         ////            setcookie('citys', json_encode($curlResponse->data, true));
         //            $this->view->cityslist = $curlResponse->data;
         //        }
     }
 }
 public function viewHotelDetailsAction()
 {
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     $hotel_id = $this->getRequest()->getParam('hotelid');
     $dt['hotel_id'] = $hotel_id;
     $url = $this->_appSetting->apiLink . '/restaurent-menu-card?method=getcuisinesofHotel';
     $curlResponse = $objCurlHandler->curlUsingPost($url, $dt);
     $i = 0;
     if ($curlResponse->code == 200) {
         foreach ($curlResponse->data as $value) {
             $array[$i] = $value['Cuisine_name'];
             $i++;
         }
         $this->view->cuisine123 = implode($array, ',');
     }
     $url = $this->_appSetting->apiLink . '/hoteldetails?method=getHotelDetailsByHotelId';
     $data['hotel_id'] = $hotel_id;
     $curlResponse1 = $objCurlHandler->curlUsingPost($url, $data);
     if ($curlResponse1->code == 200) {
         $this->view->hoteldetails = $curlResponse1->data;
     }
     $url = $this->_appSetting->apiLink . '/get-locations?method=getHotelLocation';
     $data['hotel_id'] = $hotel_id;
     $curlResponse2 = $objCurlHandler->curlUsingPost($url, $data);
     if ($curlResponse2->code == 200) {
         $this->view->hotellocation = $curlResponse2->data;
     }
 }
 public function viewRestuarentOrdersAction()
 {
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     $order_id = $this->getRequest()->getParam('oId');
     $dt['order_id'] = $order_id;
     $url = $this->_appSetting->apiLink . '/edit-order-products';
     $curlResponse = $objCurlHandler->curlUsingPost($url, $dt);
     if ($curlResponse->code == 200) {
         $this->view->orderdetails = $curlResponse->data;
     }
 }
 public function orderConfirmationAction()
 {
     $mailer = Engine_Mailer_Mailer::getInstance();
     $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance();
     $objCore = Engine_Core_Core::getInstance();
     $objSecurity = Engine_Vault_Security::getInstance();
     $this->_appSetting = $objCore->getAppSetting();
     if (isset($this->view->session->storage->user_id)) {
         $user_id = $this->view->session->storage->user_id;
     }
     $hotel_id = $this->getRequest()->getParam('hotel_id');
     $request = $this->getRequest()->getParams('order_id');
     $a1 = explode("=", $request['details']);
     if (!empty($a1[1])) {
         $this->view->orderid = $a1[1];
     }
     if ($hotel_id) {
         $loc['hotel_id'] = $hotel_id;
         $this->view->hotelId = $hotel_id;
         /*             * **** Display of restaurant  details***** */
         $url = $this->_appSetting->apiLink . '/restaurant-info-card?method=gethotelinfo';
         $curlResponse = $objCurlHandler->curlUsingPost($url, $loc);
         if ($curlResponse->code == 200) {
             $this->view->hoteldata = $curlResponse->data;
         }
         /// display cookies products display page
         //
         ////////// cart products display of logged user
         if (isset($_COOKIE['user_cartitems_cookie'])) {
             $cartitems = $_COOKIE['user_cartitems_cookie'];
             $cartitems = stripslashes($cartitems);
             $saved_cart_items = json_decode($cartitems, true);
             $ar['cookies_values'] = json_encode($saved_cart_items, true);
             $ar['hotel_id'] = $hotel_id;
             $url = $this->_appSetting->apiLink . '/restaurent-menu-card?method=getproductsByCookie';
             $Respo = $objCurlHandler->curlUsingPost($url, $ar);
             if ($Respo->code == 200) {
                 $data['subtotal'] = 0;
                 foreach ($Respo->data as $value) {
                     $data['subtotal'] += $value['cost'];
                 }
                 $this->view->addtocartproducts = $Respo->data;
                 $this->view->total = $data['subtotal'];
             }
         }
     }
     if ($this->getRequest()->isPost()) {
         //THEME OF ORDER CONFIRMATION//
         /* 1.user will enter all details like delivery details, and order messages etc
          * 
          * 2.first orders will get insert creating order id and 
          * 
          * 3. second cart prdocts will get insert
          *  
          * 4.Now the orderid and cart ids will get insert in order_product table
          * 
          * 5.while inserting products in order_products table need to check if product has any discout (amount or percentsge) that 
          *   discount will be added and final product cost will be inserted in pay_amount field in order_products table including discount details 
          * 
          * 6.now delivery details will get insert of the particular orderid
          * 
          * 
          * 7.if coupon code exists then that coupon amount will get deducted from SUM(pay_amount) in order_product table
          * and that final amount will get stored in order table 
          */
         ///////// insert order details ///////////
         $orderdata['delivery_type'] = $this->getRequest()->getPost('delivery_type');
         $orderdata['user_message'] = $this->getRequest()->getPost('user_message');
         if (isset($this->view->session->storage->user_id)) {
             $user_id = $this->view->session->storage->user_id;
             $orderdata['user_id'] = $user_id;
             $orderdata['order_date'] = date('Y-m-d H-i-s');
             $orderdata['delivery_status'] = 0;
             $orderset['orderdata'] = json_encode($orderdata, true);
             $url = $this->_appSetting->apiLink . '/order-process?method=insertwebuserorders';
             $Respo1 = $objCurlHandler->curlUsingPost($url, $orderset);
             if ($Respo1->code == 200) {
                 $order_id = $Respo1->data['order_id'];
                 if ($order_id) {
                     /////// insert cart details ///////////
                     if (isset($_COOKIE['user_cartitems_cookie'])) {
                         $cartitems = $_COOKIE['user_cartitems_cookie'];
                         $cartitems = stripslashes($cartitems);
                         $saved_cart_items = json_decode($cartitems, true);
                         $j = 0;
                         foreach ($saved_cart_items as $value) {
                             $saved_cart_items[$j]['user_id'] = $user_id;
                             $j++;
                         }
                         $bagitems['bagitems'] = json_encode($saved_cart_items, true);
                         $url = $this->_appSetting->apiLink . '/order-process?method=insertwebusercarts';
                         $Respo2 = $objCurlHandler->curlUsingPost($url, $bagitems);
                         if ($Respo2->code == 200) {
                             $cartids = $Respo2->data['cart_ids'];
                             //////// /////// insert order_product details ///////////
                             $k = 0;
                             foreach ($cartids as $value) {
                                 $cartarray[$k] = $value;
                                 $k++;
                             }
                             $bagitems['bagitems'] = json_encode($cartarray, true);
                             $url = $this->_appSetting->apiLink . '/order-process?method=getproductinfoofcarts';
                             $Respo3 = $objCurlHandler->curlUsingPost($url, $bagitems);
                             if ($Respo3->code == 200) {
                                 $finalcost = 0;
                                 $w = 0;
                                 foreach ($Respo3->data as $value) {
                                     $orderproducts[$w]['order_id'] = $order_id;
                                     $orderproducts[$w]['ordered_cart_id'] = $value['id'];
                                     $orderproducts[$w]['product_cost'] = $value['cost'];
                                     $orderproducts[$w]['product_discount'] = $value['product_discount'];
                                     if ($value['product_discount']) {
                                         if ($value['product_discount_type'] = 1) {
                                             $orderproducts[$w]['pay_amount'] = $value['cost'] * $value['product_discount'] / 100;
                                         } else {
                                             if ($value['product_discount_type'] = 2) {
                                                 $orderproducts[$w]['pay_amount'] = $value['cost'] - $value['product_discount'];
                                             } else {
                                                 $orderproducts[$w]['pay_amount'] = $value['cost'];
                                             }
                                         }
                                     } else {
                                         $orderproducts[$w]['pay_amount'] = $value['cost'];
                                     }
                                     if (isset($finalcost)) {
                                         $finalcost += $orderproducts[$w]['pay_amount'];
                                     } else {
                                         $finalcost += $orderproducts[$w]['pay_amount'];
                                     }
                                     $orderproducts[$w]['quantity'] = $value['quantity'];
                                     //$orderproducts['coupon_id'] = $value['coupon_id'];
                                     $orderproducts[$w]['hotel_id'] = $value['hotel_id'];
                                     $w++;
                                 }
                                 if ($orderproducts) {
                                     $orproducts['order_products'] = json_encode($orderproducts, true);
                                     $url = $this->_appSetting->apiLink . '/order-process?method=insertuserorderproducts';
                                     $Respo4 = $objCurlHandler->curlUsingPost($url, $orproducts);
                                 }
                             }
                         }
                     }
                     /////// insert delivery details ///////////
                     $delivery['first_name'] = $this->getRequest()->getPost('first_name');
                     $delivery['last_name'] = $this->getRequest()->getPost('last_name');
                     $delivery['Contact_no'] = $this->getRequest()->getPost('Contact_no');
                     $delivery['Contact_email'] = $this->getRequest()->getPost('Contact_email');
                     $delivery['Contact_address'] = $this->getRequest()->getPost('Contact_address');
                     $delivery['city'] = $this->getRequest()->getPost('city');
                     $deliveryaddress['house-no/name'] = $this->getRequest()->getPost('house-no/name');
                     $deliveryaddress['localityaddress'] = $this->getRequest()->getPost('localityaddress');
                     $deliveryaddress['nearby'] = $this->getRequest()->getPost('nearby');
                     $delivery['delivery_addr'] = json_encode($deliveryaddress);
                     $delivery['order_id'] = $order_id;
                     $deliver['deliver'] = json_encode($delivery, true);
                     $url = $this->_appSetting->apiLink . '/order-process?method=insertuserdeliverydetails';
                     $Respo5 = $objCurlHandler->curlUsingPost($url, $deliver);
                     ///////////coupon details and calculation , updating in order table ///////////////
                     $couponcode = $this->getRequest()->getPost('coupon_code');
                     // checking couponcode  with code in coupon table and insert that id in orders table///
                     //deducting the coupon code amount with the total cost of all products in order and  inserting it in total amount in order table//
                     ////updating finalorder amount///////
                     $orderamount['total_amount'] = $finalcost;
                     $orderamount['order_id'] = $order_id;
                     $url = $this->_appSetting->apiLink . '/order-process?method=updateuserorderdetails';
                     $Respo6 = $objCurlHandler->curlUsingPost($url, $orderamount);
                     if ($Respo6->code == 200) {
                         $this->_redirect('/order-confirmation/' . $hotel_id . '/-for-the-restaurant-Chanakya Restrurent-way-to-make-payment&order_id=' . $order_id . '');
                     } else {
                         $this->view->message = 'your order is failed';
                     }
                 } else {
                     $this->view->message = 'your order is failed';
                     // do something if order_id is not present
                 }
             } else {
                 $this->view->message = 'your order is failed';
                 // do something if order is not get inserted
             }
         }
     }
 }