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/ActivitiesController.php
<?php
/**
 * Class Activities
 * @name		Activities
 * @author		Mangal Katiyar
 * @version 	1.0
 * @copyright 	Catabatic India Pvt Ltd
 * Handle Activities Related function
 * Last Update :- Md Sabir
*/

class ActivitiesController extends Catabatic_ValidateGtx
{
    const ADMIN_ID = 1;
    const CONST_SOURCE_ADMIN = 3;
    private $intLoggedinUserId = '';
    private $intLoggedinUserGroupSysId = '';
    private $intLoggedinUserAgencySysId = '';
    private $intLoggedinUserTrxCurrency = '';
    private $IsB2CSite = false;
    private $baseUrl = '';
    private $siteUrl = '';
    private $SupplierTypeSysId = 0;
    private $InfoSourceSysId = 0;
    private $intLoggedinUserRole = 0;
    private $upload_dir = '';
    private $file_path = '';
    
    public function init() {
        parent::init();
        $aConfig = $this->getInvokeArg('bootstrap')->getOptions();
        $this->siteUrl = $aConfig['bootstrap']['siteUrl'];
        
        $sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
        //Zend_Session::rememberMe(60 * 60 * 24 * 7);
        $sessionLogin_user->lock();
        
        #get session variable
        $this->SupplierTypeSysId = 5;
        $this->InfoSourceSysId = '2'; // Information Source is Agent //
        $this->intLoggedinUserRole          = $sessionLogin_user->UserRole;
        $this->intLoggedinUserId            = $sessionLogin_user->intLoggedinUserId;
        $this->intLoggedinUserGroupSysId    = $sessionLogin_user->intLoggedinUserGroupSysId;
        $this->intLoggedinUserAgencySysId   = $sessionLogin_user->intLoggedinUserAgencySysId;
        $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/Activity/";
        $this->file_path = $_SERVER['DOCUMENT_ROOT'] . $this->upload_dir;
        
        
        // unlocking read-only lock
        if ($sessionLogin_user->isLocked()) {
            $sessionLogin_user->unLock();
        }

    }
    
    public function indexAction()
    {
        $objActivities = new Travel_Model_TblActivities();
        
        //Get City List
        $cityList = $objActivities->getInventoryCityList($this->intLoggedinUserAgencySysId);
        $this->view->cityList = $cityList;
        
        //Get Activities Group Type List 
        $this->view->arrActivitiesGroupTypeList = $objActivities->getAllActivityGroupTypeList();
        
        //Get Activities Type List 
        $this->view->arrActivitiesTypeList = $objActivities->getAllActivityTypeList();
        
        //Get Supplier List
        $supplierList = $objActivities->getSuppliersList($cityId='', $this->intLoggedinUserId);
        $this->view->supplierList = $supplierList;
//        echo "<pre>";print_r($this->view->supplierList);
        if(isset($post['supplierservices']) && !empty($post['supplierservices'])) {

            $supplierservices = $post['supplierservices'];

            $whereCondition .= " AND ( ',' + ServicesType + ',' like '%,' + '$supplierservices' + ',%' )";

        }
        //Start Search Code
        $searchArr = array();
        $getData = array();
        if($this->getRequest()->isPost())
        {
            $getData = $this->getRequest()->getPost();
//            echo "<pre>";print_r($getData);
            if(!empty($getData))
            {
                if(@$getData['cityId']!=0)
                {
                    $DestinationId = @$getData['cityId'];
                } else {
                    $DestinationId = "";
                }
                if(@$getData['ActivityGroupType']!=0)
                {
                    $ActivityGroupType = @$getData['ActivityGroupType'];
                } else {
                    $ActivityGroupType = "";
                }
                if(@$getData['ActivityType']!=0)
                {
                    $ActivityType = @$getData['ActivityType'];
                } else {
                    $ActivityType = "";
                }
                if(@$getData['supplierId']!=0)
                {
                    $supplierId = $getData['supplierId'];
                } else {
                    $supplierId = "";
                }
                if(@$getData['ActivityName']!="")
                {
                    $ActivityName = $getData['ActivityName'];
                } else {
                    $ActivityName = "";
                }
                $searchArr = array(
                            'cityId'=>$DestinationId,
                            'ActivityGroupType'=>$ActivityGroupType,
                            'ActivityType'=>$ActivityType,
                            'supplierId'=>$supplierId,
                            'ActivityName'=>$ActivityName
               );
//                echo "<pre>";print_r($searchArr);
            } 
        } else {
            $DestinationId = $this->_getParam('cityId');
            $ActivityGroupType = $this->_getParam('ActivityGroupType');
            $ActivityType = $this->_getParam('ActivityType');
            $supplierId = $this->_getParam('supplierId');
            $ActivityName = $this->_getParam('ActivityName');
            if($DestinationId!=0)
            {
                $DestinationId = $DestinationId;
            } else {
                $DestinationId = "";
            }
            if($ActivityGroupType!=0)
            {
                $ActivityGroupType = $ActivityGroupType;
            } else {
                $ActivityGroupType = "";
            }
            if($ActivityType!=0)
            {
                $ActivityType = $ActivityType;
            } else {
                $ActivityType = "";
            }
            if($supplierId!=0)
            {
                $supplierId = $supplierId;
            } else {
                $supplierId = "";
            }
            if($ActivityName!="")
            {
                $ActivityName = $ActivityName;
            } else {
                $ActivityName = "";
            }
            $searchArr = array(
                        'cityId'=>$DestinationId,
                        'ActivityGroupType'=>$ActivityGroupType,
                        'ActivityType'=>$ActivityType,
                        'supplierId'=>$supplierId,
                        'ActivityName'=>$ActivityName
            );
            
        }
        
        //echo "<pre>"; print_r($searchArr);
        $objActivities->searchArr = $searchArr;
        $this->view->searchArr = $searchArr;
        
        
        //Agency Id
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $ActivitiesList = $objActivities->getAllActivitiesList($intLoggedinUserAgencySysId);
//        echo "<pre>"; print_r($ActivitiesList);
        
        $page=$this->_getParam('page',1);
        $paginator = Zend_Paginator::factory($ActivitiesList);      
        $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 manageActivitiesAction()
    {
        $objActivities = new Travel_Model_TblActivities();
        
        //Agency Id
        if($this->intLoggedinUserRole!=1)
        {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        //Get City List
        $cityList = $objActivities->getActivitiesCityList($intLoggedinUserId);
        $this->view->cityList = $cityList;
        //Get Activities Type List 
        $this->view->arrActivitiesTypeList = $objActivities->getAllActivityTypeList();
        $this->view->arrCategoryTypeList = $objActivities->getAllActivityGroupTypeList();

//        echo "<pre>"; print_r($this->view->arrCategoryTypeList);

        
//        echo "<pre>"; print_r($this->view->arrActivitiesTypeList);

        //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['ActivityType']!=0)
                {
                    $ActivityType = @$getData['ActivityType'];
                } else {
                    $ActivityType = "";
                }
                if(@$getData['ActivityName']!="")
                {
                    $ActivityName = $getData['ActivityName'];
                } else {
                    $ActivityName = "";
                }
                $searchArr = array(
                            'cityId'=>$DestinationId,
                            'ActivityType'=>$ActivityType,
                            'ActivityName'=>$ActivityName
               );
            } 
        } else {
            $DestinationId = $this->_getParam('cityId');
            $ActivityType = $this->_getParam('ActivityType');
            $ActivityName = $this->_getParam('ActivityName');
            if($DestinationId!=0)
            {
                $DestinationId = $DestinationId;
            } else {
                $DestinationId = "";
            }
            if($ActivityType!=0)
            {
                $ActivityType = $ActivityType;
            } else {
                $ActivityType = "";
            }
            if($ActivityName!="")
            {
                $ActivityName = $ActivityName;
            } else {
                $ActivityName = "";
            }
            $searchArr = array(
                        'cityId'=>$DestinationId,
                        'ActivityType'=>$ActivityType,
                        'ActivityName'=>$ActivityName
            );
        }
        
//        echo "<pre>"; print_r($searchArr);
        $objActivities->searchActivitiesArr = $searchArr;
        $this->view->searchArr = $searchArr;
        
        
        $ActivitiesList = $objActivities->getAllManageActivitiesList($intLoggedinUserId);

       
//       echo "<pre>"; print_r($ActivitiesList);

//           foreach($ActivitiesList as $value_ActivitiesList) 
//                    {
//            
//                $ActivitiesList+= explode(",",$value_ActivitiesList['ActivityGrType']); 
////                echo "<pre>"; print_r($ActivityGrType);
//                    }
//                die;  
//        echo "<pre>"; print_r($ActivitiesList[0]['ActivityGrType']);  die;
//        $this->view->activitiesList = $ActivitiesList;

        $page=$this->_getParam('page',1);
        $paginator = Zend_Paginator::factory($ActivitiesList);      
        $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 addActivitiesInventoryAction()
    {
        //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)
        {
            $this->render('add-activities-inventory-admin');
        }
    }
    
    public function viewActivitiesInventoryBulkFormAction() {
        
        $this->_helper->layout->setLayout('newLayout');
        //die;
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            //Get Currency List
            $objCurrency = new Travel_Model_TblCurrency();
            $this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
            
            $objTest = new Cityprofiling_Model_TblCityprofiling();
            //$this->view->arrTest = $objTest->getTest();

            //Get Country List 
            $objCountry = new Travel_Model_TblCountry();
            $this->view->arrCountryList = $objCountry->getCountryList();
            
            //Get Activity Inc  Type List 
            $objActivities = new Travel_Model_TblActivities();
            $this->view->arrActivityInclypeList = $objActivities->getAllActivityInclypeList();
            
            //Get Booking Type List 
            $this->view->arrBookingTypeList = $objActivities->getAllBookingTypeList();
            
            $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
            $arrActivitiesInventoryList = $objActivities->getAllActivitiesInventoryList($intLoggedinUserAgencySysId);
            $this->view->activitiesInventoryCountList = !empty($arrActivitiesInventoryList) ? count($arrActivitiesInventoryList) : 0;
        } 
    }
    
