| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/application/controllers/ |
Upload File : |
<?php
/**
* Class Hotel
*
* @name Hotel
* @author Prashant
* @version 1.0
* @copyright Catabatic India Pvt Ltd
* Handle Hotel Related function
*
*/
class AccommodationController extends Catabatic_ValidateGtx {
private $intLoggedinUserId = '';
protected $db = NULL;
const ADMIN_ID = 1;
private $intLoggedinUserGroupSysId = '0';
private $intLoggedinUserAgencySysId = '0';
private $intLoggedinUserTrxCurrency = '0';
private $intLoggedinUserRole = '0';
private $SupplierTypeSysId = '0';
public $baseUrl = '';
private $IsB2CSite = '';
/* Tripsbank Staff */
public $InfoSourceSysId = '0';
public function init() {
parent::init();
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
$this->db = Zend_Db_Table::getDefaultAdapter();
//$this->view->headScript()->appendFile($this->baseUrl . '/public/js/hotel/accommodation.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 = $sessionLogin_user->intLoggedinUserId;
$this->intLoggedinUserGroupSysId = $sessionLogin_user->intLoggedinUserGroupSysId;
$this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->intLoggedinUserTrxCurrency = $sessionLogin_user->intLoggedinUserTrxCurrency;
$this->IsB2CSite = $sessionLogin_user->agencyDetails['IsB2CSite'];
if (!empty($this->intLoggedinUserAgencySysId)) {
$this->InfoSourceSysId = '2'; /* Information Source is Agent */
}
// unlocking read-only lock
if ($sessionLogin_user->isLocked()) {
$sessionLogin_user->unLock();
}
}
public function indexAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$this->_helper->redirector('manage', 'accommodation', 'default');
$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;
$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 manageAction() {
$this->view->IsB2CSite = $this->IsB2CSite;
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objHotel = new Travel_Model_TblHotel();
$objAccoModel = new Travel_Model_AccommodationModel();
$HotelList = $objAccoModel->HotelList($this->intLoggedinUserAgencySysId);
$searchArr = array(
'DestinationId' => isset($params['DestinationId']) && !empty($params['DestinationId']) ? $params['DestinationId'] : '',
'hotelId' => isset($params['hotelId']) && !empty($params['hotelId']) ? $params['hotelId'] : '',
'rating' => isset($params['rating']) && !empty($params['rating']) ? $params['rating'] : '',
'ProprtyType' => isset($params['ProprtyType']) && !empty($params['ProprtyType']) ? $params['ProprtyType'] : ''
);
$this->view->searchArr = $searchArr;
//Get City List
$cityList = $objHotel->getInventoryCityList($this->intLoggedinUserAgencySysId);
//$cityList = array();
$this->view->cityList = $cityList;
//Get inventory hotel list
$cityId = isset($params['DestinationId']) && !empty($params['DestinationId']) ? $params['DestinationId'] : '';
// if ($cityId != '') {
$inventoryHotelList = $objHotel->getHotelSearchListByCityId($cityId, $this->intLoggedinUserAgencySysId);
// } else {
// $inventoryHotelList = array();
// }
$this->view->inventoryHotelList = $inventoryHotelList;
$page = $this->_getParam('page', 1);
//$search=$this->_getParam('search',1);
$paginator = Zend_Paginator::factory($HotelList);
$paginator->setItemCountPerPage(15);
$paginator->setCurrentPageNumber($page);
//echo '<pre>';print_r($HotelList);die;
$this->view->paginator = $paginator;
$this->view->page = $page;
//For display message
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function GUID() {
if (function_exists('com_create_guid') === true) {
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X%04X%04X%04X%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public function inventoryoldAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objHotel = new Travel_Model_TblHotel();
$objAccoModel = new Travel_Model_AccommodationModel();
/* * ******************** Add new room if not avalable ******************* */
if (isset($params['SessionKey']) && !empty($params['SessionKey'])) {
$RateDeBySessionKey = $objAccoModel->HotelRateDeBySessionKey($params['id'], $this->intLoggedinUserAgencySysId, $params['SessionKey']);
if (empty($RateDeBySessionKey)) {
$this->_helper->redirector('rate-card', 'accommodation', 'default', array('id' => $params['id']));
}
if ($RateDeBySessionKey) {
$EconomyType = array();
$XRefAccoSysId = array();
foreach ($RateDeBySessionKey as $kk => $vall) {
$XRefAccoSysId[] = $vall['XRefAccoSysId'];
$EconomyType[] = $vall['EconomyType'];
}
//echo '<pre>';print_r($EconomyType);echo '</pre>';die;
$result = $objAccoModel->searchroomList($params['id'], $EconomyType);
//echo '<pre>';print_r($result);echo '</pre>';
$currentDate = date('Y-m-d H:i:s');
if ($result) {
foreach ($result as $k => $val) {
$RoomTypeId[] = $val['RoomTypeId'];
}
foreach ($EconomyType as $k => $value) {
if (!in_array($value, $RoomTypeId)) {
$data = array(
'AccomSysId' => $params['id'],
'SourceSysId' => $this->intLoggedinUserAgencySysId,
'Title' => '',
'RoomType' => isset($value) && !empty($value) ? $value : '',
'EconomyType' => 0,
'Qty' => 999,
'BedType' => 0,
'PaxCount' => 0,
'IsPetAllow' => 0,
'MaxPetAllow' => 0,
'AllowChild' => 0,
'AllowInfant' => 0,
'MaxPaxCount' => 0,
'MaxAllowChild' => 0,
'MaxAllowInfant' => 0,
'MealPlanType' => '',
'AminitiesMask' => '',
'InclustionOptionsMask' => '',
'OtherDetails' => '',
'UpdatedDate' => $currentDate,
'CreateDate' => $currentDate,
'ApproveDate' => EMPTY_DATE,
'ApproveBy' => 0,
'IsDelete' => 0,
'IsActive' => '1',
'IsApproved' => '0'
);
$response = $objAccoModel->AddSearchRoom($data);
$CheckInvExist = $objAccoModel->CheckInventoryExist($params['id'], $value, $this->intLoggedinUserAgencySysId);
if ($CheckInvExist) {
foreach ($CheckInvExist as $inv) {
$update = array(
'XRefItemSysId' => $response
);
$objAccoModel->UpdateInventoryExist($inv['InvnItemSysId'], $update);
}
}
}
}
//echo 'true';
} else {
foreach ($EconomyType as $k => $value) {
$data = array(
'AccomSysId' => $params['id'],
'SourceSysId' => $this->intLoggedinUserAgencySysId,
'Title' => '',
'RoomType' => isset($value) && !empty($value) ? $value : '',
'EconomyType' => 0,
'Qty' => 999,
'BedType' => 0,
'PaxCount' => 0,
'IsPetAllow' => 0,
'MaxPetAllow' => 0,
'AllowChild' => 0,
'AllowInfant' => 0,
'MaxPaxCount' => 0,
'MaxAllowChild' => 0,
'MaxAllowInfant' => 0,
'MealPlanType' => '',
'AminitiesMask' => '',
'InclustionOptionsMask' => '',
'OtherDetails' => '',
'UpdatedDate' => $currentDate,
'CreateDate' => $currentDate,
'ApproveDate' => EMPTY_DATE,
'ApproveBy' => 0,
'IsDelete' => 0,
'IsActive' => '1',
'IsApproved' => '0'
);
$response = $objAccoModel->AddSearchRoom($data);
$CheckInvExist = $objAccoModel->CheckInventoryExist($params['id'], $value, $this->intLoggedinUserAgencySysId);
if ($CheckInvExist) {
foreach ($CheckInvExist as $inv) {
$update = array(
'XRefItemSysId' => $response
);
$objAccoModel->UpdateInventoryExist($inv['InvnItemSysId'], $update);
}
}
}
//echo 'false';
}
//echo isset($response)?$response:$params['XRefItemSysId'];die('room');
//echo '<pre>';print_r($XRefAccoSysId);echo '</pre>';
// $this->view->RateDeBySessionKey = !empty($RateDeBySessionKey) ? $RateDeBySessionKey : '';
// $this->view->SessionKey = !empty($params['SessionKey']) ? $params['SessionKey'] : '';
// $FromDate = $objAccoModel->getMinimumDateSession($params['id'],$params['EconomyType'],$params['MealPlanType'],$params['SupplierSysId'],$this->intLoggedinUserAgencySysId);
// $ToDate = $objAccoModel->getMaximumDateSession($params['id'],$params['EconomyType'],$params['MealPlanType'],$params['SupplierSysId'],$this->intLoggedinUserAgencySysId);
// echo $FromDate.'=='.$ToDate;die('update');
// $SessionKeyGUID = self::GUID();
// $where = array('XRefAccoSysId =?' => $params['id'], 'FromDate >=? ' => date('Y-m-d', strtotime($FromDate)), 'FromDate <=? '=>date('Y-m-d', strtotime($ToDate)),'EconomyType IN(?) '=>array(explode(',',$params['EconomyType'])),'MealPlanType IN(?) '=>array(explode(',',$params['MealPlanType'])),'SupplierSysId =? '=>$params['SupplierSysId'], 'AgencySysId =?' => $this->intLoggedinUserAgencySysId);
// $insert_im = array('XRateSessionKey' => $SessionKeyGUID);
// $updatess = $this->db->update('TB_MP_Inventory_Accom', $insert_im, $where);
// if($updatess){
// print_r($where);
// echo self::GUID().'<br>';
// echo $FromDate.'=='.$ToDate;die('update');
// }
// die;
if (isset($params['checkroom']) && $params['checkroom'] == 'true') {
$this->_helper->redirector('inventory', 'accommodation', 'default', array('id' => $params['id'], 'XRefItemSysId' => isset($response) ? $response : $params['XRefItemSysId'], 'EconomyType' => $params['EconomyType'], 'MealPlanType' => $params['MealPlanType'], 'SupplierSysId' => $params['SupplierSysId']));
}
}
}
/** End room add* */
//$HotelrateCardList = $objAccoModel->HotelrateCardByAgList($this->intLoggedinUserAgencySysId);
$HotelrateCardByAgListByHotel = $objAccoModel->HotelrateCardByAgListByHotel($this->intLoggedinUserAgencySysId);
$HotelList = $objAccoModel->HotelList($this->intLoggedinUserAgencySysId);
//$this->view->rateCardList = $HotelrateCardList;
//$this->view->HotelrateCardByAgListByHotel = $HotelrateCardByAgListByHotel;
if (isset($params['id']) && !empty($params['id'])) {
$HotelrateCardList_ = $objAccoModel->HotelrateCardListUpdateDates($params['id'], $this->intLoggedinUserAgencySysId);
//echo '<pre>';print_r($HotelrateCardList_);die;
$SessionKeyGUID = self::GUID();
foreach ($HotelrateCardList_ as $k => $val) {
$strToDates = date("Y/m/d", strtotime("+1 day", strtotime($val['ToDate'])));
$begin = new DateTime($val['FromDate']);
$end = new DateTime($strToDates);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
$weeked = array('Sat', 'Sun');
//$where = array('XRefAccoSysId =?' => $val['XRefAccoSysId'], 'FromDate =? ' => date('Y-m-d',strtotime($val['FromDate'])),'ToDate =? ' => date('Y-m-d',strtotime($val['ToDate'])),'XRefItemSysId =? '=>$val['XRefItemSysId'],'EconomyType =? '=>$val['EconomyType'],'MealPlanType =? '=>$val['MealPlanType'], 'SupplierSysId =?' => $val['SupplierSysId'], 'AgencySysId =?' => $this->intLoggedinUserAgencySysId);
//$insert_im = array('IsMarkForDelete' => 1,'IsActive'=>0);
//$this->db->update('TB_MP_Inventory_Accom', $insert_im, $where);
//print_r($where);
foreach ($period as $dt) {
$ApproveDate = (array) $val['ApproveDate'];
$UpdateDate = (array) $val['UpdateDate'];
$CreateDate = (array) $val['CreateDate'];
$where = array('XRefAccoSysId =?' => $val['XRefAccoSysId'], 'FromDate =? ' => $dt->format("Y-m-d"), 'XRefItemSysId =? ' => $val['XRefItemSysId'], 'EconomyType =? ' => $val['EconomyType'], 'MealPlanType =? ' => $val['MealPlanType'], 'SupplierSysId =?' => $val['SupplierSysId'], 'AgencySysId =?' => $this->intLoggedinUserAgencySysId);
$insert_im = array('IsMarkForDelete' => 1, 'IsActive' => 0);
$this->db->update('TB_MP_Inventory_Accom', $insert_im, $where);
if (in_array($dt->format("D"), $weeked)) {
//echo 'wk';
$insert = array(
'XRefAccoSysId' => $val['XRefAccoSysId'],
'AgencySysId' => $val['AgencySysId'],
'XRateSessionKey' => $val['XRateSessionKey'],
'FromDate' => $dt->format("Y-m-d"), //FromDate
'ToDate' => date("Y-m-d", strtotime($val['ToDate'])), //ToDate
'InventoryType' => '1',
'Title' => $val['Title'],
'EconomyType' => $val['EconomyType'],
'CostCurrency' => $val['CostCurrency'], //CostCurrency
'RateType' => $val['RateType'], //RateType
'RackCommissionType' => $val['RackCommissionType'], //RackCommissionType
'RackCommission' => $val['RackCommission'], //RackCommission
'SupplierSysId' => $val['SupplierSysId'], //SupplierSysId
'ChildAgeLimit' => $val['ChildAgeLimit'], //ChildAgeLimit
'InfantAgeLimit' => $val['InfantAgeLimit'], //InfantAgeLimit
'XRefItemSysId' => $val['XRefItemSysId'],
'PublishQty' => $val['PublishQty'], //PublishQty
'DailyRoomLimit' => $val['DailyRoomLimit'], //PublishQty
'MealPlanType' => $val['MealPlanType'], // meal type
'SOccupCost' => (isset($val['SOccupCost']) && $val['SOccupCost'] == '') ? null : $val['SOccupCost'],
'NetSOccupCost' => (isset($val['NetSOccupCost']) && $val['NetSOccupCost'] == '') ? null : $val['NetSOccupCost'],
'DOccupCost' => (isset($val['DOccupCost']) && $val['DOccupCost'] == '') ? null : $val['DOccupCost'],
'NetDOccupCost' => (isset($val['NetDOccupCost']) && $val['NetDOccupCost'] == '') ? null : $val['NetDOccupCost'],
//'TriOccupCost' => (isset($val['TriOccupCost']) && $val['TriOccupCost'] == '') ? null : $val['TriOccupCost'],
//'NetTriOccupCost' => (isset($val['NetTriOccupCost']) && $val['NetTriOccupCost'] == '') ? null : $val['NetTriOccupCost'],
'ExtraBedCost' => (isset($val['ExtraBedCost']) && $val['ExtraBedCost'] == '') ? null : $val['ExtraBedCost'],
'NetExtraBedCost' => (isset($val['NetExtraBedCost']) && $val['NetExtraBedCost'] == '') ? null : $val['NetExtraBedCost'],
'ExtraWOBedCost' => (isset($val['ExtraWOBedCost']) && $val['ExtraWOBedCost'] == '') ? null : $val['ExtraWOBedCost'],
'NetExtraWOBedCost' => (isset($val['NetExtraWOBedCost']) && $val['NetExtraWOBedCost'] == '') ? null : $val['NetExtraWOBedCost'],
'IsTaxOnSOccupCost' => (isset($val['IsTaxOnSOccupCost']) ? $val['IsTaxOnSOccupCost'] : '0'),
'IsTaxOnDOccupCost' => (isset($val['IsTaxOnDOccupCost']) ? $val['IsTaxOnDOccupCost'] : '0'),
//'IsTaxOnTriOccupCost' => (isset($val['IsTaxOnTriOccupCost']) ? $val['IsTaxOnTriOccupCost'] : '0'),
'IsTaxOnExtraBedCost' => (isset($val['IsTaxOnExtraBedCost']) ? $val['IsTaxOnExtraBedCost'] : '0'),
'IsTaxOnExtraWOBedCost' => (isset($val['IsTaxOnExtraWOBedCost']) ? $val['IsTaxOnExtraWOBedCost'] : '0'),
'IsExtraMealAdultCost' => (isset($val['IsExtraMealAdultCost']) && $val['IsExtraMealAdultCost'] != '' ? $val['IsExtraMealAdultCost'] : '0'),
'IsExtraMealChildCost' => (isset($val['IsExtraMealChildCost']) && $val['IsExtraMealChildCost'] != '' ? $val['IsExtraMealChildCost'] : '0'),
'CreatorSysId' => $val['CreatorSysId'],
'UpdateDate' => date("Y-m-d H:i:s"),
'CreateDate' => date("Y-m-d H:i:s", strtotime($UpdateDate['date'])),
'ApproveDate' => date("Y-m-d H:i:s", strtotime($ApproveDate['date'])),
'WeekendDefine' => implode(',', $weeked),
'IsMarkForDelete' => 0,
'IsActive' => '1',
);
} else {
//echo 'wd';
$insert = array(
'XRefAccoSysId' => $val['XRefAccoSysId'],
'AgencySysId' => $val['AgencySysId'],
'XRateSessionKey' => $val['XRateSessionKey'],
'FromDate' => $dt->format("Y-m-d"), //FromDate
'ToDate' => date("Y-m-d", strtotime($val['ToDate'])), //ToDate
'InventoryType' => '1',
'Title' => $val['Title'],
'EconomyType' => $val['EconomyType'],
'CostCurrency' => $val['CostCurrency'], //CostCurrency
'RateType' => $val['RateType'], //RateType
'RackCommissionType' => $val['RackCommissionType'], //RackCommissionType
'RackCommission' => $val['RackCommission'], //RackCommission
'SupplierSysId' => $val['SupplierSysId'], //SupplierSysId
'ChildAgeLimit' => $val['ChildAgeLimit'], //ChildAgeLimit
'InfantAgeLimit' => $val['InfantAgeLimit'], //InfantAgeLimit
'XRefItemSysId' => $val['XRefItemSysId'],
'PublishQty' => $val['PublishQty'], //PublishQty
'DailyRoomLimit' => $val['DailyRoomLimit'], //PublishQty
'MealPlanType' => $val['MealPlanType'], // meal type
'SOccupCost' => (isset($val['SOccupCost']) && $val['SOccupCost'] == '') ? null : $val['SOccupCost'],
'NetSOccupCost' => (isset($val['NetSOccupCost']) && $val['NetSOccupCost'] == '') ? null : $val['NetSOccupCost'],
'DOccupCost' => (isset($val['DOccupCost']) && $val['DOccupCost'] == '') ? null : $val['DOccupCost'],
'NetDOccupCost' => (isset($val['NetDOccupCost']) && $val['NetDOccupCost'] == '') ? null : $val['NetDOccupCost'],
//'TriOccupCost' => (isset($val['TriOccupCost']) && $val['TriOccupCost'] == '') ? null : $val['TriOccupCost'],
//'NetTriOccupCost' => (isset($val['NetTriOccupCost']) && $val['NetTriOccupCost'] == '') ? null : $val['NetTriOccupCost'],
'ExtraBedCost' => (isset($val['ExtraBedCost']) && $val['ExtraBedCost'] == '') ? null : $val['ExtraBedCost'],
'NetExtraBedCost' => (isset($val['NetExtraBedCost']) && $val['NetExtraBedCost'] == '') ? null : $val['NetExtraBedCost'],
'ExtraWOBedCost' => (isset($val['ExtraWOBedCost']) && $val['ExtraWOBedCost'] == '') ? null : $val['ExtraWOBedCost'],
'NetExtraWOBedCost' => (isset($val['NetExtraWOBedCost']) && $val['NetExtraWOBedCost'] == '') ? null : $val['NetExtraWOBedCost'],
'IsTaxOnSOccupCost' => (isset($val['IsTaxOnSOccupCost']) ? $val['IsTaxOnSOccupCost'] : '0'),
'IsTaxOnDOccupCost' => (isset($val['IsTaxOnDOccupCost']) ? $val['IsTaxOnDOccupCost'] : '0'),
//'IsTaxOnTriOccupCost' => (isset($val['IsTaxOnTriOccupCost']) ? $val['IsTaxOnTriOccupCost'] : '0'),
'IsTaxOnExtraBedCost' => (isset($val['IsTaxOnExtraBedCost']) ? $val['IsTaxOnExtraBedCost'] : '0'),
'IsTaxOnExtraWOBedCost' => (isset($val['IsTaxOnExtraWOBedCost']) ? $val['IsTaxOnExtraWOBedCost'] : '0'),
'IsExtraMealAdultCost' => (isset($val['IsExtraMealAdultCost']) && $val['IsExtraMealAdultCost'] != '' ? $val['IsExtraMealAdultCost'] : '0'),
'IsExtraMealChildCost' => (isset($val['IsExtraMealChildCost']) && $val['IsExtraMealChildCost'] != '' ? $val['IsExtraMealChildCost'] : '0'),
'CreatorSysId' => $val['CreatorSysId'],
'UpdateDate' => date("Y-m-d H:i:s"),
'CreateDate' => date("Y-m-d H:i:s", strtotime($UpdateDate['date'])),
'ApproveDate' => date("Y-m-d H:i:s", strtotime($ApproveDate['date'])),
'WeekendDefine' => implode(',', $weeked),
'IsMarkForDelete' => 0,
'IsActive' => '1',
);
}
//echo '<pre>';print_r($insert);echo '</pre>';
$this->db->insert('TB_MP_Inventory_Accom', $insert);
$intLastInsertId = $this->db->lastInsertId('TB_MP_Inventory_Accom');
}
}
//die('wait....');
}
//echo $this->intLoggedinUserAgencySysId;die;
//echo $intLastInsertId;die('intLastInsertId'); 'MealPlanType =? '=>$params['MealPlanType']
if (isset($intLastInsertId) && !empty($intLastInsertId)) {
//file_put_contents(time().'.txt',$intLastInsertId);
$wherePK = array('AccoSysId =?' => $params['id'], 'RoomType =? ' => $params['EconomyType'], 'SupplierSysId =?' => $params['SupplierSysId'], 'AgencySysId =?' => $this->intLoggedinUserAgencySysId);
$insert_pk = array('InvnItemSysId' => $intLastInsertId, 'MealPlanType' => $params['MealPlanType']);
$this->db->update('TB_TravelPlan_Itenary_Accom', $insert_pk, $wherePK);
$this->db->update('TB_Agency_Customer_TravelPlan_Accom', $insert_pk, $wherePK);
}
//echo $intLastInsertId;die('intLastInsertId');
if (isset($params['id']) && !empty($params)) {
$this->_helper->redirector('inventory', 'accommodation', 'default');
}
$searchArr = array(
'DestinationId' => isset($params['DestinationId']) && !empty($params['DestinationId']) ? $params['DestinationId'] : '',
'hotelId' => isset($params['hotelId']) && !empty($params['hotelId']) ? $params['hotelId'] : '',
'rating' => isset($params['rating']) && !empty($params['rating']) ? $params['rating'] : ''
);
$this->view->searchArr = $searchArr;
//Get City List
$cityList = $objHotel->getInventoryCityList($this->intLoggedinUserAgencySysId);
$this->view->cityList = $cityList;
//Get inventory hotel list
$inventoryHotelList = $objHotel->getHotelInventoryListByCityId($cityId = '', $this->intLoggedinUserAgencySysId);
$this->view->inventoryHotelList = $inventoryHotelList;
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($HotelrateCardByAgListByHotel));
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(5000);
$data = array();
$hotelArray = array();
foreach ($paginator as $k => $vl) {
$hotelArray[$vl['XRateSessionKey']] = $vl;
}
//echo '<pre>';print_r($hotelArray);die;
foreach ($hotelArray as $ky => $v) {
$RoomArray = $objAccoModel->RoomArray($v['hotelId'], $ky);
$SupplierArray = $objAccoModel->GetSupplierArray($v['hotelId']);
$FromDate = $objAccoModel->getMinDate($v['hotelId'], $ky, $this->intLoggedinUserAgencySysId);
$ToDate = $objAccoModel->getMaximumDate($v['hotelId'], $ky, $this->intLoggedinUserAgencySysId);
$data[] = array('XRateSessionKey' => $ky, 'FromDate' => $FromDate, 'ToDate' => $ToDate, 'XRefItemSysId' => $v['XRefItemSysId'], 'EconomyType' => $v['EconomyType'], 'MealPlanType' => $v['MealPlanType'], 'SupplierSysId' => $v['SupplierSysId'], 'CreateDate' => (array) $v['CreateDate'], 'SupplierName' => $v['SupplierName'], 'ContSysId' => $v['ContSysId'], 'hotelId' => $v['hotelId'], 'ICSourceSysId' => $v['ICSourceSysId'], 'hotelname' => $v['hotelName'], 'City_title' => $v['City_title'], 'country_title' => $v['country_title'], 'RoomArray' => $RoomArray);
}
$this->view->paginator = $data;
// $page = $this->_getParam('page', 1);
// //$search=$this->_getParam('search',1);
// $paginator = Zend_Paginator::factory($HotelrateCardByAgListByHotel);
// $paginator->setItemCountPerPage(50);
// $paginator->setCurrentPageNumber($page);
// $data = array();
// $hotelArray = array();
// foreach ($paginator as $k => $vl) {
// //$CreateDate = (array)$vl['CreateDate'];
// $hotelArray[$vl['XRateSessionKey']] = $vl;
// }
//
// foreach ($hotelArray as $ky => $v) {
// $RoomArray = $objAccoModel->RoomArray($v['hotelId'],$ky);
// //$SupplierArray = self::GetSupplierArray($v['hotelId']);
// $FromDate = $objAccoModel->getMinDate($v['hotelId'],$ky,$this->intLoggedinUserAgencySysId);
// $ToDate = $objAccoModel->getMaximumDate($v['hotelId'],$ky,$this->intLoggedinUserAgencySysId);
// $data[] = array('XRateSessionKey'=>$ky,'FromDate'=>$FromDate,'ToDate'=>$ToDate,'XRefItemSysId'=>$v['XRefItemSysId'],'EconomyType'=>$v['EconomyType'],'MealPlanType'=>$v['MealPlanType'],'SupplierSysId'=>$v['SupplierSysId'],'CreateDate'=> (array)$v['CreateDate'],'SupplierName'=>$v['SupplierName'],'ContSysId'=>$v['ContSysId'],'hotelId'=>$v['hotelId'],'ICSourceSysId'=>$v['ICSourceSysId'],'hotelname'=>$v['hotelName'],'City_title'=>$v['City_title'],'country_title'=>$v['country_title'],'RoomArray'=>$RoomArray);
//
// }
//echo '<pre>';print_r($data);echo '</pre>';die;
// $this->view->paginator = $paginator;
$this->view->paginators = $paginator;
//$this->view->page = $page;
//For display message
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function inventoryAction() { //error_reporting(E_ALL);
$objHotel = new Travel_Model_TblHotel();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$RateHotelId = (isset($params['hid']) && !empty($params['hid'])) ? $params['hid'] : 0;
$objAccoModel = new Travel_Model_AccommodationModel();
//$HotelrateCardByAgListByHotel = $objAccoModel->HotelrateCardByAgListByHotelOptimized($this->intLoggedinUserAgencySysId);
$paginator = array();
$filterData = array();
if ($this->getRequest()->isPost()) {
$postData = $this->getRequest()->getPost();
$filterData['DestinationId'] = isset($postData['DestinationId']) ? $postData['DestinationId'] : 0;
$filterData['hotelId'] = isset($postData['hotelId']) ? $postData['hotelId'] : 0;
$filterData['rating'] = isset($postData['rating']) ? $postData['rating'] : '';
$filterData['dateFrom'] = (isset($postData['dateFrom']) && trim($postData['dateFrom']) != '____-__-__') ? $postData['dateFrom'] : '';
$filterData['dateTo'] = (isset($postData['dateTo']) && trim($postData['dateTo']) != '____-__-__') ? $postData['dateTo'] : '';
}
$pageNumber = $this->_getParam('page', 1);
if (empty($RateHotelId)) {
$HotelrateCardByAgListByHotelNew = $objAccoModel->HotelrateCardByAgListByHotelOptimizedNew($this->intLoggedinUserAgencySysId, 0, '', '', $filterData, $pageNumber);
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($HotelrateCardByAgListByHotelNew));
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(10);
}
$this->view->paginator = $paginator;
$this->view->RateHotelId = $RateHotelId;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$cityList = $objHotel->getInventoryCityList($this->intLoggedinUserAgencySysId);
$inventoryHotelList = $objHotel->getHotelInventoryListByCityId('', $this->intLoggedinUserAgencySysId);
$this->view->cityList = $cityList;
$this->view->inventoryHotelList = $inventoryHotelList;
$this->view->searchArr = $filterData;
}
public function inventoryolddesignAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objHotel = new Travel_Model_TblHotel();
$objAccoModel = new Travel_Model_AccommodationModel();
$HotelrateCardByAgListByHotel = $objAccoModel->HotelrateCardByAgListByHotelOptimized($this->intLoggedinUserAgencySysId);
$HotelList = $objAccoModel->HotelList($this->intLoggedinUserAgencySysId);
if (isset($params['id']) && !empty($params['id'])) {
$HotelrateCardList_ = $objAccoModel->HotelrateCardListUpdateDates($params['id'], $this->intLoggedinUserAgencySysId);
//echo '<pre>';print_r($HotelrateCardList_);die;
$SessionKeyGUID = self::GUID();
foreach ($HotelrateCardList_ as $k => $val) {
$strToDates = date("Y/m/d", strtotime("+1 day", strtotime($val['ToDate'])));
$begin = new DateTime($val['FromDate']);
$end = new DateTime($strToDates);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
$weeked = array('Sat', 'Sun');
//$where = array('XRefAccoSysId =?' => $val['XRefAccoSysId'], 'FromDate =? ' => date('Y-m-d',strtotime($val['FromDate'])),'ToDate =? ' => date('Y-m-d',strtotime($val['ToDate'])),'XRefItemSysId =? '=>$val['XRefItemSysId'],'EconomyType =? '=>$val['EconomyType'],'MealPlanType =? '=>$val['MealPlanType'], 'SupplierSysId =?' => $val['SupplierSysId'], 'AgencySysId =?' => $this->intLoggedinUserAgencySysId);
//$insert_im = array('IsMarkForDelete' => 1,'IsActive'=>0);
//$this->db->update('TB_MP_Inventory_Accom', $insert_im, $where);
//print_r($where);
foreach ($period as $dt) {
$ApproveDate = (array) $val['ApproveDate'];
$UpdateDate = (array) $val['UpdateDate'];
$CreateDate = (array) $val['CreateDate'];
$where = array('XRefAccoSysId =?' => $val['XRefAccoSysId'], 'FromDate =? ' => $dt->format("Y-m-d"), 'XRefItemSysId =? ' => $val['XRefItemSysId'], 'EconomyType =? ' => $val['EconomyType'], 'MealPlanType =? ' => $val['MealPlanType'], 'SupplierSysId =?' => $val['SupplierSysId'], 'AgencySysId =?' => $this->intLoggedinUserAgencySysId);
$insert_im = array('IsMarkForDelete' => 1, 'IsActive' => 0);
$this->db->update('TB_MP_Inventory_Accom', $insert_im, $where);
if (in_array($dt->format("D"), $weeked)) {
//echo 'wk';
$insert = array(
'XRefAccoSysId' => $val['XRefAccoSysId'],
'AgencySysId' => $val['AgencySysId'],
'XRateSessionKey' => $val['XRateSessionKey'],
'FromDate' => $dt->format("Y-m-d"), //FromDate
'ToDate' => date("Y-m-d", strtotime($val['ToDate'])), //ToDate
'InventoryType' => '1',
'Title' => $val['Title'],
'EconomyType' => $val['EconomyType'],
'CostCurrency' => $val['CostCurrency'], //CostCurrency
'RateType' => $val['RateType'], //RateType
'RackCommissionType' => $val['RackCommissionType'], //RackCommissionType
'RackCommission' => $val['RackCommission'], //RackCommission
'SupplierSysId' => $val['SupplierSysId'], //SupplierSysId
'ChildAgeLimit' => $val['ChildAgeLimit'], //ChildAgeLimit
'InfantAgeLimit' => $val['InfantAgeLimit'], //InfantAgeLimit
'XRefItemSysId' => $val['XRefItemSysId'],
'PublishQty' => $val['PublishQty'], //PublishQty
'DailyRoomLimit' => $val['DailyRoomLimit'], //PublishQty
'MealPlanType' => $val['MealPlanType'], // meal type
'SOccupCost' => (isset($val['SOccupCost']) && $val['SOccupCost'] == '') ? null : $val['SOccupCost'],
'NetSOccupCost' => (isset($val['NetSOccupCost']) && $val['NetSOccupCost'] == '') ? null : $val['NetSOccupCost'],
'DOccupCost' => (isset($val['DOccupCost']) && $val['DOccupCost'] == '') ? null : $val['DOccupCost'],
'NetDOccupCost' => (isset($val['NetDOccupCost']) && $val['NetDOccupCost'] == '') ? null : $val['NetDOccupCost'],
//'TriOccupCost' => (isset($val['TriOccupCost']) && $val['TriOccupCost'] == '') ? null : $val['TriOccupCost'],
//'NetTriOccupCost' => (isset($val['NetTriOccupCost']) && $val['NetTriOccupCost'] == '') ? null : $val['NetTriOccupCost'],
'ExtraBedCost' => (isset($val['ExtraBedCost']) && $val['ExtraBedCost'] == '') ? null : $val['ExtraBedCost'],
'NetExtraBedCost' => (isset($val['NetExtraBedCost']) && $val['NetExtraBedCost'] == '') ? null : $val['NetExtraBedCost'],
'ExtraWOBedCost' => (isset($val['ExtraWOBedCost']) && $val['ExtraWOBedCost'] == '') ? null : $val['ExtraWOBedCost'],
'NetExtraWOBedCost' => (isset($val['NetExtraWOBedCost']) && $val['NetExtraWOBedCost'] == '') ? null : $val['NetExtraWOBedCost'],
'IsTaxOnSOccupCost' => (isset($val['IsTaxOnSOccupCost']) ? $val['IsTaxOnSOccupCost'] : '0'),
'IsTaxOnDOccupCost' => (isset($val['IsTaxOnDOccupCost']) ? $val['IsTaxOnDOccupCost'] : '0'),
//'IsTaxOnTriOccupCost' => (isset($val['IsTaxOnTriOccupCost']) ? $val['IsTaxOnTriOccupCost'] : '0'),
'IsTaxOnExtraBedCost' => (isset($val['IsTaxOnExtraBedCost']) ? $val['IsTaxOnExtraBedCost'] : '0'),
'IsTaxOnExtraWOBedCost' => (isset($val['IsTaxOnExtraWOBedCost']) ? $val['IsTaxOnExtraWOBedCost'] : '0'),
'IsExtraMealAdultCost' => (isset($val['IsExtraMealAdultCost']) && $val['IsExtraMealAdultCost'] != '' ? $val['IsExtraMealAdultCost'] : '0'),
'IsExtraMealChildCost' => (isset($val['IsExtraMealChildCost']) && $val['IsExtraMealChildCost'] != '' ? $val['IsExtraMealChildCost'] : '0'),
'CreatorSysId' => $val['CreatorSysId'],
'UpdateDate' => date("Y-m-d H:i:s"),
'CreateDate' => date("Y-m-d H:i:s", strtotime($UpdateDate['date'])),
'ApproveDate' => date("Y-m-d H:i:s", strtotime($ApproveDate['date'])),
'WeekendDefine' => implode(',', $weeked),
'IsMarkForDelete' => 0,
'IsActive' => '1',
);
} else {
//echo 'wd';
$insert = array(
'XRefAccoSysId' => $val['XRefAccoSysId'],
'AgencySysId' => $val['AgencySysId'],
'XRateSessionKey' => $val['XRateSessionKey'],
'FromDate' => $dt->format("Y-m-d"), //FromDate
'ToDate' => date("Y-m-d", strtotime($val['ToDate'])), //ToDate
'InventoryType' => '1',
'Title' => $val['Title'],
'EconomyType' => $val['EconomyType'],
'CostCurrency' => $val['CostCurrency'], //CostCurrency
'RateType' => $val['RateType'], //RateType
'RackCommissionType' => $val['RackCommissionType'], //RackCommissionType
'RackCommission' => $val['RackCommission'], //RackCommission
'SupplierSysId' => $val['SupplierSysId'], //SupplierSysId
'ChildAgeLimit' => $val['ChildAgeLimit'], //ChildAgeLimit
'InfantAgeLimit' => $val['InfantAgeLimit'], //InfantAgeLimit
'XRefItemSysId' => $val['XRefItemSysId'],
'PublishQty' => $val['PublishQty'], //PublishQty
'DailyRoomLimit' => $val['DailyRoomLimit'], //PublishQty
'MealPlanType' => $val['MealPlanType'], // meal type
'SOccupCost' => (isset($val['SOccupCost']) && $val['SOccupCost'] == '') ? null : $val['SOccupCost'],
'NetSOccupCost' => (isset($val['NetSOccupCost']) && $val['NetSOccupCost'] == '') ? null : $val['NetSOccupCost'],
'DOccupCost' => (isset($val['DOccupCost']) && $val['DOccupCost'] == '') ? null : $val['DOccupCost'],
'NetDOccupCost' => (isset($val['NetDOccupCost']) && $val['NetDOccupCost'] == '') ? null : $val['NetDOccupCost'],
//'TriOccupCost' => (isset($val['TriOccupCost']) && $val['TriOccupCost'] == '') ? null : $val['TriOccupCost'],
//'NetTriOccupCost' => (isset($val['NetTriOccupCost']) && $val['NetTriOccupCost'] == '') ? null : $val['NetTriOccupCost'],
'ExtraBedCost' => (isset($val['ExtraBedCost']) && $val['ExtraBedCost'] == '') ? null : $val['ExtraBedCost'],
'NetExtraBedCost' => (isset($val['NetExtraBedCost']) && $val['NetExtraBedCost'] == '') ? null : $val['NetExtraBedCost'],
'ExtraWOBedCost' => (isset($val['ExtraWOBedCost']) && $val['ExtraWOBedCost'] == '') ? null : $val['ExtraWOBedCost'],
'NetExtraWOBedCost' => (isset($val['NetExtraWOBedCost']) && $val['NetExtraWOBedCost'] == '') ? null : $val['NetExtraWOBedCost'],
'IsTaxOnSOccupCost' => (isset($val['IsTaxOnSOccupCost']) ? $val['IsTaxOnSOccupCost'] : '0'),
'IsTaxOnDOccupCost' => (isset($val['IsTaxOnDOccupCost']) ? $val['IsTaxOnDOccupCost'] : '0'),
//'IsTaxOnTriOccupCost' => (isset($val['IsTaxOnTriOccupCost']) ? $val['IsTaxOnTriOccupCost'] : '0'),
'IsTaxOnExtraBedCost' => (isset($val['IsTaxOnExtraBedCost']) ? $val['IsTaxOnExtraBedCost'] : '0'),
'IsTaxOnExtraWOBedCost' => (isset($val['IsTaxOnExtraWOBedCost']) ? $val['IsTaxOnExtraWOBedCost'] : '0'),
'IsExtraMealAdultCost' => (isset($val['IsExtraMealAdultCost']) && $val['IsExtraMealAdultCost'] != '' ? $val['IsExtraMealAdultCost'] : '0'),
'IsExtraMealChildCost' => (isset($val['IsExtraMealChildCost']) && $val['IsExtraMealChildCost'] != '' ? $val['IsExtraMealChildCost'] : '0'),
'CreatorSysId' => $val['CreatorSysId'],
'UpdateDate' => date("Y-m-d H:i:s"),
'CreateDate' => date("Y-m-d H:i:s", strtotime($UpdateDate['date'])),
'ApproveDate' => date("Y-m-d H:i:s", strtotime($ApproveDate['date'])),
'WeekendDefine' => implode(',', $weeked),
'IsMarkForDelete' => 0,
'IsActive' => '1',
);
}
//echo '<pre>';print_r($insert);echo '</pre>';
$this->db->insert('TB_MP_Inventory_Accom', $insert);
$intLastInsertId = $this->db->lastInsertId('TB_MP_Inventory_Accom');
}
}
//die('wait....');
}
if (isset($intLastInsertId) && !empty($intLastInsertId)) {
//file_put_contents(time().'.txt',$intLastInsertId);
$wherePK = array('AccoSysId =?' => $params['id'], 'RoomType =? ' => $params['EconomyType'], 'SupplierSysId =?' => $params['SupplierSysId'], 'AgencySysId =?' => $this->intLoggedinUserAgencySysId);
$insert_pk = array('InvnItemSysId' => $intLastInsertId, 'MealPlanType' => $params['MealPlanType']);
$this->db->update('TB_TravelPlan_Itenary_Accom', $insert_pk, $wherePK);
$this->db->update('TB_Agency_Customer_TravelPlan_Accom', $insert_pk, $wherePK);
}
//echo $intLastInsertId;die('intLastInsertId');
if (isset($params['id']) && !empty($params)) {
$this->_helper->redirector('inventory', 'accommodation', 'default');
}
$searchArr = array(
'DestinationId' => isset($params['DestinationId']) && !empty($params['DestinationId']) ? $params['DestinationId'] : '',
'hotelId' => isset($params['hotelId']) && !empty($params['hotelId']) ? $params['hotelId'] : '',
'rating' => isset($params['rating']) && !empty($params['rating']) ? $params['rating'] : '',
'dateFrom' => (isset($params['dateFrom']) && trim($params['dateFrom']) != '' && trim($params['dateFrom']) != '____-__-__') ? trim($params['dateFrom']) : '',
'dateTo' => (isset($params['dateTo']) && trim($params['dateTo']) != '' && trim($params['dateTo']) != '____-__-__') ? trim($params['dateTo']) : '',
);
// echo "<pre>";print_r($searchArr);die;
$this->view->searchArr = $searchArr;
//Get City List
$cityList = $objHotel->getInventoryCityList($this->intLoggedinUserAgencySysId);
$this->view->cityList = $cityList;
//Get inventory hotel list
$inventoryHotelList = $objHotel->getHotelInventoryListByCityId($cityId = '', $this->intLoggedinUserAgencySysId);
$this->view->inventoryHotelList = $inventoryHotelList;
// echo "<pre>";
// print_r($HotelrateCardByAgListByHotel); die();
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($HotelrateCardByAgListByHotel));
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(50);
$data = array();
$hotelArray = array();
foreach ($paginator as $k => $vl) {
$hotelArray[$vl['XRateSessionKey']][$vl['TfromDate']->format("Y-m-d")]['hotel'] = $vl;
$hotelArray[$vl['XRateSessionKey']][$vl['TfromDate']->format("Y-m-d")]['RoomArray'][$vl['RoomSysId']]['EconomyType'] = $vl['EcomyType'];
$hotelArray[$vl['XRateSessionKey']][$vl['TfromDate']->format("Y-m-d")]['RoomArray'][$vl['RoomSysId']]['BookingType'] = $vl['BookingType'];
$hotelArray[$vl['XRateSessionKey']][$vl['TfromDate']->format("Y-m-d")]['RoomArray'][$vl['RoomSysId']]['RoomType'][] = $vl['MealPlanTitle'];
}
// echo "<pre>";print_r($hotelArray);exit;
foreach ($hotelArray as $ky1 => $vK1) {
foreach ($vK1 as $ky => $vK) {
$v = $vK['hotel'];
// echo "<pre>";print_r($v);exit;
$FromDate = date("Y-m-d", strtotime($v['FromDate']));
$ToDate = date("Y-m-d", strtotime($v['ToDate']));
$data[] = array('XRateSessionKey' => $ky1, 'FromDate' => $FromDate, 'ToDate' => $ToDate, 'XRefItemSysId' => $v['XRefItemSysId'], 'EconomyType' => $v['EconomyType'], 'Stars' => $v['Stars'], 'MealPlanType' => $v['MealPlanType'], 'SupplierSysId' => $v['SupplierSysId'], 'CreateDate' => (array) $v['CreatedDate'], 'SupplierName' => $v['SupplierName'], 'ContSysId' => $v['ContSysId'], 'hotelId' => $v['hotelId'], 'ICSourceSysId' => $v['ICSourceSysId'], 'hotelname' => $v['hotelName'], 'City_title' => $v['City_title'], 'country_title' => $v['country_title'], 'RoomArray' => $vK['RoomArray'], "EcomyType" => $v['EcomyType'], "MealPlanTitle" => $v['MealPlanTitle'], "InvIsActive" => $v['InvIsActive'], "IsActive" => $v['IsActive'], "IsWebsite" => $v['IsWebsite'], "PropertyType" => $v['PropertyType']);
}
}
// echo "<pre>";print_r($data); exit;
$this->view->IsB2CSite = $this->IsB2CSite;
$this->view->paginator = $data;
$this->view->paginators = $paginator;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function inventorynewAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$request = Zend_Controller_Front::getInstance()->getRequest();
$objHotel = new Travel_Model_TblHotel();
$objAccoModel = new Travel_Model_AccommodationModel();
//echo '<pre>';print_r($params);echo '</pre>';die;
//$HotelrateCardCalculation = $objAccoModel->HotelrateCardCalculation($this->intLoggedinUserAgencySysId);
$getData['show_room_name'] = true;
$HotelrateCardList = $objAccoModel->HotelrateCardByAgListNew($this->intLoggedinUserAgencySysId, $getData);
$this->view->rateCardList = $HotelrateCardList;
//echo '<pre>';print_r($HotelrateCard$HotelrateCardListList);echo '</pre>';die;
$searchArr = array(
'fromdate' => isset($params['fromdate']) && !empty($params['fromdate']) ? $params['fromdate'] : '',
'todate' => isset($params['todate']) && !empty($params['todate']) ? $params['todate'] : '',
'ToDateLast' => isset($params['ToDateLast']) && !empty($params['ToDateLast']) ? $params['ToDateLast'] : '',
'ContName' => isset($params['ContName']) && !empty($params['ContName']) ? $params['ContName'] : '',
'ContId' => isset($params['ContId']) && !empty($params['ContId']) ? $params['ContId'] : '',
'hotel_name' => isset($params['hotel_name']) && !empty($params['hotel_name']) ? $params['hotel_name'] : '',
'hotel_id' => isset($params['hotel_id']) && !empty($params['hotel_id']) ? $params['hotel_id'] : '',
'ratetype' => isset($params['ratetype']) && !empty($params['ratetype']) ? $params['ratetype'] : '',
'SupplierSysId' => isset($params['SupplierSysId']) && !empty($params['SupplierSysId']) ? $params['SupplierSysId'] : '',
);
$this->view->searchArr = $searchArr;
if ($request->isPost()) {
$result = $objAccoModel->hotelDetailsRates($params['hotel_id'], $this->intLoggedinUserAgencySysId);
$from_dt = isset($params['fromdate']) && !empty($params['fromdate']) ? $params['fromdate'] : '0';
$to_dt = isset($params['todate']) && !empty($params['todate']) ? $params['todate'] : '0';
$strFromDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($from_dt, 'd-m-y');
$strToDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($to_dt, 'd-m-y');
$strToDates = date("Y-m-d", strtotime("+1 day", strtotime($strToDate)));
$begin = new DateTime($strFromDate);
$end = new DateTime($strToDates);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
$this->view->period = $period;
$this->view->hotelDetails = !empty($result) ? $result : '';
}
//print_r($result);die;
//For display message
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function inventoryCalendarAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$request = Zend_Controller_Front::getInstance()->getRequest();
$objHotel = new Travel_Model_TblHotel();
$objAccoModel = new Travel_Model_AccommodationModel();
$hotel_id = isset($params['hotel_id']) && !empty($params['hotel_id']) ? (int) $params['hotel_id'] : 0;
$hotel_name = isset($params['hotel_name']) && !empty($params['hotel_name']) ? trim($params['hotel_name']) : '';
$first_day_this_month = date('01'); // hard-coded '01' for first day
$last_day_this_month = date('t');
//echo "<pre>";print_r($last_day_this_month);die;
$searchArr = array(
'fromdate' => isset($params['fromdate']) && !empty($params['fromdate']) ? $params['fromdate'] : '01-' . date('m-Y'),
'todate' => isset($params['todate']) && !empty($params['todate']) ? $params['todate'] : $last_day_this_month . '-' . date('m-Y'),
'ToDateLast' => isset($params['ToDateLast']) && !empty($params['ToDateLast']) ? $params['ToDateLast'] : '',
'ContName' => isset($params['ContName']) && !empty($params['ContName']) ? $params['ContName'] : '',
'ContId' => isset($params['ContId']) && !empty($params['ContId']) ? $params['ContId'] : '',
'hotel_name' => isset($params['hotel_name']) && !empty($params['hotel_name']) ? $params['hotel_name'] : '',
'hotel_id' => (isset($params['hotel_id']) && !empty($params['hotel_id']) && $hotel_name != '') ? $params['hotel_id'] : '',
'room_type' => isset($params['room_type']) && !empty($params['room_type']) ? $params['room_type'] : 0,
'SupplierSysId' => isset($params['SupplierSysId']) && !empty($params['SupplierSysId']) ? $params['SupplierSysId'] : '',
);
$this->view->searchArr = $searchArr;
//if ($request->isPost()) {
$HotelrateCardList = $objAccoModel->HotelrateCardByAgListNew($this->intLoggedinUserAgencySysId, $searchArr);
$this->view->rateCardList = $HotelrateCardList;
// echo '<pre>';print_r($HotelrateCardList);echo '</pre>';die;
//}
if ($hotel_id > 0) {
$this->view->RoomDetailsList = $RoomDetailsList = $objAccoModel->HotelRoomDetailsList($hotel_id, $this->intLoggedinUserAgencySysId);
}
// echo '<pre>';print_r($RoomDetailsList);echo '</pre>';die;
//For display message
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function inventoryCalendarDetailAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$request = Zend_Controller_Front::getInstance()->getRequest();
$objHotel = new Travel_Model_TblHotel();
$objAccoModel = new Travel_Model_AccommodationModel();
$searchData = [
'fromdate' => isset($params['date']) && !empty($params['date']) ? $params['date'] : '',
'todate' => isset($params['date']) && !empty($params['date']) ? $params['date'] : '',
'hotel_id' => isset($params['hid']) && !empty($params['hid']) ? $params['hid'] : 0,
'room_type' => isset($params['rtp']) && !empty($params['rtp']) ? $params['rtp'] : 0,
'show_room_name' => true
];
$HotelrateCardList = $objAccoModel->HotelrateCardByAgListNew($this->intLoggedinUserAgencySysId, $searchData);
// echo '<pre>';print_r($HotelrateCardList);echo '</pre>';die;
$this->view->rateCardList = $HotelrateCardList;
}
public function getinventorysearchAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$params = Zend_Controller_Front::getInstance()->getRequest()->getPost();
//print_r($params);die('ddd');
if ($this->_request->isXmlHttpRequest()) {
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
//$HotelrateCardCalculation = $objAccoModel->HotelrateCardCalculation($this->intLoggedinUserAgencySysId);
$getData['show_room_name'] = true;
$HotelrateCardList = $objAccoModel->HotelrateCardByAgListNew($this->intLoggedinUserAgencySysId, $getData);
$this->view->rateCardList = $HotelrateCardList;
$result = $objAccoModel->hotelDetailsRates($params['hotel_id'], $this->intLoggedinUserAgencySysId);
$from_dt = isset($params['fromdate']) && !empty($params['fromdate']) ? $params['fromdate'] : '0';
$to_dt = isset($params['todate']) && !empty($params['todate']) ? $params['todate'] : '0';
$strFromDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($from_dt, 'd-m-y');
$strToDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($to_dt, 'd-m-y');
$strToDates = date("Y-m-d", strtotime("+1 day", strtotime($strToDate)));
$begin = new DateTime($strFromDate);
$end = new DateTime($strToDates);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
$this->view->period = $period;
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->fromdate = !empty($params['fromdate']) ? $params['fromdate'] : '';
$this->view->todate = !empty($params['todate']) ? $params['todate'] : '';
//print_r($period);die('ddd');
$this->render('ajax-html-inventory-result');
/* $html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/accommodation/');
$html->assign('type', 'getinventorysearch');
$html->assign('data', $params);
echo $bodyText = $html->render('ajax-html-inventory-result.phtml'); */
}
}
public function individualinventoryAction() {
$this->view->layout()->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->_helper->layout->disableLayout();
$params = Zend_Controller_Front::getInstance()->getRequest()->getPost();
//print_r($params);die;
$objAccoModel = new Travel_Model_AccommodationModel();
if (isset($params['id']) && $params['id'] == 0) {
$getRTDTSR = $objAccoModel->getRatedetailsSingleRow($params['hotel_id'], $params['XRefItemSysId'], $params['EconomyType'], $params['MealPlanType'], $params['SupplierSysId'], $this->intLoggedinUserAgencySysId);
$this->view->getRTDTSR = $getRTDTSR;
}
$HotelRoomDetails = $objAccoModel->getRoomQtyOnly($params['hotel_id'], $this->intLoggedinUserAgencySysId, $params['XRefItemSysId']);
$RateDeByInvnItemSysId = $objAccoModel->HotelRateDeByInvnItemSysId($params['hotel_id'], $this->intLoggedinUserAgencySysId, $params['id']);
$result = $objAccoModel->hotelDetailsRates($params['hotel_id'], $this->intLoggedinUserAgencySysId);
$this->view->RateDeByInvnItemSysId = $RateDeByInvnItemSysId;
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotelRoomDetails = !empty($HotelRoomDetails) ? $HotelRoomDetails : '';
$this->view->params = $params;
// echo "<pre>";print_r($RateDeByInvnItemSysId);die;
} else {
die;
}
}
public function bulkinventoryAction() {
$this->view->layout()->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->_helper->layout->disableLayout();
$params = Zend_Controller_Front::getInstance()->getRequest()->getPost();
//print_r($params);die;
$objAccoModel = new Travel_Model_AccommodationModel();
if (isset($params['id']) && $params['id'] == 0) {
$getRTDTSR = $objAccoModel->getRatedetailsSingleRow($params['hotel_id'], $params['XRefItemSysId'], $params['EconomyType'], $params['MealPlanType'], $this->intLoggedinUserAgencySysId);
$this->view->getRTDTSR = $getRTDTSR;
}
$HotelRoomDetails = $objAccoModel->getRoomQtyOnly($params['hotel_id'], $this->intLoggedinUserAgencySysId, $params['XRefItemSysId']);
$RateDeByInvnItemSysId = $objAccoModel->HotelRateDeByInvnItemSysId($params['hotel_id'], $this->intLoggedinUserAgencySysId, $params['id']);
$result = $objAccoModel->hotelDetailsRates($params['hotel_id'], $this->intLoggedinUserAgencySysId);
$this->view->RateDeByInvnItemSysId = $RateDeByInvnItemSysId;
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotelRoomDetails = !empty($HotelRoomDetails) ? $HotelRoomDetails : '';
$this->view->params = $params;
}
}
public function addHotelsAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objHotel = new Travel_Model_TblHotel();
$objAgency = new Travel_Model_TblAgency();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel->orderByField = " TB_Master_Accom_AccomAminity.AminityId ";
$objHotel->orderBy = "";
$this->view->arrMasterAccomAminities = $objHotel->getMasterAccomAminities();
$agencyDetails = $objAgency->getAgencyUserList($this->intLoggedinUserAgencySysId);
$this->view->agencyDetails = $agencyDetails;
$cityList = $objHotel->getInventoryCityList($this->intLoggedinUserAgencySysId);
$this->view->cityList = $cityList;
$getMasterRoomType = $objHotel->getMasterRoomType();
$this->view->getMasterRoomType = $getMasterRoomType;
$supplierList = $objHotel->getSuppliersList($cityId = '', $this->intLoggedinUserId);
$this->view->supplierList = $supplierList;
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
if (!$result) {
die('Invalid request!! try again.');
}
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
//echo "<pre>";print_r($RoomDetailsList);die;
$AroundPropertyList = $objAccoModel->AroundPropertyList($params['id']);
$resultImg = $objAccoModel->HotelImageList($params['id']);
$this->view->arrSelectedFacilities = $objHotel->getMasking($params['id']);
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotelImages = !empty($resultImg) ? $resultImg : '';
$this->view->roomDetailsList = !empty($RoomDetailsList) ? $RoomDetailsList : '';
$this->view->AroundPropertyList = !empty($AroundPropertyList) ? $AroundPropertyList : '';
}
if (isset($params['RoomId']) && !empty($params['RoomId'])) {
$HotelRoomDetails = $objAccoModel->HotelRoomDetails($params['id'], $this->intLoggedinUserAgencySysId, $params['RoomId']);
$this->view->hotelRoomDetails = !empty($HotelRoomDetails) ? $HotelRoomDetails : '';
$this->_redirect('/accommodation/add-hotels/id/' . $params['id'] . '/#!/roomdetails/' . $params['RoomId']);
}
if (isset($params['AroundPId']) && !empty($params['AroundPId'] && $params['pages'] == 'aroundproperty')) {
$aroundPropertyDetails = $objAccoModel->AroundPropertyDetails($params['id'], $params['AroundPId']);
$this->view->aroundPropertyDetails = !empty($aroundPropertyDetails) ? $aroundPropertyDetails : '';
}
if ($this->_request->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objCountry = new Travel_Model_TblCountry();
$this->view->arrCountryList = $objCountry->getCountryList();
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->view->RoomId = isset($params['RoomId']) ? $params['RoomId'] : '0';
$this->view->AroundPId = isset($params['AroundPId']) ? $params['AroundPId'] : '0';
$this->render('ajaxrequest/' . $params['pages'] . '');
}
}
public function addhotelAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$objCountry = new Travel_Model_TblCountry();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$resultImg = $objAccoModel->HotelImageList($params['id']);
}
//print_r($params['id']);
$this->view->arrCountryList = $objCountry->getCountryList();
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotelImages = !empty($resultImg) ? $resultImg : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/addhotel');
}
public function addVillasAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objHotel = new Travel_Model_TblHotel();
$objAgency = new Travel_Model_TblAgency();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel->orderByField = " TB_Master_Accom_AccomAminity.AminityId ";
$objHotel->orderBy = "";
$this->view->arrMasterAccomAminities = $objHotel->getMasterAccomAminities();
$agencyDetails = $objAgency->getAgencyUserList($this->intLoggedinUserAgencySysId);
$this->view->agencyDetails = $agencyDetails;
$cityList = $objHotel->getInventoryCityList($this->intLoggedinUserAgencySysId);
$this->view->cityList = $cityList;
$getMasterRoomType = $objHotel->getMasterRoomType();
$this->view->getMasterRoomType = $getMasterRoomType;
$supplierList = $objHotel->getSuppliersList($cityId = '', $this->intLoggedinUserId);
$this->view->supplierList = $supplierList;
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
if (!$result) {
die('Invalid request!! try again.');
}
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
$AroundPropertyList = $objAccoModel->AroundPropertyList($params['id']);
$resultImg = $objAccoModel->HotelImageList($params['id']);
$this->view->arrSelectedFacilities = $objHotel->getMasking($params['id']);
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotelImages = !empty($resultImg) ? $resultImg : '';
$this->view->roomDetailsList = !empty($RoomDetailsList) ? $RoomDetailsList : '';
$this->view->AroundPropertyList = !empty($AroundPropertyList) ? $AroundPropertyList : '';
}
if (isset($params['RoomId']) && !empty($params['RoomId'])) {
$HotelRoomDetails = $objAccoModel->HotelRoomDetails($params['id'], $this->intLoggedinUserAgencySysId, $params['RoomId']);
$this->view->hotelRoomDetails = !empty($HotelRoomDetails) ? $HotelRoomDetails : '';
$this->_redirect('/accommodation/add-villas/id/' . $params['id'] . '/#!/villadetails/' . $params['RoomId']);
}
if (isset($params['AroundPId']) && !empty($params['AroundPId'] && $params['pages'] == 'aroundproperty')) {
$aroundPropertyDetails = $objAccoModel->AroundPropertyDetails($params['id'], $params['AroundPId']);
$this->view->aroundPropertyDetails = !empty($aroundPropertyDetails) ? $aroundPropertyDetails : '';
}
if ($this->_request->isXmlHttpRequest()) {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objCountry = new Travel_Model_TblCountry();
$this->view->arrCountryList = $objCountry->getCountryList();
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->view->RoomId = isset($params['RoomId']) ? $params['RoomId'] : '0';
$this->view->AroundPId = isset($params['AroundPId']) ? $params['AroundPId'] : '0';
$this->render('ajaxrequest/' . $params['pages'] . '');
}
}
public function addvillaAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$objCountry = new Travel_Model_TblCountry();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
if (!empty($RoomDetailsList)) {
$villaRoomID = $RoomDetailsList[0]['room']['ItemSysId'];
$HotelVillaRoomDetails = $objAccoModel->HotelRoomDetails($params['id'], $this->intLoggedinUserAgencySysId, $villaRoomID);
}
$resultImg = $objAccoModel->HotelImageList($params['id']);
}
$this->view->arrCountryList = $objCountry->getCountryList();
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotelVillRoomDetails = !empty($HotelVillaRoomDetails) ? $HotelVillaRoomDetails : '';
$this->view->hotelImages = !empty($resultImg) ? $resultImg : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/addvilla');
}
public function villacontactAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
}
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/villacontact');
}
public function villafacilityAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel = new Travel_Model_TblHotel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$this->view->arrSelectedFacilities = $objHotel->getMasking($params['id']);
}
$objHotel->orderByField = " TB_Master_Accom_AccomAminity.AminityId ";
$objHotel->orderBy = "";
$this->view->arrMasterAccomAminities = $objHotel->getMasterAccomAminities();
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/villafacility');
}
public function villaaroundpropertyAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel = new Travel_Model_TblHotel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$AroundPropertyList = $objAccoModel->AroundPropertyList($params['id']);
}
if (isset($params['AroundPId']) && !empty($params['AroundPId'])) {
$aroundPropertyDetails = $objAccoModel->AroundPropertyDetails($params['id'], $params['AroundPId']);
$this->view->aroundPropertyDetails = !empty($aroundPropertyDetails) ? $aroundPropertyDetails : '';
$this->view->AroundPId = isset($params['AroundPId']) ? $params['AroundPId'] : '0';
}
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->view->AroundPropertyList = !empty($AroundPropertyList) ? $AroundPropertyList : '';
$this->render('ajaxrequest/ng/villaaroundproperty');
}
public function villadetailsAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel = new Travel_Model_TblHotel();
$getMasterRoomType = $objHotel->getMasterRoomType();
$this->view->getMasterRoomType = $getMasterRoomType;
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
}
if (isset($params['RoomId']) && !empty($params['RoomId'])) {
$HotelRoomDetails = $objAccoModel->HotelRoomDetails($params['id'], $this->intLoggedinUserAgencySysId, $params['RoomId']);
$this->view->hotelRoomDetails = !empty($HotelRoomDetails) ? $HotelRoomDetails : '';
$this->view->RoomId = isset($params['RoomId']) ? $params['RoomId'] : '0';
}
$this->view->HotelBedTypeDetails = $HotelBedTypeDetails = $objAccoModel->HotelBedTypeDetails();
$this->view->HotelRoomViewDetails = $HotelRoomViewDetails = $objAccoModel->HotelRoomViewDetails();
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->view->roomDetailsList = !empty($RoomDetailsList) ? $RoomDetailsList : '';
$this->render('ajaxrequest/ng/villadetails');
}
public function villaroomdetailsAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel = new Travel_Model_TblHotel();
$getMasterRoomType = $objHotel->getMasterRoomType();
$this->view->getMasterRoomType = $getMasterRoomType;
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
}
if (isset($params['RoomId']) && !empty($params['RoomId'])) {
$HotelVillaRoomDetails = $objAccoModel->HotelVillaRoomDetails($params['id'], $this->intLoggedinUserAgencySysId, $params['RoomId']);
$this->view->hotelRoomDetails = !empty($HotelVillaRoomDetails) ? $HotelVillaRoomDetails : '';
$this->view->RoomId = isset($params['RoomId']) ? $params['RoomId'] : '0';
}
$VillaRoomDetailsList = $objAccoModel->HotelVillaRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
$this->view->HotelBedTypeDetails = $HotelBedTypeDetails = $objAccoModel->HotelBedTypeDetails();
$this->view->HotelRoomViewDetails = $HotelRoomViewDetails = $objAccoModel->HotelRoomViewDetails();
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->view->roomDetailsList = !empty($VillaRoomDetailsList) ? $VillaRoomDetailsList : '';
$this->render('ajaxrequest/ng/villaroomdetails');
}
public function villatncAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$TblAgency = new Travel_Model_TblAgency();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
}
$getAgencyTnCDetails = $TblAgency->getAgencyTnCDetails($this->intLoggedinUserAgencySysId);
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->getAgencyTnCDetails = !empty($getAgencyTnCDetails) ? $getAgencyTnCDetails : array();
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/villatnc');
}
public function villaMealplanratesAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = $this->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$mealPlanRates = $objAccoModel->mealPlanRates($params['id'], $this->intLoggedinUserAgencySysId);
}
if (!empty($mealPlanRates)) {
foreach ($mealPlanRates as $key => $mp) {
$newMealPlanArr[$mp['meal_type']] = $mp;
}
}
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->mealPlanRates = !empty($newMealPlanArr) ? $newMealPlanArr : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/villa-mealplanrates');
}
public function hotelcontactAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
}
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/hotelcontact');
}
public function hotelfacilityAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel = new Travel_Model_TblHotel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$this->view->arrSelectedFacilities = $objHotel->getMasking($params['id']);
}
$objHotel->orderByField = " TB_Master_Accom_AccomAminity.AminityId ";
$objHotel->orderBy = "";
$this->view->arrMasterAccomAminities = $objHotel->getMasterAccomAminities();
//print_r($params['id']);
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/hotelfacility');
}
public function aroundpropertyAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel = new Travel_Model_TblHotel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$AroundPropertyList = $objAccoModel->AroundPropertyList($params['id']);
}
//print_r($params);
if (isset($params['AroundPId']) && !empty($params['AroundPId'])) {
$aroundPropertyDetails = $objAccoModel->AroundPropertyDetails($params['id'], $params['AroundPId']);
$this->view->aroundPropertyDetails = !empty($aroundPropertyDetails) ? $aroundPropertyDetails : '';
$this->view->AroundPId = isset($params['AroundPId']) ? $params['AroundPId'] : '0';
}
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->view->AroundPropertyList = !empty($AroundPropertyList) ? $AroundPropertyList : '';
$this->render('ajaxrequest/ng/aroundproperty');
}
public function getaddhoteldetailsAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$getRoomQtyOnly = array();
//if ($this->_request->isXmlHttpRequest()) {
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
//print_r($params);die('dfff');
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$resultImg = $objAccoModel->HotelImageList($params['id']);
$objCity = new Travel_Model_TblCity();
$objCity->intContSysId = !empty($result['ContSysId']) ? $result['ContSysId'] : '101';
$arrCitiList = $objCity->getCityList();
$getRoomQtyOnly = $objAccoModel->getRoomQtyOnly($params['id'], $this->intLoggedinUserAgencySysId);
//echo "<pre>";print_r($result);die;
} else {
die();
}
$arrCity = array();
if (!empty($arrCitiList)) {
foreach ($arrCitiList as $city) {
$arrCity[] = array('CityId' => $city['CityId'], 'Title' => preg_replace('/[^A-Za-z0-9\.\, -]/', '', trim($city['Title'])));
}
}
$data = array();
if ($result) {
$data['records'] = $result;
$data['resultimg'] = $resultImg;
$data['arrCity'] = $arrCity;
$data['status'] = 'OK';
} else {
$data['records'] = array();
$data['resultimg'] = array();
$data['arrCity'] = array();
$data['status'] = 'ERR';
}
$data['rooms'] = !empty($getRoomQtyOnly) ? 1 : 0;
$data['RateType'] = (isset($result['RateType']) && $result['RateType'] !== NULL) ? 1 : 0;
try {
// echo "<pre>";print_r($resultImg);die;
echo json_encode($data);
exit;
} catch (Exception $ex) {
die($ex->getMessage());
}
//}
}
public function getaroundprAction() {
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if (isset($params['id']) && !empty($params['id'])) {
$AroundPropertyList = $objAccoModel->AroundPropertyList($params['id']);
$getRoomQtyOnly = $objAccoModel->getRoomQtyOnly($params['id'], $this->intLoggedinUserAgencySysId);
}
if ($AroundPropertyList) {
$data['records'] = $AroundPropertyList;
$data['status'] = 'OK';
} else {
$data['records'] = array();
$data['status'] = 'ERR';
}
$data['rooms'] = !empty($getRoomQtyOnly) ? 1 : 0;
$data['RateType'] = (isset($AroundPropertyList[0]['RateType']) && $AroundPropertyList[0]['RateType'] !== NULL) ? 1 : 0;
echo json_encode($data);
exit;
}
public function getnghotelcontactAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$DefaultCountryCode = $sessionLogin_user->agencyDetails['DefaultCountryCode'];
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$countryshortcode = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->countryshortcode(($result['countrycode'] != null) ? str_replace('+', '', trim($result['countrycode'])) : 'null');
$getRoomQtyOnly = $objAccoModel->getRoomQtyOnly($params['id'], $this->intLoggedinUserAgencySysId);
}
if ($result) {
$data['records'] = $result;
$data['status'] = 'OK';
$data['countrycode'] = $countryshortcode;
} else {
$data['records'] = array();
$data['status'] = 'ERR';
$data['countrycode'] = '91';
}
$data['rooms'] = !empty($getRoomQtyOnly) ? 1 : 0;
$data['RateType'] = (isset($result['RateType']) && $result['RateType'] !== NULL) ? 1 : 0;
echo json_encode($data);
exit;
}
public function getnghotelfacilityAction() {
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel = new Travel_Model_TblHotel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$arrSelectedFacilities = $objHotel->getMasking($params['id']);
$getRoomQtyOnly = $objAccoModel->getRoomQtyOnly($params['id'], $this->intLoggedinUserAgencySysId);
}
if ($result) {
$data['records'] = $result;
$data['arrSelectedFacilities'] = $arrSelectedFacilities;
$data['status'] = 'OK';
} else {
$data['records'] = array();
$data['arrSelectedFacilities'] = array();
$data['status'] = 'ERR';
}
$data['rooms'] = !empty($getRoomQtyOnly) ? 1 : 0;
$data['RateType'] = (isset($result['RateType']) && $result['RateType'] !== NULL) ? 1 : 0;
echo json_encode($data);
exit;
}
public function roomdetailsAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel = new Travel_Model_TblHotel();
$getMasterRoomType = $objHotel->getMasterRoomType();
$this->view->getMasterRoomType = $getMasterRoomType;
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
}
if (isset($params['RoomId']) && !empty($params['RoomId'])) {
$HotelRoomDetails = $objAccoModel->HotelRoomDetails($params['id'], $this->intLoggedinUserAgencySysId, $params['RoomId']);
$this->view->hotelRoomDetails = !empty($HotelRoomDetails) ? $HotelRoomDetails : '';
$this->view->RoomId = isset($params['RoomId']) ? $params['RoomId'] : '0';
}
$this->view->HotelBedTypeDetails = $HotelBedTypeDetails = $objAccoModel->HotelBedTypeDetails();
$this->view->HotelRoomViewDetails = $HotelRoomViewDetails = $objAccoModel->HotelRoomViewDetails();
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->view->roomDetailsList = !empty($RoomDetailsList) ? $RoomDetailsList : '';
$this->render('ajaxrequest/ng/roomdetails');
}
public function mealplanratesAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = $this->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$mealPlanRates = $objAccoModel->mealPlanRates($params['id'], $this->intLoggedinUserAgencySysId);
}
if (!empty($mealPlanRates)) {
foreach ($mealPlanRates as $key => $mp) {
$newMealPlanArr[$mp['meal_type']] = $mp;
}
}
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->mealPlanRates = !empty($newMealPlanArr) ? $newMealPlanArr : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/mealplanrates');
}
public function updatemealratesAction() {
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$params = $this->getRequest()->getPost();
if (!empty($params) && (int) $params['update_hotel_id'] > 0) {
$result = $objAccoModel->hotelDetails($params['update_hotel_id'], $this->intLoggedinUserAgencySysId);
$where = array('AcoomSysId =?' => $params['update_hotel_id'], 'AgencySysId =?' => $this->intLoggedinUserAgencySysId);
$insert_im = array('IsMarkForDelete' => 1, 'IsActive' => 0);
$this->db->update('Tb_Agency_Accom_Meal_Plan_Rate', $insert_im, $where);
$currentDate = date('Y-m-d h:i:s');
if (isset($params['RateType']) && ($params['RateType'] > 0)) {
for ($i = 0; $i < count($params['adult']); $i++) {
foreach ($params['adult'][$i] as $key => $val) {
if ($params['RateType'] == 2 && $key == 6) {
} else {
if ($val != '') {
$meanType = [
'AcoomSysId' => $params['update_hotel_id'],
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'meal_type' => $key,
'AdultAmount' => (isset($val) && $val != '') ? $val : '0',
'ChildAmount' => (isset($params['child'][$i][$key]) && $params['child'][$i][$key] != '') ? $params['child'][$i][$key] : '0',
'IsActive' => 1,
'IsMarkForDelete' => 0,
'CreateDate' => $currentDate,
'UpdateDate' => $currentDate
];
$this->db->insert('Tb_Agency_Accom_Meal_Plan_Rate', $meanType);
}
}
}
}
}
// if ($result['RateType'] == NULL) {
$whereA = array('AccomSysId =?' => $params['update_hotel_id']);
$this->db->update('TB_IC_Accomdation', array('HotelRateType' => (int) $params['HotelRateType'], 'RateType' => (int) $params['RateType']), $whereA);
// }
if ($result['HotelRateType'] != $params['HotelRateType']) {
$whereIn = array('AccomSysId =?' => $params['update_hotel_id']);
$update_im = array('IsMarkForDelete' => 1, 'IsActive' => 0, 'UpdatedDate' => $currentDate);
$this->db->update('Tb_MP_Accomdation_Room_Inventory', $update_im, $whereIn);
}
if ($result['RateType'] != $params['RateType']) {
$whereIn = array('AccomSysId =?' => $params['update_hotel_id']);
$update_im = array('IsMarkForDelete' => 1, 'IsActive' => 0, 'UpdatedDate' => $currentDate);
$this->db->update('Tb_MP_Accomdation_Room_Inventory', $update_im, $whereIn);
}
$response = array('success' => true, 'message' => 'Meal Rates Updated');
echo json_encode($response);
exit;
}
}
public function addupdatepromotionAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = $this->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
$mealPlanRates = $objAccoModel->mealPlanRates($params['id'], $this->intLoggedinUserAgencySysId);
}
if (isset($mealPlanRates)) {
foreach ($mealPlanRates as $key => $mp) {
$newMealPlanArr[] = $mp['meal_type'];
}
}
$getPromotionRateType = array();
if (isset($params['prmotionID']) && !empty($params['prmotionID'])) {
$promotionDataBYID = $objAccoModel->getpromotionByID($params['prmotionID'], $params['id'], $this->intLoggedinUserAgencySysId);
$getPromotionRate = $objAccoModel->getPromotionRateType($params['prmotionID'], $params['id'], $this->intLoggedinUserAgencySysId);
foreach ($getPromotionRate as $key => $value) {
$getPromotionRateType[$value['RoomSysId']][$value['MealPlanType']] = $value;
}
}
//echo "<pre>";print_r($getPromotionRateType);die;
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->newMealPlanArr = !empty($newMealPlanArr) ? $newMealPlanArr : '';
$this->view->RoomDetailsList = !empty($RoomDetailsList) ? $RoomDetailsList : '';
$this->view->promotionDatabyId = !empty($promotionDataBYID) ? $promotionDataBYID : '';
$this->view->getPromotionRateType = !empty($getPromotionRateType) ? $getPromotionRateType : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/addupdatepromotion');
}
public function getnghotelmealplanrateAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = $this->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$mealPlanRates = $newMealPlanArr = array();
if (isset($params['id']) && !empty($params['id'])) {
$getHotelRateTypes = $objAccoModel->getHotelRateType($params['id'], $this->intLoggedinUserAgencySysId);
echo "<pre>";
print_r($getHotelRateTypes);
die;
$mealPlanRates = $objAccoModel->mealPlanRates($params['id'], $this->intLoggedinUserAgencySysId);
}
$newMealPlanArr[6] = array('AdultAmount' => '', 'ChildAmount' => '');
$newMealPlanArr[7] = array('AdultAmount' => '', 'ChildAmount' => '');
$newMealPlanArr[8] = array('AdultAmount' => '', 'ChildAmount' => '');
$newMealPlanArr[9] = array('AdultAmount' => '', 'ChildAmount' => '');
$newMealPlanArr[10] = array('AdultAmount' => '', 'ChildAmount' => '');
$newMealPlanArr[3] = array('AdultAmount' => '', 'ChildAmount' => '');
if (!empty($mealPlanRates)) {
foreach ($mealPlanRates as $key => $mp) {
$newMealPlanArr[$mp['meal_type']] = $mp;
}
}
$data['records'] = $newMealPlanArr;
$data['RateType'] = $getHotelRateTypes['RateType'];
$data['IsRateType'] = $getHotelRateTypes['RateType'] !== NULL ? 1 : 0;
$data['status'] = 'OK';
echo json_encode($data);
exit;
}
public function promotionAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = $this->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
$mealPlanRates = $objAccoModel->mealPlanRates($params['id'], $this->intLoggedinUserAgencySysId);
$promotionList = $objAccoModel->getpromotionList($params['id'], $this->intLoggedinUserAgencySysId);
}
if (isset($mealPlanRates)) {
foreach ($mealPlanRates as $key => $mp) {
$newMealPlanArr[] = $mp['meal_type'];
}
}
$NewPromotionArr = array();
$accproid = null;
foreach ($promotionList as $key => $val) {
if ($val['PromotionsSysId'] == null) {
$accproid = $val['AccomPromotionsSysId'];
$NewPromotionArr[$accproid][$accproid] = $val;
}
$NewPromotionArr[$accproid][$accproid]['MealTypearr'][$val['MealType']] = $val['MealType'];
$NewPromotionArr[$accproid][$accproid]['RoomTypearr'][$val['RoomType']] = $val['title'];
}
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->newMealPlanArr = !empty($newMealPlanArr) ? $newMealPlanArr : '';
$this->view->RoomDetailsList = !empty($RoomDetailsList) ? $RoomDetailsList : '';
$this->view->promotionList = !empty($NewPromotionArr) ? $NewPromotionArr : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/promotion');
}
public function addHotelPromotionAction() {
$this->_helper->layout->disableLayout();
$objHotel = new Travel_Model_TblHotel();
$objAccoModel = new Travel_Model_AccommodationModel();
$post = $this->getRequest()->getPost();
$AcoomSysId = (isset($post['hotel_id']) && ($post['hotel_id'] != '')) ? $post['hotel_id'] : '';
$response = array('success' => false, 'message' => '! Invalid Request');
if (!empty($post) && ($AcoomSysId && ((int) $AcoomSysId > 0))) {
$getAccomRoomDetails = $objAccoModel->getAccomRoomDetails($AcoomSysId, $this->intLoggedinUserAgencySysId);
$getAccomRoomArray = array();
foreach ($getAccomRoomDetails as $rmkey => $rmvalue) {
$getAccomRoomArray[$rmvalue['RoomTypeId']] = $rmvalue['ItemSysId'];
}
$SupplierSysId = (int) $getAccomRoomDetails[0]['SupplierSysId'];
$CurrencyType = (int) $getAccomRoomDetails[0]['CurrencyType'];
$ChildAge = (int) $getAccomRoomDetails[0]['ChildAge'];
$NetRateType = (int) $getAccomRoomDetails[0]['NetRateType'];
$RackCommission = (int) $getAccomRoomDetails[0]['RackCommission'];
$WeekendDefine = trim($getAccomRoomDetails[0]['WeekendDefine']);
$currentDate = date('Y-m-d h:i:s');
$offerType = $post['offerType'];
$mealType = isset($post['MealType']) ? $post['MealType'] : array();
$roomType = isset($post['RoomType']) ? $post['RoomType'] : array();
$AccomPromotionsSysId = !empty($post['AccomPromotionsSysId']) ? $post['AccomPromotionsSysId'] : '';
$PromotionType = (int) $post['PromotionType'];
$b2b_markup = isset($post['b2b_markup']) ? $post['b2b_markup'] : array();
$b2c_markup = isset($post['b2c_markup']) ? $post['b2c_markup'] : array();
$sg_net_wd = isset($post['sg_net_wd']) ? $post['sg_net_wd'] : array();
$sg_net_wk = isset($post['sg_net_wk']) ? $post['sg_net_wk'] : array();
$db_net_wd = isset($post['db_net_wd']) ? $post['db_net_wd'] : array();
$db_net_wk = isset($post['db_net_wk']) ? $post['db_net_wk'] : array();
$ex_wbed_net_wd = isset($post['ex_wbed_net_wd']) ? $post['ex_wbed_net_wd'] : array();
$ex_wbed_net_wk = isset($post['ex_wbed_net_wk']) ? $post['ex_wbed_net_wk'] : array();
$tri_net_wd = isset($post['tri_net_wd']) ? $post['tri_net_wd'] : array();
$tri_net_wk = isset($post['tri_net_wk']) ? $post['tri_net_wk'] : array();
$chpaid_net_wd = isset($post['chpaid_net_wd']) ? $post['chpaid_net_wd'] : array();
$chpaid_net_wk = isset($post['chpaid_net_wk']) ? $post['chpaid_net_wk'] : array();
if ($PromotionType == 3) {
foreach ($roomType as $roomVal) {
if (!empty($mealType)) {
foreach ($mealType as $mealVal) {
$DOccupCostChech = (isset($db_net_wd[(int) $roomVal][(int) $mealVal])) ? $db_net_wd[(int) $roomVal][(int) $mealVal] : 0;
if (empty($DOccupCostChech)) {
$response = array('success' => false, 'message' => 'Please enter at least double occupancy net rate.');
echo json_encode($response);
exit;
}
}
}
}
}
// echo "<pre>";print_r($db_net_wd);die;
if (!empty($AccomPromotionsSysId)) {
$data = array('IsActive' => '0', 'IsMarkForDelete' => '1');
$objHotel->updateAccomPromotionsStatus($data, $AcoomSysId, $AccomPromotionsSysId, $PromotionType);
}
$k = 1;
$RoomInventoryData = array();
$RoomRateData = array();
if ($PromotionType == 3) {
$post['PromotionValue'] = 0;
}
$PromotionsSysId = null;
foreach ($roomType as $roomVal) {
$XRefItemSysId = isset($getAccomRoomArray[(int) $roomVal]) ? $getAccomRoomArray[(int) $roomVal] : '0';
if (!empty($mealType)) {
foreach ($mealType as $mealVal) {
$promotoType = [
'AcoomSysId' => $AcoomSysId,
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'RoomType' => (int) $roomVal,
'MealType' => (int) $mealVal,
'Currency' => isset($post['CurrencyType']) && ($post['CurrencyType'] != '') ? $post['CurrencyType'] : 0,
'OfferType' => $post['offerType'],
'PromotionName' => $post['PromotionName'],
'PromotionCode' => $post['PromotionCode'],
'Description' => $post['Description'],
'PromotionType' => $post['PromotionType'],
'PromotionValue' => !empty($post['PromotionValue']) ? $post['PromotionValue'] : 0,
'FromBookingDate' => $this->formatDate($post['FromBookingDate']),
'ToBookingDate' => $this->formatDate($post['ToBookingDate']),
'IsStayPeriod' => isset($post['IsStayPeriod']) ? 1 : 0,
'FromStayPeriod' => $this->formatDate($post['FromStayPeriod']),
'ToStayPeriod' => $this->formatDate($post['ToStayPeriod']),
'IsNight' => isset($post['IsNight']) ? 1 : 0,
'MinNight' => isset($post['MinNight']) ? $post['MinNight'] : '',
'MaxNight' => isset($post['MaxNight']) ? $post['MaxNight'] : '',
'IsMinRoom' => isset($post['IsMinRoom']) ? 1 : 0,
'MinRoom' => isset($post['MinRoom']) ? $post['MinRoom'] : '',
'IsDisplay' => $post['IsDisplay'],
'CreateDate' => $currentDate,
'UpdateDate' => $currentDate,
'IsActive' => $post['IsActive'],
'IsMarkForDelete' => 0,
'PromotionsSysId' => isset($PromotionsSysId) ? $PromotionsSysId : null
];
// echo "<pre>";print_r($promotoType);
$dbtable = new Zend_Db_Table("Tb_Agency_Accom_Promotions");
$PromotionsSysIdId = $dbtable->insert($promotoType);
if ($k == 1) {
$PromotionsSysId = $PromotionsSysIdId;
}
$SOccupCost = (isset($sg_net_wd[(int) $roomVal][(int) $mealVal]) && trim($sg_net_wd[(int) $roomVal][(int) $mealVal]) != '') ? $sg_net_wd[(int) $roomVal][(int) $mealVal] : NULL;
$DOccupCost = (isset($db_net_wd[(int) $roomVal][(int) $mealVal]) && trim($db_net_wd[(int) $roomVal][(int) $mealVal]) != '') ? $db_net_wd[(int) $roomVal][(int) $mealVal] : NULL;
$ExtraBedCost = (isset($ex_wbed_net_wd[(int) $roomVal][(int) $mealVal]) && trim($ex_wbed_net_wd[(int) $roomVal][(int) $mealVal]) != '') ? $ex_wbed_net_wd[(int) $roomVal][(int) $mealVal] : NULL;
$TriOccupCost = (isset($tri_net_wd[(int) $roomVal][(int) $mealVal]) && trim($tri_net_wd[(int) $roomVal][(int) $mealVal]) != '') ? $tri_net_wd[(int) $roomVal][(int) $mealVal] : NULL;
$ExtraWOBedCost = (isset($chpaid_net_wd[(int) $roomVal][(int) $mealVal]) && trim($chpaid_net_wd[(int) $roomVal][(int) $mealVal]) != '') ? $chpaid_net_wd[(int) $roomVal][(int) $mealVal] : NULL;
$WkSOccupCost = (isset($sg_net_wk[(int) $roomVal][(int) $mealVal]) && trim($sg_net_wk[(int) $roomVal][(int) $mealVal]) != '') ? $sg_net_wk[(int) $roomVal][(int) $mealVal] : NULL;
$WkDOccupCost = (isset($db_net_wk[(int) $roomVal][(int) $mealVal]) && trim($db_net_wk[(int) $roomVal][(int) $mealVal]) != '') ? $db_net_wk[(int) $roomVal][(int) $mealVal] : NULL;
$WkExtraBedCost = (isset($ex_wbed_net_wk[(int) $roomVal][(int) $mealVal]) && trim($ex_wbed_net_wk[(int) $roomVal][(int) $mealVal]) != '') ? $ex_wbed_net_wk[(int) $roomVal][(int) $mealVal] : NULL;
$WkTriOccupCost = (isset($tri_net_wk[(int) $roomVal][(int) $mealVal]) && trim($tri_net_wk[(int) $roomVal][(int) $mealVal]) != '') ? $tri_net_wk[(int) $roomVal][(int) $mealVal] : NULL;
$WkExtraWOBedCost = (isset($chpaid_net_wk[(int) $roomVal][(int) $mealVal]) && trim($chpaid_net_wk[(int) $roomVal][(int) $mealVal]) != '') ? $chpaid_net_wk[(int) $roomVal][(int) $mealVal] : NULL;
if ($PromotionType == 3) {
$InventoryRateData[$XRefItemSysId][] = array(
"MealPlanType" => (int) $mealVal,
"MarkType" => 1,
"B2BMarkup" => isset($b2b_markup[(int) $roomVal][(int) $mealVal]) ? (float) $b2b_markup[(int) $roomVal][(int) $mealVal] : 0,
"B2CMarkup" => isset($b2c_markup[(int) $roomVal][(int) $mealVal]) ? (float) $b2c_markup[(int) $roomVal][(int) $mealVal] : 0,
"SOccupCost" => $SOccupCost,
"NetSOccupCost" => $SOccupCost,
"DOccupCost" => $DOccupCost,
"NetDOccupCost" => $DOccupCost,
"ExtraBedCost" => $ExtraBedCost,
"NetExtraBedCost" => $ExtraBedCost,
"TriOccupCost" => $TriOccupCost,
"NetTriOccupCost" => $TriOccupCost,
"ExtraWOBedCost" => $ExtraWOBedCost,
"NetExtraWOBedCost" => $ExtraWOBedCost,
"WkSOccupCost" => $WkSOccupCost,
"WkNetSOccupCost" => $WkSOccupCost,
"WkDOccupCost" => $WkDOccupCost,
"WkNetDOccupCost" => $WkDOccupCost,
"WkExtraBedCost" => $WkExtraBedCost,
"WkNetExtraBedCost" => $WkExtraBedCost,
"WkTriOccupCost" => $WkTriOccupCost,
"WkNetTriOccupCost" => $WkTriOccupCost,
"WkExtraWOBedCost" => $WkExtraWOBedCost,
"WkNetExtraWOBedCost" => $WkExtraWOBedCost,
"XRefItemSysId" => isset($getAccomRoomArray[(int) $roomVal]) ? $getAccomRoomArray[(int) $roomVal] : 0,
"PromotionsSysId" => (int) $PromotionsSysId,
);
}
$k++;
}
} else {
$promotoType = [
'AcoomSysId' => $AcoomSysId,
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'RoomType' => (int) $roomVal,
'MealType' => null,
'Currency' => isset($post['CurrencyType']) && ($post['CurrencyType'] != '') ? $post['CurrencyType'] : 0,
'OfferType' => $post['offerType'],
'PromotionName' => $post['PromotionName'],
'PromotionCode' => $post['PromotionCode'],
'Description' => $post['Description'],
'PromotionType' => $post['PromotionType'],
'PromotionValue' => $post['PromotionValue'],
'FromBookingDate' => $this->formatDate($post['FromBookingDate']),
'ToBookingDate' => $this->formatDate($post['ToBookingDate']),
'IsStayPeriod' => isset($post['IsStayPeriod']) ? 1 : 0,
'FromStayPeriod' => $this->formatDate($post['FromStayPeriod']),
'ToStayPeriod' => $this->formatDate($post['ToStayPeriod']),
'IsNight' => isset($post['IsNight']) ? 1 : 0,
'MinNight' => isset($post['MinNight']) ? $post['MinNight'] : '',
'MaxNight' => isset($post['MaxNight']) ? $post['MaxNight'] : '',
'IsMinRoom' => isset($post['IsMinRoom']) ? 1 : 0,
'MinRoom' => isset($post['MinRoom']) ? $post['MinRoom'] : '',
'IsDisplay' => $post['IsDisplay'],
'CreateDate' => $currentDate,
'UpdateDate' => $currentDate,
'IsActive' => $post['IsActive'],
'IsMarkForDelete' => 0,
'PromotionsSysId' => isset($PromotionsSysId) ? $PromotionsSysId : null
];
$dbtable = new Zend_Db_Table("Tb_Agency_Accom_Promotions");
$PromotionsSysIdId = $dbtable->insert($promotoType);
if ($k == 1) {
$PromotionsSysId = $PromotionsSysIdId;
}
$k++;
}
if ($PromotionType == 3) {
$RoomInventoryData[] = array(
'FromDate' => $this->formatDate($post['FromStayPeriod']),
'Todate' => $this->formatDate($post['ToStayPeriod']),
'RoomSysId' => (int) $roomVal,
'XRefItemSysId' => $XRefItemSysId,
'PromotionsSysId' => (int) $PromotionsSysId,
);
}
}
// echo "RoomInventoryData<pre>";print_r($RoomInventoryData);
// echo "InventoryRateData<pre>";print_r($InventoryRateData); die;
foreach ($RoomInventoryData as $key => $value) {
$sessionKey = $objAccoModel->getMaxXRateSessionKey();
$XRefItemSysId = (int) $value['XRefItemSysId'];
$insert = [
'FromDate' => $value['FromDate'],
'Todate' => $value['Todate'],
'XRateSessionKey' => $sessionKey,
'PublishQty' => 0,
'NetInHandQty' => 0,
'BlockQty' => 0,
'SoldQty' => 0,
'UpdatedDate' => $currentDate,
'CreatedDate' => $currentDate,
'AccomSysId' => (int) $AcoomSysId,
'RoomSysId' => (int) $value['RoomSysId'],
'SupplierSysId' => $SupplierSysId,
'AgencySysId' => (int) $this->intLoggedinUserAgencySysId,
'XRefItemSysId' => $XRefItemSysId,
'IsMarkForDelete' => 0,
'IsActive' => 1,
'IsSaleStart' => 1,
'BookingType' => 0,
'PromotionsSysId' => $value['PromotionsSysId'],
];
// echo "<pre>";print_r($insert);
$this->db->insert('Tb_MP_Accomdation_Room_Inventory', $insert);
$RoomInventorySysId = $this->db->lastInsertId();
if (isset($InventoryRateData[$XRefItemSysId])) {
foreach ($InventoryRateData[$XRefItemSysId] as $rtkey => $rtValue) {
$addHoteRate = array(
"AgencySysId" => (int) $this->intLoggedinUserAgencySysId,
"WeekendDefine" => $WeekendDefine,
"MealPlanType" => (int) $rtValue['MealPlanType'],
"MarkType" => $rtValue['MarkType'],
"B2CMarkup" => (float) $rtValue['B2CMarkup'],
"B2BMarkup" => (float) $rtValue['B2BMarkup'],
"SOccupCost" => $rtValue['SOccupCost'],
"NetSOccupCost" => $rtValue['NetSOccupCost'],
"IsTaxOnSOccupCost" => 0,
"TaxSOccupCost" => 0,
"DOccupCost" => $rtValue['DOccupCost'],
"NetDOccupCost" => $rtValue['NetDOccupCost'],
"IsTaxOnDOccupCost" => 0,
"TaxDOccupCost" => 0,
"ExtraBedCost" => $rtValue['ExtraBedCost'],
"NetExtraBedCost" => $rtValue['NetExtraBedCost'],
"IsTaxOnExtraBedCost" => 0,
"TaxExtraBedCost" => 0,
"TriOccupCost" => $rtValue['TriOccupCost'],
"NetTriOccupCost" => $rtValue['NetTriOccupCost'],
"IsTaxOnTriOccupCost" => 0,
"TaxTriOccupCost" => 0,
"ChildAgeLimit" => $ChildAge,
"ExtraWOBedCost" => $rtValue['ExtraWOBedCost'],
"NetExtraWOBedCost" => $rtValue['NetExtraWOBedCost'],
"IsTaxOnExtraWOBedCost" => 0,
"TaxExtraWOBedCost" => 0,
"RateType" => $NetRateType,
"RackCommissionType" => 0,
"RackCommission" => $RackCommission,
"UpdatedDate" => $currentDate,
"CreatedDate" => $currentDate,
"XRefAccoSysId" => (int) $AcoomSysId,
"RoomInventorySysId" => (int) $RoomInventorySysId,
"XRefItemSysId" => (int) $rtValue['XRefItemSysId'],
"TrxCurrency" => $CurrencyType,
"SupplierSysId" => $SupplierSysId,
"IsAllowMarkupSO" => 1,
"IsAllowMarkupDO" => 1,
"IsAllowMarkupTO" => 1,
"IsAllowMarkupEB" => 1,
"IsAllowMarkupWOB" => 1,
"IsActive" => 1,
"IsMarkForDelete" => 0,
"WkSOccupCost" => $rtValue['WkSOccupCost'],
"WkNetSOccupCost" => $rtValue['WkNetSOccupCost'],
"WkDOccupCost" => $rtValue['WkDOccupCost'],
"WkNetDOccupCost" => $rtValue['WkNetDOccupCost'],
"WkExtraBedCost" => $rtValue['WkExtraBedCost'],
"WkNetExtraBedCost" => $rtValue['WkNetExtraBedCost'],
"WkTriOccupCost" => $rtValue['WkTriOccupCost'],
"WkNetTriOccupCost" => $rtValue['WkNetTriOccupCost'],
"WkExtraWOBedCost" => $rtValue['WkExtraWOBedCost'],
"WkNetExtraWOBedCost" => $rtValue['WkNetExtraWOBedCost'],
'IsPromotionalRate' => 1,
'PromotionsSysId' => $value['PromotionsSysId'],
);
//echo "<pre>";print_r($addHoteRate);
try {
$this->db->insert('TB_MP_Inventory_Accom', $addHoteRate);
} catch (Exception $ex) {
die($ex->getMessage());
}
}
}
}
$response = array('success' => true, 'message' => 'Promotion Updated');
}
echo json_encode($response);
exit;
}
private function formatDate($date) {
return !empty($date) ? DateTime::createFromFormat('d/m/Y', $date)->format('Y-m-d H:i:s') : '';
}
public function updatePromotionStatusAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objHotel = new Travel_Model_TblHotel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if (!empty($params) && ($params['AccomPromotionsSysId'] != '' && $params['AccomPromotionsSysId'] > 0)) {
$currentDate = date('Y-m-d h:i:s');
$hotelid = $params['hotelid'];
$AccomPromotionsSysId = $params['AccomPromotionsSysId'];
$PromotionType = (isset($params['PromotionType'])) ? (int) $params['PromotionType'] : 0;
$IsActive = $params['IsActive'];
if ($IsActive == 1) {
$IsActive = 0;
} else {
$IsActive = 1;
}
$data = array(
'IsActive' => $IsActive,
'UpdateDate' => $currentDate
);
$ret = $objHotel->updateAccomPromotionsStatus($data, $hotelid, $AccomPromotionsSysId, $PromotionType);
echo json_encode(array('status' => true));
exit;
}
}
public function deletePromotionAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objHotel = new Travel_Model_TblHotel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if (!empty($params) && ($params['AccomPromotionsSysId'] != '' && $params['AccomPromotionsSysId'] > 0)) {
$hotelid = $params['hotelid'];
$AccomPromotionsSysId = $params['AccomPromotionsSysId'];
$PromotionType = (isset($params['PromotionType'])) ? (int) $params['PromotionType'] : 0;
$data = array(
'IsMarkForDelete' => 1
);
$ret = $objHotel->updateAccomPromotionsStatus($data, $hotelid, $AccomPromotionsSysId, $PromotionType);
echo json_encode(array('status' => true));
exit;
}
}
public function getroomdelistAction() {
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if (isset($params['id']) && !empty($params['id'])) {
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
}
if (!empty($RoomDetailsList)) {
$data['records'] = $RoomDetailsList;
$data['rooms'] = 1;
$data['status'] = 'OK';
} else {
$data['records'] = array();
$data['rooms'] = 0;
$data['status'] = 'ERR';
}
$data['RateType'] = (isset($RoomDetailsList[0]['room']['RateType']) && $RoomDetailsList[0]['room']['RateType'] !== NULL) ? 1 : 0;
echo json_encode($data);
exit;
}
public function getvillaroomdelistAction() {
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if (isset($params['id']) && !empty($params['id'])) {
$RoomDetailsList = $objAccoModel->HotelVillaRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
}
if (!empty($RoomDetailsList)) {
$data['records'] = $RoomDetailsList;
$data['rooms'] = 1;
$data['status'] = 'OK';
} else {
$data['records'] = array();
$data['rooms'] = 0;
$data['status'] = 'ERR';
}
$data['RateType'] = (isset($RoomDetailsList[0]['room']['RateType']) && $RoomDetailsList[0]['room']['RateType'] !== NULL) ? 1 : 0;
echo json_encode($data);
exit;
}
public function addupdatehotelsAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
// echo "<pre>";print_r($post);die;
$objAccoModel = new Travel_Model_AccommodationModel();
$MinStayNights = (isset($post['MinStayNights']) && !empty($post['MinStayNights'])) ? (int) $post['MinStayNights'] : 0;
$SplitStayNights = (isset($post['SplitStayNights']) && !empty($post['SplitStayNights'])) ? (int) $post['SplitStayNights'] : 0;
$save_page = (isset($post['save_page']) && !empty($post['save_page'])) ? trim($post['save_page']) : '';
$HotelRateType = (isset($post['HotelRateType']) && !empty($post['HotelRateType'])) ? trim($post['HotelRateType']) : '';
if ($MinStayNights > 9) {
$response = array('success' => false, 'message' => 'Min Stay Can not be more than 9');
echo json_encode($response);
exit;
}
if ($SplitStayNights > 9) {
$response = array('success' => false, 'message' => 'Split Stay Can not be more than 9');
echo json_encode($response);
exit;
}
$result = $objAccoModel->addUpdateHotel($this->intLoggedinUserAgencySysId);
if (!empty($result) && $result) {
if ($post['ProprtyType'] == 12) {
$roomresult = $objAccoModel->AddHotelRoomDetails($this->intLoggedinUserAgencySysId, $result);
}
if ($save_page == 'list') {
$RoomType = isset($post['RoomType']) ? $post['RoomType'] : array();
if (!empty($RoomType)) {
$roomresult = $objAccoModel->AddHotelMultipleRoomDetails($this->intLoggedinUserAgencySysId, $result);
}
}
$response = array('success' => true, 'HotelId' => $result, 'message' => 'Hotel added successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to add hotel. try again');
echo json_encode($response);
exit;
}
}
}
public function updatehotelcontactAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
$HotelRateType = isset($post['HotelRateType']) ? $post['HotelRateType'] : '';
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->UpdateHotelContact($this->intLoggedinUserAgencySysId);
//print_r($result);die;
if (!empty($result) && $result) {
$response = array('success' => true, 'HotelId' => $result, 'message' => 'Update successfully', 'Type' => $HotelRateType);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to add hotel. try again');
echo json_encode($response);
exit;
}
}
}
public function updatehotelfacilityAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if ($params['CheckinTime'] !== '') {
if ($params['CheckOutTime'] == '') {
$response = array('success' => false, 'message' => 'All mandatory fields required. please complete required field.');
echo json_encode($response);
exit;
}
}
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->UpdateHotelFacility();
if (!empty($result) && $result) {
$response = array('success' => true, 'HotelId' => $result, 'message' => 'Update successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to add hotel. try again');
echo json_encode($response);
exit;
}
}
}
public function addaroundpropertyAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
//if ($this->_request->isXmlHttpRequest()) {
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if ($params['NearByPlaceCat'] == '' || $params['DistanceInKmTime'] == '' || $params['Description'] == '') {
$response = array('success' => false, 'message' => 'All mandatory fields required. please complete required field.');
echo json_encode($response);
exit;
}
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->AddAroundProperty($this->intLoggedinUserAgencySysId);
if (!empty($result) && $result) {
$response = array('success' => true, 'HotelId' => $result, 'message' => 'Update successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to add hotel. try again');
echo json_encode($response);
exit;
}
//}
}
public function aroundpropertylistingAction() {
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$AroundPropertyList = $objAccoModel->AroundPropertyList($params['id']);
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->view->AroundPropertyList = !empty($AroundPropertyList) ? $AroundPropertyList : '';
$this->render('ajaxrequest/aroundpropertylisting');
}
}
public function addhotelroomdetailsAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
//if ($this->_request->isXmlHttpRequest()) {
$objAccoModel = new Travel_Model_AccommodationModel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['update_hotel_id'], $this->intLoggedinUserAgencySysId);
$room_id = array();
//echo '<pre>';print_r($params);echo '</pre>';die;
if ($RoomDetailsList) {
foreach ($RoomDetailsList as $room) {
$room_id[] = $room['room']['RoomTypeId'];
}
}
if (empty($params['update_room_id'])) {
if (in_array($params['RoomType'], $room_id)) {
$response = array('success' => false, 'message' => 'This room you have already taken! please choose another room type.');
echo json_encode($response);
exit;
}
}
//echo '<pre>';print_r($room_id);echo '</pre>';die;
if ($params['RoomType'] == '') {
$response = array('success' => false, 'message' => 'All mandatory fields required. please complete required field');
echo json_encode($response);
exit;
}
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->AddHotelRoomDetails($this->intLoggedinUserAgencySysId);
//echo '<pre>';print_r($result);die;
if (!empty($result) && $result) {
$response = array('success' => true, 'message' => 'Update successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to add hotel. try again');
echo json_encode($response);
exit;
}
//}
}
public function addhotelvillaroomdetailsAction() {
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$VillaRoomDetailsList = $objAccoModel->HotelVillaRoomDetailsList($params['update_hotel_id'], $this->intLoggedinUserAgencySysId);
$room_id = array();
if ($VillaRoomDetailsList) {
foreach ($VillaRoomDetailsList as $room) {
$room_id[] = $room['room']['RoomTypeId'];
}
}
if (empty($params['update_room_id'])) {
if (in_array($params['RoomType'], $room_id)) {
$response = array('success' => false, 'message' => 'This room you have already taken! please choose another room type.');
echo json_encode($response);
exit;
}
}
if ($params['RoomType'] == '' || $params['room_des'] == '') {
$response = array('success' => false, 'message' => 'All mandatory fields required. please complete required field');
echo json_encode($response);
exit;
}
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->AddHotelVillaRoomDetails($this->intLoggedinUserAgencySysId);
if (!empty($result) && $result) {
$response = array('success' => true, 'message' => 'Update successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to add hotel. try again');
echo json_encode($response);
exit;
}
}
public function deletehotelcontimgAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
//if ($this->getRequest()->isXmlHttpRequest()) {
$objAccoModel = new Travel_Model_AccommodationModel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$result = $objAccoModel->DeleteHotelImg($params['hotel_id'], $params['DeleteId']);
if ($result) {
$response = array('success' => true, 'reply' => $result, 'message' => 'Delete successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'reply' => $result, 'message' => 'Unable to delete image. try again');
echo json_encode($response);
exit;
}
//}else{die('wrong request');}
}
public function deleteroomimgAction() {
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$result = $objAccoModel->DeleteRoomImg($params['DeleteId']);
if ($result) {
$response = array('success' => true, 'reply' => $result, 'message' => 'Delete successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'reply' => $result, 'message' => 'Unable to delete image. try again');
echo json_encode($response);
exit;
}
}
public function deletevillaroomimgAction() {
$this->_helper->layout->disableLayout();
$objAccoModel = new Travel_Model_AccommodationModel();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$result = $objAccoModel->DeleteVillaRoomImg($params['DeleteId']);
if ($result) {
$response = array('success' => true, 'reply' => $result, 'message' => 'Delete successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'reply' => $result, 'message' => 'Unable to delete image. try again');
echo json_encode($response);
exit;
}
}
public function deletearoundproAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->DeleteAroundPro($params['DeleteId']);
if ($result) {
$response = array('success' => true, 'reply' => $result, 'message' => 'Delete successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'reply' => $params['DeleteId'], 'message' => 'Unable to delete image. try again');
echo json_encode($response);
exit;
}
}
public function deletecancellationAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->DeleteCancellation();
if ($result) {
$response = array('success' => true, 'reply' => $result, 'message' => 'Remove successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'reply' => $result, 'message' => 'Unable to remove. try again');
echo json_encode($response);
exit;
}
}
}
public function activeAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$request = Zend_Controller_Front::getInstance()->getRequest();
$post = $request->getPost();
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->ActiveHotelContentRate();
$status = ($post['val'] == 1) ? 'activate' : 'deactivate';
if ($result) {
if ($post['val'] == 0) {
$objAccoModel->IsWebsiteActiveHotel();
}
if ($post['type'] == 'content') {
$response = array('success' => true, 'reply' => $result, 'message' => 'Hotel ' . $status . ' successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => true, 'reply' => $result, 'message' => 'Rate ' . $status . ' successfully');
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'reply' => $result, 'message' => 'Unable to update. try again');
echo json_encode($response);
exit;
}
}
}
public function iswebsiteAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$request = Zend_Controller_Front::getInstance()->getRequest();
$post = $request->getPost();
if (isset($post['val'])) {
$check = $this->displayHotelOnB2c($post['hotel_id'], $post['val']);
$abc = json_decode($check);
if (!$abc->success) {
$response = array('successs' => false, 'message' => 'Sorry! Please contact to IT team.');
echo json_encode($response);
exit;
}
}
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->IsWebsiteActiveHotel();
$status = ($post['val'] == 1) ? 'activate' : 'deactivate';
if ($result) {
$response = array('successs' => true, 'message' => 'Display on website ' . $status . ' successfully');
echo json_encode($response);
exit;
} else {
$response = array('successs' => false, 'message' => 'Unable to update. try again');
echo json_encode($response);
exit;
}
}
}
public function blockinventoryAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->_request->isXmlHttpRequest()) {
$request = Zend_Controller_Front::getInstance()->getRequest();
$post = $request->getPost();
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->BalockInventoryRate();
if ($result) {
$response = array('success' => true, 'message' => ' Blockout successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to update. try again');
echo json_encode($response);
exit;
}
}
}
public function activeinventoryAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$request = Zend_Controller_Front::getInstance()->getRequest();
$post = $request->getPost();
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->ActiveInventoryRate();
if ($result) {
$response = array('success' => true, 'message' => ' Active successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to update. try again');
echo json_encode($response);
exit;
}
}
}
public function activateInventorySupplierWiseAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$request = Zend_Controller_Front::getInstance()->getRequest();
$post = $request->getPost();
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->IsActiveHotelInventoryHotel();
if ($result) {
if (isset($post['IsWebsite']) && $post['IsWebsite'] == 1) {
$check = $this->displayHotelOnB2c($post['a'], 1);
}
if ($post['c'] == 0) {
$response = array('success' => true, 'message' => ' Active successfully');
} else {
$response = array('success' => true, 'message' => ' Deactive successfully');
}
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to update. try again');
echo json_encode($response);
exit;
}
}
}
public function deleteInventorySupplierWiseAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$request = Zend_Controller_Front::getInstance()->getRequest();
$post = $request->getPost();
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->IsDeleteHotelInventoryHotel();
if ($result) {
$check = $this->displayHotelOnB2c($post['a'], 0);
$response = array('success' => true, 'message' => ' Deleted successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to update. try again');
echo json_encode($response);
exit;
}
}
}
public function salestartinventoryAction() {
/* Disable Layout */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->_request->isXmlHttpRequest()) {
$request = Zend_Controller_Front::getInstance()->getRequest();
$post = $request->getPost();
//echo '<pre>';print_r($post);die;
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->SaleStartInventoryRate($this->intLoggedinUserAgencySysId);
if ($result) {
$response = array('success' => true, 'message' => ' Sale start successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to update. try again');
echo json_encode($response);
exit;
}
}
}
/* * ****########################################################### Rate Card ##############################*************************************** */
public function rateCardAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objHotel = new Travel_Model_TblHotel();
$objAgency = new Travel_Model_TblAgency();
$objAccoModel = new Travel_Model_AccommodationModel();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->view->baseCurrency = $baseCurrency = $sessionLogin_user->agencyDetails['TrxCurrency'];
$objHotel->orderByField = " TB_Master_Accom_AccomAminity.AminityId ";
$objHotel->orderBy = "";
$this->view->arrMasterAccomAminities = $objHotel->getMasterAccomAminities();
//echo "<pre>"; print_r($this->view->arrMasterAccomAminities);
$mode = (isset($params['mode']) && $params['mode'] != '') ? $params['mode'] : '';
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$SessionKey = !empty($params['SessionKey']) ? $params['SessionKey'] : '0';
$HotelrateCardListLastDate = $HotelrateCardByAgListByHotel = array();
if (isset($params['id']) && $params['id'] != '') {
if ($SessionKey != '') {
$HotelrateCardListLastDate = $objAccoModel->HotelrateCardListLastDate($params['id'], $this->intLoggedinUserAgencySysId, $SessionKey);
}
$HotelrateCardByAgListByHotel = $objAccoModel->HotelrateCardByAgListByHotelOptimized($this->intLoggedinUserAgencySysId, $params['id'], 'all');
$data = array();
$hotelArray = array();
foreach ($HotelrateCardByAgListByHotel as $k => $vl) {
$hotelArray[$vl['XRateSessionKey']][$vl['TfromDate']->format("Y-m-d")]['hotel'] = $vl;
$hotelArray[$vl['XRateSessionKey']][$vl['TfromDate']->format("Y-m-d")]['RoomArray'][$vl['XRefItemSysId']]['EconomyType'] = $vl['EcomyType'];
$hotelArray[$vl['XRateSessionKey']][$vl['TfromDate']->format("Y-m-d")]['RoomArray'][$vl['XRefItemSysId']]['BookingType'] = $vl['BookingType'];
$hotelArray[$vl['XRateSessionKey']][$vl['TfromDate']->format("Y-m-d")]['RoomArray'][$vl['XRefItemSysId']]['RoomType'][] = $vl['MealPlanTitle'];
$hotelArray[$vl['XRateSessionKey']][$vl['TfromDate']->format("Y-m-d")]['RoomArray'][$vl['XRefItemSysId']]['XRefItemSysId'][] = $vl['XRefItemSysId'];
}
// echo "<pre>";print_r($HotelrateCardByAgListByHotel);exit;
}
// echo "<pre>";print_r($data);die;
$this->view->HotelrateCardByAgListByHotel = $hotelArray;
$this->view->HotelrateCardListLastDate = $HotelrateCardListLastDate;
// echo "<pre>";
// print_r($HotelrateCardListLastDate);
// die();
if (empty($HotelrateCardListLastDate)) {
$mode = 'add';
}
if (isset($HotelrateCardListLastDate['XRateSessionKey']) && !empty($HotelrateCardListLastDate['XRateSessionKey'])) {
$SessionKey = $HotelrateCardListLastDate['XRateSessionKey'];
}
$this->view->mode = $mode;
$this->view->SessionKey = $SessionKey;
$agencyDetails = $objAgency->getAgencyUserList($this->intLoggedinUserAgencySysId);
$this->view->agencyDetails = $agencyDetails;
//Get City List
$objCurrency = new Travel_Model_TblCurrency();
$this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
$getMasterRoomType = $objHotel->getMasterRoomType();
$this->view->getMasterRoomType = $getMasterRoomType;
//Get Supplier List
$supplierList = $objHotel->getSuppliersList($cityId = '', $this->intLoggedinUserId);
$this->view->supplierList = $supplierList;
if (isset($params['ids']) && !empty($params['ids'])) {
$results = $objAccoModel->hotelDetailsRates($params['ids'], $this->intLoggedinUserAgencySysId);
if (!$results) {
die('Invalid request!! try again.');
} else {
$this->view->results = !empty($results) ? $results : '';
}
}
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetailsRates($params['id'], $this->intLoggedinUserAgencySysId);
if (!$result) {
die('Invalid request!! try again.');
}
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
$getMinDate = $objAccoModel->getMinDate($params['id'], $this->intLoggedinUserAgencySysId, $SessionKey);
$getMaxDate = $objAccoModel->getMaxDate($params['id'], $this->intLoggedinUserAgencySysId);
$this->view->arrSelectedFacilities = $objHotel->getMasking($params['id']);
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->roomDetailsList = !empty($RoomDetailsList) ? $RoomDetailsList : '';
$this->view->MaxToDate = !empty($getMaxDate['date']) ? $getMaxDate['date'] : '';
$this->view->MinFromDate = implode('/', array_reverse(explode('/', $getMinDate)));
}
}
public function transportRateCardAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objHotel = new Travel_Model_TblHotel();
$objAgency = new Travel_Model_TblAgency();
$objAccoModel = new Travel_Model_AccommodationModel();
$AddonsModel = new Travel_Model_AddonsModel();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->view->baseCurrency = $baseCurrency = $sessionLogin_user->agencyDetails['TrxCurrency'];
$objHotel->orderByField = " TB_Master_Accom_AccomAminity.AminityId ";
$objHotel->orderBy = "";
$this->view->arrMasterAccomAminities = $objHotel->getMasterAccomAminities();
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$agencyDetails = $objAgency->getAgencyUserList($this->intLoggedinUserAgencySysId);
$this->view->agencyDetails = $agencyDetails;
//Get City List
$objCurrency = new Travel_Model_TblCurrency();
$this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
$getMasterRoomType = $objHotel->getMasterRoomType();
$this->view->getMasterRoomType = $getMasterRoomType;
//Get Supplier List
$supplierList = $objHotel->getSuppliersList($cityId = '', $this->intLoggedinUserId);
$this->view->supplierList = $supplierList;
if (isset($params['ids']) && !empty($params['ids'])) {
$results = $objAccoModel->hotelDetailsRates($params['ids'], $this->intLoggedinUserAgencySysId);
if (!$results) {
die('Invalid request!! try again.');
} else {
$this->view->results = !empty($results) ? $results : '';
}
}
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetailsRates($params['id'], $this->intLoggedinUserAgencySysId);
$getAddons = $AddonsModel->getAddons($params['id'], $this->intLoggedinUserAgencySysId, 'ASC');
if (!$result) {
die('Invalid request!! try again.');
}
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->getAddons = !empty($getAddons) ? $getAddons : '';
}
}
public function searchHotelsAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getPost();
$objAccoModel = new Travel_Model_AccommodationModel();
$currentDate = date('Y-m-d H:i:s');
if ($params) {
if (isset($params['ContId']) && $params['ContId'] == '') {
$response = array('success' => false, 'message' => 'Please enter country name');
echo json_encode($response);
exit;
}
if (isset($params['hidden_selected_hotel_id']) && $params['hidden_selected_hotel_id'] == '') {
$response = array('success' => false, 'message' => 'Please enter hotel name');
echo json_encode($response);
exit;
}
if (!isset($params['room_type']) || empty($params['room_type'])) {
$response = array('success' => false, 'message' => 'Please select at least one room type');
echo json_encode($response);
exit;
}
/// Checking room master record and add new if not exist
if ($params['room_type']) {
foreach ($params['room_type'] as $ks => $room) {
$NewRoomArr = [];
$result = $objAccoModel->CheckRoomMaster($room);
if ($result) {
$NewRoomArr['room_type'][$ks] = $result;
$this->insertHotelRoomsAction($params, $NewRoomArr);
} else {
$data = array(
'Title' => $room,
'UpdateDate' => $currentDate,
'CreateDate' => $currentDate,
'Icon' => '',
'IsMarkForDel' => 0,
'IsActive' => '1',
'RoomGrMask' => '1',
);
$LastInserId = $objAccoModel->InsertNewRoom($data);
$NewRoomArr['room_type'][$ks] = $LastInserId;
$this->insertHotelRoomsAction($params, $NewRoomArr);
}
}
}
$response = array('success' => true, 'hotelId' => $params['hidden_selected_hotel_id'], 'message' => 'Redirecting please wait...');
echo json_encode($response);
exit;
//$this->_helper->redirector('rate-card', 'accommodation', 'default',array('id' => $params['hidden_selected_hotel_id']));
/* echo '<pre>';
print_r($params);
print_r($result);die; */
} else {
echo 'Oops wrong request!';
exit;
}
}
public function insertHotelRoomsAction($params, $NewRoomArr) {
//echo '<pre>';print_r($NewRoomArr);die;
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->searchroomList($params['hidden_selected_hotel_id'], $NewRoomArr['room_type']);
$currentDate = date('Y-m-d H:i:s');
if ($result) {
foreach ($result as $k => $val) {
$RoomTypeId[] = $val['RoomTypeId'];
}
foreach ($NewRoomArr['room_type'] as $k => $value) {
if (!in_array($value, $RoomTypeId)) {
$data = array(
'AccomSysId' => $params['hidden_selected_hotel_id'],
'SourceSysId' => $this->intLoggedinUserAgencySysId,
'Title' => '',
'RoomType' => isset($value) && !empty($value) ? $value : '',
'EconomyType' => 0,
'Qty' => 10,
'BedType' => 0,
'PaxCount' => 0,
'IsPetAllow' => 0,
'MaxPetAllow' => 0,
'AllowChild' => 0,
'AllowInfant' => 0,
'MaxPaxCount' => 0,
'MaxAllowChild' => 0,
'MaxAllowInfant' => 0,
'MealPlanType' => '',
'AminitiesMask' => '',
'InclustionOptionsMask' => '',
'OtherDetails' => '',
'UpdatedDate' => $currentDate,
'CreateDate' => $currentDate,
'ApproveDate' => EMPTY_DATE,
'ApproveBy' => 0,
'IsDelete' => 0,
'IsActive' => '1',
'IsApproved' => '0'
);
$response = $objAccoModel->AddSearchRoom($data);
$CheckInvExist = $objAccoModel->CheckInventoryExist($params['hidden_selected_hotel_id'], $value, $this->intLoggedinUserAgencySysId);
if ($CheckInvExist) {
foreach ($CheckInvExist as $inv) {
$update = array(
'XRefItemSysId' => $response
);
$objAccoModel->UpdateInventoryExist($inv['InvnItemSysId'], $update);
}
}
}
}
//echo 'true';
} else {
foreach ($NewRoomArr['room_type'] as $k => $value) {
$data = array(
'AccomSysId' => $params['hidden_selected_hotel_id'],
'SourceSysId' => $this->intLoggedinUserAgencySysId,
'Title' => '',
'RoomType' => isset($value) && !empty($value) ? $value : '',
'EconomyType' => 0,
'Qty' => 10,
'BedType' => 0,
'PaxCount' => 0,
'IsPetAllow' => 0,
'MaxPetAllow' => 0,
'AllowChild' => 0,
'AllowInfant' => 0,
'MaxPaxCount' => 0,
'MaxAllowChild' => 0,
'MaxAllowInfant' => 0,
'MealPlanType' => '',
'AminitiesMask' => '',
'InclustionOptionsMask' => '',
'OtherDetails' => '',
'UpdatedDate' => $currentDate,
'CreateDate' => $currentDate,
'ApproveDate' => EMPTY_DATE,
'ApproveBy' => 0,
'IsDelete' => 0,
'IsActive' => '1',
'IsApproved' => '0'
);
$response = $objAccoModel->AddSearchRoom($data);
$CheckInvExist = $objAccoModel->CheckInventoryExist($params['hidden_selected_hotel_id'], $value, $this->intLoggedinUserAgencySysId);
if ($CheckInvExist) {
foreach ($CheckInvExist as $inv) {
$update = array(
'XRefItemSysId' => $response
);
$objAccoModel->UpdateInventoryExist($inv['InvnItemSysId'], $update);
}
}
}
//echo 'false';
}
return true;
}
public function cancellationAction() {
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objHotel = new Travel_Model_TblHotel();
$objAgency = new Travel_Model_TblAgency();
$objAccoModel = new Travel_Model_AccommodationModel();
$agencyDetails = $objAgency->getAgencyUserList($this->intLoggedinUserAgencySysId);
$this->view->agencyDetails = $agencyDetails;
//Get Currency List
$objCurrency = new Travel_Model_TblCurrency();
$this->view->arrCurrencyTypes = $objCurrency->getCurrencyTypes();
$getMasterRoomType = $objHotel->getMasterRoomType();
$this->view->getMasterRoomType = $getMasterRoomType;
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->view->SessionKey = !empty($params['SessionKey']) ? $params['SessionKey'] : '0';
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetailsRates($params['id'], $this->intLoggedinUserAgencySysId);
if (!$result) {
die('Invalid request!! try again.');
}
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($params['id'], $this->intLoggedinUserAgencySysId);
$CancellationList = $objAccoModel->CancellationList($params['id'], $this->intLoggedinUserAgencySysId);
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->roomDetailsList = !empty($RoomDetailsList) ? $RoomDetailsList : '';
if ($CancellationList) {
$temp_array = array();
$key_array = array();
foreach ($CancellationList as $key => $results) {
if (!in_array($results['ItemSysId'], $key_array)) {
$key_array[$key] = $results['ItemSysId'];
if ($results['roomindex'] == 0) {
$temp_array[$results['ItemSysId']]['ItemSysId'] = $results['ItemSysId'];
$temp_array[$results['ItemSysId']]['RoomType'][] = $results['RoomType'];
} else {
$temp_array[$results['roomindex']]['RoomType'][] = $results['RoomType'];
}
}
}
}
// echo "<pre>";print_r($temp_array);die;
$this->view->cancellationList = !empty($temp_array) ? $temp_array : '';
} else {
$this->_helper->redirector('manage', 'accommodation', 'default');
}
if (isset($params['Item']) && !empty($params['Item'])) {
$CancelDeByItemSysId = $objAccoModel->CancelDeByItemSysId($params['id'], $this->intLoggedinUserAgencySysId, $params['Item']);
$CancelSubDeByItemSysId = $objAccoModel->CancelSubDeByItemSysId($params['id'], $this->intLoggedinUserAgencySysId, $CancelDeByItemSysId[0]['ItemSysId']);
// echo '<pre>';print_r($CancelSubDeByItemSysId);die;
if ($CancelDeByItemSysId) {
$this->view->CancelDeByItemSysId = !empty($CancelDeByItemSysId) ? $CancelDeByItemSysId : array();
$this->view->CancelSubDeByItemSysId = !empty($CancelSubDeByItemSysId) ? $CancelSubDeByItemSysId : array();
}
}
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function addupdateratecardAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($this->getRequest()->isPost()) {
$objAccoModel = new Travel_Model_AccommodationModel();
$post = $request->getPost();
$check_room_type = isset($post['check_room_type']) && !empty($post['check_room_type']) ? $post['check_room_type'] : '';
$check_meal_type = isset($post['check_meal_type']) && !empty($post['check_meal_type']) ? $post['check_meal_type'] : '';
$room_id = isset($post['room_id']) && !empty($post['room_id']) ? $post['room_id'] : '';
$room_type_id = isset($post['room_type_id']) && !empty($post['room_type_id']) ? $post['room_type_id'] : '';
$allocation = isset($post['allocation']) && !empty($post['allocation']) ? $post['allocation'] : '';
$BookingType = isset($post['BookingType']) && !empty($post['BookingType']) ? $post['BookingType'] : '';
$check_tax_type = isset($post['check_tax_type']) && !empty($post['check_tax_type']) ? $post['check_tax_type'] : '';
$age_paid = isset($post['age_paid']) && !empty($post['age_paid']) ? $post['age_paid'] : '';
$sg_pub_wd = isset($post['sg_pub_wd']) && !empty($post['sg_pub_wd']) ? ($post['sg_pub_wd']) : '';
$sg_pub_wk = isset($post['sg_pub_wk']) && !empty($post['sg_pub_wk']) ? ($post['sg_pub_wk']) : '';
$sg_net_wd = isset($post['sg_net_wd']) && !empty($post['sg_net_wd']) ? ($post['sg_net_wd']) : '';
$sg_net_wk = isset($post['sg_net_wk']) && !empty($post['sg_net_wk']) ? ($post['sg_net_wk']) : '';
$db_pub_wd = isset($post['db_pub_wd']) && !empty($post['db_pub_wd']) ? ($post['db_pub_wd']) : '';
$db_pub_wk = isset($post['db_pub_wk']) && !empty($post['db_pub_wk']) ? ($post['db_pub_wk']) : '';
$db_net_wd = isset($post['db_net_wd']) && !empty($post['db_net_wd']) ? ($post['db_net_wd']) : '';
$db_net_wk = isset($post['db_net_wk']) && !empty($post['db_net_wk']) ? ($post['db_net_wk']) : '';
$tri_pub_wd = isset($post['tri_pub_wd']) && !empty($post['tri_pub_wd']) ? ($post['tri_pub_wd']) : '';
$tri_pub_wk = isset($post['tri_pub_wk']) && !empty($post['tri_pub_wk']) ? ($post['tri_pub_wk']) : '';
$tri_net_wd = isset($post['tri_net_wd']) && !empty($post['tri_net_wd']) ? ($post['tri_net_wd']) : '';
$tri_net_wk = isset($post['tri_net_wk']) && !empty($post['tri_net_wk']) ? ($post['tri_net_wk']) : '';
$ex_wbed_pub_wd = isset($post['ex_wbed_pub_wd']) && !empty($post['ex_wbed_pub_wd']) ? ($post['ex_wbed_pub_wd']) : '';
$ex_wbed_pub_wk = isset($post['ex_wbed_pub_wk']) && !empty($post['ex_wbed_pub_wk']) ? ($post['ex_wbed_pub_wk']) : '';
$ex_wbed_net_wd = isset($post['ex_wbed_net_wd']) && !empty($post['ex_wbed_net_wd']) ? ($post['ex_wbed_net_wd']) : '';
$ex_wbed_net_wk = isset($post['ex_wbed_net_wk']) && !empty($post['ex_wbed_net_wk']) ? ($post['ex_wbed_net_wk']) : '';
$chpaid_pub_wd = isset($post['chpaid_pub_wd']) && !empty($post['chpaid_pub_wd']) ? ($post['chpaid_pub_wd']) : '';
$chpaid_pub_wk = isset($post['chpaid_pub_wk']) && !empty($post['chpaid_pub_wk']) ? ($post['chpaid_pub_wk']) : '';
$chpaid_net_wd = isset($post['chpaid_net_wd']) && !empty($post['chpaid_net_wd']) ? ($post['chpaid_net_wd']) : '';
$chpaid_net_wk = isset($post['chpaid_net_wk']) && !empty($post['chpaid_net_wk']) ? ($post['chpaid_net_wk']) : '';
$check_tax_sg = isset($post['check_tax_sg']) && !empty($post['check_tax_sg']) ? ($post['check_tax_sg']) : '';
$check_tax_db = isset($post['check_tax_db']) && !empty($post['check_tax_db']) ? ($post['check_tax_db']) : '';
$check_tax_tri = isset($post['check_tax_tri']) && !empty($post['check_tax_tri']) ? ($post['check_tax_tri']) : '';
$check_tax_ex = isset($post['check_tax_ex']) && !empty($post['check_tax_ex']) ? ($post['check_tax_ex']) : '';
$check_tax_chpaid = isset($post['check_tax_chpaid']) && !empty($post['check_tax_chpaid']) ? ($post['check_tax_chpaid']) : '';
$ext_adult = isset($post['ext_adult']) && !empty($post['ext_adult']) ? ($post['ext_adult']) : '';
$ext_child = isset($post['ext_child']) && !empty($post['ext_child']) ? ($post['ext_child']) : '';
$from_dt = isset($post['from_dt']) && !empty($post['from_dt']) ? $post['from_dt'] : '0';
$to_dt = isset($post['to_dt']) && !empty($post['to_dt']) ? $post['to_dt'] : '0';
$from_dt_check = isset($post['from_dt_check']) && !empty($post['from_dt_check']) ? $post['from_dt_check'] : '0';
$to_dt_check = isset($post['to_dt_check']) && !empty($post['to_dt_check']) ? $post['to_dt_check'] : '0';
$SessionKey = isset($post['SessionKey']) && !empty($post['SessionKey']) ? $post['SessionKey'] : '0';
$from_dt_checkC = $from_dtC = 0;
if ($from_dt != '0') {
$Fdate = DateTime::createFromFormat('d/m/Y', $from_dt);
$from_dtC = $Fdate->format('Y-m-d');
}
if ($to_dt != '0') {
$Tdate = DateTime::createFromFormat('d/m/Y', $to_dt);
$t_dtC = $Fdate->format('Y-m-d');
}
if ($from_dt_check != '0') {
$Ffrom_dt_check = DateTime::createFromFormat('d/m/Y', $from_dt_check);
$from_dt_checkC = $Ffrom_dt_check->format('Y-m-d');
}
$fromDateData = $objAccoModel->checkDuplicateRate($post['hotel_id'], $this->intLoggedinUserAgencySysId, $from_dtC, $t_dtC);
if (!empty($fromDateData) && empty($SessionKey)) {
$response = array('success' => false, 'message' => 'Rates are already created between these dates . Please choose another option and try again.');
echo json_encode($response);
exit;
}
if (isset($post['hidden_selected_supplier_sys_id']) && !empty($post['hidden_selected_supplier_sys_id'])) {
Zend_Controller_Action_HelperBroker::getStaticHelper('Supplier')->updateSupplierService($post['hidden_selected_supplier_sys_id'], 'Hotel');
}
$result = $objAccoModel->AddHotelRateCard($this->intLoggedinUserAgencySysId, $this->intLoggedinUserId);
if (!empty($result['status']) && $result['status']) {
$displayWebsite = (isset($post['val'])) ? (int) $post['val'] : 0;
if ($displayWebsite == 1 && (int) $post['hotel_id'] > 0) {
$check = $this->displayHotelOnB2c($post['hotel_id'], $post['val']);
$abc = json_decode($check);
if ($abc->success && $displayWebsite == 1) {
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->IsWebsiteActiveHotel();
}
}
$response = array('success' => true, 'response' => $result, 'message' => 'Save successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to save. try again');
echo json_encode($response);
exit;
}
}
}
public function updateinventoryindAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($this->getRequest()->isPost()) {
$post = $request->getPost();
//echo "<pre>";print_r($post);
$objAccoModel = new Travel_Model_AccommodationModel();
$hotelDetails = $objAccoModel->hotelDetailsRates($post['hotel_id'], $this->intLoggedinUserAgencySysId);
$FromDate = date('D', strtotime($post['fromdate']));
$getRTDTSR = $objAccoModel->getRatedetailsSingleRowNew($post['hotel_id'], $post['XRefItemSysId'], $post['EconomyType'], $post['MealPlanType'], $post['SupplierSysId'], $this->intLoggedinUserAgencySysId, $post['InvnItemSysId']);
//echo "<pre>";print_r($getRTDTSR);
if (in_array($FromDate, explode(',', $getRTDTSR['WeekendDefine']))) {
// echo 'wk';
$insert = array(
'B2CMarkup' => isset($post['B2CMarkup']) && !empty($post['B2CMarkup']) ? (float) $post['B2CMarkup'] : '0',
'B2BMarkup' => isset($post['B2BMarkup']) && !empty($post['B2BMarkup']) ? (float) $post['B2BMarkup'] : '0',
'RateType' => isset($post['ratetype']) && ($post['ratetype'] == 'NR') ? '1' : '0', //RateType
'RackCommission' => isset($post['rr_value']) && !empty($post['rr_value']) ? $post['rr_value'] : '0', //RackCommission
//'PublishQty' => isset($post['allocation']) && !empty($post['allocation']) ? ($post['allocation']) : '0',
//'DailyRoomLimit' => isset($post['allocation']) && !empty($post['allocation']) ? ($post['allocation']) : '0',
'SOccupCost' => isset($post['sg_pub_wk']) && !empty($post['sg_pub_wk']) ? ($post['sg_pub_wk']) : null,
'NetSOccupCost' => isset($post['sg_net_wk']) && !empty($post['sg_net_wk']) ? ($post['sg_net_wk']) : null,
'DOccupCost' => isset($post['db_pub_wk']) && !empty($post['db_pub_wk']) ? ($post['db_pub_wk']) : null,
'NetDOccupCost' => isset($post['db_net_wk']) && !empty($post['db_net_wk']) ? ($post['db_net_wk']) : null,
'TriOccupCost' => isset($post['tri_pub_wk']) && !empty($post['tri_pub_wk']) ? ($post['tri_pub_wk']) : null,
'NetTriOccupCost' => isset($post['tri_net_wk']) && !empty($post['tri_net_wk']) ? ($post['tri_net_wk']) : null,
'ExtraBedCost' => isset($post['ex_wbed_pub_wk']) && !empty($post['ex_wbed_pub_wk']) ? ($post['ex_wbed_pub_wk']) : null,
'NetExtraBedCost' => isset($post['ex_wbed_net_wk']) && !empty($post['ex_wbed_net_wk']) ? ($post['ex_wbed_net_wk']) : null,
'ExtraWOBedCost' => isset($post['chpaid_pub_wk']) && !empty($post['chpaid_pub_wk']) ? ($post['chpaid_pub_wk']) : null,
'NetExtraWOBedCost' => isset($post['chpaid_net_wk']) && !empty($post['chpaid_net_wk']) ? ($post['chpaid_net_wk']) : null,
//'IsExtraMealAdultCost' => isset($post['ext_adult']) && !empty($post['ext_adult']) ? ($post['ext_adult']) : '0',
//'IsExtraMealChildCost' => isset($post['ext_child']) && !empty($post['ext_child']) ? ($post['ext_child']) : '0',
'ChildAgeLimit' => isset($post['age_paid']) && !empty($post['age_paid']) ? ($post['age_paid']) : '0',
'IsTaxOnSOccupCost' => isset($post['check_tax_sg']) && !empty($post['check_tax_sg']) ? ($post['check_tax_sg']) : '0',
'IsTaxOnDOccupCost' => isset($post['check_tax_db']) && !empty($post['check_tax_db']) ? ($post['check_tax_db']) : '0',
'IsTaxOnTriOccupCost' => isset($post['check_tax_tri']) && !empty($post['check_tax_tri']) ? ($post['check_tax_tri']) : '0',
'IsTaxOnExtraBedCost' => isset($post['check_tax_ex']) && !empty($post['check_tax_ex']) ? ($post['check_tax_ex']) : '0',
'IsTaxOnExtraWOBedCost' => isset($post['check_tax_chpaid']) && !empty($post['check_tax_chpaid']) ? ($post['check_tax_chpaid']) : '0',
'TaxSOccupCost' => isset($post['sg_tax_wk']) && !empty($post['sg_tax_wk']) ? ($post['sg_tax_wk']) : '0',
'TaxDOccupCost' => isset($post['db_tax_wk']) && !empty($post['db_tax_wk']) ? ($post['db_tax_wk']) : '0',
'TaxExtraBedCost' => isset($post['tri_tax_wk']) && !empty($post['tri_tax_wk']) ? ($post['tri_tax_wk']) : '0',
'TaxTriOccupCost' => isset($post['ex_wbed_tax_wk']) && !empty($post['ex_wbed_tax_wk']) ? ($post['ex_wbed_tax_wk']) : '0',
'TaxExtraWOBedCost' => isset($post['chpaid_tax_wk']) && !empty($post['chpaid_tax_wk']) ? ($post['chpaid_tax_wk']) : '0',
'IsAllowMarkupSO' => isset($post['check_markup_sg']) && !empty($post['check_markup_sg']) ? ($post['check_markup_sg']) : '0',
'IsAllowMarkupDO' => isset($post['check_markup_db']) && !empty($post['check_markup_db']) ? ($post['check_markup_db']) : '0',
'IsAllowMarkupTO' => isset($post['check_markup_tri']) && !empty($post['check_markup_tri']) ? ($post['check_markup_tri']) : '0',
'IsAllowMarkupEB' => isset($post['check_markup_ex']) && !empty($post['check_markup_ex']) ? ($post['check_markup_ex']) : '0',
'IsAllowMarkupWOB' => isset($post['check_markup_chpaid']) && !empty($post['check_markup_chpaid']) ? ($post['check_markup_chpaid']) : '0',
);
} else {
//echo 'wd';
$insert = array(
'B2CMarkup' => isset($post['B2CMarkup']) && !empty($post['B2CMarkup']) ? (float) $post['B2CMarkup'] : '0',
'B2BMarkup' => isset($post['B2BMarkup']) && !empty($post['B2BMarkup']) ? (float) $post['B2BMarkup'] : '0',
'RateType' => isset($post['ratetype']) && ($post['ratetype'] == 'NR') ? '1' : '0', //RateType
'RackCommission' => isset($post['rr_value']) && !empty($post['rr_value']) ? $post['rr_value'] : '0', //RackCommission
//'PublishQty' => isset($post['allocation']) && !empty($post['allocation']) ? ($post['allocation']) : '0',
//'DailyRoomLimit' => isset($post['allocation']) && !empty($post['allocation']) ? ($post['allocation']) : '0',
'SOccupCost' => isset($post['sg_pub_wd']) && !empty($post['sg_pub_wd']) ? ($post['sg_pub_wd']) : null,
'NetSOccupCost' => isset($post['sg_net_wd']) && !empty($post['sg_net_wd']) ? ($post['sg_net_wd']) : null,
'DOccupCost' => isset($post['db_pub_wd']) && !empty($post['db_pub_wd']) ? ($post['db_pub_wd']) : null,
'NetDOccupCost' => isset($post['db_net_wd']) && !empty($post['db_net_wd']) ? ($post['db_net_wd']) : null,
'TriOccupCost' => isset($post['tri_pub_wd']) && !empty($post['tri_pub_wd']) ? ($post['tri_pub_wd']) : null,
'NetTriOccupCost' => isset($post['tri_net_wd']) && !empty($post['tri_net_wd']) ? ($post['tri_net_wd']) : null,
'ExtraBedCost' => isset($post['ex_wbed_pub_wd']) && !empty($post['ex_wbed_pub_wd']) ? ($post['ex_wbed_pub_wd']) : null,
'NetExtraBedCost' => isset($post['ex_wbed_net_wd']) && !empty($post['ex_wbed_net_wd']) ? ($post['ex_wbed_net_wd']) : null,
'ExtraWOBedCost' => isset($post['chpaid_pub_wd']) && !empty($post['chpaid_pub_wd']) ? ($post['chpaid_pub_wd']) : null,
'NetExtraWOBedCost' => isset($post['chpaid_net_wd']) && !empty($post['chpaid_net_wd']) ? ($post['chpaid_net_wd']) : null,
//'IsExtraMealAdultCost' => isset($post['ext_adult']) && !empty($post['ext_adult']) ? ($post['ext_adult']) : '0',
//'IsExtraMealChildCost' => isset($post['ext_child']) && !empty($post['ext_child']) ? ($post['ext_child']) : '0',
'ChildAgeLimit' => isset($post['age_paid']) && !empty($post['age_paid']) ? ($post['age_paid']) : '0',
'IsTaxOnSOccupCost' => isset($post['check_tax_sg']) && !empty($post['check_tax_sg']) ? ($post['check_tax_sg']) : '0',
'IsTaxOnDOccupCost' => isset($post['check_tax_db']) && !empty($post['check_tax_db']) ? ($post['check_tax_db']) : '0',
'IsTaxOnTriOccupCost' => isset($post['check_tax_tri']) && !empty($post['check_tax_tri']) ? ($post['check_tax_tri']) : '0',
'IsTaxOnExtraBedCost' => isset($post['check_tax_ex']) && !empty($post['check_tax_ex']) ? ($post['check_tax_ex']) : '0',
'IsTaxOnExtraWOBedCost' => isset($post['check_tax_chpaid']) && !empty($post['check_tax_chpaid']) ? ($post['check_tax_chpaid']) : '0',
'TaxSOccupCost' => isset($post['sg_tax_wd']) && !empty($post['sg_tax_wd']) ? ($post['sg_tax_wd']) : '0',
'TaxDOccupCost' => isset($post['db_tax_wd']) && !empty($post['db_tax_wd']) ? ($post['db_tax_wd']) : '0',
'TaxExtraBedCost' => isset($post['tri_tax_wd']) && !empty($post['tri_tax_wd']) ? ($post['tri_tax_wd']) : '0',
'TaxTriOccupCost' => isset($post['ex_wbed_tax_wd']) && !empty($post['ex_wbed_tax_wd']) ? ($post['ex_wbed_tax_wd']) : '0',
'TaxExtraWOBedCost' => isset($post['chpaid_tax_wd']) && !empty($post['chpaid_tax_wd']) ? ($post['chpaid_tax_wd']) : '0',
'IsAllowMarkupSO' => isset($post['check_markup_sg']) && !empty($post['check_markup_sg']) ? ($post['check_markup_sg']) : '0',
'IsAllowMarkupDO' => isset($post['check_markup_db']) && !empty($post['check_markup_db']) ? ($post['check_markup_db']) : '0',
'IsAllowMarkupTO' => isset($post['check_markup_tri']) && !empty($post['check_markup_tri']) ? ($post['check_markup_tri']) : '0',
'IsAllowMarkupEB' => isset($post['check_markup_ex']) && !empty($post['check_markup_ex']) ? ($post['check_markup_ex']) : '0',
'IsAllowMarkupWOB' => isset($post['check_markup_chpaid']) && !empty($post['check_markup_chpaid']) ? ($post['check_markup_chpaid']) : '0',
);
}
//echo '<pre>';print_r($insert);die('dddd');
$result = $objAccoModel->UpdateIndividualRateCard($insert, $this->intLoggedinUserAgencySysId, $this->intLoggedinUserId);
if (!empty($result) && $result) {
$response = array('success' => true, 'response' => $result, 'message' => 'Save successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to save. try again');
echo json_encode($response);
exit;
}
//echo '<pre>';print_r($post);die;
}
}
public function updatebulkinventoryindAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($this->getRequest()->isPost()) {
$post = $request->getPost();
$objAccoModel = new Travel_Model_AccommodationModel();
$result = $objAccoModel->UpdateBulkIndividualRateCard($this->intLoggedinUserAgencySysId, $this->intLoggedinUserId);
if (!empty($result) && $result) {
$response = array('success' => true, 'response' => $result, 'message' => 'Save successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to save. try again');
echo json_encode($response);
exit;
}
//echo '<pre>';print_r($post);die;
}
}
public function addcalcellationAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if ($this->getRequest()->isPost()) {
//echo '<pre>';print_r($params['remarks']);die;
$objAccoModel = new Travel_Model_AccommodationModel();
$CancellationList = $objAccoModel->CancellationList($params['update_hotel_id'], $this->intLoggedinUserAgencySysId);
if ($CancellationList && !isset($params['RoomCancelSysId'])) {
$temp_array = array();
$key_array = array();
foreach ($CancellationList as $key => $results) {
if (!in_array($results['ItemSysId'], $key_array)) {
$key_array[$key] = $results['ItemSysId'];
$temp_array[] = $results['ItemSysId'];
}
}
$result = array_diff($params['room_type'], $temp_array);
foreach ($params['room_type'] as $rk => $rval) {
if (in_array($rval, $temp_array)) {
$this->_helper->flashMessenger->addMessage("This room already taken?. choose another room type");
$this->_redirect('accommodation/cancellation/id/' . $params['update_hotel_id']);
exit;
}
}
}
$result = $objAccoModel->AddHotelCalcellation($this->intLoggedinUserAgencySysId, $this->intLoggedinUserId);
//echo '<pre>';print_r($result);die;
if (!empty($result) && $result) {
$this->_helper->flashMessenger->addMessage("Save successfully");
$this->_redirect('accommodation/cancellation/id/' . $params['update_hotel_id']);
} else {
$this->_helper->flashMessenger->addMessage("Unable to save. try again");
$this->_redirect('accommodation/cancellation/id/' . $params['update_hotel_id']);
}
}
}
public function startSaleAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objHotel = new Travel_Model_TblHotel();
$InvnItemSysId = base64_decode($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('inventory', 'accommodation', 'default');
}
}
/**
* 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->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('inventory', 'accommodation', 'default');
}
}
public function displayHotelOnB2c($hotelSysId, $statusValue) {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
//$hotelSysId = trim($this->getRequest()->getParam('id'));die;
//$statusValue = trim($this->getRequest()->getParam('status'));
if ($this->intLoggedinUserRole != 1) {
$intLoggedinUserId = $this->intLoggedinUserAgencySysId;
} else {
$intLoggedinUserId = "";
}
$sessionLogin_user_url = new Zend_Session_Namespace('sessionLogin_user');
if (trim($sessionLogin_user_url->agencyDetails['IsB2CSite']) == 1) {
$ItemSourceType = $hotelSysId;
$url = trim($sessionLogin_user_url->agencyDetails['Url']);
if (Travel_Model_AgencyAuth::getIdentity()->AgencySysId == 14292) {
$url = "https://b2b.summitvacations.in/";
}
if (Travel_Model_AgencyAuth::getIdentity()->AgencySysId == 1) {
$url = "http://local.superdmc.com/";
}
$this->postFields = "";
$this->postFields .= "&AgencySysId=" . Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
$this->postFields .= "&packageId=$ItemSourceType";
$this->postFields .= "&URL=" . $url;
$writeLogObj = new Payment_Model_Payment();
$writeLogObj->writeLog($this->postFields . "\n");
if ($statusValue == 1) {
$url = Catabatic_Helper::getSiteUrl() . "gtxwebservices/push-package/hotel";
} else {
$url = Catabatic_Helper::getSiteUrl() . "gtxwebservices/push-package/deactivate";
}
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
// SSL connection
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postFields);
$output = curl_exec($ch);
// echo "<pre>";print_r($output);exit;
$writeLogObj->writeLog($output . "\n");
curl_close($ch);
return $output;
} catch (Zend_Exception $ex) {
echo $ex->getMessage();
exit;
}
}
}
// public function updateextramealAction(){
// $this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
// $params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
// $objAccoModel = new Travel_Model_AccommodationModel();
// $RateDeBySessionKey = $objAccoModel->HotelRateDeBySessionKey($params['id'],$this->intLoggedinUserAgencySysId,$params['XRateSessionKey']);
// $this->_helper->layout->disableLayout();
// if($RateDeBySessionKey){
// $this->view->RateDeBySessionKey = !empty($RateDeBySessionKey)?$RateDeBySessionKey:'';
// }
// $this->view->XRateSessionKey = $params['XRateSessionKey'];
//
// }
// public function testSabirAction() {
// $objSabir = new Travel_Model_SabirTest();
// if ($this->getRequest()->isPost()) {
// $objSabir->addSabirTesting();
// }
// $this->view->arrAgency = $objSabir->getUserList();
// $this->render('test-sabir-page');
// }
public function deleteHotelAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$return = false;
$hotelId = (int) $this->getRequest()->getParam('hotelId');
$objHotel = new Travel_Model_TblHotel();
if ($hotelId > 0) {
$resultSet = $objHotel->checkHotelInPackage($hotelId);
if (!empty($resultSet)) {
$return = true;
} else {
$return = false;
}
} else {
$return = false;
}
echo $return;
exit;
}
public function deleteHotelTolistAction() {
$this->_helper->layout->disableLayout();
$hotelId = (int) $this->getRequest()->getParam('hotelId');
$AgencySysId = (int) $this->intLoggedinUserAgencySysId;
$objHotel = new Travel_Model_TblHotel();
$updateHotel = $objHotel->updateHotelInAccom($hotelId, $AgencySysId);
if ($updateHotel == 1) {
$this->displayHotelOnB2c($hotelId, 0);
}
echo $updateHotel;
die;
}
public function checkHotelRoomtypeAction() {
$this->_helper->layout->disableLayout();
$AccomSysId = (int) $this->getRequest()->getParam('AccomSysId');
$AgencySysId = (int) $this->intLoggedinUserAgencySysId;
$objAccoModel = new Travel_Model_AccommodationModel();
$objHotel = new Travel_Model_TblHotel();
$result = $objAccoModel->hotelDetails($AccomSysId, $this->intLoggedinUserAgencySysId);
$htmldata1 = '';
if ($result['ICSourceSysId'] != $AgencySysId) {
$getMasterRoomType = $objHotel->getMasterRoomType();
if (!empty($getMasterRoomType)) {
foreach ($getMasterRoomType as $roomtype) {
$htmldata1 .= '<option value="' . $roomtype['RoomTypeId'] . '">' . $roomtype['RoomType'] . '</option>';
}
}
} else {
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($AccomSysId, $AgencySysId);
foreach ($RoomDetailsList as $key => $val) {
$htmldata1 .= '<option value="' . $val['room']['RoomTypeId'] . '">' . trim($val['room']['RoomType']) . '</option>';
}
}
echo ($htmldata1);
exit;
}
public function updateRoomStatusAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
//$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$request = Zend_Controller_Front::getInstance()->getRequest();
$objHotel = new Travel_Model_TblHotel();
if ($this->getRequest()->isPost()) {
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$hotelid = $params['hotelid'];
$ItemSysId = $params['ItemSysId'];
$IsActive = $params['IsActive'];
if ($IsActive == 1) {
$IsActive = 0;
} else {
$IsActive = 1;
}
$data = array(
'IsActive' => $IsActive
);
$ret = $objHotel->updateICAccomdationRoom($data, $hotelid, $ItemSysId);
echo json_encode(array('status' => true));
exit;
}
}
public function addupdatetransportratecardAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
//$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($this->getRequest()->isPost()) {
$post = $request->getPost();
$AgencySysId = (int) $this->intLoggedinUserAgencySysId;
$UpdateHotelId = (isset($post['UpdateHotelId']) && !empty($post['UpdateHotelId'])) ? (int) $post['UpdateHotelId'] : 0;
$TransferName = (isset($post['TransferName']) && !empty($post['TransferName'])) ? $post['TransferName'] : array();
$CurrencyType = (isset($post['CurrencyType']) && !empty($post['CurrencyType'])) ? (int) $post['CurrencyType'] : $this->intLoggedinUserTrxCurrency;
//echo "<pre>";print_r($post);exit;
$status = false;
$message = 'Some Error occurred!!!';
if ($UpdateHotelId > 0) {
$ExtraServicesData = array('IsMarkForDel' => 1);
$WhereExtraServices = array('AccomSysId =?' => $UpdateHotelId, 'AgencySysId =?' => $AgencySysId);
$this->db->update('TB_MP_Inventory_Accom_ExtraServices', $ExtraServicesData, $WhereExtraServices);
foreach ($TransferName as $key => $value) {
$TransferAdultCost = (isset($post['TransferAdultCost'][$key])) ? (float) $post['TransferAdultCost'][$key] : 0;
if (trim($value) != '' && $TransferAdultCost > 0) {
$insertTransfer = array(
'AccomSysId' => $UpdateHotelId,
'AgencySysId' => $AgencySysId,
'ServiceType' => 1,
'SaleType' => $post['TransferSaletype'],
'RateType' => $post['TransferRateType'][$key],
'SupplierSysId' => (int) $post['hidden_selected_supplier_sys_id'][$key],
'Title' => trim($value),
'Detail' => '',
'Image' => '',
'CostCurrency' => $CurrencyType,
'AdultCost' => (float) $post['TransferAdultCost'][$key],
'ChildCost' => (float) $post['TransferChildCost'][$key],
'IsActive' => 1,
'IsMarkForDel' => 0,
);
try {
$this->db->insert('TB_MP_Inventory_Accom_ExtraServices', $insertTransfer);
$status = true;
$message = 'Data Saved Successfully.';
} catch (Zend_Exception $ex) {
echo $ex->getMessage();
exit;
}
}
}
$TaxName = (isset($post['TaxName']) && !empty($post['TaxName'])) ? trim($post['TaxName']) : '';
$TaxAdultCost = (isset($post['TaxAdultCost'])) ? (float) $post['TaxAdultCost'] : 0;
$TaxChildCost = (isset($post['TaxChildCost'])) ? (float) $post['TaxChildCost'] : 0;
if (trim($TaxName) != '' && $TaxAdultCost > 0) {
$insertTax = array(
'AccomSysId' => $UpdateHotelId,
'AgencySysId' => $AgencySysId,
'ServiceType' => 2,
'SaleType' => $post['TaxSaletype'],
'RateType' => $post['TaxRateType'],
'SupplierSysId' => (int) $post['hidden_selected_tax_supplier_sys_id'],
'Title' => $TaxName,
'Detail' => '',
'Image' => '',
'CostCurrency' => $CurrencyType,
'AdultCost' => $TaxAdultCost,
'ChildCost' => $TaxChildCost,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
try {
$this->db->insert('TB_MP_Inventory_Accom_ExtraServices', $insertTax);
$status = true;
$message = 'Data Saved Successfully.';
} catch (Zend_Exception $ex) {
echo $ex->getMessage();
exit;
}
}
$response = array('status' => $status, 'message' => $message);
} else {
$response = array('status' => $status, 'message' => 'Invalid Hotel Id.');
}
echo json_encode($response);
exit;
}
}
public function runmyqueryAction() {
$objAccoModel = new Travel_Model_AccommodationModel();
$runmyquery = $objAccoModel->runmyquery();
}
public function bulkUploadAction() {
$objHotel = new Travel_Model_TblHotel();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$cityList = $objHotel->getInventoryCityList($this->intLoggedinUserAgencySysId);
$this->view->cityList = $cityList;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function autosuggestAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
try {
$arrResponse = array();
if ($this->getRequest()->getParam("query")) {
$term = $this->getRequest()->getParam("query");
$objAccoModel = new Travel_Model_AccommodationModel();
$condCity = "tbl.Title like '" . $term . "%' OR Alias = '" . $term . "'";
$arrResponse = $objAccoModel->getCityAutoSuggest($condCity);
}
echo json_encode($arrResponse);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
/* ##############################
Function :uploadBulkHotels
Operation:Bulk Hotels and Hotel Rates Add and Update by ExcellSheet
Develop By : Neeraj Prajapati
Date: 24/09/2024
################################# */
public function uploadBulkHotelsAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objHotel = new Travel_Model_TblHotel();
$objAccoModel = new Travel_Model_AccommodationModel();
$objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
if ($this->getRequest()->isPost()) {
$uploadedFileName = $_FILES['myfile']['name'];
$ext = @substr($uploadedFileName, strrpos($uploadedFileName, '.'));
$this->upload_path = 'public/upload/excel/';
$destination = $this->upload_path . $uploadedFileName;
if (($ext == ".csv") || ($ext == ".xls") || ($ext == ".xlsx")) {
try {
move_uploaded_file($_FILES['myfile']['tmp_name'], $destination);
$file = $this->upload_path . $uploadedFileName;
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('PHPExcel_');
$phpexcel_obj = new PHPExcel_Classes_Readexcel;
$finalData = $phpexcel_obj->importFromExcel($file);
array_shift($finalData);
$i = 0;
$currentDate = date('Y-m-d H:m:s');
$leadListArray = array();
$sessionarray = array();
foreach ($finalData as $listArray) {
if (!empty($listArray[1]) && !empty($listArray[2])) {
$leadListArray[$i]['cityName'] = $listArray[0];
$leadListArray[$i]['cityID'] = $listArray[1];
$leadListArray[$i]['ContSysId'] = $objHotel->getCountryIdByCityId($leadListArray[$i]['cityID']);
$leadListArray[$i]['hotalName'] = $listArray[2];
$leadListArray[$i]['HotelArea'] = $listArray[3];
$leadListArray[$i]['Address'] = !empty($listArray[4]) ? trim($listArray[4]) : '';
$leadListArray[$i]['rating'] = $listArray[5];
$leadListArray[$i]['PropertyType'] = isset(($listArray[6])) ? $this->getPropertyTypeId($listArray[6]) : 1;
$leadListArray[$i]['CheckInTime'] = !empty($listArray[7]) ? $this->getTime($listArray[7]) : '';
$leadListArray[$i]['CheckOutTime'] = !empty($listArray[8]) ? $this->getTime($listArray[8]) : '';
$leadListArray[$i]['SupplierId'] = !empty($listArray[9]) ? $objHotel->CheckSuppliers($this->intLoggedinUserAgencySysId, $listArray[9]) : '';
$leadListArray[$i]['contactEmail'] = !empty($listArray[10]) ? trim($listArray[10]) : '';
$leadListArray[$i]['countryCode'] = !empty(($listArray[11])) && (strpos($listArray[11], '+') === false) ? '+' . $listArray[11] : $listArray[11];
$leadListArray[$i]['phone'] = !empty($listArray[12]) ? trim($listArray[12]) : '';
$leadListArray[$i]['phone2'] = !empty($listArray[13]) ? trim($listArray[13]) : '';
$leadListArray[$i]['roomName'] = !empty($listArray[14]) ? trim($listArray[14]) : '';
$leadListArray[$i]['roomdescrip'] = !empty($listArray[14]) ? trim($listArray[15]) : '';
$leadListArray[$i]['Invertory'] = $listArray[16];
$leadListArray[$i]['basepax'] = $listArray[17];
$leadListArray[$i]['maxAdult'] = $listArray[18];
$leadListArray[$i]['maxKids'] = $listArray[19];
$leadListArray[$i]['maxGuest'] = $listArray[20];
$leadListArray[$i]['Currency'] = isset($listArray[21]) && !empty($listArray[21]) ? $objHotel->getcurrencyType(trim($listArray[21])) : 1;
$leadListArray[$i]['MealPlanWise'] = $listArray[22];
$leadListArray[$i]['RoomMealPlanWise'] = $listArray[23];
$leadListArray[$i]['BBMealPlanWise'] = $listArray[24];
$leadListArray[$i]['CP'] = $listArray[25];
$leadListArray[$i]['Map'] = $listArray[26];
$leadListArray[$i]['AP'] = $listArray[27];
$leadListArray[$i]['AI'] = $listArray[28];
$leadListArray[$i]['PremiumAI'] = $listArray[29];
$leadListArray[$i]['FromDate'] = $listArray[30];
$leadListArray[$i]['ToDate'] = $listArray[31];
$leadListArray[$i]['SingleSharingRate'] = $listArray[32];
$leadListArray[$i]['TwinSharingRate'] = $listArray[33];
$leadListArray[$i]['Exwbed'] = $listArray[34];
$leadListArray[$i]['Exwobed'] = $listArray[35];
$leadListArray[$i]['ChildEx'] = $listArray[36];
$leadListArray[$i]['ChildAge'] = $listArray[37];
$leadListArray[$i]['Breakfastrate'] = $listArray[38];
$leadListArray[$i]['LunchORDinner'] = $listArray[39];
$leadListArray[$i]['AllMeals'] = $listArray[40];
$leadListArray[$i]['ratetype'] = 'NR';
$MealrateType = null;
if ($leadListArray[$i]['MealPlanWise'] === 'Yes') {
$MealrateType = 0;
} else if ($leadListArray[$i]['RoomMealPlanWise'] === 'Yes') {
$MealrateType = 1;
} else if ($leadListArray[$i]['BBMealPlanWise'] === 'Yes') {
$MealrateType = 2;
}
$Area = $objTransportsRoutes->getAreaSysIdByName($listArray[3], $this->intLoggedinUserAgencySysId, $listArray[1]);
$mainsupplierId = $objHotel->getMainSuppliers($this->intLoggedinUserAgencySysId);
$supplierId = !empty($leadListArray[$i]['SupplierId']) ? $leadListArray[$i]['SupplierId'] : $mainsupplierId;
$CheckExistingHotel = $objHotel->CheckExistingHotelBYName($this->intLoggedinUserAgencySysId, $leadListArray[$i]['hotalName'], $leadListArray[$i]['cityID']);
if (!empty($CheckExistingHotel)) {
$AccomSysId = $CheckExistingHotel['AccomSysId'];
$ExistMealrateType = $CheckExistingHotel['RateType'];
$updateArr = array();
$updateArr = [
'SupplierSysId' => $supplierId,
'Stars' => isset($leadListArray[$i]['rating']) && !empty($leadListArray[$i]['rating']) && ($leadListArray[$i]['rating'] < 8) ? $leadListArray[$i]['rating'] : '0',
'ZoneSysId' => !empty($Area['AreaSysId']) ? $Area['AreaSysId'] : '0',
'Address' => $leadListArray[$i]['Address'],
'countrycode' => isset($leadListArray[$i]['countryCode']) && !empty($leadListArray[$i]['countryCode']) ? trim($leadListArray[$i]['countryCode']) : '0',
'PrimaryContact' => isset($leadListArray[$i]['phone']) && !empty($leadListArray[$i]['phone']) ? trim($leadListArray[$i]['phone']) : '0',
'SecondaryContact' => isset($leadListArray[$i]['phone2']) && !empty($leadListArray[$i]['phone2']) ? trim($leadListArray[$i]['phone2']) : '0',
'EmailID' => isset($leadListArray[$i]['contactEmail']) && !empty($leadListArray[$i]['contactEmail']) ? $leadListArray[$i]['contactEmail'] : '0',
'CurrencyType' => !empty($leadListArray[$i]['Currency']) ? $leadListArray[$i]['Currency'] : 1,
'UpdateDate' => $currentDate,
'RateType' => $MealrateType,
'IsActive' => '1',
'IsMarkForDel' => '0'
];
$objHotel->updateAccomodationInfo($updateArr, $AccomSysId);
$where = array('AcoomSysId =?' => $AccomSysId, 'AgencySysId =?' => $this->intLoggedinUserAgencySysId);
$insert_im = array('IsMarkForDelete' => 1, 'IsActive' => 0);
$this->db->update('Tb_Agency_Accom_Meal_Plan_Rate', $insert_im, $where);
if ($ExistMealrateType != $MealrateType) {
$whereIn = array('AccomSysId =?' => $AccomSysId);
$whereIn_acc = array('XRefAccoSysId =?' => $AccomSysId);
$update_im = array('IsMarkForDelete' => 1, 'IsActive' => 0, 'UpdatedDate' => $currentDate);
$this->db->update('Tb_MP_Accomdation_Room_Inventory', $update_im, $whereIn);
$this->db->update('TB_MP_Inventory_Accom', $update_im, $whereIn_acc);
}
} else {
$insert_arr = array();
$insert_arr = [
'IsAgentSpec' => true,
'SupplierSysId' => $supplierId,
'ICSourceSysId' => $this->intLoggedinUserAgencySysId,
'Title' => isset($leadListArray[$i]['hotalName']) && !empty($leadListArray[$i]['hotalName']) ? trim($leadListArray[$i]['hotalName']) : '',
'Stars' => isset($leadListArray[$i]['rating']) && !empty($leadListArray[$i]['rating']) && ($leadListArray[$i]['rating'] < 8) ? $leadListArray[$i]['rating'] : '0',
'PropertyType' => $leadListArray[$i]['PropertyType'],
'CitySysId' => $leadListArray[$i]['cityID'],
'Address' => $leadListArray[$i]['Address'],
'ZoneSysId' => !empty($Area['AreaSysId']) ? $Area['AreaSysId'] : '0',
'countrycode' => isset($leadListArray[$i]['countryCode']) && !empty($leadListArray[$i]['countryCode']) ? trim($leadListArray[$i]['countryCode']) : '0',
'PrimaryContact' => isset($leadListArray[$i]['phone']) && !empty($leadListArray[$i]['phone']) ? trim($leadListArray[$i]['phone']) : '0',
'SecondaryContact' => isset($leadListArray[$i]['phone2']) && !empty($leadListArray[$i]['phone2']) ? trim($leadListArray[$i]['phone2']) : '0',
'EmailID' => isset($leadListArray[$i]['contactEmail']) && !empty($leadListArray[$i]['contactEmail']) ? $leadListArray[$i]['contactEmail'] : '0',
'ShortName' => '',
'MaxPaxCount' => isset($leadListArray[$i]['basepax']) && !empty($leadListArray[$i]['basepax']) ? $leadListArray[$i]['basepax'] : '0',
'CheckinTime' => isset($leadListArray[$i]['CheckInTime']) && !empty($leadListArray[$i]['CheckInTime']) ? $leadListArray[$i]['CheckInTime'] : '0',
'CheckOutTime' => isset($leadListArray[$i]['CheckOutTime']) && !empty($leadListArray[$i]['CheckOutTime']) ? $leadListArray[$i]['CheckOutTime'] : '0',
'ZoneType' => '0',
'RefAgencySysId' => $this->intLoggedinUserAgencySysId,
'PlaceSysId_XRef' => '0', //need to understand
'Popularity' => '0', //need to understand
'StateSysId' => '0',
'CurrencyType' => !empty($leadListArray[$i]['Currency']) ? $leadListArray[$i]['Currency'] : 1,
'ContSysId' => isset($leadListArray[$i]['ContSysId']) && !empty($leadListArray[$i]['ContSysId']) ? $leadListArray[$i]['ContSysId'] : '0',
'UpdateDate' => $currentDate,
'ApproveDate' => '',
'ApproveBy' => '0',
'CreateDate' => $currentDate,
'RateType' => $MealrateType,
'IsLocked' => '1',
'IsApproved' => '0',
'IsActive' => '1',
'IsMarkForDel' => '0',
'MinStayNights' => 0,
'SplitStayNights' => 0,
];
$this->db->insert('TB_IC_Accomdation', $insert_arr);
$AccomSysId = $this->db->lastInsertId();
}
if ($AccomSysId) {
$responseRoomType = $objAccoModel->CheckRoomMaster($leadListArray[$i]['roomName']);
if ($responseRoomType) {
$responseRoomTypeID = $responseRoomType;
} else {
$data = array(
'Title' => $leadListArray[$i]['roomName'],
'UpdateDate' => $currentDate,
'CreateDate' => $currentDate,
'Icon' => '',
'IsMarkForDel' => 0,
'IsActive' => '1',
'RoomGrMask' => '1',
);
$responseRoomTypeID = $objAccoModel->InsertNewRoom($data);
}
$CheckAccomRoomExist = $objAccoModel->CheckAccomRoomExist($AccomSysId, $responseRoomTypeID, $this->intLoggedinUserAgencySysId);
if (!empty($CheckAccomRoomExist)) {
$XRefItemSysId = $CheckAccomRoomExist['ItemSysId'];
$update_Data = array(
'Qty' => isset($leadListArray[$i]['Invertory']) && !empty($leadListArray[$i]['Invertory']) ? $leadListArray[$i]['Invertory'] : '',
'PaxCount' => isset($leadListArray[$i]['basepax']) && !empty($leadListArray[$i]['basepax']) ? $leadListArray[$i]['basepax'] : 0,
'MaxPaxCount' => isset($leadListArray[$i]['maxAdult']) && !empty($leadListArray[$i]['maxAdult']) ? $leadListArray[$i]['maxAdult'] : 0,
'MaxAllowChild' => isset($leadListArray[$i]['maxKids']) && !empty($leadListArray[$i]['maxKids']) ? $leadListArray[$i]['maxKids'] : 0,
'MaxAllowGuest' => isset($leadListArray[$i]['maxGuest']) && !empty($leadListArray[$i]['maxGuest']) ? $leadListArray[$i]['maxGuest'] : 0,
'OtherDetails' => $leadListArray[$i]['roomdescrip'],
);
$objHotel->updateICAccomdationRoom($update_Data, $AccomSysId, $XRefItemSysId);
} else {
$insert_arr2 = array(
'AccomSysId' => $AccomSysId,
'SourceSysId' => $this->intLoggedinUserAgencySysId,
'Title' => '',
'RoomType' => $responseRoomTypeID,
'EconomyType' => 0,
'Qty' => isset($leadListArray[$i]['Invertory']) && !empty($leadListArray[$i]['Invertory']) ? $leadListArray[$i]['Invertory'] : '',
'BedType' => 0,
'ExtraBedType' => 0,
'RoomView' => 0,
'RoomLenght' => 0,
'RoomBreadth' => 0,
'RoomSizeMeasurement' => 0,
'PaxCount' => isset($leadListArray[$i]['basepax']) && !empty($leadListArray[$i]['basepax']) ? $leadListArray[$i]['basepax'] : 0,
'AllowChild' => 0,
'IsPetAllow' => 0,
'MaxPetAllow' => 0,
'AllowInfant' => 0,
'MaxPaxCount' => isset($leadListArray[$i]['maxAdult']) && !empty($leadListArray[$i]['maxAdult']) ? $leadListArray[$i]['maxAdult'] : 0,
'MaxAllowChild' => isset($leadListArray[$i]['maxKids']) && !empty($leadListArray[$i]['maxKids']) ? $leadListArray[$i]['maxKids'] : 0,
'MaxAllowGuest' => isset($leadListArray[$i]['maxGuest']) && !empty($leadListArray[$i]['maxGuest']) ? $leadListArray[$i]['maxGuest'] : 0,
'MaxAllowInfant' => 0,
'MealPlanType' => '',
'AminitiesMask' => '',
'InclustionOptionsMask' => '',
'OtherDetails' => $leadListArray[$i]['roomdescrip'],
'UpdatedDate' => $currentDate,
'CreateDate' => $currentDate,
'ApproveDate' => EMPTY_DATE,
'ApproveBy' => 0,
'IsDelete' => 0,
'IsActive' => '1',
'IsApproved' => '0',
'CancellationPolicy' => '',
);
$this->db->insert('TB_IC_Accomdation_Room', $insert_arr2);
$XRefItemSysId = $this->db->lastInsertId();
}
// MealPlan Rates
if (isset($MealrateType) && $MealrateType != 0) {
$newMealPlanArr = array();
$newMealPlanArr[6] = $leadListArray[$i]['CP'];
$newMealPlanArr[7] = $leadListArray[$i]['Map'];
$newMealPlanArr[8] = $leadListArray[$i]['AP'];
$newMealPlanArr[3] = $leadListArray[$i]['AI'];
$newMealPlanArr[10] = $leadListArray[$i]['PremiumAI'];
foreach ($newMealPlanArr as $key => $val) {
if ($MealrateType == 2 && $key == 6) {
} else {
$mealPlanArr = array(
'AcoomSysId' => $AccomSysId,
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'meal_type' => $key,
'AdultAmount' => (isset($val) && $val != '') ? $val : '0',
'ChildAmount' => (isset($val) && $val != '') ? $val : '0',
'IsActive' => 1,
'IsMarkForDelete' => 0,
'CreateDate' => $currentDate,
'UpdateDate' => $currentDate
);
$this->db->insert('Tb_Agency_Accom_Meal_Plan_Rate', $mealPlanArr);
}
}
}
// MealPlan Rates
$newCurrentdate = date('Y-m-d');
$currentDateStr = strtotime($newCurrentdate);
$fromDate = !empty($leadListArray[$i]['FromDate']) ? (($leadListArray[$i]['FromDate'] - 25569) * 86400) : null;
$fdate = !empty($fromDate) ? date("Y-m-d", $fromDate) : null;
$toDate = !empty($leadListArray[$i]['ToDate']) ? (($leadListArray[$i]['ToDate'] - 25569) * 86400) : null;
$tdate = !empty($toDate) ? date("Y-m-d", $toDate) : null;
$sessionKey = $objAccoModel->getMaxXRateSessionKey();
if (!empty($sessionarray)) {
foreach ($sessionarray as $key => $valuarray) {
if (in_array($AccomSysId, $valuarray) && in_array($fdate, $valuarray) && in_array($tdate, $valuarray)) {
$sessionKey = $valuarray['XRateSessionKey'];
}
}
}
$sessionarray[$i] = array();
$sessionarray[$i]['AccomSysId'] = $AccomSysId;
$sessionarray[$i]['XRateSessionKey'] = $sessionKey;
$sessionarray[$i]['FromDate'] = $fdate;
$sessionarray[$i]['Todate'] = $tdate;
if ($fromDate >= $currentDateStr && $toDate > $currentDateStr) {
$weekend = 'Sat,Sun';
if ($weekend) {
$where = array('AccomSysId =?' => $AccomSysId);
$this->db->update('TB_IC_Accomdation', array('WeekendDefine' => $weekend), $where);
}
$weekends = !empty($weekend) ? explode(',', trim($weekend)) : '';
$B2CMarkup = 0;
$B2BMarkup = 0;
$allocation = !empty($leadListArray[$i]['Invertory']) ? $leadListArray[$i]['Invertory'] : 10;
$age_paid = !empty($leadListArray[$i]['ChildAge']) ? $leadListArray[$i]['ChildAge'] : 3;
$strToDates = date("Y-m-d", strtotime("+1 day", strtotime($tdate)));
$begin = new DateTime($fdate);
$end = new DateTime($strToDates);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
if ($MealrateType == 0 || $MealrateType == 1) {
$check_meal_type[$i][] = 9; // for hotel
}
if ($leadListArray[$i]['Breakfastrate']) {
$check_meal_type[$i][] = 6;
}
if ($leadListArray[$i]['LunchORDinner']) {
$check_meal_type[$i][] = 7;
}
if ($leadListArray[$i]['AllMeals']) {
$check_meal_type[$i][] = 8;
}
$getMealPlanRate[$i] = $objAccoModel->CheckMealPlan($AccomSysId, $this->intLoggedinUserAgencySysId);
$newmealTypes[$i] = array_column($getMealPlanRate[$i], 'meal_type');
foreach ($check_meal_type[$i] as $key) {
if (!in_array($key, $newmealTypes[$i])) {
$newcheck_meal_type[$i][] = $key;
$check_markup_sg[$i][$key] = $check_markup_db[$i][$key] = $check_markup_ex[$i][$key] = $check_markup_tri[$i][$key] = $check_markup_chpaid[$i][$key] = 1;
if ($key == 9) {
if ($leadListArray[$i]['SingleSharingRate']) {
$sg_pub_wd[$i][$key] = $sg_net_wd[$i][$key] = $leadListArray[$i]['SingleSharingRate'];
}
if ($leadListArray[$i]['TwinSharingRate']) {
$db_pub_wd[$i][$key] = $db_net_wd[$i][$key] = $leadListArray[$i]['TwinSharingRate'];
}
if ($leadListArray[$i]['Exwbed']) {
$ex_wbed_pub_wd[$i][$key] = $ex_wbed_net_wd[$i][$key] = $leadListArray[$i]['Exwbed'];
}
if ($leadListArray[$i]['ChildEx']) {
$tri_pub_wd[$i][$key] = $tri_net_wd[$i][$key] = $leadListArray[$i]['ChildEx'];
}
if ($leadListArray[$i]['Exwobed']) {
$chpaid_pub_wd[$i][$key] = $chpaid_net_wd[$i][$key] = $leadListArray[$i]['Exwobed'];
}
} else if ($key == 6 && $leadListArray[$i]['Breakfastrate']) {
$sg_pub_wd[$i][$key] = $sg_net_wd[$i][$key] = $db_pub_wd[$i][$key] = $db_net_wd[$i][$key] = $ex_wbed_pub_wd[$i][$key] = $ex_wbed_net_wd[$i][$key] = $tri_pub_wd[$i][$key] = $tri_net_wd[$i][$key] = $chpaid_pub_wd[$i][$key] = $chpaid_net_wd[$i][$key] = $leadListArray[$i]['Breakfastrate'];
} else if ($key == 7 && $leadListArray[$i]['LunchORDinner']) {
$sg_pub_wd[$i][$key] = $sg_net_wd[$i][$key] = $db_pub_wd[$i][$key] = $db_net_wd[$i][$key] = $ex_wbed_pub_wd[$i][$key] = $ex_wbed_net_wd[$i][$key] = $tri_pub_wd[$i][$key] = $tri_net_wd[$i][$key] = $chpaid_pub_wd[$i][$key] = $chpaid_net_wd[$i][$key] = $leadListArray[$i]['LunchORDinner'];
} else if ($key == 8 && $leadListArray[$i]['AllMeals']) {
$sg_pub_wd[$i][$key] = $sg_net_wd[$i][$key] = $db_pub_wd[$i][$key] = $db_net_wd[$i][$key] = $ex_wbed_pub_wd[$i][$key] = $ex_wbed_net_wd[$i][$key] = $tri_pub_wd[$i][$key] = $tri_net_wd[$i][$key] = $chpaid_pub_wd[$i][$key] = $chpaid_net_wd[$i][$key] = $leadListArray[$i]['AllMeals'];
}
}
}
foreach ($period as $dt) {
$where = array(
'AccomSysId =?' => $AccomSysId,
'FromDate =? ' => $dt->format("Y-m-d"),
'XRefItemSysId =? ' => $XRefItemSysId,
'RoomSysId =? ' => $responseRoomTypeID,
'SupplierSysId =?' => $supplierId,
'AgencySysId =?' => $this->intLoggedinUserAgencySysId, // Fix the typo here
);
$insert_im = array('IsMarkForDelete' => 1, 'IsActive' => 0);
$this->db->update('Tb_MP_Accomdation_Room_Inventory', $insert_im, $where);
$insert = array(
'FromDate' => $dt->format("Y-m-d"),
'Todate' => $tdate,
'XRateSessionKey' => $sessionKey,
'PublishQty' => $allocation,
'NetInHandQty' => $allocation,
'BlockQty' => 0,
'SoldQty' => 0,
'UpdatedDate' => $currentDate,
'CreatedDate' => $currentDate,
'AccomSysId' => (int) $AccomSysId,
'RoomSysId' => (int) $responseRoomTypeID,
'SupplierSysId' => (int) $supplierId,
'AgencySysId' => $this->intLoggedinUserAgencySysId, // Fix the typo here
'XRefItemSysId' => (int) $XRefItemSysId,
'IsMarkForDelete' => 0,
'IsActive' => 1,
'IsSaleStart' => 1,
'BookingType' => (isset($BookingType[$k])) ? (int) $BookingType[$k] : 0,
);
$this->db->insert('Tb_MP_Accomdation_Room_Inventory', $insert);
$id = $this->db->lastInsertId();
$queryVals = array();
foreach ($newcheck_meal_type[$i] as $k) {
$queryVals[] = "(" . (int) $this->intLoggedinUserAgencySysId . ","
. '\'' . str_replace(' ', '', $weekend) . '\'' . ","
. (int) $k . ","
. '1' . ","
. (float) $B2CMarkup . ","
. (float) $B2BMarkup . ","
. (isset($sg_pub_wd[$i][$k]) && $sg_pub_wd[$i][$k] == '' ? 0 : (float) $sg_pub_wd[$i][$k]) . ","
. (isset($sg_net_wd[$i][$k]) && $sg_net_wd[$i][$k] == '' ? 0 : (float) $sg_net_wd[$i][$k]) . ","
. (isset($check_tax_sg[$i][0]) ? $check_tax_sg[$i][0] : '0') . ","
. (isset($db_pub_wd[$i][$k]) && $db_pub_wd[$i][$k] == '' ? 0 : (float) $db_pub_wd[$i][$k]) . ","
. (isset($db_net_wd[$i][$k]) && $db_net_wd[$i][$k] == '' ? 0 : (float) $db_net_wd[$i][$k]) . ","
. (isset($check_tax_db[$i][0]) ? $check_tax_db[$i][0] : '0') . ","
. (isset($ex_wbed_pub_wd[$i][$k]) && $ex_wbed_pub_wd[$i][$k] == '' ? 0 : (float) $ex_wbed_pub_wd[$i][$k]) . ","
. (isset($ex_wbed_net_wd[$i][$k]) && $ex_wbed_net_wd[$i][$k] == '' ? 0 : (float) $ex_wbed_net_wd[$i][$k]) . ","
. (isset($check_tax_ex[$i][0]) ? (float) $check_tax_ex[$i][0] : '0') . ","
. (isset($tri_pub_wd[$i][$k]) && $tri_pub_wd[$i][$k] == '' ? 0 : (float) $tri_pub_wd[$i][$k]) . ","
. (isset($tri_net_wd[$i][$k]) && $tri_net_wd[$i][$k] == '' ? 0 : (float) $tri_net_wd[$i][$k]) . ","
. (isset($check_tax_tri[$i][0]) ? (float) $check_tax_tri[$i][0] : '0') . ","
. (isset($age_paid) && !empty($age_paid) ? (float) $age_paid : '1') . ","
. (isset($chpaid_pub_wd[$i][$k]) && $chpaid_pub_wd[$i][$k] == '' ? 0 : (float) $chpaid_pub_wd[$i][$k]) . ","
. (isset($chpaid_net_wd[$i][$k]) && $chpaid_net_wd[$i][$k] == '' ? 0 : (float) $chpaid_net_wd[$i][$k]) . ","
. (isset($check_tax_chpaid[$i][0]) ? (float) $check_tax_chpaid[$i][0] : '0') . ","
. (isset($leadListArray[$i]['ratetype']) && ($leadListArray[$i]['ratetype'] == 'NR') ? '1' : '0') . ","
. (isset($post['rr_type']) && !empty($post['rr_type']) ? (int) $post['rr_type'] : '0') . ","
. '\'' . $currentDate . '\'' . ","
. '\'' . $currentDate . '\'' . ","
. (int) $AccomSysId . ","
. (int) $id . ","
. (int) $XRefItemSysId . ","
. (isset($leadListArray[$i]['Currency']) && !empty($leadListArray[$i]['Currency']) ? $leadListArray[$i]['Currency'] : '1') . ","
. (isset($supplierId) && !empty($supplierId) ? $supplierId : '0') . ","
. (isset($check_markup_sg[$i][$k]) ? (float) $check_markup_sg[$i][$k] : '0') . ","
. (isset($check_markup_db[$i][$k]) ? (float) $check_markup_db[$i][$k] : '0') . ","
. (isset($check_markup_tri[$i][$k]) ? (float) $check_markup_tri[$i][$k] : '0') . ","
. (isset($check_markup_ex[$i][$k]) ? (float) $check_markup_ex[$i][$k] : '0') . ","
. (isset($check_markup_chpaid[$i][$k]) ? (float) $check_markup_chpaid[$i][$k] : '0') . ","
. '1' . ","
. '0' . ")";
}
$abdcs = "INSERT INTO TB_MP_Inventory_Accom (\"AgencySysId\",\"WeekendDefine\",\"MealPlanType\",\"MarkType\",\"B2CMarkup\",
\"B2BMarkup\",\"SOccupCost\",\"NetSOccupCost\",\"IsTaxOnSOccupCost\",\"DOccupCost\",\"NetDOccupCost\",\"IsTaxOnDOccupCost\",
\"ExtraBedCost\",\"NetExtraBedCost\",\"IsTaxOnExtraBedCost\",\"TriOccupCost\",\"NetTriOccupCost\",\"IsTaxOnTriOccupCost\",
\"ChildAgeLimit\",\"ExtraWOBedCost\",\"NetExtraWOBedCost\",\"IsTaxOnExtraWOBedCost\",\"RateType\",\"RackCommissionType\",
\"UpdatedDate\",\"CreatedDate\",\"XRefAccoSysId\",\"RoomInventorySysId\",\"XRefItemSysId\",\"TrxCurrency\",\"SupplierSysId\",\"IsAllowMarkupSO\",\"IsAllowMarkupDO\",\"IsAllowMarkupTO\",\"IsAllowMarkupEB\",\"IsAllowMarkupWOB\",\"IsActive\",\"IsMarkForDelete\")
VALUES " . implode(",", $queryVals);
$ret = $this->db->query($abdcs);
}
}
}
}
$i++;
}
$response = array('success' => true, 'msg' => "Hotel Uploaded SuccessFully");
echo json_encode($response);
exit;
} catch (Zend_File_Transfer_Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'msg' => "File Not Valid ! Only Csv, xls, xlsx File Allow");
echo json_encode($response);
exit;
}
}
}
public function getTime($the_value) {
$total = $the_value * 24;
$hours = floor($total);
$display = $hours . ":00";
return $display;
}
public function tncAction() {
$this->_helper->layout->disableLayout();
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
$objAccoModel = new Travel_Model_AccommodationModel();
$TblAgency = new Travel_Model_TblAgency();
if (isset($params['id']) && !empty($params['id'])) {
$result = $objAccoModel->hotelDetails($params['id'], $this->intLoggedinUserAgencySysId);
}
$getAgencyTnCDetails = $TblAgency->getAgencyTnCDetails($this->intLoggedinUserAgencySysId);
$this->view->hotelDetails = !empty($result) ? $result : '';
$this->view->getAgencyTnCDetails = !empty($getAgencyTnCDetails) ? $getAgencyTnCDetails : array();
$this->view->hotel_id = !empty($params['id']) ? $params['id'] : '0';
$this->render('ajaxrequest/ng/tnc');
}
public function addupdatehoteltncAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
if ($this->getRequest()->isPost()) {
$result = $objAccoModel->addUpdateHotelTnc($this->intLoggedinUserAgencySysId);
if (!empty($result)) {
$response = array('success' => true, 'HotelId' => $result, 'message' => 'Hotel term & conditions added successfully');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to add hotel. try again');
echo json_encode($response);
exit;
}
}
}
public function getPropertyTypeId($PropertyName) {
$arrProprtyType = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getProprtyType();
$Typeid = '';
foreach ($arrProprtyType as $key => $val) {
if ($PropertyName === $val) {
$Typeid = $key;
}
}
return $Typeid;
}
public function updateHotelRatesAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
$status = false;
$message = 'Unable to action please try after some time!!';
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
$type = isset($post['type']) ? trim($post['type']) : 'status';
$AccomSysId = isset($post['AccomSysId']) ? (int) $post['AccomSysId'] : 0;
$XRateSessionKey = isset($post['XRateSessionKey']) ? trim($post['XRateSessionKey']) : '';
$XRefItemSysId = isset($post['XRefItemSysId']) ? (int) $post['XRefItemSysId'] : 0;
$RoomSysId = isset($post['RoomSysId']) ? (int) $post['RoomSysId'] : 0;
$MealPlanType = isset($post['MealPlanType']) ? (int) $post['MealPlanType'] : 0;
$update_id = 0;
if ($AccomSysId > 0 && $XRefItemSysId > 0 && $MealPlanType > 0 && !empty($XRateSessionKey)) {
if ($type == 'update') {
$AddUpdateHotelRateOnly = $objAccoModel->AddUpdateHotelRateOnly($this->intLoggedinUserAgencySysId);
} else {
$getRoomInventoryIds = $objAccoModel->getRoomInventoryIds($AccomSysId, $XRateSessionKey, $XRefItemSysId);
if (!empty($getRoomInventoryIds)) {
$getRoomInventoryIdsArray = array_column($getRoomInventoryIds, 'id');
if (!empty($getRoomInventoryIdsArray)) {
$where = array(
'XRefAccoSysId =?' => $AccomSysId,
'XRefItemSysId =? ' => $XRefItemSysId,
'MealPlanType =? ' => $MealPlanType,
'RoomInventorySysId IN (?) ' => $getRoomInventoryIdsArray,
);
if ($type == 'delete') {
$updateData = array('IsMarkForDelete' => 1, 'IsActive' => 0);
} else if ($type == 'status') {
$Status = isset($post['Status']) ? (int) $post['Status'] : 1;
$updateData = array('IsActive' => $Status);
}
$update_id = $this->db->update('TB_MP_Inventory_Accom', $updateData, $where);
if ($type == 'delete') {
$CheckInventoryRateExist = $objAccoModel->CheckInventoryRateExist($this->intLoggedinUserAgencySysId, $AccomSysId, $XRateSessionKey, $XRefItemSysId);
if (empty($CheckInventoryRateExist)) {
$whereRoom = array(
'AccomSysId =?' => $AccomSysId,
'XRateSessionKey =? ' => $XRateSessionKey,
'XRefItemSysId =? ' => $XRefItemSysId,
'AgencySysId =?' => $this->intLoggedinUserAgencySysId
);
$update_id = $this->db->update('Tb_MP_Accomdation_Room_Inventory', $updateData, $whereRoom);
}
}
if ($update_id > 0) {
$status = true;
if ($type == 'delete') {
$message = 'Rate deleted successfully.';
} else {
$message = 'Rate status updated successfully.';
}
}
}
}
}
}
$response = array('status' => $status, 'message' => $message);
echo json_encode($response);
exit;
}
}
public function checkHotelDetailToAddRateAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
$MealPlanOrder = array(
9 => 0,
6 => 1,
7 => 2,
8 => 3,
3 => 4,
);
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AccomSysId = isset($post['AccomSysId']) ? $post['AccomSysId'] : 0;
$type = isset($post['type']) ? $post['type'] : 'addview';
if ($AccomSysId > 0) {
//$result = $objAccoModel->hotelDetailsRates($AccomSysId, $this->intLoggedinUserAgencySysId);
$RoomDetailsList = $objAccoModel->HotelRoomDetailsList($AccomSysId, $AgencySysId);
if (empty($RoomDetailsList)) {
echo "room";
exit;
}
$HotelrateCardByAgListByHotelNew = $objAccoModel->HotelrateCardByAgListByHotelOptimizedNew($this->intLoggedinUserAgencySysId, $AccomSysId, 'all', '', array(), 1);
$hotelName = $HotelrateCardByAgListByHotelNew[0]['hotelName'];
$CityTitle = $HotelrateCardByAgListByHotelNew[0]['CityTitle'];
$CurrencySymbol = $HotelrateCardByAgListByHotelNew[0]['CurrencySymbol'];
$SupplierName = $HotelrateCardByAgListByHotelNew[0]['SupplierName'];
$RoomTypeHtml = '<select id="room_type_' . $AccomSysId . '" name="room_type" class="form-control" placeholder="Select room types" >';
foreach ($RoomDetailsList as $rKey => $rValue) {
$RoomTypeHtml .= '<option value=' . $rValue["room"]["ItemSysId"] . '__' . $rValue["room"]["RoomTypeId"] . '>' . $rValue["room"]["RoomType"] . '</option>';
}
$RoomTypeHtml .= '</select>';
$RoomInventory = (!empty($HotelrateCardByAgListByHotelNew[0]['RoomInventory'])) ? json_decode($HotelrateCardByAgListByHotelNew[0]['RoomInventory'], 1) : array();
$RoomInventoryArray = $RoomInventoryArrayFin = array();
$CheckSeasionWiseDate = array();
// echo "<pre>";print_r($RoomInventory);die;
foreach ($RoomInventory as $riKey => $riValue) {
$FromToDate = $riValue['FromDate'].'-'.$riValue['ToDate'];
$checkStr = $riValue['XRateSessionKey'] . '-' . $riValue['RoomSysId'] . '-' . $riValue['MealPlanType'];
if ($HotelrateCardByAgListByHotelNew[0]['HotelRateType'] == 1) {
if (isset($RoomInventoryArray[$checkStr])) {
$dt = date('D', strtotime($riValue['FromDate']));
$weekends = (!empty($riValue['WeekendDefine'])) ? explode(',', $riValue['WeekendDefine']) : array();
if (in_array($dt, $weekends)) {
$RoomInventoryArray[$checkStr]['WkNetSOccupCost'] = $riValue['NetSOccupCost'];
$RoomInventoryArray[$checkStr]['WkNetDOccupCost'] = $riValue['NetDOccupCost'];
$RoomInventoryArray[$checkStr]['WkNetTriOccupCost'] = $riValue['NetTriOccupCost'];
$RoomInventoryArray[$checkStr]['WkNetExtraBedCost'] = $riValue['NetExtraBedCost'];
$RoomInventoryArray[$checkStr]['WkNetExtraWOBedCost'] = $riValue['NetExtraWOBedCost'];
}
} else {
$riValue['WkNetSOccupCost'] = $riValue['NetSOccupCost'];
$riValue['WkNetDOccupCost'] = $riValue['NetDOccupCost'];
$riValue['WkNetTriOccupCost'] = $riValue['NetTriOccupCost'];
$riValue['WkNetExtraBedCost'] = $riValue['NetExtraBedCost'];
$riValue['WkNetExtraWOBedCost'] = $riValue['NetExtraWOBedCost'];
$RoomInventoryArray[$checkStr] = $riValue;
}
} else {
$RoomInventoryArray[$checkStr] = $riValue;
}
// $RoomInventoryArrayFin[$FromToDate]['XRateSessionKey'] = $riValue['XRateSessionKey'];
$RoomInventoryArrayFin[$FromToDate][$riValue['XRefItemSysId']][$MealPlanOrder[$riValue['MealPlanType']]] = $RoomInventoryArray[$checkStr];
$FromDateSTR = strtotime($riValue['FromDate']);
if (!isset($CheckSeasionWiseDate[$FromToDate]) || $CheckSeasionWiseDate[$FromToDate] > $FromDateSTR) {
$XRateSessionKeyFinDates[$FromToDate]['Dates'] = array(
'FromDate' => date('d-M-Y', strtotime($riValue['FromDate'])),
'ToDate' => date('d-M-Y', strtotime($riValue['ToDate']))
);
if ((int) $riValue['IsPromotionalRate'] == 1) {
$XRateSessionKeyFinDates[$FromToDate]['BookingDates'] = array(
'FromDate' => date('d-M-Y', strtotime($riValue['FromBookingDate'])),
'ToDate' => date('d-M-Y', strtotime($riValue['ToBookingDate'])),
'IsNight' => (int) $riValue['IsNight'],
'MinNight' => (int) $riValue['MinNight'],
'MaxNight' => (int) $riValue['MaxNight'],
'IsMinRoom' => (int) $riValue['IsMinRoom'],
'MinRoom' => (int) $riValue['MinRoom'],
);
}
}
$CheckSeasionWiseDate[$FromToDate] = $FromDateSTR;
$XRateSessionKeyFinDates[$FromToDate]['Room'][$riValue['XRefItemSysId']] = $riValue['RoomName'];
}
$costhtml = '';
foreach ($RoomInventoryArrayFin as $riafKey => $riafValue) {
$SessionClassStr = $AccomSysId . '_' . $riafKey;
$costhtml .= '<tr class="hotelname_room_meal_tr_ hotelname_session_row_' . $SessionClassStr . '">
<td colspan="2" style="width:12.8%;" >
<input type="hidden" name="FromDateDMY" class="form-control" id="FromDateDMY_' . $SessionClassStr . '" value="' . date('d/m/Y', strtotime($XRateSessionKeyFinDates[$riafKey]['Dates']['FromDate'])) . '">
<input type="hidden" name="ToDateDMY" class="form-control" id="ToDateDMY_' . $SessionClassStr . '" value="' . date('d/m/Y', strtotime($XRateSessionKeyFinDates[$riafKey]['Dates']['ToDate'])) . '">
<div>' . date('d-M-Y', strtotime($XRateSessionKeyFinDates[$riafKey]['Dates']['FromDate'])) .
' - ' . date('d-M-Y', strtotime($XRateSessionKeyFinDates[$riafKey]['Dates']['ToDate'])) .
'</div>';
if ($XRateSessionKeyFinDates[$riafKey]['BookingDates']['FromDate'] && $XRateSessionKeyFinDates[$riafKey]['BookingDates']['ToDate']) {
$costhtml .= '<br><div style="font-weight: 700;">
<span style="">Promotion Rates:- </span><br>
From: ' . date('d-M-Y', strtotime($XRateSessionKeyFinDates[$riafKey]['BookingDates']['FromDate'])) . '
<br>To:' . date('d-M-Y', strtotime($XRateSessionKeyFinDates[$riafKey]['BookingDates']['ToDate']));
if (isset($XRateSessionKeyFinDates[$riafKey]['BookingDates']['IsNight']) && $XRateSessionKeyFinDates[$riafKey]['BookingDates']['IsNight'] == 1) {
$MinNightSh = $XRateSessionKeyFinDates[$riafKey]['BookingDates']['MinNight'];
$MaxNightSh = $XRateSessionKeyFinDates[$riafKey]['BookingDates']['MaxNight'];
$costhtml .= '<br>Night: (Min: ' . $MinNightSh . ' - Max: ' . $MaxNightSh . ')';
}
if (isset($XRateSessionKeyFinDates[$riafKey]['BookingDates']['IsMinRoom']) && $XRateSessionKeyFinDates[$riafKey]['BookingDates']['IsMinRoom'] == 1) {
$MinRoomSh = $XRateSessionKeyFinDates[$riafKey]['BookingDates']['MinRoom'];
$costhtml .= '<br>Room: (Min: ' . $MinRoomSh . ')';
}
$costhtml .= '</div>';
}
$costhtml .= '</td>
<td style="padding:0;margin:0;" colspan="15" class="room_table_classPre">
<table class="room_table_class table" style="padding:0;margin:0;width: 100%;border-collapse: collapse;table-layout: fixed;"><tbody class="hotelname_session_body_' . $SessionClassStr . '">';
ksort($riafValue);
foreach ($riafValue as $riafKey1 => $riafValue1) {
$SessionRoomClassStr = $AccomSysId . '_' . $riafKey . '_' . $riafKey1;
$costhtml .= '<tr class="hotelname_session_room_row_' . $SessionRoomClassStr . '"><td style="width:10.2%;border: 0px !important;" ><div>' . trim($XRateSessionKeyFinDates[$riafKey]['Room'][$riafKey1]) . '</div></td>'
. '<td colspan="15" style="padding:0;margin:0;" class="room_table_classPre">
<table class="room_table_class table " style="padding:0;margin:0;width: 100%;"><tbody class="hotelname_session_room_body_' . $SessionRoomClassStr . '">';
ksort($riafValue1);
foreach ($riafValue1 as $riamKey => $riamValue) {
$XRefItemSysId = $riamValue['XRefItemSysId'];
$XRateSessionKey = $riamValue['XRateSessionKey'];
$RoomSysId = $riamValue['RoomSysId'];
$MealPlanType = $riamValue['MealPlanType'];
$FromDate = date('d-M-Y', strtotime($riamValue['FromDate']));
$ToDate = date('d-M-Y', strtotime($riamValue['ToDate']));
$IsActiveRate = (int) $riamValue['IsActiveRate'];
$ratecardurl = $this->baseUrl . 'accommodation/rate-card/id/' . $riamValue['AccomSysId'] . '/SessionKey/' . (!empty($riamValue['XRateSessionKey']) ? trim($riamValue['XRateSessionKey']) : '') . '#preview_pre';
$ClassStr = $AccomSysId . '_' . $XRateSessionKey . '_' . $RoomSysId . '_' . $MealPlanType;
$costhtml .= '<tr class="hotelname_room_meal_tr_' . $ClassStr . '" >
<td style="width:6%;border-left:none !important"><input type="hidden" id="ThisDateRange_'.$AccomSysId.'_'.$XRateSessionKey.'" value="'.$riafKey.'">' . trim($riamValue["MealPlanTitle"]) . '</td>
<td style="width:3.8%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="B2BMarkup" class="form-control" id="B2BMarkup_' . $ClassStr . '" value="' . (float) $riamValue["B2BMarkup"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["B2BMarkup"] . '</div>
</td>
<td style="width:3.7%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="B2CMarkup" class="form-control" id="B2CMarkup_' . $ClassStr . '" value="' . (float) $riamValue["B2CMarkup"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["B2CMarkup"] . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetSOccupCost" class="form-control" id="NetSOccupCost_' . $ClassStr . '" value="' . ($riamValue["NetSOccupCost"] != '' ? (float) $riamValue["NetSOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetSOccupCost"] != '' ? (float) $riamValue["NetSOccupCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetSOccupCost" class="form-control" id="WkNetSOccupCost_' . $ClassStr . '" value="' . ($riamValue["WkNetSOccupCost"] != '' ? (float) $riamValue["WkNetSOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetSOccupCost"] != '' ? (float) $riamValue["WkNetSOccupCost"] : '') . '</div>
</td>
<td style="width:7%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetDOccupCost" class="form-control" id="NetDOccupCost_' . $ClassStr . '" value="' . ($riamValue["NetDOccupCost"] != '' ? (float) $riamValue["NetDOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetDOccupCost"] != '' ? (float) $riamValue["NetDOccupCost"] : '') . '</div>
</td>
<td style="width:7%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetDOccupCost" class="form-control" id="WkNetDOccupCost_' . $ClassStr . '" value="' . ($riamValue["WkNetDOccupCost"] != '' ? (float) $riamValue["WkNetDOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetDOccupCost"] != '' ? (float) $riamValue["WkNetDOccupCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetExtraBedCost" class="form-control" id="NetExtraBedCost_' . $ClassStr . '" value="' . ($riamValue["NetExtraBedCost"] != '' ? (float) $riamValue["NetExtraBedCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetExtraBedCost"] != '' ? (float) $riamValue["NetExtraBedCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetExtraBedCost" class="form-control" id="WkNetExtraBedCost_' . $ClassStr . '" value="' . ($riamValue["WkNetExtraBedCost"] != '' ? (float) $riamValue["WkNetExtraBedCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetExtraBedCost"] != '' ? (float) $riamValue["WkNetExtraBedCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetTriOccupCost" class="form-control" id="NetTriOccupCost_' . $ClassStr . '" value="' . ($riamValue["NetTriOccupCost"] != '' ? (float) $riamValue["NetTriOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetTriOccupCost"] != '' ? (float) $riamValue["NetTriOccupCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetTriOccupCost" class="form-control" id="WkNetTriOccupCost_' . $ClassStr . '" value="' . ($riamValue["WkNetTriOccupCost"] != '' ? (float) $riamValue["WkNetTriOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetTriOccupCost"] != '' ? (float) $riamValue["WkNetTriOccupCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetExtraWOBedCost" class="form-control" id="NetExtraWOBedCost_' . $ClassStr . '" value="' . ($riamValue["NetExtraWOBedCost"] != '' ? (float) $riamValue["NetExtraWOBedCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetExtraWOBedCost"] != '' ? (float) $riamValue["NetExtraWOBedCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetExtraWOBedCost" class="form-control" id="WkNetExtraWOBedCost_' . $ClassStr . '" value="' . ($riamValue["WkNetExtraWOBedCost"] != '' ? (float) $riamValue["WkNetExtraWOBedCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetExtraWOBedCost"] != '' ? (float) $riamValue["WkNetExtraWOBedCost"] : '') . '</div>
</td>
<td style="width:10.7%;padding-bottom:0px;" class="hotelname_room_meal_action_rd_' . $ClassStr . '">
<input type="hidden" value="' . $IsActiveRate . '" class="HotelRateStatus_' . $ClassStr . '">
<div class="allActionRateDiv_' . $ClassStr . '">';
if ($XRateSessionKeyFinDates[$riafKey]['BookingDates']['FromDate']) {
$PromotionsSysId = (int) $riamValue['PromotionsSysId'];
$costhtml .= '<a href="/accommodation/add-hotels/id/' . ((int) $AccomSysId) . '#!/addupdatepromotion/' . $PromotionsSysId . '" target="_blank" class="view_text1 tooltipLink"><i class="fa fa-pencil-square-o"></i></a>';
} else {
$costhtml .= '<a href="javascript://" class="view_text1 tooltipLink" onclick="updateHotelRates(\'copy\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')"><i class="fa fa-copy"></i></a>
<a href="javascript://" class="view_text1 tooltipLink" onclick="updateHotelRates(\'modify\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')"><i class="fa fa-pencil-square-o"></i></a>
<a href="javascript://" class="view_text1 tooltipLink HotelRateStatusIcon_' . $ClassStr . '" title="' . ($riamValue['IsActiveRate'] == 1 ? 'Deactivate' : 'Activate') . '" onclick="updateHotelRates(\'status\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')">';
if ($riamValue['IsActiveRate'] == 1) {
$costhtml .= '<i class="fa fa-times"></i>';
} else {
$costhtml .= '<i class="fa fa-check-circle-o"></i>';
}
$costhtml .= '</a>
<a href="javascript://" class="view_text1 tooltipLink" onclick="updateHotelRates(\'delete\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')"><i class="fa fa-minus-circle"></i></a>';
}
$costhtml .= '</div>
<div class="hide-div-class modifyRateDiv_' . $ClassStr . '">
<a class="btn btn-primary UpdateupdateHotelRatesBtn' . $ClassStr . '" onclick="updateHotelRates(\'update\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')">Update</a>
<a class="btn btn-primarygray pull-right cancelUpdateHotelRateBtn' . $ClassStr . '" onclick="cancelUpdateHotelRate(\'' . $ClassStr . '\')" title="Cancel"><i class="fa fa-close"></i></a>
</div>
<span class="hotelname_room_meal_action_rd_span_' . $ClassStr . '" style="height: 16px;width: 100%;display: block;"></span>
</td></tr>';
}
$costhtml .= '</tbody></table></td></tr> ';
}
$costhtml .= '</tbody></table></td></tr> ';
}
$RateType = isset($HotelrateCardByAgListByHotelNew[0]['RateType']) ? (int) $HotelrateCardByAgListByHotelNew[0]['RateType'] : 0;
$MealPlanTypeHtml = '<option value="9">EP</option><option value="6">CP/BB</option><option value="7">MAP</option><option value="8">AP</option><option value="3">AI</option>';
if ($RateType == 1) {
$MealPlanTypeHtml = '<option value="9">EP</option>';
} else if ($RateType == 2) {
$MealPlanTypeHtml = '<option value="6">CP/BB</option>';
}
$formhtml = '<tr id="hotelRateForm' . $AccomSysId . '" class="hotelname_room_meal_tr_">
<input type="hidden" name="NewAccomSysId" class="NewAccomSysId" value="' . $AccomSysId . '">
<td><input type="text" name="from_date" id="from_dt' . $AccomSysId . '" class="form-control no-padding" autocomplete="off"></td>
<td><input type="text" name="to_date" id="to_dt' . $AccomSysId . '" class="form-control no-padding" autocomplete="off"></td>
<td><div class="new_hotel_room_div">' . $RoomTypeHtml . '</div></td>
<td>
<select class="form-control" name="meal_plan_type" id="meal_plan_type' . $AccomSysId . '" autocomplete="off">
' . $MealPlanTypeHtml . '
</select>
</td>
<td><input type="text" name="b2b_markup" id="b2b_markup' . $AccomSysId . '" class="form-control" autocomplete="off" maxlength="3" ></td>
<td><input type="text" name="b2c_markup" id="b2c_markup' . $AccomSysId . '" class="form-control" autocomplete="off" maxlength="3"></td>
<td><input type="text" name="sg_net_wd" id="sg_net_wd' . $AccomSysId . '" class="form-control" autocomplete="off" onkeyup="CopyPasteFromTo(' . $AccomSysId . ',\'sg_net_wd\',\'sg_net_wk\')"></td>
<td><input type="text" name="sg_net_wk" id="sg_net_wk' . $AccomSysId . '" class="form-control" autocomplete="off"></td>
<td><input type="text" name="db_net_wd" id="db_net_wd' . $AccomSysId . '" class="form-control" autocomplete="off" onkeyup="CopyPasteFromTo(' . $AccomSysId . ',\'db_net_wd\',\'db_net_wk\')"></td>
<td><input type="text" name="db_net_wk" id="db_net_wk' . $AccomSysId . '" class="form-control" autocomplete="off"></td>
<td><input type="text" name="ex_wbed_net_wd" id="ex_wbed_net_wd' . $AccomSysId . '" class="form-control" autocomplete="off" onkeyup="CopyPasteFromTo(' . $AccomSysId . ',\'ex_wbed_net_wd\',\'ex_wbed_net_wk\')"></td>
<td><input type="text" name="ex_wbed_net_wk" id="ex_wbed_net_wk' . $AccomSysId . '" class="form-control" autocomplete="off"></td>
<td><input type="text" name="tri_net_wd" id="tri_net_wd' . $AccomSysId . '" class="form-control" autocomplete="off" onkeyup="CopyPasteFromTo(' . $AccomSysId . ',\'tri_net_wd\',\'tri_net_wk\')"></td>
<td><input type="text" name="tri_net_wk" id="tri_net_wk' . $AccomSysId . '" class="form-control" autocomplete="off"></td>
<td><input type="text" name="chpaid_net_wd" id="chpaid_net_wd' . $AccomSysId . '" class="form-control" autocomplete="off" onkeyup="CopyPasteFromTo(' . $AccomSysId . ',\'chpaid_net_wd\',\'chpaid_net_wk\')"></td>
<td><input type="text" name="chpaid_net_wk" id="chpaid_net_wk' . $AccomSysId . '" class="form-control" autocomplete="off"></td>
<td><a class="btn btn-primary saveHotelRateBtn' . $AccomSysId . '" onclick="saveHotelRate(' . $AccomSysId . ')">Save</a><a class="btn btn-primarygray pull-right cancelHotelRateBtn' . $AccomSysId . '" onclick="cancelHotelRate(' . $AccomSysId . ')" title="Cancel"><i class="fa fa-close"></i></a></td>
</tr>';
$html = '<table class="table tablestyle table-bottomless hotel_list_table_' . $AccomSysId . '">
<tr class="alert alert-graylight hotelname_tr_' . $AccomSysId . '" >
<th colspan="6">
<div class="new_hotel_name_html">
<a target="_blank" href="/accommodation/add-hotels/id/' . $AccomSysId . '" title="Update Hotel" class="">
<span class="smallbold">' . $hotelName . ' (' . $AccomSysId . ') - ' . $CityTitle . '</span></a>
<a target="_blank" href="/accommodation/rate-card/id/' . $AccomSysId . '" title="Update Bulk Rates" class="view_text1 tooltipLink pull-right"><i class="fa fa-money" aria-hidden="true"></i></a>
</div>
<div class="new_hotel_room_html" style="display:none;"></div>
</th>
<th class="smallbold" colspan="2">
<div class="new_hotel_currency_html">Currency : ' . $CurrencySymbol . '</div>
</th>
<th class="smallbold" colspan="10">
<div class="new_hotel_suplier_html pull-left">Supplier : ' . $SupplierName . '</div>
<a onclick="IsWebsite(' . $AccomSysId . ')" class="pull-right dow_update_' . $AccomSysId . '" style="color:#ff4906;">DOW/Update </a>
</th>
</tr>
<tr class="hotelname_rate_tr_' . $AccomSysId . '">
<th class="smallbold" width="6.4%">From</th>
<th class="smallbold" width="6.4%">To</th>
<th class="smallbold" width="9%">Room</th>
<th class="smallbold" width="5.4%">Meal Plan</th>
<th class="smallbold text-center" width="6.6%" colspan="2" >
<span class="">Markup (%)</span><br>
<span class="pull-left">B2B</span><span class="pull-right">B2C</span>
</th>
<th class="smallbold" width="5.5%">Single Weekday</th>
<th class="smallbold" width="5.5%">Single Weekend</th>
<th class="smallbold" width="6.2%">Room Base Weekday</th>
<th class="smallbold" width="6.2%">Room Base Weekend</th>
<th class="smallbold" width="5.5%">Ext Adult Weekday</th>
<th class="smallbold" width="5.5%">Ext Adult Weekend</th>
<th class="smallbold" width="5.5%">Ext Child bed Weekday</th>
<th class="smallbold" width="5.5%">Ext Child bed Weekend</th>
<th class="smallbold" width="5.5%">Child NB Weekday</th>
<th class="smallbold" width="5.5%">Child NB Weekend</th>
<th class="smallbold" width="9.8%"><a class="btn btn-primarygray pull-right getHotelAddRateFormBtn' . $AccomSysId . '" href="javascript://" onclick="getHotelAddRateForm(' . $AccomSysId . ')" disabled="disabled">Add</a></th>
</tr>' . $formhtml . '<tr><td colspan="17" style="padding:0;margin:0;"><table class="table tablestyle" style="padding:0;margin:0;width: 100%;border-collapse: collapse;table-layout: fixed;"><tbody id="hotelRateRowData' . $AccomSysId . '">' . $costhtml . '</tbody></table></td></tr>
</table>';
if ($type == 'addonly') {
echo $formhtml;
exit;
} else {
echo $html;
exit;
}
} else {
echo '';
exit;
}
}
}
public function checkHotelRatesAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$status = true;
$response = array('status' => $status);
if ($this->getRequest()->isPost()) {
$inputData = file_get_contents("php://input");
$post = json_decode($inputData, true);
$AccomSysId = isset($post['NewAccomSysId']) ? (int) $post['NewAccomSysId'] : 0;
$from_date = isset($post['from_date']) ? $post['from_date'] : '';
$to_date = isset($post['to_date']) ? $post['to_date'] : '';
if (empty($from_date) || empty($to_date)) {
$status = false;
$response = array('status' => $status, 'message' => 'Please select from and to date!!');
echo json_encode($response);
exit;
}
$room_type = isset($post['room_type']) ? $post['room_type'] : '';
$meal_plan_type = isset($post['meal_plan_type']) ? (int) $post['meal_plan_type'] : 0;
$FromDate = implode('-', array_reverse(explode('/', $from_date)));
$ToDate = implode('-', array_reverse(explode('/', $to_date)));
$currentDate = date("Y-m-d H:i:s");
if (!empty($room_type)) {
$getHotelDetails = $objAccoModel->getHotelRateType($AccomSysId, $AgencySysId);
$isInventory = true;
if (isset($getHotelDetails['HotelRateType']) && $getHotelDetails['HotelRateType'] == 2) {
$isInventory = false;
}
$rkey = 0;
$roomItemTypeE = explode('__', $room_type);
$ItemSysId = (int) $roomItemTypeE[0];
$RoomTypeId = (int) $roomItemTypeE[1];
if ($ItemSysId > 0 && $RoomTypeId > 0 && $meal_plan_type > 0) {
$checkHotelRoomInventoryRateByDate = $objAccoModel->checkHotelRoomInventoryRate($this->intLoggedinUserAgencySysId, $AccomSysId, $FromDate, $ToDate, 0, 0, 1);
$checkHotelRoomInventoryRate = $SessionRoomFromDateArray = $SessionRoomFromToDateArray = array();
if (!empty($checkHotelRoomInventoryRateByDate)) {
$ExistFromDate = $checkHotelRoomInventoryRateByDate[0]['FromDate']->format('Y-m-d');
$ExistToDate = $checkHotelRoomInventoryRateByDate[0]['ToDate']->format('Y-m-d');
$ExistFromDateDMY = $checkHotelRoomInventoryRateByDate[0]['FromDate']->format('d/m/Y');
$ExistToDateDMY = $checkHotelRoomInventoryRateByDate[0]['ToDate']->format('d/m/Y');
if ($ExistFromDate != $FromDate || $ExistToDate != $ToDate) {
$status = false;
$ExistFromDateStr = strtotime($ExistFromDate);
$ExistToDateStr = strtotime($ExistToDate);
$FromDateStr = strtotime($FromDate);
$ToDateStr = strtotime($ToDate);
$FromDateNewDMY = date('d/m/Y', $FromDateStr);
$TODateNewDMY = date('d/m/Y', $ToDateStr);
$message = 'This date range, or within date range already exist. Existing session (' . $ExistFromDateDMY . ' - ' . $ExistToDateDMY . ')';
if ($ExistFromDateStr < $FromDateStr && $ExistToDateStr > $ToDateStr) { // Old 01/04/2025-30/04/2025 new 10/04/2025-20/04/2025
$ExistToDateDMYNew = date('d/m/Y', strtotime('-1 day', $FromDateStr));
$ExistFromDateDMYNew = date('d/m/Y', strtotime('+1 day', $ToDateStr));
$NewSession = '<br><br>New session will be <br>1. ' . $ExistFromDateDMY . ' - ' . $ExistToDateDMYNew;
$NewSession .= ', <br>2. ' . $FromDateNewDMY . ' - ' . $TODateNewDMY;
$NewSession .= ', <br>3. ' . $ExistFromDateDMYNew . ' - ' . $ExistToDateDMY;
$message = $message . ' ' . $NewSession;
$status = true;
} else if ($ExistFromDateStr < $FromDateStr && $ExistToDateStr < $ToDateStr) { // Old 01/04/2025-30/04/2025 new 10/04/2025-10/05/2025
$ExistToDateDMYNew = date('d/m/Y', strtotime('-1 day', $FromDateStr));
$NewSession = '<br><br>New session will be <br>1. ' . $ExistFromDateDMY . ' - ' . $ExistToDateDMYNew;
$NewSession .= ', <br>2. ' . $FromDateNewDMY . ' - ' . $TODateNewDMY;
$message = $message . ' ' . $NewSession;
$status = true;
} else if ($ExistFromDateStr > $FromDateStr && $ExistToDateStr > $ToDateStr) { // Old 01/04/2025-30/04/2025 new 10/03/2025-10/04/2025
$ExistFromDateDMYNew = date('d/m/Y', strtotime('+1 day', $ToDateStr));
$NewSession = '<br><br>New session will be <br>1. ' . $FromDateNewDMY . ' - ' . $TODateNewDMY;
$NewSession .= ', <br>2. ' . $ExistFromDateDMYNew . ' - ' . $ExistToDateDMY;
$message = $message . ' ' . $NewSession;
$status = true;
} else if ($ExistFromDateStr > $FromDateStr && $ExistToDateStr < $ToDateStr) { // Old 01/04/2025-30/04/2025 new 10/03/2025-10/05/2025
$ExistFromDateDMYNew = date('d/m/Y', strtotime('-1 day', $ExistFromDateStr));
$ExistToDateDMYNew = date('d/m/Y', strtotime('+1 day', $ExistToDateStr));
$NewSession = '<br><br>New session will be <br>1. ' . $FromDateNewDMY . ' - ' . $ExistFromDateDMYNew;
$NewSession .= ', <br>2. ' . $ExistFromDateDMY . ' - ' . $ExistToDateDMY;
$NewSession .= ', <br>3. ' . $ExistToDateDMYNew . ' - ' . $TODateNewDMY;
$message = $message . ' ' . $NewSession;
$status = true;
}
$response = array('status' => $status, 'confirm' => 1, 'message' => $message);
echo json_encode($response);
exit;
}
foreach ($checkHotelRoomInventoryRateByDate as $key => $value) {
if ($value['RoomSysId'] == $RoomTypeId && $value['MealPlanType'] == $meal_plan_type) {
$checkHotelRoomInventoryRate[] = $value;
}
$ExistFromDate = $value['FromDate']->format('Y-m-d');
$ExistToDate = $value['ToDate']->format('Y-m-d');
$SessionRoomFromDateArray[$value['XRateSessionKey']][$value['RoomSysId']][$ExistFromDate] = $value;
$SessionRoomFromToDateArray[$value['XRateSessionKey']][$value['RoomSysId']][$ExistFromDate . '-' . $ExistToDate] = $value;
}
}
//$checkHotelRoomInventoryRate = $objAccoModel->checkHotelRoomInventoryRate($this->intLoggedinUserAgencySysId,$AccomSysId,$FromDate,$ToDate, $RoomTypeId, $meal_plan_type);
if (!empty($checkHotelRoomInventoryRate)) {
$response = array('status' => false, 'message' => 'This Room and Meal Plan Rate already exist for this date range, or within date range. Existing session (' . $ExistFromDateDMY . ' - ' . $ExistToDateDMY . ')');
echo json_encode($response);
exit;
}
} else {
$response = array('status' => false, 'message' => 'Room Id / Meal Id Missing.');
echo json_encode($response);
exit;
}
} else {
$response = array('status' => false, 'message' => 'Please select Room.');
}
echo json_encode($response);
exit;
}
}
public function copySplitSessionAndRates($post, $ranges, $intLoggedinUserAgencySysId, $AccomSysId, $XRateSessionKey, $ItemSysId, $RoomTypeId) {
$objAccoModel = new Travel_Model_AccommodationModel();
$getRoomInventoryIdsRates = $objAccoModel->getRoomInventoryIdsRates($AccomSysId, $XRateSessionKey, $ItemSysId);
// echo "<pre>";print_r($getRoomInventoryIdsRates);die;
$PublishQty = $NetInHandQty = 0;
$currentDate = date("Y-m-d H:i:s");
if(!empty($getRoomInventoryIdsRates)){
foreach ($ranges as $key => $value) {
$sessionKey = $objAccoModel->getMaxXRateSessionKey();
$insert = [
'FromDate' => $value['start_date'],
'Todate' => $value['end_date'],
'XRateSessionKey' => $sessionKey,
'PublishQty' => $getRoomInventoryIdsRates[0]['PublishQty'],
'NetInHandQty' => $getRoomInventoryIdsRates[0]['NetInHandQty'],
'BlockQty' => $getRoomInventoryIdsRates[0]['BlockQty'],
'SoldQty' => $getRoomInventoryIdsRates[0]['SoldQty'],
'UpdatedDate' => $getRoomInventoryIdsRates[0]['UpdatedDate']->format('Y-m-d H:i:s'),
'CreatedDate' => $getRoomInventoryIdsRates[0]['CreatedDate']->format('Y-m-d H:i:s'),
'AccomSysId' => (int) $AccomSysId,
'RoomSysId' => (int) $getRoomInventoryIdsRates[0]['RoomSysId'],
'SupplierSysId' => (int) $getRoomInventoryIdsRates[0]['HotelSupplierSysId'],
'AgencySysId' => (int) $intLoggedinUserAgencySysId,
'XRefItemSysId' => (int) $ItemSysId,
'IsMarkForDelete' => 0,
'IsActive' => 1,
'IsSaleStart' => 1,
'BookingType' => 0,
];
$this->db->insert('Tb_MP_Accomdation_Room_Inventory', $insert);
$id = $this->db->lastInsertId();
foreach ($getRoomInventoryIdsRates as $riKey => $riValue) {
$getRoomInventoryIdsArray[] = $riValue['id'];
$addHotelData = array(
"AgencySysId" => (int) $intLoggedinUserAgencySysId,
"WeekendDefine" => $riValue['WeekendDefine'],
"MealPlanType" => (int) $riValue['MealPlanType'],
"MarkType" => $riValue['MarkType'],
"B2CMarkup" => (float) $riValue['B2CMarkup'],
"B2BMarkup" => (float) $riValue['B2BMarkup'],
"SOccupCost" => $riValue['SOccupCost'],
"NetSOccupCost" => $riValue['NetSOccupCost'],
"IsTaxOnSOccupCost" => $riValue['IsTaxOnSOccupCost'],
"TaxSOccupCost" => $riValue['TaxSOccupCost'],
"DOccupCost" => $riValue['DOccupCost'],
"NetDOccupCost" => $riValue['NetDOccupCost'],
"IsTaxOnDOccupCost" => $riValue['IsTaxOnDOccupCost'],
"TaxDOccupCost" => $riValue['TaxDOccupCost'],
"ExtraBedCost" => $riValue['ExtraBedCost'],
"NetExtraBedCost" => $riValue['NetExtraBedCost'],
"IsTaxOnExtraBedCost" => $riValue['IsTaxOnExtraBedCost'],
"TaxExtraBedCost" => $riValue['TaxExtraBedCost'],
"TriOccupCost" => $riValue['TriOccupCost'],
"NetTriOccupCost" => $riValue['NetTriOccupCost'],
"IsTaxOnTriOccupCost" => $riValue['IsTaxOnTriOccupCost'],
"TaxTriOccupCost" => $riValue['TaxTriOccupCost'],
"ChildAgeLimit" => $riValue['ChildAgeLimit'],
"ExtraWOBedCost" => $riValue['ExtraWOBedCost'],
"NetExtraWOBedCost" => $riValue['NetExtraWOBedCost'],
"IsTaxOnExtraWOBedCost" => $riValue['IsTaxOnExtraWOBedCost'],
"TaxExtraWOBedCost" => $riValue['TaxExtraWOBedCost'],
"RateType" => $riValue['RateType'],
"RackCommissionType" => $riValue['RackCommissionType'],
"RackCommission" => $riValue['RackCommission'],
"UpdatedDate" => $riValue['UpdatedDate']->format('Y-m-d H:i:s'),
"CreatedDate" => $riValue['CreatedDate']->format('Y-m-d H:i:s'),
"XRefAccoSysId" => (int) $AccomSysId,
"RoomInventorySysId" => (int) $id,
"XRefItemSysId" => (int) $riValue['XRefItemSysId'],
"TrxCurrency" => $riValue['TrxCurrency'],
"SupplierSysId" => $riValue['SupplierSysId'],
"IsAllowMarkupSO" => $riValue['IsAllowMarkupSO'],
"IsAllowMarkupDO" => $riValue['IsAllowMarkupDO'],
"IsAllowMarkupTO" => $riValue['IsAllowMarkupTO'],
"IsAllowMarkupEB" => $riValue['IsAllowMarkupEB'],
"IsAllowMarkupWOB" => $riValue['IsAllowMarkupWOB'],
"IsActive" => 1,
"IsMarkForDelete" => 0,
"WkSOccupCost" => $riValue['WkSOccupCost'],
"WkNetSOccupCost" => $riValue['WkNetSOccupCost'],
"WkDOccupCost" => $riValue['WkDOccupCost'],
"WkNetDOccupCost" => $riValue['WkNetDOccupCost'],
"WkExtraBedCost" => $riValue['WkExtraBedCost'],
"WkNetExtraBedCost" => $riValue['WkNetExtraBedCost'],
"WkTriOccupCost" => $riValue['WkTriOccupCost'],
"WkNetTriOccupCost" => $riValue['WkNetTriOccupCost'],
"WkExtraWOBedCost" => $riValue['WkExtraWOBedCost'],
"WkNetExtraWOBedCost" => $riValue['WkNetExtraWOBedCost'],
);
try {
$this->db->insert('TB_MP_Inventory_Accom', $addHotelData);
} catch (Exception $ex) {
die($ex->getMessage());
}
}
$whereIn = array('AccomSysId =?' => $AccomSysId, 'XRateSessionKey =?' => $XRateSessionKey, 'XRefItemSysId =?' => $ItemSysId);
$whereIn_acc = array(
'XRefAccoSysId =?' => $AccomSysId,
'XRefItemSysId =? ' => $ItemSysId,
'RoomInventorySysId IN (?) ' => $getRoomInventoryIdsArray,
);
$update_im = array('IsMarkForDelete' => 1, 'IsActive' => 0, 'UpdatedDate' => $currentDate);
$this->db->update('Tb_MP_Accomdation_Room_Inventory', $update_im, $whereIn);
$this->db->update('TB_MP_Inventory_Accom', $update_im, $whereIn_acc);
}
}
return true;
}
public function saveHotelRatesAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$response = array('status' => false);
if ($this->getRequest()->isPost()) {
$inputData = file_get_contents("php://input");
$post = json_decode($inputData, true);
$AccomSysId = isset($post['NewAccomSysId']) ? (int) $post['NewAccomSysId'] : 0;
$from_date = isset($post['from_date']) ? $post['from_date'] : '';
$to_date = isset($post['to_date']) ? $post['to_date'] : '';
if (empty($from_date) || empty($to_date)) {
$response = array('status' => false, 'message' => 'Please select from and to date!!');
echo json_encode($response);
exit;
}
$room_type = isset($post['room_type']) ? $post['room_type'] : '';
$meal_plan_type = isset($post['meal_plan_type']) ? (int) $post['meal_plan_type'] : 0;
$b2b_markup = isset($post['b2b_markup']) ? (float) $post['b2b_markup'] : 0;
$b2c_markup = isset($post['b2c_markup']) ? (float) $post['b2c_markup'] : 0;
$sg_net_wd = (isset($post['sg_net_wd']) && $post['sg_net_wd'] != '') ? (float) $post['sg_net_wd'] : 'NULL';
$sg_net_wk = (isset($post['sg_net_wk']) && $post['sg_net_wk'] != '') ? (float) $post['sg_net_wk'] : 'NULL';
$db_net_wd = (isset($post['db_net_wd']) && $post['db_net_wd'] != '') ? (float) $post['db_net_wd'] : 'NULL';
$db_net_wk = (isset($post['db_net_wk']) && $post['db_net_wk'] != '') ? (float) $post['db_net_wk'] : 'NULL';
$ex_wbed_net_wd = (isset($post['ex_wbed_net_wd']) && $post['ex_wbed_net_wd'] != '') ? (float) $post['ex_wbed_net_wd'] : 'NULL';
$ex_wbed_net_wk = (isset($post['ex_wbed_net_wk']) && $post['ex_wbed_net_wk'] != '') ? (float) $post['ex_wbed_net_wk'] : 'NULL';
$tri_net_wd = (isset($post['tri_net_wd']) && $post['tri_net_wd'] != '') ? (float) $post['tri_net_wd'] : 'NULL';
$tri_net_wk = (isset($post['tri_net_wk']) && $post['tri_net_wk'] != '') ? (float) $post['tri_net_wk'] : 'NULL';
$chpaid_net_wd = (isset($post['chpaid_net_wd']) && $post['chpaid_net_wd'] != '') ? (float) $post['chpaid_net_wd'] : 'NULL';
$chpaid_net_wk = (isset($post['chpaid_net_wk']) && $post['chpaid_net_wk'] != '') ? (float) $post['chpaid_net_wk'] : 'NULL';
$age_paid = 7;
$FromDate = implode('-', array_reverse(explode('/', $from_date)));
$ToDate = implode('-', array_reverse(explode('/', $to_date)));
$currentDate = date("Y-m-d H:i:s");
if (!empty($room_type)) {
$getHotelDetails = $objAccoModel->getHotelRateType($AccomSysId, $AgencySysId);
$isInventory = true;
if (isset($getHotelDetails['HotelRateType']) && $getHotelDetails['HotelRateType'] == 2) {
$isInventory = false;
}
$rkey = 0;
$roomItemTypeE = explode('__', $room_type);
$ItemSysId = (int) $roomItemTypeE[0];
$RoomTypeId = (int) $roomItemTypeE[1];
if ($ItemSysId > 0 && $RoomTypeId > 0 && $meal_plan_type > 0) {
$checkHotelRoomInventoryRateByDate = $objAccoModel->checkHotelRoomInventoryRate($this->intLoggedinUserAgencySysId, $AccomSysId, $FromDate, $ToDate, 0, 0, 1);
$copySplitSessionAndRates = 0;
$checkHotelRoomInventoryRate = $SessionRoomFromDateArray = $SessionRoomFromToDateArray = array();
$dateranges = array();
$strFromDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($from_date, 'd/m/y');
$strToDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($to_date, 'd/m/y');
$daterangesNew[] = array(
'start_date' => $strFromDate,
'end_date' => $strToDate
);
if (!empty($checkHotelRoomInventoryRateByDate)) {
foreach ($checkHotelRoomInventoryRateByDate as $key => $value) {
if ($value['RoomSysId'] == $RoomTypeId && $value['MealPlanType'] == $meal_plan_type) {
$checkHotelRoomInventoryRate[] = $value;
}
$ExistFromDateM = $value['FromDate']->format('Y-m-d');
$ExistToDateM = $value['ToDate']->format('Y-m-d');
$SessionRoomFromDateArray[$value['XRateSessionKey']][$value['RoomSysId']][$ExistFromDateM] = $value;
$SessionRoomFromToDateArray[$value['XRateSessionKey']][$value['RoomSysId']][$ExistFromDateM . '-' . $ExistToDateM] = $value;
}
if (!empty($checkHotelRoomInventoryRate)) {
$XRateSessionKey = $checkHotelRoomInventoryRate[0]['XRateSessionKey'];
$ExistFromDate = $checkHotelRoomInventoryRate[0]['FromDate']->format('Y-m-d');
$ExistToDate = $checkHotelRoomInventoryRate[0]['ToDate']->format('Y-m-d');
$ExistFromDateDMY = $checkHotelRoomInventoryRate[0]['FromDate']->format('d/m/Y');
$ExistToDateDMY = $checkHotelRoomInventoryRate[0]['ToDate']->format('d/m/Y');
} else {
$XRateSessionKey = $checkHotelRoomInventoryRateByDate[0]['XRateSessionKey'];
$ExistFromDate = $checkHotelRoomInventoryRateByDate[0]['FromDate']->format('Y-m-d');
$ExistToDate = $checkHotelRoomInventoryRateByDate[0]['ToDate']->format('Y-m-d');
$ExistFromDateDMY = $checkHotelRoomInventoryRateByDate[0]['FromDate']->format('d/m/Y');
$ExistToDateDMY = $checkHotelRoomInventoryRateByDate[0]['ToDate']->format('d/m/Y');
}
if ($ExistFromDate != $FromDate || $ExistToDate != $ToDate) {
$ExistFromDateStr = strtotime($ExistFromDate);
$ExistToDateStr = strtotime($ExistToDate);
$FromDateStr = strtotime($FromDate);
$ToDateStr = strtotime($ToDate);
$FromDateNewDMY = date('d/m/Y', $FromDateStr);
$TODateNewDMY = date('d/m/Y', $ToDateStr);
if ($ExistFromDateStr < $FromDateStr && $ExistToDateStr > $ToDateStr) { // Old 01/04/2025-30/04/2025 new 10/04/2025-20/04/2025
$dateranges[] = [
'start_date' => $ExistFromDate,
'end_date' => date('Y-m-d', strtotime('-1 day', $FromDateStr))
];
$dateranges[] = [
'start_date' => date('Y-m-d', strtotime('+1 day', $ToDateStr)),
'end_date' => $ExistToDate
];
} else if ($ExistFromDateStr < $FromDateStr && $ExistToDateStr < $ToDateStr) { // Old 01/04/2025-30/04/2025 new 10/04/2025-10/05/2025
$dateranges[] = [
'start_date' => $ExistFromDate,
'end_date' => date('Y-m-d', strtotime('-1 day', $FromDateStr))
];
} else if ($ExistFromDateStr > $FromDateStr && $ExistToDateStr > $ToDateStr) { // Old 01/04/2025-30/04/2025 new 10/03/2025-10/04/2025
$dateranges[] = [
'start_date' => date('Y-m-d', strtotime('+1 day', $ToDateStr)),
'end_date' => $ExistToDate
];
} else if ($ExistFromDateStr > $FromDateStr && $ExistToDateStr < $ToDateStr) { // Old 01/04/2025-30/04/2025 new 10/03/2025-10/05/2025
$daterangesNew = array();
$daterangesNew[] = [
'start_date' => $FromDate,
'end_date' => date('Y-m-d', strtotime('-1 day', $ExistFromDateStr))
];
$daterangesNew[] = [
'start_date' => date('Y-m-d', strtotime('+1 day', $ExistToDateStr)),
'end_date' => $ToDate
];
$copySplitSessionAndRates = 1;
}
if (!empty($dateranges)) {
$this->copySplitSessionAndRates($post, $dateranges, $this->intLoggedinUserAgencySysId, $AccomSysId, $XRateSessionKey, $ItemSysId, $RoomTypeId);
$copySplitSessionAndRates = 1;
} else if ($copySplitSessionAndRates == 0) {
$response = array('status' => false, 'message' => 'This. date range, or within date range already exist. Existing session (' . $ExistFromDateDMY . ' - ' . $ExistToDateDMY . ')');
echo json_encode($response);
exit;
}
//
// echo "<pre>";print_r($dateranges);die;
}
}
//echo "<pre>";print_r($checkHotelRoomInventoryRateByDate);die;
//$checkHotelRoomInventoryRate = $objAccoModel->checkHotelRoomInventoryRate($this->intLoggedinUserAgencySysId,$AccomSysId,$FromDate,$ToDate, $RoomTypeId, $meal_plan_type);
// if(!empty($checkHotelRoomInventoryRate)){
// $response = array('status' => false, 'message' => 'This Room and Meal Plan Rate already exist for this date range, or within date range. Existing session ('.$ExistFromDateDMY.' - '.$ExistToDateDMY.')');
// echo json_encode($response); exit;
// }
// echo "<pre>";print_r($checkHotelRoomInventoryRateByDate);
// echo "<pre>";print_r($checkHotelRoomInventoryRate);
// echo "<pre>";print_r($SessionRoomArray);die;
if (!empty($ItemSysId) && !empty($RoomTypeId) && !empty($meal_plan_type) && !empty($db_net_wd) && $db_net_wd != 'NULL') {
$weekend = (isset($getHotelDetails['WeekendDefine']) && !empty($getHotelDetails['WeekendDefine'])) ? $getHotelDetails['WeekendDefine'] : '';
$CurrencyType = (isset($getHotelDetails['CurrencyType']) && !empty($getHotelDetails['CurrencyType'])) ? (int) $getHotelDetails['CurrencyType'] : 0;
$SupplierSysId = (isset($getHotelDetails['SupplierSysId']) && !empty($getHotelDetails['SupplierSysId'])) ? (int) $getHotelDetails['SupplierSysId'] : 0;
$NetRateType = (isset($getHotelDetails['NetRateType']) && !empty($getHotelDetails['NetRateType'])) ? (int) $getHotelDetails['NetRateType'] : 0;
$RackCommission = (isset($getHotelDetails['RackCommission']) && !empty($getHotelDetails['RackCommission'])) ? (float) $getHotelDetails['RackCommission'] : 0;
$RRType = 0;
$check_markup_sg = $check_markup_db = $check_markup_tri = $check_markup_ex = $check_markup_chpaid = 1;
$PublishQty = $NetInHandQty = 10;
$weekends = explode(',', $weekend);
$strToDates = date("Y-m-d", strtotime("+1 day", strtotime($strToDate)));
$begin = new DateTime($strFromDate);
$end = new DateTime($strToDates);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
$queryVals = array();
if ($isInventory == true) {
$IsExistSessionKey = 0;
if (isset($checkHotelRoomInventoryRateByDate[0]['XRateSessionKey']) && !empty($checkHotelRoomInventoryRateByDate[0]['XRateSessionKey']) && $copySplitSessionAndRates == 0) {
$sessionKey = $checkHotelRoomInventoryRateByDate[0]['XRateSessionKey'];
$IsExistSessionKey = 1;
} else {
$sessionKey = $objAccoModel->getMaxXRateSessionKey();
}
foreach ($period as $dt) {
$FromDateDDD = $dt->format("Y-m-d");
$insert = [
'FromDate' => $FromDateDDD,
'Todate' => $strToDate,
'XRateSessionKey' => $sessionKey,
'PublishQty' => $PublishQty,
'NetInHandQty' => $NetInHandQty,
'BlockQty' => 0,
'SoldQty' => 0,
'UpdatedDate' => $currentDate,
'CreatedDate' => $currentDate,
'AccomSysId' => (int) $AccomSysId,
'RoomSysId' => (int) $RoomTypeId,
'SupplierSysId' => (int) $SupplierSysId,
'AgencySysId' => $AgencySysId,
'XRefItemSysId' => (int) $ItemSysId,
'IsMarkForDelete' => 0,
'IsActive' => 1,
'IsSaleStart' => 1,
'BookingType' => 0,
];
if (isset($SessionRoomFromDateArray[$sessionKey][$RoomTypeId][$FromDateDDD]) && !empty($SessionRoomFromDateArray[$sessionKey][$RoomTypeId][$FromDateDDD])) {
$id = $SessionRoomFromDateArray[$sessionKey][$RoomTypeId][$FromDateDDD]['id'];
} else {
$this->db->insert('Tb_MP_Accomdation_Room_Inventory', $insert);
$id = $this->db->lastInsertId();
}
if (in_array($dt->format("D"), $weekends)) {
$queryVals[] = "(" . (int) $AgencySysId . ","
. '\'' . $weekend . '\'' . ","
. (int) $meal_plan_type . ","
. '1' . ","
. (float) $b2c_markup . ","
. (float) $b2b_markup . ","
. $sg_net_wk . ","
. $sg_net_wk . ","
. '0' . ","
. '0' . ","
. $db_net_wk . ","
. $db_net_wk . ","
. '0' . ","
. '0' . ","
. $ex_wbed_net_wk . ","
. $ex_wbed_net_wk . ","
. '0' . ","
. '0' . ","
. $tri_net_wk . ","
. $tri_net_wk . ","
. '0' . ","
. '0' . ","
. $age_paid . ","
. $chpaid_net_wk . ","
. $chpaid_net_wk . ","
. '0' . ","
. '0' . ","
. $NetRateType . ","
. $RRType . ","
. $RackCommission . ","
. '\'' . $currentDate . '\'' . ","
. '\'' . $currentDate . '\'' . ","
. (int) $AccomSysId . ","
. (int) $id . ","
. (int) $ItemSysId . ","
. $CurrencyType . ","
. $SupplierSysId . ","
. $check_markup_sg . ","
. $check_markup_db . ","
. $check_markup_tri . ","
. $check_markup_ex . ","
. $check_markup_chpaid . ","
. '1' . ","
. '0' . ")";
} else {
$queryVals[] = "(" . (int) $AgencySysId . ","
. '\'' . $weekend . '\'' . ","
. (int) $meal_plan_type . ","
. '1' . ","
. (float) $b2c_markup . ","
. (float) $b2b_markup . ","
. $sg_net_wd . ","
. $sg_net_wd . ","
. '0' . ","
. '0' . ","
. $db_net_wd . ","
. $db_net_wd . ","
. '0' . ","
. '0' . ","
. $ex_wbed_net_wd . ","
. $ex_wbed_net_wd . ","
. '0' . ","
. '0' . ","
. $tri_net_wd . ","
. $tri_net_wd . ","
. '0' . ","
. '0' . ","
. $age_paid . ","
. $chpaid_net_wd . ","
. $chpaid_net_wd . ","
. '0' . ","
. '0' . ","
. $NetRateType . ","
. $RRType . ","
. $RackCommission . ","
. '\'' . $currentDate . '\'' . ","
. '\'' . $currentDate . '\'' . ","
. (int) $AccomSysId . ","
. (int) $id . ","
. (int) $ItemSysId . ","
. $CurrencyType . ","
. $SupplierSysId . ","
. $check_markup_sg . ","
. $check_markup_db . ","
. $check_markup_tri . ","
. $check_markup_ex . ","
. $check_markup_chpaid . ","
. '1' . ","
. '0' . ")";
}
}
$abdcs = "INSERT INTO TB_MP_Inventory_Accom (\"AgencySysId\",\"WeekendDefine\",\"MealPlanType\",\"MarkType\",\"B2CMarkup\",
\"B2BMarkup\",\"SOccupCost\",\"NetSOccupCost\",\"IsTaxOnSOccupCost\",\"TaxSOccupCost\",\"DOccupCost\",\"NetDOccupCost\",\"IsTaxOnDOccupCost\",\"TaxDOccupCost\",
\"ExtraBedCost\",\"NetExtraBedCost\",\"IsTaxOnExtraBedCost\",\"TaxExtraBedCost\",\"TriOccupCost\",\"NetTriOccupCost\",\"IsTaxOnTriOccupCost\",\"TaxTriOccupCost\",
\"ChildAgeLimit\",\"ExtraWOBedCost\",\"NetExtraWOBedCost\",\"IsTaxOnExtraWOBedCost\",\"TaxExtraWOBedCost\",\"RateType\",\"RackCommissionType\",\"RackCommission\",
\"UpdatedDate\",\"CreatedDate\",\"XRefAccoSysId\",\"RoomInventorySysId\",\"XRefItemSysId\",\"TrxCurrency\",\"SupplierSysId\",\"IsAllowMarkupSO\",\"IsAllowMarkupDO\",\"IsAllowMarkupTO\",\"IsAllowMarkupEB\",\"IsAllowMarkupWOB\",\"IsActive\",\"IsMarkForDelete\")
VALUES " . implode(",", $queryVals);
$ret = $this->db->query($abdcs);
} else {
if (!empty($daterangesNew)) {
foreach ($daterangesNew as $dKey => $dValue) {
$IsExistSessionKey = 0;
if (isset($checkHotelRoomInventoryRateByDate[0]['XRateSessionKey']) && !empty($checkHotelRoomInventoryRateByDate[0]['XRateSessionKey']) && $copySplitSessionAndRates == 0) {
$sessionKey = $checkHotelRoomInventoryRateByDate[0]['XRateSessionKey'];
$IsExistSessionKey = 1;
} else {
$sessionKey = $objAccoModel->getMaxXRateSessionKey();
}
$strFromDate = $dValue['start_date'];
$strToDate = $dValue['end_date'];
$insert = [
'FromDate' => $dValue['start_date'],
'Todate' => $dValue['end_date'],
'XRateSessionKey' => $sessionKey,
'PublishQty' => $PublishQty,
'NetInHandQty' => $NetInHandQty,
'BlockQty' => 0,
'SoldQty' => 0,
'UpdatedDate' => $currentDate,
'CreatedDate' => $currentDate,
'AccomSysId' => (int) $AccomSysId,
'RoomSysId' => (int) $RoomTypeId,
'SupplierSysId' => (int) $SupplierSysId,
'AgencySysId' => $AgencySysId,
'XRefItemSysId' => (int) $ItemSysId,
'IsMarkForDelete' => 0,
'IsActive' => 1,
'IsSaleStart' => 1,
'BookingType' => 0,
];
//echo $strFromDate.'-'.$strToDate."<pre>";print_r($insert);die;
if (isset($SessionRoomFromToDateArray[$sessionKey][$RoomTypeId][$strFromDate . '-' . $strToDate]) && !empty($SessionRoomFromToDateArray[$sessionKey][$RoomTypeId][$strFromDate . '-' . $strToDate])) {
$id = $SessionRoomFromToDateArray[$sessionKey][$RoomTypeId][$strFromDate . '-' . $strToDate]['id'];
} else {
$this->db->insert('Tb_MP_Accomdation_Room_Inventory', $insert);
$id = $this->db->lastInsertId();
}
$addHotelData = array(
"AgencySysId" => (int) $AgencySysId,
"WeekendDefine" => $weekend,
"MealPlanType" => (int) $meal_plan_type,
"MarkType" => 1,
"B2CMarkup" => (float) $b2c_markup,
"B2BMarkup" => (float) $b2b_markup,
"SOccupCost" => ($sg_net_wd != 'NULL') ? $sg_net_wd : NULL,
"NetSOccupCost" => ($sg_net_wd != 'NULL') ? $sg_net_wd : NULL,
"IsTaxOnSOccupCost" => '0',
"TaxSOccupCost" => '0',
"DOccupCost" => $db_net_wd,
"NetDOccupCost" => $db_net_wd,
"IsTaxOnDOccupCost" => '0',
"TaxDOccupCost" => '0',
"ExtraBedCost" => ($ex_wbed_net_wd != 'NULL') ? $ex_wbed_net_wd : NULL,
"NetExtraBedCost" => ($ex_wbed_net_wd != 'NULL') ? $ex_wbed_net_wd : NULL,
"IsTaxOnExtraBedCost" => '0',
"TaxExtraBedCost" => '0',
"TriOccupCost" => ($tri_net_wd != 'NULL') ? $tri_net_wd : NULL,
"NetTriOccupCost" => ($tri_net_wd != 'NULL') ? $tri_net_wd : NULL,
"IsTaxOnTriOccupCost" => '0',
"TaxTriOccupCost" => '0',
"ChildAgeLimit" => $age_paid,
"ExtraWOBedCost" => ($chpaid_net_wd != 'NULL') ? $chpaid_net_wd : NULL,
"NetExtraWOBedCost" => ($chpaid_net_wd != 'NULL') ? $chpaid_net_wd : NULL,
"IsTaxOnExtraWOBedCost" => '0',
"TaxExtraWOBedCost" => '0',
"RateType" => $NetRateType,
"RackCommissionType" => $RRType,
"RackCommission" => $RackCommission,
"UpdatedDate" => $currentDate,
"CreatedDate" => $currentDate,
"XRefAccoSysId" => (int) $AccomSysId,
"RoomInventorySysId" => (int) $id,
"XRefItemSysId" => (int) $ItemSysId,
"TrxCurrency" => $CurrencyType,
"SupplierSysId" => $SupplierSysId,
"IsAllowMarkupSO" => $check_markup_sg,
"IsAllowMarkupDO" => $check_markup_db,
"IsAllowMarkupTO" => $check_markup_tri,
"IsAllowMarkupEB" => $check_markup_ex,
"IsAllowMarkupWOB" => $check_markup_chpaid,
"IsActive" => 1,
"IsMarkForDelete" => 0,
"WkSOccupCost" => ($sg_net_wk != 'NULL') ? $sg_net_wk : NULL,
"WkNetSOccupCost" => ($sg_net_wk != 'NULL') ? $sg_net_wk : NULL,
"WkDOccupCost" => $db_net_wk,
"WkNetDOccupCost" => $db_net_wk,
"WkExtraBedCost" => ($ex_wbed_net_wk != 'NULL') ? $ex_wbed_net_wk : NULL,
"WkNetExtraBedCost" => ($ex_wbed_net_wk != 'NULL') ? $ex_wbed_net_wk : NULL,
"WkTriOccupCost" => ($tri_net_wk != 'NULL') ? $tri_net_wk : NULL,
"WkNetTriOccupCost" => ($tri_net_wk != 'NULL') ? $tri_net_wk : NULL,
"WkExtraWOBedCost" => ($chpaid_net_wk != 'NULL') ? $chpaid_net_wk : NULL,
"WkNetExtraWOBedCost" => ($chpaid_net_wk != 'NULL') ? $chpaid_net_wk : NULL,
);
try {
$this->db->insert('TB_MP_Inventory_Accom', $addHotelData);
} catch (Exception $ex) {
die($ex->getMessage());
}
}
}
}
$UpdateHotelData = array('UpdateDate' => $currentDate);
$whereH = array('AccomSysId =?' => $AccomSysId);
$this->db->update('TB_IC_Accomdation', $UpdateHotelData, $whereH);
$response = array('status' => true, 'AccomSysId' => $AccomSysId, 'IsExistSessionKey' => $IsExistSessionKey, 'SessionKey' => $sessionKey, 'message' => 'Date Updated Successfully.');
echo json_encode($response);
exit;
}
} else {
$response = array('status' => false, 'message' => 'Room Id / Meal Id Missing.');
echo json_encode($response);
exit;
}
} else {
$response = array('status' => false, 'message' => 'Please select Room.');
}
echo json_encode($response);
exit;
}
}
public function getHotelInventoryRateByDataAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$response = array('status' => false);
$costhtml = '';
$MealPlanOrder = array(
9 => 0,
6 => 1,
7 => 2,
8 => 3,
3 => 4,
);
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
$AccomSysId = isset($post['AccomSysId']) ? (int) $post['AccomSysId'] : 0;
$SessionKey = isset($post['SessionKey']) ? trim($post['SessionKey']) : '';
$IsExistSessionKey = isset($post['IsExistSessionKey']) ? trim($post['IsExistSessionKey']) : 0;
if ($AccomSysId > 0 && $SessionKey != '') {
$HotelrateCardByAgListByHotelNew = $objAccoModel->HotelrateCardByAgListByHotelOptimizedNew($AgencySysId, $AccomSysId, 'all', '', array(), 1);
$RoomInventory = (!empty($HotelrateCardByAgListByHotelNew[0]['RoomInventory'])) ? json_decode($HotelrateCardByAgListByHotelNew[0]['RoomInventory'], 1) : array();
$RoomInventoryArray = $RoomInventoryArrayFin = $CheckSeasionWiseDate = array();
foreach ($RoomInventory as $riKey => $riValue) {
$FromToDate = $riValue['FromDate'].'-'.$riValue['ToDate'];
$checkStr = $riValue['XRateSessionKey'] . '-' . $riValue['RoomSysId'] . '-' . $riValue['MealPlanType'];
if ($HotelrateCardByAgListByHotelNew[0]['HotelRateType'] == 1) {
if (isset($RoomInventoryArray[$checkStr])) {
$dt = date('D', strtotime($riValue['FromDate']));
$weekends = (!empty($riValue['WeekendDefine'])) ? explode(',', $riValue['WeekendDefine']) : array();
if (in_array($dt, $weekends)) {
$RoomInventoryArray[$checkStr]['WkNetSOccupCost'] = $riValue['NetSOccupCost'];
$RoomInventoryArray[$checkStr]['WkNetDOccupCost'] = $riValue['NetDOccupCost'];
$RoomInventoryArray[$checkStr]['WkNetTriOccupCost'] = $riValue['NetTriOccupCost'];
$RoomInventoryArray[$checkStr]['WkNetExtraBedCost'] = $riValue['NetExtraBedCost'];
$RoomInventoryArray[$checkStr]['WkNetExtraWOBedCost'] = $riValue['NetExtraWOBedCost'];
}
} else {
$riValue['WkNetSOccupCost'] = $riValue['NetSOccupCost'];
$riValue['WkNetDOccupCost'] = $riValue['NetDOccupCost'];
$riValue['WkNetTriOccupCost'] = $riValue['NetTriOccupCost'];
$riValue['WkNetExtraBedCost'] = $riValue['NetExtraBedCost'];
$riValue['WkNetExtraWOBedCost'] = $riValue['NetExtraWOBedCost'];
$RoomInventoryArray[$checkStr] = $riValue;
}
} else {
$RoomInventoryArray[$checkStr] = $riValue;
}
$RoomInventoryArrayFin[$FromToDate][$riValue['XRefItemSysId']][$MealPlanOrder[$riValue['MealPlanType']]] = $RoomInventoryArray[$checkStr];
$FromDateSTR = strtotime($riValue['FromDate']);
if (!isset($CheckSeasionWiseDate[$FromToDate]) || $CheckSeasionWiseDate[$riValue['XRateSessionKey']] > $FromDateSTR) {
$XRateSessionKeyFinDates[$FromToDate]['Dates'] = array(
'FromDate' => date('d-M-Y', strtotime($riValue['FromDate'])),
'ToDate' => date('d-M-Y', strtotime($riValue['ToDate']))
);
if ((int) $riValue['IsPromotionalRate'] == 1) {
$XRateSessionKeyFinDates[$FromToDate]['BookingDates'] = array(
'FromDate' => date('d-M-Y', strtotime($riValue['FromBookingDate'])),
'ToDate' => date('d-M-Y', strtotime($riValue['ToBookingDate'])),
'IsNight' => (int) $riValue['IsNight'],
'MinNight' => (int) $riValue['MinNight'],
'MaxNight' => (int) $riValue['MaxNight'],
'IsMinRoom' => (int) $riValue['IsMinRoom'],
'MinRoom' => (int) $riValue['MinRoom'],
);
}
}
$CheckSeasionWiseDate[$FromToDate] = $FromDateSTR;
$XRateSessionKeyFinDates[$FromToDate]['Room'][$riValue['XRefItemSysId']] = $riValue['RoomName'];
}
foreach ($RoomInventoryArrayFin as $riafKey => $riafValue) {
$SessionClassStr = $AccomSysId . '_' . $riafKey;
$costhtml .= '<tr class="hotelname_room_meal_tr_ hotelname_session_row_' . $SessionClassStr . '">
<td colspan="2" style="width:12.8%;" >
<input type="hidden" name="FromDateDMY" class="form-control" id="FromDateDMY_' . $SessionClassStr . '" value="' . date('d/m/Y', strtotime($XRateSessionKeyFinDates[$riafKey]['Dates']['FromDate'])) . '">
<input type="hidden" name="ToDateDMY" class="form-control" id="ToDateDMY_' . $SessionClassStr . '" value="' . date('d/m/Y', strtotime($XRateSessionKeyFinDates[$riafKey]['Dates']['ToDate'])) . '">
<div>' . date('d-M-Y', strtotime($XRateSessionKeyFinDates[$riafKey]['Dates']['FromDate'])) .
' - ' . date('d-M-Y', strtotime($XRateSessionKeyFinDates[$riafKey]['Dates']['ToDate'])) .
'</div>';
if ($XRateSessionKeyFinDates[$riafKey]['BookingDates']['FromDate'] && $XRateSessionKeyFinDates[$riafKey]['BookingDates']['ToDate']) {
$costhtml .= '<br><div style="font-weight: 700;">
<span style="">Promotion Rates:- </span><br>
From: ' . date('d-M-Y', strtotime($XRateSessionKeyFinDates[$riafKey]['BookingDates']['FromDate'])) . '
<br>To:' . date('d-M-Y', strtotime($XRateSessionKeyFinDates[$riafKey]['BookingDates']['ToDate']));
if (isset($XRateSessionKeyFinDates[$riafKey]['BookingDates']['IsNight']) && $XRateSessionKeyFinDates[$riafKey]['BookingDates']['IsNight'] == 1) {
$MinNightSh = $XRateSessionKeyFinDates[$riafKey]['BookingDates']['MinNight'];
$MaxNightSh = $XRateSessionKeyFinDates[$riafKey]['BookingDates']['MaxNight'];
$costhtml .= '<br>Night: (Min: ' . $MinNightSh . ' - Max: ' . $MaxNightSh . ')';
}
if (isset($XRateSessionKeyFinDates[$riafKey]['BookingDates']['IsMinRoom']) && $XRateSessionKeyFinDates[$riafKey]['BookingDates']['IsMinRoom'] == 1) {
$MinRoomSh = $XRateSessionKeyFinDates[$riafKey]['BookingDates']['MinRoom'];
$costhtml .= '<br>Room: (Min: ' . $MinRoomSh . ')';
}
$costhtml .= '</div>';
}
$costhtml .= '</td>
<td style="padding:0;margin:0;" colspan="15" class="room_table_classPre">
<table class="room_table_class table " style="padding:0;margin:0;width: 100%;border-collapse: collapse;table-layout: fixed;"><tbody class="hotelname_session_body_' . $SessionClassStr . '">';
ksort($riafValue);
foreach ($riafValue as $riafKey1 => $riafValue1) {
$SessionRoomClassStr = $AccomSysId . '_' . $riafKey . '_' . $riafKey1;
$costhtml .= '<tr class="hotelname_session_room_row_' . $SessionRoomClassStr . '"><td style="width:10.2%;border: 0px !important;" ><div>' . trim($XRateSessionKeyFinDates[$riafKey]['Room'][$riafKey1]) . '</div></td>'
. '<td colspan="15" style="padding:0;margin:0;" class="room_table_classPre"><table class="room_table_class table " style="padding:0;margin:0;width: 100%;border-collapse: collapse;table-layout: fixed;"><tbody class="hotelname_session_room_body_' . $SessionRoomClassStr . '">';
ksort($riafValue1);
foreach ($riafValue1 as $riamKey => $riamValue) {
$XRefItemSysId = $riamValue['XRefItemSysId'];
$XRateSessionKey = $riamValue['XRateSessionKey'];
$RoomSysId = $riamValue['RoomSysId'];
$MealPlanType = $riamValue['MealPlanType'];
$FromDate = date('d-M-Y', strtotime($riamValue['FromDate']));
$ToDate = date('d-M-Y', strtotime($riamValue['ToDate']));
$IsActiveRate = (int) $riamValue['IsActiveRate'];
$ratecardurl = $this->baseUrl . 'accommodation/rate-card/id/' . $riamValue['AccomSysId'] . '/SessionKey/' . (!empty($riamValue['XRateSessionKey']) ? trim($riamValue['XRateSessionKey']) : '') . '#preview_pre';
$SessionClassStr = $AccomSysId . '_' . $XRateSessionKey;
$ClassStr = $AccomSysId . '_' . $XRateSessionKey . '_' . $RoomSysId . '_' . $MealPlanType;
$costhtml .= '<tr class="hotelname_room_meal_tr_' . $ClassStr . '" >
<td style="width:6%;border-left:none !important"><input type="hidden" id="ThisDateRange_'.$AccomSysId.'_'.$XRateSessionKey.'" value="'.$riafKey.'">' . trim($riamValue["MealPlanTitle"]) . '</td>
<td style="width:3.8%;">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="B2BMarkup" class="form-control" id="B2BMarkup_' . $ClassStr . '" value="' . (float) $riamValue["B2BMarkup"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["B2BMarkup"] . '</div>
</td>
<td style="width:3.7%;">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="B2CMarkup" class="form-control" id="B2CMarkup_' . $ClassStr . '" value="' . (float) $riamValue["B2CMarkup"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["B2CMarkup"] . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetSOccupCost" class="form-control" id="NetSOccupCost_' . $ClassStr . '" value="' . ($riamValue["NetSOccupCost"] != '' ? (float) $riamValue["NetSOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetSOccupCost"] != '' ? (float) $riamValue["NetSOccupCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetSOccupCost" class="form-control" id="WkNetSOccupCost_' . $ClassStr . '" value="' . ($riamValue["WkNetSOccupCost"] != '' ? (float) $riamValue["WkNetSOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetSOccupCost"] != '' ? (float) $riamValue["WkNetSOccupCost"] : '') . '</div>
</td>
<td style="width:7%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetDOccupCost" class="form-control" id="NetDOccupCost_' . $ClassStr . '" value="' . ($riamValue["NetDOccupCost"] != '' ? (float) $riamValue["NetDOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetDOccupCost"] != '' ? (float) $riamValue["NetDOccupCost"] : '') . '</div>
</td>
<td style="width:7%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetDOccupCost" class="form-control" id="WkNetDOccupCost_' . $ClassStr . '" value="' . ($riamValue["WkNetDOccupCost"] != '' ? (float) $riamValue["WkNetDOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetDOccupCost"] != '' ? (float) $riamValue["WkNetDOccupCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetExtraBedCost" class="form-control" id="NetExtraBedCost_' . $ClassStr . '" value="' . ($riamValue["NetExtraBedCost"] != '' ? (float) $riamValue["NetExtraBedCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetExtraBedCost"] != '' ? (float) $riamValue["NetExtraBedCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetExtraBedCost" class="form-control" id="WkNetExtraBedCost_' . $ClassStr . '" value="' . ($riamValue["WkNetExtraBedCost"] != '' ? (float) $riamValue["WkNetExtraBedCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetExtraBedCost"] != '' ? (float) $riamValue["WkNetExtraBedCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetTriOccupCost" class="form-control" id="NetTriOccupCost_' . $ClassStr . '" value="' . ($riamValue["NetTriOccupCost"] != '' ? (float) $riamValue["NetTriOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetTriOccupCost"] != '' ? (float) $riamValue["NetTriOccupCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetTriOccupCost" class="form-control" id="WkNetTriOccupCost_' . $ClassStr . '" value="' . ($riamValue["WkNetTriOccupCost"] != '' ? (float) $riamValue["WkNetTriOccupCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetTriOccupCost"] != '' ? (float) $riamValue["WkNetTriOccupCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetExtraWOBedCost" class="form-control" id="NetExtraWOBedCost_' . $ClassStr . '" value="' . ($riamValue["NetExtraWOBedCost"] != '' ? (float) $riamValue["NetExtraWOBedCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["NetExtraWOBedCost"] != '' ? (float) $riamValue["NetExtraWOBedCost"] : '') . '</div>
</td>
<td style="width:6.2%">
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetExtraWOBedCost" class="form-control" id="WkNetExtraWOBedCost_' . $ClassStr . '" value="' . ($riamValue["WkNetExtraWOBedCost"] != '' ? (float) $riamValue["WkNetExtraWOBedCost"] : '') . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . ($riamValue["WkNetExtraWOBedCost"] != '' ? (float) $riamValue["WkNetExtraWOBedCost"] : '') . '</div>
</td>
<td style="width:10.8%;padding-bottom:0px;" class="hotelname_room_meal_action_rd_' . $ClassStr . '">
<input type="hidden" value="' . $IsActiveRate . '" class="HotelRateStatus_' . $ClassStr . '">
<div class="allActionRateDiv_' . $ClassStr . '">';
if ($XRateSessionKeyFinDates[$riafKey]['BookingDates']['FromDate']) {
$PromotionsSysId = (int) $riamValue['PromotionsSysId'];
$costhtml .= '<a href="/accommodation/add-hotels/id/' . ((int) $AccomSysId) . '#!/addupdatepromotion/' . $PromotionsSysId . '" target="_blank" class="view_text1 tooltipLink"><i class="fa fa-pencil-square-o"></i></a>';
} else {
$costhtml .= '<a href="javascript://" class="view_text1 tooltipLink" onclick="updateHotelRates(\'copy\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')"><i class="fa fa-copy"></i></a>
<a href="javascript://" class="view_text1 tooltipLink" onclick="updateHotelRates(\'modify\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')"><i class="fa fa-pencil-square-o"></i></a>
<a href="javascript://" class="view_text1 tooltipLink HotelRateStatusIcon_' . $ClassStr . '" title="' . ($riamValue['IsActiveRate'] == 1 ? 'Deactivate' : 'Activate') . '" onclick="updateHotelRates(\'status\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')">';
if ($riamValue['IsActiveRate'] == 1) {
$costhtml .= '<i class="fa fa-times"></i>';
} else {
$costhtml .= '<i class="fa fa-check-circle-o"></i>';
}
$costhtml .= '</a>
<a href="javascript://" class="view_text1 tooltipLink" onclick="updateHotelRates(\'delete\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')"><i class="fa fa-minus-circle"></i></a>';
}
$costhtml .= '</div>
<div class="hide-div-class modifyRateDiv_' . $ClassStr . '">
<a class="btn btn-primary UpdateupdateHotelRatesBtn' . $ClassStr . '" onclick="updateHotelRates(\'update\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')">Update</a>
<a class="btn btn-primarygray pull-right cancelUpdateHotelRateBtn' . $ClassStr . '" onclick="cancelUpdateHotelRate(\'' . $ClassStr . '\')" title="Cancel"><i class="fa fa-close"></i></a>
</div>
<span class="hotelname_room_meal_action_rd_span_' . $ClassStr . '" style="height: 16px;width: 100%;display: block;"></span>
</td>
</tr>';
}
$costhtml .= '</tbody></table></td></tr> ';
}
$costhtml .= '</tbody></table></td></tr> ';
}
echo $costhtml;
exit;
}
}
echo $costhtml;
exit;
}
public function getHotelInventoryRateByDataBackupAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$response = array('status' => false);
$costhtml = '';
$MealPlanOrder = array(
9 => 0,
6 => 1,
7 => 2,
8 => 3,
3 => 4,
);
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
$AccomSysId = isset($post['AccomSysId']) ? (int) $post['AccomSysId'] : 0;
$SessionKey = isset($post['SessionKey']) ? trim($post['SessionKey']) : '';
if ($AccomSysId > 0 && $SessionKey != '') {
$HotelrateCardByAgListByHotelNew = $objAccoModel->HotelrateCardByAgListByHotelOptimizedNew($AgencySysId, $AccomSysId, 'all', $SessionKey);
$RoomInventory = (!empty($HotelrateCardByAgListByHotelNew[0]['RoomInventory'])) ? json_decode($HotelrateCardByAgListByHotelNew[0]['RoomInventory'], 1) : array();
$RoomInventoryArray = $RoomInventoryArrayFin = array();
foreach ($RoomInventory as $riKey => $riValue) {
$checkRoomStr = $riValue['XRateSessionKey'] . '-' . $riValue['XRefItemSysId'];
$checkStr = $riValue['XRateSessionKey'] . '-' . $riValue['RoomSysId'] . '-' . $riValue['MealPlanType'];
if ($HotelrateCardByAgListByHotelNew[0]['HotelRateType'] == 1) {
if (isset($RoomInventoryArray[$checkStr])) {
$dt = date('D', strtotime($riValue['FromDate']));
$weekends = (!empty($riValue['WeekendDefine'])) ? explode(',', $riValue['WeekendDefine']) : array();
if (in_array($dt, $weekends)) {
$RoomInventoryArray[$checkStr]['WkNetSOccupCost'] = $riValue['NetSOccupCost'];
$RoomInventoryArray[$checkStr]['WkNetDOccupCost'] = $riValue['NetDOccupCost'];
$RoomInventoryArray[$checkStr]['WkNetTriOccupCost'] = $riValue['NetTriOccupCost'];
$RoomInventoryArray[$checkStr]['WkNetExtraBedCost'] = $riValue['NetExtraBedCost'];
$RoomInventoryArray[$checkStr]['WkNetExtraWOBedCost'] = $riValue['NetExtraWOBedCost'];
}
} else {
$riValue['WkNetSOccupCost'] = $riValue['NetSOccupCost'];
$riValue['WkNetDOccupCost'] = $riValue['NetDOccupCost'];
$riValue['WkNetTriOccupCost'] = $riValue['NetTriOccupCost'];
$riValue['WkNetExtraBedCost'] = $riValue['NetExtraBedCost'];
$riValue['WkNetExtraWOBedCost'] = $riValue['NetExtraWOBedCost'];
$RoomInventoryArray[$checkStr] = $riValue;
}
} else {
$RoomInventoryArray[$checkStr] = $riValue;
}
$RoomInventoryArrayFin[$checkRoomStr][$MealPlanOrder[$riValue['MealPlanType']]] = $RoomInventoryArray[$checkStr];
}
foreach ($RoomInventoryArrayFin as $riafKey => $riafValue) {
ksort($riafValue);
foreach ($riafValue as $riamKey => $riamValue) {
$XRefItemSysId = $riamValue['XRefItemSysId'];
$XRateSessionKey = $riamValue['XRateSessionKey'];
$RoomSysId = $riamValue['RoomSysId'];
$MealPlanType = $riamValue['MealPlanType'];
$FromDate = date('d-M-Y', strtotime($riamValue['FromDate']));
$ToDate = date('d-M-Y', strtotime($riamValue['ToDate']));
$IsActiveRate = (int) $riamValue['IsActiveRate'];
$ratecardurl = $this->baseUrl . 'accommodation/rate-card/id/' . $riamValue['AccomSysId'] . '/SessionKey/' . (!empty($riamValue['XRateSessionKey']) ? trim($riamValue['XRateSessionKey']) : '') . '#preview_pre';
$ClassStr = $AccomSysId . '_' . $XRateSessionKey . '_' . $RoomSysId . '_' . $MealPlanType;
$costhtml .= '<tr class="hotelname_room_meal_tr_' . $ClassStr . '">
<td>' . $FromDate . '</td>
<td>' . $ToDate . '</td>
<td>' . trim($riamValue["RoomName"]) . '</td>
<td>' . trim($riamValue["MealPlanTitle"]) . '</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="B2BMarkup" class="form-control" id="B2BMarkup_' . $ClassStr . '" value="' . (float) $riamValue["B2BMarkup"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["B2BMarkup"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="B2CMarkup" class="form-control" id="B2CMarkup_' . $ClassStr . '" value="' . (float) $riamValue["B2CMarkup"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["B2CMarkup"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetSOccupCost" class="form-control" id="NetSOccupCost_' . $ClassStr . '" value="' . (float) $riamValue["NetSOccupCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["NetSOccupCost"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetSOccupCost" class="form-control" id="WkNetSOccupCost_' . $ClassStr . '" value="' . (float) $riamValue["WkNetSOccupCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["WkNetSOccupCost"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetDOccupCost" class="form-control" id="NetDOccupCost_' . $ClassStr . '" value="' . (float) $riamValue["NetDOccupCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["NetDOccupCost"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetDOccupCost" class="form-control" id="WkNetDOccupCost_' . $ClassStr . '" value="' . (float) $riamValue["WkNetDOccupCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["WkNetDOccupCost"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetExtraBedCost" class="form-control" id="NetExtraBedCost_' . $ClassStr . '" value="' . (float) $riamValue["NetExtraBedCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["NetExtraBedCost"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetExtraBedCost" class="form-control" id="WkNetExtraBedCost_' . $ClassStr . '" value="' . (float) $riamValue["WkNetExtraBedCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["WkNetExtraBedCost"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetTriOccupCost" class="form-control" id="NetTriOccupCost_' . $ClassStr . '" value="' . (float) $riamValue["NetTriOccupCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["NetTriOccupCost"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetTriOccupCost" class="form-control" id="WkNetTriOccupCost_' . $ClassStr . '" value="' . (float) $riamValue["WkNetTriOccupCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["WkNetTriOccupCost"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="NetExtraWOBedCost" class="form-control" id="NetExtraWOBedCost_' . $ClassStr . '" value="' . (float) $riamValue["NetExtraWOBedCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["NetExtraWOBedCost"] . '</div>
</td>
<td>
<div class="rate-div-input' . $ClassStr . ' hide-div-class"><input type="text" name="WkNetExtraWOBedCost" class="form-control" id="WkNetExtraWOBedCost_' . $ClassStr . '" value="' . (float) $riamValue["WkNetExtraWOBedCost"] . '"></div>
<div class="rate-div-text' . $ClassStr . '">' . (float) $riamValue["WkNetExtraWOBedCost"] . '</div>
</td>
<td style="padding-bottom:0px;" class="hotelname_room_meal_action_rd_' . $ClassStr . '">
<input type="hidden" value="' . $IsActiveRate . '" class="HotelRateStatus_' . $ClassStr . '">
<div class="allActionRateDiv_' . $ClassStr . '">
<a href="javascript://" class="view_text1 tooltipLink" onclick="updateHotelRates(\'copy\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')"><i class="fa fa-copy"></i></a>
<a href="javascript://" class="view_text1 tooltipLink" onclick="updateHotelRates(\'modify\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')"><i class="fa fa-pencil-square-o"></i></a>
<a href="javascript://" class="view_text1 tooltipLink HotelRateStatusIcon_' . $ClassStr . '" title="' . ($riamValue['IsActiveRate'] == 1 ? 'Deactivate' : 'Activate') . '" onclick="updateHotelRates(\'status\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')">';
if ($riamValue['IsActiveRate'] == 1) {
$costhtml .= '<i class="fa fa-times"></i>';
} else {
$costhtml .= '<i class="fa fa-check-circle-o"></i>';
}
$costhtml .= '</a>
<a href="javascript://" class="view_text1 tooltipLink" onclick="updateHotelRates(\'delete\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')"><i class="fa fa-minus-circle"></i></a>
</div>
<div class="hide-div-class modifyRateDiv_' . $ClassStr . '">
<a class="btn btn-primary UpdateupdateHotelRatesBtn' . $ClassStr . '" onclick="updateHotelRates(\'update\',' . $AccomSysId . ',\'' . $XRateSessionKey . '\',' . $XRefItemSysId . ',' . $RoomSysId . ',' . $MealPlanType . ')">Update</a>
<a class="btn btn-primarygray pull-right cancelUpdateHotelRateBtn' . $ClassStr . '" onclick="cancelUpdateHotelRate(\'' . $ClassStr . '\')" title="Cancel"><i class="fa fa-close"></i></a>
</div>
<span class="hotelname_room_meal_action_rd_span_' . $ClassStr . '" style="height: 16px;width: 100%;display: block;"></span>
</td></tr>';
}
}
echo $costhtml;
exit;
}
}
echo $costhtml;
exit;
}
private function excelDateToPhpDate($excelValue) {
// If numeric → Excel serial date
if (is_numeric($excelValue)) {
$phpDate = PHPExcel_Shared_Date::ExcelToPHP($excelValue);
return date('Y-m-d', $phpDate);
}
// If already string date
return trim($excelValue);
}
private function excelDateToPhpDateDMY($excelValue) {
// If numeric → Excel serial date
if (is_numeric($excelValue)) {
$phpDate = PHPExcel_Shared_Date::ExcelToPHP($excelValue);
return date('d/m/Y', $phpDate);
}
// If already string date
return trim($excelValue);
}
public function copySplitSessionAndRatesExcel($post, $ranges, $intLoggedinUserAgencySysId, $AccomSysId, $XRateSessionKey, $ItemSysId, $RoomTypeId,$MealPlanType = 0) {
$objAccoModel = new Travel_Model_AccommodationModel();
$getRoomInventoryIdsRates = $objAccoModel->getRoomInventoryIdsRates($AccomSysId, $XRateSessionKey, $ItemSysId,$MealPlanType);
// echo "<pre>";print_r($getRoomInventoryIdsRates);die;
$PublishQty = $NetInHandQty = 0;
$currentDate = date("Y-m-d H:i:s");
if(!empty($getRoomInventoryIdsRates)){
foreach ($ranges as $key => $value) {
$InvnItemSysIdM = isset($value['InvnItemSysIdM']) ? (int)$value['InvnItemSysIdM'] : 0;
$sessionKey = $objAccoModel->getMaxXRateSessionKey();
$insert = [
'FromDate' => $value['start_date'],
'Todate' => $value['end_date'],
'XRateSessionKey' => $sessionKey,
'PublishQty' => $getRoomInventoryIdsRates[0]['PublishQty'],
'NetInHandQty' => $getRoomInventoryIdsRates[0]['NetInHandQty'],
'BlockQty' => $getRoomInventoryIdsRates[0]['BlockQty'],
'SoldQty' => $getRoomInventoryIdsRates[0]['SoldQty'],
'UpdatedDate' => $getRoomInventoryIdsRates[0]['UpdatedDate']->format('Y-m-d H:i:s'),
'CreatedDate' => $getRoomInventoryIdsRates[0]['CreatedDate']->format('Y-m-d H:i:s'),
'AccomSysId' => (int) $AccomSysId,
'RoomSysId' => (int) $getRoomInventoryIdsRates[0]['RoomSysId'],
'SupplierSysId' => (int) $getRoomInventoryIdsRates[0]['HotelSupplierSysId'],
'AgencySysId' => (int) $intLoggedinUserAgencySysId,
'XRefItemSysId' => (int) $ItemSysId,
'IsMarkForDelete' => 0,
'IsActive' => 1,
'IsSaleStart' => 1,
'BookingType' => 0,
];
$this->db->insert('Tb_MP_Accomdation_Room_Inventory', $insert);
$id = $this->db->lastInsertId();
foreach ($getRoomInventoryIdsRates as $riKey => $riValue) {
$getRoomInventoryIdsArray[] = $riValue['id'];
$InvnItemSysIdMArray[] = $riValue['InvnItemSysId'];
if($InvnItemSysIdM == $riValue['InvnItemSysId']){
$b2b_markup = isset($post['b2b_markup']) ? (float) $post['b2b_markup'] : 0;
$b2c_markup = isset($post['b2c_markup']) ? (float) $post['b2c_markup'] : 0;
$sg_net_wd = (isset($post['sg_net_wd']) && $post['sg_net_wd'] != '') ? (float) $post['sg_net_wd'] : 'NULL';
$sg_net_wk = (isset($post['sg_net_wk']) && $post['sg_net_wk'] != '') ? (float) $post['sg_net_wk'] : 'NULL';
$db_net_wd = (isset($post['db_net_wd']) && $post['db_net_wd'] != '') ? (float) $post['db_net_wd'] : 'NULL';
$db_net_wk = (isset($post['db_net_wk']) && $post['db_net_wk'] != '') ? (float) $post['db_net_wk'] : 'NULL';
$ex_wbed_net_wd = (isset($post['ex_wbed_net_wd']) && $post['ex_wbed_net_wd'] != '') ? (float) $post['ex_wbed_net_wd'] : 'NULL';
$ex_wbed_net_wk = (isset($post['ex_wbed_net_wk']) && $post['ex_wbed_net_wk'] != '') ? (float) $post['ex_wbed_net_wk'] : 'NULL';
$tri_net_wd = (isset($post['tri_net_wd']) && $post['tri_net_wd'] != '') ? (float) $post['tri_net_wd'] : 'NULL';
$tri_net_wk = (isset($post['tri_net_wk']) && $post['tri_net_wk'] != '') ? (float) $post['tri_net_wk'] : 'NULL';
$chpaid_net_wd = (isset($post['chpaid_net_wd']) && $post['chpaid_net_wd'] != '') ? (float) $post['chpaid_net_wd'] : 'NULL';
$chpaid_net_wk = (isset($post['chpaid_net_wk']) && $post['chpaid_net_wk'] != '') ? (float) $post['chpaid_net_wk'] : 'NULL';
$age_paid = 7;
$RRType = 0;
$check_markup_sg = $check_markup_db = $check_markup_tri = $check_markup_ex = $check_markup_chpaid = 1;
$PublishQty = $NetInHandQty = 10;
$addHotelData = array(
"AgencySysId" => (int) $intLoggedinUserAgencySysId,
"WeekendDefine" => $riValue['WeekendDefine'],
"MealPlanType" => (int) $riValue['MealPlanType'],
"MarkType" => $riValue['MarkType'],
"B2CMarkup" => (float) $b2c_markup,
"B2BMarkup" => (float) $b2b_markup,
"SOccupCost" => ($sg_net_wd != 'NULL') ? $sg_net_wd : NULL,
"NetSOccupCost" => ($sg_net_wd != 'NULL') ? $sg_net_wd : NULL,
"IsTaxOnSOccupCost" => '0',
"TaxSOccupCost" => '0',
"DOccupCost" => $db_net_wd,
"NetDOccupCost" => $db_net_wd,
"IsTaxOnDOccupCost" => '0',
"TaxDOccupCost" => '0',
"ExtraBedCost" => ($ex_wbed_net_wd != 'NULL') ? $ex_wbed_net_wd : NULL,
"NetExtraBedCost" => ($ex_wbed_net_wd != 'NULL') ? $ex_wbed_net_wd : NULL,
"IsTaxOnExtraBedCost" => '0',
"TaxExtraBedCost" => '0',
"TriOccupCost" => ($tri_net_wd != 'NULL') ? $tri_net_wd : NULL,
"NetTriOccupCost" => ($tri_net_wd != 'NULL') ? $tri_net_wd : NULL,
"IsTaxOnTriOccupCost" => '0',
"TaxTriOccupCost" => '0',
"ChildAgeLimit" => $age_paid,
"ExtraWOBedCost" => ($chpaid_net_wd != 'NULL') ? $chpaid_net_wd : NULL,
"NetExtraWOBedCost" => ($chpaid_net_wd != 'NULL') ? $chpaid_net_wd : NULL,
"IsTaxOnExtraWOBedCost" => '0',
"TaxExtraWOBedCost" => '0',
"RateType" => $riValue['RateType'],
"RackCommissionType" => $riValue['RackCommissionType'],
"RackCommission" => $riValue['RackCommission'],
"UpdatedDate" => $currentDate,
"CreatedDate" => $currentDate,
"XRefAccoSysId" => (int) $AccomSysId,
"RoomInventorySysId" => (int) $id,
"XRefItemSysId" => (int) $ItemSysId,
"TrxCurrency" => $riValue['TrxCurrency'],
"SupplierSysId" => $riValue['SupplierSysId'],
"IsAllowMarkupSO" => $check_markup_sg,
"IsAllowMarkupDO" => $check_markup_db,
"IsAllowMarkupTO" => $check_markup_tri,
"IsAllowMarkupEB" => $check_markup_ex,
"IsAllowMarkupWOB" => $check_markup_chpaid,
"IsActive" => 1,
"IsMarkForDelete" => 0,
"WkSOccupCost" => ($sg_net_wk != 'NULL') ? $sg_net_wk : NULL,
"WkNetSOccupCost" => ($sg_net_wk != 'NULL') ? $sg_net_wk : NULL,
"WkDOccupCost" => $db_net_wk,
"WkNetDOccupCost" => $db_net_wk,
"WkExtraBedCost" => ($ex_wbed_net_wk != 'NULL') ? $ex_wbed_net_wk : NULL,
"WkNetExtraBedCost" => ($ex_wbed_net_wk != 'NULL') ? $ex_wbed_net_wk : NULL,
"WkTriOccupCost" => ($tri_net_wk != 'NULL') ? $tri_net_wk : NULL,
"WkNetTriOccupCost" => ($tri_net_wk != 'NULL') ? $tri_net_wk : NULL,
"WkExtraWOBedCost" => ($chpaid_net_wk != 'NULL') ? $chpaid_net_wk : NULL,
"WkNetExtraWOBedCost" => ($chpaid_net_wk != 'NULL') ? $chpaid_net_wk : NULL,
"RateSource" => 1,
);
}else{
$addHotelData = array(
"AgencySysId" => (int) $intLoggedinUserAgencySysId,
"WeekendDefine" => $riValue['WeekendDefine'],
"MealPlanType" => (int) $riValue['MealPlanType'],
"MarkType" => $riValue['MarkType'],
"B2CMarkup" => (float) $riValue['B2CMarkup'],
"B2BMarkup" => (float) $riValue['B2BMarkup'],
"SOccupCost" => $riValue['SOccupCost'],
"NetSOccupCost" => $riValue['NetSOccupCost'],
"IsTaxOnSOccupCost" => $riValue['IsTaxOnSOccupCost'],
"TaxSOccupCost" => $riValue['TaxSOccupCost'],
"DOccupCost" => $riValue['DOccupCost'],
"NetDOccupCost" => $riValue['NetDOccupCost'],
"IsTaxOnDOccupCost" => $riValue['IsTaxOnDOccupCost'],
"TaxDOccupCost" => $riValue['TaxDOccupCost'],
"ExtraBedCost" => $riValue['ExtraBedCost'],
"NetExtraBedCost" => $riValue['NetExtraBedCost'],
"IsTaxOnExtraBedCost" => $riValue['IsTaxOnExtraBedCost'],
"TaxExtraBedCost" => $riValue['TaxExtraBedCost'],
"TriOccupCost" => $riValue['TriOccupCost'],
"NetTriOccupCost" => $riValue['NetTriOccupCost'],
"IsTaxOnTriOccupCost" => $riValue['IsTaxOnTriOccupCost'],
"TaxTriOccupCost" => $riValue['TaxTriOccupCost'],
"ChildAgeLimit" => $riValue['ChildAgeLimit'],
"ExtraWOBedCost" => $riValue['ExtraWOBedCost'],
"NetExtraWOBedCost" => $riValue['NetExtraWOBedCost'],
"IsTaxOnExtraWOBedCost" => $riValue['IsTaxOnExtraWOBedCost'],
"TaxExtraWOBedCost" => $riValue['TaxExtraWOBedCost'],
"RateType" => $riValue['RateType'],
"RackCommissionType" => $riValue['RackCommissionType'],
"RackCommission" => $riValue['RackCommission'],
"UpdatedDate" => $riValue['UpdatedDate']->format('Y-m-d H:i:s'),
"CreatedDate" => $riValue['CreatedDate']->format('Y-m-d H:i:s'),
"XRefAccoSysId" => (int) $AccomSysId,
"RoomInventorySysId" => (int) $id,
"XRefItemSysId" => (int) $riValue['XRefItemSysId'],
"TrxCurrency" => $riValue['TrxCurrency'],
"SupplierSysId" => $riValue['SupplierSysId'],
"IsAllowMarkupSO" => $riValue['IsAllowMarkupSO'],
"IsAllowMarkupDO" => $riValue['IsAllowMarkupDO'],
"IsAllowMarkupTO" => $riValue['IsAllowMarkupTO'],
"IsAllowMarkupEB" => $riValue['IsAllowMarkupEB'],
"IsAllowMarkupWOB" => $riValue['IsAllowMarkupWOB'],
"IsActive" => 1,
"IsMarkForDelete" => 0,
"WkSOccupCost" => $riValue['WkSOccupCost'],
"WkNetSOccupCost" => $riValue['WkNetSOccupCost'],
"WkDOccupCost" => $riValue['WkDOccupCost'],
"WkNetDOccupCost" => $riValue['WkNetDOccupCost'],
"WkExtraBedCost" => $riValue['WkExtraBedCost'],
"WkNetExtraBedCost" => $riValue['WkNetExtraBedCost'],
"WkTriOccupCost" => $riValue['WkTriOccupCost'],
"WkNetTriOccupCost" => $riValue['WkNetTriOccupCost'],
"WkExtraWOBedCost" => $riValue['WkExtraWOBedCost'],
"WkNetExtraWOBedCost" => $riValue['WkNetExtraWOBedCost'],
);
}
try {
$this->db->insert('TB_MP_Inventory_Accom', $addHotelData);
} catch (Exception $ex) {
die($ex->getMessage());
}
}
$whereIn = array('AccomSysId =?' => $AccomSysId, 'XRateSessionKey =?' => $XRateSessionKey, 'XRefItemSysId =?' => $ItemSysId);
$whereIn_acc = array(
'XRefAccoSysId =?' => $AccomSysId,
'XRefItemSysId =? ' => $ItemSysId,
'InvnItemSysId IN (?) ' => $InvnItemSysIdMArray,
// 'RoomInventorySysId IN (?) ' => $getRoomInventoryIdsArray,
);
$update_im = array('IsMarkForDelete' => 1, 'IsActive' => 0, 'UpdatedDate' => $currentDate);
//$this->db->update('Tb_MP_Accomdation_Room_Inventory', $update_im, $whereIn);
$this->db->update('TB_MP_Inventory_Accom', $update_im, $whereIn_acc);
}
}
return true;
}
public function saveHotelRatesExcelAction($postData = array()) {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$response = array('status' => false);
$IsReturn = (!empty($postData)) ? 1 : 0;
if ($this->getRequest()->isPost() || !empty($postData)) {
$inputData = file_get_contents("php://input");
$post = json_decode($inputData, true);
if(!empty($postData)){
$post = $postData;
}
$AccomSysId = isset($post['NewAccomSysId']) ? (int) $post['NewAccomSysId'] : 0;
$from_date = isset($post['from_date']) ? $post['from_date'] : '';
$to_date = isset($post['to_date']) ? $post['to_date'] : '';
if (empty($from_date) || empty($to_date)) {
$response = array('status' => false, 'message' => 'Please select from and to date!!');
if($IsReturn == 1){
return $response;
}else{
echo json_encode($response);exit;
}
}
$room_type = isset($post['room_type']) ? $post['room_type'] : '';
$meal_plan_type = isset($post['meal_plan_type']) ? (int) $post['meal_plan_type'] : 0;
$b2b_markup = isset($post['b2b_markup']) ? (float) $post['b2b_markup'] : 0;
$b2c_markup = isset($post['b2c_markup']) ? (float) $post['b2c_markup'] : 0;
$sg_net_wd = (isset($post['sg_net_wd']) && $post['sg_net_wd'] != '') ? (float) $post['sg_net_wd'] : 'NULL';
$sg_net_wk = (isset($post['sg_net_wk']) && $post['sg_net_wk'] != '') ? (float) $post['sg_net_wk'] : 'NULL';
$db_net_wd = (isset($post['db_net_wd']) && $post['db_net_wd'] != '') ? (float) $post['db_net_wd'] : 'NULL';
$db_net_wk = (isset($post['db_net_wk']) && $post['db_net_wk'] != '') ? (float) $post['db_net_wk'] : 'NULL';
$ex_wbed_net_wd = (isset($post['ex_wbed_net_wd']) && $post['ex_wbed_net_wd'] != '') ? (float) $post['ex_wbed_net_wd'] : 'NULL';
$ex_wbed_net_wk = (isset($post['ex_wbed_net_wk']) && $post['ex_wbed_net_wk'] != '') ? (float) $post['ex_wbed_net_wk'] : 'NULL';
$tri_net_wd = (isset($post['tri_net_wd']) && $post['tri_net_wd'] != '') ? (float) $post['tri_net_wd'] : 'NULL';
$tri_net_wk = (isset($post['tri_net_wk']) && $post['tri_net_wk'] != '') ? (float) $post['tri_net_wk'] : 'NULL';
$chpaid_net_wd = (isset($post['chpaid_net_wd']) && $post['chpaid_net_wd'] != '') ? (float) $post['chpaid_net_wd'] : 'NULL';
$chpaid_net_wk = (isset($post['chpaid_net_wk']) && $post['chpaid_net_wk'] != '') ? (float) $post['chpaid_net_wk'] : 'NULL';
$age_paid = 7;
$MealPlanType = 0;
$FromDate = implode('-', array_reverse(explode('/', $from_date)));
$ToDate = implode('-', array_reverse(explode('/', $to_date)));
$currentDate = date("Y-m-d H:i:s");
if (!empty($room_type)) {
$getHotelDetails = $objAccoModel->getHotelRateType($AccomSysId, $AgencySysId);
$isInventory = true;
if (isset($getHotelDetails['HotelRateType']) && $getHotelDetails['HotelRateType'] == 2) {
$isInventory = false;
}
$rkey = 0;
$roomItemTypeE = explode('__', $room_type);
$ItemSysId = (int) $roomItemTypeE[0];
$RoomTypeId = (int) $roomItemTypeE[1];
if ($ItemSysId > 0 && $RoomTypeId > 0 && $meal_plan_type > 0) {
$checkHotelRoomInventoryRateByDate = $objAccoModel->checkHotelRoomInventoryRate($this->intLoggedinUserAgencySysId, $AccomSysId, $FromDate, $ToDate, 0, 0, 1);
$copySplitSessionAndRates = 0;
$checkHotelRoomInventoryRate = $SessionRoomFromDateArray = $SessionRoomFromToDateArray = array();
$dateranges = array();
$strFromDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($from_date, 'd/m/y');
$strToDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($to_date, 'd/m/y');
$daterangesNew[] = array(
'start_date' => $strFromDate,
'end_date' => $strToDate
);
$DateWiseSecurityKey = [];
if (!empty($checkHotelRoomInventoryRateByDate)) {
foreach ($checkHotelRoomInventoryRateByDate as $key => $value) {
if ($value['RoomSysId'] == $RoomTypeId && $value['MealPlanType'] == $meal_plan_type) {
$checkHotelRoomInventoryRate[] = $value;
}
$ExistFromDateM = $value['FromDate']->format('Y-m-d');
$ExistToDateM = $value['ToDate']->format('Y-m-d');
$DateWiseSecurityKey[$ExistFromDateM . '-' . $ExistToDateM][$value['RoomSysId']] = $value['XRateSessionKey'];
$SessionRoomFromDateArray[$value['XRateSessionKey']][$value['RoomSysId']][$ExistFromDateM] = $value;
$SessionRoomFromToDateArray[$value['XRateSessionKey']][$value['RoomSysId']][$ExistFromDateM . '-' . $ExistToDateM] = $value;
}
$InvnItemSysIdM = 0;
if (!empty($checkHotelRoomInventoryRate)) {
$InvnItemSysIdM = $checkHotelRoomInventoryRate[0]['InvnItemSysId'];
$getRoomInventoryId = $checkHotelRoomInventoryRate[0]['id'];
$XRateSessionKey = $checkHotelRoomInventoryRate[0]['XRateSessionKey'];
$ExistFromDate = $checkHotelRoomInventoryRate[0]['FromDate']->format('Y-m-d');
$ExistToDate = $checkHotelRoomInventoryRate[0]['ToDate']->format('Y-m-d');
$ExistFromDateDMY = $checkHotelRoomInventoryRate[0]['FromDate']->format('d/m/Y');
$ExistToDateDMY = $checkHotelRoomInventoryRate[0]['ToDate']->format('d/m/Y');
// } else {
// $getRoomInventoryId = $checkHotelRoomInventoryRateByDate[0]['id'];
// $XRateSessionKey = $checkHotelRoomInventoryRateByDate[0]['XRateSessionKey'];
// $ExistFromDate = $checkHotelRoomInventoryRateByDate[0]['FromDate']->format('Y-m-d');
// $ExistToDate = $checkHotelRoomInventoryRateByDate[0]['ToDate']->format('Y-m-d');
//
// $ExistFromDateDMY = $checkHotelRoomInventoryRateByDate[0]['FromDate']->format('d/m/Y');
// $ExistToDateDMY = $checkHotelRoomInventoryRateByDate[0]['ToDate']->format('d/m/Y');
}
if (!empty($checkHotelRoomInventoryRate)) {
if($ExistFromDate == $FromDate && $ExistToDate == $ToDate){
if($AccomSysId > 0 && !empty($XRateSessionKey) && $ItemSysId > 0 && (int)$InvnItemSysIdM > 0){
$whereIn = array('AccomSysId =?' => $AccomSysId, 'XRateSessionKey =?' => $XRateSessionKey, 'XRefItemSysId =?' => $ItemSysId);
$whereIn_acc = array(
'XRefAccoSysId =?' => $AccomSysId,
'XRefItemSysId =? ' => $ItemSysId,
'InvnItemSysId =? ' => $InvnItemSysIdM,
);
$update_im = array('IsMarkForDelete' => 1, 'IsActive' => 0, 'UpdatedDate' => $currentDate);
// $this->db->update('Tb_MP_Accomdation_Room_Inventory', $update_im, $whereIn);
$this->db->update('TB_MP_Inventory_Accom', $update_im, $whereIn_acc);
}
}else if ($ExistFromDate != $FromDate || $ExistToDate != $ToDate) {
$ExistFromDateStr = strtotime($ExistFromDate);
$ExistToDateStr = strtotime($ExistToDate);
$FromDateStr = strtotime($FromDate);
$ToDateStr = strtotime($ToDate);
$FromDateNewDMY = date('d/m/Y', $FromDateStr);
$TODateNewDMY = date('d/m/Y', $ToDateStr);
// echo "ExistFromDate:".$ExistFromDate.'<br>';
// echo "ExistToDate:".$ExistToDate.'<br>';
// echo "FromDate:".$FromDate.'<br>';
// echo "ToDate:".$ToDate.'<br>';
// echo "<pre>";print_r($post);
// echo "<pre>";print_r($checkHotelRoomInventoryRateByDate);
// echo "<pre>";print_r($checkHotelRoomInventoryRate);
// echo "<pre>";print_r($DateWiseSecurityKey);
// echo "<pre>";print_r($SessionRoomFromToDateArray);die;
if ($ExistFromDateStr <= $FromDateStr && $ExistToDateStr >= $ToDateStr) {
// 01/02/2026 15/02/2026
// 15/02/2026 28/02/2026
// 15/02/2026 20/02/2026
if($ExistFromDateStr != $FromDateStr){
$dateranges[] = [
'start_date' => $ExistFromDate,
'end_date' => date('Y-m-d', strtotime('-1 day', $FromDateStr))
];
}
$dateranges[] = [
'start_date' => $strFromDate,
'end_date' => $strToDate,
'InvnItemSysIdM' => $InvnItemSysIdM,
];
if($ExistToDateStr != $ToDateStr){
$dateranges[] = [
'start_date' => date('Y-m-d', strtotime('+1 day', $ToDateStr)),
'end_date' => $ExistToDate
];
}
if($InvnItemSysIdM > 0){
$daterangesNew = array();
}
}else if ($ExistFromDateStr >= $FromDateStr && $ExistToDateStr >= $ToDateStr) {
// 15/01/2026 15/02/2026
// 15/01/2026 28/02/2026
$dateranges[] = [
'start_date' => $strFromDate,
'end_date' => $strToDate,
'InvnItemSysIdM' => $InvnItemSysIdM,
];
if($ExistToDateStr != $ToDateStr){
$dateranges[] = [
'start_date' => date('Y-m-d', strtotime('+1 day', $ToDateStr)),
'end_date' => $ExistToDate,
];
}
$MealPlanType = $meal_plan_type;
if($InvnItemSysIdM > 0){
$daterangesNew = array();
}
}else if ($ExistFromDateStr >= $FromDateStr && $ExistToDateStr < $ToDateStr) {
// 15/01/2026 15/03/2026
// 01/02/2026 15/03/2026
$dateranges[] = [
'start_date' => $strFromDate,
'end_date' => $strToDate,
'InvnItemSysIdM' => $InvnItemSysIdM,
];
$MealPlanType = $meal_plan_type;
if($InvnItemSysIdM > 0){
$daterangesNew = array();
}
}else if ($ExistFromDateStr < $FromDateStr && $ExistToDateStr < $ToDateStr) {
// 15/02/2026 15/03/2026
if($ExistFromDateStr != $FromDateStr){
$dateranges[] = [
'start_date' => $ExistFromDate,
'end_date' => date('Y-m-d', strtotime('-1 day', $FromDateStr)),
];
}
$dateranges[] = [
'start_date' => $strFromDate,
'end_date' => $strToDate,
'InvnItemSysIdM' => $InvnItemSysIdM,
];
$MealPlanType = $meal_plan_type;
if($InvnItemSysIdM > 0){
$daterangesNew = array();
}
}
// echo "<pre>";print_r($checkHotelRoomInventoryRate);
// echo "<pre>";print_r($dateranges);
// echo "<pre>";print_r($daterangesNew);die;
if (!empty($dateranges)) {
$this->copySplitSessionAndRatesExcel($post, $dateranges, $this->intLoggedinUserAgencySysId, $AccomSysId, $XRateSessionKey, $ItemSysId, $RoomTypeId, $MealPlanType);
$copySplitSessionAndRates = 1;
} else if ($copySplitSessionAndRates == 0) {
$response = array('status' => false, 'message' => 'This date range, or within date range already exist. Existing session (' . $ExistFromDateDMY . ' - ' . $ExistToDateDMY . ')');
if($IsReturn == 1){
$copySplitSessionAndRates = 1;
}else{
echo json_encode($response);exit;
}
}
//
// echo "<pre>";print_r($dateranges);die;
}
}
}
// echo "daterangesNew<pre>";print_r($DateWiseSecurityKey);
// echo "daterangesNew<pre>";print_r($daterangesNew);die;
// die('test');
// echo "dateranges<pre>";print_r($dateranges);die;
//echo "<pre>";print_r($checkHotelRoomInventoryRateByDate);die;
//$checkHotelRoomInventoryRate = $objAccoModel->checkHotelRoomInventoryRate($this->intLoggedinUserAgencySysId,$AccomSysId,$FromDate,$ToDate, $RoomTypeId, $meal_plan_type);
// if(!empty($checkHotelRoomInventoryRate)){
// $response = array('status' => false, 'message' => 'This Room and Meal Plan Rate already exist for this date range, or within date range. Existing session ('.$ExistFromDateDMY.' - '.$ExistToDateDMY.')');
// echo json_encode($response); exit;
// }
// echo "<pre>";print_r($checkHotelRoomInventoryRateByDate);
// echo "<pre>";print_r($checkHotelRoomInventoryRate);
// echo "<pre>";print_r($SessionRoomArray);die;
if (!empty($ItemSysId) && !empty($RoomTypeId) && !empty($meal_plan_type) && !empty($db_net_wd) && $db_net_wd != 'NULL') {
$weekend = (isset($getHotelDetails['WeekendDefine']) && !empty($getHotelDetails['WeekendDefine'])) ? $getHotelDetails['WeekendDefine'] : '';
$CurrencyType = (isset($getHotelDetails['CurrencyType']) && !empty($getHotelDetails['CurrencyType'])) ? (int) $getHotelDetails['CurrencyType'] : 0;
$SupplierSysId = (isset($getHotelDetails['SupplierSysId']) && !empty($getHotelDetails['SupplierSysId'])) ? (int) $getHotelDetails['SupplierSysId'] : 0;
$NetRateType = (isset($getHotelDetails['NetRateType']) && !empty($getHotelDetails['NetRateType'])) ? (int) $getHotelDetails['NetRateType'] : 0;
$RackCommission = (isset($getHotelDetails['RackCommission']) && !empty($getHotelDetails['RackCommission'])) ? (float) $getHotelDetails['RackCommission'] : 0;
$RRType = 0;
$check_markup_sg = $check_markup_db = $check_markup_tri = $check_markup_ex = $check_markup_chpaid = 1;
$PublishQty = $NetInHandQty = 10;
$weekends = explode(',', $weekend);
$strToDates = date("Y-m-d", strtotime("+1 day", strtotime($strToDate)));
$begin = new DateTime($strFromDate);
$end = new DateTime($strToDates);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
$queryVals = array();
// echo "<pre>";print_r($checkHotelRoomInventoryRateByDate);
if (!empty($daterangesNew)) {
foreach ($daterangesNew as $dKey => $dValue) {
$IsExistSessionKey = 0;
if(isset($dValue['XRateSessionKey']) && !empty($dValue['XRateSessionKey'])){
$sessionKey = $dValue['XRateSessionKey'];
$IsExistSessionKey = 1;
}else{
if (isset($XRateSessionKey) && !empty($XRateSessionKey) && $copySplitSessionAndRates == 0) {
$sessionKey = $XRateSessionKey;
$IsExistSessionKey = 1;
} else {
$sessionKey = $objAccoModel->getMaxXRateSessionKey();
}
}
$strFromDate = $dValue['start_date'];
$strToDate = $dValue['end_date'];
$XRateSessionKeyM = isset($DateWiseSecurityKey[$strFromDate.'-'.$strToDate][$RoomTypeId]) ? $DateWiseSecurityKey[$strFromDate.'-'.$strToDate][$RoomTypeId] : '';
if(!empty($XRateSessionKeyM)){
$sessionKey = $XRateSessionKeyM;
}
$insert = [
'FromDate' => $dValue['start_date'],
'Todate' => $dValue['end_date'],
'XRateSessionKey' => $sessionKey,
'PublishQty' => $PublishQty,
'NetInHandQty' => $NetInHandQty,
'BlockQty' => 0,
'SoldQty' => 0,
'UpdatedDate' => $currentDate,
'CreatedDate' => $currentDate,
'AccomSysId' => (int) $AccomSysId,
'RoomSysId' => (int) $RoomTypeId,
'SupplierSysId' => (int) $SupplierSysId,
'AgencySysId' => $AgencySysId,
'XRefItemSysId' => (int) $ItemSysId,
'IsMarkForDelete' => 0,
'IsActive' => 1,
'IsSaleStart' => 1,
'BookingType' => 0,
];
//echo $strFromDate.'-'.$strToDate."<pre>";print_r($insert);die;
if (isset($SessionRoomFromToDateArray[$sessionKey][$RoomTypeId][$strFromDate . '-' . $strToDate]) && !empty($SessionRoomFromToDateArray[$sessionKey][$RoomTypeId][$strFromDate . '-' . $strToDate])) {
$id = $SessionRoomFromToDateArray[$sessionKey][$RoomTypeId][$strFromDate . '-' . $strToDate]['id'];
} else {
$this->db->insert('Tb_MP_Accomdation_Room_Inventory', $insert);
$id = $this->db->lastInsertId();
}
$addHotelData = array(
"AgencySysId" => (int) $AgencySysId,
"WeekendDefine" => $weekend,
"MealPlanType" => (int) $meal_plan_type,
"MarkType" => 1,
"B2CMarkup" => (float) $b2c_markup,
"B2BMarkup" => (float) $b2b_markup,
"SOccupCost" => ($sg_net_wd != 'NULL') ? $sg_net_wd : NULL,
"NetSOccupCost" => ($sg_net_wd != 'NULL') ? $sg_net_wd : NULL,
"IsTaxOnSOccupCost" => '0',
"TaxSOccupCost" => '0',
"DOccupCost" => $db_net_wd,
"NetDOccupCost" => $db_net_wd,
"IsTaxOnDOccupCost" => '0',
"TaxDOccupCost" => '0',
"ExtraBedCost" => ($ex_wbed_net_wd != 'NULL') ? $ex_wbed_net_wd : NULL,
"NetExtraBedCost" => ($ex_wbed_net_wd != 'NULL') ? $ex_wbed_net_wd : NULL,
"IsTaxOnExtraBedCost" => '0',
"TaxExtraBedCost" => '0',
"TriOccupCost" => ($tri_net_wd != 'NULL') ? $tri_net_wd : NULL,
"NetTriOccupCost" => ($tri_net_wd != 'NULL') ? $tri_net_wd : NULL,
"IsTaxOnTriOccupCost" => '0',
"TaxTriOccupCost" => '0',
"ChildAgeLimit" => $age_paid,
"ExtraWOBedCost" => ($chpaid_net_wd != 'NULL') ? $chpaid_net_wd : NULL,
"NetExtraWOBedCost" => ($chpaid_net_wd != 'NULL') ? $chpaid_net_wd : NULL,
"IsTaxOnExtraWOBedCost" => '0',
"TaxExtraWOBedCost" => '0',
"RateType" => $NetRateType,
"RackCommissionType" => $RRType,
"RackCommission" => $RackCommission,
"UpdatedDate" => $currentDate,
"CreatedDate" => $currentDate,
"XRefAccoSysId" => (int) $AccomSysId,
"RoomInventorySysId" => (int) $id,
"XRefItemSysId" => (int) $ItemSysId,
"TrxCurrency" => $CurrencyType,
"SupplierSysId" => $SupplierSysId,
"IsAllowMarkupSO" => $check_markup_sg,
"IsAllowMarkupDO" => $check_markup_db,
"IsAllowMarkupTO" => $check_markup_tri,
"IsAllowMarkupEB" => $check_markup_ex,
"IsAllowMarkupWOB" => $check_markup_chpaid,
"IsActive" => 1,
"IsMarkForDelete" => 0,
"WkSOccupCost" => ($sg_net_wk != 'NULL') ? $sg_net_wk : NULL,
"WkNetSOccupCost" => ($sg_net_wk != 'NULL') ? $sg_net_wk : NULL,
"WkDOccupCost" => $db_net_wk,
"WkNetDOccupCost" => $db_net_wk,
"WkExtraBedCost" => ($ex_wbed_net_wk != 'NULL') ? $ex_wbed_net_wk : NULL,
"WkNetExtraBedCost" => ($ex_wbed_net_wk != 'NULL') ? $ex_wbed_net_wk : NULL,
"WkTriOccupCost" => ($tri_net_wk != 'NULL') ? $tri_net_wk : NULL,
"WkNetTriOccupCost" => ($tri_net_wk != 'NULL') ? $tri_net_wk : NULL,
"WkExtraWOBedCost" => ($chpaid_net_wk != 'NULL') ? $chpaid_net_wk : NULL,
"WkNetExtraWOBedCost" => ($chpaid_net_wk != 'NULL') ? $chpaid_net_wk : NULL,
"RateSource" => 1,
);
try {
$this->db->insert('TB_MP_Inventory_Accom', $addHotelData);
} catch (Exception $ex) {
die($ex->getMessage());
}
if($AccomSysId > 0 && $ItemSysId > 0 && isset($dValue['InvnItemSysIdM']) && (int)$dValue['InvnItemSysIdM'] > 0){
$whereIn_acc = array(
'XRefAccoSysId =?' => $AccomSysId,
'XRefItemSysId =? ' => $ItemSysId,
'InvnItemSysId =? ' => (int)$dValue['InvnItemSysIdM'],
);
$update_im = array('IsMarkForDelete' => 1, 'IsActive' => 0, 'UpdatedDate' => $currentDate);
// $this->db->update('Tb_MP_Accomdation_Room_Inventory', $update_im, $whereIn);
$this->db->update('TB_MP_Inventory_Accom', $update_im, $whereIn_acc);
}
}
}
$UpdateHotelData = array('UpdateDate' => $currentDate);
$whereH = array('AccomSysId =?' => $AccomSysId);
$this->db->update('TB_IC_Accomdation', $UpdateHotelData, $whereH);
$response = array('status' => true, 'AccomSysId' => $AccomSysId, 'IsExistSessionKey' => $IsExistSessionKey, 'SessionKey' => $sessionKey, 'message' => 'Date Updated Successfully.');
if($IsReturn == 1){
return $response;
}else{
echo json_encode($response);exit;
}
}
} else {
$response = array('status' => false, 'message' => 'Room Id / Meal Id Missing.');
if($IsReturn == 1){
return $response;
}else{
echo json_encode($response);exit;
}
}
} else {
$response = array('status' => false, 'message' => 'Please select Room.');
}
if($IsReturn == 1){
return $response;
}else{
echo json_encode($response);exit;
}
}
}
public function updateRateFromExcelAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$objAccoModel = new Travel_Model_AccommodationModel();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$this->_leadstageObj = new Travel_Model_TblLeadSource();
$return = array();
$file = isset($_FILES['myfile']['tmp_name']) ? $_FILES['myfile']['tmp_name'] : '';
if ($this->getRequest()->isPost() && !empty($file)) {
$post = $this->getRequest()->getPost();
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('PHPExcel_');
$phpexcel_obj = new PHPExcel_Classes_Readexcel;
$finalData = $phpexcel_obj->importFromExcel($file);
// echo "<pre>";print_r($finalData);die;
$hotelArray = array();
if (!empty($finalData)) {
foreach ($finalData as $key => $values) {
if ((isset($values[8]) && trim($values[8]) != '')) {
if ($key == 0) {
$hotelId = (isset($values[0]) && trim($values[0]) != '') ? trim($values[0]) : 0;
$RoomType = (isset($values[3]) && trim($values[3]) != '') ? trim($values[3]) : '';
$hotelArray[$hotelId]['HotelId'] = $hotelId;
$hotelArray[$hotelId]['HotelName'] = $hotelName = (isset($values[1]) && trim($values[1]) != '') ? trim($values[1]) : '';
$hotelArray[$hotelId]['HotelStar'] = $HotelStar = (isset($values[2]) && trim($values[2]) != '') ? trim($values[2]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['RoomType'] = $RoomType;
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['FromDate'] = $FromDate = (isset($values[4]) && trim($values[4]) != '') ? $this->excelDateToPhpDateDMY($values[4]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['ToDate'] = $ToDate = (isset($values[5]) && trim($values[5]) != '') ? $this->excelDateToPhpDateDMY($values[5]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['MealType'] = $MealType = (isset($values[6]) && trim($values[6]) != '') ? trim($values[6]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['SingleOcc'] = $SingleOcc = (isset($values[7]) && trim($values[7]) != '') ? trim($values[7]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['DoubleOcc'] = $DoubleOcc = (isset($values[8]) && trim($values[8]) != '') ? trim($values[8]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['AdultExtraBed'] = $AdultExtraBed = (isset($values[9]) && trim($values[9]) != '') ? trim($values[9]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['ChildExtraBed'] = $ChildExtraBed = (isset($values[10]) && trim($values[10]) != '') ? trim($values[10]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['CNB'] = $CNB = (isset($values[11]) && trim($values[11]) != '') ? trim($values[11]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['MarkType'] = $MarkType = (isset($values[12]) && trim($values[12]) != '') ? trim($values[12]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['B2CMarkup'] = $B2CMarkup = (isset($values[13]) && trim($values[13]) != '') ? trim($values[13]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['B2BMarkup'] = $B2BMarkup = (isset($values[14]) && trim($values[14]) != '') ? trim($values[14]) : '';
} else {
$hotelId = (isset($values[0]) && trim($values[0]) != '') ? trim($values[0]) : $hotelId;
$RoomType = (isset($values[3]) && trim($values[3]) != '') ? trim($values[3]) : $RoomType;
$hotelArray[$hotelId]['HotelId'] = $hotelId;
$hotelArray[$hotelId]['HotelName'] = $hotelName = (isset($values[1]) && trim($values[1]) != '') ? trim($values[1]) : $hotelName;
$hotelArray[$hotelId]['HotelStar'] = $HotelStar = (isset($values[2]) && trim($values[2]) != '') ? trim($values[2]) : $HotelStar;
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['RoomType'] = $RoomType;
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['FromDate'] = $FromDate = (isset($values[4]) && trim($values[4]) != '') ? $this->excelDateToPhpDateDMY($values[4]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['ToDate'] = $ToDate = (isset($values[5]) && trim($values[5]) != '') ? $this->excelDateToPhpDateDMY($values[5]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['MealType'] = $MealType = (isset($values[6]) && trim($values[6]) != '') ? trim($values[6]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['SingleOcc'] = $SingleOcc = (isset($values[7]) && trim($values[7]) != '') ? trim($values[7]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['DoubleOcc'] = $DoubleOcc = (isset($values[8]) && trim($values[8]) != '') ? trim($values[8]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['AdultExtraBed'] = $AdultExtraBed = (isset($values[9]) && trim($values[9]) != '') ? trim($values[9]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['ChildExtraBed'] = $ChildExtraBed = (isset($values[10]) && trim($values[10]) != '') ? trim($values[10]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['CNB'] = $CNB = (isset($values[11]) && trim($values[11]) != '') ? trim($values[11]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['MarkType'] = $MarkType = (isset($values[12]) && trim($values[12]) != '') ? trim($values[12]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['B2CMarkup'] = $B2CMarkup = (isset($values[13]) && trim($values[13]) != '') ? trim($values[13]) : '';
$hotelArray[$hotelId]['Rooms'][$RoomType][$key]['B2BMarkup'] = $B2BMarkup = (isset($values[14]) && trim($values[14]) != '') ? trim($values[14]) : '';
}
}
}
}
$MEAL_TYPE = unserialize(MEAL_TYPE);
$MEAL_TYPER = array_flip($MEAL_TYPE);
$AgencySysId = $this->intLoggedinUserAgencySysId;
foreach($hotelArray as $hkey => $hvalue){
$hotelpost = array(
'HotelId' => $hvalue['HotelId'],
'HotelName' => $hvalue['HotelName'],
'HotelStar' => $hvalue['HotelStar'],
);
$UpdateHotelId = $objAccoModel->CheckUpdateHotelDetail($AgencySysId,$hotelpost);
if((int)$UpdateHotelId > 0){
foreach($hvalue['Rooms'] as $hrkey => $hrvalue){
$roompost = array(
'HotelId' => $UpdateHotelId,
'RoomType' => $hrkey,
'total_room' => 0,
);
$ItemSysIdRoomTypeArray = $objAccoModel->AddHotelMultipleRoomDetails($AgencySysId,$UpdateHotelId,$roompost,1);
$ItemSysIdRoomType = $ItemSysIdRoomTypeArray[0];
foreach($hrvalue as $hrmkey => $hrmvalue){
$MealType = $MEAL_TYPER[$hrmvalue['MealType']];
$data = array(
'NewAccomSysId' => $UpdateHotelId,
'from_date' => $hrmvalue['FromDate'],
'to_date' => $hrmvalue['ToDate'],
'room_type' => $ItemSysIdRoomType,
'meal_plan_type' => $MealType,
'b2b_markup' => $hrmvalue['B2BMarkup'],
'b2c_markup' => $hrmvalue['B2CMarkup'],
'sg_net_wd' => $hrmvalue['SingleOcc'],
'sg_net_wk' => $hrmvalue['SingleOcc'],
'db_net_wd' => $hrmvalue['DoubleOcc'],
'db_net_wk' => $hrmvalue['DoubleOcc'],
'ex_wbed_net_wd' => $hrmvalue['AdultExtraBed'],
'ex_wbed_net_wk' => $hrmvalue['AdultExtraBed'],
'tri_net_wd' => $hrmvalue['ChildExtraBed'],
'tri_net_wk' => $hrmvalue['ChildExtraBed'],
'chpaid_net_wd' => $hrmvalue['CNB'],
'chpaid_net_wk' => $hrmvalue['CNB'],
);
$return[] = $this->saveHotelRatesExcelAction($data);
}
}
}
}
}
$message = "Hotel Rate Updated Successfully.";
$this->_helper->flashMessenger->addMessage($message);
$this->_helper->redirector('inventory', 'accommodation', 'default');
echo json_encode($return);exit;
}
}