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/admin/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2bzend/application/admin/controllers/HotelController.php
<?php
/**
 * Class Hotel
 *
 * @name		Hotel
 * @author		Ravi Khare
 * @version 	1.0
 * @copyright 	Catabatic India Pvt Ltd
 * Handle Hotel Related function
 *
*/

class Admin_HotelController extends Catabatic_ValidateAdmin
{   
    private $intLoggedinUserId = '';
    
    const ADMIN_ID = 1;
    
    private $intLoggedinUserGroupSysId = '0';
    
    private $intLoggedinUserAgencySysId = '0';
    
    private $intLoggedinUserTrxCurrency = '0';
    
    public $baseUrl = '';
    
    /* Tripsbank Staff */
    public $InfoSourceSysId = '0';
    
    public function init() {
        parent::init();
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
        
        
        $this->view->headScript()->appendFile($this->baseUrl . '/public/js/hotel/hotel.js');
        $this->view->headScript()->appendFile($this->baseUrl . '/public/assets/js/jquery-ui.js');
        $this->view->headLink()->appendStylesheet($this->baseUrl.'/public/assets/css/autosuggest-jquery-ui.css');
        
        
        $sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
        $sessionLogin_user->lock();
        
        #get session variable
        $this->SupplierTypeSysId = 4;
        $this->intLoggedinUserRole          = $sessionLogin_user->UserRole;
        $this->intLoggedinUserId            = 1;
        $this->intLoggedinUserGroupSysId    = $sessionLogin_user->intLoggedinUserGroupSysId;
        $this->intLoggedinUserAgencySysId   = $sessionLogin_user->intLoggedinUserAgencySysId;
        $this->intLoggedinUserTrxCurrency   = $sessionLogin_user->intLoggedinUserTrxCurrency;
         
        if(!empty($this->intLoggedinUserAgencySysId)) {
            $this->InfoSourceSysId = '2'; /* Information Source is Agent */
        }
        
        // unlocking read-only lock
        if ($sessionLogin_user->isLocked()) {
            $sessionLogin_user->unLock();
        }
        
       
    }
    
    
    public function viewHotelInventoryAction() {
        
        $AccomSysId = $this->getRequest()->getParam('AccomSysId');
        $key = $this->getRequest()->getParam('key');
        
        if(empty($AccomSysId)) {
            throw new Exception('Accomodation Id not found.');
        }
        
        $this->view->AccomSysId = $AccomSysId;
        $this->view->key = $key;
        $this->view->PageTitle = " View / Edit Hotel Inventory ";
        $this->render('add-hotel-inventory');
    }
    
    

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

            $intHotelId     = $this->getRequest()->getParam('intHotelId');
            
            $objHotel = new Travel_Model_TblHotel();
            $objHotel->intId  = $intHotelId;
            $result = $objHotel->getHotelListDetails();
            
            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 indexAction()
    {
        $this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        
        $objHotel = new Travel_Model_TblHotel();
        $objAgency = new Travel_Model_TblAgency();
        
        $agencyDetails = $objAgency->getAgencyUserList($this->intLoggedinUserAgencySysId);
        $this->view->agencyDetails = $agencyDetails;
        //echo "<pre>"; print_r($agencyDetails); die;
        
        //Get City List
        $cityList = $objHotel->getInventoryCityList($this->intLoggedinUserAgencySysId);
        $this->view->cityList = $cityList;
        
        //Get Supplier List
        $supplierList = $objHotel->getSuppliersList($cityId='', $this->intLoggedinUserId);
        $this->view->supplierList = $supplierList;
        
        //Get inventory hotel list
        $inventoryHotelList = $objHotel->getHotelInventoryListByCityId($cityId='', $this->intLoggedinUserAgencySysId);
        $this->view->inventoryHotelList = $inventoryHotelList;
        
        //Get total rooms
        //$total_rooms = $objHotel->getTotalRooms($this->intLoggedinUserAgencySysId);
        //$this->view->total_rooms = $total_rooms;
        
        //Get Total inventory Room
        $total_inventory_rooms = $objHotel->getTotalInventoryRooms($this->intLoggedinUserAgencySysId);
        $this->view->total_inventory_rooms = $total_inventory_rooms; 
        
        //Get Sold Total inventory Room
        //$total_sold_rooms = $objHotel->getSoldTotalInventoryRooms($this->intLoggedinUserAgencySysId);
        //$this->view->total_sold_rooms = $total_sold_rooms;
        
        $total_cost = $objHotel->getHotelInventoryTotalCost($this->intLoggedinUserAgencySysId);
        $this->view->total_inventory_cost = $total_cost;
        //echo $total_cost; 
        
        $total_sold_cost = $objHotel->getHotelInventoryTotalSoldCost($this->intLoggedinUserAgencySysId);
        $this->view->total_inventory_sold_cost = $total_sold_cost;
        
        //Get total unsold inventory room
        $total_unsold_inventory_rooms = $total_inventory_rooms['total_inventory'] - $total_inventory_rooms['total_sold_inventory'];
        $this->view->total_unsold_inventory_rooms = $total_unsold_inventory_rooms;
        
        $total_unsold_inventory_cost = $total_cost - $total_sold_cost;
        $this->view->total_unsold_inventory_cost = $total_unsold_inventory_cost;
       
//        if(@$this->intLoggedinUserId != ADMIN_ID)
//        {
//            $objHotel->strCondition = " AND ICSourceSysId = " .$this->intLoggedinUserAgencySysId;
//        }
        
        $searchArr = array();
        $getData = array();
        if($this->getRequest()->isPost())
        {
            $getData = $this->getRequest()->getPost();
            if(!empty($getData))
            {
                if(@$getData['DestinationId']!=0)
                {
                    $DestinationId = @$getData['DestinationId'];
                } else {
                    $DestinationId = "";
                }
                if(@$getData['hotelId']!=0)
                {
                    $hotelId = $getData['hotelId'];
                } else {
                    $hotelId = "";
                }
                if(@$getData['supplierId']!=0)
                {
                    $supplierId = $getData['supplierId'];
                } else {
                    $supplierId = "";
                }
                if(@$getData['rating']!=0)
                {
                    $rating = $getData['rating'];
                } else {
                    $rating = "";
                }
                $searchArr = array(
                            'DestinationId'=>$DestinationId,
                            'hotelId'=>$hotelId,
                            'supplierId'=>$supplierId,
                            'rating'=>$rating
               );
            } 
        } else {
            $DestinationId = $this->_getParam('DestinationId');
            $hotelId = $this->_getParam('hotelId');
            $supplierId = $this->_getParam('supplierId');
            $rating = $this->_getParam('rating');
            if($DestinationId!=0)
            {
                $DestinationId = $DestinationId;
            } else {
                $DestinationId = "";
            }
            if($hotelId!=0)
            {
                $hotelId = $hotelId;
            } else {
                $hotelId = "";
            }
            if($supplierId!=0)
            {
                $supplierId = $supplierId;
            } else {
                $supplierId = "";
            }
            if($rating!=0)
            {
                $rating = $rating;
            } else {
                $rating = "";
            }
            $searchArr = array(
                        'DestinationId'=>$DestinationId,
                        'hotelId'=>$hotelId,
                        'supplierId'=>$supplierId,
                        'rating'=>$rating
            );
        }
        
        //echo "<pre>"; print_r($searchArr); 
        $objHotel->searchArr = $searchArr;
        $this->view->searchArr = $searchArr;
        $arrHotels =  $objHotel->getHotelAllInventoryList($this->intLoggedinUserAgencySysId);
//        echo "<pre>";
//        print_r($arrHotels);
//        exit;
                                        
        $page=$this->_getParam('page',1);
        //$search=$this->_getParam('search',1);
        $paginator = Zend_Paginator::factory($arrHotels);
        $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
        $paginator->setCurrentPageNumber($page);

        $this->view->paginator = $paginator;
        
        //For display message
        $this->view->messages = $this->_helper->flashMessenger->getMessages();
    }
    
    
    public function manageHotelAction() {
                
        $objHotel = new Travel_Model_TblHotel();
        
        //Agency Id
        if($this->intLoggedinUserRole!=1)
        {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        
        $this->view->intLoggedinUserIdSetPage = $intLoggedinUserId;
        
                               
        $searchArr = array();
        $getData = array();
        if($this->getRequest()->isPost())
        {
            $this->view->arrGetData = $getData = $this->getRequest()->getPost();
            $this->view->cityName = $cityName = $getData['city_name'];
            $this->view->DestinationId  = $DestinationId = $getData['DestinationId'];
            $this->view->HotelName      = $HotelName = $getData['HotelName'];
            $this->view->Status         = $Status = $getData['status'];
            $this->view->ratingArray    = !empty($getData['rating'])?$getData['rating']:'';
            if(isset($getData['rating']) && count($getData['rating']) > 0){
                $Rating = "'".implode("','", $getData['rating'])."'";
                $this->view->Rating = $Rating;
            }else{
                $Rating = "";
                $this->view->Rating = $Rating;
            }
            
            //echo $Rating;exit;
            
            if (!empty($getData)) {
                if (!empty($DestinationId)) {
                    $DestinationId = $DestinationId;
                } else {
                    $DestinationId = "";
                }
                if (!empty($HotelName)) {
                    $HotelName = $HotelName;
                } else {
                    $HotelName = "";
                }
                if ($Rating !="") {
                    $rating = $Rating;
                } else {
                    $rating = "";
                }
                $searchArr = array(
                    'DestinationId' => $DestinationId,
                    'HotelName' => $HotelName,
                    'rating' => $rating,
                    'IsActive' => $Status
                );
            } 
        } else {
            $DestinationId = $this->_getParam('DestinationId');
            $HotelName = $this->_getParam('HotelName');
            $rating = $this->_getParam('rating');
            if ($DestinationId != 0) {
                $DestinationId = $DestinationId;
            } else {
                $DestinationId = "";
            }
            if ($HotelName != "") {
                $HotelName = $HotelName;
            } else {
                $HotelName = "";
            }
            if ($rating != 0) {
                $rating = $rating;
            } else {
                $rating = "";
            }
            $searchArr = array(
                'DestinationId' => $DestinationId,
                'HotelName' => $HotelName,
                'rating' => $rating,
                'IsActive' => ''
            );
        }
        
        //echo "<pre>"; print_r($searchArr); 
        $objHotel->searchArr = $searchArr;
        $this->view->searchArr = $searchArr;
        $arrHotels =  $objHotel->getAllHotelListAdmin();
       // echo $arrHotels;exit;
        $page=$this->_getParam('page',1);
        $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($arrHotels));
        //$paginator = Zend_Paginator::factory($arrHotels);
        $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
        $paginator->setCurrentPageNumber($page);

        $this->view->paginator = $paginator;
        
        //For display message
        $this->view->messages = $this->_helper->flashMessenger->getMessages();
    }
    
