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 static function getInstance() { if (!is_object(self::$_instance)) { //or if( is_null(self::$_instance) ) or if( self::$_instance == null ) $objCore = Engine_Core_Core::getInstance(); $appSetting = $objCore->getAppSetting(); switch ($appSetting->mailSelector) { case 'Mandrill': self::$_instance = Engine_Mailer_MandrillApp_Mailer::getInstance(); break; case 'SendGrid': self::$_instance = Engine_Mailer_SendGrid_Mailer::getInstance(); break; default: throw new Zend_Controller_Action_Exception('Invalid Mail selector Passed', 500); break; } } return self::$_instance; }
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 indexAction() { $mailer = Engine_Mailer_Mailer::getInstance(); $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance(); $objCore = Engine_Core_Core::getInstance(); $objSecurity = Engine_Vault_Security::getInstance(); $this->_appSetting = $objCore->getAppSetting(); /* * temporary usage for user not to redirect to agent panel */ if ($this->view->auth->hasIdentity()) { $this->view->auth->clearIdentity(); Zend_Session::destroy(true); $this->_redirect('/agent/dashboard'); } /////////////////code ends //////////////// if ($this->getRequest()->isPost()) { $methodSelector = $this->getRequest()->getPost('agentform'); if ($methodSelector == 'agentsignup') { $first_name = $this->getRequest()->getPost('first_name'); $last_name = $this->getRequest()->getPost('last_name'); $username = $this->getRequest()->getPost('name'); $email = $this->getRequest()->getPost('email'); $password = $this->getRequest()->getPost('password'); $city = $this->getRequest()->getPost('city'); if (isset($first_name) && isset($last_name) && isset($username) && isset($email) && isset($password) && isset($city)) { $data = array('loginname' => $username, 'first_name' => $first_name, 'last_name' => $last_name, 'password' => md5($password), 'email' => $email, 'city' => $city, 'reg_date' => date('Y-m-d H-i-s'), 'role' => 4, 'agent_status' => 1, 'membership' => 1); $agentdata['agentdata'] = json_encode($data); $url = $this->_appSetting->apiLink . '/agent-authentication?method=agentsignup'; $curlResponse = $objCurlHandler->curlUsingPost($url, $agentdata); if ($curlResponse->code === 200) { //////////////////SEND EMAIL ///////////////////////////// $authStatus = $objSecurity->agentAuthenticate($email, md5($password)); } if ($authStatus->message == 'Authentication Successful') { // die('fdg'); $this->_redirect('/agent/dashboard'); } } } else { if ($methodSelector == 'agentlogin') { $loginData = $this->getRequest()->getPost('loginname'); $password = $this->getRequest()->getPost('pwd'); if (isset($loginData) && isset($password)) { $data['logindata'] = $loginData; $data['password'] = $password; $url = $this->_appSetting->apiLink . '/agent-authentication?method=agentlogin'; $curlResponse = $objCurlHandler->curlUsingPost($url, $data); if ($curlResponse->code == 200) { $authStatus = $objSecurity->agentAuthenticate($loginData, md5($password)); if ($authStatus) { $this->_redirect('/agent/dashboard'); } } else { $this->view->msg = "Please check your login credentials"; } } } } } }
public function activateAccountAction() { $token = $this->getRequest()->getParam('token'); if ($token) { $data = array('ActivationToken' => $token); $mailer = Engine_Mailer_Mailer::getInstance(); $objCurlHandler = Engine_Utilities_CurlRequestHandler::getInstance(); $response = new stdClass(); $objCore = Engine_Core_Core::getInstance(); // $this->_appSetting = $objCore->getAppSetting(); // $url = $this->_appSetting->apiLink . '/user-authentication?method=userSignupActivationLink'; $url = 'api.ziingo.com/user-authentication?method=userSignupActivationLink'; $curlResponse = $objCurlHandler->curlUsingPost($url, $data); if ($curlResponse->code == 200) { $this->view->successMsg = "Account Activation Successful...!!!"; } else { if ($curlResponse->code == 100) { $this->view->errorMsg = $curlResponse->message; } else { $this->_redirect('/'); //REDIRECT THIS TO 404 PAGE } } } }
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 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 } } } }