    public function viewActivitiesAddInventoryBulkFormAction() {
        
        $this->_helper->layout->setLayout('newLayout');
        //die;
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            $ActivitySysId  = base64_decode($this->getRequest()->getParam('ActivitySysId'));
            
            if($this->intLoggedinUserRole!=1)
            {
                $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
            } else {
                $intLoggedinUserId = "";
            }

            $objActivities = new Travel_Model_TblActivities();
            $this->view->arrActivitiesDetails = $objActivities->getManageActivitiesDetails($ActivitySysId, $intLoggedinUserId);
            //echo '<pre>';print_r($arrActivitiesDetails);echo '</pre>';
            //Get Currency List
            $objCurrency = new Travel_Model_TblCurrency();
            $this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
            
            $objTest = new Cityprofiling_Model_TblCityprofiling();
            //$this->view->arrTest = $objTest->getTest();

            //Get Country List 
            $objCountry = new Travel_Model_TblCountry();
            $this->view->arrCountryList = $objCountry->getCountryList();
            
            //Get Activity Inc  Type List 
            $this->view->arrActivityInclypeList = $objActivities->getAllActivityInclypeList();
            
            //Get Booking Type List 
            $this->view->arrBookingTypeList = $objActivities->getAllBookingTypeList();
            
            $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
            $arrActivitiesInventoryList = $objActivities->getAllActivitiesInventoryList($intLoggedinUserAgencySysId);
            $this->view->activitiesInventoryCountList = !empty($arrActivitiesInventoryList) ? count($arrActivitiesInventoryList) : 0;
        } 
    }
    
    public function viewActivitiesInventoryBulkEditFormAction() {
        
        $this->_helper->layout->setLayout('newLayout');
       
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $InvnItemSysId  = base64_decode($this->getRequest()->getParam('InvnItemSysId'));
            
            $objActivities = new Travel_Model_TblActivities();
            $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
            $arrActivitiesInventoryDetails = $objActivities->getActivitiesInventoryDetailsList($InvnItemSysId, $intLoggedinUserAgencySysId);
            
            $FromDateTimeObj = (array) $arrActivitiesInventoryDetails['FromDate'];
            $from_date_time = date("d/m/Y",strtotime($FromDateTimeObj['date'])); 
            
            $ToDateTimeObj = (array) $arrActivitiesInventoryDetails['ToDate'];
            $to_date_time = date("d/m/Y",strtotime($ToDateTimeObj['date'])); 
            
            $arrActivitiesInventoryDetailsArr = array('FromDateFormat'=>$from_date_time,'ToDateFormat'=>$to_date_time);
            
            $arrActivitiesInventoryDetailsArrFinal = array();
            $arrActivitiesInventoryDetailsArrFinal = @array_merge($arrActivitiesInventoryDetails,$arrActivitiesInventoryDetailsArr);
            $this->view->arrActivitiesInventoryDetails = $arrActivitiesInventoryDetailsArrFinal;
            //echo "<pre>"; print_r($arrActivitiesInventoryDetailsArrFinal);die;
        } 
    }
    
    public function viewActivitiesInventoryIndividualFormAction() {



//echo "exit";exit;

        $this->_helper->layout->setLayout('newLayout');
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            $post=$this->getRequest()->isPost();
//            echo "<pre>";
//            print_r($post);
//            exit;
            //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 Activities Group Type List 
            $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 = $objActivities->getAllDifficultyTypeList();
            $params = $this->getRequest()->getParams();
            $this->view->params = @$params;
        } 
    }
    
    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 arrayUnique($array, $preserveKeys = false)
    {
        // Unique Array for return
        $arrayRewrite = array();
        // Array with the md5 hashes
        $arrayHashes = array();
        foreach($array as $key => $item) {
            // Serialize the current element and create a md5 hash
            $hash = md5(serialize($item));
            // If the md5 didn't come up yet, add the element to
            // to arrayRewrite, otherwise drop it
            if (!isset($arrayHashes[$hash])) {
                // Save the current element hash
                $arrayHashes[$hash] = $hash;
                // Add element to the unique Array
                if ($preserveKeys) {
                    $arrayRewrite[$key] = $item;
                } else {
                    $arrayRewrite[] = $item;
                }
            }
        }
        return $arrayRewrite;
    }
    public function saveActivitiesAction() 
    {    
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        
        if($this->getRequest()->isPost())
        {
            $post = $this->getRequest()->getPost();
            $objActivities = new Travel_Model_TblActivities();
            $params = json_decode(base64_decode($post['params']),1);
            
//            echo "<pre>";print_r($params);print_r($post);die;
            /* For activities */
            if(!empty($post)) {
                $ActivitySysId        = isset($post['ActivitySysId']) ? $post['ActivitySysId'] : '0';
                $isunique        = isset($post['isunique']) ? $post['isunique'] : '0';
                $ContId               = isset($post['ContId']) ? $post['ContId'] : '';
                $CitySysId            = isset($post['CitySysId']) ? $post['CitySysId'] : '0';
                $ActivityGroupType    = isset($post['ActivityGroupType']) ? @implode(",",@$post['ActivityGroupType']) : '';

                $ActivityType         = isset($post['ActivityType']) ? @implode(",",@$post['ActivityType']) : '';
                $ActivityNameArr = array(); $ActivityGroupNameArr = array(); 
                if(!empty($post['ActivityGroupType'])){
                    foreach ($post['ActivityGroupType'] as $GroupType) {
                        $ActivityGroupNameArr[] = isset($GroupType)?$objActivities->getActivityGroupName($GroupType):'0';
                    }
                }
                if(!empty($post['ActivityType'])){
                    foreach ($post['ActivityType'] as $value) {
                        $ActivityNameArr[] = isset($value)?$objActivities->getActivityName($value):'0';
                    }
                }
                
                $ActivityGroupTypeName    = isset($ActivityGroupNameArr) ? json_encode($ActivityGroupNameArr) : '';
                $ActivityTypeName         = isset($ActivityNameArr) ? json_encode($ActivityNameArr) : '';

                //echo '<pre>';print_r($post);
                //echo '<pre>';print_r($ActivityGroupTypeName);
                //die('dd');
                $ActivityName         = isset($post['ActivityName']) ? trim($this->sanitize_data($post['ActivityName'])) : '';
                $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']) : '0';
                $IsTransferInc        = isset($post['Transfers']) ? $post['Transfers'] : '0';
                $pick_drop            = isset($post['pick_drop']) ? trim($this->sanitize_data($post['pick_drop'])) : '';
                $details              = isset($post['details']) ? trim($this->sanitize_data_html($post['details']))  : '';
                $address              = isset($post['Address']) ? trim($this->sanitize_data($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'])) : '';
            } 
            
            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;
            }
            if(!empty($Duration))
            {
                $DurationDays = $Duration[0];
                $DurationMin   = $Duration[1];
            } else {
                $DurationDays = 0;
                $DurationMin   = 0;
            }

            $arrActivitiesDetails = $objActivities->getManageActivitiesDetails($ActivitySysId, $this->intLoggedinUserId);

            
            $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;
            $AliasAndMeta = "";
            $ActivityIncMask=0;
//            $DurationInMin=0;
            
            $MinPax =0;
            $MaxPax = 0;
            $LeanMonthMask="1000000000000";
            $SilentMonthMask="1000000000000";
            if($arrActivitiesDetails['IsKidAllowed']!="")
            {
                $IsKidAllowed = $arrActivitiesDetails['IsKidAllowed'];
            } else {
                $IsKidAllowed = 0;
            }
            if($arrActivitiesDetails['IsTeenAllowed']!="")
            {
                $IsTeenAllowed = $arrActivitiesDetails['IsTeenAllowed'];
            } else {
                $IsTeenAllowed = 0;
            }
            if($arrActivitiesDetails['IsAdultAllowed']!="")
            {
                $IsAdultAllowed = $arrActivitiesDetails['IsAdultAllowed'];
            } else {
                $IsAdultAllowed = 0;
            }
            if($arrActivitiesDetails['IsPetAllowed']!="")
            {
                $IsPetAllowed = $arrActivitiesDetails['IsPetAllowed'];
            } else {
                $IsPetAllowed = 0;
            }
            if($arrActivitiesDetails['IsTrxAllowed']!="")
            {
                $IsTrxAllowed = $arrActivitiesDetails['IsTrxAllowed'];
            } else {
                $IsTrxAllowed = 0;
            }
            if($arrActivitiesDetails['IsPickAllowed']!="")
            {
                $IsPickAllowed = $arrActivitiesDetails['IsPickAllowed'];
            } else {
                $IsPickAllowed = 0;
            }
            $Rating=0;
            if($arrActivitiesDetails['AwardRecognizations']!="" && $arrActivitiesDetails['AwardRecognizations']!=0)
            {
                $AwardRecognizations = $arrActivitiesDetails['AwardRecognizations'];
            } else {
                $AwardRecognizations = "";
            }
            if($arrActivitiesDetails['BookingType']!="")
            {
                $BookingType = $arrActivitiesDetails['BookingType'];
            } else {
                $BookingType = 0;
            }
            if($arrActivitiesDetails['StartLocalTime']!="")
            {
                $StartLocalTime = $arrActivitiesDetails['StartLocalTime'];
            } else {
                $StartLocalTime = $CreateDate;
            }
            if($arrActivitiesDetails['EndLocalTime']!="")
            {
                $EndLocalTime = $arrActivitiesDetails['EndLocalTime'];
            } else {
                $EndLocalTime = $CreateDate;
            }
            $IsDayLightApp =0;
//            if($arrActivitiesDetails['latitude']!="" && $arrActivitiesDetails['latitude']!=0)
//            {
//                $latitude = $arrActivitiesDetails['latitude'];
//            } else {
//                $latitude = 0;
//            }
//            if($arrActivitiesDetails['longitude']!="" && $arrActivitiesDetails['longitude']!=0)
//            {
//                $longitude = $arrActivitiesDetails['longitude'];
//            } else {
//                $longitude = 0;
//            }
            
            $PinCode="";
            $ZoneSysId =0;
            $ZoneType=0;
            $StateSysId=0;
            if($arrActivitiesDetails['PrimaryContact']!="" && $arrActivitiesDetails['PrimaryContact']!=0)
            {
                $PrimaryContact = $arrActivitiesDetails['PrimaryContact'];
            } else {
                $PrimaryContact = "";
            }
            if($arrActivitiesDetails['SecondaryContact']!="" && $arrActivitiesDetails['SecondaryContact']!=0)
            {
                $SecondaryContact = $arrActivitiesDetails['SecondaryContact'];
            } else {
                $SecondaryContact = "";
            }
            if($arrActivitiesDetails['OtherContacts']!="" && $arrActivitiesDetails['OtherContacts']!=0)
            {
                $OtherContacts = $arrActivitiesDetails['OtherContacts'];
            } else {
                $OtherContacts = "";
            }
            
            $ApproveBy = 0;
            $ApproveDate = date('Y-m-d H:i:s');
            
            
            /* Check if connecting flight already exists */
//            $arrFlightConnecting = $objFlight->getCustomizedMarkups($InvnItemSysId,$this->intLoggedinUserId );
//
//            if(!empty($arrFlightConnecting)) {
//                $response = array('success' => false, 'msg' => 'Connecting flight of the selected airlines has already been added.');
//                echo json_encode($response);
//                exit;
//            }
            
           
                


            if($ActivitySysId!="" && $ActivitySysId!=0)
            {
                if($this->intLoggedinUserRole!=1)
                {
                    $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
                } else {
                    $intLoggedinUserId = "";
                } 
                $AgentSysId = $arrActivitiesDetails['AgentSysId']; 
                $IsAgentSpec = $arrActivitiesDetails['IsAgentSpec']; 
                $IsApproved = $arrActivitiesDetails['IsApproved']; 
                $IsActive = $arrActivitiesDetails['IsActive']; 
                $IsMarkForDel = $arrActivitiesDetails['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 = $objActivities->setMasking($season_month, $season_month_arr);
            } else {
                $seasonMonthMasking = "1000000000000";
            }
            //Days of week Masking
            if(!empty($season_day))
            {
                $season_day_arr  = unserialize(SEASON_DAYS);
                $seasonDaysMasking = $objActivities->setMasking($season_day, $season_day_arr);
            } else {
                $seasonDaysMasking = "10000000";
            }
            

            
            $insert = 
            array(
                'IsAgentSpec'              => $IsAgentSpec,
//                'AgentSysId'               => $AgentSysId,
                'ICSourceSysId'            => $this->intLoggedinUserAgencySysId,
                'StartPlaceSysId'          => $StartPlaceSysId,
                'EndPlaceSysId'            => $EndPlaceSysId,       
                'Title'                    => $ActivityName,
                'synonyms'                    => $ActivityName,
                'WriteUp'                  => $details,
                'DifficultyLevel'          => $difficulty_level,
                'AliasAndMeta'             => $AliasAndMeta,
                'ActivityGrType'           => $ActivityGroupType,
                'ActivityType'             => $ActivityType,
                'ActivityGrTypeName'             => $ActivityGroupTypeName,
                'ActivityTypeName'             => $ActivityTypeName,
//                'SubActivityType'          => $SubActivityType,
                'ActivityIncMask'          => $ActivityIncMask,
                'DurationInMin'             => $DurationDays,
                'DurationStr'              => $DurationMin,                             
                'MinPax'                   => $MinPax,
                'MaxPax'                   => $MaxPax,
                '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,
                '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 ($ActivitySysId == "" || $ActivitySysId == 0) {
                $insert['AgentSysId'] = $AgentSysId;
            }
            //end
            
            // start : for image upload
            $imagename = '';
           if (!empty($_FILES['activitiesIcon']['name'])) {
              
                $orignalFileName = $_FILES['activitiesIcon']['name'];
                $strFileName = $this->_helper->General->toTitle($ActivityName);
                $fileExt = $this->_helper->General->getFileExtension($orignalFileName);
                $fileName =  $this->intLoggedinUserAgencySysId.'_' . time() . '.' . $fileExt;
                $originalFolder = $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/" . $CitySysId . "/activities";

                /* Create directory if not exists */
                if (!file_exists($originalFolder)) {
                    @mkdir($originalFolder, 0777, true);
                }

                $upload = new Zend_File_Transfer_Adapter_Http();
                $upload->setDestination("public/upload/city/" . $CitySysId . "/activities/");
                $upload->addFilter('Rename', "public/upload/city/" . $CitySysId . "/activities/" . $fileName);
                $file = $upload->getFileName();

                $upload->receive(); // get physical file into folder
                //Remove file
                if (!empty($arrActivitiesDetails)) {
                    $Icon = trim($arrActivitiesDetails['Icon']);
                    if ($Icon != "No File" && $Icon != "") {
//                        unlink($originalFolder.$Icon);
                    }
                }
                $imagename = $this->siteUrl."public/upload/city/" . $CitySysId . "/activities/".$fileName;
                
               $insert['Icon'] = $imagename; 
               $insert['ThumnailImg'] = $imagename; 
               $insert['DetailImg'] = $imagename; 
               
            }
            // end : for image upload
            
//            echo "<pre>";
//            print_r($insert);
//            exit;

            try {
                
                if($ActivitySysId!="" && $ActivitySysId!=0)
                {
                  $objActivities->updateActivitiesDetails($ActivitySysId, $insert);
                  
                  if($params['ptype'] == 'FlexiReadymade'){
                      $secureCode = Catabatic_ValidateCustomer::secureCode($params['package'],0);
                   $this->_helper->redirector('view-flexi-final-package-readymade','package','default',array('id'=>$params['package'],'code'=>$secureCode)); 
                  } else if($params['ptype'] == 'FlexiDynamic'){
                      $this->_redirect('/package/pkgviewnew/id/' . base64_encode($params['package']).base64_decode($params['params']));
//                      $this->_helper->redirector('pkgviewnew','package','default',array('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("Activities saved successfully.");
	          $this->_helper->redirector('manage-activities', 'activities', 'default');
                  }
                } else {
                  $activityId = $objActivities->addActivitiesDetails($insert); 
                  if($post['IsApproved'] == 1 && isset($params['ptype'])){
                    $objPackage = new Travel_Model_TblPackage();
                    $where = array('VersionId = ? ' => $params['version']);
                    $updateData = array('TPActivitySysId'=>$activityId);
                    $table = ($params['ptype'] == 'Quick') ? 'TB_Agency_Customer_TravelPlan_Itenary_Events' : 'TB_TravelPlan_Itenary_Events';
                    $objPackage -> actSightUpdateStatus($table,$updateData,$where);
                    }
                    if ($params['ptype'] == 'FlexiReadymade') {
                          $secureCode = Catabatic_ValidateCustomer::secureCode($params['package'],0);
                   $this->_helper->redirector('view-flexi-final-package-readymade','package','default',array('id'=>$params['package'],'code'=>$secureCode)); 
                       // $this->_helper->redirector('view-flexi-final-package-readymade', 'package', 'default', array('id' => $params['package']));
                    } else if ($params['ptype'] == 'FlexiDynamic') {
                        $objPackage -> actSightRateUpdateStatus('TB_MP_Inventory_Activity',$activityId,$params['id']);// function to add rates for new activity
                        $this->_redirect('/package/pkgviewnew/id/' . base64_encode($params['package']).base64_decode($params['params']));
//                        $this->_helper->redirector('pkgviewnew', 'package', 'default', array('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("Activities saved successfully.");
                        $this->_helper->redirector('add-activities-inventory', 'activities', '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 getActivitiesAutoSearchAction() {
        
        $this->_helper->layout->disableLayout();
        if ($this->getRequest()->isXmlHttpRequest()) { 

            $strActivitiesName     = $this->getRequest()->getParam('term');
            $strcountryId     = $this->getRequest()->getParam('countryId');
            $strCitySysId     = $this->getRequest()->getParam('CitySysId');
            
            $AgentSysId = $this->intLoggedinUserAgencySysId;
            $objActivities = new Travel_Model_TblActivities();
            $rowset = $objActivities->getActivitiesList($AgentSysId, $strActivitiesName,$strcountryId,$strCitySysId);
            //echo "<pre>";print_r($result);die;
            
            if(!empty($rowset)){
            foreach($rowset as $row) {
                $internal = (($row['ICSourceSysId'] == $AgentSysId) && $row['IsAgentSpec'] == 1 ) ? ' (Internal)' : '';
                $title = $row['Title'].$internal;
                $response[] = array('ActivitySysId'=>$row['ActivitySysId'],'value' => $row['Title'], 'label' => $title);
                }
            } else {
                $response[] = array('ActivitySysId'=>0,'value' => 'Add New Activity' , 'label' => 'Add New Activity');   
            }
            
            echo $this->_helper->json($response);
            exit;
        }
    }
    
    public function addActivitiesAction() 
    {    
        $this->_helper->layout->disableLayout();
        
        //Get Country List 
        $objCountry = new Travel_Model_TblCountry();
        $this->view->arrCountryList = $objCountry->getCountryList();

        //Get Activities Group Type List 
        $objActivities = new Travel_Model_TblActivities();
        $this->view->arrActivitiesGroupTypeList = $objActivities->getAllActivityGroupTypeList();

        //Get Activities Type List 
        $this->view->arrActivitiesTypeList = $objActivities->getAllActivityTypeList();
        $objThings = new Cityprofiling_Model_TblCityprofiling();
        $this->view->arrThingsToCarryList=$objThings->getThingsToCarryList();
        //Get Difficulty Type List 
        $this->view->arrDifficultyTypeList = $objActivities->getAllDifficultyTypeList();
        
    }
    
    public function saveActivitiesInventoryAction() {
        
        $this->_helper->layout->disableLayout();
        $this->_helper->flashMessenger->addMessage("Activities Inventory saved successfully.");
	$this->_helper->redirector('index', 'activities', '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;
            $AgencySysId = $this->intLoggedinUserAgencySysId;
            $SupplierTypeSysId = $this->SupplierTypeSysId;
            $result = $objSupplier->getSupplierAutoSearchList($strSupplierName, $AgentId,'',$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'],'Activity');
            }
            //echo "<pre>"; print_r($post);
            
            $objActivities = new Travel_Model_TblActivities();
            $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';
            $activity_name                          = !empty($post['activity_name']) ? $post['activity_name'] : '';
            $activity_id                            = !empty($post['activity_id']) ? $post['activity_id'] : '0';
            $inclusions_id                          = !empty(@$post['inclusions_id']) ? @implode(",",@$post['inclusions_id']) : '';
            $transfers                              = !empty($post['transfers']) ? $post['transfers'] : '0';
            $from_date                              = !empty($post['activities_from_date']) ? $post['activities_from_date'] : '';
            $to_date                                = !empty($post['activities_to_date']) ? $post['activities_to_date'] : '';
            $currency_type                          = !empty($post['currency_type']) ? $post['currency_type'] : '';
            $adult_cost_natives                     = !empty($post['activities_adult_cost_natives']) ? $post['activities_adult_cost_natives'] : '0'; 
            $kids_cost_natives                      = !empty($post['activities_kids_cost_natives']) ? $post['activities_kids_cost_natives'] : '0';
            $adult_cost_foreigners                  = !empty($post['activities_adult_cost_foreigners']) ? $post['activities_adult_cost_foreigners'] : '0';
            $kids_cost_foreigners                   = !empty($post['activities_kids_cost_foreigners']) ? $post['activities_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($activity_id==0) {
                $response = array('success'=> false, 'msg' => 'Please enter activity 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'=>$activity_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'=>$adult_cost_natives,'TotalCostNativeChild'=>$kids_cost_natives,'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'
            );
            //echo "<pre>";print_r($insertData); die;

            $intLastInsertId = $objActivities->addActivitiesInventory($insertData);
            //$intLastInsertId = 1;

            $response = array('success'=>true,'intLastInsertId' => $intLastInsertId);
           
            echo json_encode($response);
            exit;
        }
         
    }
    
    
    public function viewActivitiesInventoryTableAction()
    {
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        
        //$this->view->headScript()->appendFile('/public/assets/css/style.css');
        //$this->view->headScript()->appendFile('/public/assets/css/bootstrap.min.css');
        
        $objActivities = new Travel_Model_TblActivities();
        $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
        $arrActivitiesInventoryList = $objActivities->getAllActivitiesInventoryList($intLoggedinUserAgencySysId);
        $this->view->arrActivitiesInventoryList = $arrActivitiesInventoryList;
//        echo "<pre>";
//        print_r($arrActivitiesInventoryList);
//        exit;
    }
    
    public function viewActivitiesInventoryTablebyactivityidAction()
    {
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        $ActivitySysId = $this->getRequest()->getParam('ActivitySysId');
        //$this->view->headScript()->appendFile('/public/assets/css/style.css');
        //$this->view->headScript()->appendFile('/public/assets/css/bootstrap.min.css');
        
        $objActivities = new Travel_Model_TblActivities();
        $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
        $arrActivitiesInventoryList = $objActivities->getAllActivitiesInventoryListByActivityId($ActivitySysId,$intLoggedinUserAgencySysId);
        $this->view->arrActivitiesInventoryList = $arrActivitiesInventoryList;

    }
    
    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;  
        $objActivities = new Travel_Model_TblActivities();
        $arrActivitiesInventoryList = $objActivities->getActivitiesInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
        //echo "<pre>";print_r($arrActivitiesInventoryList);die;
        
        if(empty($arrActivitiesInventoryList)) {
            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;  
        $objActivities = new Travel_Model_TblActivities();
        $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
        $arrActivitiesInventoryList = $objActivities->getActivitiesInventoryList($InvnItemSysId,$intLoggedinUserAgencySysId);
        //echo "<pre>";print_r($arrFlightInventoryList);die;
        $this->view->arrActivitiesInventoryList = $arrActivitiesInventoryList;
        
        if(count($arrActivitiesInventoryList) <> 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');
        
        $objActivities = new Travel_Model_TblActivities();
        $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
        $arrActivitiesInventoryList = $objActivities->getActivitiesInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
        //echo "<pre>";print_r($arrFlightInventoryList);die;
        
        if(count($arrActivitiesInventoryList) <> 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;
            
            $objActivities = new Travel_Model_TblActivities();
            $arrActivitiesInventoryList = $objActivities->getActivitiesInventoryList($InvnItemSysId, $intAgencySysId);
            //echo "<pre>";print_r($arrFlightInventoryList);die;
            if(count($arrActivitiesInventoryList) <> 1 ) {
                throw new Exception('There has been an error, Please try again later');
            }
            
            if($MarkupSetting == 'STANDARD') {
                
                $this->view->arrActivitiesInventoryList = $arrActivitiesInventoryList;
                $this->view->agencyDetails = $objAgency->getAgencyUserList($intAgencySysId);
                
                //For  Natives
                //echo $intAgencySysId; 
                $arrStandardMarkups = $objActivities->getStandardMarkupsActivities($intAgencySysId);
                //echo "<pre>"; print_r($arrStandardMarkups);die;
                $this->view->arrStandardNativesMarkups = $arrStandardMarkups;
                
                //For  Natives
                //$arrStandardForeignersMarkups = $objActivities->getStandardMarkupsActivities($intAgencySysId, $cost_markup='2');
                //echo "<pre>"; print_r($arrStandardForeignersMarkups);die;
                //$this->view->arrStandardForeignersMarkups = $arrStandardForeignersMarkups;
                
            } else if($MarkupSetting == 'CUSTOMIZE') {
                $this->view->arrActivitiesInventoryList = $arrActivitiesInventoryList;
                $this->view->agencyDetails = $objAgency->getAgencyUserList($intAgencySysId);
                
                //For Natives
                $this->view->arrActivitiesNativesAllocMarketPlaces = $objActivities->getActivitiesMarketPlacesByAgencySysId($InvnItemSysId,$intAgencySysId,$cost_markup='1');
                //For Foreigners
                $this->view->arrActivitiesForeignersAllocMarketPlaces = $objActivities->getActivitiesMarketPlacesByAgencySysId($InvnItemSysId,$intAgencySysId,$cost_markup='2');
                
                //For  Natives
                $arrCustomizedMarkups = $objActivities->getCustomizedMarkups($InvnItemSysId,$MPType='', $intAgencySysId, $cost_markup='1');
                //echo "<pre>"; print_r($arrCustomizedMarkups);die;
                $this->view->arrCustomizedNativesMarkups = $arrCustomizedMarkups;
                
                //For Foreigners
                $arrForeignersCustomizedMarkups = $objActivities->getCustomizedMarkups($InvnItemSysId,$MPType='', $intAgencySysId, $cost_markup='2');
                //echo "<pre>"; print_r($arrCustomizedMarkups);die;
                $this->view->arrForeignersCustomizedMarkups = $arrForeignersCustomizedMarkups;
                
            } else if($MarkupSetting == 'STANDARDPOLICIES') {
                $this->view->arrStandardMarkupsPolicies = $objActivities->getStandardMarkupsPolicies($InvnItemSysId);
            } else if($MarkupSetting == 'CUSTOMIZEPOLICIES') {
                $this->view->arrCustomizedMarkupPolicies = $objActivities->getCustomizedMarkupsPolicies($InvnItemSysId);
            } else if($MarkupSetting == 'GROUP') {
                $this->view->arrCustomizedGroupList = $objActivities->getActivitiesGroupList($InvnItemSysId);
            } 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');
            }
            
        } 
    }
    
    
    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 Activities Model
            $objActivities = new Travel_Model_TblActivities();
            //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']) ? $post['PaxCount'] : '0';
                $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';
                
                $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(empty($TotalCostNativeAdult)) {
                $response = array('success' => false, 'msg' => 'Please enter native adult cost.');
                echo json_encode($response);
                exit;
            }
            if($TotalCostNativeAdult<=0) {
                $response = array('success' => false, 'msg' => 'Please enter native adult cost should be greater than zero');
                echo json_encode($response);
                exit;
            }
            if(empty($TotalCostNativeChild)) {
                $response = array('success' => false, 'msg' => 'Please enter native kids cost.');
                echo json_encode($response);
                exit;
            }
            if($TotalCostNativeChild<=0) {
                $response = array('success' => false, 'msg' => 'Please enter native kids cost should be greater than zero');
                echo json_encode($response);
                exit;
            }
            if(empty($TotalCostForeignerAdult)) {
                $response = array('success' => false, 'msg' => 'Please enter foreigners adult cost.');
                echo json_encode($response);
                exit;
            }
            if($TotalCostForeignerAdult<=0) {
                $response = array('success' => false, 'msg' => 'Please enter foreigners adult cost should be greater than zero');
                echo json_encode($response);
                exit;
            }
            if(empty($TotalCostForeignerChild)) {
                $response = array('success' => false, 'msg' => 'Please enter foreigners kids cost.');
                echo json_encode($response);
                exit;
            }
            if($TotalCostForeignerChild<=0) {
                $response = array('success' => false, 'msg' => 'Please enter foreigners kids cost should be greater than zero');
                echo json_encode($response);
                exit;
            }
            
            /* Check if group settings already exists */
            $arrGroupPaxCountSettings = $objActivities->getActivitiesGroupList($InvnItemSysId, $PaxCount);
            if(!empty($arrGroupPaxCountSettings)) {
                $response = array('success' => false, 'msg' => 'Pax has been already added.');
                echo json_encode($response);
                exit;
            }

            $insert = 
            array(
                'InvnItemSysId'              => $InvnItemSysId,
                'PaxCount'                   => $PaxCount,
                'TotalCostNativeAdult'       => $TotalCostNativeAdult,
                'TotalCostNativeChild'       => $TotalCostNativeChild,
                'TotalCostForeignerChild'    => $TotalCostForeignerChild,       
                'TotalCostForeignerAdult'    => $TotalCostForeignerAdult,
                'TrxCurrency'                => $TrxCurrency,
                'SaleAmtNativeChild'         => $SaleAmtNativeChild,
                'SaleAmtNativeAdult'         => $SaleAmtNativeAdult,
                'SaleAmtForeignerChild'      => $SaleAmtForeignerChild,
                'SaleAmtForeignerAdult'      => $SaleAmtForeignerAdult,         
                'TCInfo'                     => $TCInfo,
                'TCDocPath'                  => $TCDocPath,
                'CreateDate'                 => $currentDate,
                'UpdateDate'                 => $currentDate,
                'IsApproved'                 => $IsApproved,
                'IsMarkForDelete'            => $IsMarkForDel,
                'IsActive'                   => $IsActive                       
            );
            
//            echo "<pre>";
//            print_r($insert);
//            exit;

            try {
                $objActivities->addGroupSettings($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 deleteCustomizedGroupSettingAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
         
        if($this->_request->isXmlHttpRequest()) {
            $InvnItemSysId  = $this->getRequest()->getParam('InvnItemSysId');
            $PaxVal         = $this->getRequest()->getParam('PaxVal');
            
            $objActivities = new Travel_Model_TblActivities();
            $objActivities->deleteCustomizedGroupSetting($InvnItemSysId, $PaxVal);
            
            $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
            $objActivities = new Travel_Model_TblActivities();
            //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 = $objActivities->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 {
                $objActivities->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
            $objActivities = new Travel_Model_TblActivities();
            //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 = $objActivities->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 {
                $objActivities->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');
            
            $objActivities = new Travel_Model_TblActivities();
            $objActivities->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
            $objActivities = new Travel_Model_TblActivities();
            //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;
            $arrActivitiesInventoryList = $objActivities->getActivitiesInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
            if(!empty($arrActivitiesInventoryList)) {
                
                $update = 
                array(     
                    'TCInfo'           => $MarPolicies                    
                );
                
                try {
                    $objActivities->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 updateActivitiesSaleAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
         
        if($this->_request->isXmlHttpRequest()) {
            $InvnItemSysId   = $this->getRequest()->getParam('InvnItemSysId');
            $actionValue     = $this->getRequest()->getParam('actionValue');
            
            $objActivities = new Travel_Model_TblActivities();
            $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
            $arrActivitiesInventoryList = $objActivities->getActivitiesInventoryList($InvnItemSysId, $intLoggedinUserAgencySysId);
            if(count($arrActivitiesInventoryList) <> 1 ) {
                throw new Exception('There has been an error, Please try again later');
            }
            
            $objActivities->updateActivitiesSaleInventory($InvnItemSysId, $actionValue, $intLoggedinUserAgencySysId);
            
            $response = array('success' => true);
            echo json_encode($response);
            exit;
        }
    }
    
    
    public function editActivitiesDetailsAction() 
    {    
        $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 {
                $objActivities = new Travel_Model_TblActivities();
                $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
                $objActivities->updateActivitiesInventoryDetails($update, $InvnItemSysId, $intLoggedinUserAgencySysId);
                
                $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 copyActivitiesDetailsAction() 
    {    
        $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 {
                $objActivities = new Travel_Model_TblActivities();
                $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
                $intNewInvnItemSysId = $objActivities->cloneMPInventoryActivities($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 getActivitiesInventoryDetailAction() {
        
        $this->_helper->layout->setLayout('newLayout');
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $InvnItemSysId  = $this->getRequest()->getParam('InvnItemSysId');
            
            $objActivities = new Travel_Model_TblActivities();
            $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
            $arrActivitiesInventoryDetails = $objActivities->getActivitiesInventoryDetailsList($InvnItemSysId, $intLoggedinUserAgencySysId);
            
            $FromDateTimeObj = (array) $arrActivitiesInventoryDetails['FromDate'];
            $from_date_time = date("d/m/Y",strtotime($FromDateTimeObj['date'])); 
            
            $ToDateTimeObj = (array) $arrActivitiesInventoryDetails['ToDate'];
            $to_date_time = date("d/m/Y",strtotime($ToDateTimeObj['date'])); 
            
            $arrActivitiesInventoryDetailsArr = array('FromDateFormat'=>$from_date_time,'ToDateFormat'=>$to_date_time);
            
            $arrActivitiesInventoryDetailsArrFinal = array();
            $arrActivitiesInventoryDetailsArrFinal = @array_merge($arrActivitiesInventoryDetails,$arrActivitiesInventoryDetailsArr);
            
            //echo "<pre>"; print_r($arrActivitiesInventoryDetailsArrFinal); die;
            echo json_encode($arrActivitiesInventoryDetailsArrFinal);
            exit;
        }
        
    }
    
   
    public function deleteActivitiesAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
         
        $InvnItemSysId   = base64_decode($this->getRequest()->getParam('id'));
          
        $objActivities = new Travel_Model_TblActivities();
        $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
        $arrActivitiesInventoryList = $objActivities->getActivitiesInventoryList($InvnItemSysId);
//        if(count($arrActivitiesInventoryList) <> 1 ) {
//            throw new Exception('There has been an error, Please try again later');
//        }

        $objActivities->deleteActivitiesInventory($InvnItemSysId, $intLoggedinUserAgencySysId);

        $this->_helper->flashMessenger->addMessage("Activities Inventory deleted successfully.");
        $this->_helper->redirector('index', 'activities', 'default');
    }
    
    
    public function viewDetailsAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        $InvnItemSysId   = $this->getRequest()->getParam('id');
        
        $objActivities = new Travel_Model_TblActivities();
        $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
        $arrActivitiesInventoryDetails = $objActivities->getInventoryDetails($InvnItemSysId, $intLoggedinUserAgencySysId);
        //echo "<pre>"; print_r($arrActivitiesInventoryDetails);die;
        $this->view->arrActivitiesInventoryDetails = $arrActivitiesInventoryDetails;
    }
    
    
    public function viewManageActivitiesDetailsAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        $ActivitySysId   = $this->getRequest()->getParam('id');
        
        $objActivities = new Travel_Model_TblActivities();
        if($this->intLoggedinUserRole!=1)
        {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }

        $this->view->arrActivitiesTypeList = $objActivities->getAllActivityTypeList();

        $arrActivitiesDetails = $objActivities->getManageActivitiesDetails($ActivitySysId, $intLoggedinUserId);
        $this->view->arrCategoryTypeList = $objActivities->getAllActivityGroupTypeList();
//        echo "<pre>"; print_r($arrActivitiesDetails);die;
        $this->view->arrActivitiesDetails = $arrActivitiesDetails;
    }
    
    public function viewEditActivitiesDetailsAction() {
        /* Disable Layout */
//        die("here");
        $this->_helper->layout->disableLayout();
                

        $ActivitySysId   = $this->getRequest()->getParam('id');
        //echo $InvnItemSysId; 
        if($this->intLoggedinUserRole!=1)
        {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        
        $objActivities = new Travel_Model_TblActivities();
        $arrActivitiesDetails = $objActivities->getManageActivitiesDetails($ActivitySysId, $intLoggedinUserId);
//        echo "<pre>"; print_r($arrActivitiesDetails);die;
        
        //Get Country List 
        $objCountry = new Travel_Model_TblCountry();
        $arrCountryList = $objCountry->getCountryList();
        //echo "<pre>"; print_r($arrCountryList);die;
        $this->view->arrCountryList =  $arrCountryList;
        //Get Things To Carry List 
        $objThings = new Cityprofiling_Model_TblCityprofiling();
        $this->view->arrThingsToCarryList=$objThings->getThingsToCarryList();
        
        //Get City List
        $objCity  = new Travel_Model_TblCity();
        $objCity->intContSysId = $arrActivitiesDetails['ContSysId'];
        $cityList = $objCity->getCityList();
        //echo "<pre>"; print_r($cityList);die;
        $this->view->cityList = $cityList;

        //Get Activities Group Type List 
        $this->view->arrActivitiesGroupTypeList = $objActivities->getAllActivityGroupTypeList();
//        echo "<pre>"; print_r($this->view->arrActivitiesGroupTypeList);
        //Get Activities Type List 
        $this->view->arrActivitiesTypeList = $objActivities->getAllActivityTypeList();
//echo "<pre>"; print_r($this->view->arrActivitiesTypeList);
        //Get Difficulty Type List 
        $this->view->arrDifficultyTypeList = $objActivities->getAllDifficultyTypeList();
        
        $this->view->arrActivitiesDetails = $arrActivitiesDetails;
        
        $season_month_arr  = unserialize(SEASON_MONTH);
        $seasonMonthMasking = $objActivities->getMasking($arrActivitiesDetails['PeakMothMask'], $season_month_arr);
        $this->view->seasonMonthMasking = $seasonMonthMasking;
        //echo "<pre>"; print_r($seasonMonthMasking);die;
        
        $season_day_arr  = unserialize(SEASON_DAYS);
        $seasonDaysMasking = $objActivities->getMasking($arrActivitiesDetails['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;
        
    }
    
    public function addThingsToCarryAction() {
        $this->_helper->layout->disableLayout();
        $data =  $this->_request->getParam('Data');
        $currentDate = date('Y-m-d H:i:s');
        if(isset($data)&&!empty($data)){
            $array=array(
                "PackType"=>0,
                "Description"=>trim($this->sanitize_data($data)),
                "CreateDate"=>$currentDate,
                "IsApproved"=>0,
                "IsMarkForDel"=>0,
                "IsActive"=>0,
                "AgencySysId"=>$this->intLoggedinUserAgencySysId,
                );
        $objThings = new Cityprofiling_Model_TblCityprofiling();
        $checkThingsToCarryPresent = $objThings->getThingsToCarryDetail('TB_Master_Geo_City_Packing',$data,$this->intLoggedinUserAgencySysId);

        if(isset($checkThingsToCarryPresent) && $checkThingsToCarryPresent!=0 ){
           $response = array('success' => false, 'msg' => 'Things To Carry Is Already Added Try Something New' );
            echo json_encode($response);
            exit; 
            
        }
        $thingsCarry = $objThings->insertTable('TB_Master_Geo_City_Packing',$array);
        if(isset($thingsCarry) && !empty($thingsCarry)){
            $response = array('success' => true, 'msg' => 'Added Succesfully' );
            echo json_encode($response);
            exit;
            
        }
        else{
            $response = array('success' => false, 'msg' => 'Some Error Occured' );
            echo json_encode($response);
            exit;
            
        }
        }
        
        else{
            $response = array('success' => false, 'msg' => 'Field Cannot be left blank' );
            echo json_encode($response);
            exit;  
            
        }
    }
    public function searchAction()
    {
        $objCity = new Travel_Model_TblCity();
        $objActivities = new Travel_Model_TblActivities();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        
        //Get Activities Type List 
        $this->view->arrActivitiesTypeList = $objActivities->getAllActivityTypeList();
        
        //Get City List    
        $CityList = $objCity->getCityList();
        //echo "<pre>"; print_r($CityList);  die;
        $this->view->cityList = $CityList;
               
    }
    
    
    public function searchResultAction()
    {
        $objCity = new Travel_Model_TblCity();
        $objActivities = new Travel_Model_TblActivities();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        
        //Get Activities Type List 
        $this->view->arrActivitiesTypeList = $objActivities->getAllActivityTypeList();
        
        //Get City List    
        $CityList = $objCity->getCityList();
        //echo "<pre>"; print_r($CityList);  die;
        $this->view->cityList = $CityList;
        
        if($this->getRequest()->isPost())
        {
            $getData = $this->getRequest()->getPost();
            if(!empty($getData))
            {
               $DestinationId = implode(",",@$getData['DestinationId']);
               $ActivitiesTypeId = implode(",",@$getData['ActivitiesTypeId']);
               $tour_date = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($getData['tour_date'],'d/m/y');
               $searchArr = array(
                                'DestinationId'=>$DestinationId,
                                'tour_date'=>$tour_date,
                                'no_of_pax'=>$getData['no_of_pax'],
                                'no_of_adults'=>$getData['no_of_adults'],
                                'no_of_children'=>$getData['no_of_children'],
                                'age_of_children'=>$getData['age_of_children'],
                                'ActivitiesTypeId'=>$ActivitiesTypeId,
               );
               $objActivities = new Travel_Model_TblActivities();
               $resultActivities = $objActivities->getAllActivitiesSearchList($intLoggedinUserAgencySysId,$searchArr);
               $this->view->resultActivities = $resultActivities;
               //echo "<pre>";print_r($searchArr);die;
            } else {
              echo "Test";die;  
            }
        }
        
    }
    
    
    public function searchDetailsAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        $InvnItemSysId   = $this->getRequest()->getParam('id');
        
        $objActivities = new Travel_Model_TblActivities();
        $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
        $arrActivitiesInventoryDetails = $objActivities->getInventoryDetails($InvnItemSysId, $intLoggedinUserAgencySysId);
        //echo "<pre>"; print_r($arrActivitiesInventoryDetails);die;
        $this->view->arrActivitiesInventoryDetails = $arrActivitiesInventoryDetails;
    }
    
    
    public function deactivateAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objActivities   = new Travel_Model_TblActivities();
        $ActivitySysId = $this->getRequest()->getParam('id'); 
        $statusValue = '0';
        if($this->intLoggedinUserRole!=1)
        {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        
        $isDeactive = $objActivities->setActiveDeactive($ActivitySysId, $statusValue); 
        $message    = @$isDeactive ? "Activity deactivated successfully." : "Activity deactivation failed.";
        $this->_helper->flashMessenger->addMessage($message);
        $this->_helper->redirector('manage-activities', 'activities', 'default');
    }
    
    public function activateAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objActivities   = new Travel_Model_TblActivities();
        $ActivitySysId = $this->getRequest()->getParam('id'); 
        $statusValue = '1';
        if($this->intLoggedinUserRole!=1)
        {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        
        $isActive   = $objActivities->setActiveDeactive($ActivitySysId, $statusValue);          
        $message    = @$isActive ? "Activity activated successfully." : "Activity activation failed."; 
        $this->_helper->flashMessenger->addMessage($message);
        $this->_helper->redirector('manage-activities', 'activities', 'default');
    }
    
    
    public function deactivateInventoryAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objActivities   = new Travel_Model_TblActivities();
        $InvnItemSysId = $this->getRequest()->getParam('id'); 
        $statusValue = '0';
        $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
        
        $isDeactive = $objActivities->setActiveDeactiveInventory($InvnItemSysId, $intLoggedinUserAgencySysId, $statusValue); 
        $message    = @$isDeactive ? "Activity inventory deactivated successfully." : "Activity inventory deactivation failed.";
        $this->_helper->flashMessenger->addMessage($message);
        $this->_helper->redirector('index', 'activities', 'default');
    }
    
    public function activateInventoryAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objActivities   = new Travel_Model_TblActivities();
        $InvnItemSysId = $this->getRequest()->getParam('id'); 
        $statusValue = '1';
        $intLoggedinUserAgencySysId            = $this->intLoggedinUserAgencySysId;
        
        $isActive   = $objActivities->setActiveDeactiveInventory($InvnItemSysId, $intLoggedinUserAgencySysId, $statusValue);          
        $message    = @$isActive ? "Activity inventory activated successfully." : "Activity inventory activation failed."; 
        $this->_helper->flashMessenger->addMessage($message);
        $this->_helper->redirector('index', 'activities', 'default');
    }
    
    public function getSearchSupplierActivitiesAction() {
        
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $cityId    = $this->getRequest()->getParam('cityId');
                      
            if($cityId!="" && $cityId!="0")
            {
                $searchSupplierSelect = '';
                $objActivities   = new Travel_Model_TblActivities();
                $intSearchSupplierList = $objActivities->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 getActivitiesTypeListAction() {
        
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $ActivitiesGrTypeId    = $this->getRequest()->getParam('ActivitiesGrTypeId');
            $ActivitiesGrType    = $this->getRequest()->getParam('ActivitiesGrType');
            $Mode    = $this->getRequest()->getParam('Mode');
            
            if($ActivitiesGrType=="page" && $Mode=="add")  
            {
              $nameId = "ActivityTypeId";  
            } else if($ActivitiesGrType=="popup" && $Mode=="add")  {
              $nameId = "popupActivityType";    
            } else if($ActivitiesGrType=="popup" && $Mode=="edit")  {
              $nameId = "ActivityTypeId";    
            }
            
            if($ActivitiesGrTypeId!="" && $ActivitiesGrTypeId!="0")
            {
                $activitiesSelect = '';
                $objActivities   = new Travel_Model_TblActivities();
                $intActivitiesTypeList = $objActivities->getActivitiesTypeListByActivitiesGroupId($ActivitiesGrTypeId);
                if(!empty($intActivitiesTypeList))
                {
                    $activitiesSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script>';
                    $activitiesSelect .= '<select id="'.$nameId.'" name="ActivityType[]" multiple class="demo-default select-ajax-country" placeholder="Select Activity Type"><option value="0">Select Activity Type</option>'; 
                    foreach($intActivitiesTypeList as $intActivitiesType)
                    { 
                        $activitiesSelect .= '<option value="'.$intActivitiesType['ActivityType'].'">'.$intActivitiesType['Title'].'</option>'; 
                    }
                    $activitiesSelect .= '</select>';
                } else {
                    $activitiesSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script><select id="ActivityType" name="ActivityType" class="demo-default select-ajax-country" placeholder="Select Activity Type"><option value="0">Select Activity Type</option></select>'; 
                }
            } else {
                   $activitiesSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script><select id="ActivityType" name="ActivityType" class="demo-default select-ajax-country" placeholder="Select Activity Type"><option value="0">Select Activity Type</option></select>'; 
            }
            
            echo $activitiesSelect;
            exit;
        }
        
    }
    
    
    /**
     * Disapprove Hotel Action. 
     */
    public function disapprovedAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objActivities   = new Travel_Model_TblActivities();
        $ActivitySysId = base64_decode($this->getRequest()->getParam('id')); 
        $approveDate = date('Y-m-d H:i:s');
        
        $updateArr = array('ApproveDate' =>$approveDate, 'ApproveBy' =>$this->intLoggedinUserId, 'IsApproved' =>'0');
        
        $isDisapprove = $objActivities->setApproveDisapprove(" ActivitySysId=$ActivitySysId", "TB_IC_Activity", $updateArr);             
        $message    = @$isDisapprove ? "Activity disapproved successfully." : "Activity disapproved failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        if(@$isDisapprove)
        {
            if($this->intLoggedinUserRole==1)
            {
              $this->_helper->redirector('manage-activities', 'activities', 'default');
            } 
        }
    }
    
    
    /**
     * Approve Hotel Action. 
     */
    public function approvedAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objActivities   = new Travel_Model_TblActivities();
        $ActivitySysId = base64_decode($this->getRequest()->getParam('id')); 
        $approveDate = date('Y-m-d H:i:s');
        
        $updateArr = array('ApproveDate' =>$approveDate, 'ApproveBy' =>$this->intLoggedinUserId, 'IsApproved' =>'1');
        
        $isApprove = $objActivities->setApproveDisapprove(" ActivitySysId=$ActivitySysId", "TB_IC_Activity", $updateArr);             
        $message    = @$isApprove ? "Activity approved successfully." : "Activity approved failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        if(@$isApprove)
        {
            if($this->intLoggedinUserRole==1)
            {
              $this->_helper->redirector('manage-activities', 'activities', 'default');
            } 
        }
    }
    
    
    /**
     * Stop Sale Hotel Action. 
     */
    public function stopSaleAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objActivities   = new Travel_Model_TblActivities();
        $InvnItemSysId = base64_decode($this->getRequest()->getParam('id')); 
        
        $isDeactive = $objActivities->setSaleStartStop(" InvnItemSysId=$InvnItemSysId", "TB_MP_Inventory_Activity",0);             
        $message    = @$isDeactive ? "Activities inventory sale stop successfully." : "Activities inventory sale stop failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        if(@$isDeactive)
        {
            $this->_helper->redirector('index', 'activities', 'default');
        }
    }
    
    
    /**
     * Start Sale Hotel Action. 
     */
    public function startSaleAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objActivities   = new Travel_Model_TblActivities();
        $InvnItemSysId = base64_decode($this->getRequest()->getParam('id')); 
        
        $isActive = $objActivities->setSaleStartStop(" InvnItemSysId=$InvnItemSysId", "TB_MP_Inventory_Activity",1);       
        $message    = @$isActive ? "Activities inventory sale start successfully." : "Activities inventory sale start failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        
        if(@$isActive)
        {
            $this->_helper->redirector('index', 'activities', 'default');
        }
    }
    
    
    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++)
                {
                    if($OperatingTimeCounter<$srt)
                    {
                        if($OperatingTimeCounter==0)
                        {
                           $div_str = '<script src="/public/assets/js/pages/pickerTool.js"></script><div class="remove_field_div" id="opt_time_remove_2"><div class="col-md-12"><div class="form-group1"><label class="col-md-12 no-padding">Operating Time</label><div class="col-md-12 no-padding"><div class="col-md-2 col-sm-2 col-xs-2 no-padding" style="line-height:34px;">From</div><div class="col-md-3 col-sm-3 col-xs-3"><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 text-right" style="line-height:34px">To</div><div class="col-md-3 col-sm-3 col-xs-3"><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 no-padding"><a type="button" data-original-title="Delete" onclick="deleteOpTimeDiv(2);" id="delete_operating_time" class="view-text1 tooltipLink" data-toggle="tooltip" data-placement="top" title=""><i class="fa fa-minus-circle"></i></a></div></div></div></div></div>'; 
                        } 
                        else if($OperatingTimeCounter==1)
                        {
                           $div_str = '<script src="/public/assets/js/pages/pickerTool.js"></script><div class="remove_field_div" id="opt_time_remove_3"><div class="col-md-12"><div class="form-group1"><label class="col-md-12 no-padding">Operating Time</label><div class="col-md-12 no-padding"><div class="col-md-2 col-sm-2 col-xs-2 no-padding" style="line-height:34px;">From</div><div class="col-md-3 col-sm-3 col-xs-3"><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 text-right" style="line-height:34px">To</div><div class="col-md-3 col-sm-3 col-xs-3"><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 no-padding"><a type="button" data-original-title="Delete" onclick="deleteOpTimeDiv(3);" id="delete_operating_time" class="view-text1 tooltipLink" data-toggle="tooltip" data-placement="top" title=""><i class="fa fa-minus-circle"></i></a></div></div></div></div></div>'; 
                        }
                    }
                }
            } 
            else if($max_fields=1 && $OperatingTimeCounter==1)
            {
               $div_str = '<script src="/public/assets/js/pages/pickerTool.js"></script><div class="remove_field_div" id="opt_time_remove_3"><div class="col-md-4"><div class="form-group"><label class="col-md-12 no-padding">Operating Time</label><div class="col-md-12 no-padding"><div class="col-md-2 col-sm-2 col-xs-2 no-padding" style="line-height:34px;">From</div><div class="col-md-3 col-sm-3 col-xs-3"><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 text-right" style="line-height:34px">To</div><div class="col-md-3 col-sm-3 col-xs-3"><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 no-padding"><a type="button" data-original-title="Delete" onclick="deleteOpTimeDiv(3);" id="delete_operating_time" class="view-text1 tooltipLink" data-toggle="tooltip" data-placement="top" title=""><i class="fa fa-minus-circle"></i></a></div></div></div></div></div>'; 
            } 
            
            echo $div_str;
            exit;
        }
        
    }
    
    
    
    // Added By Pardeep Panchal
    
    
    
    public function displayOnB2cAction() {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $objActivities = new Travel_Model_TblActivities();
        $ActivitySysId = trim($this->getRequest()->getParam('id'));
        $statusValue = trim($this->getRequest()->getParam('status'));
        if ($this->intLoggedinUserRole != 1) {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        $sessionLogin_user_url = new Zend_Session_Namespace('sessionLogin_user');
        if (trim($sessionLogin_user_url->agencyDetails['IsB2CSite']) == 1) {
            
           $getXrefId= $objActivities->getXrefNumberForActivity($ActivitySysId);
           $ItemSourceType = $getXrefId['XRef'];
            
            
                $this->postFields = "";
                $this->postFields .= "&AgencySysId=" . Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
                $this->postFields .= "&packageId=$ItemSourceType";
                $this->postFields .= "&URL=" . trim($sessionLogin_user_url->agencyDetails['Url']);
                $writeLogObj = new Payment_Model_Payment();
                $writeLogObj->writeLog($this->postFields . "\n");
                $url = Catabatic_Helper::getSiteUrl() . "gtxwebservices/push-package/activity";
                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);
                    $writeLogObj->writeLog($output . "\n");
                    curl_close($ch);
                    $isDeactive = $objActivities->displayOnB2C($ActivitySysId, $statusValue); 
                    $status = ($statusValue == 1) ? 'activate' : 'deactivate';
                    if($isDeactive){
                        $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;
                    }
                    //$message = @$isDeactive ? "Activity status changed successfully." : "Oops! Action failed.";
                    //$this->_helper->flashMessenger->addMessage($message);
                    //$this->_helper->redirector('index', 'activities', 'default');
                } catch (Zend_Exception $ex) {
                  echo   $ex->getMessage(); exit;
                }
            }
    }
	//for booked package list
	 public function activityBookingListAction() {
	
			$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
			$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
			$this->view->msg = !empty($arrUrlData['msg']) ? $arrUrlData['msg'] : '';
			$this->view->TPSysIdReq = !empty($arrUrlData['TPSysId']) ? $arrUrlData['TPSysId'] : 0;
	
	
			$objPackageViewList = new Travel_Model_TblAgencyCustomerTrx();
			if ($this->getRequest()->isPost()) {
				$this->_HtmlPurifier = new Zend_Filter_HtmlPurifier();
				$getData = $this->getRequest()->getPost();
				// $getData=$this->sanitizeData($getData);
				$getData = $this->_HtmlPurifier->filterArray($getData);
				$this->view->searchData = $getData;
				$customerBookingRecord = $objPackageViewList->getBookedActivityDetail($this->intLoggedinUserAgencySysId, $getData);
			} else {
				$getData = array();
				$customerBookingRecord = $objPackageViewList->getBookedActivityDetail($this->intLoggedinUserAgencySysId);
			}
	
			$page = $this->_getParam('page', 1);
			$paginator = Zend_Paginator::factory($customerBookingRecord);
			$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
			$paginator->setCurrentPageNumber($page);
			$this->view->paginator = $paginator;
			$this->view->page = $page;
		}    
    

}

Youez - 2016 - github.com/yon3zu
LinuXploit