403Webshell
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/b2bzend/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2bzend/application/controllers/SightseeingController.php
<?php

/**
 * Class Sightseeing
 * @name		Sightseeing
 * @author		Praveen Kumar
 * @version 	1.0
 * @copyright 	Catabatic India Pvt Ltd
 * Handle Sightseeing Related function
 * Last Update : - Md Sabir
 */
class SightseeingController extends Catabatic_ValidateGtx
{

    //ini_set("display_errors", 0);

    private $intLoggedinUserId = '';
    private $intLoggedinUserGroupSysId = '';
    private $intLoggedinUserAgencySysId = '';
    private $intLoggedinUserTrxCurrency = '';
    private $IsB2CSite = false;
    public $baseUrl = '';
    public $siteUrl = '';


    public function init()
    {
        parent::init();
        $aConfig = $this->getInvokeArg('bootstrap')->getOptions();
        $this->siteUrl = $aConfig['bootstrap']['siteUrl'];
        ini_set("display_errors", 0);
        $sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
        //Zend_Session::rememberMe(60 * 60 * 24 * 7);
        $sessionLogin_user->lock();

        #get session variable
        $this->SupplierTypeSysId = 6;
        $this->InfoSourceSysId = '2'; // Information Source is Agent //
        $this->intLoggedinUserRole = $sessionLogin_user->UserRole;
        $this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
        $this->intLoggedinUserGroupSysId = $sessionLogin_user->intLoggedinUserGroupSysId;
        $this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
        $this->view->intLoggedinUserTrxCurrency = $this->intLoggedinUserTrxCurrency = $sessionLogin_user->intLoggedinUserTrxCurrency;
        $this->view->intLoggedinUserRole = $sessionLogin_user->UserRole;
        $this->view->IsB2CSite = $sessionLogin_user->IsB2CSite;

        //File Upload Directory Path
        $this->upload_dir = "/public/assets/images/Sightseeing/";
        $this->file_path = $_SERVER['DOCUMENT_ROOT'] . $this->upload_dir;

        // unlocking read-only lock
        if ($sessionLogin_user->isLocked()) {
            $sessionLogin_user->unLock();
        }
        //error_reporting(E_ALL);
    }

    public function indexAction()
    {
        $objSightseeing = new Travel_Model_TblSightseeing();
        $this->view->fullUrl = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
        //Get City List
        $cityList = $objSightseeing->getInventoryCityList($this->intLoggedinUserAgencySysId);
        $this->view->cityList = $cityList;

        //Get Sightseeing Group Type List 
        $this->view->arrSightseeingGroupTypeList = $objSightseeing->getAllSightseeingGroupTypeList();

        //Get Sightseeing Type List 
        $this->view->arrSightseeingTypeList = $objSightseeing->getAllSightseeingTypeList();

        //Get Supplier List
        $supplierList = $objSightseeing->getSuppliersList($cityId = '', $this->intLoggedinUserId);
        $this->view->supplierList = $supplierList;

        //Start Search Code
        $searchArr = array();
        $getData = array();
        if ($this->getRequest()->isPost()) {
            $getData = $this->getRequest()->getPost();

            if (!empty($getData)) {
                if (@$getData['cityId'] != 0) {
                    $DestinationId = @$getData['cityId'];
                } else {
                    $DestinationId = "";
                }
                if (@$getData['SightseeingGroupType'] != 0) {
                    $SightseeingGroupType = @$getData['SightseeingGroupType'];
                } else {
                    $SightseeingGroupType = "";
                }
                if (@$getData['SightseeingType'] != 0) {
                    $SightseeingType = @$getData['SightseeingType'];
                } else {
                    $SightseeingType = "";
                }

                if (@$getData['supplierId'] != 0) {
                    $supplierId = $getData['supplierId'];
                } else {
                    $supplierId = "";
                }
                if (@$getData['SightseeingName'] != "") {
                    $SightseeingName = $getData['SightseeingName'];
                } else {
                    $SightseeingName = "";
                }
                $searchArr = array(
                    'cityId' => $DestinationId,
                    'SightseeingGroupType' => $SightseeingGroupType,
                    'SightseeingType' => $SightseeingType,
                    'supplierId' => $supplierId,
                    'SightseeingName' => $SightseeingName
                );
            }
        } else {
            $DestinationId = $this->_getParam('cityId');
            $SightseeingGroupType = $this->_getParam('SightseeingGroupType');
            $SightseeingType = $this->_getParam('SightseeingType');
            $supplierId = $this->_getParam('supplierId');
            $SightseeingName = $this->_getParam('SightseeingName');
            if ($DestinationId != 0) {
                $DestinationId = $DestinationId;
            } else {
                $DestinationId = "";
            }
            if ($SightseeingGroupType != 0) {
                $SightseeingGroupType = $SightseeingGroupType;
            } else {
                $SightseeingGroupType = "";
            }
            if ($SightseeingType != 0) {
                $SightseeingType = $SightseeingType;
            } else {
                $SightseeingType = "";
            }
            if ($supplierId != 0) {
                $supplierId = $supplierId;
            } else {
                $supplierId = "";
            }
            if ($SightseeingName != "") {
                $SightseeingName = $SightseeingName;
            } else {
                $SightseeingName = "";
            }
            $searchArr = array(
                'cityId' => $DestinationId,
                'SightseeingGroupType' => $SightseeingGroupType,
                'SightseeingType' => $SightseeingType,
                'supplierId' => $supplierId,
                'SightseeingName' => $SightseeingName
            );
        }

        //echo "<pre>"; print_r($searchArr);
        $objSightseeing->searchArr = $searchArr;
        $this->view->searchArr = $searchArr;


        //Agency Id
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $SightseeingList = $objSightseeing->getAllSightseeingList($intLoggedinUserAgencySysId);
        //echo "<pre>"; print_r($SightseeingList);  die;
        //$this->view->sightseeingList = $SightseeingList;

        $page = $this->_getParam('page', 1);
        $paginator = Zend_Paginator::factory($SightseeingList);
        $paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
        $perPage = $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT); // number of items to show per page
        $this->view->paginator = $paginator;
        $this->view->totalrec = $paginator->getTotalItemCount();