    public function addNewAction() {
        
        $this->_helper->layout->disableLayout();
        
        if ($this->getRequest()->isXmlHttpRequest()) { 
            
            $post = $this->getRequest()->getPost();
            
//            echo "<pre>";
//            print_r($post);
//            exit;
            
            
            $hotelName       = $post['popup_hotel_name'];
            $intCountryId    = $post['hotel-country'];
            $intCityId       = $post['hotel-city'];
            $address         = $post['hotel-address'];
            
            if(empty($intCountryId)) {
                $response = array('succes' => false, 'msg' => 'Please select country.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($intCityId)) {
                $response = array('succes' => false, 'msg' => 'Please select a City.');
                echo json_encode($response);
                exit;
            }
            
            
            if(empty($hotelName)) {
                $response = array('succes' => false, 'msg' => 'Please enter hotel name.');
                echo json_encode($response);
                exit;
            }
            
            $intHotelType = isset($post['hotel-type']) ? $post['hotel-type'] : 0;
                    
            if(empty($intHotelType)) {
                $response = array('succes' => false, 'msg' => 'Please select accomodation type.');
                echo json_encode($response);
                exit;
            }

            if(!isset($post['hotel-room-types']) || count($post['hotel-room-types']) == 0 ) {
                $response = array('succes' => false, 'msg' => 'Please select atleast one room type.');
                echo json_encode($response);
                exit;
            }
            
           
            $currentDate   = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $this->InfoSourceSysId = (@$this->intLoggedinUserId != ADMIN_ID) ? $this->intLoggedinUserAgencySysId : CONST_SOURCE_ADMIN;
            
            $newAccomodation = array('IsAgentSpec'   => true, 
                         'ICSourceSysId'             => $this->intLoggedinUserAgencySysId, 
                         'Title'                     => $hotelName,
                         'AccomGrSysId'              => '0',
                         'AliasAndMeta'              => '',
                         'ShortName'                 => '',
                         'PlaceSysId_XRef'           => '0',
                         'Icon'                      => '',
                         'ThumnailImg'               => '',
                         'DetailImg'                 => '',
                         'Stars'                     => isset($post['star-rating']) && !empty($post['star-rating']) ? $post['star-rating'] : '0',
                         'Rating'                    => '0',
                         'Popularity'                => '0',
                         'AwardRecognizations'       => '',
                         'PropertyType'              => '0',
                         'EconomyType'               => $intHotelType,
                         'AccoAminitiesMask'         => '',
                         'MaxPaxCount'               => '0',
                         'RoomCounts'                => '0',
                         'Brief'                     => '',
                         'CheckinTime'               => '',
                         'CheckOutTime'              => '',
                         'IsDayLightApp'             => '',
                         'GeoLat'                    => '',
                         'GeoLong'                   => '',
                         'Address'                   => $address,
                         'PinCode'                   => isset($post['pinCode']) ? $post['pinCode'] : '',
                         'CitySysId'                 => $intCityId,
                         'ZoneSysId'                 => '0',
                         'ZoneType'                  => '0',
                         'StateSysId'                => '0',
                         'ContSysId'                 => $intCountryId,
                         'UpdateDate'                => $currentDate,
                         'ApproveDate'               => '',
                         'ApproveBy'                 => '0',
                         'CreateDate'                => $currentDate,
                         'IsLocked'                  => '1',
                         'IsApproved'                => '0',
                         'IsActive'                  => '1',
                         'IsMarkForDel'              => '0'
                    );
            
//            echo "<pre>";
//            print_r($newAccomodation);
//            exit;
            
                try {
            
                    $objHotel = new Travel_Model_TblHotel();
                    $intLastInsertId = $objHotel->addAccomodation($newAccomodation, $hotel_chain='1');
                    $AccomSysId = $intLastInsertId ;

                    if(!empty($AccomSysId)) {
                        /*Add Rooms */
                        if(isset($post['hotel-room-types']) && count($post['hotel-room-types']) > 0 )
                        {
                            foreach($post['hotel-room-types'] as $roomType) {

                                $insert = array(
                                        'AccomSysId'       => $AccomSysId,
                                        'SourceSysId'       => $this->intLoggedinUserAgencySysId,
                                        'Title'             => '',
                                        'RoomType'          => $roomType,
                                        'EconomyType'       => 0,
                                        'Qty'               => 0,
                                        'BedType'           => 0,
                                        'PaxCount'          => 0,
                                        'IsPetAllow'        => 0,
                                        'MaxPetAllow'       => 0,
                                        'AllowChild'        => 0,
                                        'AllowInfant'       => 0,
                                        'MaxPaxCount'       => 0,
                                        'MaxAllowChild'     => 0,
                                        'MaxAllowInfant'    => 0,
                                        'MealPlanType'      => 0,
                                        'AminitiesMask'     => '',
                                        'InclustionOptionsMask' => '',
                                        'OtherDetails'      => '',
                                        'UpdatedDate'       => $currentDate,
                                        'CreateDate'        => $currentDate,
                                        'ApproveDate'       => EMPTY_DATE,
                                        'ApproveBy'         => 0,
                                        'IsDelete'          => 0,
                                        'IsActive'          => '1',
                                        'IsApproved'        => '0'
                                );

//                                echo "<pre>";
//                                print_r($insert);
//                                exit;
                                
                                $objHotel = new Travel_Model_TblHotel();
                                $intNewItemId = $objHotel->addICAccomdationRoom($insert);
                                
                                if(empty($intNewItemId)) {
                                    $response = array('success' => false, 'msg' => TECHNICAL_ERROR_MSG);
                                    echo json_encode($response);
                                    exit;
                                }
                                
                            }
                        }
                        /***********************************************************************/
                    
                    $objHotel = new Travel_Model_TblHotel();
                    $objHotel->intAccomSysId = $AccomSysId;
                    $arrHotelDetails = $objHotel->getHotelListDetails();
                    
                    if(!empty($arrHotelDetails)) {
                        $response = array('success' => true, 'intLastInsertId' => $AccomSysId, 'Title' => $arrHotelDetails[0]['Title'], 'CityName' => $arrHotelDetails[0]['CityName'], 'Stars' => $arrHotelDetails[0]['Stars'], 'PriceRange' => $arrHotelDetails[0]['PriceRange']);
                        echo json_encode($response);
                        exit;
                    }
                }
            } catch(Exception $e) {
                 throw new Exception($e->getMessage());
            }
                
            $response = array('success' => false, 'msg' => TECHNICAL_ERROR_MSG);
            echo json_encode($response);
            exit;
        }
    }
    
    public function addHotelInventoryAction() {
        
        $objHotel = new Travel_Model_TblHotel();
//        $this->view->arrHotels         = $objHotel->getHotelListDetails();
        
        $objHotelRooms = new Travel_Model_TblHotelRooms();
        $this->view->arrHotelRoomTypes = $objHotelRooms->getRoomTypes();
        
        $objHotelMeals = new Travel_Model_TblHotelMeals();
        $this->view->arrHotelMeals = $objHotelMeals->getMealTypes();
        
        $objSupplier = new Travel_Model_TblSupplier();
        $this->view->arrSupplierTypes = $objSupplier->getSupplierTypes();
       // $this->view->arrSupplierList = $objSupplier->getSuppliers();
        
        $objCurrency = new Travel_Model_TblCurrency();
        $this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
        
        //For display message
        $this->view->messages = $this->_helper->flashMessenger->getMessages();
        
        if($this->intLoggedinUserId == ADMIN_ID)
        {
            $objCountry = new Travel_Model_TblCountry();
            $this->view->arrCountryList = $objCountry->getCountryList();

            $objHotel = new Travel_Model_TblHotel();
            $this->view->arrAccomodationGroups      = $arrAccomodationGroups      = $objHotel->getAccomodationGroups();
            $this->view->arrAccomodationEconomyType = $arrAccomodationEconomyType = $objHotel->getAccomodationEconomyType();
            $intAccomSysId = base64_decode($this->getRequest()->getParam('AccomSysId'));
            
            if($intAccomSysId)
            {  
                $arrHotelDetail = $objHotel->getHotelListDetailsByHotelId($intAccomSysId);
                //echo "<pre>"; print_r($arrHotelDetail);die;
                $arrHotelGroupInfo = $objHotel->getHotelGroupMapByAccomSysId($intAccomSysId);
                $this->view->arrHotelInfo = $arrHotelDetail;
                $this->view->arrHotelGroupInfo = $arrHotelGroupInfo;
            }
            
            $this->render('add-hotel-inventory-admin');
        }

    }
    
    
    public function saveHotelAction()  {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->getRequest()->isPost())
        {    
            $data = $this->getRequest()->getPost();
//            echo "<pre>"; print_r($data); die;
            $objHotel = new Travel_Model_TblHotel();
            $currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $hotelId       = isset($data['hidden_selected_hotel_id']) ? trim($this->sanitize_data($data['hidden_selected_hotel_id'])) : '0';
            $hotelName     = isset($data['hotel_name']) ? trim($this->sanitize_data($data['hotel_name'])) : '';
            $intCountryId  = isset($data['select_hotel_country']) ? trim($this->sanitize_data($data['select_hotel_country'])) : '';
            $intCityId     = isset($data['select_hotel_city']) ? trim($this->sanitize_data($data['select_hotel_city'])) : '';
            $intHotelType  =  isset($data['hotel_type']) ? trim($this->sanitize_data($data['hotel_type'])) : 0; 
            $GeoLat        =  isset($data['latitude']) ? trim($this->sanitize_data($data['latitude'])) : 0; 
            $GeoLong       =  isset($data['longitude']) ? trim($this->sanitize_data($data['longitude'])) : 0; 
            
            //For Admin
            if(!empty($hotelId) && $hotelId!=0)
            {
               $arrHotelDetail = $objHotel->getHotelListDetailsByHotelId($hotelId); 
               $Brief = $arrHotelDetail['Brief'];
               $Address = $arrHotelDetail['Address'];
               $PinCode = $arrHotelDetail['PinCode'];
               $IsAgentSpec = $arrHotelDetail['IsAgentSpec'];
               $ICSourceSysId = $arrHotelDetail['ICSourceSysId'];
               $ApproveDate = $arrHotelDetail['ApproveDate'];
               $ApproveBy = $arrHotelDetail['ApproveBy'];
               $CreateDate = $arrHotelDetail['CreateDate'];
               $IsLocked = $arrHotelDetail['IsLocked'];
               $IsApproved = $arrHotelDetail['IsApproved'];
               $IsActive = $arrHotelDetail['IsActive'];
               $IsMarkForDel = $arrHotelDetail['IsMarkForDel'];
            } else {
               $currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
               $IsAgentSpec = 0;
               $ICSourceSysId = 1;
               $ApproveDate = '';
               $ApproveBy = 0;
               $CreateDate = $currentDate;
               $IsLocked = 1;
               $IsApproved = 1;
               $IsActive = 1;
               $IsMarkForDel = 0; 
            }
            
            //Add and edit parameter 
            
            if($arrHotelDetail['AliasAndMeta']!="") {
                $AliasAndMeta = $arrHotelDetail['AliasAndMeta'];
            } else {
                $AliasAndMeta= '';
            }
            if($arrHotelDetail['ShortName']!="") {
                $ShortName = $arrHotelDetail['ShortName'];
            } else {
                $ShortName= '';
            }
            if($arrHotelDetail['PlaceSysId_XRef']!="") {
                $PlaceSysId_XRef = $arrHotelDetail['PlaceSysId_XRef'];
            } else {
                $PlaceSysId_XRef= '0';
            }
            if($arrHotelDetail['Icon']!="") {
                $Icon = $arrHotelDetail['Icon'];
            } else {
                $Icon= '';
            }
            if($arrHotelDetail['ThumnailImg']!="") {
                $ThumnailImg = $arrHotelDetail['ThumnailImg'];
            } else {
                $ThumnailImg= '';
            }
            if($arrHotelDetail['DetailImg']!="") {
                $DetailImg = $arrHotelDetail['DetailImg'];
            } else {
                $DetailImg= '';
            }
            if($arrHotelDetail['DetailImg']!="") {
                $DetailImg = $arrHotelDetail['DetailImg'];
            } else {
                $DetailImg= '';
            }
            if($arrHotelDetail['Rating']!="") {
                $Rating = $arrHotelDetail['Rating'];
            } else {
                $Rating= '0';
            }
            if($arrHotelDetail['Popularity']!="") {
                $Popularity = $arrHotelDetail['Popularity'];
            } else {
                $Popularity= '0';
            }
            if($arrHotelDetail['AwardRecognizations']!="") {
                $AwardRecognizations = $arrHotelDetail['AwardRecognizations'];
            } else {
                $AwardRecognizations= '';
            }
            if($arrHotelDetail['AccoAminitiesMask']!="") {
                $AccoAminitiesMask = $arrHotelDetail['AccoAminitiesMask'];
            } else {
                $AccoAminitiesMask= '';
            }
            
//            if($arrHotelDetail['GeoLat']!="") {
//                $GeoLat = $arrHotelDetail['GeoLat'];
//            } else {
//                $GeoLat= '';
//            }
//            if($arrHotelDetail['GeoLong']!="") {
//                $GeoLong = $arrHotelDetail['GeoLong'];
//            } else {
//                $GeoLong= '';
//            }
            
            $insert = array('IsAgentSpec'               => $IsAgentSpec, 
                            'ICSourceSysId'             => $ICSourceSysId, 
                            'Title'                     => $hotelName,
                            
                            'AliasAndMeta'              => $AliasAndMeta,
                            'ShortName'                 => $ShortName,
                            'PlaceSysId_XRef'           => $PlaceSysId_XRef,
                            'Icon'                      => $Icon,
                            'ThumnailImg'               => $ThumnailImg,
                            'DetailImg'                 => $DetailImg,
                            'Stars'                     => isset($data['star_rating']) ? trim($this->sanitize_data($data['star_rating'])) : '0',
                            'Rating'                    => $Rating,
                            'Popularity'                => $Popularity,
                            'AwardRecognizations'       => $AwardRecognizations,
                            'PropertyType'              => '0',
                            'EconomyType'               => isset($intHotelType) ? $intHotelType : '',
                            'AccoAminitiesMask'         => $AccoAminitiesMask,
                            'MaxPaxCount'               => '0',
                            'RoomCounts'                => '0',
                            'Brief'                     => isset($data['brief']) ? trim($this->sanitize_data($data['brief'])) : @$Brief,
                            'CheckinTime'               => isset($data['CheckinTime']) ? trim($this->sanitize_data($data['CheckinTime'])) : @$data['CheckinTime'],
                            'CheckOutTime'              => isset($data['CheckOutTime']) ? trim($this->sanitize_data($data['CheckOutTime'])) : @$data['CheckOutTime'],
                            'IsDayLightApp'             => '0',
                            'GeoLat'                    => $GeoLat,
                            'GeoLong'                   => $GeoLong,
                            'Address'                   => isset($data['address']) ? trim($this->sanitize_data($data['address'])) : @$Address ,
                            'PinCode'                   => isset($data['pinCode']) ? trim($this->sanitize_data($data['pinCode'])) : @$PinCode,
                            'CitySysId'                 => $intCityId,
                            'ZoneSysId'                 => '0',
                            'ZoneType'                  => '0',
                            'StateSysId'                => 0,
                            'ContSysId'                 => isset($intCountryId) ? $intCountryId : '',
                            //'PrimaryContact'            => isset($arrHotelDetail['PrimaryContact']) ? $arrHotelDetail['PrimaryContact'] : '',
                            //'SecondaryContact'          => isset($arrHotelDetail['SecondaryContact']) ? $arrHotelDetail['SecondaryContact'] : '',
                            //'OtherContacts'             => isset($arrHotelDetail['OtherContacts']) ? $arrHotelDetail['OtherContacts'] : '',
                            'UpdateDate'                => $currentDate,
                            'ApproveDate'               => $ApproveDate,
                            'ApproveBy'                 => $ApproveBy,
                            'CreateDate'                => $CreateDate,
                            'IsLocked'                  => $IsLocked,
                            'IsApproved'                => $IsApproved,
                            'IsActive'                  => $IsActive,
                            'IsMarkForDel'              => $IsMarkForDel
                        );
            
            //echo "<pre>"; print_r($insert);die;
            
            if(!empty($hotelId) && $hotelId!=0)
            {
                //echo "dssd sdfds sdas";die;
                $objHotel->updateAccomodationInfo($insert, $hotelId);
                $objHotel->updateAccomodationGroupInfo(trim($this->sanitize_data($data['hotel_chain'])), $hotelId);
                $this->_helper->flashMessenger->addMessage("Hotel saved successfully.");
	        $this->_helper->redirector('manage-hotel', 'hotel', 'admin');
            } else {
                //echo "dssd sdfds";die;
                $objHotel->addAccomodation($insert, trim($this->sanitize_data($data['hotel_chain'])));
                $this->_helper->flashMessenger->addMessage("Hotel saved successfully.");
	        $this->_helper->redirector('manage-hotel', 'hotel', 'admin');
            }  
        }
    }
    
    
    
    /*
    public function saveInventoryAction() {
        

        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
            
    
       
        if ($this->_request->isXmlHttpRequest()) {

            $post = $this->getRequest()->getPost();

            $intHotelId             = $this->getRequest()->getPost('hotel_id');
            $strRoomName            = $this->getRequest()->getPost('room_name');
            $intRoomType            = $this->getRequest()->getPost('room_type');
            $intMealPlan            = $this->getRequest()->getPost('meal_plan');
            $strFromDate            = $this->getRequest()->getPost('from_dt');
            $strToDate              = $this->getRequest()->getPost('to_dt');
            
            $strFromDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strFromDate,'d/m/y');
            $strToDate   = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strToDate,'d/m/y');
            
            
            $strCurrencyType        = $this->getRequest()->getPost('currency_type');
            $intDailyRoomLimit      = $this->getRequest()->getPost('daily_room_limit');        
            $intPermission          = $this->getRequest()->getPost('permission');
            $fltCostDoubleOccupancy = $this->getRequest()->getPost('cost_double_occupancy');
            $fltCostSingleOccupancy = $this->getRequest()->getPost('cost_single_occupancy');
            $fltCostExtraWithBed    = $this->getRequest()->getPost('cost_extra_with_bed');
            $fltCostExtraWithoutBed = $this->getRequest()->getPost('cost_extra_without_bed');
           // $intSupplierType        = $this->getRequest()->getPost('supplier_type');
            
      
            


            $intLoggedinUserId            = $this->intLoggedinUserId ;

            $insertData = array('InventoryType' => '1', 'AccomSysId' => $intHotelId,
                    'AgencySysId' => $intLoggedinUserId, 'SupplierSysId' =>  $intSupplierSysId, 'Title' => $strRoomName,
                    'EconomyType' => $strCurrencyType, 'MealPlanType' => $intMealPlan, 'IxFixedDateInven' => '0',
                    'FromDate' => $strFromDate, 'ToDate' => $strToDate, 'DailyRoomLimit' => $intDailyRoomLimit,'PurchasedQty' => 0,
                    'PublishQty' => 0, 'BlockQty' => 0, 'SoldQty' => 0, 'ReturnQty' => 0, 'NetInHandQty' => 0,
                    'Currency' => $strCurrencyType, 'IsPerPaxCostAllowed' => $intPermission, 'PerPaxCost' => 0, 'DOccupCost' => $fltCostDoubleOccupancy,
                    'SOccupCost' => $fltCostSingleOccupancy, 'ExtraBedCost' => $fltCostExtraWithBed, 'ExtraWOBedCost' => $fltCostExtraWithoutBed,
                    'OtherCost' => '0', 'SaleAmount' => '0', 'DefaultPrice' => 0, 'Brief' => '', 'IfAnyOffer' => '0',
                    'OfferMsg' => '', 'OfferImage' => '','CreatorSysId' => $intLoggedinUserId, 'CreateDate' => '', 'ApproveDate' => '',
                    'UpdateDate' => '', 'IsActive' => '0', 'IsMarkForDelete' => 0, 'IsApproved' => '0'
                );

            $objHotel = new Travel_Model_TblHotel();
            $objHotel->addHotelInventory($insertData);
            $response = array('success'=>true);
            echo json_encode($response);
        }
         
    } */
    
    
    public function viewHotelInventoryTableAction() {
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        
        //$this->layout()->headLink()->appendStylesheet('/public/assets/css/style.css'); 
        
        $this->view->headScript()->appendFile('/public/assets/css/style.css');
        $this->view->headScript()->appendFile('/public/assets/css/bootstrap.min.css');
        
        $objHotel = new Travel_Model_TblHotel();
        $objHotel->intLoggedinUserAgencySysId   = $this->intLoggedinUserAgencySysId;
        $this->view->arrHotelInventoryList = $objHotel->getHotelInventoryList();
        
//        echo "<pre>";
//        print_r($objHotel->getHotelInventoryList());
//        exit;
        
    }
    
    public function manageMarkupAction() {
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        
        $this->view->InvnItemSysId = $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
        $this->view->MarkupSetting = $MarkupSetting = $this->getRequest()->getParam('MarkupSetting');
        $this->view->MarkupType    = $MarkupType    = $this->getRequest()->getParam('MarkupType');
        $this->view->key           = $key    = $this->getRequest()->getParam('key');
        $this->view->popupType     = $popupType    = $this->getRequest()->getParam('popupType');
        
        if(empty($InvnItemSysId)) {
            throw new Exception('InvnItemSysId not found');
        }
        
        $objHotel = new Travel_Model_TblHotel();
        $objHotel->strCondition = " AND TB_MP_Inventory_Accom.InvnItemSysId = " . $InvnItemSysId;
        $this->view->arrMPInventoryAccomList = $arrMPInventoryAccomList = $objHotel->getMPInventoryAccomList();
        
        $objHotel = new Travel_Model_TblHotel();
        $objHotel->InvnItemSysId = $InvnItemSysId;
        $objHotel->MPType        = $MarkupType;
        $objHotel->CustGrSysId   = $this->intLoggedinUserGroupSysId;
        
        $arrInventoryAllocationList = $objHotel->getMPInventoryAccomAlloc();
        if(!empty($arrInventoryAllocationList) ) {
            $this->view->InventoryAllocationExists = true;
            $this->view->InventoryAllocationExistsOf = $arrInventoryAllocationList[0]['MarkUpType'];
        } else {
            $this->view->InventoryAllocationExists = false;
        }
        
//        echo "<pre>";)
//        print_r($arrMPInventoryAccomList);
//        exit;
        
        if(count($arrMPInventoryAccomList) <> 1 ) {
            throw new Exception('There has been an error, Please try again later');
        }
    }
    

    
    public function individualHotelManageMarkupAction() {
        
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $this->view->AccomSysId = $AccomSysId = $this->getRequest()->getParam('AccomSysId');
           
            
            if(!empty($AccomSysId)) {

                $objHotel = new Travel_Model_TblHotel();
                $objHotel->intAccomSysId = $AccomSysId;
                $arrHotelInfo = $objHotel->getHotelListDetails();

                if(count($arrHotelInfo) <> 1 ) {
                    throw new Exception('Hotel information not found.');
                }
                $this->view->strHotelInfo = $arrHotelInfo[0]['Title'] .", " . $arrHotelInfo[0]['CityName'] ;
            }
        }
    }
    
    
    public function viewMarkupSettingGridAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        
        $this->view->intLoggedinUserAgencySysId = $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        
        $objAgent = new Travel_Model_TblAgency();
        $CurrencyType = $objAgent->getAgentTxnCurrency($intLoggedinUserAgencySysId);
        
        $objCurrency = new Travel_Model_TblCurrency();
        $this->view->TransactionCurrencySymbol = $currencySymbol = $objCurrency->getCurrencySymbol($CurrencyType);
        
        
       
        
        
        if($this->_request->isXmlHttpRequest()) {
           
          //  $this->view->AccomSysId     = $AccomSysId    = $this->getRequest()->getParam('AccomSysId');
            $this->view->InvnItemSysId  = $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
            $this->view->MarkupSetting  = $MarkupSetting = $this->getRequest()->getParam('MarkupSetting');
            $this->view->RateType       = $RateType      = $this->getRequest()->getParam('RateType');
            $this->view->key       = $key    = $this->getRequest()->getParam('key');
            
            if($MarkupSetting == 'S') {
                $this->view->MarkupType     = $MarkupType = '';
            } else {
                $this->view->MarkupType     = $MarkupType    = $this->getRequest()->getParam('MarkupType');
            }
            
            if($MarkupType == '1' || $MarkupType == '2') {
                 $this->view->MarkupSetting  = $MarkupSetting = 'C';
            }
            
            $objHotel = new Travel_Model_TblHotel();
            
            if(!empty($InvnItemSysId)) {
                $condition = " AND TB_MP_Inventory_Accom.InvnItemSysId = " . $InvnItemSysId;
                $objHotel->strCondition = $condition;
                $arrMPInventoryAccomList     = $objHotel->getMPInventoryAccomList();
                
                if(count($arrMPInventoryAccomList) <> 1 ) {
                    throw new Exception('There has been an error, Please try again later');
                }
                
                $this->view->arrMPInventoryAccomList    = $arrMPInventoryAccomList = $arrMPInventoryAccomList[0];
                $this->view->DOccupCost                 = $arrMPInventoryAccomList['DOccupCost'];
                $this->view->SOccupCost                 = $arrMPInventoryAccomList['SOccupCost'];
                $this->view->ExtraBedCost               = $arrMPInventoryAccomList['ExtraBedCost'];
                $this->view->ExtraWOBedCost             = $arrMPInventoryAccomList['ExtraWOBedCost'];
                
//                echo "<pre>";
//                print_r($arrMPInventoryAccomList);
//                exit;
//                
                
                $this->view->NetDOccupCost              = $arrMPInventoryAccomList['NetDOccupCost'];
                $this->view->NetSOccupCost              = $arrMPInventoryAccomList['NetSOccupCost'];
                $this->view->NetExtraBedCost            = $arrMPInventoryAccomList['NetExtraBedCost'];
                $this->view->NetExtraWOBedCost          = $arrMPInventoryAccomList['NetExtraWOBedCost'];
                
                
                $this->view->Tax                        = $arrMPInventoryAccomList['Tax'];
                $this->view->RateType                   = $arrMPInventoryAccomList['RateType'];
                
                $CostCurrency                      = $arrMPInventoryAccomList['CostCurrency'];
                $TrxCurrency                       = $arrMPInventoryAccomList['TrxCurrency'];
            }
            
            $objHotel = new Travel_Model_TblHotel();
            $objHotel->InvnItemSysId = $InvnItemSysId;
               
                
            if($MarkupSetting == 'S') {
                $objAgency = new Travel_Model_TblAgency();
                $objAgency->getStandardMarkupAccomodation();
                $objAgency->intAgencySysId = $this->intLoggedinUserAgencySysId;
                $this->view->arrMarkupList = $objAgency->getStandardMarkupAccomodation();
            } else if($MarkupSetting == 'C') {
                 
                if(!empty($MarkupType)) {
                    $objHotel->strCondition .= " AND TB_MP_Inventory_Accom_Alloc.MarkUpType = " . $MarkupType;
                }
                
                $this->view->arrMarkupList = $arrMarkupList = $objHotel->getMPInventoryAccomAlloc();
                
                $objAgent = new Travel_Model_TblAgency();
                $arrExtraMarkupDetail = $objAgent->getExtraMarkupDetail($this->intLoggedinUserAgencySysId, $CurrencyType);
                
                if(!empty($arrExtraMarkupDetail)) {
                    $this->view->ExtraPaddingIsInPercentage = @$arrExtraMarkupDetail[0]['IsInPercentage'];
                    $this->view->ExtraPadding               = @$arrExtraMarkupDetail[0]['ExtraPadding'];
                }
                
                
                
            } else {
               // throw new Exception('Markup settings not found.');
            }
            
//            $arrHotelInventoryList = $objHotel->getHotelInventoryList($InvnItemSysId);
//
//            if(count($arrHotelInventoryList) <> 1 ) {
//                throw new Exception('There has been an error, Please try again later');
//            }
//            
//            $this->view->arrHotelInventoryList = $arrHotelInventoryList[0];
            
            
            $this->view->arrMarketPlaces = Zend_Controller_Action_HelperBroker::getStaticHelper('B2B')->getMarketPlaces(); 
            $this->view->arrPermissions  = Zend_Controller_Action_HelperBroker::getStaticHelper('B2B')->getPermissions(); 
            
            if($MarkupSetting == 'S') {
                $this->render('view-standard-markup-grid');
            } else if($MarkupSetting == 'C') {
                $this->render('view-customized-markup-grid');
            } else {
                throw new Exception(TECHNICAL_ERROR_MSG);
            }
            
        } 
    }
    
  
    
    
    
    
   
    
    
    
    public function addMarkupAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $this->sanitize_data = $this->getRequest()->getPost();
            
