public function editAction() { $id = $this->_getParam('id', 0); if ($id > 0) { $products = new Application_Model_Products(); $this->view->entries = $products->find($id); } }
public static function getInstance() { if (!is_object(self::$_instance)) { self::$_instance = new Application_Model_Products(); } return self::$_instance; }
public function productAction() { // action body $id = $this->_getParam('id', 0); $code = $this->_getParam('productcode', ''); $product = new Application_Model_Products(); if ($id > 0) { $this->_helper->json($product->find($id)); } if ($code != '') { $code = trim($code); $where = "ProductCode='" . $code . "'"; $info = $product->fetchAll('Id', $where); if (isset($info['products'][0]['Id'])) { $this->_helper->json($product->find($info['products'][0]['Id'])); } else { $this->_helper->json(''); } } }
public function restaurantInfoCardAction() { $locationsmodal = Application_Model_Location::getInstance(); $hoteldetailsModal = Application_Model_HotelDetails::getInstance(); $productdetailsModal = Application_Model_Products::getInstance(); $response = new stdClass(); $method = $this->getRequest()->getParam('method'); if ($method) { switch ($method) { case 'getmenulist': if ($this->getRequest()->isPost()) { $hotel_id = $this->getRequest()->getPost('hotel_id'); if ($hotel_id) { $restuarentsmenudetails = $productdetailsModal->getRestaurentsMenuDetails($hotel_id); if ($restuarentsmenudetails) { $response->message = 'Successfull'; $response->code = 200; $response->data = $restuarentsmenudetails; } else { $response->message = 'Could not Serve the Response'; $response->code = 197; $response->data = NUll; } } } else { $response->message = 'Could not Serve the Response'; $response->code = 197; $response->data = NUll; } echo json_encode($response, true); die; break; case 'gethotelinfo': if ($this->getRequest()->isPost()) { $hotel_id = $this->getRequest()->getPost('hotel_id'); if ($hotel_id) { $restuarentsmenudetails = $hoteldetailsModal->getHoteldetailsByHotelId($hotel_id); if ($restuarentsmenudetails) { $response->message = 'Successfull'; $response->code = 200; $response->data = $restuarentsmenudetails; } else { $response->message = 'Could not Serve the Response'; $response->code = 197; $response->data = NUll; } } } else { $response->message = 'Could not Serve the Response'; $response->code = 197; $response->data = NUll; } echo json_encode($response, true); die; break; } } else { $response->message = 'Could not Serve the Response'; $response->code = 197; $response->data = NUll; } echo json_encode($response, true); die; }
public function productsSummaryAction() { $productsummaryModel = Application_Model_Products::getInstance(); $response = new stdClass(); $method = $this->getRequest()->getParam('method'); if ($method) { switch ($method) { case 'allproducts': $productdetails = $productsummaryModel->selectAllProducts(); if ($productdetails) { $response->message = 'Successfull'; $response->code = 200; $response->data = $productdetails; } else { $response->message = 'Could not Serve the Response'; $response->code = 197; $response->data = NUll; } echo json_encode($response, true); die; break; case 'getagentproducts': if ($this->getRequest()->isPost()) { $agent_id = $this->getRequest()->getPost('agent_id'); if ($agent_id) { $agentproducts = $productsummaryModel->getALLAgentProducts($agent_id); if ($agentproducts) { $response->message = 'successfull'; $response->code = 200; $response->data = $agentproducts; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; case 'getProductsByHotelId': if ($this->getRequest()->isPost()) { $hotelid = $this->getRequest()->getPost('hotel_id'); if ($hotelid) { $agentproducts = $productsummaryModel->getProductsByHotelId($hotelid); if ($agentproducts) { $response->message = 'successfull'; $response->code = 200; $response->data = $agentproducts; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; // added by sowmya 6/5/2016 to get store product details in agent panel // added by sowmya 6/5/2016 to get store product details in agent panel case 'getagentstoreproducts': if ($this->getRequest()->isPost()) { $agent_id = $this->getRequest()->getPost('agent_id'); if ($agent_id) { $agentproducts = $productsummaryModel->getALLAgentStoreProducts($agent_id); if ($agentproducts) { $response->message = 'successfull'; $response->code = 200; $response->data = $agentproducts; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; // added by sowmya 6/5/2016 to get store product details by store id in agent panel // added by sowmya 6/5/2016 to get store product details by store id in agent panel case 'getProductsByStoreId': if ($this->getRequest()->isPost()) { $store_id = $this->getRequest()->getPost('store_id'); if ($store_id) { $agentproducts = $productsummaryModel->getProductsByStoreId($store_id); if ($agentproducts) { $response->message = 'successfull'; $response->code = 200; $response->data = $agentproducts; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; case 'changeproductstatus': if ($this->getRequest()->isPost()) { $product_id = $this->getRequest()->getPost('product_id'); if ($product_id) { $updatestatus = $productsummaryModel->getstatusChangeOfProduct($product_id); if ($updatestatus) { $response->message = 'successfull'; $response->code = 200; $response->data['product_id'] = $product_id; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; case 'productdelete': if ($this->getRequest()->isPost()) { $product_id = $this->getRequest()->getPost('product_id'); if ($product_id) { $updatestatus = $productsummaryModel->productDelete($product_id); if ($updatestatus) { $response->message = 'successfull'; $response->code = 200; $response->data['product_id'] = $product_id; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = "No Method Passed"; echo json_encode($response, true); die; } }
public function addtoCartSummaryAction() { $Addtocart = Application_Model_Addtocart::getInstance(); $objProducts = Application_Model_Products::getInstance(); $response = new stdClass(); $method = $this->getRequest()->getParam('method'); if ($method) { switch ($method) { case 'InsertOrdersToCart': if ($this->getRequest()->isPost()) { $data['user_id'] = $this->getRequest()->getPost('userid'); $data['product_id'] = $this->getrequest()->getPost('productid'); $data['hotel_id'] = $this->getRequest()->getPost('hotelid'); $data['quantity'] = $this->getRequest()->getPost('quantity'); if ($data['user_id'] && $data['hotel_id']) { $productexists = $Addtocart->checkProductifExists($data['user_id'], $data['product_id'], $data['hotel_id']); if ($productexists) { $array = array('product_id' => $data['product_id'], 'hotel_id' => $data['hotel_id']); $response->message = 'Product Already Exists'; $response->code = 198; $response->data = $array; } else { $result = $Addtocart->insertCartProducts($data); if ($result) { if (!is_null($result)) { $response->message = 'successfull'; $response->code = 200; $response->data['cart_id'] = $result['cart_id']; $response->data['total'] = $result['total']; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } echo json_encode($response, true); die; } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; echo json_encode($response, true); die; } break; /* * Dev : Nitin Kumar Gupta * Desc : To insert the new cart product in table and update the existing cart product in table. * Date : 19 FEB 2016 */ /* * Dev : Nitin Kumar Gupta * Desc : To insert the new cart product in table and update the existing cart product in table. * Date : 19 FEB 2016 */ case 'InsertUpdateAllOrdersToCart': if ($this->getRequest()->isPost()) { $user_id = $this->getRequest()->getPost('userid'); $hotel_id = $this->getRequest()->getPost('hotelid'); $product_id = (array) json_decode($this->getrequest()->getPost('productid'), true); $quantity = (array) json_decode($this->getrequest()->getPost('quantity'), true); if ($user_id && $hotel_id && !empty($product_id) && !empty($quantity)) { if (sizeof($product_id) == sizeof($quantity)) { $availableOrNot = $objProducts->seperateTheProductsByQuantityAvailablity($product_id, $quantity); if (is_array($availableOrNot) && !empty($availableOrNot)) { if (array_key_exists('success', $availableOrNot)) { $updatedAndInsertedProduct = $Addtocart->insertUpdateProductInCart($user_id, $hotel_id, $availableOrNot['success'], $availableOrNot['quantity']); if (is_array($updatedAndInsertedProduct) && !empty($updatedAndInsertedProduct)) { $availableOrNot['success'] = $updatedAndInsertedProduct; unset($availableOrNot['quantity']); $response->message = 'Successfully inserted or updated the product in cart.'; $response->code = 200; $response->data = $availableOrNot; } else { $response->message = $updatedAndInsertedProduct; $response->code = 198; $response->data = Null; } } else { $response->message = 'All requested product has been out of stocks.'; $response->code = 200; $response->data = $availableOrNot; } } else { $response->message = $availableOrNot; $response->code = 198; $response->data = Null; } } else { $response->message = 'The number of product and quantity in array should be same.'; $response->code = 195; $response->data = NULL; } } else { $response->message = 'You should enter all params.'; $response->code = 195; $response->data = NULL; } } else { $response->message = 'You should use the post method'; $response->code = 195; $response->data = Null; } echo json_encode($response, true); die; break; case 'BulkInsertOrdersToCart': if ($this->getRequest()->isPost()) { $carts = $this->getRequest()->getPost('cart_items'); $cartitems = (array) json_decode($carts, true); if ($cartitems) { foreach ($cartitems as $value) { $result = $Addtocart->insertCartProducts($value); if ($result) { if (!is_null($result)) { $arr[] = $result; $response->message = 'successfull'; $response->code = 200; $response->data['cart_id'] = $arr; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } echo json_encode($response, true); die; } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; echo json_encode($response, true); die; } break; /* * Modyfied By : Nitin Kumar Gupta * Modyfied Date : 20 FEB 2016 */ /* * Modyfied By : Nitin Kumar Gupta * Modyfied Date : 20 FEB 2016 */ case 'getOrderToCart': if ($this->getRequest()->isPost()) { $user_id = $this->getRequest()->getPost('user_id'); $hotel_id = $this->getRequest()->getPost('hotel_id'); if ($user_id && $hotel_id) { $getaddtocartdetails = $Addtocart->getaddtocart($user_id, $hotel_id); if ($getaddtocartdetails) { $response->message = 'successfull'; $response->code = 200; $response->data = $getaddtocartdetails; echo json_encode($response, true); die; } else { $response->message = 'No Products available'; $response->code = 197; $response->data = null; } } else { $response->message = 'parametre not passed'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } echo json_encode($response, true); die; break; case 'getCartProductsByIds': if ($this->getRequest()->isPost()) { $user_id = $this->getRequest()->getPost('user_id'); $hotel_id = $this->getRequest()->getPost('hotel_id'); if ($user_id && $hotel_id) { $getaddtocartdetails = $Addtocart->getCartProductsByHotelIds($user_id, $hotel_id); if ($getaddtocartdetails) { $response->message = 'successfull'; $response->code = 200; $response->data = $getaddtocartdetails; echo json_encode($response, true); die; } else { $response->message = 'Could Not Serve The Request completely'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } echo json_encode($response, true); die; break; case 'RemoveOrderToCart': if ($this->getRequest()->isPost()) { $addtocartSerialNo = $this->getRequest()->getPost('cart_id'); $user_id = $this->getRequest()->getPost('user_id'); if ($addtocartSerialNo && $user_id) { $cartdetails = $Addtocart->RemoveAddtocartorder($addtocartSerialNo, $user_id); if ($cartdetails) { $response->message = 'successfully Deleted'; $response->code = 200; $response->data = $cartdetails; echo json_encode($response, true); die; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; /* * Dev : Priyanka Varanasi * Date: 18/1/2016 * Desc: update cart */ /* * Dev : Priyanka Varanasi * Date: 18/1/2016 * Desc: update cart */ case 'updateuserscart': if ($this->getRequest()->isPost()) { $productid = $this->getRequest()->getPost('productid'); $hotelid = $this->getRequest()->getPost('hotelid'); $inf['quantity'] = $this->getRequest()->getPost('quantity'); $userid = $this->getRequest()->getPost('userid'); $cost = $this->getRequest()->getPost('cost'); if ($productid && $userid && $cost && $hotelid) { $respo = $Addtocart->updateCart($userid, $productid, $inf, $cost, $hotelid); if ($respo) { if (!is_null($respo)) { $response->message = 'successfully updated'; $response->code = 200; $response->data = $respo; echo json_encode($response, true); die; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; /* * Dev : Priyanka Varanasi * Date: 18/1/2016 * Desc: delete cart */ /* * Dev : Priyanka Varanasi * Date: 18/1/2016 * Desc: delete cart */ case 'deleteitem': if ($this->getRequest()->isPost()) { $productid = $this->getRequest()->getPost('productid'); $hotelid = $this->getRequest()->getPost('hotelid'); $userid = $this->getRequest()->getPost('userid'); if ($productid && $userid && $hotelid) { $res = $Addtocart->deleteItem($userid, $productid, $hotelid); if ($res) { if (!is_null($res)) { $response->message = 'successfully updated'; $response->code = 200; $response->data = $res; echo json_encode($response, true); die; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = "No Method Passed"; echo json_encode($response, true); die; } }
public function orderProcessAction() { $ordersModel = Application_Model_Orders::getInstance(); $cartsModel = Application_Model_Addtocart::getInstance(); $productsModel = Application_Model_Products::getInstance(); $orderproductsModel = Application_Model_OrderProducts::getInstance(); $deliveryModal = Application_Model_UserDeliveryAddr::getInstance(); $response = new stdClass(); $method = $this->getRequest()->getParam('method'); if ($method) { switch ($method) { case 'insertwebuserorders': if ($this->getRequest()->isPost()) { $orderdata = $this->getRequest()->getPost('orderdata'); $order = (array) json_decode($orderdata, true); $orderId = $ordersModel->insertOrders($order); if ($orderId) { $response->message = 'successfull'; $response->code = 200; $response->data['order_id'] = $orderId; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } echo json_encode($response, true); die; break; case 'insertwebusercarts': if ($this->getRequest()->isPost()) { $cartitems = $this->getRequest()->getPost('bagitems'); $bagitems = (array) json_decode($cartitems, true); if ($bagitems) { $cartIds = $cartsModel->insertCartProducts($bagitems); if ($cartIds) { $response->message = 'successfull'; $response->code = 200; $response->data['cart_ids'] = $cartIds; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; case 'getproductinfoofcarts': if ($this->getRequest()->isPost()) { $carts = $this->getRequest()->getPost('bagitems'); $bag = (array) json_decode($carts, true); if ($bag) { $result = $cartsModel->getCartProductsByCartIds($bag); if ($result) { $response->message = 'successfull'; $response->code = 200; $response->data = $result; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; case 'insertuserorderproducts': if ($this->getRequest()->isPost()) { $order_products = $this->getRequest()->getPost('order_products'); $order_productsnew = (array) json_decode($order_products, true); if ($order_productsnew) { $result = $orderproductsModel->insertOrderedCartProducts($order_productsnew); if ($result) { $response->message = 'successfull'; $response->code = 200; $response->data = $result; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; case 'insertuserdeliverydetails': if ($this->getRequest()->isPost()) { $delivery = $this->getRequest()->getPost('deliver'); $deliverynew = (array) json_decode($delivery, true); if ($deliverynew) { $result = $deliveryModal->insertUserDeliveryAddress($deliverynew); if ($result) { $response->message = 'successfull'; $response->code = 200; $response->data = $result; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; case 'updateuserorderdetails': if ($this->getRequest()->isPost()) { $total_amount = $this->getRequest()->getPost('total_amount'); if (!empty($total_amount)) { $data['total_amount'] = $total_amount; } $pay_type = $this->getRequest()->getPost('pay_type'); if (!empty($pay_type)) { $data['pay_type'] = $pay_type; } $pay_status = $this->getRequest()->getPost('pay_status'); if (!empty($pay_status)) { $data['pay_status'] = $pay_status; } $order_status = $this->getRequest()->getPost('order_status'); if (!empty($order_status)) { $data['order_status'] = $order_status; } $delivery_status = $this->getRequest()->getPost('delivery_status'); if (!empty($delivery_status)) { $data['delivery_status'] = $delivery_status; } $order_id = $this->getRequest()->getPost('order_id'); if ($order_id && $data) { $result = $ordersModel->updateOrderDetails($data, $order_id); if ($result) { $response->message = 'successfull'; $response->code = 200; $response->data = $order_id; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; case 'updatepaymenttypedetails': if ($this->getRequest()->isPost()) { $order['pay_status'] = $this->getRequest()->getPost('pay_status'); $order['order_status'] = $this->getRequest()->getPost('order_status'); $order['delivery_status'] = $this->getRequest()->getPost('delivery_status'); $order['pay_type'] = $this->getRequest()->getPost('pay_type'); $order_id = $this->getRequest()->getPost('order_id'); if ($order && $order_id) { $result = $ordersModel->updateOrderDetails($order, $order_id); if ($result) { $response->message = 'successfull'; $response->code = 200; $response->data = $order_id; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = null; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; echo json_encode($response); die; } }