        //For display message
        $this->view->messages = $this->_helper->flashMessenger->getMessages();
    }

    public function manageSightseeingAction()
    {
        $objSightseeing = new Travel_Model_TblSightseeing();
        $this->view->fullUrl = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
        //Agent Id

        if ($this->intLoggedinUserRole != 1) {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }

        //Get City List
        $cityList = $objSightseeing->getSightseeingCityList($intLoggedinUserId);
        $this->view->cityList = $cityList;

        $countryList = $objSightseeing->getSightseeingCountryList($intLoggedinUserId);
        $this->view->countryList = $countryList;


        //Get Sightseeing Type List 
        $this->view->arrSightseeingTypeList = $objSightseeing->getAllSightseeingTypeList();


        //Start Search Code
        $searchArr = array();
        $getData = array();
        if ($this->getRequest()->isPost()) {
            $getData = $this->getRequest()->getPost();

            if (!empty($getData)) {
                if (@$getData['cityId'] != 0) {
                    $DestinationId = @$getData['cityId'];
                } else {
                    $DestinationId = "";
                }

                if (@$getData['countryId'] != 0) {
                    $countryId = @$getData['countryId'];
                } else {
                    $countryId = "";
                }

                if (@$getData['SightseeingType'] != 0) {
                    $SightseeingType = @$getData['SightseeingType'];
                } else {
                    $SightseeingType = "";
                }
                if (@$getData['SightseeingName'] != "") {
                    $SightseeingName = $getData['SightseeingName'];
                } else {
                    $SightseeingName = "";
                }
                $searchArr = array(
                    'cityId' => $DestinationId,
                    'ContSysId' => $countryId,
                    'SightseeingType' => $SightseeingType,
                    'SightseeingName' => $SightseeingName
                );
            }
        } else {
            $DestinationId = $this->_getParam('cityId');
            $countryId = $this->_getParam('countryId');
            $SightseeingType = $this->_getParam('SightseeingType');
            $SightseeingName = $this->_getParam('SightseeingName');
            if ($DestinationId != 0) {
                $DestinationId = $DestinationId;
            } else {
                $DestinationId = "";
            }
            if ($countryId != 0) {
                $countryId = $countryId;
            } else {
                $countryId = "";
            }
            if ($SightseeingType != 0) {
                $SightseeingType = $SightseeingType;
            } else {
                $SightseeingType = "";
            }
            if ($SightseeingName != "") {
                $SightseeingName = $SightseeingName;
            } else {
                $SightseeingName = "";
            }
            $searchArr = array(
                'cityId' => $DestinationId,
                'ContSysId' => $countryId,
                'SightseeingType' => $SightseeingType,
                'SightseeingName' => $SightseeingName
            );
        }

        // echo "<pre>"; print_r($searchArr);
        $objSightseeing->searchSightseeingArr = $searchArr;
        $this->view->searchArr = $searchArr;


        $SightseeingList = $objSightseeing->getAllManageSightseeingListAgencyWise($intLoggedinUserId, $searchArr);
        // echo "<pre>"; print_r($SightseeingList);  die;
        //$this->view->sightseeingList = $SightseeingList;

        $page = $this->_getParam('page', 1);
        $paginator = Zend_Paginator::factory($SightseeingList);
        $paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
        $perPage = $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT); //  number of items to show per page
        $this->view->paginator = $paginator;
        $this->view->totalrec = $paginator->getTotalItemCount();

        // echo "<pre>"; print_r($SightseeingList);  die;

        //For display message
        $this->view->messages = $this->_helper->flashMessenger->getMessages();
    }

    public function addSightseeingInventoryAction()
    {

        //Get Currency List
        $objCurrency = new Travel_Model_TblCurrency();
        $this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();

        //Get Supplier List 
        $objSupplier = new Travel_Model_TblSupplier();
        $this->view->arrSupplierTypes = $objSupplier->getSupplierTypes();

        //For display message
        $this->view->messages = $this->_helper->flashMessenger->getMessages();

        if (@$this->intLoggedinUserId == ADMIN_ID) {
            //Get Country List 
            $objCountry = new Travel_Model_TblCountry();
            $this->view->arrCountryList = $objCountry->getCountryList();

            //Get Sightseeing Group Type List 
            $objSightseeing = new Travel_Model_TblSightseeing();
            $this->view->arrSightseeingGroupTypeList = $objSightseeing->getAllSightseeingGroupTypeList();

            //Get Sightseeing Type List 
            $this->view->arrSightseeingTypeList = $objSightseeing->getAllSightseeingTypeList();

            //Get Difficulty Type List 
            $this->view->arrDifficultyTypeList = $objSightseeing->getAllDifficultyTypeList();

            $this->render('add-sightseeing-inventory-admin');
        }
    }

    public function viewSightseeingInventoryBulkFormAction()
    {

        $this->_helper->layout->setLayout('newLayout');

        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Get Currency List
            $objCurrency = new Travel_Model_TblCurrency();
            $this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();

            //Get Country List 
            $objCountry = new Travel_Model_TblCountry();
            $this->view->arrCountryList = $objCountry->getCountryList();

            //Get Sightseeing Inc  Type List 
            $objSightseeing = new Travel_Model_TblSightseeing();
            $this->view->arrSightseeingInclypeList = $objSightseeing->getAllSightseeingInclypeList();

            //Get Booking Type List 
            $this->view->arrBookingTypeList = $objSightseeing->getAllBookingTypeList();

            //Get Sightseeing Count
            $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
            $arrSightseeingInventoryList = $objSightseeing->getAllSightseeingInventoryList($intLoggedinUserAgencySysId);
            $this->view->sightseeingInventoryList = count($arrSightseeingInventoryList);
        }
    }

    public function viewSightseeingInventoryBulkFormAddAction()
    {

        $this->_helper->layout->setLayout('newLayout');

        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {
            $SSSysId = base64_decode($this->getRequest()->getParam('SSSysId'));
            $objSightseeing = new Travel_Model_TblSightseeing();
            if ($this->intLoggedinUserRole != 1) {
                $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
            } else {
                $intLoggedinUserId = "";
            }

            $this->view->arrSightseeingDetails = $objSightseeing->getSightseeingDetails($SSSysId, $intLoggedinUserId);
            //echo $SSSysId;
            //Get Currency List

            $objCurrency = new Travel_Model_TblCurrency();
            $this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();

            //Get Country List 
            $objCountry = new Travel_Model_TblCountry();
            $this->view->arrCountryList = $objCountry->getCountryList();

            //Get Sightseeing Inc  Type List 
            $this->view->arrSightseeingInclypeList = $objSightseeing->getAllSightseeingInclypeList();

            //Get Booking Type List 
            $this->view->arrBookingTypeList = $objSightseeing->getAllBookingTypeList();

            //Get Sightseeing Count
            $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;

            $arrSightseeingInventoryList = $objSightseeing->getAllSightseeingInventoryList($intLoggedinUserAgencySysId);

            $this->view->sightseeingInventoryList = count($arrSightseeingInventoryList);
        }
    }

    public function viewSightseeingInventoryBulkEditFormAction()
    {

        $this->_helper->layout->setLayout('newLayout');

        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            $InvnItemSysId = base64_decode($this->getRequest()->getParam('InvnItemSysId'));

            $objSightseeing = new Travel_Model_TblSightseeing();
            $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
            $arrSightseeingInventoryDetails = $objSightseeing->getSightseeingInventoryDetailsList($InvnItemSysId, $intLoggedinUserAgencySysId);

            $FromDateTimeObj = (array) $arrSightseeingInventoryDetails['FromDate'];
            $from_date_time = date("d/m/Y", strtotime($FromDateTimeObj['date']));

            $ToDateTimeObj = (array) $arrSightseeingInventoryDetails['ToDate'];
            $to_date_time = date("d/m/Y", strtotime($ToDateTimeObj['date']));

            $arrSightseeingInventoryDetailsArr = array('FromDateFormat' => $from_date_time, 'ToDateFormat' => $to_date_time);

            $arrSightseeingInventoryDetailsArrFinal = array();
            $arrSightseeingInventoryDetails = @array_merge($arrSightseeingInventoryDetails, $arrSightseeingInventoryDetailsArr);
            $this->view->arrSightseeingInventoryDetails = $arrSightseeingInventoryDetails;
            $objCurrency = new Travel_Model_TblCurrency();
            $this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
            //echo "<pre>"; print_r($arrSightseeingInventoryDetails);
        }
    }

    public function viewSightseeingInventoryIndividualFormAction()
    {

        $this->_helper->layout->setLayout('newLayout');

        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Get Country List 
            $objCountry = new Travel_Model_TblCountry();
            $this->view->arrCountryList = $objCountry->getCountryList();
            //Get Things To Carry List 
            $objThings = new Cityprofiling_Model_TblCityprofiling();
            $this->view->arrThingsToCarryList = $objThings->getThingsToCarryList();

            //Get Sightseeing Group Type List 
            $objSightseeing = new Travel_Model_TblSightseeing();
            $this->view->arrSightseeingGroupTypeList = $objSightseeing->getAllSightseeingGroupTypeList();

            //Get Sightseeing Type List 
            $this->view->arrSightseeingTypeList = $objSightseeing->getAllSightseeingTypeList();

            $objActivities = new Travel_Model_TblActivities();
            $this->view->arrActivitiesGroupTypeList = $objActivities->getAllActivityGroupTypeList();
            //Get Activities Type List 
            $this->view->arrActivitiesTypeList = $objActivities->getAllActivityTypeList();
            //Get Difficulty Type List 
            $this->view->arrDifficultyTypeList = $objSightseeing->getAllDifficultyTypeList();
        }
    }

    public function getCityDetailsListAction()
    {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Get Post form data
            $post = $this->getRequest()->getPost();

            //Get Country List 
            $str_city = '';
            if ($post['countryId'] != 0) {
                $objCity = new Travel_Model_TblCity();
                $objCity->intContSysId = $post['countryId'];
                $arrCityList = $objCity->getCityList();
                if (!empty($arrCityList)) {
                    foreach ($arrCityList as $arrCity) {
                        $str_city .= '<option value="' . $arrCity['CityId'] . '">' . $arrCity['Title'] . '</option>';
                    }
                } else {
                    $str_city = '<option value="0">Select</option>';
                }
            } else {
                $str_city = '<option value="0">Select</option>';
            }
            echo $str_city;
            exit;
        }
    }

    public function saveSightseeingAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        if ($this->getRequest()->isPost()) {
            $post = $this->getRequest()->getPost();
            // echo "<pre>"; print_r($post); die("");
            $params = json_decode(base64_decode($post['params']), 1);
            $redirect = base64_decode($post['redirect']);
            if (!empty($post)) {
                $SSSysId = isset($post['SSSysId']) ? $post['SSSysId'] : '';
                $ContId = isset($post['ContId']) ? $post['ContId'] : '';
                $isunique = isset($post['isunique']) ? $post['isunique'] : '0';
                $CitySysId = isset($post['CitySysId']) ? $post['CitySysId'] : '0';
                $SightseeingGroupType = isset($post['SightseeingGroupType']) ? implode(',', $post['SightseeingGroupType']) : '';
                $SightseeingType = isset($post['SightseeingType']) ? implode(',', $post['SightseeingType']) : '';
                $SightseeingName = isset($post['SightseeingName']) ? trim($this->sanitize_data($post['SightseeingName'])) : '';
                $MinPax = isset($post['PaxTitleMin']) ? $post['PaxTitleMin'] : '0';
                $MaxPax = isset($post['PaxTitleMax']) ? $post['PaxTitleMax'] : '0';
                $term_and_condition = isset($post['term_and_condition']) ? $post['term_and_condition'] : '';
                $Duration = isset($post['Duration']) ? $post['Duration'] : '0';
                $difficulty_level = isset($post['difficulty_level']) ? $post['difficulty_level'] : '';
                $OperatingTime1 = isset($post['OperatingTime_1']) ? $post['OperatingTime_1'] : '';
                $OperatingTime2 = isset($post['OperatingTime_2']) ? $post['OperatingTime_2'] : '';
                $OperatingTime3 = isset($post['OperatingTime_3']) ? $post['OperatingTime_3'] : '';
                $season_month = isset($post['season_month']) ? $post['season_month'] : '';
                $season_day = isset($post['season_day']) ? $post['season_day'] : '';
                $age_group = isset($post['AgeGroup']) ? $post['AgeGroup'] : '';
                $Popularity = isset($post['Popularity']) ? $post['Popularity'] : '';
                $things_to_carry = isset($post['things_to_carry']) ? implode(',', $post['things_to_carry']) : '';
                $Transfers = isset($post['Transfers']) ? $post['Transfers'] : '';
                $pick_drop = isset($post['pick_drop']) ? trim($this->sanitize_data($post['pick_drop'])) : '';
				$PickUpTime = isset($post['PickUpTime']) ? trim($this->sanitize_data($post['PickUpTime'])) : '';
                $YoutubeURL = isset($post['YoutubeURL']) ? $post['YoutubeURL'] : '';
                $details = isset($post['details']) ? trim($this->sanitize_data_html($post['details'])) : '';
                $address = isset($post['Address']) ? trim($this->sanitize_data_html($post['Address'])) : '';
                $latitude = isset($post['latitude']) ? $post['latitude'] : '0';
                $longitude = isset($post['longitude']) ? $post['longitude'] : '0';
                $other_inclusions = isset($post['other_inclusions']) ? trim($this->sanitize_data_html($post['other_inclusions'])) : '';
                $advisory = isset($post['advisory']) ? trim($this->sanitize_data_html($post['advisory'])) : '0';
                $cancel_policy = isset($post['cancel_policy']) ? trim($this->sanitize_data_html($post['cancel_policy'])) : '';
                $refund_policy = isset($post['refund_policy']) ? trim($this->sanitize_data_html($post['refund_policy'])) : '';
                $Confirmation_policy = isset($post['Confirmation_policy']) ? trim($this->sanitize_data_html($post['Confirmation_policy'])) : '';
                $IsTransferInc = isset($post['Transfers']) ? $post['Transfers'] : '0';
		$DurationStr = '';		
                if (!empty($Duration)) {
                    $DurationDays = isset($Duration[0]) && !empty($Duration[0]) ? $Duration[0]: 0;
                    $DurationHours = isset($Duration[1]) && !empty($Duration[1]) ? $Duration[1]: 0;
                    $DurationMin = isset($Duration[2]) && !empty($Duration[2]) ? $Duration[2]: 0;
                    
                    if($DurationDays>0){  $DurationStr .= $DurationDays.' '.($DurationDays>1 ? 'Days' : 'Day'); }
                    if($DurationHours>0){  $DurationStr .= ', '.$DurationHours.' '.($DurationHours>1 ? 'Hours' : 'Hour'); }
                    if($DurationMin>0){  $DurationStr .= ', '.$DurationMin.' '.($DurationMin>1 ? 'Minutes' : 'Minute'); }
                    
                } else {
                    $DurationDays = 0;
                    $DurationHours = 0;
                    $DurationMin = 0;
                }
                
                $DayHourMinToMin = $DurationDays * 24 * 60 + $DurationHours * 60 + $DurationMin;
                
                
                $ActivityNameArr = array();
                $ActivityGroupNameArr = array();
                $objectcitypro = new Cityprofiling_Model_TblCityprofiling();
                $objActivities = new Travel_Model_TblActivities();
                if (!empty($post['SightseeingGroupType'])) {
                    foreach ($post['SightseeingGroupType'] as $GroupType) {
                        $ActivityGroupNameArr[] = isset($GroupType) ? $objActivities->getActivityGroupName($GroupType) : '0';
                    }
                }
                if (!empty($post['SightseeingType'])) {
                    foreach ($post['SightseeingType'] as $value) {
                        $ActivityNameArr[] = isset($value) ? $objActivities->getActivityName($value) : '0';
                    }
                }
                $SightseeingGroupTypeName = isset($ActivityGroupNameArr) ? json_encode($ActivityGroupNameArr) : '';
                $SightseeingTypeName = isset($ActivityNameArr) ? json_encode($ActivityNameArr) : '';
            }
            if (!empty($OperatingTime1) && empty($OperatingTime2) && empty($OperatingTime3)) {
                $OperatingTime = array($OperatingTime1);
            } else {
                $OperatingTime = $OperatingTime1;
            }
            if (!empty($OperatingTime1) && !empty($OperatingTime2)) {
                $OperatingTime = array($OperatingTime1, $OperatingTime2);
            }
            if (!empty($OperatingTime1) && !empty($OperatingTime2) && !empty($OperatingTime3)) {
                $OperatingTime = array($OperatingTime1, $OperatingTime2, $OperatingTime3);
            }
            if (!empty($OperatingTime)) {
                $time_slots = json_encode($OperatingTime);
            } else {
                $time_slots = '';
            }
            if (!empty($age_group)) {
                $StartAgeYr = $age_group[0];
                $EndAgeYr = $age_group[1];
            } else {
                $StartAgeYr = 0;
                $EndAgeYr = 0;
            }
            $objSightseeing = new Travel_Model_TblSightseeing();
            $arrSightseeingDetails = $objSightseeing->getSightseeingDetails($SSSysId);
            $UpdateDate = date('Y-m-d H:i:s');
            $CreateDate = date('Y-m-d H:i:s');
            //Fixed variables
            $ICSourceSysId = $this->InfoSourceSysId;
            $StartPlaceSysId = 0;
            $EndPlaceSysId = 0;
            if ($arrSightseeingDetails['synonyms'] != "") {
                $synonyms = $arrSightseeingDetails['synonyms'];
            } else {
                $synonyms = "";
            }
            $AliasAndMeta = "";
            $ActivityIncMask = 0;
            $DurationInMin = 0;
            // $MinPax = 0;
            // $MaxPax = 0;
            $LeanMonthMask = 0;
            $SilentMonthMask = 0;
            if ($arrSightseeingDetails['IsKidAllowed'] != "") {
                $IsKidAllowed = $arrSightseeingDetails['IsKidAllowed'];
            } else {
                $IsKidAllowed = 0;
            }
            if ($arrSightseeingDetails['IsTeenAllowed'] != "") {
                $IsTeenAllowed = $arrSightseeingDetails['IsTeenAllowed'];
            } else {
                $IsTeenAllowed = 0;
            }
            if ($arrSightseeingDetails['IsAdultAllowed'] != "") {
                $IsAdultAllowed = $arrSightseeingDetails['IsAdultAllowed'];
            } else {
                $IsAdultAllowed = 0;
            }
            if ($arrSightseeingDetails['IsPetAllowed'] != "") {
                $IsPetAllowed = $arrSightseeingDetails['IsPetAllowed'];
            } else {
                $IsPetAllowed = 0;
            }
            if ($arrSightseeingDetails['IsTrxAllowed'] != "") {
                $IsTrxAllowed = $arrSightseeingDetails['IsTrxAllowed'];
            } else {
                $IsTrxAllowed = 0;
            }
            if ($arrSightseeingDetails['IsPickAllowed'] != "") {
                $IsPickAllowed = $arrSightseeingDetails['IsPickAllowed'];
            } else {
                $IsPickAllowed = 0;
            }
            $Rating = 0;
            if ($arrSightseeingDetails['AwardRecognizations'] != "" && $arrSightseeingDetails['AwardRecognizations'] != 0) {
                $AwardRecognizations = $arrSightseeingDetails['AwardRecognizations'];
            } else {
                $AwardRecognizations = "";
            }
            if ($arrSightseeingDetails['BookingType'] != "") {
                $BookingType = $arrSightseeingDetails['BookingType'];
            } else {
                $BookingType = 0;
            }
            if ($arrSightseeingDetails['StartLocalTime'] != "") {
                $StartLocalTime = $arrSightseeingDetails['StartLocalTime'];
            } else {
                $StartLocalTime = $CreateDate;
            }
            if ($arrSightseeingDetails['EndLocalTime'] != "") {
                $EndLocalTime = $arrSightseeingDetails['EndLocalTime'];
            } else {
                $EndLocalTime = $CreateDate;
            }
            $IsDayLightApp = 0;
            $PinCode = '';
            $ZoneSysId = 0;
            $ZoneType = 0;
            $StateSysId = 0;
            if ($arrSightseeingDetails['PrimaryContact'] != "" && $arrSightseeingDetails['PrimaryContact'] != 0) {
                $PrimaryContact = $arrSightseeingDetails['PrimaryContact'];
            } else {
                $PrimaryContact = '';
            }
            if ($arrSightseeingDetails['SecondaryContact'] != "" && $arrSightseeingDetails['SecondaryContact'] != 0) {
                $SecondaryContact = $arrSightseeingDetails['SecondaryContact'];
            } else {
                $SecondaryContact = '';
            }
            if ($arrSightseeingDetails['OtherContacts'] != "" && $arrSightseeingDetails['OtherContacts'] != 0) {
                $OtherContacts = $arrSightseeingDetails['OtherContacts'];
            } else {
                $OtherContacts = '';
            }
            $ApproveBy = 0;
            $ApproveDate = date('Y-m-d H:i:s');
            if ($SSSysId != "" && $SSSysId != 0) {
                if ($this->intLoggedinUserRole != 1) {
                    $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
                } else {
                    $intLoggedinUserId = "";
                }
                $AgentSysId = $arrSightseeingDetails['AgentSysId'];
                $IsAgentSpec = $arrSightseeingDetails['IsAgentSpec'];
                $IsApproved = $arrSightseeingDetails['IsApproved'];
                $IsActive = $arrSightseeingDetails['IsActive'];
                $IsMarkForDel = $arrSightseeingDetails['IsMarkForDel'];
            } else {
                if ($this->intLoggedinUserRole != 1) {
                    $AgentSysId = $this->intLoggedinUserId;
                    $IsAgentSpec = 1;
                    $IsApproved = 0;
                    $IsActive = 1;
                    $IsMarkForDel = 0;
                } else {
                    $AgentSysId = 0;
                    $IsAgentSpec = 0;
                    $IsApproved = 1;
                    $IsActive = 1;
                    $IsMarkForDel = 0;
                }
            }
            //create season masking
            if (!empty($season_month)) {
                $season_month_arr = unserialize(SEASON_MONTH);
                $seasonMonthMasking = $objSightseeing->setMasking($season_month, $season_month_arr);
            } else {
                $seasonMonthMasking = "1000000000000";
            }
            //Days of week Masking
            if (!empty($season_day)) {
                $season_day_arr = unserialize(SEASON_DAYS);
                $seasonDaysMasking = $objSightseeing->setMasking($season_day, $season_day_arr);
            } else {
                $seasonDaysMasking = "10000000";
            }
            $insert = array(
                'IsAgentSpec' => $IsAgentSpec,
                'ICSourceSysId' => $this->intLoggedinUserAgencySysId,
                'StartPlaceSysId' => $StartPlaceSysId,
                'EndPlaceSysId' => $EndPlaceSysId,
                'SSGrType' => $SightseeingGroupType,
                'SSType' => $SightseeingType,
                'SightSeeingGrTypeName' => $SightseeingGroupTypeName,
                'SightSeeingTypeName' => $SightseeingTypeName,
                'Title' => $SightseeingName,
                'synonyms' => $SightseeingName,
                'WriteUp' => $details,
                'YoutubeURL' => $YoutubeURL,
                'DifficultyLevel' => $difficulty_level,
                'AliasAndMeta' => $AliasAndMeta,
                'SSIncMask' => $ActivityIncMask,
                // 'PaxInMin' => $PaxTitleMin,
                // 'PaxInMax' => $PaxTitleMax,
                'DurationInMin' => $DayHourMinToMin,
                'DurationStr' => ltrim($DurationStr,','),
                'MinPax' => $MinPax,
                'MaxPax' => $MaxPax,
                'TermCondition' => $term_and_condition,
                'PeakMothMask' => $seasonMonthMasking,
                'LeanMonthMask' => $LeanMonthMask,
                'SilentMonthMask' => $SilentMonthMask,
                'IsTransferInc' => $IsTransferInc,
                'IsKidAllowed' => $IsKidAllowed,
                'IsTeenAllowed' => $IsTeenAllowed,
                'IsAdultAllowed' => $IsAdultAllowed,
                'IsPetAllowed' => $IsPetAllowed,
                'IsTrxAllowed' => $IsTrxAllowed,
                'IsPickAllowed' => $IsPickAllowed,
                'StartAgeYr' => $StartAgeYr,
                'EndAgeYr' => $EndAgeYr,
                'Rating' => $Rating,
                'Popularity' => $Popularity,
                'ThingsToCarry' => $things_to_carry,
                'AwardRecognizations' => $AwardRecognizations,
                'BookingType' => $BookingType,
                'DifficultyType' => 0,
                'DaysWeekMask' => $seasonDaysMasking,
                'StartLocalTime' => $StartLocalTime,
                'EndLocalTime' => $EndLocalTime,
                'TimeSlots' => $time_slots,
                'IsDayLightApp' => $IsDayLightApp,
                'Address' => $address,
                'latitude' => $latitude,
                'longitude' => $longitude,
                'PinCode' => $PinCode,
                'CitySysId' => $CitySysId,
                'ZoneSysId' => $ZoneSysId,
                'ZoneType' => $ZoneType,
                'StateSysId' => $StateSysId,
                'ContSysId' => $ContId,
                'PickUpLocation' => $pick_drop,
				'PickUpTime' => $PickUpTime,
                'PrimaryContact' => $PrimaryContact,
                'SecondaryContact' => $SecondaryContact,
                'OtherContacts' => $OtherContacts,
                'UpdateDate' => $UpdateDate,
                'ApproveDate' => $ApproveDate,
                'ApproveBy' => $ApproveBy,
                'CreateDate' => $CreateDate,
                'IsApproved' => $IsApproved,
                'IsActive' => $IsActive,
                'IsMarkForDel' => $IsMarkForDel,
                'OtherInclusion' => $other_inclusions,
                'Advisory' => $advisory,
                'CancellationPolicy' => $cancel_policy,
                'RefundPolicy' => $refund_policy,
                'ConfirmationPolicy' => $Confirmation_policy,
                'IsUnique' => $isunique
            );
            // echo "<pre>"; print_r($insert); die("");
            //Added by pooja
            if ($SSSysId == "" || $SSSysId == 0) {
                $insert['AgentSysId'] = $AgentSysId;
                $insert['Icon'] = '';
                $insert['ThumnailImg'] = '';
                $insert['DetailImg'] = '';
            }
            //end
            // start : for image upload
            $imagename = '';
            
            if (!empty($_FILES['sightseeingIcon']['name'])) {
                $orignalFileName = $_FILES['sightseeingIcon']['name'];
                $strFileName = $this->_helper->General->toTitle($SightseeingName);
                $fileExt = $this->_helper->General->getFileExtension($orignalFileName);
                $fileName = $this->intLoggedinUserAgencySysId . '_' . time() . '.' . $fileExt;
                /* Create directory if not exists */
                
                //$imagename = isset($fileName) ? $this->siteUrl . "public/upload/city/" . $CitySysId . "/sightseeing/" . $fileName : '';
                $image_path = 'img/'.$this->intLoggedinUserAgencySysId.'/city/'.$CitySysId.'/sightseeing';
                $imageDetail = IMAGE_PATH_URL_AWS . $image_path . '/' . $fileName;
                $data = array(
                    'AgencySysId' =>  $this->intLoggedinUserAgencySysId,
                    'image_path' =>  $image_path,
                    'tags' =>  'package',
                    'title' =>  $fileName,
                    'FILES' =>  $_FILES["sightseeingIcon"],
                    'fileName' =>  $fileName,
                );
                
                $toupload = Zend_Controller_Action_HelperBroker::getStaticHelper('FileUpload')->uploadToAWS($data);
                if($toupload['status'] == true){
                    $imagename = $imageDetail;
                }
                $insert['Icon'] = $imagename;
                $insert['ThumnailImg'] = $imagename;
                $insert['DetailImg'] = $imagename;
                $insert['IsValidImage'] = ($imagename != '') ? 1 : 0;
//                echo "<pre>";print_r($insert);die;
                
            }
            try {
                if ($SSSysId != "" && $SSSysId != 0) {
                    $objSightseeing->updateSightseeingDetails($SSSysId, $insert);
                    $objPackage = new Travel_Model_TblPackage();
                    $objPackage->updateData('TB_IC_SightSeeing_Variant_Mapping', array('IsMarkForDel' => 1), array('SSysId = ? ' => $SSSysId));
                    if (!empty($post['variantName'])) {
                        foreach ($post['variantName'] as $vKey => $vVal) {
                            $VarSysId = $objSightseeing->checkVarientName(trim($vVal));
                            if (empty($VarSysId)) {
                                $data = array(
                                    'VariantName' => trim($vVal),
                                    'CreateDate' => date('Y-m-d'),
                                    'UpdateDate' => date('Y-m-d'),
                                    'IsActive' => 1,
                                    'IsMarkForDel' => 0,

                                );
                                $VarSysId = $objPackage->insertData('TB_IC_SightSeeing_Variant', $data);
                            }

                            $data1 = array(
                                'VSysId' => (int)$VarSysId,
                                'SSysId' => (int)$SSSysId,
                                'CreateDate' => date('Y-m-d'),
                                'UpdateDate' => date('Y-m-d'),
                                'IsActive' => 1,
                                'IsMarkForDel' => 0,

                            );
                            $objPackage->insertData('TB_IC_SightSeeing_Variant_Mapping', $data1);
                        }
                    }

                    if ($params['ptype'] == 'FlexiReadymade') {
                        $secureCode = Catabatic_ValidateCustomer::secureCode($params['package'], 0);
                        $this->_redirect('/package/view-flexi-final-package-readymade/id/' . $params['package'] . '/code/' . $secureCode . base64_decode($params['params']));
                    } else if ($params['ptype'] == 'FlexiDynamic') {
                        $this->_redirect('/package/pkgviewnew/id/' . base64_encode($params['package']) . base64_decode($params['params']));
                    } else if ($params['ptype'] == 'Quick') {
                        $secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($params['package']), 1);
                        $this->_helper->redirector('view-customer-final-package', 'publicpackage', 'default', array('id' => base64_encode($params['package']), 'code' => $secureCode));
                    } else {
                        $this->_helper->flashMessenger->addMessage("Sightseeing saved successfully.");
                        $this->_redirect($redirect);
                    }
                } else {
                    $sssId = $objSightseeing->addSightseeingDetails($insert);
                    $objPackage = new Travel_Model_TblPackage();
                    if (!empty($post['variantName'])) {
                        foreach ($post['variantName'] as $vKey => $vVal) {
                            $VarSysId = $objSightseeing->checkVarientName(trim($vVal));
                            if (empty($VarSysId)) {
                                $data = array(
                                    'VariantName' => trim($vVal),
                                    'CreateDate' => date('Y-m-d'),
                                    'UpdateDate' => date('Y-m-d'),
                                    'IsActive' => 1,
                                    'IsMarkForDel' => 0,

                                );
                                $VarSysId = $objPackage->insertData('TB_IC_SightSeeing_Variant', $data);
                            }

                            $data1 = array(
                                'VSysId' => (int)$VarSysId,
                                'SSysId' => (int)$sssId,
                                'CreateDate' => date('Y-m-d'),
                                'UpdateDate' => date('Y-m-d'),
                                'IsActive' => 1,
                                'IsMarkForDel' => 0,

                            );
                            $objPackage->insertData('TB_IC_SightSeeing_Variant_Mapping', $data1);
                        }
                    }




                    if ($post['IsApproved'] == 1 && isset($params['ptype'])) {

                        if ($params['ptype'] == 'Quickpro') {    // condition added for pro package change sightseeing on agent view page 10-05-2020
                            $modelBY0 = new BuildYourOwn_Model_Byo();
                            $eventData = $modelBY0->getEventByVersionId('TB_Agency_BYO_Customer_TravelPlan_Itenary_Events', $params['version']);
                            $eventDataJson = json_decode($eventData['OtherJson'], 1);
                            if ($eventDataJson['onlyFreeSightSeeing'] == 1) {
                                $idold = $params['id'];
                                $sightseeingNameIdArr = array();
                                foreach ($eventDataJson['freeSightseeing'] as $fKey => $fVal) {
                                    $sightseeingNameId = explode('__', $fVal);
                                    if (trim($sightseeingNameId[0]) == trim($idold)) {
                                        $sightseeingNameIdArr[$fKey] = $sssId . '__' . $SightseeingName;
                                    } else {
                                        $sightseeingNameIdArr[$fKey] = $fVal;
                                    }
                                }
                                $eventDataJson[freeSightseeing] = $sightseeingNameIdArr;
                            } else {
                                $eventDataJson['sightseeing'] = $SightseeingName;
                                $eventDataJson['sightseeing_id'] = $sssId;
                            }

                            $updateData = array('OtherJson' => json_encode($eventDataJson, 1));
                            $table = 'TB_Agency_BYO_Customer_TravelPlan_Itenary_Events';
                            $where = array('VersionId = ? ' => $params['version']);
                        } else {
                            $where = array('VersionId = ? ' => $params['version']);
                            $updateData = array('SSSysId' => $sssId);
                            $table = ($params['ptype'] == 'Quick') ? 'TB_Agency_Customer_TravelPlan_SightSeeing' : 'TB_TravelPlan_SightSeeing';
                        }
                        $objPackage->actSightUpdateStatus($table, $updateData, $where);
                    }
                    if ($params['ptype'] == 'FlexiReadymade') {
                        $secureCode = Catabatic_ValidateCustomer::secureCode($params['package'], 0);
                        $this->_redirect('/package/view-flexi-final-package-readymade/id/' . $params['package'] . '/code/' . $secureCode . base64_decode($params['params']));
                    } else if ($params['ptype'] == 'FlexiDynamic') {
                        $objPackage->actSightRateUpdateStatus('TB_MP_Inventory_Sightseeing', $sssId, $params['id']); // function to add rates for new sightseeing
                        $this->_redirect('/package/pkgviewnew/id/' . base64_encode($params['package']) . base64_decode($params['params']));
                    } else if ($params['ptype'] == 'Quick') {
                        $secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($params['package']), 1);
                        $this->_helper->redirector('view-customer-final-package', 'publicpackage', 'default', array('id' => base64_encode($params['package']), 'code' => $secureCode));
                    } else if ($params['ptype'] == 'Quickpro') {
                        $this->_redirect($redirect);
                    } else {
                        $this->_helper->flashMessenger->addMessage("Sightseeing saved successfully.");
                        $this->_helper->redirector('manage-sightseeing', 'sightseeing', 'default');
                    }
                }
            } catch (Exception $e) {
                $response = array('success' => false, 'msg' => $e->getMessage());
                echo json_encode($response);
                exit;
            }
        }
    }

    public function addSupplierAction()
    {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        //Get Country List 
        $objCountry = new Travel_Model_TblCountry();
        $this->view->arrCountryList = $objCountry->getCountryList();
    }

    public function saveSupplierAction()
    {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Get Post form data
            $post = $this->getRequest()->getPost();

            //            echo "<pre>";
            //            print_r($post);
            //            exit;

            $currentDate = date('Y-m-d H:i:s');
            $SupplierName = $this->getRequest()->getPost('SupplierName') ? $this->getRequest()->getPost('SupplierName') : '';
            $ContactPerson = $this->getRequest()->getPost('ContactPerson') ? $this->getRequest()->getPost('ContactPerson') : '';
            $Designation = $this->getRequest()->getPost('Designation') ? $this->getRequest()->getPost('Designation') : '';
            $ContactNo = $this->getRequest()->getPost('ContactNo') ? $this->getRequest()->getPost('ContactNo') : '';
            $EmailId = $this->getRequest()->getPost('EmailId') ? $this->getRequest()->getPost('EmailId') : '';
            $Address = $this->getRequest()->getPost('Address') ? $this->getRequest()->getPost('Address') : '';
            $ContId = $this->getRequest()->getPost('ContId') ? $this->getRequest()->getPost('ContId') : '';
            $CitySysId = $this->getRequest()->getPost('CitySysId') ? $this->getRequest()->getPost('CitySysId') : '';
            $SupplierTypeSysId = $this->SupplierTypeSysId;
            $FacilityMask = 0;
            $PrefCurrencyType = 1;
            $StateId = 0;
            $PlaceSysId = 0;
            $IsCreatedByAgent = 1;
            $AgentSysId = $this->intLoggedinUserId;
            $UpdatedDate = $currentDate;
            $CreateDate = $currentDate;
            $ApproveDate = '';
            $IsApproved = 0;
            $IsDelete = 0;
            $IsActive = 1;

            if (empty($post) || empty($this->intLoggedinUserId)) {
                throw new Exception('There has been an error, Please try again later');
            }

            $insert = array(
                'SupplierTypeSysId' => $SupplierTypeSysId,
                'FacilityMask' => $FacilityMask,
                'SupplierName' => $SupplierName,
                'ContactPerson' => $ContactPerson,
                'PrefCurrencyType' => $PrefCurrencyType,
                'Designation' => $Designation,
                'ContactNo' => $ContactNo,
                'EmailId' => $EmailId,
                'Address' => $Address,
                'CitySysId' => $CitySysId,
                'ContId' => $ContId,
                'StateId' => $StateId,
                'PlaceSysId' => $PlaceSysId,
                'IsCreatedByAgent' => $IsCreatedByAgent,
                'AgentSysId' => $AgentSysId,
                'PlaceSysId' => $PlaceSysId,
                'UpdatedDate' => $UpdatedDate,
                'CreateDate' => $CreateDate,
                'ApproveDate' => $ApproveDate,
                'IsApproved' => $IsApproved,
                'IsDelete' => $IsDelete,
                'IsActive' => $IsActive
            );
            //                echo "<pre>";
            //                print_r($insert);
            //                exit;

            try {
                //Call Supplier Model
                $objSupplier = new Travel_Model_TblSupplier();
                $lastInsertId = $objSupplier->addSupplier($insert);
                $arrSupplierList = $objSupplier->getSupplierList($lastInsertId);
                $response = array('success' => 'Supplier saved successfully.', 'supplier_list' => $arrSupplierList);
                echo json_encode($response);
                exit;
            } catch (Exception $e) {
                $response = array('success' => false, 'msg' => $e->getMessage());
                echo json_encode($response);
                exit;
            }
        }
    }

    public function getCountryAutoSearchAction()
    {

        $this->_helper->layout->disableLayout();
        if ($this->getRequest()->isXmlHttpRequest()) {

            $strCountryName = $this->getRequest()->getParam('term');

            $objActivities = new Travel_Model_TblActivities();
            $result = $objActivities->getCountryList($strCountryName);
            //echo "<pre>";print_r($result);die;
            //            if(count($result) != 1) {
            //                throw new Exception('There has been a technical error. Please try again later.');
            //            }
            echo $this->_helper->json($result);
            exit;
        }
    }

    public function getCityAutoSearchAction()
    {

        $this->_helper->layout->disableLayout();
        if ($this->getRequest()->isXmlHttpRequest()) {

            $strCityName = $this->getRequest()->getParam('term');
            $strcountryId = $this->getRequest()->getParam('countryId');

            $objActivities = new Travel_Model_TblActivities();
            $result = $objActivities->getCityList($strCityName, $strcountryId);
            //echo "<pre>";print_r($result);die;
            //            if(count($result) != 1) {
            //                throw new Exception('There has been a technical error. Please try again later.');
            //            }
            echo $this->_helper->json($result);
            exit;
        }
    }

    public function getSightseeingAutoSearchAction()
    {

        $this->_helper->layout->disableLayout();
        if ($this->getRequest()->isXmlHttpRequest()) {

            $strSightseeingName = $this->getRequest()->getParam('term');
            $strcountryId = $this->getRequest()->getParam('countryId');
            $strCitySysId = $this->getRequest()->getParam('CitySysId');

            $AgentSysId = $this->intLoggedinUserAgencySysId;
            $objSightseeing = new Travel_Model_TblSightseeing();
            $result = $objSightseeing->getSightseeingList($AgentSysId, $strSightseeingName, $strcountryId, $strCitySysId);
            //            echo "<pre>";print_r($result);die;
            //            if(count($result) != 1) {
            //                throw new Exception('There has been a technical error. Please try again later.');
            //            }

            echo $this->_helper->json($result);
            exit;
        }
    }

    public function addSightseeingAction()
    {
        $this->_helper->layout->disableLayout();
        $params = $this->getRequest()->getParams();
        $CityId = isset($params['cid']) ? (int)$params['cid'] : 0;
        //Get Country List 
        $arrCityList = array();
        if($CityId > 0){
            $objCity = new Travel_Model_TblCity();
            $objCity->intCityId = $CityId;
            $arrCityList = $objCity->getCityList();
        }else{
            $objCountry = new Travel_Model_TblCountry();
            $this->view->arrCountryList = $objCountry->getCountryList();
        }
        $this->view->arrCityList = $arrCityList;

        //Get Sightseeing Group Type List 
        $objSightseeing = new Travel_Model_TblSightseeing();
         $objActivities = new Travel_Model_TblActivities();
//        $this->view->arrSightseeingGroupTypeList = $objSightseeing->getAllSightseeingGroupTypeList();
        $this->view->arrSightseeingGroupTypeList = $objActivities->getAllActivityGroupTypeList();
        
        $objThings = new Cityprofiling_Model_TblCityprofiling();
        $this->view->arrThingsToCarryList = $objThings->getThingsToCarryList();
        //Get Sightseeing Type List 
        $this->view->arrSightseeingTypeList = $objSightseeing->getAllSightseeingTypeList();

        //Get Difficulty Type List 
        $this->view->arrDifficultyTypeList = $objSightseeing->getAllDifficultyTypeList();
    }

    public function saveSightseeingInventoryAction()
    {

        $this->_helper->layout->disableLayout();
        $this->_helper->flashMessenger->addMessage("Sightseeing Inventory saved successfully.");
        $this->_helper->redirector('index', 'sightseeing', 'default');
    }

    public function getSupplierAutoSearchAction()
    {

        $this->_helper->layout->disableLayout();
        if ($this->getRequest()->isXmlHttpRequest()) {

            $strSupplierName = $this->getRequest()->getParam('term');
            //echo $strFlightNo; exit;

            $result = array();
            $objSupplier = new Travel_Model_TblSupplier();
            $AgentId = $this->intLoggedinUserId;
            $SupplierTypeSysId = $this->SupplierTypeSysId;
            $AgencySysId = $this->intLoggedinUserAgencySysId;
            $result = $objSupplier->getSupplierAutoSearchList($strSupplierName, $AgentId, $SupplierTypeSysId, $AgencySysId);
            //echo "<pre>";print_r($result);die;
            //            if(count($result) != 1) {
            //                throw new Exception('There has been a technical error. Please try again later.');
            //            }

            echo $this->_helper->json($result);
            exit;
        }
    }

    public function saveInventoryAction()
    {

        /* Disable layout */
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();

        /* If ajax request */
        if ($this->_request->isXmlHttpRequest()) {

            $post = $this->getRequest()->getPost();
            if (isset($post['supplier_type_id']) && !empty($post['supplier_type_id'])) {
                Zend_Controller_Action_HelperBroker::getStaticHelper('Supplier')->updateSupplierService($post['supplier_type_id'], 'Sightseeing');
            }
            //echo "<pre>"; print_r($post);die;

            $objSightseeing = new Travel_Model_TblSightseeing();
            $objAgency = new Travel_Model_TblAgency();

            $ContId = !empty($post['ContId']) ? $post['ContId'] : '0';
            $CitySysId = !empty($post['CitySysId']) ? $post['CitySysId'] : '0';
            $InvnItemSysId = !empty($post['InvnItemSysId']) ? $post['InvnItemSysId'] : '0';
            $sightseeing_name = !empty($post['sightseeing_name']) ? $post['sightseeing_name'] : '';
            $sightseeing_id = !empty($post['sightseeing_id']) ? $post['sightseeing_id'] : '0';
            $inclusions_id = !empty(@$post['inclusions_id']) ? @implode(",", @$post['inclusions_id']) : '0';
            $transfers = !empty($post['transfers']) ? $post['transfers'] : '';
            $from_date = !empty($post['sightseeing_from_date']) ? $post['sightseeing_from_date'] : '';
            $to_date = !empty($post['sightseeing_to_date']) ? $post['sightseeing_to_date'] : '';
            $currency_type = !empty($post['currency_type']) ? $post['currency_type'] : '';
            $adult_cost_natives = !empty($post['sightseeing_adult_cost_natives']) ? $post['sightseeing_adult_cost_natives'] : '0';
            $kids_cost_natives = !empty($post['sightseeing_kids_cost_natives']) ? $post['sightseeing_kids_cost_natives'] : '0';
            $adult_cost_foreigners = !empty($post['sightseeing_adult_cost_foreigners']) ? $post['sightseeing_adult_cost_foreigners'] : '0';
            $kids_cost_foreigners = !empty($post['sightseeing_kids_cost_foreigners']) ? $post['sightseeing_kids_cost_foreigners'] : '0';
            $booking_type = !empty($post['booking_type']) ? $post['booking_type'] : '';
            $supplier_type = !empty($post['supplier_type']) ? $post['supplier_type'] : '';
            $supplier_type_id = !empty($post['supplier_type_id']) ? $post['supplier_type_id'] : '';

            $strFromDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($from_date, 'd/m/y');
            $strToDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($to_date, 'd/m/y');
            $currentDate = date('Y-m-d H:i:s');
            $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
            $intLoggedinUserId = $this->intLoggedinUserId;

            $agencyDetails = $objAgency->getAgencyUserList($intLoggedinUserAgencySysId);
            if ($this->intLoggedinUserTrxCurrency != 0) {
                $TrxCurrency = $this->intLoggedinUserTrxCurrency;
            } else {
                $TrxCurrency = $agencyDetails['TrxCurrency'];
            }


            if ($ContId == 0) {
                $response = array('success' => false, 'msg' => 'Please select country');
                echo json_encode($response);
                exit;
            }
            if ($CitySysId == 0) {
                $response = array('success' => false, 'msg' => 'Please select city');
                echo json_encode($response);
                exit;
            }
            if ($sightseeing_id == 0) {
                $response = array('success' => false, 'msg' => 'Please enter sightseeing name');
                echo json_encode($response);
                exit;
            }
//            if (empty(@$inclusions_id)) {
//                $response = array('success' => false, 'msg' => 'Please select inclusions');
//                echo json_encode($response);
//                exit;
//            }
            if ($from_date == "__/__/____") {
                $response = array('success' => false, 'msg' => 'Please select from date');
                echo json_encode($response);
                exit;
            }
            if ($to_date == "__/__/____") {
                $response = array('success' => false, 'msg' => 'Please select to date');
                echo json_encode($response);
                exit;
            }
            if ($strFromDate > $strToDate) {
                $response = array('success' => false, 'msg' => 'Please select to date should be greater than from date');
                echo json_encode($response);
                exit;
            }
            if ($adult_cost_natives == "") {
                $response = array('success' => false, 'msg' => 'Please enter native adult cost');
                echo json_encode($response);
                exit;
            }
            //            if(empty($kids_cost_natives)) {
            //                $response = array('success'=> false, 'msg' => 'Please enter native kids cost');
            //                echo json_encode($response);
            //                exit;
            //            }
            if ($adult_cost_foreigners == "") {
                $response = array('success' => false, 'msg' => 'Please enter foreigners adult cost');
                echo json_encode($response);
                exit;
            }
            //            if(empty($kids_cost_foreigners)) {
            //                $response = array('success'=> false, 'msg' => 'Please enter foreigners kids cost');
            //                echo json_encode($response);
            //                exit;
            //            }
            if ($booking_type == 0) {
                $response = array('success' => false, 'msg' => 'Please select booking type');
                echo json_encode($response);
                exit;
            }
            if ($supplier_type == "" || $supplier_type_id == 0) {
                $response = array('success' => false, 'msg' => 'Please enter supplier name');
                echo json_encode($response);
                exit;
            }

            //echo "<pre>"; print_r($post);die;
            //Get Sipplier Masking
            if ($supplier_type_id != "" && $supplier_type_id != 0) {
                $objSupplier = new Travel_Model_TblSupplier();
                $supplierDetails = $objSupplier->getSupplierList($supplier_type_id);
                $supplierMasking = $supplierDetails['Services'];

                //Get Old Masking Array
                $SupplierServicesArrDB = $objSupplier->getSupplierServices(); //Get Supplier Services
                $servicesMaskingArr = $objSupplier->getMasking($supplierMasking, $SupplierServicesArrDB, 'SupplierSerSysId');
                $ActivitiesSupplierTypeSysIdArr = array($this->SupplierTypeSysId);
                $newMaskingArr = array_unique(array_merge($servicesMaskingArr, $ActivitiesSupplierTypeSysIdArr));

                //Set new masking string
                $supplierServicesNewMasking = $objSupplier->setMasking($newMaskingArr, $SupplierServicesArrDB, 'SupplierSerSysId');
                //echo $supplierServicesNewMasking; die;
                //Update Masking
                $supplierMaskingUpdateArr = array('Services' => $supplierServicesNewMasking);
                $objSupplier->updateSupplier($supplierMaskingUpdateArr, $supplier_type_id);
            }

            //Insert data array
            $insertData = array(
                'InventoryType' => '2', 'XRef' => $sightseeing_id, 'AgencySysId' => $intLoggedinUserAgencySysId, 'SupplierSysId' => $supplier_type_id, 'FromDate' => $strFromDate, 'ToDate' => $strToDate,
                'BookingType' => $booking_type, 'inclusions' => $inclusions_id, 'IsTransferInc' => $transfers, 'IsPickDropInc' => 0, 'PurchasedQty' => 0, 'PublishQty' => 0, 'BlockQty' => '0', 'SoldQty' => '0', 'ReturnQty' => '0', 'NetInHandQty' => 0,
                'CostCurrency' => $currency_type, 'TotalCostNativeAdult' => 0, 'TotalCostNativeChild' => 0, 'TotalCostForeignerAdult' => $adult_cost_foreigners, 'TotalCostForeignerChild' => $kids_cost_foreigners,
                'TrxCurrency' => $TrxCurrency, 'SaleAmtNativeChild' => 0, 'SaleAmtNativeAdult' => '0', 'SaleAmtForeignerChild' => 0, 'SaleAmtForeignerAdult' => 0, 'Brief' => '', 'IfAnyOffer' => '0', 'OfferMsg' => '', 'OfferImage' => '',
                'TCInfo' => '', 'TCDocPath' => '', 'IxFixedDateInven' => '0', 'CreatorSysId' => $intLoggedinUserId, 'ApproveDate' => $currentDate, 'CreateDate' => $currentDate,
                'UpdateDate' => $currentDate, 'IsActive' => '1', 'IsMarkForDelete' => 0, 'IsApproved' => '1', 'AdultEntryFee' => $adult_cost_natives, 'ChildEntryFee' => $kids_cost_natives
            );
//            echo "<pre>";print_r($insertData); die;

            $intLastInsertId = $objSightseeing->addSightseeingInventory($insertData);
            if($intLastInsertId > 0){
                $objSightseeing->checkAndUpdateIsRateAvailable($this->intLoggedinUserAgencySysId,$sightseeing_id);
            }
            
            //$intLastInsertId = 1;

            $response = array('success' => true, 'intLastInsertId' => $intLastInsertId);

            echo json_encode($response);
            exit;
        }
    }

    public function viewSightseeingInventoryTableAction()
    {
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        if ($this->_request->isXmlHttpRequest()) {
            $post = $this->getRequest()->getPost();
            $objSightseeing = new Travel_Model_TblSightseeing();
            $City = (int) $post['City'];
            $Country = (int) $post['Country'];
            $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
            $arrSightseeingInventoryList = $objSightseeing->getAllSightseeingInventoryList($intLoggedinUserAgencySysId, $City, $Country);
            $this->view->arrSightseeingInventoryList = $arrSightseeingInventoryList;
        }
    }

    public function viewSightseeingInventoryTableAddAction()
    {
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        $SSSysId = ($this->getRequest()->getParam('SSSysId'));
        $objSightseeing = new Travel_Model_TblSightseeing();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $arrSightseeingInventoryList = $objSightseeing->getAllSightseeingInventoryListBySSSId($SSSysId, $intLoggedinUserAgencySysId);
        $this->view->arrSightseeingInventoryList = $arrSightseeingInventoryList;
        //        echo "<pre>";
        //        print_r($arrSightseeingInventoryList);
        //        exit;
    }

    public function manageGroupAction()
    {
        /* Disable layout */
        $this->_helper->layout->disableLayout();

        $InvnItemSysId = $this->getRequest()->getParam('id');
        $key = $this->getRequest()->getParam('key');
        //echo "dsbfsjdugf sid";
        //echo $InvnItemSysId; 
        //die;

        $this->view->key = $key;
        $this->view->InvnItemSysId = $InvnItemSysId;
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        //echo $InvnItemSysId;  
        $objSightseeing = new Travel_Model_TblSightseeing();
        $arrSightseeingInventoryList = $objSightseeing->getSightseeingInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
       
        $arrSightseeingSICInventoryList = $objSightseeing->getAllSightseeingInventoryMarkupList($InvnItemSysId, $intLoggedinUserAgencySysId);
         //echo "<pre>";print_r($arrSightseeingSICInventoryList);die;
        $this->view->marrSightseeingSICInventoryList = $arrSightseeingSICInventoryList;
        $this->view->marrSightseeingInventoryList = $arrSightseeingInventoryList;
        $checkSightseeingGroupCost = $objSightseeing->checkSightseeingGroupCost($InvnItemSysId);
        $this->view->checkSightseeingGroupCost = $checkSightseeingGroupCost;
        if (count($arrSightseeingInventoryList) <> 1) {
            throw new Exception('There has been an error, Please try again later');
        }
    }

    public function manageMarkupAction()
    {
        /* Disable layout */
        $this->_helper->layout->disableLayout();

        $InvnItemSysId = $this->getRequest()->getParam('id');
        $key = $this->getRequest()->getParam('key');
        $popupType = $this->getRequest()->getParam('popupType');
        //echo "dsbfsjdugf sid";
        //echo $InvnItemSysId; 
        //die;

        $this->view->key = $key;
        $this->view->popupType = $popupType;
        $this->view->InvnItemSysId = $InvnItemSysId = $this->getRequest()->getParam('id');
        //echo $InvnItemSysId;  
        $objSightseeing = new Travel_Model_TblSightseeing();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;

        $arrSightseeingInventoryList = $objSightseeing->getSightseeingInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
        //echo "<pre>";print_r($arrFlightInventoryList);die;
        $this->view->arrSightseeingInventoryList = $arrSightseeingInventoryList;

        if (count($arrSightseeingInventoryList) <> 1) {
            throw new Exception('There has been an error, Please try again later');
        }
    }

    public function managePoliciesAction()
    {
        /* Disable layout */
        $this->_helper->layout->disableLayout();

        $key = $this->getRequest()->getParam('key');
        $popupType = $this->getRequest()->getParam('popupType');

        $this->view->key = $key;
        $this->view->popupType = $popupType;
        $this->view->InvnItemSysId = $InvnItemSysId = $this->getRequest()->getParam('id');

        $objSightseeing = new Travel_Model_TblSightseeing();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $arrSightseeingInventoryList = $objSightseeing->getSightseeingInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
        //echo "<pre>";print_r($arrSightseeingInventoryList);die;
        if (count($arrSightseeingInventoryList) <> 1) {
            throw new Exception('There has been an error, Please try again later');
        }
    }

    public function viewMarkupSettingGridAction()
    {

        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        if ($this->_request->isXmlHttpRequest()) {

            $objAgency = new Travel_Model_TblAgency();

            $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
            $MarkupSetting = $this->getRequest()->getParam('MarkupSetting');
            $intAgencySysId = $this->intLoggedinUserAgencySysId;

            $objSightseeing = new Travel_Model_TblSightseeing();
            $arrSightseeingInventoryList = $objSightseeing->getSightseeingInventoryList($InvnItemSysId, $intAgencySysId);
            //echo "<pre>";print_r($arrFlightInventoryList);die;
            if (count($arrSightseeingInventoryList) <> 1) {
                throw new Exception('There has been an error, Please try again later');
            }

            if ($MarkupSetting == 'STANDARD') {

                $this->view->arrSightseeingInventoryList = $arrSightseeingInventoryList;
                $this->view->agencyDetails = $objAgency->getAgencyUserList($intAgencySysId);

                //For  Natives
                //echo $intAgencySysId;
                $objActivities = new Travel_Model_TblActivities();
                $arrStandardMarkups = $objActivities->getStandardMarkupsActivities($intAgencySysId);
                //               echo "<pre>"; print_r($arrStandardMarkups);die;
                $this->view->arrStandardNativesMarkups = $arrStandardMarkups;

                //For  Natives
                //$arrStandardForeignersMarkups = $objSightseeing->getStandardMarkupsSightseeing($intAgencySysId, $cost_markup='2');
                //echo "<pre>"; print_r($arrStandardForeignersMarkups);die;
                //$this->view->arrStandardForeignersMarkups = $arrStandardForeignersMarkups;
            } else if ($MarkupSetting == 'CUSTOMIZE') {
                $this->view->arrSightseeingInventoryList = $arrSightseeingInventoryList;
                $this->view->agencyDetails = $objAgency->getAgencyUserList($intAgencySysId);

                //For Natives
                $this->view->arrSightseeingNativesAllocMarketPlaces = $objSightseeing->getSightseeingMarketPlacesByAgencySysId($InvnItemSysId, $intAgencySysId, $cost_markup = '1');
                //For Foreigners
                $this->view->arrSightseeingForeignersAllocMarketPlaces = $objSightseeing->getSightseeingMarketPlacesByAgencySysId($InvnItemSysId, $intAgencySysId, $cost_markup = '2');

                //For  Natives
                $arrCustomizedMarkups = $objSightseeing->getCustomizedMarkups($InvnItemSysId, $MPType = '', $intAgencySysId, $cost_markup = '1');
                //echo "<pre>"; print_r($arrCustomizedMarkups);die;
                $this->view->arrCustomizedNativesMarkups = $arrCustomizedMarkups;

                //For Foreigners
                $arrForeignersCustomizedMarkups = $objSightseeing->getCustomizedMarkups($InvnItemSysId, $MPType = '', $intAgencySysId, $cost_markup = '2');
                //echo "<pre>"; print_r($arrCustomizedMarkups);die;
                $this->view->arrForeignersCustomizedMarkups = $arrForeignersCustomizedMarkups;
            } else if ($MarkupSetting == 'STANDARDPOLICIES') {
                $this->view->arrStandardMarkupsPolicies = $objSightseeing->getStandardMarkupsPolicies($InvnItemSysId);
            } else if ($MarkupSetting == 'CUSTOMIZEPOLICIES') {
                $this->view->arrCustomizedMarkupPolicies = $objSightseeing->getCustomizedMarkupsPolicies($InvnItemSysId);
            } else if ($MarkupSetting == 'GROUP') {
                $arrCustomizedGroupList = $objSightseeing->getSightseeingGroupList($InvnItemSysId);

                $arrCustomizedGroupListArr = array();
                foreach ($arrCustomizedGroupList as $gKey => $gVal) {
                    $arrCustomizedGroupListArr[$gVal['PaxCount']][] = $gVal;
                }
                krsort($arrCustomizedGroupListArr);
                $this->view->arrCustomizedGroupList = $arrCustomizedGroupListArr;
                
            } else if ($MarkupSetting == 'VEHICLE') {
                $objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
                $arrVehicleList = $objTransportsRoutes->getVehicleList('', $this->intLoggedinUserAgencySysId);
                $this->view->arrVehicleList = $arrVehicleList;
                $this->view->arrSightseeingInventoryList = $arrSightseeingInventoryList;
                $getSightseeingVehicles = $objSightseeing->getSightseeingVehiclesIncluded($InvnItemSysId);
                $getSightseeingOtherServices = $objSightseeing->getSightseeingOtherServices($InvnItemSysId);
                //echo "<pre>";print_r($getSightseeingOtherServices);die;  
                $this->view->getSightseeingVehicles = $getSightseeingVehicles; 
                $this->view->getSightseeingOtherServices = $getSightseeingOtherServices; 
                 
            } else {
                throw new Exception('Markup settings not found.');
            }

            $this->view->InvnItemSysId = $InvnItemSysId;
            $this->view->MarkupSetting = $MarkupSetting;

            $this->view->arrMarketPlaces = Zend_Controller_Action_HelperBroker::getStaticHelper('B2B')->getMarketPlaces();
            $this->view->arrPermissions = Zend_Controller_Action_HelperBroker::getStaticHelper('B2B')->getPermissions();

            if ($MarkupSetting == 'STANDARD') {
                $this->render('view-standard-fixed-amount-grid');
            } else if ($MarkupSetting == 'CUSTOMIZE') {
                $this->render('view-customize-fixed-amount-grid');
            } else if ($MarkupSetting == 'STANDARDPOLICIES') {
                $this->render('view-standard-fixed-policies-grid');
            } else if ($MarkupSetting == 'CUSTOMIZEPOLICIES') {
                $this->render('view-customize-fixed-policies-grid');
            } else if ($MarkupSetting == 'GROUP') {
                $this->render('view-customize-group-grid');
            } else if ($MarkupSetting == 'VEHICLE') {
                $this->render('view-customize-vehicle-grid');
            }
        }
    }

    public function calculateNetsalepriceCustomizedMarkupAction()
    {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Get Post form data
            $post = $this->getRequest()->getPost();

            //            echo "<pre>";
            //            print_r($post);
            //            exit;

            $cost = $post['cost'];
            $markup = $post['markup'];
            $tax = $post['tax'];
            $discount = $post['discount'];

            if ($cost) {
                $formDataValFinal = $cost;
            }
            if ($markup != 0) {
                $formDataValFinal = $formDataValFinal + $markup;
            }
            if ($tax != 0) {
                $formDataValFinal = $formDataValFinal + $tax;
            }
            if ($discount != 0) {
                $formDataValFinal = $formDataValFinal - $discount;
            } else {
                $formDataValFinal = $formDataValFinal;
            }
            $discountPrice = 0;
            $response = array('success' => true, 'netSalePrice' => $formDataValFinal, 'discountPrice' => $discountPrice);
            echo json_encode($response);
            exit;
        }
    }

    public function addCustomizedGroupAction()
    {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Call Sightseeing Model
            $objSightseeing = new Travel_Model_TblSightseeing();
            //Get Post form data
            $post = $this->getRequest()->getPost();

            //            echo "<pre>";
            //            print_r($post);
            //            exit;

            $InvnItemSysId = $this->getRequest()->getPost('InvnItemSysId');

            if (empty($InvnItemSysId) || empty($this->intLoggedinUserId)) {
                throw new Exception('There has been an error, Please try again later');
            }

            /* For Customize Markup Type */
            if (!empty($post)) {
                $PaxCount = !empty($post['PaxCount']) ? (int)$post['PaxCount'] : '0';
                $ToPaxCount = !empty($post['ToPaxCount']) ? (int)$post['ToPaxCount'] : $PaxCount;
                $TotalCostNativeAdult = !empty($post['TotalCostNativeAdult']) ? $post['TotalCostNativeAdult'] : '0';
                $TotalCostNativeChild = !empty($post['TotalCostNativeChild']) ? $post['TotalCostNativeChild'] : '0';
                $TotalCostForeignerAdult = !empty($post['TotalCostForeignerChild']) ? $post['TotalCostForeignerChild'] : '0';
                $TotalCostForeignerChild = !empty($post['TotalCostForeignerAdult']) ? $post['TotalCostForeignerAdult'] : '0';
                $adultB2CMarkup = !empty($post['adultB2CMarkup']) ? $post['adultB2CMarkup'] : '0';
                $adultB2BMarkup = !empty($post['adultB2BMarkup']) ? $post['adultB2BMarkup'] : '0';
                $childB2CMarkup = !empty($post['childB2CMarkup']) ? $post['childB2CMarkup'] : '0';
                $childB2BMarkup = !empty($post['childB2BMarkup']) ? $post['childB2BMarkup'] : '0';
                $objAgency = new Travel_Model_TblAgency();
                $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
                $agencyDetails = $objAgency->getAgencyUserList($intLoggedinUserAgencySysId);
                //echo "<pre>"; print_r($agencyDetails);die;
                if (!empty($agencyDetails)) {
                    $TrxCurrency = $agencyDetails['TrxCurrency'];
                } else {
                    $TrxCurrency = 1;
                }
                $SaleAmtNativeChild = 0;
                $SaleAmtNativeAdult = 0;
                $SaleAmtForeignerChild = 0;
                $SaleAmtForeignerAdult = 0;
                $TCInfo = '';
                $TCDocPath = '';
                $currentDate = date('Y-m-d H:i:s');
                $IsApproved = 0;
                $IsMarkForDel = 0;
                $IsActive = 1;

                /* For Fixed Amount Markup Type */
            } else {
                throw new Exception('There has been an error, Please try again later');
            }

            if (empty($PaxCount)) {
                $response = array('success' => false, 'msg' => 'Please enter pax.');
                echo json_encode($response);
                exit;
            }
            if ($PaxCount <= 0) {
                $response = array('success' => false, 'msg' => 'Please enter pax should be greater than zero');
                echo json_encode($response);
                exit;
            }
            if ($ToPaxCount < $PaxCount) {
                $response = array('success' => false, 'msg' => 'To Pax can not be less than From Pax.');
                echo json_encode($response);
                exit;
            }
            if (empty($TotalCostNativeAdult)) {
                $response = array('success' => false, 'msg' => 'Please enter adult cost.');
                echo json_encode($response);
                exit;
            }
            if ($TotalCostNativeAdult <= 0) {
                $response = array('success' => false, 'msg' => 'Please enter adult cost should be greater than zero');
                echo json_encode($response);
                exit;
            }
            $ExitPax = array();
            /* Check if group settings already exists */
            if($ToPaxCount >= $PaxCount){
                for($count = $PaxCount; $count <= $ToPaxCount; $count ++){
                    $arrGroupPaxCountSettings = $objSightseeing->getSightseeingGroupList($InvnItemSysId, $count);
                    if (!empty($arrGroupPaxCountSettings) ) {
                        $ExitPax[] = $count;

                    }
                }
                if(!empty($ExitPax)){
                    $response = array('success' => false, 'msg' => 'Pax has been already added for pax '.implode(', ',$ExitPax).'.');
                    echo json_encode($response); exit;
                }
                    for($count = $PaxCount; $count <= $ToPaxCount; $count ++){
                     
                        for ($man = 1; $man <= 2; $man++) {
                            $adultMarkup = $childMarkup = 0;
                            if ($man == 1) {
                                $adultMarkup = $adultB2CMarkup;
                                $childMarkup = $childB2CMarkup;
                            } else if ($man == 2) {
                                $adultMarkup = $adultB2BMarkup;
                                $childMarkup = $childB2BMarkup;
                            }
                            $SaleAmtNativeAdult = (int) $TotalCostNativeAdult + (int) $adultMarkup;
                            $SaleAmtNativeChild = (int) $TotalCostNativeChild + (int) $childMarkup;

                            $insert = array(
                                'InvnItemSysId' => $InvnItemSysId,
                                'PaxCount' => $count,
                                'TotalCostNativeAdult' => $TotalCostNativeAdult,
                                'TotalCostNativeChild' => $TotalCostNativeChild,
                                'TotalCostForeignerChild' => (int) $TotalCostForeignerChild,
                                'TotalCostForeignerAdult' => (int) $TotalCostForeignerAdult,
                                'TrxCurrency' => $TrxCurrency,
                                'SaleAmtNativeChild' => $SaleAmtNativeChild,
                                'SaleAmtNativeAdult' => $SaleAmtNativeAdult,
                                'SaleAmtForeignerChild' => (int) $SaleAmtForeignerChild,
                                'SaleAmtForeignerAdult' => (int) $SaleAmtForeignerAdult,
                                'TCInfo' => $TCInfo,
                                'TCDocPath' => $TCDocPath,
                                'CreateDate' => $currentDate,
                                'UpdateDate' => $currentDate,
                                'IsApproved' => $IsApproved,
                                'IsMarkForDelete' => $IsMarkForDel,
                                'IsActive' => $IsActive,
                                'Marketplace' => (int) $man,
                                'MarkupType' => 1,
                                'AdultMarkup' => $adultMarkup,
                                'ChildMarkup' => $childMarkup,
                            );
                            try {
                                $objSightseeing->addGroupSettings($insert);
                                $response = array('success' => true);
                            } catch (Exception $e) {
                                $response = array('success' => false, 'msg' => $e->getMessage());
                            }
                         
                        }
                    }
                    if((int)$InvnItemSysId > 0){
                        $getXrefId = $objSightseeing->GetRateExist($InvnItemSysId);
                        if((int)$getXrefId['XRef'] > 0){
                            $objSightseeing->checkAndUpdateIsRateAvailable($this->intLoggedinUserAgencySysId,(int)$getXrefId['XRef']);
                        }
                    }
                    
                    
            }
             
            
            echo json_encode($response);
            exit;
        }
    }

    public function deleteCustomizedGroupSettingAction()
    {

        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {
            $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
            $PaxVal = $this->getRequest()->getParam('PaxVal');

            $objSightseeing = new Travel_Model_TblSightseeing();
            $objSightseeing->deleteCustomizedGroupSetting($InvnItemSysId, $PaxVal);
            if((int)$InvnItemSysId > 0){
                $getXrefId = $objSightseeing->GetRateExist($InvnItemSysId);
                if((int)$getXrefId['XRef'] > 0){
                    $objSightseeing->checkAndUpdateIsRateAvailable($this->intLoggedinUserAgencySysId,(int)$getXrefId['XRef']);
                }
            }
            
            $response = array('success' => true);
            echo json_encode($response);
            exit;
        }
    }

    public function addCustomizedMarkupAction()
    {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Call Activities Model
            $objSightseeing = new Travel_Model_TblSightseeing();
            //Get Post form data
            $post = $this->getRequest()->getPost();

            //            echo "<pre>";
            //            print_r($post);
            //            exit;

            $currentDate = date('Y-m-d H:i:s');
            $intMarkupType = $post['markupType'];
            $InvnItemSysId = $this->getRequest()->getPost('InvnItemSysId');

            if (empty($InvnItemSysId) || empty($intMarkupType) || empty($this->intLoggedinUserId)) {
                throw new Exception('There has been an error, Please try again later');
            }

            /* For Customize Markup Type */
            if ($intMarkupType == 'CUSTOMIZE') {
                $cost_markup = !empty($post['cost_markup']) ? $post['cost_markup'] : '1';
                $MarPlace = !empty($post['customized-fixed-amount-market-place']) ? $post['customized-fixed-amount-market-place'] : '0';
                $Permission = !empty($post['customized-fixed-amount-permissions']) ? $post['customized-fixed-amount-permissions'] : '0';
                $Cost_adult = !empty($post['customized-fixed-amount-cost-adult']) ? $post['customized-fixed-amount-cost-adult'] : 0;
                $Cost_kids = !empty($post['customized-fixed-amount-cost-kids']) ? $post['customized-fixed-amount-cost-kids'] : 0;
                $Markup_adult = !empty($post['customized-fixed-amount-markup-adult']) ? $post['customized-fixed-amount-markup-adult'] : 0;
                $Markup_kids = !empty($post['customized-fixed-amount-markup-kids']) ? $post['customized-fixed-amount-markup-kids'] : 0;
                $tax = !empty($post['customized-fixed-amount-tax']) ? $post['customized-fixed-amount-tax'] : 0;
                $Discount_adult = !empty($post['customized-fixed-amount-discount-adult']) ? $post['customized-fixed-amount-discount-adult'] : 0;
                $Discount_kids = !empty($post['customized-fixed-amount-discount-kids']) ? $post['customized-fixed-amount-discount-kids'] : 0;
                $DiscountAmount_adult = !empty($post['customized-fixed-amount-discount-price-adult']) ? $post['customized-fixed-amount-discount-price-adult'] : 0;
                $DiscountAmount_kids = !empty($post['customized-fixed-amount-discount-price-kids']) ? $post['customized-fixed-amount-discount-price-kids'] : 0;
                $message = !empty($post['customized-fixed-amount-message']) ? $post['customized-fixed-amount-message'] : '';
                $netsale_price_adult = !empty($post['customized-fixed-amount-netsale_price-adult']) ? $post['customized-fixed-amount-netsale_price-adult'] : 0;
                $netsale_price_kids = !empty($post['customized-fixed-amount-netsale_price-kids']) ? $post['customized-fixed-amount-netsale_price-kids'] : 0;
                /* For Fixed Amount Markup Type */
            } else {
                throw new Exception('There has been an error, Please try again later');
            }

            if (empty($MarPlace)) {
                $response = array('success' => false, 'msg' => 'Please select market place');
                echo json_encode($response);
                exit;
            }

            if ($Permission == "") {
                $response = array('success' => false, 'msg' => 'Please select permission');
                echo json_encode($response);
                exit;
            }

            if (empty($Cost_adult)) {
                $response = array('success' => false, 'msg' => 'Please enter cost');
                echo json_encode($response);
                exit;
            }
            //            if($Markup_adult=="") {
            //                $response = array('success' => false, 'msg' => 'Please enter adult markup');
            //                echo json_encode($response);
            //                exit;
            //            }
            //            if($Markup_kids=="") {
            //                $response = array('success' => false, 'msg' => 'Please enter kids markup');
            //                echo json_encode($response);
            //                exit;
            //            }
            //            if($tax=="") {
            //                $response = array('success' => false, 'msg' => 'Please enter tax');
            //                echo json_encode($response);
            //                exit;
            //            }
            //            if($message=="") {
            //                $response = array('success' => false, 'msg' => 'Please enter mesage');
            //                echo json_encode($response);
            //                exit;
            //            }

            $CustGrSysId = $this->intLoggedinUserGroupSysId;
            $AgencySysId = $this->intLoggedinUserAgencySysId;
            $MaxQntToSale = '0';
            $Currency = '0';
            $MarkUpType = $cost_markup;
            $MarkUpNativeAdult = $Markup_adult;
            $MarkUpNativeChild = $Markup_kids;
            $MarkUpForeignerAdult = '0';
            $MarkUpForeignerChild = '0';
            $DiscountType = '0';
            $DiscountMsg = $message;
            $DiscountNativeAdult = $Discount_adult;
            $DiscountNativeChild = $Discount_kids;
            $DiscountForeignerAdult = '0';
            $DiscountForeignerChild = '0';
            $NetPriceNativeAdult = $netsale_price_adult;
            $NetPriceNativeChild = $netsale_price_kids;
            $NetPriceForeignerAdult = '0';
            $NetPriceForeignerChild = '0';
            $IsPublish = '0';
            $PublishDate = '0';
            $Details = '';
            $RateRuleSysId = '0';
            $TCDocSysId = '0';
            $ValidTill = $currentDate;
            $CreateDate = $currentDate;
            $UpdateDate = $currentDate;
            $IsMarkForDel = '0';
            $IsActive = $Permission;

            /* Check if markup settings already exists */
            $arrMarkupSettings = $objSightseeing->getCustomizedMarkups($InvnItemSysId, $MarPlace, $this->intLoggedinUserAgencySysId, $cost_markup);

            if (!empty($arrMarkupSettings) ) {
                $response = array('success' => false, 'msg' => 'Markup settings of the selected Market Place has already been added.');
                echo json_encode($response);
                exit;
            }

            $insert = array(
                'InvnItemSysId' => $InvnItemSysId,
                'MPType' => $MarPlace,
                'CustGrSysId' => $CustGrSysId,
                'AgencySysId' => $AgencySysId,
                'MaxQntToSale' => $MaxQntToSale,
                'Currency' => $Currency,
                'MarkUpType' => $MarkUpType,
                'TaxPer' => $tax,
                'MarkUpNativeAdult' => $MarkUpNativeAdult,
                'MarkUpNativeChild' => $MarkUpNativeChild,
                'MarkUpForeignerAdult' => $MarkUpForeignerAdult,
                'MarkUpForeignerChild' => $MarkUpForeignerChild,
                'DiscountType' => $DiscountType,
                'DiscountMsg' => $DiscountMsg,
                'DiscountNativeAdult' => $DiscountNativeAdult,
                'DiscountNativeChild' => $DiscountNativeChild,
                'DiscountForeignerAdult' => $DiscountForeignerAdult,
                'DiscountForeignerChild' => $DiscountForeignerChild,
                'NetPriceNativeAdult' => $NetPriceNativeAdult,
                'NetPriceNativeChild' => $NetPriceNativeChild,
                'NetPriceForeignerAdult' => $NetPriceForeignerAdult,
                'NetPriceForeignerChild' => $NetPriceForeignerChild,
                'IsPublish' => $IsPublish,
                'PublishDate' => $PublishDate,
                'Details' => $Details,
                'RateRuleSysId' => $RateRuleSysId,
                'TCDocSysId' => $TCDocSysId,
                'ValidTill' => $ValidTill,
                'CreateDate' => $CreateDate,
                'UpdateDate' => $UpdateDate,
                'IsMarkForDel' => $IsMarkForDel,
                'IsActive' => $IsActive
            );

            //            echo "<pre>";
            //            print_r($insert);
            //            exit;

            try {
                $objSightseeing->addMarkupSettings($insert);
                $response = array('success' => true);
                echo json_encode($response);
                exit;
            } catch (Exception $e) {
                $response = array('success' => false, 'msg' => $e->getMessage());
                echo json_encode($response);
                exit;
            }
        }
    }

    public function addCustomizedMarkupForeignersAction()
    {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Call Activities Model
            $objSightseeing = new Travel_Model_TblSightseeing();
            //Get Post form data
            $post = $this->getRequest()->getPost();

            //            echo "<pre>";
            //            print_r($post);
            //            exit;

            $currentDate = date('Y-m-d H:i:s');
            $intMarkupType = $post['markupType-foreigners'];
            $InvnItemSysId = $this->getRequest()->getPost('InvnItemSysId');

            if (empty($InvnItemSysId) || empty($intMarkupType) || empty($this->intLoggedinUserId)) {
                throw new Exception('There has been an error, Please try again later');
            }

            /* For Customize Markup Type */
            if ($intMarkupType == 'CUSTOMIZE') {
                $cost_markup = !empty($post['cost_markup_foreigners']) ? $post['cost_markup_foreigners'] : '1';
                $MarPlace = !empty($post['customized-fixed-amount-market-place-foreigners']) ? $post['customized-fixed-amount-market-place-foreigners'] : '0';
                $Permission = !empty($post['customized-fixed-amount-permissions-foreigners']) ? $post['customized-fixed-amount-permissions-foreigners'] : '0';
                $Cost_adult = !empty($post['customized-fixed-amount-cost-foreigners-adult']) ? $post['customized-fixed-amount-cost-foreigners-adult'] : 0;
                $Cost_kids = !empty($post['customized-fixed-amount-cost-foreigners-kids']) ? $post['customized-fixed-amount-cost-foreigners-kids'] : 0;
                $Markup_adult = !empty($post['customized-fixed-amount-markup-foreigners-adult']) ? $post['customized-fixed-amount-markup-foreigners-adult'] : 0;
                $Markup_kids = !empty($post['customized-fixed-amount-markup-foreigners-kids']) ? $post['customized-fixed-amount-markup-foreigners-kids'] : 0;
                $tax = !empty($post['customized-fixed-amount-tax-foreigners']) ? $post['customized-fixed-amount-tax-foreigners'] : 0;
                $Discount_adult = !empty($post['customized-fixed-amount-discount-foreigners-adult']) ? $post['customized-fixed-amount-discount-foreigners-adult'] : 0;
                $Discount_kids = !empty($post['customized-fixed-amount-discount-foreigners-kids']) ? $post['customized-fixed-amount-discount-foreigners-kids'] : 0;
                $DiscountAmount_adult = !empty($post['customized-fixed-amount-discount-price-foreigners-adult']) ? $post['customized-fixed-amount-discount-price-foreigners-adult'] : 0;
                $DiscountAmount_kids = !empty($post['customized-fixed-amount-discount-price-foreigners-kids']) ? $post['customized-fixed-amount-discount-price-foreigners-kids'] : 0;
                $message = !empty($post['customized-fixed-amount-message-foreigners']) ? $post['customized-fixed-amount-message-foreigners'] : '';
                $netsale_price_adult = !empty($post['customized-fixed-amount-netsale_price-foreigners-adult']) ? $post['customized-fixed-amount-netsale_price-foreigners-adult'] : 0;
                $netsale_price_kids = !empty($post['customized-fixed-amount-netsale_price-foreigners-kids']) ? $post['customized-fixed-amount-netsale_price-foreigners-kids'] : 0;
                /* For Fixed Amount Markup Type */
            } else {
                throw new Exception('There has been an error, Please try again later');
            }

            if (empty($MarPlace)) {
                $response = array('success' => false, 'msg' => 'Please select market place');
                echo json_encode($response);
                exit;
            }

            if ($Permission == "") {
                $response = array('success' => false, 'msg' => 'Please select permission');
                echo json_encode($response);
                exit;
            }

            if (empty($Cost_adult)) {
                $response = array('success' => false, 'msg' => 'Please enter cost');
                echo json_encode($response);
                exit;
            }
            //            if($Markup_adult=="") {
            //                $response = array('success' => false, 'msg' => 'Please enter adult markup');
            //                echo json_encode($response);
            //                exit;
            //            }
            //            if($Markup_kids=="") {
            //                $response = array('success' => false, 'msg' => 'Please enter kids markup');
            //                echo json_encode($response);
            //                exit;
            //            }
            //            if($tax=="") {
            //                $response = array('success' => false, 'msg' => 'Please enter tax');
            //                echo json_encode($response);
            //                exit;
            //            }
            //            if($message=="") {
            //                $response = array('success' => false, 'msg' => 'Please enter mesage');
            //                echo json_encode($response);
            //                exit;
            //            }

            $CustGrSysId = $this->intLoggedinUserGroupSysId;
            $AgencySysId = $this->intLoggedinUserAgencySysId;
            $MaxQntToSale = '0';
            $Currency = '0';
            $MarkUpType = $cost_markup;
            $MarkUpNativeAdult = '0';
            $MarkUpNativeChild = '0';
            $MarkUpForeignerAdult = $Markup_adult;
            $MarkUpForeignerChild = $Markup_kids;
            $DiscountType = '0';
            $DiscountMsg = $message;
            $DiscountNativeAdult = '0';
            $DiscountNativeChild = '0';
            $DiscountForeignerAdult = $Discount_adult;
            $DiscountForeignerChild = $Discount_kids;
            $NetPriceNativeAdult = '0';
            $NetPriceNativeChild = '0';
            $NetPriceForeignerAdult = $netsale_price_adult;
            $NetPriceForeignerChild = $netsale_price_kids;
            $IsPublish = '0';
            $PublishDate = '0';
            $Details = '';
            $RateRuleSysId = '0';
            $TCDocSysId = '0';
            $ValidTill = $currentDate;
            $CreateDate = $currentDate;
            $UpdateDate = $currentDate;
            $IsMarkForDel = '0';
            $IsActive = $Permission;

            /* Check if markup settings already exists */
            $arrMarkupSettings = $objSightseeing->getCustomizedMarkups($InvnItemSysId, $MarPlace, $this->intLoggedinUserAgencySysId, $cost_markup);

            if (!empty($arrMarkupSettings) ) {
                $response = array('success' => false, 'msg' => 'Markup settings of the selected Market Place has already been added.');
                echo json_encode($response);
                exit;
            }

            $insert = array(
                'InvnItemSysId' => $InvnItemSysId,
                'MPType' => $MarPlace,
                'CustGrSysId' => $CustGrSysId,
                'AgencySysId' => $AgencySysId,
                'MaxQntToSale' => $MaxQntToSale,
                'Currency' => $Currency,
                'MarkUpType' => $MarkUpType,
                'TaxPer' => $tax,
                'MarkUpNativeAdult' => $MarkUpNativeAdult,
                'MarkUpNativeChild' => $MarkUpNativeChild,
                'MarkUpForeignerAdult' => $MarkUpForeignerAdult,
                'MarkUpForeignerChild' => $MarkUpForeignerChild,
                'DiscountType' => $DiscountType,
                'DiscountMsg' => $DiscountMsg,
                'DiscountNativeAdult' => $DiscountNativeAdult,
                'DiscountNativeChild' => $DiscountNativeChild,
                'DiscountForeignerAdult' => $DiscountForeignerAdult,
                'DiscountForeignerChild' => $DiscountForeignerChild,
                'NetPriceNativeAdult' => $NetPriceNativeAdult,
                'NetPriceNativeChild' => $NetPriceNativeChild,
                'NetPriceForeignerAdult' => $NetPriceForeignerAdult,
                'NetPriceForeignerChild' => $NetPriceForeignerChild,
                'IsPublish' => $IsPublish,
                'PublishDate' => $PublishDate,
                'Details' => $Details,
                'RateRuleSysId' => $RateRuleSysId,
                'TCDocSysId' => $TCDocSysId,
                'ValidTill' => $ValidTill,
                'CreateDate' => $CreateDate,
                'UpdateDate' => $UpdateDate,
                'IsMarkForDel' => $IsMarkForDel,
                'IsActive' => $IsActive
            );

            //                echo "<pre>";
            //                print_r($insert);
            //                exit;

            try {
                $objSightseeing->addMarkupSettings($insert);
                $response = array('success' => true);
                echo json_encode($response);
                exit;
            } catch (Exception $e) {
                $response = array('success' => false, 'msg' => $e->getMessage());
                echo json_encode($response);
                exit;
            }
        }
    }

    public function deleteCustomizedMarkupSettingAction()
    {

        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {
            $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
            $MPType = $this->getRequest()->getParam('MPType');
            $MarkUpType = $this->getRequest()->getParam('MarkUpType');

            $objSightseeing = new Travel_Model_TblSightseeing();
            $objSightseeing->deleteCustomizedMarkupSetting($InvnItemSysId, $MPType, $this->intLoggedinUserAgencySysId, $MarkUpType);

            $response = array('success' => true);
            echo json_encode($response);
            exit;
        }
    }

    public function addCustomizedMarkupPoliciesAction()
    {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Call Activities Model
            $objSightseeing = new Travel_Model_TblSightseeing();
            //Get Post form data
            $post = $this->getRequest()->getPost();

            //            echo "<pre>";
            //            print_r($post);
            //            exit;

            $intMarkupType = $post['markupType'];
            $InvnItemSysId = $this->getRequest()->getPost('InvnItemSysId');

            if (empty($InvnItemSysId) || empty($this->intLoggedinUserId)) {
                throw new Exception('There has been an error, Please try again later');
            }

            /* For Customize Markup Type */
            if ($intMarkupType == 'CUSTOMIZEPOLICIES') {
                $MarPolicies = isset($post['markup_setting_customize_policies']) ? $post['markup_setting_customize_policies'] : '0';
                /* For Fixed Amount Markup Type */
            } else {
                throw new Exception('There has been an error, Please try again later');
            }

            if (empty($MarPolicies)) {
                $response = array('success' => false, 'msg' => 'Please enter Markup Policies.');
                echo json_encode($response);
                exit;
            }

            /* Check if markup settings already exists */
            $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
            $arrSightseeingInventoryList = $objSightseeing->getSightseeingInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
            if (!empty($arrSightseeingInventoryList)) {

                $update = array(
                    'TCInfo' => $MarPolicies
                );

                try {
                    $objSightseeing->editMarkupPoliciesSettings($update, $InvnItemSysId);
                    $response = array('success' => true);
                    echo json_encode($response);
                    exit;
                } catch (Exception $e) {
                    $response = array('success' => false, 'msg' => $e->getMessage());
                    echo json_encode($response);
                    exit;
                }
            }
        }
    }

    public function updateSightseeingSaleAction()
    {

        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {
            $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
            $actionValue = $this->getRequest()->getParam('actionValue');
            $statusValue = $this->getRequest()->getParam('status');

            $objSightseeing = new Travel_Model_TblSightseeing();
            $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
            $arrSightseeingInventoryList = $objSightseeing->getSightseeingInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
            if (count($arrSightseeingInventoryList) <> 1) {
                throw new Exception('There has been an error, Please try again later');
            }

            $objSightseeing->updateSightseeingSaleInventory($InvnItemSysId, $actionValue, $intLoggedinUserAgencySysId);
            $data = array(
                'SSSysId' => $InvnItemSysId,
                'status' => $statusValue,
            );
            $return = $this->displayOnWebsite($data);
            $response = array('success' => true);
            echo json_encode($response);
            exit;
        }
    }

    public function editSightseeingDetailsAction()
    {
        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isPost()) {
            $post = $this->getRequest()->getPost();
            //            echo "<pre>";
            //            print_r($post);
            //            exit;

            /* For activities */
            if (!empty($post)) {
                $InvnItemSysId = isset($post['InvnItemSysId']) ? $post['InvnItemSysId'] : '';
                $from_date = isset($post['from_date']) ? $post['from_date'] : '';
                $to_date = isset($post['to_date']) ? $post['to_date'] : '0';
                $adult_cost_natives = isset($post['adult_cost_natives']) ? $post['adult_cost_natives'] : '';
                $kids_cost_natives = isset($post['kids_cost_natives']) ? $post['kids_cost_natives'] : '';
                $adult_cost_foreigners = isset($post['adult_cost_foreigners']) ? $post['adult_cost_foreigners'] : '';
                $kids_cost_foreigners = isset($post['kids_cost_foreigners']) ? $post['kids_cost_foreigners'] : '0';
                $DisplayOnWebsite = isset($post['DisplayOnWebsite']) ? (int)$post['DisplayOnWebsite'] : 0;
                $currency_type = isset($post['currency_type']) ? (int)$post['currency_type'] : 1;

                $strFromDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($from_date, 'd/m/y');
                $strToDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($to_date, 'd/m/y');
            

                if ($from_date == "__/__/____") {
                    $response = array('success' => false, 'msg' => 'Please select from date');
                    echo json_encode($response);
                    exit;
                }
                if ($to_date == "__/__/____") {
                    $response = array('success' => false, 'msg' => 'Please select to date');
                    echo json_encode($response);
                    exit;
                }
                if ($strFromDate > $strToDate) {
                    $response = array('success' => false, 'msg' => 'Please select to date should be greater than from date');
                    echo json_encode($response);
                    exit;
                }

                $update = array(
                    'FromDate' => $strFromDate,
                    'ToDate' => $strToDate,
                    'AdultEntryFee' => (float) $adult_cost_natives,
                    'ChildEntryFee' => (float) $kids_cost_natives,
                    'CostCurrency' => $currency_type,
                    //  'TotalCostForeignerAdult' => (float)$adult_cost_foreigners,
                    //  'TotalCostForeignerChild' => (float) $kids_cost_foreigners
                );

                //            echo "<pre>";
                //            print_r($update);
                //            exit;

                try {
                    $objSightseeing = new Travel_Model_TblSightseeing();
                    $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
                    $getXrefId = $objSightseeing->GetRateExist($InvnItemSysId);
                    $objSightseeing->updateSightseeingInventoryDetails($update, $InvnItemSysId, $intLoggedinUserAgencySysId);
                    if((int)$getXrefId['XRef'] > 0){
                        $objSightseeing->checkAndUpdateIsRateAvailable($intLoggedinUserAgencySysId,$getXrefId['XRef']);
                    }
                    
                    
                        $sessionLogin_user_url = new Zend_Session_Namespace('sessionLogin_user');
                        if (trim($sessionLogin_user_url->agencyDetails['IsB2CSite']) == 1) {
                            
                            $this->postFields = "";
                            $this->postFields .= "&AgencySysId=" . Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
                            $this->postFields .= "&URL=" . trim($sessionLogin_user_url->agencyDetails['Url']);
                            if ($DisplayOnWebsite == 1) {
                                $ItemSourceType = $getXrefId['InvnItemSysId'];
                                $this->postFields .= "&packageId=$ItemSourceType";
                                $url = Catabatic_Helper::getSiteUrl() . "gtxwebservices/push-package/sightseeing-inv";
                            } else {
                                $ItemSourceType = $getXrefId['InvnItemSysId'];
                                $this->postFields .= "&packageId=$ItemSourceType";
                                $url = Catabatic_Helper::getSiteUrl() . "gtxwebservices/push-package/deactivate";
                            }
                            
                            $writeLogObj = new Payment_Model_Payment();
                            $writeLogObj->writeLog($this->postFields . "\n");
                            try {
                                $ch = curl_init();
                                curl_setopt($ch, CURLOPT_URL, $url);
                                curl_setopt($ch, CURLOPT_HEADER, 0);
                                curl_setopt($ch, CURLOPT_POST, 1);
                                if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
                                    //     SSL connection
                                    curl_setopt($ch, CURLOPT_PORT, 443);
                                    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
                                    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                                }
                                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                                curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postFields);
                                $output = curl_exec($ch);
                                // echo "<pre>";print_r($output);exit;
                                $writeLogObj->writeLog($output . "\n");
                                curl_close($ch);
                                $data = json_decode(stripslashes($output), true);

                                $isDeactive = $objSightseeing->displayOnB2C(base64_encode($InvnItemSysId), $DisplayOnWebsite);
                                $status = ($DisplayOnWebsite == 1) ? 'activate' : 'deactivate';
                            } catch (Zend_Exception $ex) {
//                                echo $ex->getMessage();
//                                exit;
                            }
                        }
                    
                    
                    $response = array('success' => true);
                    echo json_encode($response);
                    exit;
                } catch (Exception $e) {
                    $response = array('success' => false, 'msg' => $e->getMessage());
                    echo json_encode($response);
                    exit;
                }
            
            }
        }
    }

    public function copySightseeingDetailsAction()
    {
        $this->_helper->layout->disableLayout();

        if ($this->getRequest()->isPost()) {
            $post = $this->getRequest()->getPost();
            //            echo "<pre>";
            //            print_r($post);
            //            exit;

            /* For activities */
            if (!empty($post)) {
                $InvnItemSysId = isset($post['InvnItemSysId']) ? $post['InvnItemSysId'] : '';
                $from_date = isset($post['from_date']) ? $post['from_date'] : '';
                $to_date = isset($post['to_date']) ? $post['to_date'] : '0';
                $adult_cost_natives = isset($post['adult_cost_natives']) ? $post['adult_cost_natives'] : '';
                $kids_cost_natives = isset($post['kids_cost_natives']) ? $post['kids_cost_natives'] : '';
                $adult_cost_foreigners = isset($post['adult_cost_foreigners']) ? $post['adult_cost_foreigners'] : '';
                $kids_cost_foreigners = isset($post['kids_cost_foreigners']) ? $post['kids_cost_foreigners'] : '0';

                $strFromDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($from_date, 'd/m/y');
                $strToDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($to_date, 'd/m/y');
            }

            if ($from_date == "__/__/____") {
                $response = array('success' => false, 'msg' => 'Please select from date');
                echo json_encode($response);
                exit;
            }
            if ($to_date == "__/__/____") {
                $response = array('success' => false, 'msg' => 'Please select to date');
                echo json_encode($response);
                exit;
            }
            if ($strFromDate > $strToDate) {
                $response = array('success' => false, 'msg' => 'Please select to date should be greater than from date');
                echo json_encode($response);
                exit;
            }

            $update = array(
                'FromDate' => $strFromDate,
                'ToDate' => $strToDate,
                'TotalCostNativeAdult' => $adult_cost_natives,
                'TotalCostNativeChild' => $kids_cost_natives,
                'TotalCostForeignerAdult' => $adult_cost_foreigners,
                'TotalCostForeignerChild' => $kids_cost_foreigners
            );

            //            echo "<pre>";
            //            print_r($update);
            //            exit;

            try {
                $objSightseeing = new Travel_Model_TblSightseeing();
                $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
                $intNewInvnItemSysId = $objSightseeing->cloneMPInventorySightseeing($update, $InvnItemSysId);

                $response = array('success' => true, 'intLastInsertId' => $intNewInvnItemSysId);
                echo json_encode($response);
                exit;
            } catch (Exception $e) {
                $response = array('success' => false, 'msg' => $e->getMessage());
                echo json_encode($response);
                exit;
            }
        }
    }

    public function getSightseeingInventoryDetailAction()
    {
         
        $this->_helper->layout->setLayout('newLayout');

        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');

            $objSightseeing = new Travel_Model_TblSightseeing();
            $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
            $arrSightseeingInventoryDetails = $objSightseeing->getSightseeingInventoryDetailsList($InvnItemSysId, $intLoggedinUserAgencySysId);

            $FromDateTimeObj = (array) $arrSightseeingInventoryDetails['FromDate'];
            $from_date_time = date("d/m/Y", strtotime($FromDateTimeObj['date']));

            $ToDateTimeObj = (array) $arrSightseeingInventoryDetails['ToDate'];
            $to_date_time = date("d/m/Y", strtotime($ToDateTimeObj['date']));

            $arrSightseeingInventoryDetailsArr = array('FromDateFormat' => $from_date_time, 'ToDateFormat' => $to_date_time);

            $arrSightseeingInventoryDetailsArrFinal = array();
            $arrSightseeingInventoryDetailsArrFinal = @array_merge($arrSightseeingInventoryDetails, $arrSightseeingInventoryDetailsArr);

            //echo "<pre>"; print_r($arrActivitiesInventoryDetailsArrFinal); die;
            echo json_encode($arrSightseeingInventoryDetailsArrFinal);
            exit;

            //$this->view->arrFlightInventoryDetails = $arrFlightInventoryDetails;
            //
            //
            //echo "<pre>";print_r($arrFlightInventoryDetails);
            //exit;
        }
    }

    public function viewDetailsAction()
    {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        $InvnItemSysId = $this->getRequest()->getParam('id');
        //echo $InvnItemSysId; 
        $objSightseeing = new Travel_Model_TblSightseeing();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $arrSightseeingInventoryDetails = $objSightseeing->getInventoryDetails($InvnItemSysId, $intLoggedinUserAgencySysId);
        //echo "<pre>"; print_r($arrSightseeingInventoryDetails);die;
        $this->view->arrSightseeingInventoryDetails = $arrSightseeingInventoryDetails;
    }

    public function viewManageSightseeingDetailsAction()
    {
        /* Disable Layout */
        $objThings = new Cityprofiling_Model_TblCityprofiling();
        $this->_helper->layout->disableLayout();
        $SSSysId = $this->getRequest()->getParam('id');
        //echo $InvnItemSysId; 
        $objSightseeing = new Travel_Model_TblSightseeing();
        if ($this->intLoggedinUserRole != 1) {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        $arrSightseeingDetails = $objSightseeing->getSightseeingDetails($SSSysId, $intLoggedinUserId);
        //echo "<pre>"; print_r($arrSightseeingInventoryDetails);die;
        $this->view->arrSightseeingDetails = $arrSightseeingDetails;

        $this->view->arrThingsToCarryList = $objThings->getThingsToCarryList();

    }

    public function viewEditSightseeingDetailsAction()
    {
        /* Disable Layout */
        $popup = $this->getRequest()->getParam('popup');
        if ($popup == 1) {
            $this->_helper->layout->disableLayout();
        }
        //

        $SSSysId = $this->getRequest()->getParam('id');
        $redirect = $this->getRequest()->getParam('uri');
        //echo $InvnItemSysId; 
        if ($this->intLoggedinUserRole != 1) {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }

        $objSightseeing = new Travel_Model_TblSightseeing();
        $arrSightseeingDetails = $objSightseeing->getSightseeingDetails($SSSysId, $intLoggedinUserId);
        // echo "<pre>"; print_r($arrSightseeingDetails); die;
        //Get Country List 
        $objCountry = new Travel_Model_TblCountry();
        $arrCountryList = $objCountry->getCountryList();
        //echo "<pre>"; print_r($arrCountryList);die;
        $this->view->arrCountryList = $arrCountryList;
        $objThings = new Cityprofiling_Model_TblCityprofiling();
        $this->view->arrThingsToCarryList = $objThings->getThingsToCarryList();
        // echo "<pre>"; print_r($this->view->arrThingsToCarryList);die;
        //Get City List
        $cityList = array();
        if ((int) $arrSightseeingDetails['ContSysId'] > 0) {
            $objCity = new Travel_Model_TblCity();
            $objCity->intContSysId = $arrSightseeingDetails['ContSysId'];
            $cityList = $objCity->getCityList();
        }
        //echo "<pre>"; print_r($cityList);die;
        $this->view->cityList = $cityList;

        //Get Sightseeing Group Type List 
        //$this->view->arrSightseeingGroupTypeList = $objSightseeing->getAllSightseeingGroupTypeList();
        //Get Sightseeing Type List 
        //$this->view->arrSightseeingTypeList = $objSightseeing->getAllSightseeingTypeList();


        $objActivities = new Travel_Model_TblActivities();
        $this->view->arrSightseeingGroupTypeList = $objActivities->getAllActivityGroupTypeList();
        //Get Activities Type List
        // print_r($this->view->arrSightseeingGroupTypeList); die; 
        $this->view->arrSightseeingTypeList = $objActivities->getAllActivityTypeList();



        //Get Difficulty Type List 
        $this->view->arrDifficultyTypeList = $objSightseeing->getAllDifficultyTypeList();

        //Set sightseeing details
        $this->view->arrSightseeingDetails = $arrSightseeingDetails;

        $season_month_arr = unserialize(SEASON_MONTH);
        $seasonMonthMasking = $objSightseeing->getMasking($arrSightseeingDetails['PeakMothMask'], $season_month_arr);
        $this->view->seasonMonthMasking = $seasonMonthMasking;
        //echo "<pre>"; print_r($seasonMonthMasking);die;

        $season_day_arr = unserialize(SEASON_DAYS);
        $seasonDaysMasking = $objSightseeing->getMasking($arrSightseeingDetails['DaysWeekMask'], $season_day_arr);
        $this->view->seasonDaysMasking = $seasonDaysMasking;
        $params = $this->getRequest()->getParams();
        //        echo "<pre>"; print_r($params);die;
        $this->view->IsFromPackage = @$params['package'];
        $this->view->ptype = @$params['ptype'];
        $this->view->params = @$params;
        $this->view->redirect = $redirect;
		
		$this->view->sightseeingVariant = $sightseeingVariant = $objSightseeing->getSightseeingVariant($SSSysId);
		//echo "<pre>"; print_r($sightseeingVariant);die;
        //        $this->view->IsFromDynamicPackage = @$this->getRequest()->getParam('dynamicpackage');
    }

    public function deleteSightseeingAction()
    {

        /* Disable Layout */
        $this->_helper->layout->disableLayout();

        $InvnItemSysId = base64_decode($this->getRequest()->getParam('id'));

        $objSightseeing = new Travel_Model_TblSightseeing();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $arrSightseeingInventoryList = $objSightseeing->getSightseeingInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
        //        if(count($arrSightseeingInventoryList) <> 1 ) {
        //            throw new Exception('There has been an error, Please try again later');
        //        }

        $objSightseeing->deleteSightseeingInventory($InvnItemSysId, $intLoggedinUserAgencySysId);

        $this->_helper->flashMessenger->addMessage("Sightseeing Inventory deleted successfully.");
        $this->_helper->redirector('index', 'sightseeing', 'default');
    }

    public function deactivateInventoryAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objSightseeing = new Travel_Model_TblSightseeing();
        $InvnItemSysId = $this->getRequest()->getParam('id');
        $redirect = base64_decode($this->getRequest()->getParam('uri'));
        $statusValue = '0';
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;

        $isDeactive = $objSightseeing->setActiveDeactiveInventory($InvnItemSysId, $intLoggedinUserAgencySysId, $statusValue);
        $message = @$isDeactive ? "Sightseeing inventory deactivated successfully." : "Sightseeing inventory deactivation failed.";
        $this->_helper->flashMessenger->addMessage($message);
        $this->_redirect($redirect);
        //$this->_helper->redirector('index', 'sightseeing', 'default');
    }

    public function activateInventoryAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objSightseeing = new Travel_Model_TblSightseeing();
        $InvnItemSysId = $this->getRequest()->getParam('id');
        $redirect = base64_decode($this->getRequest()->getParam('uri'));
        $statusValue = '1';
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;

        $isActive = $objSightseeing->setActiveDeactiveInventory($InvnItemSysId, $intLoggedinUserAgencySysId, $statusValue);
        $message = @$isActive ? "Sightseeing inventory activated successfully." : "Sightseeing inventory activation failed.";
        $this->_helper->flashMessenger->addMessage($message);
        $this->_redirect($redirect);
        $this->_helper->redirector('index', 'sightseeing', 'default');
    }

    public function deactivateAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objSightseeing = new Travel_Model_TblSightseeing();
        $SSSysId = $this->getRequest()->getParam('id');
        $redirect = base64_decode($this->getRequest()->getParam('uri'));
        $statusValue = '0';
        if ($this->intLoggedinUserRole != 1) {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }

        $isDeactive = $objSightseeing->setActiveDeactive($SSSysId, $statusValue);
        $message = @$isDeactive ? "Sightseeing deactivated successfully." : "Sightseeing deactivation failed.";
        $this->_helper->flashMessenger->addMessage($message);
        $this->_redirect($redirect);
        //$this->_helper->redirector('manage-sightseeing', 'sightseeing', 'default');
    }

    public function activateAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objSightseeing = new Travel_Model_TblSightseeing();
        $SSSysId = $this->getRequest()->getParam('id'); 
        $statusValue = $this->getRequest()->getParam('status'); 
         
        if ($this->intLoggedinUserRole != 1) {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        if((int)$SSSysId>0){
            $SSSysIdEnc = base64_encode($SSSysId);
            $isActive = $objSightseeing->setActiveDeactive($SSSysIdEnc, $statusValue);
            if($statusValue == 1){
                $message = @$isActive ? "Sightseeing activated successfully." : "Sightseeing activation failed.";
            }else{
                $message = @$isActive ? "Sightseeing deactivated successfully." : "Sightseeing activation failed.";
            }
            
            $this->_helper->flashMessenger->addMessage($message); 
            if($statusValue == 1){ 
                $URL = '<a onclick="isActiveDeactive('.$SSSysId.',0)" class="view_text1 tooltipLink" title="Deactivate"><i class="fa fa-stop"></i></a>';
            }else{
                $URL = '<a onclick="isActiveDeactive('.$SSSysId.',1)" class="view_text1 tooltipLink" title="Activate"><i class="fa fa-play"></i></a>';
            }
            $SightseeingRateList = $objSightseeing->GetSightseeingRateListExist($SSSysId); 
            foreach($SightseeingRateList as $key => $value){
                if($value['DisplayOnB2C'] == 1 && (int)$value['InvnItemSysId']>0){
                    $data = array(
                        'SSSysId' => (int)$value['InvnItemSysId'],
                        'status' => $statusValue,
                    ); 
                    $this->displayOnWebsite($data);
                }
            }
            
            
            $return = array('status' => true,'url' => $URL,'message' => $message,'statusValue'=>$statusValue);
        }else{
            $message = 'Sightseeing activation failed. ';
            $return = array('status' => false,'url' => '','message' => $message,'statusValue'=>$statusValue);
        } 
        echo json_encode($return);die;
    }

    public function getSearchSupplierSightseeingAction()
    {

        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            $cityId = $this->getRequest()->getParam('cityId');

            if ($cityId != "" && $cityId != "0") {
                $searchSupplierSelect = '';
                $objSightseeing = new Travel_Model_TblSightseeing();
                $intSearchSupplierList = $objSightseeing->getSuppliersList($cityId, $this->intLoggedinUserId);
                if (!empty($intSearchSupplierList) ) {
                    $searchSupplierSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script>';
                    $searchSupplierSelect .= '<select id="supplierId" name="supplierId" class="demo-default select-ajax-country" placeholder="Select Supplier"><option value="0">Select Supplier</option>';
                    foreach ($intSearchSupplierList as $intSearchSupplier) {
                        $searchSupplierSelect .= '<option value="' . $intSearchSupplier['SupplierSysId'] . '">' . $intSearchSupplier['SupplierName'] . '</option>';
                    }
                    $searchSupplierSelect .= '</select>';
                } else {
                    $searchSupplierSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script><select id="supplierId" name="supplierId" class="demo-default select-ajax-country" placeholder="Select Supplier"><option value="0">Select Supplier</option></select>';
                }
            } else {
                $searchSupplierSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script><select id="supplierId" name="supplierId" class="demo-default select-ajax-country" placeholder="Select Supplier"><option value="0">Select Supplier</option></select>';
            }

            echo $searchSupplierSelect;
            exit;
        }
    }

    public function getSightseeingTypeListAction()
    {

        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            $SightseeingGrTypeId = $this->getRequest()->getParam('SightseeingGrTypeId');
            $SightseeingGrType = $this->getRequest()->getParam('SightseeingGrType');
            $Mode = $this->getRequest()->getParam('Mode');

            if ($SightseeingGrType == "page" && $Mode == "add") {
                $nameId = "SightseeingType";
            } else if ($SightseeingGrType == "popup" && $Mode == "add") {
                $nameId = "popupSightseeingType";
            } else if ($SightseeingGrType == "popup" && $Mode == "edit") {
                $nameId = "SightseeingType";
            }

            if ($SightseeingGrTypeId != "" && $SightseeingGrTypeId != "0") {
                $sightseeingSelect = '';
                $objSightseeing = new Travel_Model_TblSightseeing();
                $intSightseeingTypeList = $objSightseeing->getSightseeingTypeListBySightseeingGroupId($SightseeingGrTypeId);
                if (!empty($intSightseeingTypeList) ) {
                    $sightseeingSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script>';
                    $sightseeingSelect .= '<select id="' . $nameId . '" name="SightseeingType" class="demo-default select-ajax-country" placeholder="Select Sightseeing Type"><option value="0">Select Sightseeing Type</option>';
                    foreach ($intSightseeingTypeList as $intSightseeingType) {
                        $sightseeingSelect .= '<option value="' . $intSightseeingType['SSType'] . '">' . $intSightseeingType['Title'] . '</option>';
                    }
                    $sightseeingSelect .= '</select>';
                } else {
                    $sightseeingSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script><select id="SightseeingType" name="SightseeingType" class="demo-default select-ajax-country" placeholder="Select Sightseeing Type"><option value="0">Select Sightseeing Type</option></select>';
                }
            } else {
                $sightseeingSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script><select id="SightseeingType" name="SightseeingType" class="demo-default select-ajax-country" placeholder="Select Sightseeing Type"><option value="0">Select Sightseeing Type</option></select>';
            }

            echo $sightseeingSelect;
            exit;
        }
    }

    /**
     * Disapprove Hotel Action. 
     */
    public function disapprovedAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objSightseeing = new Travel_Model_TblSightseeing();
        $SSSysId = base64_decode($this->getRequest()->getParam('id'));
        $approveDate = date('Y-m-d H:i:s');

        $updateArr = array('ApproveDate' => $approveDate, 'ApproveBy' => $this->intLoggedinUserId, 'IsApproved' => '0');

        $isDisapprove = $objSightseeing->setApproveDisapprove(" SSSysId=$SSSysId", "TB_IC_SightSeeing", $updateArr);
        $message = @$isDisapprove ? "Sightseeing disapproved successfully." : "Sightseeing disapproved failed.";

        $this->_helper->flashMessenger->addMessage($message);
        if (@$isDisapprove) {
            if ($this->intLoggedinUserRole == 1) {
                $this->_helper->redirector('manage-sightseeing', 'sightseeing', 'default');
            }
        }
    }

    /**
     * Approve Hotel Action. 
     */
    public function approvedAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objSightseeing = new Travel_Model_TblSightseeing();
        $SSSysId = base64_decode($this->getRequest()->getParam('id'));
        $approveDate = date('Y-m-d H:i:s');

        $updateArr = array('ApproveDate' => $approveDate, 'ApproveBy' => $this->intLoggedinUserId, 'IsApproved' => '1');

        $isApprove = $objSightseeing->setApproveDisapprove(" SSSysId=$SSSysId", "TB_IC_SightSeeing", $updateArr);
        $message = @$isApprove ? "Sightseeing approved successfully." : "Sightseeing approved failed.";

        $this->_helper->flashMessenger->addMessage($message);
        if (@$isApprove) {
            if ($this->intLoggedinUserRole == 1) {
                $this->_helper->redirector('manage-sightseeing', 'sightseeing', 'default');
            }
        }
    }

    /**
     * Stop Sale Hotel Action. 
     */
    public function stopSaleAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objSightseeing = new Travel_Model_TblSightseeing();
        $InvnItemSysId = base64_decode($this->getRequest()->getParam('id'));
        $redirect = base64_decode($this->getRequest()->getParam('uri'));

        $isDeactive = $objSightseeing->setSaleStartStop(" InvnItemSysId=$InvnItemSysId", "TB_MP_Inventory_SightSeeing", 0);
        $message = @$isDeactive ? "Sightseeing inventory sale stop successfully." : "Sightseeing inventory sale stop failed.";

        $this->_helper->flashMessenger->addMessage($message);
        if (@$isDeactive) {
            $this->_redirect($redirect);
            //$this->_helper->redirector('index', 'sightseeing', 'default');
        }
    }

    /**
     * Start Sale Hotel Action. 
     */
    public function startStopSaleAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objSightseeing = new Travel_Model_TblSightseeing();
        $params = $this->getRequest()->getParams();
        $InvnItemSysId = isset($params['InvnItemSysId']) ? (int)$params['InvnItemSysId'] : 0;
        $displayOnWebsite = isset($params['displayOnWebsite']) ? (int)$params['displayOnWebsite'] : 0;
        $status = $this->getRequest()->getParam('status');
        $showmsg = $this->getRequest()->getParam('showmsg');
        $statusValue = $displayOnWebsite;
        if($status == 1){
            $isActive = $objSightseeing->setSaleStartStop(" InvnItemSysId=$InvnItemSysId", "TB_MP_Inventory_SightSeeing", 1);
            $message = @$isActive ? "Sightseeing inventory sale start successfully." : "Sightseeing inventory sale start failed.";
            $URL = '<a onclick="startStpSales('.($InvnItemSysId).',0,0)" class="view_text1 tooltipLink startStpSalesLink'.$InvnItemSysId.'" title="Stop Sale"><i class="fa fa-stop"></i></a>';
             
        }else{
            $isActive = $objSightseeing->setSaleStartStop(" InvnItemSysId=$InvnItemSysId", "TB_MP_Inventory_SightSeeing", 0);
            $message = @$isActive ? "Sightseeing inventory sale stop successfully." : "Sightseeing inventory sale start failed.";
            $URL = '<a onclick="startStpSales('.($InvnItemSysId).',1,0)" class="view_text1 tooltipLink startStpSalesLink'.$InvnItemSysId.'" title="Start Sale"><i class="fa fa-play"></i></a>';
            $statusValue = 0;  
        }
        
        $data = array(
            'SSSysId' => $InvnItemSysId,
            'status' => $statusValue,
        );
        $return = $this->displayOnWebsite($data);
        if($showmsg == 1){
            $message = 'Display on website activate successfully.';
        }
        $this->_helper->flashMessenger->addMessage($message);
        $return = array('status' => true,'url' => $URL,'message' => $message,'statusValue'=>$statusValue);
        echo json_encode($return);die;
    }

    public function getOperatingTimeDivAction()
    {

        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            $max_fields = $this->getRequest()->getParam('max_fields');
            $srt = $this->getRequest()->getParam('srt');
            $OperatingTimeCounter = $this->getRequest()->getParam('OperatingTimeCounter');
            $div_str = '';

            if ($max_fields != "" && $srt != "0") {
                for ($i = 2; $i <= $srt; $i++) {
                    //echo $i;
                    if ($OperatingTimeCounter < $srt) {
                        if ($OperatingTimeCounter == 0) {
                            $div_str = '<script src="/public/assets/js/pages/pickerTool.js"></script><div style="margin-top:10px;" class="col-md-12 no-padding remove_field_div" id="opt_time_remove_2"><div class="col-md-2 col-sm-2 col-xs-2 no-padding-right" style="line-height:34px;">From</div><div class="col-md-3 col-sm-3 col-xs-3 no-padding-right"><input type="text" id="OperatingStTime_2" name="OperatingTime_2[]" value="" class="form-control whbg timePickerOnly" style="padding-left:3px; padding-right:3px;"></div><div class="col-md-2 col-sm-2 col-xs-2 no-padding-right text-right" style="line-height:34px">To</div><div class="col-md-3 col-sm-3 col-xs-3 no-padding-right"><input type="text" id="OperatingEndTime_2" name="OperatingTime_2[]" value="" class="form-control whbg timePickerOnly" style="padding-left:3px; padding-right:3px;"></div><div class="col-md-2 col-sm-2 col-xs-2"><button type="button" data-original-title="Delete" onclick="deleteOpTimeDiv(2);" id="delete_operating_time" class="btn btn-xs btn-danger tooltipLink" data-toggle="tooltip" data-placement="top" title=""><i class="fa fa-trash-o"></i></button></div></div>';
                        } else if ($OperatingTimeCounter == 1) {
                            $div_str = '<script src="/public/assets/js/pages/pickerTool.js"></script><div style="margin-top:10px;" class="col-md-12 no-padding remove_field_div" id="opt_time_remove_3"><div class="col-md-2 col-sm-2 col-xs-2 no-padding-right" style="line-height:34px;">From</div><div class="col-md-3 col-sm-3 col-xs-3 no-padding-right"><input type="text" id="OperatingStTime_3" name="OperatingTime_3[]" value="" class="form-control whbg timePickerOnly" style="padding-left:3px; padding-right:3px;"></div><div class="col-md-2 col-sm-2 col-xs-2 no-padding-right text-right" style="line-height:34px">To</div><div class="col-md-3 col-sm-3 col-xs-3 no-padding-right"><input type="text" id="OperatingEndTime_3" name="OperatingTime_3[]" value="" class="form-control whbg timePickerOnly" style="padding-left:3px; padding-right:3px;"></div><div class="col-md-2 col-sm-2 col-xs-2"><button type="button" data-original-title="Delete" onclick="deleteOpTimeDiv(3);" id="delete_operating_time" class="btn btn-xs btn-danger tooltipLink" data-toggle="tooltip" data-placement="top" title=""><i class="fa fa-trash-o"></i></button></div></div>';
                        }
                    }
                }
            } else if ($max_fields = 1 && $OperatingTimeCounter == 1) {
                $div_str = '<script src="/public/assets/js/pages/pickerTool.js"></script><div style="margin-top:10px;" class="col-md-12 no-padding remove_field_div" id="opt_time_remove_3"><div class="col-md-2 col-sm-2 col-xs-2 no-padding-right" style="line-height:34px;">From</div><div class="col-md-3 col-sm-3 col-xs-3 no-padding-right"><input type="text" id="OperatingStTime_3" name="OperatingTime_3[]" value="" class="form-control whbg timePickerOnly" style="padding-left:3px; padding-right:3px;"></div><div class="col-md-2 col-sm-2 col-xs-2 no-padding-right text-right" style="line-height:34px">To</div><div class="col-md-3 col-sm-3 col-xs-3 no-padding-right"><input type="text" id="OperatingEndTime_3" name="OperatingTime_3[]" value="" class="form-control whbg timePickerOnly" style="padding-left:3px; padding-right:3px;"></div><div class="col-md-2 col-sm-2 col-xs-2"><button type="button" data-original-title="Delete" onclick="deleteOpTimeDiv(3);" id="delete_operating_time" class="btn btn-xs btn-danger tooltipLink" data-toggle="tooltip" data-placement="top" title=""><i class="fa fa-trash-o"></i></button></div></div></div>';
            }

            echo $div_str;
            exit;
        }
    }

    public function getPlaceDetailsAction()
    {
        if ($this->getRequest()->isXmlHttpRequest()) {
            /* Disable layout */
            $this->_helper->viewRenderer->setNoRender(true);

            $this->_helper->layout->disableLayout();
            $strAddress = $this->getRequest()->getPost('address');
            $arrLocation = $this->getHelper('General')->getPlaceDetails($strAddress);
            echo Zend_Json::encode($arrLocation);
            exit;
        }
    }

    // Added By Pardeep Panchal
    //    public function displayOnB2cAction() {
    //        $this->_helper->layout->disableLayout();
    //        $this->_helper->viewRenderer->setNoRender(true);
    //        $objSightseeing = new Travel_Model_TblSightseeing();
    //        $SSSysId = trim($this->getRequest()->getParam('id'));
    //        $statusValue = trim($this->getRequest()->getParam('status'));
    //        $redirect = base64_decode($this->getRequest()->getParam('uri'));
    //        if ($this->intLoggedinUserRole != 1) {
    //            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
    //        } else {
    //            $intLoggedinUserId = "";
    //        }
    //
    //        $isDeactive = $objSightseeing->displayOnB2C($SSSysId, $statusValue);
    //        $message = @$isDeactive ? "Sightseeing status changed successfully." : "Oops! Action failed.";
    //        $this->_helper->flashMessenger->addMessage($message);
    //        $this->_redirect($redirect);
    //        //$this->_helper->redirector('index', 'sightseeing', 'default');
    //    }
    public function displayOnB2cAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $objSightseeing = new Travel_Model_TblSightseeing();
        $SSSysId = trim($this->getRequest()->getParam('id'));
        $statusValue = trim($this->getRequest()->getParam('status'));
        if ($this->intLoggedinUserRole != 1) {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        $data = array(
            'SSSysId' => $SSSysId,
            'status' => $statusValue,
        );
        $return = $this->displayOnWebsite($data);
        $status = ($statusValue == 1) ? 'activate' : 'deactivate';
        if ($return == 1) {
            $response = array('successs' => true, 'message' => 'Display on website ' . $status . ' successfully');
            echo json_encode($response);
            exit;
        } else {
            $response = array('successs' => false, 'message' => 'Oops! Action failed.');
            echo json_encode($response);
            exit;
        }
    }
    public function displayOnWebsite($data){
        $objSightseeing = new Travel_Model_TblSightseeing();
        $sessionLogin_user_url = new Zend_Session_Namespace('sessionLogin_user');
        if (trim($sessionLogin_user_url->agencyDetails['IsB2CSite']) == 1) {
           $SSSysId =  $data['SSSysId'];
           $statusValue =  $data['status'];
//           echo "<pre>";print_r($data);
//            $sessionLogin_user_url->agencyDetails['Url'] = 'http://local.superdmc.com/';
            $getXrefId = $objSightseeing->GetRateExist($SSSysId);
//            echo "<pre>";print_r($getXrefId);
            $this->postFields = "";
            $this->postFields .= "&AgencySysId=" . Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
            $this->postFields .= "&URL=" . trim($sessionLogin_user_url->agencyDetails['Url']);
            if ($statusValue == 1 && $getXrefId['InvnItemSysId'] > 0) {
                $ItemSourceType = $getXrefId['InvnItemSysId'];
                $this->postFields .= "&packageId=$ItemSourceType";
                $url = Catabatic_Helper::getSiteUrl() . "gtxwebservices/push-package/sightseeing-inv";
            } else {
                $ItemSourceType = $SSSysId;
                $this->postFields .= "&packageId=$ItemSourceType";
                $url = Catabatic_Helper::getSiteUrl() . "gtxwebservices/push-package/deactivate";
            }
            $writeLogObj = new Payment_Model_Payment();
            $writeLogObj->writeLog($this->postFields . "\n");
//            echo "<pre>";print_r($url);
            try {
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_POST, 1);
                if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
                    //     SSL connection
                    curl_setopt($ch, CURLOPT_PORT, 443);
                    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
                    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                }
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postFields);
                $output = curl_exec($ch);
                  