//            echo "<pre>";
//            print_r($post);
//            exit;
            
            
            $currentDate   = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $intMarkupType = trim($this->sanitize_data($post['MarkupType']));
            $InvnItemSysId = trim($this->sanitize_data($post['InvnItemSysId']));
            $MarkupSetting = trim($this->sanitize_data($post['MarkupSetting']));
            
            $MPType = trim($this->sanitize_data($post['MPType']));
            $doccupancy = trim($this->sanitize_data($post['doccupancy']));
            $soccupancy = trim($this->sanitize_data($post['soccupancy']));
            $extra_bed = trim($this->sanitize_data($post['extra-bed']));
            $extra_without_bed = trim($this->sanitize_data($post['extra-without-bed']));
            $tax = trim($this->sanitize_data($post['tax']));
            
            if(empty($MPType)) {
                $response = array('success' => false, 'msg' => 'Please select Market Place.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($intMarkupType)) {
                $response = array('success' => false, 'msg' => 'Please select Markup Type.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($doccupancy)) {
                $response = array('success' => false, 'msg' => 'Please enter Double occupancy Markup.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($soccupancy)) {
                $response = array('success' => false, 'msg' => 'Please enter Single occupancy Markup.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($extra_bed)) {
                $response = array('success' => false, 'msg' => 'Please enter Extra with bed Markup.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($extra_without_bed)) {
                $response = array('success' => false, 'msg' => 'Please enter Extra W/O bed Markup.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($tax)) {
                $response = array('success' => false, 'msg' => 'Please enter tax.');
                echo json_encode($response);
                exit;
            }
            
            
            if(empty($InvnItemSysId) || empty($intMarkupType)) {
                throw new Exception('There has been an error, Please try again later');
            }
            
            $MPType             = !empty($post['MPType']) ? trim($this->sanitize_data($post['MPType'])) : '0';
            
            $MarkUp             = !empty($post['MarkUp']) ? trim($this->sanitize_data($post['MarkUp'])) : '0';
            $DOccupPrice        = !empty($post['doccupancy']) ? trim($this->sanitize_data($post['doccupancy'])) : '0';
            $SOccupPrice        = !empty($post['soccupancy']) ? trim($this->sanitize_data($post['soccupancy'])) : '0';
            $ExtraBedPrice      = !empty($post['extra-bed'])  ? trim($this->sanitize_data($post['extra-bed']))  : '0';
            $ExtraWOBedPrice    = !empty($post['extra-without-bed']) ? trim($this->sanitize_data($post['extra-without-bed'])) : '0';
            $Details            = !empty($post['Details'])     ? trim($this->sanitize_data($post['Details'])) : '';
            $permissions        = !empty($post['permissions']) ? trim($this->sanitize_data($post['permissions'])) : '0';
            $Tax                = !empty($post['tax']) ? trim($this->sanitize_data($post['tax'])) : 0;

            $CustGrSysId        = $this->intLoggedinUserGroupSysId;
            $ItemType           = '0';        
            $AgencySysId        = $this->intLoggedinUserAgencySysId ;
            $AllocateQty        = '0';
            $IsVirtualInven     = '0';
            $SoldQty            = '0';
            $ReturnQty          = '0';
            $NetQty             = '0';             
            $BlockQty           = '0';
            $MarkUpType         = $intMarkupType;
            $Currency           = $this->intLoggedinUserTrxCurrency;
            $PerPaxPrice        = '0';
            $OtherPrice         = '0';
            $Discount           = '0';
            $DiscountType       = '0';
            $DiscountAmount     = '0';
            $DiscountMsg        = '';
            $NetPrice           = '0';
            $IsPublish          = '0';
            $PublishDate        = '';
            $RateRuleSysId      = '0';
            $TCDocSysId         = '0';
            $ValidTill          = '';
            $ApproveDate        = '';
            $CreateDate         = $currentDate;
            $UpdateDate         = $currentDate;
            $IsApproved         = '0';
            $IsMarkForDel       = '0';
            $IsActive           = $permissions;
             
            $insert = 
            array(
                'InvnItemSysId'     => $InvnItemSysId,
                'MPType'            => $MPType,
                'CustGrSysId'       => $CustGrSysId,
                'ItemType'          => $ItemType,       
                'AgencySysId'       => $AgencySysId,
                'AllocateQty'       => $AllocateQty,
                'IsVirtualInven'    => $IsVirtualInven,
                'SoldQty'           => $SoldQty,
                'ReturnQty'         => $ReturnQty,
                'NetQty'            => $NetQty,         
                'BlockQty'          => $BlockQty,
                'MarkUpType'        => $MarkUpType,
                'MarkUp'            => $MarkUp,
                'Currency'          => $Currency,
                'DOccupPrice'       => $DOccupPrice,
                'SOccupPrice'       => $SOccupPrice,
                'ExtraBedPrice'     => $ExtraBedPrice,
                'ExtraWOBedPrice'   => $ExtraWOBedPrice,
                'Tax'               => $Tax,
                'PerPaxPrice'       => $PerPaxPrice,
                'OtherPrice'        => $OtherPrice,
                'Discount'          => $Discount,
                'DiscountType'      => $DiscountType,
                'DiscountAmount'    => $DiscountAmount,
                'DiscountMsg'       => $DiscountMsg,
                'NetPrice'          => $NetPrice,
                'IsPublish'         => $IsPublish,
                'PublishDate'       => $PublishDate,
                'Details'           => $Details,
                'RateRuleSysId'     => $RateRuleSysId,
                'TCDocSysId'        => $TCDocSysId,
                'ValidTill'         => $ValidTill,
                'ApproveDate'       => $ApproveDate,
                'CreateDate'        => $CreateDate,
                'UpdateDate'        => $UpdateDate,
                'IsApproved'        => $IsApproved,
                'IsMarkForDel'      => '0',
                'IsActive'          => $IsActive                       
            );
              
//              
//              echo "<pre>";
//            print_r($insert);
//            exit;
//            
            
                
            /* Check if markup settings already exists */
            $objHotel = new Travel_Model_TblHotel();
            $arrMarkupSettings = $objHotel->getMarkups($InvnItemSysId, $MPType, $this->intLoggedinUserGroupSysId );

            if(!empty($arrMarkupSettings) ) {
                
                $objHotel = new Travel_Model_TblHotel();
                $objHotel->strCondition = " AND TB_MP_Inventory_Accom_Alloc.IsMarkForDel = '1' ";
                $arrMarkupSettings = $objHotel->getMarkups($InvnItemSysId, $MPType, $this->intLoggedinUserGroupSysId );

                /* Check if markup settings already exists */
                if(count($arrMarkupSettings) == 0 ) {
                    $response = array('success' => false, 'msg' => 'Markup settings of the selected Market Place has already been added.');
                    echo json_encode($response);
                    exit;
                } else {
                    try {
                        unset($insert['InvnItemSysId']);
                        unset($insert['MPType']);
                        unset($insert['CustGrSysId']);
                        $insert['IsMarkForDel'] = '0';
                        $objHotel->updateMarkupSettings($InvnItemSysId, $MPType, $CustGrSysId, $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;
                    }
                }
            } else {
                    try {
                        $objHotel = new Travel_Model_TblHotel();
                        $objHotel->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 deleteMarkupSettingAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
         
        if($this->_request->isXmlHttpRequest()) {
            $InvnItemSysId  = $this->getRequest()->getParam('InvnItemSysId');
            $MPType         = $this->getRequest()->getParam('MPType');
            $CustGrSysId    = $this->intLoggedinUserGroupSysId;
            
            $objHotel = new Travel_Model_TblHotel();
            $objHotel->deleteMarkupSetting($InvnItemSysId, $MPType, $CustGrSysId);
            
            $response = array('success' => true);
            echo json_encode($response);
            exit;
        }
    }
    
   
    
    public function deleteBulkHotelInventoryAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            $InvnItemSysId = $this->getRequest()->getParam('intRecordId');
            
            $objHotel = new Travel_Model_TblHotel();
            $objHotel->deleteMPInventoryAccom($InvnItemSysId);
            
            $response = array('success' => true);
            echo json_encode($response);
            exit;
        }
        
    }
    
    
    public function viewHotelInventoryBulkFormAction() {
        
        $this->_helper->layout->setLayout('newLayout');
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
          //  $this->_response->setHttpResponseCode(401); //401 = unauthorized
            
            $objHotel = new Travel_Model_TblHotel();
           // $this->view->arrHotels         = $objHotel->getHotelList();

            $objHotelRooms = new Travel_Model_TblHotelRooms();
            $this->view->arrHotelRoomTypes = $objHotelRooms->getRoomTypes();

            $objHotelMeals = new Travel_Model_TblHotelMeals();
            $this->view->arrHotelMeals = $objHotelMeals->getMealTypes();

            $objSupplier = new Travel_Model_TblSupplier();
            //$this->view->arrSupplierTypes = $objSupplier->getSupplierTypes();
            $this->view->SupplierTypeSysId = $objSupplier->SupplierTypeSysId = 4;
            $this->view->arrSupplierList = $objSupplier->getSuppliers();
             

            $objCurrency = new Travel_Model_TblCurrency();
            $this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
        }
        
    }
    
    
    public function viewHotelInventoryBulkEditFormAction() {
        
        $this->_helper->layout->setLayout('newLayout');
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $InvnItemSysId  = base64_decode($this->getRequest()->getParam('InvnItemSysId'));
            
            $objHotel = new Travel_Model_TblHotel();
            $objHotel->strCondition =" AND InvnItemSysId = " . $InvnItemSysId;
            $arrHotelDetail = $objHotel->getHotelInventoryList();
            $arrHotelInventoryDetail = $arrHotelDetail[0];
            
            //echo "<pre>"; print_r($arrHotelInventoryDetail);die;
            
            //$objHotelRooms = new Travel_Model_TblHotelRooms();
            //$this->view->arrHotelRoomTypes = $objHotelRooms->getRoomTypes();

            $objHotelMeals = new Travel_Model_TblHotelMeals();
            $this->view->arrHotelMeals = $objHotelMeals->getMealTypes();

            //$objSupplier = new Travel_Model_TblSupplier();
            //$this->view->arrSupplierTypes = $objSupplier->getSupplierTypes();
            //$this->view->SupplierTypeSysId = $objSupplier->SupplierTypeSysId = 4;
            //$this->view->arrSupplierList = $objSupplier->getSuppliers();
             
            //$objCurrency = new Travel_Model_TblCurrency();
            //$this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
            
            $this->view->arrHotelInventoryDetail = $arrHotelInventoryDetail;
            
        }
        
    }
    
    public function viewHotelInventoryIndividualFormAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        if($this->_request->isXmlHttpRequest()) {
            $AccomSysId = $this->getRequest()->getParam('AccomSysId');
            $this->view->AccomSysId = base64_decode($AccomSysId) ;
        }
        
    }
    
    
    public function changeStatusAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            $AccomSysId = $this->getRequest()->getParam('AccomSysId');
            $Status     = $this->getRequest()->getParam('Status');
            
            $objHotel = new Travel_Model_TblHotel();
            $objHotel->changeStatus($AccomSysId, $Status);
            
            $response = array('success' => true);
            
            echo json_encode($response);
            exit;
            
        }
        
    }
    
    
    public function individualHotelOverviewAction() {
        
        /* Disable Layout */
        
        $this->_helper->layout->disableLayout();
        

  
        if($this->_request->isXmlHttpRequest()) {
            
                    $objCountry = new Travel_Model_TblCountry();
        $this->view->arrCountryList = $objCountry->getCountryList();
        
        $objHotel = new Travel_Model_TblHotel();
        $this->view->arrAccomodationGroups      = $arrAccomodationGroups      = $objHotel->getAccomodationGroups();
        
        $this->view->arrAccomodationEconomyType = $arrAccomodationEconomyType = $objHotel->getAccomodationEconomyType();
        
        $this->view->intAccomSysId = $intAccomSysId = $this->getRequest()->getParam('intAccomSysId');
            
            if(!empty($intAccomSysId)) {
                
                $objHotel = new Travel_Model_TblHotel();
                $objHotel->intAccomSysId = $intAccomSysId;
                $arrHotelDetail = $objHotel->getHotelListDetails();
//                echo "<pre>"; print_r($arrHotelDetail);
//                die;
                //Get Hotel Room Details IDs
                $arrHotelRoomIds = $objHotel->getHotelRoomIdsList($intAccomSysId);
                //echo "<pre>"; print_r($arrHotelRoomIds);
                
                $arrHotelGroupInfo = $objHotel->getHotelGroupMapByAccomSysId($intAccomSysId);
//                echo "<pre>"; print_r($arrHotelGroupInfo);
//                die;
                if(count($arrHotelDetail) <> 1 ) {
                    throw new Exception('Hotel information not found.');
                }
                
                $this->view->arrHotelInfo = $arrHotelDetail[0];
                $this->view->arrHotelRoomIds = $arrHotelRoomIds;
                $this->view->arrHotelGroupInfo = $arrHotelGroupInfo;
                
            }
            
        }
   
    }
    
    
    public function individualHotelAddroomsAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            
            $this->view->intAccomSysId = $intAccomSysId = $this->getRequest()->getParam('intAccomSysId');
            
            $objHotelRooms = new Travel_Model_TblHotelRooms();
            $this->view->arrHotelRoomTypes = $objHotelRooms->getRoomTypes();
            
            if(!empty($intAccomSysId)) {
                

                $this->view->mode = $mode = $this->getRequest()->getParam('mode');

                if($mode == 'edit') {
                   // $this->view->ItemSysId     = $ItemSysId = $this->getRequest()->getParam('InvnItemSysId');
                    $this->view->InvnItemSysId     = $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
                    
//                    $objHotel = new Travel_Model_TblHotel();
//                    $objHotel->ItemSysId      = $ItemSysId;
//                    $arrRoomDetail = $objHotel->getICAccomdationRoom($intAccomSysId);

                    $objHotel = new Travel_Model_TblHotel();
                    
                    $objHotel->strCondition = " AND TB_IC_Accomdation_Room.ItemSysId  = " .$InvnItemSysId;
                    
                    //echo " AND TB_MP_Inventory_Accom.InvnItemSysId  = " .$InvnItemSysId;
                    
                    $arrRoomDetail = $objHotel->getMPInventoryHotelRoomList();
                    
                    
                    if(count($arrRoomDetail) <> 1) {
                        throw new Exception('Room detail not found.');
                    }
                    
                    $this->view->arrRoomDetail = $arrRoomDetail[0];
                } 


                $objHotel = new Travel_Model_TblHotel();
                $objHotel->intAccomSysId = $intAccomSysId;
                $arrHotelInfo = $objHotel->getHotelListDetails();

                if(count($arrHotelInfo) <> 1 ) {
                    throw new Exception('Hotel information not found.');
                }

                $this->view->arrHotelRoomsInfo = $objHotel->getHotelRoomsInventory($intAccomSysId);
                $this->view->strHotelInfo = $arrHotelInfo[0]['Title'] .", " . $arrHotelInfo[0]['CityName'] ;
            }
        }
    }
    
    
    public function addIcAccomodationRoomAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $post = $this->getRequest()->getPost();
            
