| 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/indoasiaholidays.com/library/Helper/ |
Upload File : |
<?php
/* * *************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : Hotel.php
* File Desc. : Hotel helper to including supporting functions/methods for Hotels
* Created By : Pardeep Panchal <pardeep@catpl.co.in>
* Created Date : 24 Nov 2017
* Updated Date : 24 Nov 2017
* ************************************************************* */
class Zend_Controller_Action_Helper_Hotel extends Zend_Controller_Action_Helper_Abstract {
public $baseUrl;
public function __construct() {
$this->pluginLoader = new Zend_Loader_PluginLoader();
$this->db = Zend_Db_Table::getDefaultAdapter();
$BootStrap = $this->config();
$this->siteName = $BootStrap['siteName'];
$this->baseUrl = $BootStrap['siteUrl'];
}
public function config() {
$front = $this->getFrontController();
$bootstrap = $front->getParam('bootstrap');
if (null === $bootstrap) {
throw new Exception('Unable to find bootstrap');
}
// return $bootstrap->getOptions();
return $bootstrap->getOptions()['bootstrap'];
}
public function getRatingImage($rating, $fullRating = 5) {
$ratingStar = '<img src="' . $this->baseUrl . 'public/images/red-star.png">';
$ratingStar_light = '<img src="' . $this->baseUrl . 'public/images/gray-star.png">';
$ratingImage = '';
for ($i = 0; $i < $rating; $i++) {
$ratingImage .= $ratingStar;
}
$grayStars = $fullRating - $rating;
for ($i = 0; $i < $grayStars; $i++) {
$ratingImage .= $ratingStar_light;
$ratingImage;
}
return $ratingImage;
}
public function getInclusionIcon($Inclusions, $stringSeparator = "") {
//echo "<pre>";print_r($Inclusions);echo "</pre>";
$ret = $icon = '';
$InclusionsMaster = [
'wi-fi' => 'wifi' ,
'Internet' => 'wifi' ,
'tv' => 'television' ,
'minibar' => 'glass' ,
'bar' => 'glass' ,
'disability-friendly bathroom' => 'wheelchair' ,
'Disabled facilities' => 'wheelchair' ,
'secure parking' => 'car' ,
'parking' => 'car' ,
'Car parking (Payable to hotel, if applicable)' => 'car' ,
'Car parking' => 'car' ,
//'smoking rooms' => 'bath' ,
];
$ret = [];
if($stringSeparator!=""){
foreach (explode($stringSeparator, $Inclusions) as $inc) {
$inc = trim($inc);
$icon = (isset($InclusionsMaster[$inc])) ? $InclusionsMaster[$inc] : "question";
if ($icon != 'question') {
if(!in_array($icon, $ret))
$ret[$InclusionsMaster[$inc]] = $icon;
}
}
}else{
foreach ($Inclusions as $inc) {
$inc = trim($inc);
$icon = (isset($InclusionsMaster[$inc])) ? $InclusionsMaster[$inc] : "question";
if ($icon != 'question') {
if(!in_array($icon, $ret))
$ret[$InclusionsMaster[$inc]] = $icon;
}
}
}
return $ret;
}
public function dataEncode($arrData) {
return base64_encode(json_encode($arrData));
}
public function dataDecode($strData) {
return json_decode(base64_decode($strData), 1);
}
public function sortArrayByColumn(&$arr = [], $col, $order = SORT_ASC){
$sort_col = array();
if(count($arr)>0){
foreach ($arr as $key => $row) {
@$sort_col[$key] = $row[$col];
}
}
@array_multisort($sort_col, $order, $arr);
}
public function dateFormat($date,$format = 1){
if($format == 1){ // 2018-01-19T00:00:00
$arrDate = explode("T", $date);
return date('d-m-Y',strtotime($arrDate[0])); //30 Nov' 17 Thu
}elseif($format == 2){
return date('d M'."'".' y D',strtotime($date)); //30 Nov' 17 Thu
}else{
return $date;
}
}
public function getRoomImagesByItemSysId( array $array , $ItemSysId) {
$ret = [];
foreach ( $array as $key => $value ) {
if($value['ItemSysId'] == $ItemSysId) {
$ret[] = ['index'=> $value['ImgIndex'], 'img'=> $value['Details'] ];
}
}
return $ret;
}
public function calculateNoOfDays($date1,$date2){
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = ceil(($diff - $years * 365*60*60*24 - $months*30*60*60*24) / (60*60*24))+1;
return $days;
}
public function getTotalCostOfHotelByTravelers($hotelArray, $roominfoarr,$arrMarkUp = []) {
// echo "<pre>";print_r($hotelArray);
// echo "<pre>";print_r($roominfoarr);
// echo "<pre>";print_r($arrMarkUp);exit;
$MarkUpType = isset($arrMarkUp['MarkUpType'])?$arrMarkUp['MarkUpType']:'';
$MarkUp = isset($arrMarkUp['MarkUp'])?$arrMarkUp['MarkUp']:'';
$DOccupMarkUp = isset($arrMarkUp['DOccupMarkUp'])?$arrMarkUp['DOccupMarkUp']:'';
$SOccupMarkUp = isset($arrMarkUp['SOccupMarkUp'])?$arrMarkUp['SOccupMarkUp']:'';
$ExtraBedMarkUp = isset($arrMarkUp['ExtraBedMarkUp'])?$arrMarkUp['ExtraBedMarkUp']:'';
$ExtraWOBedMarkUp = isset($arrMarkUp['ExtraWOBedMarkUp'])?$arrMarkUp['ExtraWOBedMarkUp']:'';
if($MarkUpType == 1){
// Single
$NetSOccupCost = isset($hotelArray['NetSOccupCost'])?$hotelArray['NetSOccupCost']:0;
$NetSOccupCostWidMrkp = $NetSOccupCost + $SOccupMarkUp;
// Single
// Double
$NetDOccupCost = isset($hotelArray['DOccupCost'])?$hotelArray['DOccupCost']:0;
$NetDOccupCostWidMrkp = $NetDOccupCost + $DOccupMarkUp;
// Double
// ExtraBed
$NetExtraBedCost = isset($hotelArray['NetExtraBedCost'])?$hotelArray['NetExtraBedCost']:0;
$NetExtraBedCostWidMrkp = $NetExtraBedCost + $ExtraBedMarkUp;
// ExtraBed
// ExtraWoBed
$NetExtraWOBedCost = isset($hotelArray['NetExtraWOBedCost'])?$hotelArray['NetExtraWOBedCost']:0;
$NetExtraWOBedCostWidMrkp = $NetExtraWOBedCost + $ExtraWOBedMarkUp;
// ExtraWoBed
}else if($MarkUpType == 2){
// Single
$NetSOccupCost = isset($hotelArray['NetSOccupCost'])?$hotelArray['NetSOccupCost']:0;
$SOccupMarkUpAmt = ($NetSOccupCost*$SOccupMarkUp)/100;
$NetSOccupCostWidMrkp = $NetSOccupCost + $SOccupMarkUpAmt;
// Single
// Double
$NetDOccupCost = isset($hotelArray['DOccupCost'])?$hotelArray['DOccupCost']:0;
$DOccupMarkUpAmt = ($NetDOccupCost*$DOccupMarkUp)/100;
$NetDOccupCostWidMrkp = $NetDOccupCost + $DOccupMarkUpAmt;
// Double
// ExtraBed
$NetExtraBedCost = isset($hotelArray['NetExtraBedCost'])?$hotelArray['NetExtraBedCost']:0;
$ExtraBedMarkUpAmt = ($NetExtraBedCost*$ExtraBedMarkUp)/100;
$NetExtraBedCostWidMrkp = $NetExtraBedCost + $ExtraBedMarkUpAmt;
// ExtraBed
// ExtraBed
$NetExtraWOBedCost = isset($hotelArray['NetExtraWOBedCost'])?$hotelArray['NetExtraWOBedCost']:0;
$ExtraBedMarkUpAmt = ($NetExtraWOBedCost*$ExtraWOBedMarkUp)/100;
$NetExtraWOBedCostWidMrkp = $NetExtraWOBedCost + $ExtraBedMarkUpAmt;
// ExtraBed
}else{
// Single
$NetSOccupCost = isset($hotelArray['NetSOccupCost'])?$hotelArray['NetSOccupCost']:0;
$SOccupMarkUpAmt = 0;
$NetSOccupCostWidMrkp = $NetSOccupCost + $SOccupMarkUpAmt;
// Single
// Double
$NetDOccupCost = isset($hotelArray['DOccupCost'])?$hotelArray['DOccupCost']:0;
$DOccupMarkUpAmt = 0;
$NetDOccupCostWidMrkp = $NetDOccupCost + $DOccupMarkUpAmt;
// Double
// ExtraBed
$NetExtraBedCost = isset($hotelArray['NetExtraBedCost'])?$hotelArray['NetExtraBedCost']:0;
$ExtraBedMarkUpAmt = 0;
$NetExtraBedCostWidMrkp = $NetExtraBedCost + $ExtraBedMarkUpAmt;
// ExtraBed
// ExtraBed
$NetExtraWOBedCost = isset($hotelArray['NetExtraWOBedCost'])?$hotelArray['NetExtraWOBedCost']:0;
$ExtraBedMarkUpAmt = 0;
$NetExtraWOBedCostWidMrkp = $NetExtraWOBedCost + $ExtraBedMarkUpAmt;
// ExtraBed
}
$totalMember = 0;
$newcost = 0;
for ($m = 0; $m <= count($roominfoarr); $m++) {
$AdultPax = (int) @$roominfoarr[$m]['AdultPax'];
$ChildPax = (int) @$roominfoarr[$m]['ChildPax'];
$totalMember = $AdultPax + $ChildPax;
$ChildsAge = @$roominfoarr[$m]['ChildsAge'];
if($totalMember == 1){
$newcost = $newcost + (isset($hotelArray['NetSOccupCost'])?$NetSOccupCostWidMrkp:$NetDOccupCostWidMrkp);
//$newcost = $newcost + $hotelArray['DOccupCost'];
}elseif ($totalMember == 2) {
$newcost = $newcost + $NetDOccupCostWidMrkp;
}else if($totalMember > 2){
if($AdultPax == 3 && $ChildPax == 0){
$newcost = $newcost + ($NetDOccupCostWidMrkp + $NetExtraBedCostWidMrkp);
}else if($AdultPax == 2 && $ChildPax == 1){
$newcost = $newcost + ($NetDOccupCostWidMrkp + $NetExtraWOBedCostWidMrkp);
}else if($AdultPax == 3 && $ChildPax == 1){
$newcost = $newcost + ($NetDOccupCostWidMrkp + $NetExtraBedCostWidMrkp + $NetExtraWOBedCostWidMrkp);
}else if($AdultPax == 2 && $ChildPax == 2){
$newcost = $newcost + ($NetDOccupCostWidMrkp + $NetExtraWOBedCostWidMrkp + $NetExtraWOBedCostWidMrkp);
}else if($AdultPax == 1 && $ChildPax == 2){
$newcost = $newcost + ($NetSOccupCostWidMrkp + $NetExtraWOBedCostWidMrkp + $NetExtraWOBedCostWidMrkp);
}
}
}
return round($newcost);
}
public function getTotalCostOfHotelByTravelersAPI($roomRate, $roominfoarr,$arrMarkUp = []) {
// echo "<pre>";print_r($roomRate);
// echo "<pre>";print_r($roominfoarr);
// echo "<pre>";print_r($arrMarkUp);exit;
$MarkUpType = isset($arrMarkUp['MarkUpType'])?$arrMarkUp['MarkUpType']:'';
$MarkUp = isset($arrMarkUp['MarkUp'])?$arrMarkUp['MarkUp']:'';
$DOccupMarkUp = isset($arrMarkUp['DOccupMarkUp'])?$arrMarkUp['DOccupMarkUp']:'';
$SOccupMarkUp = isset($arrMarkUp['SOccupMarkUp'])?$arrMarkUp['SOccupMarkUp']:'';
$ExtraBedMarkUp = isset($arrMarkUp['ExtraBedMarkUp'])?$arrMarkUp['ExtraBedMarkUp']:'';
$ExtraWOBedMarkUp = isset($arrMarkUp['ExtraWOBedMarkUp'])?$arrMarkUp['ExtraWOBedMarkUp']:'';
if($MarkUpType == 1){
// Single
$SOccupMarkUpAmt = $SOccupMarkUp;
// Single
// Double
$DOccupMarkUpAmt = $DOccupMarkUp;
// Double
// ExtraBed
$ExtraBedMarkUpAmt = $ExtraBedMarkUp;
// ExtraBed
// ExtraWoBed
$ExtraWOBedMarkUpAmt = $ExtraWOBedMarkUp;
// ExtraWoBed
}else if($MarkUpType == 2){
// Single
$NetSOccupCost = !empty($roomRate)?$roomRate:0;
$SOccupMarkUpAmt = ($NetSOccupCost*$SOccupMarkUp)/100;
// Single
// Double
$NetDOccupCost = !empty($roomRate)?$roomRate:0;
$DOccupMarkUpAmt = ($NetDOccupCost*$DOccupMarkUp)/100;
// Double
// ExtraBed
$NetExtraBedCost = !empty($roomRate)?$roomRate:0;
$ExtraBedMarkUpAmt = ($NetExtraBedCost*$ExtraBedMarkUp)/100;
// ExtraBed
// ExtraBed
$NetExtraWOBedCost = !empty($roomRate)?$roomRate:0;
$ExtraWOBedMarkUpAmt = ($NetExtraWOBedCost*$ExtraWOBedMarkUp)/100;
// ExtraBed
}else{
// Single
$SOccupMarkUpAmt = 0;
// Single
// Double
$DOccupMarkUpAmt = 0;
// Double
// ExtraBed
$ExtraBedMarkUpAmt = 0;
// ExtraBed
// ExtraBed
$ExtraWOBedMarkUpAmt = 0;
// ExtraBed
}
$totalMember = 0;
$newcost = 0;
for ($m = 0; $m <= count($roominfoarr); $m++) {
$AdultPax = (int) @$roominfoarr[$m]['AdultPax'];
$ChildPax = (int) @$roominfoarr[$m]['ChildPax'];
$totalMember = $AdultPax + $ChildPax;
$ChildsAge = @$roominfoarr[$m]['ChildsAge'];
if($totalMember == 1){
$newcost = $newcost + (!empty($SOccupMarkUpAmt)?$SOccupMarkUpAmt:$DOccupMarkUpAmt);
//$newcost = $newcost + $hotelArray['DOccupCost'];
}elseif ($totalMember == 2) {
$newcost = $newcost + $DOccupMarkUpAmt;
}else if($totalMember > 2){
if($AdultPax == 3 && $ChildPax == 0){
$newcost = $newcost + ($DOccupMarkUpAmt + $ExtraBedMarkUpAmt);
}else if($AdultPax == 2 && $ChildPax == 1){
$newcost = $newcost + ($DOccupMarkUpAmt + $ExtraWOBedMarkUpAmt);
}else if($AdultPax == 3 && $ChildPax == 1){
$newcost = $newcost + ($DOccupMarkUpAmt + $ExtraBedMarkUpAmt + $ExtraWOBedMarkUpAmt);
}else if($AdultPax == 2 && $ChildPax == 2){
$newcost = $newcost + ($DOccupMarkUpAmt + $ExtraWOBedMarkUpAmt + $ExtraWOBedMarkUpAmt);
}else if($AdultPax == 1 && $ChildPax == 2){
$newcost = $newcost + (!empty($SOccupMarkUpAmt)?$SOccupMarkUpAmt:$DOccupMarkUpAmt + $ExtraWOBedMarkUpAmt + $ExtraWOBedMarkUpAmt);
}
}
}
return round($newcost + $roomRate);
}
public function markUpCalculation($cast, $roominfoarr) {
// echo "<pre>";print_r($hotelArray);
// echo "<pre>";print_r($roominfoarr);
echo $cast;exit;
$totalMember = 0;
$newcost = 0;
for ($m = 0; $m <= count($roominfoarr); $m++) {
$AdultPax = (int) @$roominfoarr[$m]['AdultPax'];
$ChildPax = (int) @$roominfoarr[$m]['ChildPax'];
$totalMember = $AdultPax + $ChildPax;
$ChildsAge = @$roominfoarr[$m]['ChildsAge'];
}
return round($newcost);
}
}