| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/holidaybyatlas/application/modules/tours/controllers/ |
Upload File : |
<?php
/* * ***********************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : PackageController.php
* File Desc. : Index controller for home page front end
* Created By : Piyush Tiwari <piyush@catpl.co.in>
* Created Date : 04 July 2018
* Updated Date : 21 July 2018
* Tours_PackageController | Tours Module / Index controller
* *************************************************************
*/
class Tours_PackageController extends Zend_Controller_Action {
protected $objMdl;
protected $objHelperGeneral;
protected $tablename;
public $baseUrl = '';
protected $gtxwebservicesURL;
protected $gtxagencysysid;
protected $CONST_PACKAGE_TRAVELER_MAX_ROOM;
protected $CONST_PACKAGE_TRAVELER_MAX_ADULT_IN_ROOM;
protected $CONST_PACKAGE_TRAVELER_MAX_CHILD_IN_ROOM;
protected $CONST_PACKAGE_TRAVELER_MAX_INFANT_IN_ROOM;
public $defaultTourListingImage;
public function init() {
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$BootStrap = $aConfig['bootstrap'];
$this->siteName = $BootStrap['siteName'];
$this->baseUrl = $BootStrap['siteUrl'];
$this->gtxwebservicesURL = $BootStrap['gtxwebserviceurl']; // get gtxwebserviceurl from application config
$this->gtxagencysysid = $BootStrap['gtxagencysysid']; // get gtxagencysysid from application config
$this->CONST_PACKAGE_TRAVELER_MAX_ROOM = $BootStrap['CONST_PACKAGE_TRAVELER_MAX_ROOM']; // get variable from application config
$this->CONST_PACKAGE_TRAVELER_MAX_ADULT_IN_ROOM = $BootStrap['CONST_PACKAGE_TRAVELER_MAX_ADULT_IN_ROOM']; // get variable from application config
$this->CONST_PACKAGE_TRAVELER_MAX_CHILD_IN_ROOM = $BootStrap['CONST_PACKAGE_TRAVELER_MAX_CHILD_IN_ROOM']; // get variable from application config
$this->CONST_PACKAGE_TRAVELER_MAX_INFANT_IN_ROOM = $BootStrap['CONST_PACKAGE_TRAVELER_MAX_INFANT_IN_ROOM']; // get variable from application config
$this->per_page_record = '100';
$this->objMdl = new Admin_Model_CRUD();
$this->tablename = "tb_tbb2c_packages_master";
$this->objHelperGeneral = $this->_helper->General;
$this->defaultTourListingImage = "default-tour-listing.jpg";
}
/*
* This function is used to search packages based on keywords typed by user on home page..
* @param void
* @return void
*/
public function indexAction(){
$params = $this->getRequest()->getParams();
$destinationname = explode('-', $params['des']);
$catnameArr = explode('-', $params['cat']);
$destname = '';
foreach ($destinationname as $desKey => $desValue) {
$destname .= $desValue.' ';
}
foreach ($catnameArr as $catKey => $catValue) {
$catname .= $catValue.' ';
}
$keywords = !empty($destname)?trim($destname):'';
$category = $catname;
$getMaxResults = $this->objMdl->rv_select_row($this->tablename, ['GROUP_CONCAT(MinPrice) as minPriceArray', 'MAX(Nights) as maxnight', 'MAX(MinPrice) as MaxPrice', 'MIN(MinPrice) as MinPrice'], ['IsFeatured' => 1, 'IsMarkForDel' => 0, 'IsActive' => 1, 'IsPublish' => 1], ['PkgSysId' => 'DESC']);
$staticPage = $this->objMdl->rv_select_all("tbl_pack_type", ['packType','banner_image'], ['Title'=>$category,'IsActive' => 1, 'IsMarkForDel' => 0], ['packType' => 'DESC'], '');
/*** chandra*******************/
$regionDescription = $this->objMdl->rv_select_all('tb_tbb2c_destinations', ['regionDescription','DesSysId','Title'], ['IsActive' => 1, 'IsMarkForDel' => 0,'Title'=>$keywords],['DesSysId'=>'ASC']);
$minPriceArray = explode(',', $getMaxResults['minPriceArray']);
$priceRange = $this->objHelperGeneral->getPriceDropdown($getMaxResults['MinPrice'], $getMaxResults['MaxPrice'], 5000, $minPriceArray);
$getData = array(
'destination' => trim($keywords),
'noofday' => $this->getRequest()->getParam("noofday"),
'pricerange' => $this->getRequest()->getParam("pricerange"),
'maxnight' => $getMaxResults['maxnight'],
);
if ($getData['destination'] != "") {
$selectTitle = explode(",", $getData['destination']);
$checkdata = $this->objMdl->selectOne('tb_tbb2c_destinations', ['Bannerimg', 'DesSysId','Keyword','Description','Metatag','regionDescription','seoHcontent','seoFcontent'], ['Title' => $selectTitle[0]]);
$this->view->DesSysId = $checkdata['DesSysId'];
}
$searchContArr = array('title'=>$keywords );
$this->objMdl->searchContArr = $searchContArr;
$countrydata = $this->objMdl->rv_select_all_countries();
$searchStateArr = array( 'title'=>$keywords );
$this->objMdl->searchStateArr = $searchStateArr;
$statedata = $this->objMdl->rv_select_all_states();
$searchRegionsArr = array( 'title'=>$keywords );
$this->objMdl->searchRegionsArr = $searchRegionsArr;
$regiondata = $this->objMdl->rv_select_all_region();
if(isset($countrydata[0]['bannerImage']) && $countrydata[0]['bannerImage'] !=''){
$bannerImage = 'public/upload/country/'.$countrydata[0]['countryId'].'/banner/{size}/'.$countrydata[0]['bannerImage'];
}else if(isset($regiondata[0]['banner_image']) && $regiondata[0]['banner_image'] !=''){
$bannerImage = 'public/upload/region/'.$regiondata[0]['sid'].'/banner/{size}/'.$regiondata[0]['banner_image'];
} else if(isset($statedata[0]['bannerImage']) && $statedata[0]['bannerImage'] !=''){
$bannerImage = 'public/upload/state/'.$statedata[0]['stateId'].'/banner/{size}/'.$statedata[0]['bannerImage'];
}else if(isset($checkdata['Bannerimg']) && $checkdata['Bannerimg'] !=''){
$bannerImage = 'public/upload/destinations/'.$checkdata['DesSysId'].'/banner/{size}/'.$checkdata['Bannerimg'];
}
if(isset($countrydata[0]) && !empty($countrydata[0])){
$detailLayout['Keyword'] = $countrydata[0]['metaKeyword']; // get package Keyword
$detailLayout['Description'] = $countrydata[0]['metaDescription']; // get package Description
$detailLayout['metaTitle'] = ($countrydata[0]['metaTitle']!='') ? $countrydata[0]['metaTitle'] : ucwords($keywords).' Holiday Packages'; // get package Metatag
$detailLayout['meta_header'] = ($countrydata[0]['meta_header']!='') ? $countrydata[0]['meta_header'] : ''; // get package Description
$detailLayout['meta_footer'] = ($countrydata[0]['meta_footer']!='') ? $countrydata[0]['meta_footer'] : ''; // get package Metatag
}else if(isset($regiondata[0]) && !empty ($regiondata[0])){
$detailLayout['Keyword'] = $regiondata[0]['Keyword']; // get package Keyword
$detailLayout['Description'] = $regiondata[0]['Description']; // get package Description
$detailLayout['metaTitle'] = ($regiondata[0]['Metatag']!='') ? $regiondata[0]['Metatag'] : ucwords($keywords).' Holiday Packages'; // get package Metatag
$detailLayout['meta_header'] = ($regiondata[0]['meta_header']!='') ? $regiondata[0]['meta_header'] : ''; // get package Description
$detailLayout['meta_footer'] = ($regiondata[0]['meta_footer']!='') ? $regiondata[0]['meta_footer'] : ''; // get package Metatag
}else if(isset($statedata[0]) && !empty ($statedata[0])){
$detailLayout['Keyword'] = $statedata[0]['metaKeyword']; // get package Keyword
$detailLayout['Description'] = $statedata[0]['metaDescription']; // get package Description
$detailLayout['metaTitle'] = ($statedata[0]['metaTitle']!='') ? $statedata[0]['metaTitle'] : ucwords($keywords).' Holiday Packages'; // get package Metatag
$detailLayout['meta_header'] = $statedata[0]['meta_header']; // get package Description
$detailLayout['meta_footer'] = ($statedata[0]['meta_footer']!='') ? $statedata[0]['meta_footer'] : ''; // get package Metatag
}else if(isset($checkdata) && !empty ($checkdata)){
$detailLayout['Keyword'] = $checkdata['Keyword']; // get package Keyword
$detailLayout['Description'] = $checkdata['Description']; // get package Description
$detailLayout['metaTitle'] = ($checkdata['Metatag']!='') ? $checkdata['Metatag'] : ucwords($keywords).' Holiday Packages'; // get package Metatag
$detailLayout['meta_header'] = $checkdata['seoHcontent']; // get package Description
$detailLayout['meta_footer'] = ($checkdata['seoFcontent']!='') ? $checkdata['seoFcontent'] : ''; // get package Metatag
}
if ($keywords == "" && $category != "") {
$staticPage = $this->objMdl->rv_select_all("tbl_pack_type", ['*'], ['IsActive' => 1, 'IsMarkForDel' => 0, 'Title' => ucwords($category)], ['packType' => 'DESC'], 1);
/* SEO KEYWORD */
$detailLayout = array();
$detailLayout['Keyword'] = $staticPage[0]['metaKeyword']; // get package Keyword
$detailLayout['Description'] = $staticPage[0]['metaDescription']; // get package Description
$detailLayout['metaTitle'] = ($staticPage[0]['metaTitle'] !='') ? $staticPage[0]['metaTitle'] : ucwords($category).' Packages';
if(trim($staticPage[0]['banner_image']) !=''){
$bannerImage = 'public/upload/pack/'.$staticPage[0]['packType'].'/banner/{size}/'.$staticPage[0]['banner_image'];
}
}
$this->view->detailLayout = $detailLayout;
$this->view->bannerImage = $bannerImage;
$noofday = isset($params['noofday']) ? $params['noofday'] : 1;
$noofdayMax = 6;
$filterDurationListArr = [];
for ($a = $noofday; $a <= $noofdayMax; $a++) {
$filterDurationListArr[] = $a;
}
$decodedPackageDestinationArray = array();
$packageDestinationArray = $this->curl_get($this->baseUrl . 'public/data/dynamic/package_destinations.json');
if(!empty($packageDestinationArray)){
$decodedPackageDestinationArray = Zend_Json::decode($packageDestinationArray);
}
$this->view->hcode = $hcode = !empty($this->getRequest()->getParam("hcode")) ? trim($this->getRequest()->getParam("hcode")) : '';
$this->view->cityid = $cityid = !empty($this->getRequest()->getParam("cid")) ? trim($this->getRequest()->getParam("cid")) : '';
$this->view->strcat = $strcat = ($keywords) ? trim($keywords) : '';
$this->view->citytxt = $citytxt = ($keywords) ? trim($keywords) : '';
$this->view->citytxt = $citytxt = ($keywords) ? trim($keywords) : '';
$this->view->UniqueSessionId = Zend_Session::getId();
$this->view->getData = $getData;
$this->view->priceRange = $priceRange;
$this->view->filterDurationListArr = $filterDurationListArr;
$this->view->baseUrl = $this->baseUrl;
$this->view->params = $params;
$this->view->CONST_PACKAGE_TRAVELER_MAX_ROOM = $this->CONST_PACKAGE_TRAVELER_MAX_ROOM;
$this->view->CONST_PACKAGE_TRAVELER_MAX_ADULT_IN_ROOM = $this->CONST_PACKAGE_TRAVELER_MAX_ADULT_IN_ROOM;
$this->view->CONST_PACKAGE_TRAVELER_MAX_CHILD_IN_ROOM = $this->CONST_PACKAGE_TRAVELER_MAX_CHILD_IN_ROOM;
$this->view->CONST_PACKAGE_TRAVELER_MAX_INFANT_IN_ROOM = $this->CONST_PACKAGE_TRAVELER_MAX_INFANT_IN_ROOM;
$this->view->defaultTourListingImage = $this->defaultTourListingImage;
$this->view->mydevice = $this->objHelperGeneral->getDevice();
$this->view->keywords = $keywords;
$this->view->themeImage = $staticPage;
$this->view->regionDescription = $regionDescription;
$this->view->packageDestinationArray = $decodedPackageDestinationArray;
}
public function getsearchdataAction() {
try {
$arrResponse = array();
$params = $this->getRequest()->getParams();
//echo"<pre>";print_r($params);die;
if ($params['type']) {
$type = !empty($params['type']) ? trim($params['type']) : '';
$keywords = !empty($params['key']) ? trim($params['key']) : '';
$objPackagesMaster = new Travel_Model_PackagesMaster();
$arrResponse = $objPackagesMaster->packageSearch($type,$keywords);
$data = $resultFinalArr = array();
//echo"<pre>";print_r($arrResponse);die;
if(!empty($arrResponse)){
$data = $this->objHelperGeneral->customiseForJsonV2($arrResponse, 'B2C');
$resultFinalArr = Zend_Json::decode($data, true);
// echo"<pre>";print_r($resultFinalArr);die;
$imgIndex = 1;
$arr = [];
$MyMparr = [];
foreach ($resultFinalArr['rows'] as $k => $val) {
$MyMparr[$val['PkgSysId']] = $val['mpArr'];
$arr[$k] = $imgIndex;
if ($imgIndex >= 3) {
$imgIndex = 1;
} else {
$imgIndex++;
}
}
$resultFinalArr['imgIndex'] = $arr;
$resultFinalArr['MyMparr'] = $MyMparr;
}
$resultFinalArr = Zend_Json::encode($resultFinalArr, true);
echo ($resultFinalArr);
exit;
}
// echo '<pre>';print_r($resultFinalArr);die('data');
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
/*
* This function is used to search packages based on keywords typed by user on home page..
* @param void
* @return void
*/
public function newAction() {
$params = $this->getRequest()->getParams();
// print_r($params); die;
// Get maximum total night
$getMaxResults = $this->objMdl->rv_select_row($this->tablename, ['GROUP_CONCAT(MinPrice) as minPriceArray', 'MAX(Nights) as maxnight', 'MAX(MinPrice) as MaxPrice', 'MIN(MinPrice) as MinPrice'], ['IsFeatured' => 1, 'IsMarkForDel' => 0, 'IsActive' => 1, 'IsPublish' => 1], ['PkgSysId' => 'DESC']);
$minPriceArray = explode(',', $getMaxResults['minPriceArray']);
$priceRange = $this->objHelperGeneral->getPriceDropdown($getMaxResults['MinPrice'], $getMaxResults['MaxPrice'], 10000, $minPriceArray);
$getData = array(
'destination' => trim($this->getRequest()->getParam("des")),
'noofday' => $this->getRequest()->getParam("noofday"),
'pricerange' => $this->getRequest()->getParam("pricerange"),
'maxnight' => $getMaxResults['maxnight'],
);
if ($getData['destination'] != "") {
$selectTitle = explode(",", $getData['destination']);
$checkdata = $this->objMdl->selectOne('tb_tbb2c_destinations', ['Bannerimg'], ['Title' => $selectTitle[0]]);
$bannerImage = $checkdata['Bannerimg'];
$this->view->bannerImage = $bannerImage;
}
// echo "<pre>"; print_r($bannerImage); die('test');
$this->view->getData = $getData;
$this->view->priceRange = $priceRange;
$noofday = isset($params['noofday']) ? $params['noofday'] : 1;
$noofdayMax = 6;
$filterDurationListArr = [];
for ($a = $noofday; $a <= $noofdayMax; $a++) {
$filterDurationListArr[] = $a;
}
$this->view->filterDurationListArr = $filterDurationListArr;
$this->view->baseUrl = $this->baseUrl;
$this->view->CONST_PACKAGE_TRAVELER_MAX_ROOM = $this->CONST_PACKAGE_TRAVELER_MAX_ROOM;
$this->view->CONST_PACKAGE_TRAVELER_MAX_ADULT_IN_ROOM = $this->CONST_PACKAGE_TRAVELER_MAX_ADULT_IN_ROOM;
$this->view->CONST_PACKAGE_TRAVELER_MAX_CHILD_IN_ROOM = $this->CONST_PACKAGE_TRAVELER_MAX_CHILD_IN_ROOM;
$this->view->CONST_PACKAGE_TRAVELER_MAX_INFANT_IN_ROOM = $this->CONST_PACKAGE_TRAVELER_MAX_INFANT_IN_ROOM;
$this->view->defaultTourListingImage = $this->defaultTourListingImage;
}
/**
* This function is used to fetch all records from database
* @param void
* @return json
* */
public function fetchallAction() {
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$params = $this->getRequest()->getParams();
// print_r($params); die;
$sid = $this->getRequest()->getParam('id');
$whereNights = $whereDestination = $wherePrice = '';
$where = [
'IsMarkForDel' => 0,
'IsActive' => 1,
'IsPublish' => 1,
'ItemType' => 1 // for Tour Package 1
];
if ($sid) {
$where['PkgSysId'] = $sid;
}
// param conditions
$str2 = '';
if (isset($params['noofday']) && !empty($params['noofday'])) {
$val = $params['noofday'];
$whereNights .= ' ( Nights >= ' . $val . ') ';
}
if ((isset($params['des']) && !empty($params['des'])) && ($params['des'] != 'all')) {
$temp = explode("RVSTR", $params['des']);
$str = $operator = '';
foreach ($temp as $k => $val) {
$operator = ($k != 0) ? ' OR ' : '';
if ($val) {
$str .= " $operator Destinations LIKE ('%" . $val . "%') OR Countries LIKE ('%" . $val . "%') ";
}
}
if ($str) {
$whereDestination .= ' (' . $str . ') ';
}
}
$str1 = '';
if (isset($params['pricerange']) && !empty($params['pricerange'])) {
if (strtolower($params['pricerange']) != 'all') {
$temp = explode("-", $params['pricerange']);
$operator = ( isset($temp[1]) && ( isset($temp[0]) && $temp[0]) ) ? ' AND ' : '';
if ($temp[0]) {
$val = $temp[0];
$str1 .= " MinPrice >= ('" . $val . "') ";
}
if ($temp[1]) {
$val = $temp[1];
$str1 .= " $operator MinPrice <= ('" . $val . "') ";
}
if ($str1) {
$wherePrice .= ' (' . $str1 . ')';
}
}
}
$whereCustom = " (1=1) ";
$whereCustom .= ($whereNights) ? " AND $whereNights " : "";
$whereCustom .= ($whereDestination) ? " AND $whereDestination " : "";
$whereCustom .= ($wherePrice) ? " AND $wherePrice " : "";
$currentTime = date('Y-m-d 00:00:00');
$whereCustom .= " AND ( (`PkgValidFrom` <= '$currentTime') AND (`PkgValidUntil` >= '$currentTime') ) ";
$whereCustom .= " AND ( `BookingValidUntil` >= '$currentTime') ";
$resultset = $this->objMdl->rv_select_all_custom_query($this->tablename, ['*'], $where, $whereCustom, ['MinPrice' => 'ASC'], $this->per_page_record);
// Zend_Debug::dump($resultset);
echo $this->objHelperGeneral->customiseForJsonV2($resultset, 'B2C');
}
function curl_get($url, array $get = NULL, array $options = array())
{
$defaults = array(
CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''). http_build_query($get),
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 4
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
if( ! $result = curl_exec($ch))
{
trigger_error(curl_error($ch));
}
curl_close($ch);
return $result;
}
}