//            echo "<pre>";
//            print_r($post);
//            exit;
            
            $AccomSysId  = $post['AccomSysId'];
            $ItemSysId   = $post['ItemSysId'];
            
            $title    = $post['room_name'];
            $roomType = $post['room_type'];
            $mealPlan = $post['meal_plan'];
            
            $roomAmenities = isset($post['room_amenities']) && count($post['room_amenities']) > 0  ? $post['room_amenities'] : array();
            $amenities = implode(",", $roomAmenities);
            $objHotel = new Travel_Model_TblHotel();
            $amenitiesMask = $objHotel->createRoomAmenitiesMask($amenities);
            
            if(empty($title)) {
                $response = array('success' => false, 'msg' => 'Please enter room name');
                echo json_encode($response);
                exit;
            }
            
            if(empty($roomType)) {
                $response = array('success' => false, 'msg' => 'Please selecte room type');
                echo json_encode($response);
                exit;
            }
            
            /* Check if room type already exists of this Hotel */
            
            if(!empty($ItemSysId)) { /* Update case */
                $objHotel = new Travel_Model_TblHotel();
                $objHotel->strCondition = " AND TB_IC_Accomdation_Room.RoomType = ". $roomType ." AND TB_IC_Accomdation_Room.ItemSysId != " .$ItemSysId ;
                // " AND TB_IC_Accomdation_Room.RoomType = ". $roomType ." AND TB_IC_Accomdation_Room.ItemSysId != " .$ItemSysId ;
                $arrRoomDetail = $objHotel->getICAccomdationRoom($AccomSysId);
            }else { /* Newly add case */
                $objHotel = new Travel_Model_TblHotel();
                $objHotel->strCondition = " AND TB_IC_Accomdation_Room.RoomType = ". $roomType ;
                $arrRoomDetail = $objHotel->getICAccomdationRoom($AccomSysId);
            }
            
            if(!empty($arrRoomDetail) ){
                $response = array('success' => false, 'msg' => 'This room type is already added for this Hotel.');
                echo json_encode($response);
                exit;
            }
            
            $currentDate   = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            
            $insert = array(
                'AccomSysId'       => $AccomSysId,
                'SourceSysId'       => $this->InfoSourceSysId,
                'Title'             => $title,
                'RoomType'          => $roomType,
                'EconomyType'       => 0,
                'Qty'               => $post['room_inventory'],
                'BedType'           => 0,
                'PaxCount'          => $post['PaxCount'],
                'IsPetAllow'        => 0,
                'MaxPetAllow'       => 0,
                'AllowChild'        => $post['AllowChild'],
                'AllowInfant'       => 0,
                'MaxPaxCount'       => $post['MaxPaxCount'],
                'MaxAllowChild'     => $post['MaxAllowChild'],
                'MaxAllowInfant'    => 0,
                'MealPlanType'      => $mealPlan,
                'AminitiesMask'     => $amenitiesMask,
                'InclustionOptionsMask' => '',
                'OtherDetails'      => $post['other_details'],
                'UpdatedDate'       => $currentDate,
                'CreateDate'        => $currentDate,
                'ApproveDate'       => EMPTY_DATE,
                'ApproveBy'         => 0,
                'IsDelete'          => 0,
                'IsActive'          => '1',
                'IsApproved'        => '0'
            );
            
            
            $objHotel = new Travel_Model_TblHotel();
            
            if(!empty($ItemSysId)) { /* Update case */
                $objHotel->updateICAccomdationRoom($insert, $AccomSysId, $ItemSysId);
                $response = array('success' => true);
            } else {
                $intLastInsertId = $objHotel->addICAccomdationRoom($insert);
                if(!empty($intLastInsertId)) {
                    $response = array('success' => true, 'intLastInsertId' => $intLastInsertId);
                } else {
                    $response = array('success' => false, 'msg' => TECHNICAL_ERROR_MSG);
                }
            }
            
            echo json_encode($response);
            exit;
            
        }
            
    }
    
    
    
     public function addMpInventoryAccomodationRoomAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        
        if($this->_request->isXmlHttpRequest()) {
            
            $post = $this->getRequest()->getPost();
            
            $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
            $AccomSysId = $this->getRequest()->getParam('AccomSysId');
            
//            echo "<pre>";
//            print_r($post);
//            exit;
            
            // $AccomSysId  = $post['AccomSysId'];
            //$ItemSysId   = $post['ItemSysId'];
            
            //$title    = $post['room_name'];
            $roomType = $post['room_type'];
            $mealPlan = $post['meal_plan'];
            $room_inventory = $post['room_inventory'];
            
            $roomAmenities = isset($post['room_amenities']) && count($post['room_amenities']) > 0  ? $post['room_amenities'] : array();
            $amenities = implode(",", $roomAmenities);
            $objHotel = new Travel_Model_TblHotel();
            $amenitiesMask = $objHotel->createRoomAmenitiesMask($amenities);
            
//            if(empty($title)) {
//                $response = array('success' => false, 'msg' => 'Please enter room name');
//                echo json_encode($response);
//                exit;
//            }
            
            if($roomType==0) {
                $response = array('success' => false, 'msg' => 'Please select room type');
                echo json_encode($response);
                exit;
            }
            
            if($mealPlan==0) {
                $response = array('success' => false, 'msg' => 'Please select meal plan');
                echo json_encode($response);
                exit;
            }
            
            if($room_inventory=="" || $room_inventory==0) {
                $response = array('success' => false, 'msg' => 'Please enter total rooms');
                echo json_encode($response);
                exit;
            }
            
            $ItemSysId = $objHotel->getRoomIdByRoomType($AccomSysId, $roomType);
            
           // echo $XRefItemSysId;exit;
            
            
            
            /* Check if room type already exists of this Hotel */
            
//            if(!empty($ItemSysId)) { /* Update case */
//                $objHotel = new Travel_Model_TblHotel();
//                $objHotel->strCondition = " AND TB_IC_Accomdation_Room.RoomType = ". $roomType ." AND TB_IC_Accomdation_Room.ItemSysId != " .$ItemSysId ;
//                // " AND TB_IC_Accomdation_Room.RoomType = ". $roomType ." AND TB_IC_Accomdation_Room.ItemSysId != " .$ItemSysId ;
//                $arrRoomDetail = $objHotel->getICAccomdationRoom($AccomSysId);
//            }else { /* Newly add case */
//                $objHotel = new Travel_Model_TblHotel();
//                $objHotel->strCondition = " AND TB_IC_Accomdation_Room.RoomType = ". $roomType ;
//                $arrRoomDetail = $objHotel->getICAccomdationRoom($AccomSysId);
//            }
            
//            if(count($arrRoomDetail) > 0 ){
//                $response = array('success' => false, 'msg' => 'This room type is already added for this Hotel.');
//                echo json_encode($response);
//                exit;
//            }
            
            $currentDate   = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            
            $insert = array(
                'AccomSysId'        => $AccomSysId,
                'SourceSysId'       => $this->intLoggedinUserAgencySysId,
                'Title'             => '',
                'RoomType'          => $roomType,
                'EconomyType'       => 0,
                'Qty'               => $post['room_inventory'],
                'BedType'           => 0,
                'PaxCount'          => 0,
                'IsPetAllow'        => 0,
                'MaxPetAllow'       => 0,
                'AllowChild'        => 0,
                'AllowInfant'       => 0,
                'MaxPaxCount'       => $post['MaxPaxCount'],
                'MaxAllowChild'     => $post['MaxAllowChild'],
                'MaxAllowInfant'    => 0,
                'MealPlanType'      => $mealPlan,
                'AminitiesMask'     => $amenitiesMask,
                'InclustionOptionsMask' => '',
                'OtherDetails'      => $post['other_details'],
                'UpdatedDate'       => $currentDate,
                'CreateDate'        => $currentDate,
                'ApproveDate'       => EMPTY_DATE,
                'ApproveBy'         => 0,
                'IsDelete'          => 0,
                'IsActive'          => '1',
                'IsApproved'        => '0'
            );
            
//            echo "<pre>";
//            print_r($insert);
//            exit;
            
            
            $objHotel = new Travel_Model_TblHotel();
            if(!empty($InvnItemSysId)) { /* Update case */
                
                $checkEditTotalRooms = $objHotel->isEditICAccomodationRoomExists($AccomSysId, $roomType, $InvnItemSysId);
                if($checkEditTotalRooms>0)
                {
                    $response = array('success' => false, 'msg' => "This room type is already added for this Hotel.");
                    echo json_encode($response);
                    exit;
                } else {  
                    $objHotel->updateICAccomdationRoom($insert, $AccomSysId, $InvnItemSysId);

                    //$data = array('DailyRoomLimit' => $post['room_inventory']);
                    //$objHotel->updateMPInventoryAccom($InvnItemSysId, $data);
                    $response = array('success' => true);
                    echo json_encode($response);
                    exit;
                }
            } 
            else {
                $checkTotalRooms = $objHotel->isICAccomodationRoomExists($AccomSysId, $roomType);
                if($checkTotalRooms>0)
                {
                    $response = array('success' => false, 'msg' => "This room type is already added for this Hotel.");
                    echo json_encode($response);
                    exit;
                } 
                else 
                {
                    $intLastInsertId = $objHotel->addICAccomdationRoom($insert);
                    if(!empty($intLastInsertId)) {
                        $response = array('success' => true, 'intLastInsertId' => $intLastInsertId);
                    } else {
                        $response = array('success' => false, 'msg' => TECHNICAL_ERROR_MSG);
                    }

                    echo json_encode($response);
                    exit;
                }
            }
        } 
    }
    
    
    
    
    public function individualHotelRatesAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            $this->view->intAccomSysId = $intAccomSysId = $this->getRequest()->getParam('intAccomSysId');
            
            
            $objHotel = new Travel_Model_TblHotel();
            $arrRoomTypes = $objHotel->getAccomodationRoomTypes($intAccomSysId);
            
            $this->view->isRoomExists = ( count($arrRoomTypes) == 0 ? false : true ) ;
        }
    }
    
    public function individualHotelRoomRatesAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
              
        if($this->_request->isXmlHttpRequest()) {
            
            $this->view->intAccomSysId = $intAccomSysId = $this->getRequest()->getParam('intAccomSysId');
            
            if(!empty($intAccomSysId)) {
            
                $objHotel = new Travel_Model_TblHotel();
                $objHotel->intAccomSysId = $intAccomSysId;
                $arrHotelInfo = $objHotel->getHotelListDetails();
                $this->view->arrHotelRoomsInfo = $objHotel->getHotelRoomsInventory($intAccomSysId);
                if(count($arrHotelInfo) <> 1 ) {
                    throw new Exception('Hotel information not found.');
                }
                $this->view->strHotelInfo = $arrHotelInfo[0]['Title'] .", " . $arrHotelInfo[0]['CityName'] ;

                //Get hotel room type list
                $this->view->arrHotelRoomTypes = $objHotel->getAvailableRoomTypes($intAccomSysId);
                
                //Get hotel meals type list
                $objHotelMeals = new Travel_Model_TblHotelMeals();
                $this->view->arrHotelMeals = $objHotelMeals->getMealTypes();
                
                //Get supplier type
                $objSupplier = new Travel_Model_TblSupplier();
                $this->view->SupplierTypeSysId = $objSupplier->SupplierTypeSysId = 4;
            
                $this->view->arrAccoRoomTypes = $arrAccoRoomTypes = $objHotel->getAccomodationRoomTypes($intAccomSysId);
            }
            
//            echo "<pre>";
//            print_r($arrAccoRoomTypes);
//            exit;
            
        }
        
    }
    
    public function addInventoryAccomRoomRatesAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $post = $this->getRequest()->getPost();
            
