Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
89 kB
1
Indexable
Never
<?php
$VRCalendarSettings = VRCalendarSettings::getInstance();
$VRCalendarEntity = VRCalendarEntity::getInstance();
$calid = 0;
if(isset($_GET['cal_id'])){
	$calid = $_GET['cal_id'];
}
$cal_data = $VRCalendarEntity->getCalendar( $calid );

$getAllCalendar = $VRCalendarEntity->getAllCalendar();
if(empty($cal_data->calendar_id) && $_GET["page"] == 'vr-calendar-mycalendar' && ($VRCalendarSettings->getSettings('licensekey_active')) && $gbversiontype != "pro-envato"){
	?>
	<div class="license_error">
	<?php
		echo esc_html( __('Calendar id does not exist! Please Select your Calendar below.', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
	?>
	</div><br/>
	<?php
}
if($_GET["page"] == 'vr-calendar-mycalendar' && ($VRCalendarSettings->getSettings('licensekey_active') && $gbversiontype != "pro-envato")){
?>
	<select style="margin-bottom: 15px;" class="select_calendar">
		<option>Select Calendar</option>
		<?php
			foreach($getAllCalendar as $d_cal){
		?>
				<option value="<?=$d_cal->calendar_id;?>" <?=(!empty($_GET["cal_id"]) && $_GET["cal_id"] == $d_cal->calendar_id) ? "selected":"";?>><?=$d_cal->calendar_name;?></option>
		<?php
			}
		?>
	</select>
	<script>
		jQuery(".select_calendar").on("change", function(){
			var cal_id = jQuery(this).val();
			location.href = 'admin.php?page=vr-calendar-mycalendar&cal_id='+cal_id;
		});
	</script>
<?php
}
if($VRCalendarSettings->getSettings('licensekey_active') && $gbversiontype != "pro-envato"){
		
		$next_month=0;
        $booking_checkin_date = date("Y-m-d");
		$booking_checkout_date = date('Y-m-d', strtotime('+1 day', strtotime($booking_checkin_date)));

		$getdisplay_month_data = $VRCalendarEntity->getCalendar($calid);
		$next_data = date('Y-m-d', mktime(0, 0, 0, date('m')+$next_month, 1, date('Y')));
		$month = date('n', strtotime($next_data));
		$year =  date('Y', strtotime($next_data));
		$current_month = date('Y-m-d', strtotime("{$year}-{$month}-1"));
		$month_year_name = '';
		if(empty($getdisplay_month_data->calendar_display_num_months)){
			$number_months = 12;
		}else{
			$number_months = $getdisplay_month_data->calendar_display_num_months;
		}
		
		$month_year_name .= '<select id="select_month" class="btn-select_month-single-'.$calid.'">';
		for ($count_cal = 0; $count_cal <= $number_months; $count_cal++) {
			$dates = date('F Y', strtotime($current_month.' + '.$count_cal.' Months'));
			$month_year_name .= '<option value="'.($count_cal+1).'">'.$dates.'</option>';
		}
		$month_year_name .= '</select>';
		$num_months = $number_months;
		$siteurl = site_url().'/wp-admin/admin-ajax.php';
		$dir = VRCALENDAR_PLUGIN_URL;
		if(!empty($cal_data->calendar_price_exception)){
			foreach ($cal_data->calendar_price_exception as $gustKey=>$gustValue) {
				$startDate = new DateTime($gustValue->start_date);
                $endDate = new DateTime($gustValue->end_date);

				$formatCheckingDate = new DateTime($booking_checkin_date);
				$checkInYearStart = $formatCheckingDate->format('Y');
				$checkInMonthStart = $formatCheckingDate->format('m');
				$checkInDateStart = $formatCheckingDate->format('d');

				$formatCheckoutDate = new DateTime($booking_checkout_date);
				$checkoutYearEnd = $formatCheckoutDate->format('Y');
				$checkoutMonthEnd = $formatCheckoutDate->format('m');
				$checkoutDateEnd = $formatCheckoutDate->format('d');
				$checkoutDateEnd = $checkoutDateEnd - 1;

				$seasonal_guest_max = $gustValue->seasonal_gustno_pricing;
				$seasonal_child_max = $gustValue->seasonal_childno_pricing;
				$count = 0;
				for ($seasonaldate = $startDate; $seasonaldate <= $endDate; $seasonaldate->modify('+1 day')) {

					$seasonStartYear = $startDate->format('Y');
					$seasonStartMonth = $startDate->format('m');
					$seasonStartDate = $startDate->format('d');

					$seasonEndYear = $endDate->format('Y');
					$seasonEndMonth = $endDate->format('m');
					$seasonEndDate = $endDate->format('d');

					$changingDate = $seasonaldate->format('d');
					$changingMonth = $seasonaldate->format('m');

					if ($seasonStartYear == $checkInYearStart || $checkoutYearEnd == $seasonStartYear || $checkInYearStart == $seasonEndYear || $checkoutYearEnd == $seasonEndYear) {
						if ($checkInMonthStart == $seasonStartMonth || $checkoutMonthEnd == $seasonEndMonth || $checkInMonthStart == $seasonEndMonth || $checkoutMonthEnd == $seasonEndMonth) {
							if ($checkInDateStart >= $seasonStartDate || $checkInDateStart <= $seasonEndDate || $checkoutDateEnd <= $seasonStartDate || $checkoutDateEnd >= $seasonEndDate) {

								if ($checkoutDateEnd < $changingDate && $checkoutMonthEnd == $changingMonth) {
									break;
								} else if ($checkInDateStart > $seasonStartDate && $checkInMonthStart == $seasonStartMonth) {

								} else {
									$count = $count + 1;
									$seasonaldaysname = $seasonaldate->format('l');
									$seasonalGust = $seasonal_guest_max;
									$seasonalChild = $seasonal_child_max;
								}
							}
						}
					}
				}
			}
		}
		if(!empty($seasonalGust)){
			$maxGuestNo = $seasonalGust;
		}else {
			$maxGuestNo = @$cal_data->calendar_max_guest_no;
		}
		if(!empty($seasonalChild)){
			$maxChildNo = $seasonalChild;
		}else {
			$maxChildNo = @$cal_data->calendar_max_child_no;
		}
		$fee_extra = @json_decode($cal_data->extra_fees_section); 
		
		$pro_one_day_book = @$cal_data->pro_one_day_book;
		$hourly_booking = @$cal_data->hourly_booking;
            
        $minimum_number_of_night = @$cal_data->minimum_number_of_night;
        $number_of_night = @$cal_data->number_of_night;
        
		$booking_form_text = 'Request to Book';
		if(@$cal_data->booking_form_text != ''){
			$booking_form_text = $cal_data->booking_form_text;
		}
		$calendar_tax_per_stay = @trim($cal_data->calendar_tax_per_stay);
		$calendar_tax_type = @trim($cal_data->calendar_tax_type);

        //style of left and right moves
		$VRCalendarSettings = VRCalendarSettings::getInstance();
		$dateformat = $VRCalendarSettings->getSettings('dateformat');
		$field_name_yes = @$cal_data->custom_field;

		//$field_name = esc_html( __(@$cal_data->custom_field_name, VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		$custom_field_name = "";
		if($field_name_yes == "yes"){
			$count_field = 0;
			$custom_field_data = json_decode($cal_data->custom_field_name);
			$count_field = count((array) $custom_field_data);
			if($count_field > 1){
				$col_field = "col-sm-6";
			}else{
				$col_field = "col-sm-12";
			}
			foreach($custom_field_data as $fieldval){
				$required_field = ($fieldval->field_required == 'yes') ? 'required' : '';
				$custom_field_name .= '<div class="'.$col_field.'">
					<div class="form-group">
						<label for="custom_field_name">'. esc_html( __($fieldval->field_name, VRCALENDAR_PLUGIN_TEXT_DOMAIN) ) .'</label>
						<input type="text" class="form-control '. $required_field .'" placeholder="'. $fieldval->field_placeholder .'" name="custom_field[' . $fieldval->field_name . ']" id="custom_field_name">
					</div>
				</div>';
			}
		}else{
			$custom_field_name = '';
		}
		
		$calendar_enable_csc = @$cal_data->calendar_enable_csc;
		if($calendar_enable_csc == "yes"){
			$city 		= esc_html( __('City', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
			$state 		= esc_html( __('State', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
			$country 	= esc_html( __('Country', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
			
			$yes_city 		= $cal_data->calendar_enable_city;
			$yes_state 		= $cal_data->calendar_enable_state;
			$yes_country 	= $cal_data->calendar_enable_country;
			
			if($yes_city == "yes"){
				if($yes_state == "yes" || $yes_country == "yes"){
					$col_city = "col-sm-6";
				}else{
					$col_city = "col-sm-12";
				}
				$enable_city = '
					<div class="'.$col_city.'">
						<div class="form-group">
							<label for="calendar_enable_city">'.$city.'</label>
							<input type="text" class="form-control" value="" name="calendar_enable_city" id="calendar_enable_city" placeholder="'.$city.'" />
						</div>
					</div>';
			}
			if($yes_state == "yes"){
				if($yes_city == "yes" || $yes_country == "yes"){
					$col_state = "col-sm-6";
				}else{
					$col_state = "col-sm-12";
				}
				$enable_state = '
					<div class="'.$col_state.'">
						<div class="form-group">
							<label for="calendar_enable_state">'.$state.'</label>
							<input type="text" class="form-control" value="" name="calendar_enable_state" id="calendar_enable_state" placeholder="'.$state.'"  />
						</div>
					</div>';
			}
			if($yes_country == "yes"){
				if($yes_city == "yes" && $yes_state == "yes"){
					$col_country = "col-sm-12";
				}else{
					$col_country = "col-sm-6";
				}
				$enable_country = '
					<div class="'.$col_country.'">
						<div class="form-group">
							<label for="calendar_enable_country">'.$country.'</label>
							<input type="text" class="form-control" value="" name="calendar_enable_country" id="calendar_enable_country" placeholder="'.$country.'" />
						</div>
					</div>';
			}
		}
		
        $CheckIn = esc_html( __('Check In', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $CheckOut = esc_html( __('Check Out', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $Guests = esc_html( __('Adult', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		if(@$cal_data->calendar_tax_charge == "yes"){
			$Child = 'Children Below '.$cal_data->calendar_tax_charge_label.' Years old';
		}else{
			$Child = esc_html( __('Children', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		}
		$Taxes = esc_html( __('Taxes', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		$Taxes_per_person = esc_html( __('Tax Adult per Day', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        // $Child = esc_html( __('Children', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $FirstName = esc_html( __('First Name', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $LastName = esc_html( __('Last Name', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $Email_booking = esc_html( __('Email', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $PhoneNumber = esc_html( __('Phone Number', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $NoteToHost = esc_html( __('Note To Host', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $zero_value = esc_html( __('0', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $ExtraGuestFees = esc_html( __('Extra Adult Fee', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $ExtraChildFees = esc_html( __('Extra Children Fee', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        //$CleaningFee = esc_html( __('Cleaning Fee', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		
        // $Taxes = esc_html( __('Taxes', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        //$ExtraFees = esc_html( __('Extra Fees', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $TotalReservationAmount = esc_html( __('Total Reservation Amount', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $RequesttoBook = esc_html( __($booking_form_text, VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $CheckInDate = esc_html( __('Check In Date', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $CheckOutDate = esc_html( __('Check Out Date', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $remove_x = esc_html( __('x', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $zero_days = esc_html( __('0', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		$clear_dates = esc_html( __('Clear Dates', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		$read_agree = esc_html( __(' I have read and agree to the', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		$rental_agreement = esc_html( __('rental agreement', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		$save_copy = esc_html( __('and saved a copy for my reference', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		$url = VRCALENDAR_PLUGIN_URL;
		if(@$cal_data->calendar_custom_field_name != ''){		
			$ExtraFees = esc_html( __($cal_data->calendar_custom_field_name, VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		}else{
			$ExtraFees = esc_html( __('Extra Fees', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
		} 
        
        $show_booking_from_one_page = @$cal_data->show_booking_from_one_page;
            
            $booking_form_location_style = '';
            $booking_form_location_style .= '<style> .spanhide{display:none;} </style>';
            $nbsptext = '';
            $div_vrc_calendar_wrapper_open = '';
            $div_vrc_calendar_wrapper_close = '';
            if($show_booking_from_one_page == 'yes')
            {
                if($cal_data->booking_form_location == 'next_to_call')
                {
                        $nbsptext = '&nbsp;';
                        $div_vrc_calendar_wrapper_open = '<div class="vrc-calendar-wrapper vrc-layout-inline">';
                        $div_vrc_calendar_wrapper_close = '</div>';
                }
            }

            $booking_powered_style = '';
            $checkerDay = esc_html( __('Per Night', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
            $check_in_time = '';
            $check_out_time = '';
            $valid_hourly_booking = 0;
            
            $dayNight = esc_html( __('Night', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
            if($pro_one_day_book == 'yes')
            {
                $checkerDay = esc_html( __('Per Day', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
                $dayNight = esc_html( __('day', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
            }


            if($hourly_booking == 'yes')
            {
                $booking_powered_style = 'style="width:100%; float:left;"';
                $valid_hourly_booking = 1;
                $check_in_time .= '<div class="col-sm-6">
                            <div class="form-group">
                                <label for="booking_checkin_intime">'.esc_html( __('Check In Time', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ).'</label>
                                <select name="checkintime" id="checkintime" class="form-control required" onchange="timeChange(this.value)">
                                  </select>
                            </div>
                        </div>';
                
                $check_out_time .= '<div class="col-sm-6">
                            <div class="form-group">
                                <label for="checkouttime">'.esc_html( __('Check Out Time', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ).'</label>
                                <select name="checkouttime" id="checkouttime" class="form-control required">
                                  </select>
                            </div>
                        </div>';
                
                $check_in_time .=  "<script>
                    
                    function firstDatetimeChange(inDate)
                    {
                        var timeArray = {'0' : '12:00am', '1' : '1:00am', '2' : '2:00am', '3' : '3:00am', '4' : '4:00am', '5' : '5:00am', '6' : '6:00am', '7' : '7:00am', '8' : '8:00am', '9' : '9:00am', '10' : '10:00am', '11' : '11:00am', '12' : '12:00pm', '13' : '1:00pm', '14' : '2:00pm','15' : '3:00pm', '16' : '4:00pm', '17' : '5:00pm', '18' : '6:00pm', '19' : '7:00pm', '20' : '8:00pm', '21' : '9:00pm', '22' : '10:00pm', '23' : '11:00pm'};
                        var timeKeysget = {'0' : '00:00:00', '1' : '01:00:00', '2' : '02:00:00', '3' : '03:00:00', '4' : '04:00:00', '5' : '05:00:00', '6' : '06:00:00', '7' : '07:00:00', '8' : '08:00:00', '9' : '09:00:00', '10' : '10:00:00', '11' : '11:00:00', '12' : '12:00:00', '13' : '13:00:00', '14' : '14:00:00','15' : '15:00:00', '16' : '16:00:00', '17' : '17:00:00', '18' : '18:00:00', '19' : '19:00:00', '20' : '20:00:00', '21' : '21:00:00', '22' : '22:00:00', '23' : '23:00:00'};
                        var optionInValues = ''; 
                        var calendar_id = jQuery('#cal_id').val();
                        var data = {
                                'action': 'get_updated_checkindate',
                                'cal_id': calendar_id,
                                'inDate': inDate,
                            };
                        
                            jQuery.post(vrc_data.ajax_url, data, function(response) {
                                var obj = jQuery.parseJSON( response );
                            
                            jQuery.each(obj, function(key, value) {
                                optionInValues += '<option value='+timeKeysget[key]+'>'+timeArray[key]+'</option>';
                            });
                            jQuery('#checkintime').html(optionInValues);
                            
                            timeChange(jQuery('#checkintime').val());
                        });
                    }

                    function timeChange(thisinvalue)
                        {
                            var timeArray = {'0' : '12:00am', '1' : '1:00am', '2' : '2:00am', '3' : '3:00am', '4' : '4:00am', '5' : '5:00am', '6' : '6:00am', '7' : '7:00am', '8' : '8:00am', '9' : '9:00am', '10' : '10:00am', '11' : '11:00am', '12' : '12:00pm', '13' : '1:00pm', '14' : '2:00pm','15' : '3:00pm', '16' : '4:00pm', '17' : '5:00pm', '18' : '6:00pm', '19' : '7:00pm', '20' : '8:00pm', '21' : '9:00pm', '22' : '10:00pm', '23' : '11:00pm'};
                            var timeKeysget = {'0' : '00:00:00', '1' : '01:00:00', '2' : '02:00:00', '3' : '03:00:00', '4' : '04:00:00', '5' : '05:00:00', '6' : '06:00:00', '7' : '07:00:00', '8' : '08:00:00', '9' : '09:00:00', '10' : '10:00:00', '11' : '11:00:00', '12' : '12:00:00', '13' : '13:00:00', '14' : '14:00:00','15' : '15:00:00', '16' : '16:00:00', '17' : '17:00:00', '18' : '18:00:00', '19' : '19:00:00', '20' : '20:00:00', '21' : '21:00:00', '22' : '22:00:00', '23' : '23:00:00'};

                            
                            var cal_id = jQuery('#cal_id').val();
                            var date_of_only_hourly_booking = jQuery('#date_of_only_hourly_booking').val();

                            var data = {
                                'action': 'get_updated_checkoudate',
                                'cal_id': cal_id,
                                'thisinvalue': thisinvalue,
                                'date_of_only_hourly_booking': date_of_only_hourly_booking 
                            };
                            var optionValues = '';
                            jQuery.post(vrc_data.ajax_url, data, function(response) {

                               var obj = jQuery.parseJSON( response );
                               
                                  jQuery.each(obj, function(key, value) {

                                      optionValues += '<option value='+timeKeysget[key]+'>'+timeArray[key]+'</option>';
                                    });
                                   jQuery('#checkouttime').html(optionValues);
                            });

                        }
                    </script>";
            }
			$individual_currency = @json_decode($cal_data->individual_calendar_payment);
			if(@$individual_currency->attr_currency != ''){
				$individual_currencie = $individual_currency->attr_currency;
				if($individual_currencie == 'USD'){
					$individual_currencies = '$';
				}else if($individual_currencie == 'AUD'){
					$individual_currencies = '$';
				}else{
					$individual_currencies = $individual_currencie;
				}
			}else {
				$individual_currencies = renderCurrency();
			}
			
			if($individual_currencies == "£"){
				$getRenderCurrency = "&pound;";
			}else if($individual_currencies == "€"){
				$getRenderCurrency = "&euro;";
			}else{
				$getRenderCurrency = $individual_currencies;
			}
            $lang_update = esc_html( __('Calendar Updated on', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
			
			$display_ornot = (@$cal_data->calendar_update_display == 'no') ? "style='display:none'":"";
            $lang_available = esc_html( __('Available', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
            $lang_unavailable = esc_html( __('Unavailable', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
            $last_sync_date = @get_date_from_gmt(@$cal_data->calendar_last_synchronized, 'F d, Y \a\t h:i a');
			if($dateformat == 'usa'){
				$start_dates = @$data['check_in_date'];
				$newDateString = date("m-d-Y", strtotime($start_dates));

				$last_sync_date = @get_date_from_gmt($cal_data->calendar_last_synchronized, 'F d, Y \a\t h:i a');
			}else if ($dateformat == 'euro'){
				$last_sync_date = @get_date_from_gmt($cal_data->calendar_last_synchronized, 'd F, Y \a\t h:i a');
			}else{
				$last_sync_date = @get_date_from_gmt(@$cal_data->calendar_last_synchronized, 'Y, F d \a\t h:i a');
			}
		
        //Attribution Code here which adds a Powered by VR Cal Sync under the Calendar.
        //First, make sure it is set, if its not, set it to yes by default
        $Next_arrow = esc_html( __('Next', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
        $doattribution = $VRCalendarSettings->getSettings('attribution');
        
         $textForTotal = '';
         $textForTotal .= "<div class='default_price'>Total</div>";
         $textForTotal .= "<div class='updated_price' style='display: none;'>".esc_html( __('Deposit Due Today', VRCALENDAR_PLUGIN_TEXT_DOMAIN) )." (".@$cal_data->deposit_percentage."%)</div>";
        
		if(isset($_POST['user_first_name'])){ $user_first_name = $_POST['user_first_name'];}else{ $user_first_name = ''; }
        if(isset($_POST['user_last_name'])){ $user_last_name = $_POST['user_last_name'];}else{ $user_last_name =  ''; }
		if(isset($_POST['user_email'])){ $user_email = $_POST['user_email']; }else{ $user_email = ''; }
		if(isset($_POST['user_phone'])){ $user_phone = $_POST['user_phone'];}else{ $user_phone = ''; }

        $calendar_extracharge_after_guest_no = 'style="display:none"';
        if(@$cal_data->calendar_extracharge_after_limited_guests > 0)
        {
            $calendar_extracharge_after_guest_no = 'style="display:block"';
        }
		
        $calendar_extracharge_after_child_no = 'style="display:none"';
        if(@$cal_data->calendar_extracharge_after_limited_child > 0)
        {
            $calendar_extracharge_after_child_no = 'style="display:block"';
        }
        
        $show_booking_from_one_page = @$cal_data->show_booking_from_one_page;
        $calendar_enable_booking = @$cal_data->calendar_enable_booking;
            $showFormData = 'style="display:none"';
            if($show_booking_from_one_page == 'yes' && $calendar_enable_booking == "yes")
                $showFormData = 'style="display:block"';
        
        if (!isset($doattribution)) {
            $doattribution = 'yes';}
        
        //Next, If attribution is desired print it, otherwise print blank string
        if ($doattribution == 'yes'){
            $printattribution = "<div class=\"calendar-info\">".esc_html( __('Powered By', VRCALENDAR_PLUGIN_TEXT_DOMAIN) )." <a href=\"http://www.vrcalendarsync.com\" target=\"_blank\">".esc_html( __('Vacation Rental Calendar Sync', VRCALENDAR_PLUGIN_TEXT_DOMAIN) )."</a></div>";
        } else {
            $printattribution = "";}
        $calendar_display_num_months = 0;
        if(@$cal_data->calendar_display_num_months > 0){
			$calendar_display_num_months = $cal_data->calendar_display_num_months;
			$navigation_block = '';
			if($cal_data->calendar_display_num_months <= 12){
				$navigation_block = 'display:none;';
			}else{
				$navigation_block = 'display:block;';
			}
		}else{
			$calendar_display_num_months = 36 ;
		}
		$captchaImg = VRCALENDAR_PLUGIN_URL.'Public/captcha.php';
		$submitNewClass = '';
		$captchaOption = '';
		$recaptchaHtml = '';
		$recaptchaDisplay = '';
		if(@$cal_data->calendar_recaptcha == 'yes'){
			$btnType = "button";
			$submitNewClass = 'onclick="javascript:get_action(this);"';
			if($VRCalendarSettings->getSettings('re_sitekey') == ""){
				$errorkey = "<div class='errorcaptkey'>You must add the SITE KEY from reCaptcha to enable this feature!</div>";
			}else{
				$errorkey = "<div id='rcaptcha'></div>";
			}
			$recaptchaDisplay = 'display:table-row;';
			$captchaScript = '
			<script>
			var verifyCallback = function(v) {
				if(v.length != 0)
				{
					document.getElementById("captcha").innerHTML = "";
					jQuery("#vrc_pcmd").val("saveBooking");
					jQuery("#checkseasonal").attr("type","submit");
				}else{
					document.getElementById("captcha").innerHTML = "You cant leave Captcha Code empty";
					jQuery("#vrc_pcmd").val("");
					jQuery("#checkseasonal").attr("type","button");
					return false;
				}
				};
				var onloadCallback = function() {
					grecaptcha.render("rcaptcha", {
					  "sitekey" : jQuery("#sitekey").val(),
					  "callback" : verifyCallback,
					  theme : "light"
					});
				};

				function get_action(form) {
					var v = grecaptcha.getResponse();
					//alert(v);
					
					if(v.length != 0)
					{
						jQuery("#vrc_pcmd").val("saveBooking");
						form.submit();
					}else{
						document.getElementById("captcha").innerHTML = "You cant leave Captcha Code empty";
						jQuery("#vrc_pcmd").val("");
						jQuery("#checkseasonal").attr("type","button");
						return false;
					}
				}
				</script>
				<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
			';
		}else{
			$btnType = "submit";
			$captchaOption = "saveBooking";
			$recaptchaDisplay = 'display:none;';
		}
		// $VRCalendar = VRCalendar::getInstance();
		$months_per_page = @$cal_data->calendar_layout_options['rows'] * @$cal_data->calendar_layout_options['columns'];

		if($months_per_page > 0){
			$months_per_page = $months_per_page;
		}else{
			$months_per_page = 12;
		}
		$headout = '';
        $pages = @ceil($calendar_display_num_months / $months_per_page);

		//echo $pages;
		$headout .= '<input type="hidden" value="'.$pages.'" class="total_pages">';
		$headout .= '<input type="hidden" id="sitekey" value="'.$VRCalendarSettings->getSettings('re_sitekey').'">';
        $calendar_html = getCalendar($cal_data, 1);
		
        $calendar_css = getCalendarCSS($cal_data);
		$calendar_name = @$cal_data->calendar_name;
        $uid = uniqid();
		
		if(@$cal_data->deposit_enable == 'no'){
			$customhtml = '<td>'.$getRenderCurrency.'<span id="table-booking-price-with-taxes" class="finaltotal" >'.$zero_value.'</span></td>';	
		}else{
			$customhtml = '<td>'.$getRenderCurrency.'<span id="table-booking-price-with-taxes" class="customupdatedprice">'.$zero_value.'</span></td>';
		}

		if($cal_data->calendar_rental_agreement_option == "upload_pdf"){
			$rental_agreement = content_url().$cal_data->calendar_agreement_attachment;
		}else{
			$rental_agreement = $cal_data->calendar_agreement_attachment;
		}

		$agreement_attachment_url = (@$cal_data->calendar_rental_agreement_required == 'yes')?$cal_data->calendar_agreement_attachment:'';
		$rental_agreement_text = "<input type='checkbox' name='rental_agreement_approval'> {$read_agree} <a href='".$rental_agreement."' target='_blank'>{$rental_agreement}</a> {$save_copy}.<input type='hidden' value='".$agreement_attachment_url."' name='calendar_agreement_value'>";
		
		$calendarSetTaxperStay = @$cal_data->calendar_set_taxperstay;
		if($calendarSetTaxperStay == 'no'){
			$setNo = 'style="display:none;"';
		}
		$calendar_tax_charge = @$cal_data->calendar_tax_charge;
		if($calendar_tax_charge == 'no'){
			$setNoperperson = 'style="display:none;"';
		}
		$calendarSetGuestFees = @$cal_data->calendar_set_guestfee;
		if($calendarSetGuestFees == 'no'){
			$setNoGuest = 'style="display:none;"';
		}
		$calendarSetChildFees = @$cal_data->calendar_set_childfee;
		if($calendarSetChildFees == 'no'){
			$setNoChild = 'style="display:none;"';
		}
		
		if(@$cal_data->calendar_persons_option == "yes"){
			$maxChild = @$cal_data->calendar_max_child_no;
		}else{
			$maxChild = @$cal_data->calendar_max_guest_no;
		}
		
		if(@$cal_data->calendar_child_field == "yes"){
			$col = "col-sm-6";
			$field = "";
			$value = $cal_data->calendar_max_child_no;
			$label = "Adults";
		}else{
			$col = "col-sm-12";
			$field = "hide";
			$value = "0";
			$label = "Guest";
		}
		if(@$cal_data->calendar_set_title == "no"){
			$settitle = "display:none;";
		}else{
			$settitle = "";
		}
		//$headout .= '<div class="please_wait" style="margin: 0 auto; width: 100%; display: block;position: absolute;top: 0;left: 0;height: 100%;z-index: 1;background: #fff;opacity: 0.5;"><img src="'. VRCALENDAR_PLUGIN_URL .'/assets/images/spinner.gif" alt="Smiley face" height="35" width="35"></div>';
		$titlecolor = @$cal_data->calendar_layout_options['default_form_font_color'];
		$formheadercolor = @$cal_data->calendar_layout_options['default_form_bg_color'];
        //$show_booking_from_one_page = $cal_data->show_booking_from_one_page;
        $onepagevalue = 1;
        // if($show_booking_from_one_page == 'yes')
            // $onepagevalue = 1;

        $output = <<<E
{$div_vrc_calendar_wrapper_open}                
<div class="vrc vrc-calendar vrc-calendar-id-{$calid}" id="vrc-calendar-uid-{$uid}">
	<div id ="indicator-single-{$calid}" style="margin: 0 auto; width: 100%; display: none;position: absolute;top: 0;left: 0;height: 100%;z-index: 999;background: #fff;opacity: 0.5;">
		<img src="{$url}/assets/images/spinner.gif" alt="Smiley face" height="35" width="35">
	</div>
	<div id ="indicator-single-form-{$calid}" style="margin: 0 auto; width: 100%; display: none;position: absolute;top: 0;left: 0;height: 100%;z-index: 999;background: #fff;opacity: 0.5;">
		<img src="{$url}/assets/images/spinner.gif" alt="Smiley face" height="35" width="35">
	</div>
    <div class="calendar-header">
        <div class="avail_labl">
			<input type="hidden" name="onepagevalue" id="onepagevalue" value="$onepagevalue" />
			<input type="hidden" name="nextpage" id="nextpage" value="1" />
			<input type="hidden" name="valid_hourly_booking" id="valid_hourly_booking" value="0">
			<input type="hidden" class="changedateformat" name="changedateformat" value="{$dateformat}">
			<input type="hidden" name="cal_id" class="admin_calendar_id" value="{$calid}">
			<input type="hidden" value="1" class="next_page-{$calid}">
			<input type="hidden" name="valid_hourly_booking" id="valid_hourly_booking" value="0">
			<input type="hidden" class="changedateformat" name="changedateformat" value="{$dateformat}">
			<div class="blockdate_input">
				<div class="label_lft">
					<div class="color-label">
						<div class="color-label_text">
							<div class="color-label_box" style="background:#ec1919">
							</div>
							<div class="color-label_info">
								Website Blocked
							</div>
							<div class="color-label_box" style="background:#e66">
							</div>
							<div class="color-label_info">
								ICS link Blocked
							</div>
							<div class="color-label_box" style="background:#e96">
							</div>
							<div class="color-label_info">
								ICS link Reserved
							</div>
							<div class="color-label_box" style="background:#8fb5ff">
							</div>
							<div class="color-label_info">
								Booking Confirmed
							</div>
							<div class="color-label_box" style="background:#45a859">
							</div>
							<div class="color-label_info">
								Booking Approval Needed
							</div>
						</div>
					</div>
				</div>
				<div class="label_rgt">
					<div class="block_date_enable">
						<input type="button" id="blockdates_show" class="form-control blockdates_btn" value="Block Dates?">
						<input type="button" id="addbooking_show" class="form-control bookdates_btn" value="Add Booking?">
					</div>
					<div class="input_date hide">
						<input type="text" class="form-control required" name="blockin_date" id="booking_checkin_date" value="" placeholder="Check In Date" aria-required="true" aria-invalid="false" readonly>
						<input type="text" class="form-control required" name="blockout_date" id="booking_checkout_date" value="" placeholder="Check Out Date" aria-required="true" readonly><input type="button" id="blockdates_cancel" class="form-control blockdates_btn" value="Cancel">
					</div>
					<div class="input_date_booking hide">
						<input type="text" class="form-control required" name="blockin_date" id="add_booking_checkin_date" value="" placeholder="Check In Date" aria-required="true" aria-invalid="false" readonly>
						<input type="text" class="form-control required" name="blockout_date" id="add_booking_checkout_date" value="" placeholder="Check Out Date" aria-required="true" readonly><input type="button" id="bookdates_cancel" class="form-control blockdates_btn" value="Cancel">
					</div>
				</div>
			</div>
        </div>
    </div>
	<div class="head-indicator">
		<div class="calendar-month-name">{$month_year_name}</div>
        <div class="btn-labl">
			<div class="btn-nextprev">
				<div class="button_calaner_header">
					<div class="customNavigation">
						<a class="a1 btn-prev-single-{$calid} pull-left" style="cursor:pointer;width: 30px;height: 30px;">&nbsp;</a> <a class="a2 btn-next-single-{$calid} pull-right" style="cursor:pointer;width: 30px;height: 30px;">&nbsp;</a>
					</div>
				</div>
			</div>
        </div>
	</div>
    <div class="calendar-slides calid-{$calid}">
        {$calendar_html}
    </div>
</div>
<script>
	jQuery(".vrc-calendar .btn-select_month-single-{$calid}").change(function(){

		jQuery("#indicator-single-{$calid}").show();

		var id = '{$calid}';

		var calendar = jQuery('.calendar-month-name').html();

		var next_page = parseInt(jQuery(this).val());
		
		var next_page_no  = next_page;
		
		jQuery("#nextpage").val(next_page_no);
		var detailresponseurl = '{$siteurl}';

		jQuery.ajax({

			type : "post",

			dataType : "html",

			url : detailresponseurl,

			data : {action: "getSingleCalendarCustomAdmin", calendar: calendar, type: 'next',id:id, next_page:next_page_no },

			success: function(response) {

				jQuery('.calid-{$calid}').html(response);
				
				if(jQuery(".block_date_enable").hasClass("hide")){
					jQuery(".no-event-day").addClass("enable_block");
				}
				if(!jQuery(".input_date_booking").hasClass("hide")){
					jQuery(".no-event-day").addClass("enable_add");
				}

				jQuery("#indicator-single-{$calid}").hide();
				var next_cal_page = next_page;
				jQuery("#nextpage").val(next_cal_page);
				
					var chkindate = jQuery('#booking_checkin_date').val();
					var chkoutdate = jQuery('#booking_checkout_date').val();
					if(isNaN(chkindate)){
						jQuery(".single-calendar table tr td div[data-booking-date='" + chkindate + "']").addClass('hasClicked');
					}
					if(isNaN(chkoutdate)){
						jQuery(this).addClass('hasClicked');
						var dateformat = jQuery('.changedateformat').val();
						if(dateformat == 'euro'){
							var fordatein = chkindate.split("-");
							var fordateout = chkoutdate.split("-");
							var d_in = fordatein[0];
							var m_in = fordatein[1];
							var y_in = fordatein[2];
							
							var d_out = fordateout[0];
							var m_out = fordateout[1];
							var y_out = fordateout[2];
							
							var chkin = y_in+m_in+d_in;
							var chkout = y_out+m_out+d_out;
							
						}else if (dateformat == 'usa'){
							var fordatein = chkindate.split("-");
							var fordateout = chkoutdate.split("-");
							var m_in = fordatein[0];
							var d_in = fordatein[1];
							var y_in = fordatein[2];
							
							var m_out = fordateout[0];
							var d_out = fordateout[1];
							var y_out = fordateout[2];
							var chkin = y_in+m_in+d_in;
							var chkout = y_out+m_out+d_out;
						}else {
							var fordatein = chkindate.split("-");
							var fordateout = chkoutdate.split("-");
							var y_in = fordatein[0];
							var m_in = fordatein[1];
							var d_in = fordatein[2];
							
							var y_out = fordateout[0];
							var m_out = fordateout[1];
							var d_out = fordateout[2];
							
							var chkin = y_in+m_in+d_in;
							var chkout = y_out+m_out+d_out;
						}
						//console.log(chkin);
						
						//$(this).addClass('hasClicked');
						jQuery(".day-number").removeClass('hasClicked');
						
						for(var get_d = parseInt(chkin); get_d <= parseInt(chkout); get_d++){
							jQuery(".single-calendar table tr td div[date-highlight='" + get_d + "']").addClass('hasClicked');
						}
					}
				
				jQuery('.next_page-{$calid}').val(next_cal_page);
				 load_js();

			}

		});

	});
	
	jQuery(".vrc-calendar .btn-next-single-{$calid}").click(function(){

		jQuery("#indicator-single-{$calid}").show();

		var id = '{$calid}';

		var calendar = jQuery('.calendar-month-name').html();

		var next_page = parseInt(jQuery('.next_page-{$calid}').val());
		
		var next_page_no  = next_page+1;
		
		var total_pages = parseInt(jQuery('.total_pages').val());
		if(total_pages == next_page){
			next_page_no = 1;
		}
		if(next_page_no > {$num_months}+1){
			next_page_no = 1;
		}
		jQuery("#nextpage").val(next_page_no);
		var detailresponseurl = '{$siteurl}';

		jQuery.ajax({

			type : "post",

			dataType : "html",

			url : detailresponseurl,

			data : {action: "getSingleCalendarCustomAdmin", calendar: calendar, type: 'next',id:id, next_page:next_page_no },

			success: function(response) {

				jQuery('.calid-{$calid}').html(response);

				jQuery("#indicator-single-{$calid}").hide();
				var next_cal_page = next_page + 1;
				if(total_pages == next_page){
					next_cal_page = 1;
				}
				if(next_cal_page > {$num_months}+1){
					next_cal_page = 1;
				}
				
				if(!jQuery(".input_date").hasClass("hide")){
					jQuery(".no-event-day").addClass("enable_block");
				}
				
				if(!jQuery(".input_date_booking").hasClass("hide")){
					jQuery(".no-event-day").addClass("enable_add");
				}
				
				jQuery("#select_month").val(next_cal_page).attr("selected","selected");
				jQuery("#nextpage").val(next_cal_page);
				
					var chkindate = jQuery('#booking_checkin_date').val();
					var chkoutdate = jQuery('#booking_checkout_date').val();
					if(isNaN(chkindate)){
						jQuery(".single-calendar table tr td div[data-booking-date='" + chkindate + "']").addClass('hasClicked');
					}
					if(isNaN(chkoutdate)){
						jQuery(this).addClass('hasClicked');
						var dateformat = jQuery('.changedateformat').val();
						if(dateformat == 'euro'){
							var fordatein = chkindate.split("-");
							var fordateout = chkoutdate.split("-");
							var d_in = fordatein[0];
							var m_in = fordatein[1];
							var y_in = fordatein[2];
							
							var d_out = fordateout[0];
							var m_out = fordateout[1];
							var y_out = fordateout[2];
							
							var chkin = y_in+m_in+d_in;
							var chkout = y_out+m_out+d_out;
							
						}else if (dateformat == 'usa'){
							var fordatein = chkindate.split("-");
							var fordateout = chkoutdate.split("-");
							var m_in = fordatein[0];
							var d_in = fordatein[1];
							var y_in = fordatein[2];
							
							var m_out = fordateout[0];
							var d_out = fordateout[1];
							var y_out = fordateout[2];
							var chkin = y_in+m_in+d_in;
							var chkout = y_out+m_out+d_out;
						}else {
							var fordatein = chkindate.split("-");
							var fordateout = chkoutdate.split("-");
							var y_in = fordatein[0];
							var m_in = fordatein[1];
							var d_in = fordatein[2];
							
							var y_out = fordateout[0];
							var m_out = fordateout[1];
							var d_out = fordateout[2];
							
							var chkin = y_in+m_in+d_in;
							var chkout = y_out+m_out+d_out;
						}
						//console.log(chkin);
						
						//$(this).addClass('hasClicked');
						jQuery(".day-number").removeClass('hasClicked');
						
						for(var get_d = parseInt(chkin); get_d <= parseInt(chkout); get_d++){
							jQuery(".single-calendar table tr td div[date-highlight='" + get_d + "']").addClass('hasClicked');
						}
					}
				
				jQuery('.next_page-{$calid}').val(next_cal_page);
				 load_js();

			}

		});

	});
	
	jQuery(".vrc-calendar .btn-prev-single-{$calid}").click(function(){

		jQuery("#indicator-single-{$calid}").show();

		var id = '{$calid}';

		var calendar = jQuery('.calendar-month-name').html();

		var next_page = parseInt(jQuery('.next_page-{$calid}').val());
		
		var next_page_no  = next_page-1;
		
		if(next_page_no < 1){
			next_page_no = 1;
		}
		jQuery("#nextpage").val(next_page_no);
		var detailresponseurl = '{$siteurl}';

		jQuery.ajax({

			type : "post",

			dataType : "html",

			url : detailresponseurl,

			data : {action: "getSingleCalendarCustomAdmin", calendar: calendar, type: 'next',id:id, next_page:next_page_no },

			success: function(response) {

				jQuery('.calid-{$calid}').html(response);

				jQuery("#indicator-single-{$calid}").hide();
				var next_cal_page = next_page-1;
				
				if(next_cal_page < 1){
					next_cal_page = 1;
				}
				
				if(!jQuery(".input_date").hasClass("hide")){
					jQuery(".no-event-day").addClass("enable_block");
				}
				
				if(!jQuery(".input_date_booking").hasClass("hide")){
					jQuery(".no-event-day").addClass("enable_add");
				}
				
				jQuery("#select_month").val(next_cal_page).attr("selected","selected");
				jQuery("#nextpage").val(next_cal_page);
				
					var chkindate = jQuery('#booking_checkin_date').val();
					var chkoutdate = jQuery('#booking_checkout_date').val();
					if(isNaN(chkindate)){
						jQuery(".single-calendar table tr td div[data-booking-date='" + chkindate + "']").addClass('hasClicked');
					}
					if(isNaN(chkoutdate)){
						jQuery(this).addClass('hasClicked');
						var dateformat = jQuery('.changedateformat').val();
						if(dateformat == 'euro'){
							var fordatein = chkindate.split("-");
							var fordateout = chkoutdate.split("-");
							var d_in = fordatein[0];
							var m_in = fordatein[1];
							var y_in = fordatein[2];
							
							var d_out = fordateout[0];
							var m_out = fordateout[1];
							var y_out = fordateout[2];
							
							var chkin = y_in+m_in+d_in;
							var chkout = y_out+m_out+d_out;
							
						}else if (dateformat == 'usa'){
							var fordatein = chkindate.split("-");
							var fordateout = chkoutdate.split("-");
							var m_in = fordatein[0];
							var d_in = fordatein[1];
							var y_in = fordatein[2];
							
							var m_out = fordateout[0];
							var d_out = fordateout[1];
							var y_out = fordateout[2];
							var chkin = y_in+m_in+d_in;
							var chkout = y_out+m_out+d_out;
						}else {
							var fordatein = chkindate.split("-");
							var fordateout = chkoutdate.split("-");
							var y_in = fordatein[0];
							var m_in = fordatein[1];
							var d_in = fordatein[2];
							
							var y_out = fordateout[0];
							var m_out = fordateout[1];
							var d_out = fordateout[2];
							
							var chkin = y_in+m_in+d_in;
							var chkout = y_out+m_out+d_out;
						}
						//console.log(chkin);
						
						//$(this).addClass('hasClicked');
						jQuery(".day-number").removeClass('hasClicked');
						
						for(var get_d = parseInt(chkin); get_d <= parseInt(chkout); get_d++){
							jQuery(".single-calendar table tr td div[date-highlight='" + get_d + "']").addClass('hasClicked');
						}
					}
				
				jQuery('.next_page-{$calid}').val(next_cal_page);
				 load_js();

			}

		});

	});
				
	function load_js(){

		  var head= document.getElementsByTagName('head')[0];

		  var script= document.createElement('script');

		  script.type= 'text/javascript';

		  script.src='{$dir}assets/js/public.js?ver=1.0.0';

		  head.appendChild(script);

	   };
</script>
{$div_vrc_calendar_wrapper_close}
{$calendar_css}
E;
;

echo $output;
}else{
	?>
	<div class="license_error">
	<?php
		echo esc_html( __('This is for Pro/Enterprise Version or check your License if Expired! Please Renew or Upgrade.', VRCALENDAR_PLUGIN_TEXT_DOMAIN) );
	?>
	</div>
	<?php
}

function getCalendarCSS($cal_data) {
	$dir = VRCALENDAR_PLUGIN_URL;
	$cal_id = @$cal_data->calendar_id;
	$options = @$cal_data->calendar_layout_options;

        $style = <<<E
<style>
	#my-calendar .day-number{
		position: relative;
		font-weight: 600;
	}
	#my-calendar .pull-left{
		float: left;
	}
	#my-calendar .pull-right{
		float: right;
	}
	#my-calendar #select_month {
		padding: 5px 30px 5px 10px !important;
	}
	#my-calendar .head-indicator {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 10px 0;
	}
	#my-calendar .btn-nextprev .customNavigation a.a1 {
		background: url("{$dir}assets/images/arrow_left.png") center center no-repeat;
	}
	#my-calendar .btn-nextprev .customNavigation a.a2 {
		background: url("{$dir}assets/images/arrow_right.png") center center no-repeat;
	}
	#my-calendar .customNavigation {
		z-index: 9;
		position: relative;
		display: flex;
	}
	#my-calendar .blockdate_input {
		display: flex;
		flex-direction: row-reverse;
		align-items: center;
		width: 100% !important;
		justify-content: space-between;
	}
	#my-calendar .color-label_text {
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	#my-calendar .color-label_text .color-label_info {
		padding: 5px;
		font-size: 14px;
		margin-right: 5px;
	}
	#my-calendar .color-label_text .color-label_box {
		width: 25px;
		height: 25px;
	}
	#my-calendar .has-booking.last-data{
		background: linear-gradient(135deg, #8fb5ff 50%,transparent 50%,transparent 100%);
	}
	#my-calendar .has-booking.first-data{
		background: linear-gradient(135deg, transparent, transparent, transparent, transparent, transparent, #fff 8.5%, #8FB5FF 0);
	}
	#my-calendar .has-approve.last-data{
		background: linear-gradient(135deg, #45a859 50%,transparent 50%,transparent 100%);
	}
	#my-calendar .has-approve.first-data{
		background: linear-gradient(135deg, transparent, transparent, transparent, transparent, transparent, #fff 8.5%, #45a859 0);
	}
	#my-calendar .has-reserved_ics.last-data{
		background: linear-gradient(135deg, #e96 50%,transparent 50%,transparent 100%);
	}
	#my-calendar .has-reserved_ics.first-data{
		background: linear-gradient(135deg, transparent, transparent, transparent, transparent, transparent, #fff 8.5%, #e96 0);
	}
	#my-calendar .has-blocksite.last-data{
		background: linear-gradient(135deg, #ec1919 50%,transparent 50%,transparent 100%);
	}
	#my-calendar .has-blocksite.first-data{
		background: linear-gradient(135deg, transparent, transparent, transparent, transparent, transparent, #fff 8.5%, #ec1919 0);
	}
	#my-calendar .has-blocked_ics.last-data {
		background: linear-gradient(135deg, #e66 50%,transparent 50%,transparent 100%);
	}
	#my-calendar .has-blocked_ics.first-data {
		background: linear-gradient(135deg, transparent, transparent, transparent, transparent, transparent, #fff 8.5%, #e66 0);
	}
	#my-calendar .has-booking,
	#my-calendar .has-approve,
	#my-calendar .has-reserved_ics,
	#my-calendar .has-blocksite,
	#my-calendar .has-blocked_ics {
		position: absolute;
		left: 0;
		width: 100%;
		padding: 1px;
		color: #fff !important;
	}
	#my-calendar .has-booking {
		top: 24px;
		background: #8fb5ff;
	}
	#my-calendar .has-approve {
		top: 24px;
		background: #45a859;
	}
	#my-calendar .has-blocked_ics {
		background: #e66;
		top: 55px;
	}
	#my-calendar .has-blocksite {
		background: #ec1919;
		top: 55px;
	}
	#my-calendar .has-reserved_ics {
		background: #e96;
		top: 80px;
	}
	#my-calendar .list-day {
		z-index: 99;
		position: absolute;
		top: 0;
		right: 0;
		padding: 5px;
		margin-right: 10px;
	}
	.first-data {
		z-index: 1;
	}
	#my-calendar #indicator-single-{$cal_id} img, 
	.please_wait img,
	#my-calendar #indicator-single-form-{$cal_id} img{
		top: 50%;
		position: relative;
		opacity: 1;
		display: block;
		margin: 0 auto;
	}
	#my-calendar .calendar tr td.calendar-day-np {
		background: #f7f7f7;
		color: #3e3e3e;
	}
	#my-calendar .enable_block:hover {
		background: #f9f9f9;
	}
	#my-calendar .no-event-day.enable_block.hasClicked .list-day {
		color: #fff !important;
	}
	#my-calendar .no-event-day.enable_block {
		cursor: pointer !important;
	}
	#my-calendar .enable_add:hover {
		background: #f9f9f9;
	}
	#my-calendar .no-event-day.enable_add.hasClicked .list-day {
		color: #fff !important;
	}
	#my-calendar .no-event-day.enable_add {
		cursor: pointer !important;
	}
	#my-calendar .no-event-day {
		cursor: no-drop;
	}
	#my-calendar .vrc {
		position: relative;
	}
	#my-calendar .avail_labl, .date_update {
		position: relative;
		z-index: 2;
		width: 100%;
	}
	#my-calendar .booking-details:hover {
		opacity: 0.8;
	}
	#my-calendar .booking-details {
		cursor: pointer;
		color: #fff !important;
	}
	.vrc.vrc-calendar .calendar-header .btn-prev-single-{$cal_id},
	.vrc.vrc-calendar .calendar-header .btn-next-single-{$cal_id} {
		display: block;
		width: 30px;
		height: 30px;
		text-indent: -99999px;
		cursor: pointer;
		text-decoration: none;
		border: none;
	}
	.vrc.vrc-calendar .calendar-month-container table tr td {
		padding: 0;
	}
	#my-calendar .calendar tr td {
		text-align: center;
		height: 40px;
		border: 1px solid #ccc;
		vertical-align: middle;
	}
	#my-calendar .calendar {
		width: 100%;
		padding-top: 20px;
	}
	#my-calendar .day-number.event-day.day-past {
		background: #f7f7f7 !important;
	}
	#my-calendar .calendar tr td .event-day,
	#my-calendar .calendar tr td .day-number,
	#my-calendar .calendar tr td .event-start,
	#my-calendar .calendar tr td .no-event-day,
	#my-calendar .calendar tr td .start-end-day {
		padding: 40px;
		min-height: 70px;
	}
	#my-calendar .vrc-calendar-id-{$cal_id}{
		display: flex;
		flex-direction: column;
	}
	#my-calendar .calendar-header {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 0 0 15px 0;
	}
	#my-calendar .blockdate_input input.blockdates_btn:hover,
	#my-calendar .blockdate_input input.bookdates_btn:hover {
		opacity: 0.9;
	}
	#my-calendar .blockdate_input input.bookdates_btn {
		min-height: 40px;
		background: #328f44;
		border: none;
		padding: 0 20px;
		color: #fff !important;
		cursor: pointer;
		font-weight: 500;
	}
	#my-calendar .blockdate_input input.blockdates_btn {
		min-height: 40px;
		background: #dd5b3d;
		border: none;
		padding: 0 20px;
		color: #fff !important;
		cursor: pointer;
		font-weight: 500;
	}
	#my-calendar .calendar-slides.calid-{$cal_id} {
		padding: 0 0 30px 0;
	}
	#my-calendar .ui-datepicker-inline.ui-datepicker.ui-widget.ui-widget-content.ui-helper-clearfix.ui-corner-all {
		display: none !important;
	}
    #my-calendar .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} .calendar-month-container {
        background:{$options['default_bg_color']};
        color:{$options['default_font_color']};
        border-color:{$options ['calendar_border_color']};
		position: relative;
		padding: 0 30px 30px;
    }
    .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} * {
        color:#5e5e5e;
        //color:{$options['default_font_color']};
    }
    .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} td.calendar-day-head {
        background: #5e5e5e;
		color: #fff;
		font-weight: 600;
		// background:{$options['week_header_bg_color']};
        // color:{$options['week_header_font_color']};
    }
    .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} td.calendar-day .day-number,
    .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} .day-number{
        background: #fff;
        color: #5e5e5e;
    }
    .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} td.calendar-day .day-number.hasClicked{
        background:{$options['sel_highlight_bg_color']} !important;
		color:{$options['sel_highlight_font_color']};
    }
    .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} td.calendar-day .day-number.event-day,
     .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} .day-number.event-day{
        background: #fff;
        //color: #3e3e3e;
    }
    .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} td.calendar-day .day-number.event-start {
        background: #fff;
        //color: #3e3e3e;
    }
    .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} td.calendar-day .day-number.event-end {
        background: #fff;
        //color: #3e3e3e;
    }
    .vrc.vrc-calendar.vrc-calendar-id-{$cal_id} td.calendar-day .day-number.start-end-day {
		background: #fff;
		//color: #3e3e3e;
    }