//                 echo "<pre>";print_r($output);exit;
                $writeLogObj->writeLog($output . "\n");
                curl_close($ch);
                $data = json_decode(stripslashes($output), true);

                $isDeactive = $objSightseeing->displayOnB2C(base64_encode($SSSysId), $statusValue);
                return 1;
            } catch (Zend_Exception $ex) {
                return 0;
            }
        } else {
            return 0;
        }
    }
    public function saveSicCostDataAction()
    {
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {

            //Call Activities Model
            $objSightseeing = new Travel_Model_TblSightseeing();
            //Get Post form data
            $post = $this->getRequest()->getPost();

//                        echo "<pre>";
//                        print_r($post);
//                        exit;

            $currentDate = date('Y-m-d H:i:s');

            $InvnItemSysId = $this->getRequest()->getPost('InvnItemSysId');

            if (empty($InvnItemSysId) || empty($this->intLoggedinUserId)) {
                throw new Exception('There has been an error, Please try again later');
            }
            $TotalCostNativeAdult = (isset($post['TotalCostNativeAdultSIC']) && $post['TotalCostNativeAdultSIC'] != '') ? $post['TotalCostNativeAdultSIC'] : 0;
            $TotalCostNativeChild = (isset($post['TotalCostNativeChildSIC']) && $post['TotalCostNativeChildSIC'] != '') ? $post['TotalCostNativeChildSIC'] : 0;
            $currency = (isset($post['CurrencyType']) && $post['CurrencyType'] != '') ? $post['CurrencyType'] : 1;

            if ($TotalCostNativeAdult == '') {
                $response = array('success' => false, 'msg' => 'Please enter adult cost.');
                echo json_encode($response);
                exit;
            }
            if ($TotalCostNativeChild == '') {
                $response = array('success' => false, 'msg' => 'Please enter child cost.');
                echo json_encode($response);
                exit;
            }

            $update = array('TotalCostNativeAdult' => $TotalCostNativeAdult, 'TotalCostNativeChild' => $TotalCostNativeChild);
            $objSightseeing->updateSightseeingInventoryDetails($update, $InvnItemSysId, $this->intLoggedinUserAgencySysId);
             
            $MPType = $objSightseeing->getSightseeingMarketPlacesByAgencySysId($InvnItemSysId, $this->intLoggedinUserAgencySysId, 1);
            //echo "<pre>";print_r($MPType);die;
            for ($man = 1; $man <= 2; $man++) {
                $TotalAdultSICMArkup = (isset($post['TotalAdultSICMArkup' . $man]) && $post['TotalAdultSICMArkup' . $man] != '') ? $post['TotalAdultSICMArkup' . $man] : 0;
                $TotalChildSICMArkup = (isset($post['TotalChildSICMArkup' . $man]) && $post['TotalChildSICMArkup' . $man] != '') ? $post['TotalChildSICMArkup' . $man] : 0;
                $TotalAdultSICCost = (isset($post['TotalAdultSICCost' . $man]) && $post['TotalAdultSICCost' . $man] != '') ? $post['TotalAdultSICCost' . $man] : 0;
                $TotalChildSICCost = (isset($post['TotalChildSICCost' . $man]) && $post['TotalChildSICCost' . $man] != '') ? $post['TotalChildSICCost' . $man] : 0;
                if ($TotalAdultSICCost != 0 && $TotalChildSICCost != 0) {


                    $insert = array(
                        'InvnItemSysId' => $InvnItemSysId,
                        'MPType' => $man,
                        'CustGrSysId' => $this->intLoggedinUserGroupSysId,
                        'AgencySysId' => $this->intLoggedinUserAgencySysId,
                        'MaxQntToSale' => 0,
                        'Currency' => $currency,
                        'MarkUpType' => 1,
                        'TaxPer' => 0,
                        'MarkUpNativeAdult' => $TotalAdultSICMArkup,
                        'MarkUpNativeChild' => $TotalChildSICMArkup,
                        'MarkUpForeignerAdult' => 0,
                        'MarkUpForeignerChild' => 0,
                        'DiscountType' => '0',
                        'DiscountMsg' => '',
                        'DiscountNativeAdult' => 0,
                        'DiscountNativeChild' => 0,
                        'DiscountForeignerAdult' => 0,
                        'DiscountForeignerChild' => 0,
                        'NetPriceNativeAdult' => $TotalAdultSICCost,
                        'NetPriceNativeChild' => $TotalChildSICCost,
                        'NetPriceForeignerAdult' => 0,
                        'NetPriceForeignerChild' => 0,
                        'IsPublish' => 1,
                        'PublishDate' => 0,
                        'Details' => '',
                        'RateRuleSysId' => 0,
                        'TCDocSysId' => 0,
                        'ValidTill' => $currentDate,
                        'CreateDate' => $currentDate,
                        'UpdateDate' => $currentDate,
                        'IsMarkForDel' => 0,
                        'IsActive' => 1
                    );

                    try {

                        if (!empty($MPType) && in_array($man, $MPType)) {
                            $where = array('InvnItemSysId = ? ' => $InvnItemSysId, 'MPType = ? ' => $man, 'AgencySysId = ? ' => $this->intLoggedinUserAgencySysId);
                            $objSightseeing->updateSightseeingSICDetails($insert, $where);
                        } else {
                            $objSightseeing->addMarkupSettings($insert);
                        }
                        $response = array('success' => true);
                    } catch (Exception $e) {
                        $response = array('success' => false, 'msg' => $e->getMessage());
                    }
                }
            }
            $getXrefId = $objSightseeing->GetRateExist($InvnItemSysId); 
            if((int)$getXrefId['XRef'] > 0){
                $objSightseeing->checkAndUpdateIsRateAvailable($this->intLoggedinUserAgencySysId,(int)$getXrefId['XRef']);
            }
            echo json_encode($response);
            exit;
        }
    }
    public function deleteSicCostDataAction()
    {
        $this->_helper->layout->disableLayout();

        if ($this->_request->isXmlHttpRequest()) {
            $objSightseeing = new Travel_Model_TblSightseeing();
            $post = $this->getRequest()->getPost();
//            echo "<pre>";print_r($post);die;
            $InvnItemSysId = isset($post['InvnItemSysId']) ? (int)$post['InvnItemSysId'] : 0;
            if($InvnItemSysId>0){
                $updateInv = array('TotalCostNativeAdult' => 0, 'TotalCostNativeChild' => 0);
                $objSightseeing->updateSightseeingInventoryDetails($updateInv, $InvnItemSysId, $this->intLoggedinUserAgencySysId);
                
                $insert = array('IsMarkForDel'=>1);
                $where = array('InvnItemSysId = ? ' => $InvnItemSysId, 'AgencySysId = ? ' => $this->intLoggedinUserAgencySysId);
                $objSightseeing->updateSightseeingSICDetails($insert, $where);
                
                $getXrefId = $objSightseeing->GetRateExist($InvnItemSysId);
                if((int)$getXrefId['XRef'] > 0){
                    $objSightseeing->checkAndUpdateIsRateAvailable($this->intLoggedinUserAgencySysId,(int)$getXrefId['XRef']);
                }
                $response = array('success' => true); 
            }else{
                $response = array('success' => false,'success'=>'Missing Parameters, Unable to remove.');
            }
            echo json_encode($response);
            exit;
        }
    }
    public function addSightseeingPlaceDetailAction()
    {
        $this->_helper->layout->disableLayout();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $objPackage = new Travel_Model_TblPackage();
        $sightseeing = $this->getRequest()->getParam('sightseeing');
        $this->view->sightseeing = $sightseeing;
        //echo '<pre>';
        //echo $this->getRequest()->getParam('code');
    }
    public function saveSightseeingVehicleDataAction(){
        $this->_helper->layout->disableLayout();
        if ($this->_request->isXmlHttpRequest()) {
            $objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
            $objSightseeing = new Travel_Model_TblSightseeing();
            $post = $this->getRequest()->getPost();
//            echo"<pre>";print_r($post);die('here');
            $InvnItemSysId = isset($post['InvnItemSysId']) ? (int)$post['InvnItemSysId'] : 0;
            $currentDate = date('Y-m-d');
            if($InvnItemSysId>0){
                $pickup_city = trim($post['pickup_city']);
                $pickup_point_area_id = $post['pickup_point_area_id'];
                $pickup_point_area = $post['pickup_point_area'];
                $vehicle_name = (!empty($post['vehicle_name'])) ? explode('~~',$post['vehicle_name']) : '';
                $vehicle_cost = (float)$post['vehicle_cost'];
                $vehicle_markup_type = (int)$post['vehicle_markup_type'];
                $vehicle_markup = (float)$post['vehicle_markup'];
                $vehicle_total_cost = (float)$post['vehicle_total_cost'];
                $car_capacity = (int)$post['car_capacity'];
                $supplier_type = trim($post['supplier_type']);
                $supplier_type_id = (int)$post['supplier_type_id'];
                if(empty($pickup_point_area_id)){
                    $response = array('status' => false, 'message' => 'Please select pick area fro suggestion!!!');
                    echo json_encode($response); exit; 
                }
                if(empty($vehicle_name)){
                    $response = array('status' => false, 'message' => 'Please select vehicle name!!!');
                    echo json_encode($response); exit; 
                }
                 if(empty($car_capacity)){
                    $response = array('status' => false, 'message' => 'Please enter vehicle  capacity!!!');
                    echo json_encode($response); exit; 
                }
                if(empty($supplier_type_id)){
                    $response = array('status' => false, 'message' => 'Please select supplier!!!');
                    echo json_encode($response); exit; 
                }
                if((int)$vehicle_cost == 0){
                    $response = array('status' => false, 'message' => 'Please enter vehicle cost!!!');
                    echo json_encode($response); exit; 
                }
               
                $VehicleData = array(
                    'RouteSysId' => 0,
                    'SSInvnItemSysId' => $InvnItemSysId,
                    'PickupAreaId' => (int)$pickup_point_area_id,
                    'VehicleSysId' => (int)$vehicle_name[0],
                    'VehicleTypeSysId' => 0,
                    'SupplierSysId' => $supplier_type_id,
                    'CurrencyType' => (int)$post['CurrencyType'],
                    'Cost' => $vehicle_cost,
                    'MarkupType' => $vehicle_markup_type,
                    'Markup' => $vehicle_markup,
                    'TotalCost' => $vehicle_total_cost,
                    'Capacity' => (int)$post['car_capacity'],
                    'UpdateDate' => $currentDate,
                    'CreateDate' => $currentDate,
                    'IsActive' => '1',
                    'IsMarkForDel' => '0',
                    'ChildCost' => 0,
                    'ChildAge' => 0,
                    'vehicleCostType' => 0,
                    'vehicleKM' => 0,
                    'vehiclePerKMCost' => 0,
                    'vehicleDriverPerDayCost' => 0,
                    'vehicleDriverPerNightCost' => 0,
                    'vehicleTollTax' => 0,
                    'vehicleOtherCost' => 0,
                );
                            
             
                try {
                    $RouteVechSysId = $objTransportsRoutes->addRoutesVehicles($VehicleData);
                    $getXrefId = $objSightseeing->GetRateExist($InvnItemSysId);
                    if((int)$getXrefId['XRef'] > 0){
                        $objSightseeing->checkAndUpdateIsRateAvailable($this->intLoggedinUserAgencySysId,(int)$getXrefId['XRef']);
                    } 
                } catch (Zend_Exception $e) {
                    $response = array('status' => false, 'msg' => $e->getMessage());
                    echo json_encode($response);
                    exit;
                }
                
                
                if($RouteVechSysId){
                    $data = array(
                        'CityName'=>$pickup_city,
                        'PickupAreaName'=>$pickup_point_area,
                        'VehicleName'=>$vehicle_name[1],
                        'Capacity'=>$car_capacity,
                        'Supplier'=>$supplier_type,
                        'Cost'=>$vehicle_cost,
                    );
                    $response = array('status' => true, 'message' => '', 'RVSysId'=>$RouteVechSysId, 'IISysId'=>$InvnItemSysId,'data' => $data); 
                }else{
                    $response = array('status' => false, 'message' => '');
                }
            }else{
                $response = array('status' => false, 'message' => 'Error, Please try after some time!!!');
            }
            
            echo json_encode($response); exit; 
        }  
    }
    public function saveSightseeingOtherServicesDataAction(){
        $this->_helper->layout->disableLayout();
        if ($this->_request->isXmlHttpRequest()) {
            $objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
            $objSightseeing = new Travel_Model_TblSightseeing();
            $post = $this->getRequest()->getPost();
            //echo"<pre>";print_r($post);die('here');
            $InvnItemSysId = isset($post['InvnItemSysId']) ? (int)$post['InvnItemSysId'] : 0;
             
            if($InvnItemSysId>0){
                $service_type = trim($post['service_type']); 
                $service_price_type = (int)$post['service_price_type']; 
                $service_total_cost = (float)$post['service_total_cost']; 
                $supplier_type = trim($post['supplier_type']);
                $supplier_type_id = (int)$post['supplier_type_id'];
                $CurrencyType = (int)$post['CurrencyType'];
                 
                if(empty($service_type)){
                    $response = array('status' => false, 'message' => 'Please enter service name!!!');
                    echo json_encode($response); exit; 
                } 
                if((int)$service_total_cost == 0){
                    $response = array('status' => false, 'message' => 'Please enter service cost!!!');
                    echo json_encode($response); exit; 
                }
               
                $ServiceData = array( 
                    'InvnItemSysId' => $InvnItemSysId,
                    'AgencySysId' => (int)$this->intLoggedinUserAgencySysId,
                    'Title' => $service_type,
                    'Detail' => '',
                    'PriceType' => $service_price_type,
                    'CostCurrency' => (int)$CurrencyType,
                    'TotalCost' => $service_total_cost, 
                    'SupplierSysId' => $supplier_type_id, 
                    'IsActive' => '1',
                    'IsMarkForDel' => '0', 
                );
                   
                try {
                    $ExtraServiceSysId = $objSightseeing->addSIghtseeingExtraServices($ServiceData);
                } catch (Zend_Exception $e) {
                    $response = array('status' => false, 'msg' => $e->getMessage());
                    echo json_encode($response);
                    exit;
                }
                
                $data = array(
                    'service_type' => $service_type,
                    'supplier_type' => $supplier_type,
                    'total_cost' => $service_total_cost,
                    'price_type' => ($service_price_type == 1) ? 'Per Vehicle' : 'Per Person',
                );
                if($ExtraServiceSysId){ 
                    $response = array('status' => true, 'message' => '', 'ExtraServiceSysId'=>$ExtraServiceSysId, 'IISysId'=>$InvnItemSysId,'data' => $data); 
                }else{
                    $response = array('status' => false, 'message' => 'Unable to save, Please try after some time!!!');
                }
            }else{
                $response = array('status' => false, 'message' => 'Error, Please try after some time!!!');
            }
            
            echo json_encode($response); exit; 
        }  
    }
    public function removeSightseeingVehicleDataAction(){
        $this->_helper->layout->disableLayout();
        if ($this->_request->isXmlHttpRequest()) {
             
            $post = $this->getRequest()->getPost();
            $IISysId = (int)$post['IISysId'];
            $RVSysId = (int)$post['RVSysId'];
            if($IISysId>0 && $RVSysId>0){
                $objPackage = new Travel_Model_TblPackage();
                $objSightseeing = new Travel_Model_TblSightseeing();
                $where = array('SSInvnItemSysId = ? ' => $IISysId,'RouteVechSysId = ? ' => $RVSysId);
                $data = array('IsMarkForDel' => 1,'IsActive' => 0);
                 
                $objPackage->updateData('TB_Agency_Transport_Route_Vehicle', $data, $where);
                $getXrefId = $objSightseeing->GetRateExist($IISysId);
                if((int)$getXrefId['XRef'] > 0){
                    $objSightseeing->checkAndUpdateIsRateAvailable($this->intLoggedinUserAgencySysId,(int)$getXrefId['XRef']);
                } 
            }
            $response = array('status' => true, 'message' => 'Vehicle Data Removed Successfully.');
            echo json_encode($response); exit; 
        }
    }
    public function removeSightseeingOtherServicesDataAction(){
        $this->_helper->layout->disableLayout();
        if ($this->_request->isXmlHttpRequest()) {
             
            $post = $this->getRequest()->getPost();
            $IISysId = (int)$post['IISysId'];
            $ESSysId = (int)$post['ESSysId'];
            if($IISysId>0 && $ESSysId>0){
                $objPackage = new Travel_Model_TblPackage(); 
                $where = array('InvnItemSysId = ? ' => $IISysId,'ExtraServiceSysId = ? ' => $ESSysId);
                $data = array('IsMarkForDel' => 1,'IsActive' => 0);
                $objPackage->updateData('TB_MP_Inventory_SightSeeing_ExtraServices', $data, $where); 
            }
            $response = array('status' => true, 'message' => 'Service Data Removed Successfully.');
            echo json_encode($response); exit; 
        }
    }
    public function deleteSightseeingRatesAction(){
        $this->_helper->layout->disableLayout(); 
        $objPackage = new Travel_Model_TblPackage();
        $objSightseeing = new Travel_Model_TblSightseeing();
        if ($this->_request->isXmlHttpRequest()) { 
            $params = $this->getRequest()->getParams();  
            $InvnItemSysId = (isset($params['InvnItemSysId'])) ? (int)base64_decode($params['InvnItemSysId']) : 0;
            $SSSysId = (isset($params['SSSysId'])) ? (int)base64_decode($params['SSSysId']) : 0;
            $statusValue = (isset($params['statusValue'])) ? (int)($params['statusValue']) : 0;
            
            if((int)$InvnItemSysId>0){
                $objPackage->updateData('TB_MP_Inventory_SightSeeing', array('IsMarkForDelete' => 1), array('InvnItemSysId = ? ' => $InvnItemSysId));
                $Status = true;
                $message = 'Delete Successfully.';
                
                $IsRate = $objSightseeing->checkAndUpdateIsRateAvailable($this->intLoggedinUserAgencySysId,$SSSysId);
                $data = array(
                    'SSSysId' => $InvnItemSysId,
                    'status' => $IsRate,
                );
                $return = $this->displayOnWebsite($data);
            }else{
                $Status = false;
                $message = 'Data Missing';
            }
            $return = array('status' => $Status, 'message' => $message);
            echo json_encode($return);die;
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit