Example #1
0
<?php 
if (!empty($_GET['complete']) and $_GET['complete'] == 'true') {
    ?>



<?php 
} else {
    $apartment_id = empty($_GET['apartment_id']) ? '' : $_GET['apartment_id'];
    $apartment = false;
    $unavailable_dates = '';
    $maximum_guests = '';
    $minimum_stay = '';
    if (!empty($apartment_id)) {
        $apartment = new TVR_Apartment($apartment_id);
        $apartment_id = !empty($apartment->ID) ? $apartment->ID : '';
        $unavailable_dates = json_encode($apartment->get_unavailable_dates());
        $maximum_guests = $apartment->maximum_guests;
        $minimum_stay = !empty($apartment->data->minimum_stay) ? $apartment->data->minimum_stay : 1;
    }
    $checkin['value'] = empty($_GET['checkin']) ? '' : $_GET['checkin'];
    $checkin['disabled'] = empty($apartment_id) ? 'disabled="disabled"' : '';
    $checkout['value'] = empty($_GET['checkout']) ? '' : $_GET['checkout'];
    $checkout['disabled'] = empty($apartment_id) ? 'disabled="disabled"' : '';
    $guests['value'] = empty($_GET['guests']) ? '' : $_GET['guests'];
    $guests['disabled'] = empty($apartment_id) ? 'disabled="disabled"' : '';
    $name['value'] = empty($_GET['name']) ? '' : $_GET['name'];
    $name['disabled'] = empty($apartment_id) ? 'disabled="disabled"' : '';
    $email['value'] = empty($_GET['email']) ? '' : $_GET['email'];
    $email['disabled'] = empty($apartment_id) ? 'disabled="disabled"' : '';
Example #2
0
    function widget($args, $instance)
    {
        global $post, $framework, $apartments;
        $apartment_list = $apartments->get_apartment_dropwdown_list();
        if (!empty($apartment_list)) {
            if ($instance['autodetect'] == 'yes' and is_singular('tvr_apartment')) {
                $apartment_id = $post->ID;
            } elseif (!empty($instance['apartment_id'])) {
                $apartment_id = $instance['apartment_id'];
            } else {
                $apartment_id = current($apartment_list);
            }
            $apartment = new TVR_Apartment($apartment_id);
            $unavailable_dates = json_encode($apartment->get_unavailable_dates());
            $maximum_guests = $apartment->maximum_guests;
            $hidden_selector = ($instance['autodetect'] == 'yes' and is_singular('tvr_apartment')) ? 'hidden' : '';
            ob_start();
            ?>


		<?php 
            echo $args['before_widget'];
            ?>
			<div class='widget-container tvr_widget_booking' data-apartment_id='<?php 
            echo $post->ID;
            ?>
' id='<?php 
            echo $args['widget_id'];
            ?>
'><div class='full-loader'></div>
				<?php 
            if (!empty($instance['title'])) {
                echo $args['before_title'] . $instance['title'] . $args['after_title'];
            }
            ?>


				<style type='text/css'>
					<?php 
            $styler = new EB_Styler();
            ?>

					.ui-datepicker-<?php 
            echo $post->ID;
            ?>
 table td.available .ui-state-default {
						background: <?php 
            echo $instance['availability_background_color'];
            ?>
;
						border:1px solid <?php 
            echo $styler->lightness($instance['availability_background_color'], '-', '15');
            ?>
;
						color: <?php 
            echo $instance['availability_text_color'];
            ?>
 !important;
					}
					.ui-datepicker-<?php 
            echo $post->ID;
            ?>
 table td.available .ui-state-default:hover {
						background:  <?php 
            echo $styler->lightness($instance['availability_background_color'], '+', '11');
            ?>
;
						border:1px solid <?php 
            echo $instance['availability_background_color'];
            ?>
;
					}

					.ui-datepicker-<?php 
            echo $post->ID;
            ?>
 table td.unavailable .ui-state-default {
						background: <?php 
            echo $instance['unavailability_background_color'];
            ?>
;
						border:1px solid <?php 
            echo $styler->lightness($instance['unavailability_background_color'], '-', '15');
            ?>
;
						color: <?php 
            echo $instance['unavailability_text_color'];
            ?>
 !important;
					}

					.ui-datepicker-<?php 
            echo $post->ID;
            ?>
 table td.past .ui-state-default {
						background: <?php 
            echo $instance['past_background_color'];
            ?>
;
						border:1px solid <?php 
            echo $styler->lightness($instance['past_background_color'], '-', '15');
            ?>
;
						color: <?php 
            echo $instance['past_text_color'];
            ?>
 !important;
					}

					.ui-datepicker-<?php 
            echo $post->ID;
            ?>
 table .ui-datepicker-unselectable.available .ui-state-default {
						background: <?php 
            echo $instance['past_background_color'];
            ?>
 !important;
						border:1px solid <?php 
            echo $styler->lightness($instance['past_background_color'], '-', '15');
            ?>
;
						color: <?php 
            echo $instance['past_text_color'];
            ?>
 !important;
					}

				</style>



				<div class='widget-content'>
					<form class='booking-widget' method='get' action='<?php 
            echo get_permalink($instance['book_now_page']);
            ?>
'>
						<div class='loader'></div>

					<div class='hidden unavailable'><?php 
            echo $unavailable_dates;
            ?>
</div>
					<div class='hidden maximum_guests'><?php 
            echo $maximum_guests;
            ?>
</div>

					<div class='row apartment-selector <?php 
            echo $hidden_selector;
            ?>
'>
						<select class='apartment_id' name='apartment_id'>
							<?php 
            foreach ($apartment_list as $name => $id) {
                $current = $id == $apartment_id ? 'selected="selected"' : '';
                ?>
								<option <?php 
                echo $current;
                ?>
 value='<?php 
                echo $id;
                ?>
'><?php 
                echo $name;
                ?>
</option>
							<?php 
            }
            ?>
						</select>
					</div>



					<div class='section-price' data-price='<?php 
            echo $apartment->default_price;
            ?>
'>
						from <?php 
            echo $framework->get_price_format($apartment->default_price, 'price-' . $post->ID);
            ?>

						<div class='per_time_select'>
						<select class='per_time'>
							<option value='1'>per day</option>
							<option value='7'>per week</option>
							<option value='30'>per month</option>
						</select>
						</div>
					</div>



					<div class='row'>
						<div class='date-col'>
							<label>Check In</label>
							<p>
							<input name='checkin' type='text' data-id='<?php 
            echo $post->ID;
            ?>
'>
							</p>
						</div>

						<div class='date-col'>
							<label>Check Out</label>
							<p>
							<input name='checkout' type='text' data-id='<?php 
            echo $post->ID;
            ?>
'>
							</p>
						</div>
						<div class='guest-col'>
							<label>Guests</label>
							<p>
							<select class='guests' name='guests'>
								<?php 
            for ($i = 1; $i <= $apartment->maximum_guests; $i++) {
                ?>
									<option value='<?php 
                echo $i;
                ?>
'><?php 
                echo $i;
                ?>
</option>
								<?php 
            }
            ?>
							</select>
							</p>
						</div>
					</div>

					<?php 
            $price_display = $framework->get_price_format(0, 'price-' . $post->ID);
            ?>
					<div class='section-total'>
						total: <?php 
            echo $price_display;
            ?>
					</div>

					<?php 
            $permalink_structure = get_option('permalink_structure');
            if (empty($permalink_structure)) {
                ?>
						<input type='hidden' name='p' value='<?php 
                echo $instance['book_now_page'];
                ?>
 '>
					<?php 
            }
            ?>


						<?php 
            echo do_shortcode('[button margin="0px" background="secondary" text="<input type=\'submit\' value=\'Book Now\'>"]');
            ?>

					</form>

				</div>

			</div>
				<?php 
            echo $args['after_widget'];
            ?>

			<?php 
            $output = ob_get_clean();
            echo $output;
        }
    }
Example #3
0
function action_get_apartment_daterange_price()
{
    $apartment = new TVR_Apartment($_POST['apartment_id']);
    echo $apartment->get_daterange_price($_POST['checkin'], $_POST['checkout']);
    die;
}