//            echo "<pre>";
//            print_r($post);
//            exit;
            
            $form  =  $this->getRequest()->getParam('form');
            
            $mealPlan           = '0';
            $intPermission      = '0';
            $intCurrency        = isset($post['currency_type']) ? $post['currency_type'] : '0';
            $intSupplierSysId   = '0';
            $title              = '';
            
            $strFromDate = isset($post['from_dt']) ? $post['from_dt'] : '';
            $strToDate   = isset($post['to_dt']) ? $post['to_dt'] : '';
            $intRoomType = isset($post['room_type']) ? $post['room_type'] : '0';
            $intMealPlan = isset($post['meal_plan']) ? $post['meal_plan'] : '0';
            $intDailyRoomLimit = isset($post['daily_room_limit']) ? $post['daily_room_limit'] : '0';
            
            $rateType           = isset($post['rate_type'])     ? $post['rate_type']  : 'RR';
            
            $fltCostDoubleOccupancy  = !empty($post['cost_double_occupancy']) ? $post['cost_double_occupancy'] : '0';
            $fltCostSingleOccupancy  = !empty($post['cost_single_occupancy']) ? $post['cost_single_occupancy'] : '0';
            $fltCostExtraWithBed     = !empty($post['cost_extra_with_bed'])   ? $post['cost_extra_with_bed']   : '0';
            $fltCostExtraWithoutBed  = !empty($post['cost_extra_without_bed'])? $post['cost_extra_without_bed']: '0';
            
            if($rateType == 'RR') {
                $fltRackCommission    = !empty(@$post['rack_commission']) ? @$post['rack_commission'] : '0';
                
                if(empty(@$fltRackCommission)) {
                    $response = array('success' => false, 'msg' => 'Please enter Rack Commission.');
                    echo json_encode($response);
                    exit;
                }
            } else {
                $fltRackCommission = 0;
            }
            
            
            $fltNetCostDoubleOccupancy  = !empty($post['net_cost_double_occupancy']) ? $post['net_cost_double_occupancy'] : '0';
            $fltNetCostSingleOccupancy  = !empty($post['net_cost_single_occupancy']) ? $post['net_cost_single_occupancy'] : '0';
            $fltNetCostExtraWithBed     = !empty($post['net_cost_extra_with_bed'])   ? $post['net_cost_extra_with_bed']   : '0';
            $fltNetCostExtraWithoutBed  = !empty($post['net_cost_extra_without_bed'])? $post['net_cost_extra_without_bed']: '0';
            $fltNetTax                  = !empty($post['net_tax'])                   ? $post['net_tax']: '0';
            $intSelectedHotelId         = !empty($post['hidden_selected_hotel_id'])  ? $post['hidden_selected_hotel_id']: '0';
            $InvnItemSysId              = !empty($post['InvnItemSysId'])  ? $post['InvnItemSysId']: '0';
            $hotelName                  = isset($post['hotel_name'])    ? $post['hotel_name'] : '';
            $roomName                   = isset($post['room_name'])     ? $post['room_name']  : '';
            $tax                        = !empty($post['tax'])          ? $post['tax']        : '0';
            
            
            if(empty($intSelectedHotelId)) {
                $response = array('success' => false, 'msg' => 'Please choose the Hotel from the list or click on "Add New".');
                echo json_encode($response);
                exit;
            }

            if($intRoomType==0) {
                $response = array('success' => false, 'msg' => 'Please select room type.');
                echo json_encode($response);
                exit;
            }
            
            if($intMealPlan==0) {
                $response = array('success' => false, 'msg' => 'Please select meal plan.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($intDailyRoomLimit) ) {
                $response = array('success' => false, 'msg' => 'Please enter daily room limit.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($strFromDate) || $strFromDate == EMPTY_DATE_FIELD ) {
                $response = array('success' => false, 'msg' => 'Please enter From Date.');
                echo json_encode($response);
                exit;
            }

            if(empty($strToDate) || $strToDate == EMPTY_DATE_FIELD ) {
                $response = array('success' => false, 'msg' => 'Please enter To Date.');
                echo json_encode($response);
                exit;
            }
              
            if(empty($intCurrency) ) {
                $response = array('success' => false, 'msg' => 'Please select currency.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($fltCostDoubleOccupancy) ) {
                $response = array('success' => false, 'msg' => 'Please enter double Occupancy cost.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($fltNetCostDoubleOccupancy) ) {
                $response = array('success' => false, 'msg' => 'Please enter Net double Occupancy cost.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($fltNetCostDoubleOccupancy) ) {
                $response = array('success' => false, 'msg' => 'Please enter Net double Occupancy cost.');
                echo json_encode($response);
                exit;
            }
            
            if(!empty($fltCostDoubleOccupancy) ) {
                if(empty($fltNetCostDoubleOccupancy) ) {
                    $response = array('success' => false, 'msg' => 'Please enter Net double Occupancy cost.');
                    echo json_encode($response);
                    exit;
                }
            }
            
            if(!empty($fltCostSingleOccupancy) ) {
                if(empty($fltNetCostSingleOccupancy) ) {
                    $response = array('success' => false, 'msg' => 'Please enter Net Single Occupancy cost.');
                    echo json_encode($response);
                    exit;
                }
            }
            
            if(!empty($fltCostExtraWithBed) ) {
                if(empty($fltNetCostExtraWithBed) ) {
                    $response = array('success' => false, 'msg' => 'Please enter Net Extra with bed cost.');
                    echo json_encode($response);
                    exit;
                }
            }
            
            if(!empty($fltCostExtraWithoutBed) ) {
                if(empty($fltNetCostExtraWithoutBed) ) {
                    $response = array('success' => false, 'msg' => 'Please enter Net Extra without bed cost.');
                    echo json_encode($response);
                    exit;
                }
            }
            
            if( ($fltCostDoubleOccupancy < $fltNetCostDoubleOccupancy)  && (!empty($fltCostDoubleOccupancy))) {
                $response = array('success' => false, 'msg' => 'Net rate of double occupancy must be less than Rack rate of double occupancy.');
                echo json_encode($response);
                exit;
            }
            
            if( ($fltCostSingleOccupancy < $fltNetCostSingleOccupancy)  && (!empty($fltCostSingleOccupancy))) {
                $response = array('success' => false, 'msg' => 'Net rate of single occupancy must be less than Rack rate of single occupancy.');
                echo json_encode($response);
                exit;
            }
            
            if( ($fltCostExtraWithBed < $fltNetCostExtraWithBed)  && (!empty($fltCostExtraWithBed))) {
                $response = array('success' => false, 'msg' => 'Net rate of extra with bed must be less than Rack rate of extra with bed.');
                echo json_encode($response);
                exit;
            }
            
            if( ($fltCostExtraWithoutBed < $fltNetCostExtraWithoutBed)  && (!empty($fltCostExtraWithoutBed))) {
                $response = array('success' => false, 'msg' => 'Net rate of extra without bed must be less than Rack rate of extra without bed.');
                echo json_encode($response);
                exit;
            }
            
                
            
            /* If entry from bulk form */
            if(!empty($form) && $form == 'bulk') {
               
                $RoomTypeId         = $post['room_type'];
                $mealPlan           = !empty($post['meal_plan'])     ? $post['meal_plan'] : '0';
                $intPermission      = !empty($post['permission'])    ? $post['permission'] : '0';
                $supplier_name      = !empty($post['supplier_name'])    ? $post['supplier_name'] : '';
                $intSupplierSysId   = !empty($post['hidden_selected_supplier_sys_id']) ? $post['hidden_selected_supplier_sys_id'] : '0';
                $title              = !empty($post['room_name'])     ? $post['room_name'] : '';
                
                $intAccomSysId      = $this->getRequest()->getParam('hidden_selected_hotel_id');
                $InvnItemSysId      = $this->getRequest()->getParam('InvnItemSysId');
                
              
                
//                if(empty($title)) {
//                    $response = array('success' => false, 'msg' => 'Please enter room name.');
//                    echo json_encode($response);
//                    exit;
//                }
                
                if(empty($RoomTypeId)) {
                    $response = array('success' => false, 'msg' => 'Please select room type.');
                    echo json_encode($response);
                    exit;
                }
                
                if(empty($mealPlan)) {
                    $response = array('success' => false, 'msg' => 'Please select meal plan.');
                    echo json_encode($response);
                    exit;
                }
                
                if(empty($supplier_name) || $intSupplierSysId==0) {
                    $response = array('success' => false, 'msg' => 'Please enter supplier name.');
                    echo json_encode($response);
                    exit;
                }
                
            }else {
                $intAccomSysId  = $post['intAccomSysId'];
                $RoomTypeId     = $post['RoomTypeId'];
            }
            
                    
            $strFromDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strFromDate,'d/m/y');
            $strToDate   = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($strToDate,'d/m/y');
            
            $isGreater = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->isGreater($strFromDate, $strToDate);
            
            if($isGreater == 1 ) {
                $response = array('success' => false, 'msg' => 'To Date must be greater than From Date');
                echo json_encode($response);
                exit;
            }
            
            $currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            
            $intLastInsertedRoomId = 0 ;
            
            $approveDate = (@$this->intLoggedinUserId != ADMIN_ID) ? '' : $currentDate;
            $isApproved  = (@$this->intLoggedinUserId != ADMIN_ID) ? 0 : 1;
            $isActive    = (@$this->intLoggedinUserId != ADMIN_ID) ? 0 : 1;
            /* Check if Accomodation already exists  in database. If not exists then add */
            if(empty($intAccomSysId)){
                  $newAccomodation = array('IsAgentSpec'         => true, 'ICSourceSysId' => '0', 
                            'Title'                     => $hotelName,
                            'AccomGrSysId'              => '0',
                            'AliasAndMeta'              => '',
                            'ShortName'                 => '',
                            'PlaceSysId_XRef'           => '0',
                            'Icon'                      => '',
                            'ThumnailImg'               => '',
                            'DetailImg'                 => '',
                            'Stars'                     => '0',
                            'Rating'                    => '0',
                            'Popularity'                => '0',
                            'AwardRecognizations'       => '',
                            'PropertyType'              => '0',
                            'EconomyType'               => '0',
                            'AccoAminitiesMask'         => '',
                            'MaxPaxCount'               => '0',
                            'RoomCounts'                => '0',
                            'Brief'                     => '',
                            'CheckinTime'               => '',
                            'CheckOutTime'              => '',
                            'IsDayLightApp'             => '',
                            'GeoLat'                    => '',
                            'GeoLong'                   => '',
                            'Address'                   => '',
                            'PinCode'                   => '',
                            'CitySysId'                 => '0',
                            'ZoneSysId'                 => '0',
                            'ZoneType'                  => '0',
                            'StateSysId'                => '0',
                            'ContSysId'                 => '0',
                            'UpdateDate'                => $currentDate,
                            'ApproveDate'               => $approveDate,//'',
                            'ApproveBy'                 => '0',
                            'CreateDate'                => $currentDate,
                            'IsApproved'                => $isApproved,//'0',
                            'IsActive'                  => $isActive,//'0',
                            'IsMarkForDel'              => '0'
                        );
            
                $objHotel = new Travel_Model_TblHotel();
                $intLastInsertId = $objHotel->addAccomodation($newAccomodation) ;
                $XRefAccoSysId = $intLastInsertId;
                
                /* Add room to accomodation */
                $newRoomData = array('AccomSysId' => $intAccomSysId, 'SourceSysId' => $this->InfoSourceSysId,
                        'Title' => $roomName, 'RoomType' => $RoomTypeId, 'EconomyType' => '0',
                        'Qty' => 0, 'BedType' => '0', 'PaxCount' => '0', 'IsPetAllow' => 0,
                        'MaxPetAllow' => '0', 'AllowChild' => '0', 'AllowInfant' => '0',
                        'MaxPaxCount' => '0', 'MaxAllowChild' => 0, 'MaxAllowInfant' => 0,
                        'MealPlanType' => '0', 'AminitiesMask' => '', 'InclustionOptionsMask' => '',
                        'OtherDetails' => '', 'UpdatedDate' => $currentDate, 'ApproveDate' => EMPTY_DATE,
                        'CreateDate' => $currentDate, 'ApproveDate' => EMPTY_DATE, 'ApproveBy' => 0,
                        'IsDelete' => '0', 'IsActive' => 0, 'IsApproved' => '0');
                $intLastInsertedRoomId = $objHotel->addIndividualHotelRoomsInventory($newRoomData);
                $XRefItemSysId = $intLastInsertedRoomId;
            } else {
                $XRefAccoSysId = $intAccomSysId;
                $objHotel = new Travel_Model_TblHotel();
                $XRefItemSysId = $objHotel->getICAccomodationItemSysId($intAccomSysId, $RoomTypeId);
            }
            
            $objAgent = new Travel_Model_TblAgency();
            $TrxCurrency = $objAgent->getAgentTxnCurrency($this->intLoggedinUserAgencySysId);
            
            //Get Sipplier Masking
            if($intSupplierSysId!="" && $intSupplierSysId!=0)
            {
              $objSupplier = new Travel_Model_TblSupplier();
              $supplierDetails = $objSupplier->getSupplierList($intSupplierSysId);
              $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, $intSupplierSysId);
            }
            
            $inventoryAccomodationData = array('InventoryType' => HOTEL_INVENTORY_TYPE_ID, 
                    'XRefAccoSysId' => $XRefAccoSysId,
                    'XRefItemSysId' => $XRefItemSysId,
                    'AgencySysId' => $this->intLoggedinUserAgencySysId, 
                    'SupplierSysId' =>  $intSupplierSysId, 'Title' => $title,
                    'EconomyType' => $RoomTypeId, 'MealPlanType' => $mealPlan, 'IxFixedDateInven' => '0',
                    'FromDate' => $strFromDate, 'ToDate' => $strToDate, 'DailyRoomLimit' => $intDailyRoomLimit,'PurchasedQty' => 0,
                    'PublishQty' => 0, 'BlockQty' => 0, 'SoldQty' => 0, 'ReturnQty' => 0, 'NetInHandQty' => 0,
                    'CostCurrency' => $intCurrency, 'TrxCurrency' => $TrxCurrency,  'IsPerPaxCostAllowed' => '', 'RateType' => $rateType, 
                    'PerPaxCost' => 0, 'DOccupCost' => $fltCostDoubleOccupancy, 'RackCommission' => $fltRackCommission,
                    'SOccupCost' => $fltCostSingleOccupancy, 'ExtraBedCost' => $fltCostExtraWithBed, 'ExtraWOBedCost' => $fltCostExtraWithoutBed,
                    'NetDOccupCost' => $fltNetCostDoubleOccupancy, 'NetSOccupCost' => $fltNetCostSingleOccupancy, 
                    'NetExtraBedCost' => $fltNetCostExtraWithBed, 'NetExtraWOBedCost' => $fltNetCostExtraWithoutBed,
                    'Tax' => $tax, 'NetTax' => $fltNetTax,
                    'OtherCost' => '0', 'SaleAmount' => '0', 'DefaultPrice' => 0, 'Brief' => '', 'IfAnyOffer' => '0',
                    'OfferMsg' => '', 'OfferImage' => '','CreatorSysId' => $this->intLoggedinUserId, 'CreateDate' => $currentDate, 'ApproveDate' => '',
                    'UpdateDate' => $currentDate, 'IsActive' => $intPermission, 'IsMarkForDelete' => 0, 'IsApproved' => '0'
            );
    
            
            $objHotel = new Travel_Model_TblHotel();
            // $intLastInsertId  = $objHotel->addInventoryAccomRoomRates($insertData);
            
//            echo "<pre>";
//            print_r($inventoryAccomodationData);
//            exit;
            
            if($InvnItemSysId!="" && $InvnItemSysId!=0)
            {
              $objHotel->updateMPInventoryAccom($InvnItemSysId, $inventoryAccomodationData); 
              $intLastInsertId = $InvnItemSysId;
            } else { 
              $intLastInsertId = $objHotel->addMPInventoryAccom($inventoryAccomodationData); 
            }
            
            if(!empty($intLastInsertId)) {
                $response = array('success' => true, 'intLastInsertId' => $intLastInsertId);
            }else {
                $response = array('success' => false);
            }
            
            echo json_encode($response);
            exit;
            
//            echo "<pre>";
//            print_r($post);
//            exit;
            
        }
        
    }
    
    public function individualHotelRateRulesAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $this->view->intAccomSysId = $intAccomSysId = $this->getRequest()->getParam('intAccomSysId');
            
            
        }
        
    }
    
    public function individualHotelAmenitiesAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            $this->view->intAccomSysId = $intAccomSysId = $this->getRequest()->getParam('intAccomSysId');
            
            if(!empty($intAccomSysId)) {
            
                $objHotel = new Travel_Model_TblHotel();
                $objHotel->intAccomSysId = $intAccomSysId;
                $arrHotelInfo = $objHotel->getHotelListDetails();
                $this->view->arrHotelRoomsInfo = $objHotel->getHotelRoomsInventory($intAccomSysId);
                if(count($arrHotelInfo) <> 1 ) {
                    throw new Exception('Hotel information not found.');
                }
                $this->view->strHotelInfo = $arrHotelInfo[0]['Title'] .", " . $arrHotelInfo[0]['CityName'] ;

                $objHotel = new Travel_Model_TblHotel();
                $objHotel->orderByField = " TB_Master_Accom_AccomAminity.AminityId ";
				$objHotel->orderBy="";

                $this->view->arrMasterAccomAminities = $objHotel->getMasterAccomAminities();

                $this->view->arrSelectedAmenities = $objHotel->getMasking($intAccomSysId);
            }
        }
    }
    
    public function individualHotelSuppliersAction() {
        
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            $this->view->intAccomSysId = $intAccomSysId = $this->getRequest()->getParam('intAccomSysId');
            $objSuppliers = new Travel_Model_TblSupplier();
            $objSuppliers->orderByField = " TB_IC_Supplier.SupplierSysId ";
            $objSuppliers->orderBy      = " DESC ";
            $this->view->arrSuppliers = $objSuppliers->getSuppliers();
        }
        
    }
    
    public function individualHotelTermsConditionsAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            $this->view->intAccomSysId = $intAccomSysId = $this->getRequest()->getParam('intAccomSysId');
            
            $objHotel = new Travel_Model_TblHotel();
            $this->view->terms = $objHotel->getTermsNConditions($intAccomSysId);
        }
        
    }
    
    
    public function getCountryAutoSearchAction() {
        
        $this->_helper->layout->disableLayout();
        if ($this->getRequest()->isXmlHttpRequest()) { 

            $strCountryName     = $this->getRequest()->getParam('term');
            
            $objHotel = new Travel_Model_TblHotel();
            $result = $objHotel->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 autosuggestAction() {
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
        
        $arrResponse = array();
        if($this->getRequest()->getParam("term")) {
            $term = $this->getRequest()->getParam("term");
            $strcountryId     = $this->getRequest()->getParam('countryId');

            $objHotel = new Travel_Model_TblHotel();
            $arrResponse = $objHotel->getAutoSuggest($term, $strcountryId, $this->intLoggedinUserAgencySysId);
        }
        echo json_encode( $arrResponse );

    }
    
    
    public function autosuggestAgentAction() {
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
        
        $arrResponse = array();
        if($this->getRequest()->getParam("term")) {
            $term = $this->getRequest()->getParam("term");

            $objHotel = new Travel_Model_TblHotel();
            $arrResponse = $objHotel->getAutoSuggestByAgent($term, $this->intLoggedinUserAgencySysId);
        }
        echo json_encode( $arrResponse );

    }
    
    
    public function addHotelRoomAmenitiesAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $amenities  = $this->getRequest()->getParam('Amenities');
            $AccomSysId = $this->getRequest()->getParam('AccomSysId');
            
            $objHotel = new Travel_Model_TblHotel();
            $objHotel->addAccomodationRoomAmenities($AccomSysId, $amenities);
            
            $response = array('success' => true);
            echo json_encode($response);
            exit;
        }
    }
    
    
    public function saveIndividualHotelOverviewAction()  {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $data = $this->getRequest()->getPost();
            
            //echo "<pre>"; print_r($data);die;
            
            $objHotel = new Travel_Model_TblHotel();
            
            $currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            
            $hotelId       = isset($data['hidden_selected_hotel_id']) ? trim($this->sanitize_data($data['hidden_selected_hotel_id'])) : '0';
            if($hotelId!=0 && $hotelId!="")
            {
                $hotelName     = isset($data['edit_hotel_name']) ? trim($this->sanitize_data($data['edit_hotel_name'])) : '';
            } else {
                $hotelName     = isset($data['hotel_name']) ? trim($this->sanitize_data($data['hotel_name'])) : '';
            }
            
            $hotel_chain   = isset($data['hotel_chain']) ? trim($this->sanitize_data($data['hotel_chain'])) : '';
            $intCountryId  = isset($data['select-hotel-country']) ? trim($this->sanitize_data($data['select-hotel-country'])) : '';
            $intCityId     = isset($data['select-hotel-city']) ? trim($this->sanitize_data($data['select-hotel-city'])) : '';
            $intHotelType  =  isset($data['hotel-type']) ? trim($this->sanitize_data($data['hotel-type'])) : 0; 
            $GeoLat        =  isset($data['latitude']) ? trim($this->sanitize_data($data['latitude'])) : 0; 
            $GeoLong       =  isset($data['longitude']) ? trim($this->sanitize_data($data['longitude'])) : 0; 
            
            if(empty($hotelName) && $hotelId==0) {
                $response = array('success' => false, 'msg' => 'Please enter hotel name.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($intHotelType)) {
                $response = array('succes' => false, 'msg' => 'Please select accomodation type.');
                echo json_encode($response);
                exit;
            }
//            if(!isset($data['hotel-room-types']) || count($data['hotel-room-types']) == 0 ) {
//                $response = array('succes' => false, 'msg' => 'Please select atleast one room type.');
//                echo json_encode($response);
//                exit;
//            }
            //$arrHotelRoomIds = $objHotel->getHotelRoomIdsList($hotelId);
            //echo "<pre>"; print_r($data['hotel-room-types']);
            //echo "<pre>"; print_r($arrHotelRoomIds);
            //die;
            
//            if(count($arrHotelRoomIds) > count($data['hotel-room-types'])) {
//                $response = array('success' => false, 'msg' => 'The hotel room type are different from your previous selection');
//                echo json_encode($response);
//                exit;
//            }
            
            if(empty($intCountryId)) {
                $response = array('success' => false, 'msg' => 'Please choose the country.');
                echo json_encode($response);
                exit;
            }
            
            if(empty($intCityId)) {
                $response = array('success' => false, 'msg' => 'Please choose the city..');
                echo json_encode($response);
                exit;
            }
            
            $arrHotelDetail = $objHotel->getHotelListDetailsByHotelId($hotelId);
            
            
            $db_IsAgentSpec = $arrHotelDetail['IsAgentSpec'];
            $Brief = trim($arrHotelDetail['Brief']);
            $Address = trim($arrHotelDetail['Address']);
            $PinCode = trim($arrHotelDetail['PinCode']);
            $db_CreateDate = $arrHotelDetail['CreateDate'];
            $db_IsLocked = $arrHotelDetail['IsLocked'];
            $db_ApproveDate = $arrHotelDetail['ApproveDate'];
            $db_ApproveBy = $arrHotelDetail['ApproveBy'];
            $db_IsApproved = $arrHotelDetail['IsApproved'];
            $db_IsActive = $arrHotelDetail['IsActive'];
            $db_IsMarkForDel = $arrHotelDetail['IsMarkForDel'];
            
            
            //Add and edit parameter 
            if($arrHotelDetail['ResultIndex']!="") {
                $ResultIndex = $arrHotelDetail['ResultIndex'];
            } else {
                $ResultIndex= '';
            }
            if($arrHotelDetail['TraceId']!="") {
                $TraceId = $arrHotelDetail['TraceId'];
            } else {
                $TraceId= '';
            }
            if($arrHotelDetail['TokenId']!="") {
                $TokenId = $arrHotelDetail['TokenId'];
            } else {
                $TokenId= '';
            }
            if($arrHotelDetail['AliasAndMeta']!="") {
                $AliasAndMeta = $arrHotelDetail['AliasAndMeta'];
            } else {
                $AliasAndMeta= '';
            }
            if($arrHotelDetail['ShortName']!="") {
                $ShortName = $arrHotelDetail['ShortName'];
            } else {
                $ShortName= '';
            }
            if($arrHotelDetail['PlaceSysId_XRef']!="") {
                $PlaceSysId_XRef = $arrHotelDetail['PlaceSysId_XRef'];
            } else {
                $PlaceSysId_XRef= '0';
            }
            if($arrHotelDetail['Icon']!="") {
                $Icon = $arrHotelDetail['Icon'];
            } else {
                $Icon= '';
            }
            if($arrHotelDetail['ThumnailImg']!="") {
                $ThumnailImg = $arrHotelDetail['ThumnailImg'];
            } else {
                $ThumnailImg= '';
            }
            if($arrHotelDetail['DetailImg']!="") {
                $DetailImg = $arrHotelDetail['DetailImg'];
            } else {
                $DetailImg= '';
            }
            if($arrHotelDetail['DetailImg']!="") {
                $DetailImg = $arrHotelDetail['DetailImg'];
            } else {
                $DetailImg= '';
            }
            if($arrHotelDetail['Rating']!="") {
                $Rating = $arrHotelDetail['Rating'];
            } else {
                $Rating= '0';
            }
            if($arrHotelDetail['Popularity']!="") {
                $Popularity = $arrHotelDetail['Popularity'];
            } else {
                $Popularity= '0';
            }
            if($arrHotelDetail['AwardRecognizations']!="") {
                $AwardRecognizations = $arrHotelDetail['AwardRecognizations'];
            } else {
                $AwardRecognizations= '';
            }
            if($arrHotelDetail['AccoAminitiesMask']!="") {
                $AccoAminitiesMask = $arrHotelDetail['AccoAminitiesMask'];
            } else {
                $AccoAminitiesMask= '';
            }
            
//            if($arrHotelDetail['GeoLat']!="") {
//                $GeoLat = $arrHotelDetail['GeoLat'];
//            } else {
//                $GeoLat= '';
//            }
//            if($arrHotelDetail['GeoLong']!="") {
//                $GeoLong = $arrHotelDetail['GeoLong'];
//            } else {
//                $GeoLong= '';
//            }
            
            $insert = array('IsAgentSpec'               => !empty($db_IsAgentSpec) ? $db_IsAgentSpec : '1', 
                            'ICSourceSysId'             => $this->intLoggedinUserAgencySysId, 
                            'Title'                     => $hotelName,
                            'ResultIndex'               => $ResultIndex,
                            'TraceId'                   => $TraceId,
                            'TokenId'                   => $TokenId,
                            'AliasAndMeta'              => $AliasAndMeta,
                            'ShortName'                 => $ShortName,
                            'PlaceSysId_XRef'           => $PlaceSysId_XRef,
                            'Icon'                      => $Icon,
                            'ThumnailImg'               => $ThumnailImg,
                            'DetailImg'                 => $DetailImg,
                            'Stars'                     => !empty($data['star-rating']) ? trim($this->sanitize_data($data['star-rating'])) : '0',
                            'Rating'                    => $Rating,
                            'Popularity'                => $Popularity,
                            'AwardRecognizations'       => $AwardRecognizations,
                            'PropertyType'              => '0',
                            'EconomyType'               => !empty($data['hotel-type']) ? trim($this->sanitize_data($data['hotel-type'])) : '',
                            'AccoAminitiesMask'         => $AccoAminitiesMask,
                            'MaxPaxCount'               => '0',
                            'RoomCounts'                => '0',
                            'Brief'                     => !empty($data['brief']) ? trim($this->sanitize_data($data['brief'])) : $Brief,
                            'CheckinTime'               => !empty($data['CheckinTime']) ? trim($this->sanitize_data($data['CheckinTime'])) : @$this->sanitize_data($data['CheckinTime']),
                            'CheckOutTime'              => !empty($data['CheckOutTime']) ? trim($this->sanitize_data($data['CheckOutTime'])) : @$this->sanitize_data($data['CheckOutTime']),
                            'IsDayLightApp'             => '0',
                            'GeoLat'                    => $GeoLat,
                            'GeoLong'                   => $GeoLong,
                            'Address'                   => !empty($data['address']) ? trim($this->sanitize_data($data['address'])) : @$Address,
                            'PinCode'                   => !empty($data['pinCode']) ? trim($this->sanitize_data($data['pinCode'])) : @$PinCode,
                            'CitySysId'                 => $intCityId,
                            'ZoneSysId'                 => '0',
                            'ZoneType'                  => '0',
                            'StateSysId'                => isset($data['select-hotel-state']) ? trim($this->sanitize_data($data['select-hotel-state'])) : '',
                            'ContSysId'                 => $intCountryId,
                            //'PrimaryContact'            => isset($hotel_details['PrimaryContact']) ? $hotel_details['PrimaryContact'] : '',
                            //'SecondaryContact'          => isset($hotel_details['SecondaryContact']) ? $hotel_details['SecondaryContact'] : '',
                            //'OtherContacts'             => isset($hotel_details['OtherContacts']) ? $hotel_details['OtherContacts'] : '',
                            'UpdateDate'                => $currentDate,
                            'ApproveDate'               => !empty($db_ApproveDate) ? $db_ApproveDate : '',
                            'ApproveBy'                 => !empty($db_ApproveBy) ? $db_ApproveBy : '0',
                            'CreateDate'                => !empty($db_CreateDate) ? $db_CreateDate : $currentDate,
                            'IsLocked'                  => !empty($db_IsLocked) ? $db_IsLocked : '1',
                            'IsApproved'                => !empty($db_IsApproved) ? $db_IsApproved : '0',
                            'IsActive'                  => !empty($db_IsActive) ? $db_IsActive : '1',
                            'IsMarkForDel'              => !empty($db_IsMarkForDel) ? $db_IsMarkForDel : '0'
                        );
            
            //echo "<pre>"; print_r($insert);die;
            
            if(!empty($hotelId) && $hotelId!=0)
            {
                //echo "dssd sdfds sdas";die;
                $objHotel->updateAccomodationInfo($insert, $hotelId);
                if($data['hotel_chain'])
                {
                    $objHotel->updateAccomodationGroupInfo(trim($this->sanitize_data($data['hotel_chain'])), $hotelId);
                }
                $intLastInsertId = $hotelId;
            } else {
                //echo "dssd sdfds";die;
                $intLastInsertId = $objHotel->addAccomodation($insert, trim($this->sanitize_data($data['hotel_chain'])));
                $AccomSysId = $intLastInsertId; 
            }
            
            //echo $intLastInsertId; die;
            if(!empty($AccomSysId) && $hotelId==0) {
                /*Add Rooms */
                if(isset($data['hotel-room-types']) && count($data['hotel-room-types']) > 0 )
                {
                    foreach($data['hotel-room-types'] as $roomType) {

                        $insert = array(
                                'AccomSysId'       => $AccomSysId,
                                'SourceSysId'       => $this->InfoSourceSysId,
                                'Title'             => '',
                                'RoomType'          => $roomType,
                                'EconomyType'       => 0,
                                'Qty'               => 0,
                                'BedType'           => 0,
                                'PaxCount'          => 0,
                                'IsPetAllow'        => 0,
                                'MaxPetAllow'       => 0,
                                'AllowChild'        => 0,
                                'AllowInfant'       => 0,
                                'MaxPaxCount'       => 0,
                                'MaxAllowChild'     => 0,
                                'MaxAllowInfant'    => 0,
                                'MealPlanType'      => 0,
                                'AminitiesMask'     => '',
                                'InclustionOptionsMask' => '',
                                'OtherDetails'      => '',
                                'UpdatedDate'       => $currentDate,
                                'CreateDate'        => $currentDate,
                                'ApproveDate'       => EMPTY_DATE,
                                'ApproveBy'         => 0,
                                'IsDelete'          => 0,
                                'IsActive'          => '1',
                                'IsApproved'        => '0'
                        );

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

                        $objHotel = new Travel_Model_TblHotel();
                        $intNewItemId = $objHotel->addICAccomdationRoom($insert);

                        if(empty($intNewItemId)) {
                            $response = array('success' => false, 'msg' => TECHNICAL_ERROR_MSG);
                            echo json_encode($response);
                            exit;
                        }

                    }
                }
                /***********************************************************************/
            }
            //echo $intLastInsertId; die;
            if(!empty($intLastInsertId)) {
                $response = array('success' => true, 'intLastInsertId' => $intLastInsertId);
                echo json_encode($response);
                exit;
            } else {
                $response = array('success' => false,'msg' => TECHNICAL_ERROR_MSG);
                echo json_encode($response);
                exit;
            }
      
//            echo "<pre>";
//            print_r($data);
//            exit;
        }
            
        
    }
    
    
    public function deleteMpInventoryAccomAction() {
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $InvnItemSysId  = $this->getRequest()->getParam('InvnItemSysId');
            
            $objHotel = new Travel_Model_TblHotel();
            $objHotel->deleteMpInventoryAccom($InvnItemSysId);
            
            $response = array('success' => true);
            echo json_encode($response);
            exit;
        }
    }
    
    public function saveTermsAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        
        
        if($this->_request->isXmlHttpRequest()) {
            
            $AccomSysId = $this->getRequest()->getParam('AccomSysId');
            $terms      = $this->getRequest()->getParam('terms');
            
            $objHotel = new Travel_Model_TblHotel();
            
            $currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            
            
            if($objHotel->isTermsNConditionsExists($AccomSysId)) {
                $update = array('Writeup' => $terms);
                $objHotel->updateTermsConditions($AccomSysId, $update);
            }else {
                $insert = array('AccomSysId' => $AccomSysId, 'Title' => '', 'Details' => '', 'Writeup' => $terms, 'ArtifectType' => '1', 
                    'XUrl' => '', 'UpdateDate' => $currentDate, 'CreateDate' => $currentDate, 'IsActive' => '1', 'IsMarkForDel' => '0' );
                $objHotel->addTermsConditions($insert);
            }
            
            $response = array('success' => true);
            echo json_encode($response);
            exit;
        }
        
    }
    
    public function populateAccoRoomTypeAction() {
        
        /* Disable Layout */
        $this->_helper->layout->disableLayout();
        //$this->_helper->viewRenderer->setNoRender(true);
        
        if($this->_request->isXmlHttpRequest()) {
            $AccomSysId = $this->getRequest()->getParam('AccomSysId');
            $objHotel = new Travel_Model_TblHotel();
            
            if(!empty($AccomSysId)) {
                $arrRoomTypes = $objHotel->getAvailableRoomTypes($AccomSysId);
            } else {
                $arrRoomTypes = $objHotel->getMasterRoomType();
            }
            
            $options = '';
            if(!empty($arrRoomTypes)) {
                foreach($arrRoomTypes as $type) {
                    $options .= '<option value="'.$type['RoomTypeId'].'">'.$type['RoomType'].'</option>';
                }
            }else {
                $options .= '<option value="0">No data available</option>';
            }
            echo  $options;
            exit;
        }
    }
    
    
    public function cloneMpInventoryAccomAction() {
        
        if($this->_request->isXmlHttpRequest()) {
            $InvnItemSysId = $this->getRequest()->getParam('InvnItemSysId');
            $objHotel = new Travel_Model_TblHotel();
            $intNewInvnItemSysId = $objHotel->cloneMPInventoryAccom($InvnItemSysId);
            
            $response = array('success' => true, 'intLastInsertId' => $intNewInvnItemSysId);
            echo json_encode($response);
            exit;
        }
        
    }
    
    public function updateMpInventoryAccomAction() {
        
        if($this->_request->isXmlHttpRequest()) {
            
            $InvnItemSysId          = trim($this->sanitize_data($this->getRequest()->getParam('InvnItemSysId')));
            $room_name              = trim($this->sanitize_data($this->getRequest()->getParam('room_name')));
            $meal_plan              = trim($this->sanitize_data($this->getRequest()->getParam('meal_plan')));
            $daily_room_limit       = trim($this->sanitize_data($this->getRequest()->getParam('daily_room_limit')));
            $from_dt                = trim($this->sanitize_data($this->getRequest()->getParam('from_dt')));
            $to_dt                  = trim($this->sanitize_data($this->getRequest()->getParam('to_dt')));
            $cost_double_occupancy  = trim($this->sanitize_data($this->getRequest()->getParam('cost_double_occupancy')));
            $cost_single_occupancy  = trim($this->sanitize_data($this->getRequest()->getParam('cost_single_occupancy')));
            $cost_extra_without_bed = trim($this->sanitize_data($this->getRequest()->getParam('cost_extra_without_bed')));
            $tax                    = trim($this->sanitize_data($this->getRequest()->getParam('tax')));
            
            $net_cost_double_occupancy  = trim($this->sanitize_data($this->getRequest()->getParam('net_cost_double_occupancy')));
            $net_cost_single_occupancy  = trim($this->sanitize_data($this->getRequest()->getParam('net_cost_single_occupancy')));
            $net_cost_extra_with_bed    = trim($this->sanitize_data($this->getRequest()->getParam('net_cost_extra_with_bed')));
            $net_cost_extra_without_bed = trim($this->sanitize_data($this->getRequest()->getParam('net_cost_extra_without_bed')));
            $net_tax                    = trim($this->sanitize_data($this->getRequest()->getParam('net_tax')));
            $rateType                   = trim($this->sanitize_data($this->getRequest()->getParam('rate_type')));
            $rack_commission            = trim($this->sanitize_data($this->getRequest()->getParam('rack_commission')));
            
            $from_dt = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($from_dt,'d/m/y');
            $to_dt   = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($to_dt,'d/m/y');
            
            if(empty($meal_plan)) {
                $response = array('success' => false, 'msg' => 'Please select meal plan.');
                echo json_encode($response);
                exit;
            }

            if(empty($daily_room_limit) ) {
                $response = array('success' => false, 'msg' => 'Please enter daily room limit.');
                echo json_encode($response);
                exit;
            }

            if(empty($from_dt) || $from_dt == EMPTY_DATE_FIELD ) {
                $response = array('success' => false, 'msg' => 'Please select From Date.');
                echo json_encode($response);
                exit;
            }

            if(empty($to_dt) || $to_dt == EMPTY_DATE_FIELD ) {
                $response = array('success' => false, 'msg' => 'Please select To Date.');
                echo json_encode($response);
                exit;
            }

            $isGreater = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->isGreater($from_dt, $to_dt);
            if($isGreater == 1 ) {
                $response = array('success' => false, 'msg' => 'To Date must be greater than From Date');
                echo json_encode($response);
                exit;
            }
            
            if(empty($cost_double_occupancy) ) {
                $response = array('success' => false, 'msg' => 'Please enter Double Occupancy cost.');
                echo json_encode($response);
                exit;
            }
                        
            if($rateType == 'RR') {
                $fltRackCommission          = $rack_commission;
                
                if(empty(@$fltRackCommission)) {
                    $response = array('success' => false, 'msg' => 'Please enter Rack Commission.');
                    echo json_encode($response);
                    exit;
                }
                if(!empty(@$fltRackCommission) && $fltRackCommission<0) {
                    $response = array('success' => false, 'msg' => 'Rack Commission should not be zero');
                    echo json_encode($response);
                    exit;
                }
                
            } else {
                $fltRackCommission = 0;
            }
            
            if(empty($net_cost_double_occupancy) ) {
                $response = array('success' => false, 'msg' => 'Please enter Net double Occupancy cost.');
                echo json_encode($response);
                exit;
            }
            
            if( ($cost_double_occupancy < $net_cost_double_occupancy)  && (!empty($cost_double_occupancy))) {
                $response = array('success' => false, 'msg' => 'Net rate of double occupancy must be less than Rack rate of double occupancy.');
                echo json_encode($response);
                exit;
            }
            
            if( ($cost_single_occupancy < $net_cost_single_occupancy)  && (!empty($cost_single_occupancy))) {
                $response = array('success' => false, 'msg' => 'Net rate of single occupancy must be less than Rack rate of single occupancy.');
                echo json_encode($response);
                exit;
            }
            
            if( ($net_cost_extra_with_bed < $net_cost_extra_with_bed)  && (!empty($net_cost_extra_with_bed))) {
                $response = array('success' => false, 'msg' => 'Net rate of extra with bed must be less than Rack rate of extra with bed.');
                echo json_encode($response);
                exit;
            }
            
            if( ($cost_extra_without_bed < $net_cost_extra_without_bed)  && (!empty($cost_extra_without_bed))) {
                $response = array('success' => false, 'msg' => 'Net rate of extra without bed must be less than Rack rate of extra without bed.');
                echo json_encode($response);
                exit;
            }
            
            $data = array('Title' => $room_name, 'MealPlanType' => $meal_plan, 'DailyRoomLimit' => $daily_room_limit,
                        'FromDate' => $from_dt, 'ToDate' => $to_dt, 'DOccupCost' => $cost_double_occupancy,
                        'SOccupCost' => $cost_single_occupancy, 'ExtraBedCost' => $cost_extra_with_bed, 'ExtraWOBedCost' => $cost_extra_without_bed,
                        'Tax' => $tax, 'NetDOccupCost' => $net_cost_double_occupancy, 'NetSOccupCost' => $net_cost_single_occupancy,
                        'NetExtraBedCost' => $net_cost_extra_with_bed, 'NetExtraWOBedCost' => $net_cost_extra_without_bed, 'NetTax' => $net_tax,
                        'RackCommission' => $fltRackCommission);
            
            $objHotel = new Travel_Model_TblHotel();
            if( $objHotel->updateMPInventoryAccom($InvnItemSysId, $data)) {
                $response = array('success' => true);
                echo json_encode($response);
                exit;
            } 
            
            $response = array('success' => false);
            echo json_encode($response);
            exit;
        }
    }
    
    
    public function showRoomRatesGridAction() {
        
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $this->view->AccomSysId     = $AccomSysId    = $this->getRequest()->getParam('AccomSysId');
            //$this->view->intRoomTypeId  = $intRoomTypeId = $this->getRequest()->getParam('intRoomTypeId');
            
            if(empty($AccomSysId)) {
                throw new Exception('Accomodation Id not found.');
            }
            
//            if(empty($intRoomTypeId)) {
//                throw new Exception('Room Type Id not found.');
//            }
            
            $objHotel = new Travel_Model_TblHotel();
            //$objHotel->strCondition = " AND TB_MP_Inventory_Accom.EconomyType = ". $intRoomTypeId;
            $objHotel->intAccomSysId = $AccomSysId;
            $this->view->arrRoomRates = $objHotel->getHotelInventoryList();
            
        }
        
    }
    
    
    public function getroomitemidAction() {
        
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $AccomSysId    = $this->getRequest()->getParam('accomSysID');
            $intRoomTypeId = $this->getRequest()->getParam('roomTypeID');
            
            if(empty($AccomSysId)) {
                throw new Exception('Accomodation Id not found.');
            }
            
            if(empty($intRoomTypeId)) {
                throw new Exception('Room Type Id not found.');
            }
            
            $objHotel = new Travel_Model_TblHotel();
            $intRoomTypeId = $objHotel->getRoomItemSysID($AccomSysId,$intRoomTypeId);
            echo $intRoomTypeId;
            exit;
        }
        
    }
    
    
    public function getroommealplanAction() {
        
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $intAccomSysId    = $this->getRequest()->getParam('intAccomSysId');
            $intRoomTypeId = $this->getRequest()->getParam('roomTypeId');
            
            if(empty($intAccomSysId)) {
                throw new Exception('Accomodation Id not found.');
            }
            
            if(empty($intRoomTypeId)) {
                throw new Exception('Room Type Id not found.');
            }
            
            $objHotel = new Travel_Model_TblHotel();
            $intRoomMealPlanList = $objHotel->getRoomMealPlanSysID($intAccomSysId,$intRoomTypeId);
            if(!empty($intRoomMealPlanList))
            {
                $mealPlanSelect = '<option value="0">Select</option>'; 
                foreach($intRoomMealPlanList as $intRoomMealPlan)
                { 
                    $mealPlanSelect .= '<option value="'.$intRoomMealPlan['MealTypeId'].'">'.$intRoomMealPlan['mealPlan'].'</option>'; 
                }
            }
            echo $mealPlanSelect;
            exit;
        }
        
    }
    
    
    
    public function getSearchInventoryHotelAction() {
        
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $cityId    = $this->getRequest()->getParam('cityId');
            
//            if(empty($cityId)) {
//                throw new Exception('City Id not found.');
//            }
            
            if($cityId!="" && $cityId!="0")
            {
                $searchHotelSelect = '';
                $objHotel = new Travel_Model_TblHotel();
                $intSearchHotelList = $objHotel->getHotelInventoryListByCityId($cityId,$this->intLoggedinUserAgencySysId);
                if(!empty($intSearchHotelList))
                {
                    $searchHotelSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script>';
                    $searchHotelSelect .= '<select id="hotelId" name="hotelId" class="demo-default select-ajax-country" placeholder="Select Hotel"><option value="0">Select Hotel</option>'; 
                    foreach($intSearchHotelList as $intSearchHotel)
                    { 
                        $searchHotelSelect .= '<option value="'.$intSearchHotel['hotelId'].'">'.$intSearchHotel['Title'].'</option>'; 
                    }
                    $searchHotelSelect .= '</select>';
                } else {
                    $searchHotelSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script><select id="hotelId" name="hotelId" class="demo-default select-ajax-country" placeholder="Select Hotel"><option value="0">Select Hotel</option></select>'; 
                }
            } else {
                   $searchHotelSelect = '<script src="/public/assets/js/pages/selectAjaxTag.js"></script><select id="hotelId" name="hotelId" class="demo-default select-ajax-country" placeholder="Select Hotel"><option value="0">Select Hotel</option></select>'; 
            }
            echo $searchHotelSelect;
            exit;
        }
    }
    
    
    public function getSearchSupplierHotelAction() {
        
        $this->_helper->layout->disableLayout();
        
        if($this->_request->isXmlHttpRequest()) {
            
            $cityId    = $this->getRequest()->getParam('cityId');
                      
            if($cityId!="" && $cityId!="0")
            {
                $searchSupplierSelect = '';
                $objHotel = new Travel_Model_TblHotel();
                $intSearchSupplierList = $objHotel->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" style="width:320px; height: 35px;"><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;
        }
        
    }
    
    
    
    /**
     * Deactivate Hotel Action. 
     */
    public function deactivateAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objHotel   = new Travel_Model_TblHotel();
        $accomSysId = base64_decode($this->sanitize_data($this->getRequest()->getParam('id'))); 
        
        $isDeactive = $objHotel->setActiveDeactive(" AccomSysId=$accomSysId", "TB_IC_Accomdation",0);             
        $message    = @$isDeactive ? "Hotel deactivated successfully." : "Hotel deactivation failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        if(@$isDeactive)
        {
            $this->_helper->redirector('manage-hotel', 'hotel', 'admin');
//            if($this->intLoggedinUserRole==1)
//            {
//              $this->_helper->redirector('manage-hotel', 'hotel', 'default');
//            } else {
//              $this->_helper->redirector('index', 'hotel', 'default');
//            }
        }
    }
    
    /**
     * Activate Hotel Action. 
     */
    public function activateAction()
    {
        $this->tableName = 'TB_IC_Accomdation';
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objHotel   = new Travel_Model_TblHotel();
        $accomSysId = base64_decode($this->sanitize_data($this->getRequest()->getParam('id'))); 
        
        $isActive   = $objHotel->setActiveDeactive(" AccomSysId=$accomSysId", "TB_IC_Accomdation", 1);          
        $message    = @$isActive ? "Hotel activated successfully." : "Hotel activation failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        
        if(@$isActive)
        {
            $this->_helper->redirector('manage-hotel', 'hotel', 'admin');
//            if($this->intLoggedinUserRole==1)
//            {
//              $this->_helper->redirector('manage-hotel', 'hotel', 'default');
//            } else {
//              $this->_helper->redirector('index', 'hotel', 'default');
//            }
        }
    }
    
    /**
     * Disapprove Hotel Action. 
     */
    public function disapprovedAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objHotel   = new Travel_Model_TblHotel();
        $accomSysId = base64_decode($this->sanitize_data($this->getRequest()->getParam('id'))); 
        $approveDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
        if($this->intLoggedinUserRole!=1)
        {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        $ApproveBy = Travel_Model_AdminAuth::getIdentity()->UserSysId;
        $updateArr = array('ApproveDate' =>$approveDate, 'ApproveBy' =>$ApproveBy, 'IsApproved' =>'0');
        
        $isDisapprove = $objHotel->setApproveDisapprove(" AccomSysId=$accomSysId", "TB_IC_Accomdation", $updateArr);             
        $message    = @$isDisapprove ? "Hotel disapproved successfully." : "Hotel disapproved failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        if(@$isDisapprove)
        {
            $this->_helper->redirector('manage-hotel', 'hotel', 'admin');
        }
    }
    
    
    /**
     * Approve Hotel Action. 
     */
    public function approvedAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objHotel   = new Travel_Model_TblHotel();
        $accomSysId = base64_decode($this->sanitize_data($this->getRequest()->getParam('id'))); 
        $approveDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
        if($this->intLoggedinUserRole!=1)
        {
            $intLoggedinUserId = $this->intLoggedinUserAgencySysId;
        } else {
            $intLoggedinUserId = "";
        }
        $ApproveBy = Travel_Model_AdminAuth::getIdentity()->UserSysId;
        $updateArr = array('ApproveDate' =>$approveDate, 'ApproveBy' =>$ApproveBy, 'IsApproved' =>'1');
        
        $isApprove = $objHotel->setApproveDisapprove(" AccomSysId=$accomSysId", "TB_IC_Accomdation", $updateArr);             
        $message    = @$isApprove ? "Hotel approved successfully." : "Hotel approved failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        if(@$isApprove)
        {
            $this->_helper->redirector('manage-hotel', 'hotel', 'admin'); 
        }
    }
    
    
    /**
     * Stop Sale Hotel Action. 
     */
    public function stopSaleAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objHotel   = new Travel_Model_TblHotel();
        $InvnItemSysId = base64_decode($this->sanitize_data($this->getRequest()->getParam('id'))); 
        
        $isDeactive = $objHotel->setSaleStartStop(" InvnItemSysId=$InvnItemSysId", "TB_MP_Inventory_Accom",0);             
        $message    = @$isDeactive ? "Hotel inventory sale stop successfully." : "Hotel inventory sale stop failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        if(@$isDeactive)
        {
            $this->_helper->redirector('index', 'hotel', 'admin');
        }
    }
    
    
    /**
     * Start Sale Hotel Action. 
     */
    public function startSaleAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
                
        $objHotel   = new Travel_Model_TblHotel();
        $InvnItemSysId = base64_decode($this->sanitize_data($this->getRequest()->getParam('id'))); 
        
        $isActive = $objHotel->setSaleStartStop(" InvnItemSysId=$InvnItemSysId", "TB_MP_Inventory_Accom",1);       
        $message    = @$isActive ? "Hotel inventory sale start successfully." : "Hotel inventory sale start failed.";                
        
        $this->_helper->flashMessenger->addMessage($message);
        
        if(@$isActive)
        {
            $this->_helper->redirector('index', 'hotel', 'admin');
        }
    }
    
    
    public function autoSuggestCityAction() {
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
//       print_r($this->getRequest()->getParam("term"));
//       exit;
        try {
            $arrResponse = array();
            if ($this->getRequest()->getParam("term") or $this->getRequest()->getParam("query")) {
                $term = $this->getRequest()->getParam("term") ? $this->getRequest()->getParam("term") : $this->getRequest()->getParam("query");
                $objHotel = new Travel_Model_TblBuyHotel();
                $condCity = "tbl.Title like '" . $term . "%'";
                $arrResponse = $objHotel->getBuyHotelCityAutoSuggest($condCity);
                // print_r($arrResponse);die;
            }
            echo json_encode($arrResponse);
            exit;
        } catch (Exception $e) {
            $response = array('success' => false, 'msg' => $e->getMessage());
            echo json_encode($response);
            exit;
        }
    }
    
}

Youez - 2016 - github.com/yon3zu
LinuXploit