public function addProductDetailsAction()
 {
     $adminModel = Admin_Model_Users::getInstance();
     $result = $adminModel->getAdminDetails();
     // showing image
     if ($result) {
         $this->view->admindetails = $result;
     }
     $productsModel = Admin_Model_Products::getInstance();
     $agentModel = Admin_Model_Agents::getInstance();
     $agentdetails = $agentModel->getAgentsDetails();
     if ($agentdetails) {
         $this->view->agentlist = $agentdetails;
     }
     if ($this->_request->isPost()) {
         $productdata['agent_id'] = $this->getRequest()->getPost('agent_id');
         $productdata['hotel_id'] = $this->getRequest()->getPost('hotel_id');
         $productdata['item_type'] = $this->getRequest()->getPost('item_type');
         $productdatatype = $this->getRequest()->getPost('product_type');
         $productdatatype1 = $this->getRequest()->getPost('product_type1');
         $productdata['prod_type'] = $productdatatype . "," . $productdatatype1 . "";
         $productdata['category_id'] = $this->getRequest()->getPost('category_id');
         $productdata['cuisine_id'] = $this->getRequest()->getPost('cusine_id');
         $productdata['name'] = $this->getRequest()->getPost('name');
         $productdata['prod_desc'] = $this->getRequest()->getPost('prod_desc');
         $productdata['imagelink'] = $this->getRequest()->getPost('imagelink');
         $productdata['cost'] = $this->getRequest()->getPost('cost');
         $productdata['product_discount'] = $this->getRequest()->getPost('product_discount');
         $productdata['product_discount_type'] = $this->getRequest()->getPost('product_discount_type');
         $productdata['delivery_time'] = $this->getRequest()->getPost('delivery_time');
         $productdata['prod_status'] = $this->getRequest()->getPost('prod_status');
         $productdata['servicetax'] = $this->getRequest()->getPost('servicetax');
         if ($productdata) {
             $productId = $productsModel->addProductsdetails($productdata);
             if ($productId) {
                 $coverphoto = $_FILES["fileToUpload"]["name"];
                 $dirpath = getcwd() . "/assets/productimages/{$productId}/";
                 if (!file_exists($dirpath)) {
                     mkdir($dirpath, 0777, true);
                 }
                 if (!empty($coverphoto)) {
                     $imagepath = $dirpath . $coverphoto;
                     $savepath = "/assets/productimages/{$productId}/{$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;
                             $product['imagelink'] = $link . $savepath;
                             $result3 = $productsModel->updateProductsdetails($productId, $product);
                             if ($result3) {
                                 $this->redirect('/admin/product-details');
                             } else {
                                 $this->view->errormessage = 'Product image not updated ';
                             }
                         } else {
                             $this->view->errormessage = 'Product image not updated ';
                         }
                     }
                 } else {
                     $this->redirect('/admin/product-details');
                 }
             }
         }
     }
 }
 public function sendAgentNotificationAction()
 {
     $adminModel = Admin_Model_Users::getInstance();
     $result = $adminModel->getAdminDetails();
     // showing image
     if ($result) {
         $this->view->admindetails = $result;
     }
     $objAgentsModel = Admin_Model_Agents::getInstance();
     $AgentsDetails = $objAgentsModel->getAgentsDetails();
     $this->view->data = $AgentsDetails;
 }
 public function dashboardAction()
 {
     $adminModel = Admin_Model_Users::getInstance();
     $result = $adminModel->getAdminDetails();
     // showing image
     if ($result) {
         $this->view->admindetails = $result;
     }
     $userModel = Admin_Model_Users::getInstance();
     $result = $userModel->getUserdetails();
     if ($result) {
         $this->view->userdetails = count($result);
     }
     $usertransactionModel = Admin_Model_UserTransactions::getInstance();
     $result1 = $usertransactionModel->getAllUsertransaction();
     if ($result1) {
         $this->view->usertransaction = count($result1);
     }
     $ordersModel = Admin_Model_Orders::getInstance();
     $result2 = $ordersModel->getAllHotelOrder();
     if ($result2) {
         $this->view->orderdetails = count($result2);
     }
     $ordersModel1 = Admin_Model_Orders::getInstance();
     $result21 = $ordersModel->getAllStoreOrder();
     if ($result21) {
         $this->view->storeorderdetails = count($result21);
     }
     $productsModel = Admin_Model_Products::getInstance();
     $result3 = $productsModel->getProductsdetails();
     if ($result3) {
         $this->view->productsdetails = count($result3);
     }
     $productsModel1 = Admin_Model_Products::getInstance();
     $result31 = $productsModel1->getAllStoreProductdetails();
     if ($result31) {
         $this->view->productsdetails = count($result31);
     }
     $agentsModel = Admin_Model_Agents::getInstance();
     $result4 = $agentsModel->getAgentsDetails();
     if ($result4) {
         $this->view->agentsdetails = count($result4);
     }
     $storeDetailsModel = Admin_Model_StoreDetails::getInstance();
     $result5 = $storeDetailsModel->getAllStore();
     if ($result5) {
         $this->view->storedetails = count($result5);
     }
     $hotelDetailsModel = Admin_Model_HotelDetails::getInstance();
     $result6 = $hotelDetailsModel->getAllHotels();
     if ($result6) {
         $this->view->hoteldetails = count($result6);
     }
     $agenttransactionModel = Admin_Model_AgentTransactions::getInstance();
     $result7 = $agenttransactionModel->getAllAgenttransaction();
     if ($result7) {
         $this->view->agenttransaction = count($result7);
     }
     $producttransactionModel = Admin_Model_ProductTransactions::getInstance();
     $result8 = $producttransactionModel->getAllProducttransaction();
     if ($result8) {
         $this->view->producttransaction = count($result8);
     }
     $storeCategoryDetailsModel = Admin_Model_StoreCategory::getInstance();
     $result9 = $storeCategoryDetailsModel->selectAllCategorys();
     if ($result9) {
         $this->view->storecategorydetails = count($result9);
     }
     $DeliveryGuysModel = Admin_Model_DeliveryGuys::getInstance();
     $result10 = $DeliveryGuysModel->getAllDeliveryGuys();
     if ($result10) {
         $this->view->DeliveryGuys = count($result10);
     }
     $NotificationModel = Admin_Model_Notification::getInstance();
     $result11 = $NotificationModel->getNotificationDetail();
     if ($result11) {
         $this->view->Notification = count($result11);
     }
     $ReviewsModel = Admin_Model_Reviews::getInstance();
     $result12 = $ReviewsModel->getAllHotelReviews();
     if ($result12) {
         $this->view->HotelReviews = count($result12);
     }
     $ReviewModel = Admin_Model_Reviews::getInstance();
     $result13 = $ReviewModel->getAllStoreReviews();
     if ($result13) {
         $this->view->StoreReviews = count($result13);
     }
     $locationsModel1 = Admin_Model_Location::getInstance();
     $result14 = $locationsModel1->getCountrys();
     if ($result14) {
         $this->view->CountryDetails = count($result14);
     }
     $locationsModel2 = Admin_Model_Location::getInstance();
     $result15 = $locationsModel2->getStates();
     if ($result15) {
         $this->view->StateDetails = count($result15);
     }
     $locationsModel3 = Admin_Model_Location::getInstance();
     $result16 = $locationsModel3->getCitys();
     if ($result16) {
         $this->view->CityDetails = count($result16);
     }
     $locationsModel4 = Admin_Model_Location::getInstance();
     $result17 = $locationsModel4->getLocations();
     if ($result17) {
         $this->view->LocationDetails = count($result17);
     }
     $cuisinesModel = Admin_Model_FamousCuisines::getInstance();
     $result18 = $cuisinesModel->getCuisines();
     if ($result18) {
         $this->view->CuisineDetails = count($result18);
     }
     $categoryModel = Admin_Model_MenuCategory::getInstance();
     $result19 = $categoryModel->selectAllCategorys();
     if ($result19) {
         $this->view->CategoryDetails = count($result19);
     }
     $objModelCoupons = Admin_Model_Coupons::getInstance();
     $allCoupons = $objModelCoupons->getCoupons();
     if ($allCoupons) {
         $this->view->allcoupons = count($allCoupons);
     }
     $objModelCouponUsers = Admin_Model_CouponUsers::getInstance();
     $couponsLog = $objModelCouponUsers->getCouponsLog();
     if ($couponsLog) {
         $this->view->couponsLog = count($couponsLog);
     }
 }
 public function userAjaxHandlerAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $userModel = Admin_Model_Users::getInstance();
     $usermetaModel = Admin_Model_Usermeta::getInstance();
     $addtocartModel = Admin_Model_Addtocart::getInstance();
     $userDeliveryAddressModel = Admin_Model_UserDeliveryAddress::getInstance();
     $hotelDetailsModel = Admin_Model_HotelDetails::getInstance();
     $productsModel = Admin_Model_Products::getInstance();
     $agentsModal = Admin_Model_Agents::getInstance();
     $delguyModal = Admin_Model_DeliveryGuys::getInstance();
     $storeDetailsModel = Admin_Model_StoreDetails::getInstance();
     $userTransModal = Admin_Model_UserTransactions::getInstance();
     $agentTransModal = Admin_Model_AgentTransactions::getInstance();
     $productTransModal = Admin_Model_ProductTransactions::getInstance();
     $orderModal = Admin_Model_Orders::getInstance();
     if ($this->getRequest()->isPost()) {
         $method = $this->getRequest()->getParam('method');
         switch ($method) {
             case 'useractive':
                 $userstate = $this->getRequest()->getParam('userid');
                 $ok = $userModel->getstatustodeactivate($userstate);
                 if ($ok) {
                     echo $userstate;
                 } else {
                     echo "Error";
                 }
                 break;
                 // added by sowmya 11/4/2016
             // added by sowmya 11/4/2016
             case 'userdelete':
                 $userid = $this->getRequest()->getParam('userid');
                 $result = $userModel->userdelete($userid);
                 if ($result) {
                     $result1 = $usermetaModel->usermetadelete($userid);
                     $result2 = $addtocartModel->addToCartDeleteByUserId($userid);
                     $result3 = $userTransModal->userDeleteByUserId($userid);
                     $result4 = $productTransModal->productDeleteByUserId($userid);
                     $result5 = $orderModal->orderDeleteByUserId($userid);
                     $result6 = $userDeliveryAddressModel->userDeliveryAddressByUserId($userid);
                     echo $result;
                     '<br>';
                     echo $result1;
                     '<br>';
                     echo $result2;
                     '<br>';
                     echo $result3;
                     '<br>';
                     echo $result4;
                     '<br>';
                     echo $result5;
                     '<br>';
                     echo $result6;
                 } else {
                     echo "error";
                 }
                 break;
             case 'agentactive':
                 $userstate = $this->getRequest()->getParam('agentid');
                 $ok = $agentsModal->getstatustodeactivate($userstate);
                 if ($ok) {
                     echo $userstate;
                     return $userstate;
                 } else {
                     echo "Error";
                 }
                 break;
                 // added by sowmya 11/4/2016
             // added by sowmya 11/4/2016
             case 'agentdelete':
                 $agentid = $this->getRequest()->getParam('agentid');
                 $result = $agentsModal->agentdelete($agentid);
                 if ($result) {
                     $result1 = $agentTransModal->agentDeleteByAgentId($agentid);
                     $result2 = $hotelDetailsModel->hotelDeleteByAgentId($agentid);
                     $result3 = $productsModel->productDeleteByAgentId($agentid);
                     echo $result;
                     '<br>';
                     echo $result1;
                     '<br>';
                     echo $result2;
                     '<br>';
                     echo $result3;
                 } else {
                     echo "error";
                 }
                 break;
             case 'delguystatus':
                 $delguyid = $this->getRequest()->getParam('delguyid');
                 $ok = $delguyModal->getstatustodeactivate($delguyid);
                 if ($ok) {
                     echo $delguyid;
                     return $delguyid;
                 } else {
                     echo "Error";
                 }
                 break;
             case 'delguydelete':
                 $delguyid = $this->getRequest()->getParam('delguyid');
                 $result = $delguyModal->deliveryGuydelete($delguyid);
                 if ($result) {
                     echo $result;
                 } else {
                     echo "error";
                 }
                 break;
                 //added by sowmya 30/3/2016
             //added by sowmya 30/3/2016
             case 'transdelete':
                 $transid = $this->getRequest()->getParam('transid');
                 $result = $userTransModal->transDelete($transid);
                 if ($result) {
                     echo $result;
                 } else {
                     echo "error";
                 }
                 break;
                 //added by sowmya 30/3/2016
             //added by sowmya 30/3/2016
             case 'orderdelete':
                 $orderid = $this->getRequest()->getParam('orderid');
                 $result = $orderModal->orderDelete($orderid);
                 if ($result) {
                     echo $result;
                 } else {
                     echo "error";
                 }
                 break;
                 //added by sowmya 4/4/2016
             //added by sowmya 4/4/2016
             case 'agenttransdelete':
                 $transid = $this->getRequest()->getParam('transid');
                 $result = $agentTransModal->transDelete($transid);
                 if ($result) {
                     echo $result;
                 } else {
                     echo "error";
                 }
                 break;
                 //added by sowmya 4/4/2016
             //added by sowmya 4/4/2016
             case 'producttransdelete':
                 $transid = $this->getRequest()->getParam('transid');
                 $result = $productTransModal->transDelete($transid);
                 if ($result) {
                     echo $result;
                 } else {
                     echo "error";
                 }
                 break;
             case "OrderStatusChange":
                 //This method is use to change the status of merchant as well as his store.
                 $orderId = $this->_request->getParam('orderId');
                 $orderStatus = $this->_request->getParam('orderStatus');
                 $changed = $orderModal->changeOrderStatus($orderId);
                 if ($changed) {
                     $changed = $orderModal->updateOrderStatus($orderId, $orderStatus);
                     echo 1;
                 } else {
                     echo 0;
                 }
                 break;
             case 'findhotel':
                 $locationid = $this->_request->getParam('locationid');
                 $result = $hotelDetailsModel->getHotelDetailsByLocation($locationid);
                 if ($result) {
                     echo json_encode($result);
                 } else {
                     echo "error";
                 }
                 break;
             case 'findstore':
                 $locationid = $this->_request->getParam('locationid');
                 $result = $storeDetailsModel->getStoreDetailsByLocation($locationid);
                 if ($result) {
                     echo json_encode($result);
                 } else {
                     echo "error";
                 }
                 break;
         }
     }
 }
 public function viewAgentDetailsAction()
 {
     $adminModel = Admin_Model_Users::getInstance();
     $result = $adminModel->getAdminDetails();
     // showing image
     if ($result) {
         $this->view->admindetails = $result;
     }
     $agentsModel = Admin_Model_Agents::getInstance();
     $agentid = $this->getRequest()->getParam('agentid');
     $agentdetails = $agentsModel->getAgentsDetailsByAgentID($agentid);
     if ($agentdetails) {
         $this->view->agentdetails = $agentdetails;
     }
 }