</style>
E;
        return $style;
    }

    function getCalendar($cal_data, $months,$next_page = 0) {
		// echo $cal_data->calendar_name;
		
        $calendar_html = '';

        $months_per_page =  1;

        $pages = ceil($months / $months_per_page);
		$show_months = $months_per_page-1;
        $next_month = 0;
        $page = 0;
		if($next_page){
			$show_months = $next_page*$months_per_page - 1;
			$next_month = ($next_page - 1) * $months_per_page;
		}
        while($page < $pages) {
            $calendar_html .= '<div class="calendar-page" >';
            for($row=1; $row<=@$cal_data->calendar_layout_options['rows'] && $next_month<=$show_months; $row++) {
                $calendar_html .= '<div class="row">';
                for($col=1; $col<=$cal_data->calendar_layout_options['columns'] && $next_month<=$show_months; $col++) {
                    //$next_data = date('Y-m-d', strtotime("+{$next_month} months"));
                    $next_data = date('Y-m-d', mktime(0, 0, 0, date('m')+$next_month, 1, date('Y')));
                    $month = date('n', strtotime($next_data));
                    $year =  date('Y', strtotime($next_data));
					$col_class = '';
					if($cal_data->calendar_layout_options['columns']){
						$col_class = floor(12/$cal_data->calendar_layout_options['columns']);
					}
                    $calendar_html .= '<div class="col-md-'.$col_class.'">';
                    $calendar_html .= getMonthCalendar($cal_data, $month, $year);
                    $calendar_html .= '</div>';
                    $next_month++;
                }
                $calendar_html .= '</div>';
            }
            $calendar_html .= '</div>';
            $page++;
        }

        return $calendar_html;
    }

    function getstatusOfCalender($calendar_id, $cDate)
    {
       
        $timeArray = array('0' => esc_html( __('12:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '1' => esc_html( __('1:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '2' => esc_html( __('2:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '3' => esc_html( __('3:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '4' => esc_html( __('4:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '5' => esc_html( __('5:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '6' => esc_html( __('6:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '7' => esc_html( __('7:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '8' => esc_html( __('8:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '9' => esc_html( __('9:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '10' => esc_html( __('10:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '11' => esc_html( __('11:00am', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '12' => esc_html( __('12:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '13' => esc_html( __('1:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '14' => esc_html( __('2:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),'15' => esc_html( __('3:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '16' => esc_html( __('4:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '17' => esc_html( __('5:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '18' => esc_html( __('6:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '19' => esc_html( __('7:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '20' => esc_html( __('8:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '21' => esc_html( __('9:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '22' => esc_html( __('10:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '23' => esc_html( __('11:00pm', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ));
        $timeKeysget = array('0' => esc_html( __('00:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '1' => esc_html( __('01:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '2' => esc_html( __('02:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '3' => esc_html( __('03:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '4' => esc_html( __('04:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '5' => esc_html( __('05:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '6' => esc_html( __('06:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '7' => esc_html( __('07:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '8' => esc_html( __('08:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '9' => esc_html( __('09:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '10' => esc_html( __('10:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '11' => esc_html( __('11:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '12' => esc_html( __('12:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '13' => esc_html( __('13:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '14' => esc_html( __('14:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),'15' => esc_html( __('15:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '16' => esc_html( __('16:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '17' => esc_html( __('17:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '18' => esc_html( __('18:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '19' => esc_html( __('19:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '20' => esc_html( __('20:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '21' => esc_html( __('21:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '22' => esc_html( __('22:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ), '23' => esc_html( __('23:00:00', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ));

       global $wpdb;
        $table_name = $wpdb->prefix . 'vrcalandar_bookings';
        $results = $wpdb->get_results( "SELECT booking_date_from, booking_date_to FROM $table_name WHERE (booking_admin_approved = 'yes' AND booking_calendar_id = '".$calendar_id."') AND DATE(booking_date_to) <= '".$cDate."'", OBJECT );
        
		if(count($results) > 0)
        {
            $arrayinTimes = array();
                foreach($results as $gettimes)
                {
                    foreach($timeKeysget as $key => $timeget)
                    {
						$VRCalendarEntity = VRCalendarEntity::getInstance();
						$cal_data = $VRCalendarEntity->getCalendar($calendar_id);

						$hoursbookingdiifference = $cal_data->hoursbookingdiifference;
						
                        $dates1 = date("H:i:s", strtotime('+'.$hoursbookingdiifference.' hours', strtotime($gettimes->booking_date_to)));
                        $dates2 = date("H:i:s", strtotime('-'.$hoursbookingdiifference.' hours', strtotime($gettimes->booking_date_from)));


                        if(date("Y-m-d", strtotime('-'.$hoursbookingdiifference.' hours', strtotime($gettimes->booking_date_from))) == @$_GET['bdate']){
                            if(strtotime($dates2) > strtotime($timeget)){
                                $arrayinTimes[$key] = $timeget;
                            }else if(strtotime($dates1) <= strtotime($timeget)){
                                $arrayinTimes[$key] = $timeget;
                            }
                        }else{
                                if(strtotime($dates2) > strtotime($timeget)){
                                    $arrayinTimes[$key] = $timeget;
                                }else if(strtotime($dates1) < strtotime($timeget)){
                                    $arrayinTimes[$key] = $timeget;
                                }
                        }
                    }
                }
                if(count($arrayinTimes) > 0)
                {
                    return 1;
                }
                else {
                    return 0;
                }
        } 
        else {
            return 0;
        }
    }
    function seasonalDays($from_date, $to_date){

       // $from_date = new DateTime($from_date);
        //$to_date = new DateTime($to_date);
        $startDate = new DateTime($from_date);
        $endDate = new DateTime($to_date);

        $sundays = array();

        while ($startDate <= $endDate) {
            if ($startDate->format('w') == 0) {
                $sundays[] = $startDate->format('Y-m-d');
            }

            $startDate->modify('+1 day');
        }
        var_dump($sundays);

    }

    function getMonthCalendar($cal_data, $month, $year) {
        
        $bookingCalendarIds = $cal_data->calendar_id;
        global $wpdb;
        $unable_dates = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}vrcalandar_unable_booking` WHERE `booking_calendar_id` = '".$bookingCalendarIds."'");
        
		$VRCalendarSettings = VRCalendarSettings::getInstance();
		$dateformat = $VRCalendarSettings->getSettings('dateformat');
		
        $VRCalendarBooking = VRCalendarBooking::getInstance();
        $VRCalendarEntity = VRCalendarEntity::getInstance();

        $month_name = date_i18n('F', strtotime("{$year}-{$month}-1"));
        $year_name = date_i18n('Y', strtotime("{$year}-{$month}-1"));
		
        /* draw table */
        $calendar = '<table cellpadding="0" cellspacing="0" class="calendar">';
		
		$day_start = $VRCalendarSettings->getSettings('day_start');
		if($day_start == "Sat"){
			$headings = array(
				esc_html( __('Sat', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Sun', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Mon', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Tue', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Wed', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Thu', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Fri', VRCALENDAR_PLUGIN_TEXT_DOMAIN) )
			);
			$date_value = 2;
		}elseif($day_start == "Mon"){
			$headings = array(
				esc_html( __('Mon', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Tue', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Wed', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Thu', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Fri', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Sat', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Sun', VRCALENDAR_PLUGIN_TEXT_DOMAIN) )
			);
			$date_value = 7;
		}else{
			$headings = array(
				esc_html( __('Sun', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Mon', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Tue', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Wed', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Thu', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Fri', VRCALENDAR_PLUGIN_TEXT_DOMAIN) ),
				esc_html( __('Sat', VRCALENDAR_PLUGIN_TEXT_DOMAIN) )
			);
			$date_value = 1;
		}
        $calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>';

        /* days and weeks vars now ... */
        $running_day = date('w',mktime(0,0,0,$month,$date_value,$year));
        $days_in_month = date('t',mktime(0,0,0,$month,1,$year));
        $days_in_this_week = 1;
        $day_counter = 0;
        $dates_array = array();
		
		$prev_month = date('t',mktime(0,0,0,$month-1,1,$year))-2;

        /* row for week one */
        $calendar.= '<tr class="calendar-row">';

        /* print "blank" days until the first of the current week */
        for($x = 0; $x < $running_day; $x++):
            $calendar.= '<td class="calendar-day-np"> </td>';
            $days_in_this_week++;
        endfor;

        /* keep going with days.... */
        for($list_day = 1; $list_day <= $days_in_month; $list_day++):
			
			$cDate = date('Y-m-d', mktime(0,0,0,$month,$list_day,$year));
            //custom Code
            //19-02-2016
                //$VRCalendarSettings = VRCalendarSettings::getInstance();
                $pro_one_day_book = $cal_data->pro_one_day_book;
                $hourly_booking = $cal_data->hourly_booking;
                $hoursbookingdiifference = $cal_data->hoursbookingdiifference;
                $show_booking_from_one_page = $cal_data->show_booking_from_one_page;
                
            //Custom Code

            if($VRCalendarBooking->isStartEndDate($cal_data, $cDate )) {
                
                $booked_class = 'start-end-day';
                //custom calender
                if($hourly_booking == 'yes'){
                    
                    $valuesOfData = getstatusOfCalender($cal_data->calendar_id, $cDate); //20-02-2016
                    if($valuesOfData == 1)
                    {
                        $booked_class = 'no-event-day'; //'no-event-day';
                    }else{
                        $booked_class = 'event-day';
                    }
                }else if($pro_one_day_book == 'yes'){
                    $booked_class = 'event-day'; //'start-end-day';
                }
                //custom calender
            }
            else if($VRCalendarBooking->isStartDate($cal_data, $cDate )) {
                
                //$booked_class = 'event-start';
                $booked_class = 'no-event-day event-start';
                
                if($hourly_booking == 'yes'){
                    
                    $valuesOfData = getstatusOfCalender($cal_data->calendar_id, $cDate); //20-02-2016
                    if($valuesOfData == 1)
                    {
                        $booked_class = 'no-event-day'; //'no-event-day';
                    }else{
                        $booked_class = 'event-day';
                    }
                }else if($pro_one_day_book == 'yes'){
                    $booked_class = 'event-day'; //'start-end-day';
                }
            }
            else if($VRCalendarBooking->isEndDate($cal_data, $cDate )) {
                $booked_class = 'no-event-day event-end';
                //custom Calender
                if($hourly_booking == 'yes')
                {
                    $booked_class = 'event-day';
                }
                else if($pro_one_day_book == 'yes')
                {
                    $booked_class = 'event-day';//'no-event-day event-end';
                }
                //Custom Calender
            }
            else if( $VRCalendarBooking->isDateAvailable($cal_data, $cDate )) {
                $booked_class = 'no-event-day';
            }
            else {
                $booked_class = 'event-day';
            }
			
			if(count($unable_dates) > 0)
            {
                foreach ($unable_dates as $unableDates)
                {
                    $booking_date_from = date("Y-m-d", strtotime($unableDates->booking_date_from));
                    $booking_date_to = date("Y-m-d", strtotime($unableDates->booking_date_to));
                    
                    if($unableDates->booking_date_to == '0000-00-00 00:00:00')
                    {
                        if($booking_date_from == $cDate  || $booking_date_from <= $cDate)
                        {
                            //event-day
                            $booked_class = 'event-day';
                        }
                    }
                    
                    if(strtotime($booking_date_from) <= strtotime($cDate) && strtotime($booking_date_to) >= strtotime($cDate))
                    {
                        if($VRCalendarBooking->isStartEndDateBlocked($cal_data, $cDate )) {
                
							$booked_class = 'start-end-day';
							//custom calender
							if($hourly_booking == 'yes'){
								
								$valuesOfData = getstatusOfCalender($cal_data->calendar_id, $cDate); //20-02-2016
								if($valuesOfData == 1)
								{
									$booked_class = 'no-event-day'; //'no-event-day';
								}else{
									$booked_class = 'event-day';
								}
							}else if($pro_one_day_book == 'yes'){
								$booked_class = 'event-day'; //'start-end-day';
							}
							//custom calender
						}
						else if($VRCalendarBooking->isStartDateBlocked($cal_data, $cDate )) {
							
							//$booked_class = 'event-start';
							$booked_class = 'no-event-day event-start';
							
							if($hourly_booking == 'yes'){
								
								$valuesOfData = getstatusOfCalender($cal_data->calendar_id, $cDate); //20-02-2016
								if($valuesOfData == 1)
								{
									$booked_class = 'no-event-day'; //'no-event-day';
								}else{
									$booked_class = 'event-day';
								}
							}else if($pro_one_day_book == 'yes'){
								$booked_class = 'event-day'; //'start-end-day';
							}
						}
						else if($VRCalendarBooking->isEndDateBlocked($cal_data, $cDate )) {
							$booked_class = 'no-event-day event-end';
							//custom Calender
							if($hourly_booking == 'yes')
							{
								$booked_class = 'event-day';
							}
							else if($pro_one_day_book == 'yes')
							{
								$booked_class = 'event-day';//'no-event-day event-end';
							}
							//Custom Calender
						}
						else if( $VRCalendarBooking->isDateAvailableBlocked($cal_data, $cDate )) {
							$booked_class = 'no-event-day';
						}
						else {
							$booked_class = 'event-day';
						}
                    }
                }
            }
            $booking_price = $VRCalendarEntity->getSingleNightCost($cal_data, $cDate);
			$month_namedd = date_i18n('m', strtotime("{$year}-{$month}-1"));
			$year_namedd = date_i18n('Y', strtotime("{$year}-{$month}-1"));
			$date = $year_namedd.'/'.$month_namedd.'/'.$list_day;
			$ddd = date('l', strtotime($date));

			$getcalendardata = $VRCalendarEntity->getCalendar($bookingCalendarIds);
			if($getcalendardata->weekend_pricing == 'yes' && $getcalendardata->weekend_pricing != ''){
				switch($ddd){
					case 'Friday':
						if($getcalendardata->friday_night_discount != ''){
							$booking_price = number_format($getcalendardata->friday_night_discount, 2, '.', '');
						}
					break;
					case 'Saturday':
						if($getcalendardata->saturday_night_discount != ''){
							$booking_price = number_format($getcalendardata->saturday_night_discount, 2, '.', '');
						}
					break;
					case 'Sunday':
						if($getcalendardata->sunday_night_discount != ''){
							$booking_price = number_format($getcalendardata->sunday_night_discount, 2, '.', '');
						}
					break;
				}
			}

			if($dateformat == 'usa'){
				$cDate = date('m-d-Y', mktime(0,0,0,$month,$list_day,$year));
			}else if($dateformat == 'euro'){
				$cDate = date('d-m-Y', mktime(0,0,0,$month,$list_day,$year));
			}else{
				$cDate = date('Y-m-d', mktime(0,0,0,$month,$list_day,$year));
			}
			
			$datetohighlight = date('Ymd', mktime(0,0,0,$month,$list_day,$year));
			
			$calendar.= '<td class="calendar-day">';
            $newArray = array();
			
			$seasonal_weekend_price = '';
			//echo $cDate;
			if(!empty($cal_data->calendar_price_exception)){
			foreach($cal_data->calendar_price_exception as $keys=>$seasonalprices){
                $begin = strtotime($seasonalprices->start_date);
                $end = strtotime($seasonalprices->end_date);
                $currentdatetime = strtotime($date);
                $seasonal_day_array = array();
                // if($cal_data->calendar_enable_booking == 'yes' ){
                    if(isset($begin) && isset($end)){
                        if($begin <= $currentdatetime && $currentdatetime <= $end){
                            $startDate = new DateTime($seasonalprices->start_date);
                            $endDate = new DateTime($seasonalprices->end_date);

                            $sundays = array();

                            while ($startDate <= $endDate) {
                                if($dateformat == 'usa'){
                                    $seasonal_full_date = $startDate->format('m-d-Y');
                                }else if($dateformat == 'euro'){
                                    $seasonal_full_date = $startDate->format('d-m-Y');
                                }else{
                                    $seasonal_full_date = $startDate->format('Y-m-d');
                                }
                                $sundays[$seasonal_full_date] = $startDate->format('l');


                                $startDate->modify('+1 day');
                            }
							$booking_price = '';
							foreach($sundays as $daykey=>$dayvalue){
								if($dateformat == 'usa'){
									$expl_daykey = explode('-', $daykey);
									$daykey1 = $expl_daykey[2].'-'.$expl_daykey[0].'-'.$expl_daykey[1];
									$expl_cDate = explode('-', $cDate);
									$cDate1 = $expl_cDate[2].'-'.$expl_cDate[0].'-'.$expl_cDate[1];
									
								}
								switch ($dayvalue){
									case 'Friday':
										if(strtotime($daykey1) != strtotime($cDate1)){
											$booking_price = number_format(@$seasonalprices->variation_price_per_night, 2, '.', '');
										}else{
											$booking_price = number_format(@$seasonalprices->variation_friday_weekend_pricing, 2, '.', '');
											$seasonal_weekend_price = $booking_price;
										}
										break;
									case 'Saturday':
										 if(strtotime($daykey1) == strtotime($cDate1)){
											$booking_price = number_format(@$seasonalprices->variation_saturday_weekend_pricing, 2, '.', '');
											$seasonal_weekend_price = $booking_price;
										}else{
											$booking_price = number_format(@$seasonalprices->variation_price_per_night, 2, '.', '');
										}
										break;
									case 'Sunday':
										 if(strtotime($daykey1) == strtotime($cDate1)){
											$booking_price = number_format(@$seasonalprices->variation_sunday_weekend_pricing, 2, '.', '');
											$seasonal_weekend_price = $booking_price;
										}else{
											$booking_price = number_format(@$seasonalprices->variation_price_per_night, 2, '.', '');
										}
										break;
									default:
										$booking_price = number_format(@$seasonalprices->variation_price_per_night, 2, '.', '');
								}
								
                            }
                        }
                    }

				}
			}
			
			if($cal_data->calendar_enable_booking == "yes"){
				$bookingurl = "yes";
			}else{
				$bookingurl = $cal_data->calendar_booking_url;
			}
			
			if( $seasonal_weekend_price!=''){
				$booking_price = $seasonal_weekend_price;
			}
			
			if($cal_data->calendar_show_tooltip == "yes"){
				$tooltip = $booking_price;
			}else{
				$tooltip = '';
			}
			
			$dateparam = '';
			if(!empty($VRCalendarSettings->getSettings('get_param'))){
				$splitdate = explode("=",$VRCalendarSettings->getSettings('get_param'));
				$param_format = $splitdate[1];
				$dateparam = 'data-parameter="'.date($param_format, mktime(0,0,0,$month,$list_day,$year)).'"';
			}
			$caldate = strtotime(date('Ymd', mktime(0,0,0,$month,$list_day,$year)));
			$caldatenow = strtotime(date('Ymd'));

			if($caldate < $caldatenow){
				$booked_class = 'event-day day-past';
			}
			$booking_table = $wpdb->prefix.'vrcalandar_bookings';
			$getbooked = $wpdb->get_results("SELECT * FROM {$booking_table} WHERE booking_calendar_id = '{$bookingCalendarIds}' AND booking_source = 'website' AND booking_status = 'confirmed'");
			
			$getapprove = $wpdb->get_results("SELECT * FROM {$booking_table} WHERE booking_calendar_id = '{$bookingCalendarIds}' AND booking_source = 'website' AND booking_status = 'pending' AND booking_admin_approved = 'no'");
			
			$getbooked_ics = $wpdb->get_results("SELECT * FROM {$booking_table} WHERE booking_calendar_id = '{$bookingCalendarIds}' AND booking_source LIKE '%ics%'OR booking_source LIKE '%ical%' AND booking_summary LIKE '%reserved%'");
			
			$getlocked_ics = $wpdb->get_results("SELECT * FROM {$booking_table} WHERE booking_calendar_id = '{$bookingCalendarIds}' AND booking_source LIKE '%ics%' OR booking_source LIKE '%ical%' AND booking_summary LIKE '%blocked%' OR booking_summary LIKE '%Not available%'");

			$getNotincluded_file = $wpdb->get_results("SELECT * FROM {$booking_table} WHERE booking_calendar_id = '{$bookingCalendarIds}' AND (booking_source LIKE '%ics%' OR booking_source LIKE '%ical%') AND booking_summary NOT LIKE '%blocked%' OR booking_summary NOT LIKE '%Not available%' AND booking_source != 'website'");
			
			$getblocked_website = $wpdb->get_results("SELECT * FROM {$booking_table} WHERE booking_calendar_id = '{$bookingCalendarIds}' AND booking_source = 'Website Blocked' AND booking_summary = 'UNAVAILABLE'");
			//echo $booking_price;
            $calendar .= '<div class="day-number '.$booked_class.'" '.$dateparam.' data-tooltip="" book-url="'.$bookingurl.'" data-calendar-id="'.$cal_data->calendar_id.'" date-highlight="'.$datetohighlight.'" data-booking-date="'.$cDate.'" data-price="'.$booking_price.'"><div class="list-day">'.$list_day.'</div>';
			
			$cls_dbook = "";
			foreach($getbooked as $dbook){
				for ($x=strtotime($dbook->booking_date_from);$x<=strtotime($dbook->booking_date_to);$x+=86400){
					if(date('Y-m-d',$x) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)))
					{
						if(date('Y-m-d', strtotime($dbook->booking_date_from)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $list_day == 1){
							if(!empty($dbook->booking_user_email)){
								$details_text = "Confirmed Booking";
								//$highlight_color = '#8fb5ff';
							}else{
								// foreach($cal_data->calendar_links as $clink) {
									// $highlight_color = $clink->color;
									// if(!empty($clink->name)){
										// $details_text = ucfirst($clink->name);
									// }else{
										$details_text = $dbook->booking_summary;
									// }
								// }
							}
							$individual_currency = json_decode($dbook->booking_sub_price);
							$details = '<div class="has-booking first-data has_popup" data-calendar-id="'.$bookingCalendarIds.'" data-booking-id="'.$dbook->booking_id.'" style="border-left: 1px solid #fff;"><a title="Click to see details.." class="booking-details" data-calendar-id="'.$bookingCalendarIds.'" data-booking-id="'.$dbook->booking_id.'">'.$details_text.'</a>
							<span class="popuptext my_popup_'.$dbook->booking_id.'">
								<table class="popup_table">
									<tr>
										<td>Full Name: </td><td>'.ucfirst($dbook->booking_user_lname).', '.ucfirst($dbook->booking_user_fname).'</td>
									</tr>
									<tr>
										<td>Email: </td><td>'.$dbook->booking_user_email.'</td>
									</tr>
									<tr>
										<td>Contact: </td><td>'.$dbook->booking_user_phone.'</td>
									</tr>
									<tr>
										<td>Total Amount: </td><td>'.$individual_currency->render_currency.$dbook->booking_total_price.'</td>
									</tr>
								</table>
							</span>
							</div>';
						}else{
							if(date('Y-m-d', strtotime($dbook->booking_date_to)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $booked_class == 'event-end'){
								$cls_dbook .= ' last-data';
							}
							$details = '<div class="has-booking'.$cls_dbook.'">&nbsp;</div>';
						}
						$calendar .= $details;
					}
				}
			}
			
			$cls_getNotincluded_file = "";
			foreach($getNotincluded_file as $d_notincluded){
				for ($x=strtotime($d_notincluded->booking_date_from);$x<=strtotime($d_notincluded->booking_date_to);$x+=86400){
					if(date('Y-m-d',$x) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)))
					{
						if(date('Y-m-d', strtotime($d_notincluded->booking_date_from)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $list_day == 1){
							if(!empty($d_notincluded->booking_user_email)){
								$details_text = ucfirst($d_notincluded->booking_user_fname).', '.$d_notincluded->booking_user_email;
								//$highlight_color = '#8fb5ff';
							}else{
								// foreach($cal_data->calendar_links as $clink) {
									// $highlight_color = $clink->color;
									// if(!empty($clink->name)){
										// $details_text = ucfirst($clink->name);
									// }else{
										$details_text = $d_notincluded->booking_summary;
									// }
								// }
							}
							$details = '<div class="has-reserved_ics first-data" style="border-left: 1px solid #fff;">'.$details_text.'</div>';
						}else{
							if(date('Y-m-d', strtotime($d_notincluded->booking_date_to)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $booked_class == 'event-end'){
								$cls_getNotincluded_file .= ' last-data';
							}
							$details = '<div class="has-reserved_ics'.$cls_getNotincluded_file.'">&nbsp;</div>';
						}
						$calendar .= $details;
					}
				}
			}
			
			$cls_dblocksite = "";
			foreach($getblocked_website as $dblocksite){
				for ($x=strtotime($dblocksite->booking_date_from);$x<=strtotime($dblocksite->booking_date_to);$x+=86400){
					if(date('Y-m-d',$x) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)))
					{
						if(date('Y-m-d', strtotime($dblocksite->booking_date_from)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $list_day == 1){
							if(!empty($dblocksite->booking_user_email)){
								$details_text = ucfirst($dblocksite->booking_user_fname).', '.$dblocksite->booking_user_email;
								//$highlight_color = '#8fb5ff';
							}else{
								// foreach($cal_data->calendar_links as $clink) {
									// $highlight_color = $clink->color;
									// if(!empty($clink->name)){
										// $details_text = ucfirst($clink->name);
									// }else{
										$details_text = $dblocksite->booking_summary;
									// }
								// }
							}
							$details = '<div class="has-blocksite first-data" style="border-left: 1px solid #fff;">'.$details_text.'</div>';
						}else{
							if(date('Y-m-d', strtotime($dblocksite->booking_date_to)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $booked_class == 'event-end'){
								$cls_dblocksite .= ' last-data';
							}
							$details = '<div class="has-blocksite'.$cls_dblocksite.'">&nbsp;</div>';
						}
						$calendar .= $details;
					}
				}
			}
			
			$cls_dbook_ics = "";
			foreach($getbooked_ics as $dbook_ics){
				for ($x=strtotime($dbook_ics->booking_date_from);$x<=strtotime($dbook_ics->booking_date_to);$x+=86400){
					if(date('Y-m-d',$x) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)))
					{
						if(date('Y-m-d', strtotime($dbook_ics->booking_date_from)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $list_day == 1){
							if(!empty($dbook_ics->booking_user_email)){
								$details_text = ucfirst($dbook_ics->booking_user_fname).', '.$dbook_ics->booking_user_email;
								//$highlight_color = '#8fb5ff';
							}else{
								// foreach($cal_data->calendar_links as $clink) {
									// $highlight_color = $clink->color;
									// if(!empty($clink->name)){
										// $details_text = ucfirst($clink->name);
									// }else{
										$details_text = $dbook_ics->booking_summary;
									// }
								// }
							}
							$details = '<div class="has-reserved_ics first-data" style="border-left: 1px solid #fff;">'.$details_text.'</div>';
						}else{
							if(date('Y-m-d', strtotime($dbook_ics->booking_date_to)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $booked_class == 'event-end'){
								$cls_dbook_ics .= ' last-data';
							}
							$details = '<div class="has-reserved_ics'.$cls_dbook_ics.'">&nbsp;</div>';
						}
						$calendar .= $details;
					}
				}
			}
			
			$cls_dlocked_ics = "";
			foreach($getlocked_ics as $dlocked_ics){
				for ($x=strtotime($dlocked_ics->booking_date_from);$x<=strtotime($dlocked_ics->booking_date_to);$x+=86400){
					
					if(date('Y-m-d',$x) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)))
					{
						if(date('Y-m-d', strtotime($dlocked_ics->booking_date_from)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $list_day == 1){
							if(!empty($dlocked_ics->booking_user_email)){
								$details_text = ucfirst($dlocked_ics->booking_user_fname).', '.$dlocked_ics->booking_user_email;
								//$highlight_color = '#8fb5ff';
							}else{
								// foreach($cal_data->calendar_links as $clink) {
									// $highlight_color = $clink->color;
									// if(!empty($clink->name)){
										// $details_text = ucfirst($clink->name);
									// }else{
										$details_text = $dlocked_ics->booking_summary;
									// }
								// }
							}
							$details = '<div class="has-blocked_ics first-data" style="border-left: 1px solid #fff;">'.$details_text.'</div>';
						}else{
							if(date('Y-m-d', strtotime($dlocked_ics->booking_date_to)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $booked_class == 'event-end'){
								$cls_dlocked_ics .= ' last-data';
							}
								$details = '<div class="has-blocked_ics'.$cls_dlocked_ics.'">&nbsp;</div>';
						}
						$calendar .= $details;
					}
				}
			}
			
			$cls_dapprove = "";
			foreach($getapprove as $dapprove){
				for ($x=strtotime($dapprove->booking_date_from);$x<=strtotime($dapprove->booking_date_to);$x+=86400){
					if(date('Y-m-d',$x) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)))
					{
						if(date('Y-m-d', strtotime($dapprove->booking_date_from)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $list_day == 1){
							if(!empty($dapprove->booking_user_email)){
								$details_text = "Needs Approval";
								//$highlight_color = '#8fb5ff';
							}else{
								// foreach($cal_data->calendar_links as $clink) {
									// $highlight_color = $clink->color;
									// if(!empty($clink->name)){
										// $details_text = ucfirst($clink->name);
									// }else{
										$details_text = $dapprove->booking_summary;
									// }
								// }
							}
							$individual_currency_approve = json_decode($dapprove->booking_sub_price);
							$details = '<div class="has-approve has_popup first-data" data-calendar-id="'.$bookingCalendarIds.'" data-booking-id="'.$dapprove->booking_id.'" style="border-left: 1px solid #fff;"><a title="Click to see details.." class="booking-details" data-calendar-id="'.$bookingCalendarIds.'" data-booking-id="'.$dapprove->booking_id.'">'.$details_text.'</a>
								<div class="popuptext my_popup_'.$dapprove->booking_id.'">
									<table class="popup_table">
										<tr>
											<td>Full Name: </td><td>'.ucfirst($dapprove->booking_user_lname).', '.ucfirst($dapprove->booking_user_fname).'</td>
										</tr>
										<tr>
											<td>Email: </td><td>'.$dapprove->booking_user_email.'</td>
										</tr>
										<tr>
											<td>Contact: </td><td>'.$dapprove->booking_user_phone.'</td>
										</tr>
										<tr>
											<td>Total Amount: </td><td>'.$individual_currency_approve->render_currency.$dapprove->booking_total_price.'</td>
										</tr>
									</table>
									<input type="button" value="View" class="view_has_approve" data-calendar-id="'.$bookingCalendarIds.'" data-booking-id="'.$dapprove->booking_id.'"/>
								</div>
							</div>';
						}else{
							if(date('Y-m-d', strtotime($dapprove->booking_date_to)) == date('Y-m-d', mktime(0,0,0,$month,$list_day,$year)) || $booked_class == 'event-end'){
								$cls_dapprove .= ' last-data';
							}
							$details = '<div class="has-approve'.$cls_dapprove.'">&nbsp;</div>';
						}
						$calendar .= $details;
					}
				}
			}
			
			$calendar .= '</div>';
            /* add in the day number */
            

            $calendar.= '</td>';
            if($running_day == 6):
                $calendar.= '</tr>';
                if(($day_counter+1) != $days_in_month):
                    $calendar.= '<tr class="calendar-row">';
                endif;
                $running_day = -1;
                $days_in_this_week = 0;
            endif;
            $days_in_this_week++; $running_day++; $day_counter++;
			$dc = $day_counter;
        endfor;

        /* finish the rest of the days in the week */
        if($days_in_this_week < 8 && $days_in_this_week>1):
            for($x = 1; $x <= (8 - $days_in_this_week); $x++):
                $calendar.= '<td class="calendar-day-np"> </td>';
            endfor;
        endif;

        /* final row */
        $calendar.= '</tr>';

        /* end the table */
        $calendar.= '</table>';
		
        $result = <<<E
<div class="calendar-month-container single-calendar">
    {$calendar}
</div>
E;
        return $result;
    }
?>