function get_property_bookings_for_calendar($property_id) { $bookings = get_property_bookings($property_id); $booking_dates = array(); foreach ($bookings as $date) { $booking_dates[] = '"' . $date . '"'; } $booking_dates = '[' . implode(',', $booking_dates) . ']'; return $booking_dates; }
function widget($args, $instance) { global $post, $wpdb; $bookable = get_post_meta($post->ID, '_est_bookable', true); $currency = get_post_meta($post->ID, '_est_rent_currency', true); $currency_position = get_post_meta($post->ID, '_est_rent_currency_position', true); $interval = get_post_meta($post->ID, '_est_booking_interval', true); if ($bookable == 'yes') { echo $args['before_widget']; echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; ?> <form method='get' action='<?php echo get_permalink($instance['booking_page_id']); ?> ' class='custom' id='booking-form-widget'> <div class='bookingCalendar' id='bookingCalendar-<?php echo $args['widget_id']; ?> ' data-interval='<?php echo $interval; ?> '> <div class='row'> <div class='small-12 large-4 columns'> <label for='_est_start'> <img class="retina" src="<?php echo get_template_directory_uri(); ?> /images/icons/glyphicons/black/14x14/calendar.png" alt="Calendar icon"><?php _e('Arrival', THEMENAME); ?> </label> </div> <div class='small-12 large-8 columns'> <input type='text' class='calculatePrice start' value=''> <input type='hidden' name='_est_start' class='start-field' id='_est_start' value=''> </div> </div> <div class='row'> <div class='small-12 large-4 columns'> <label for='_est_end'> <img class="retina" src="<?php echo get_template_directory_uri(); ?> /images/icons/glyphicons/black/14x14/calendar.png" alt="Calendar icon"><?php _e('Departure', THEMENAME); ?> </label> </div> <div class='small-12 large-8 columns'> <input type='text' class='calculatePrice end' value=''> <input type='hidden' class='calculatePrice end-field' name='_est_end' id='_est_end' value=''> </div> </div> </div> <div class='row'> <div class='small-12 large-4 columns'> <label for='_est_guests'> <img class="retina" src="<?php echo get_template_directory_uri(); ?> /images/icons/glyphicons/black/14x14/user.png" alt="Calendar icon"><?php _e('Guests', THEMENAME); ?> </label> </div> <div class='small-12 large-8 columns'> <input type='text' onkeyup='refreshPrice()' class='calculatePrice' name='_est_guests' id='_est_guests' value=''> </div> </div> <div class='calculated'> <div class='row'> <div class='small-12 large-6 columns'> <label> <img class="retina" src="<?php echo get_template_directory_uri(); ?> /images/icons/glyphicons/black/14x14/coins.png" alt="Coin icon"><?php _e('Price Per Night', THEMENAME); ?> </label> </div> <div class='small-12 large-6 columns'> <div class='price-per-night'><?php echo est_get_amount(0, $currency, $currency_position); ?> </div> </div> </div> <div class='row mt22'> <div class='small-12 large-6 columns'> <label class='total-price-label'> <img class="retina" src="<?php echo get_template_directory_uri(); ?> /images/icons/glyphicons/black/14x14/coins.png" alt="Coin icon"><?php _e('Total Price', THEMENAME); ?> </label> </div> <div class='small-12 large-6 columns total-price-label'> <div class='total-price'><?php echo est_get_amount(0, $currency, $currency_position); ?> </div> </div> </div> </div> <div class='mt11 text-right'> <input type='hidden' name='_est_property_id' id='_est_property_id' value='<?php echo $post->ID; ?> '> <input type='submit' class='submit button mb0' value='<?php _e('Submit Booking', THEMENAME); ?> '> </div> <?php $bookings = get_property_bookings($post->ID); $booking_dates = array(); foreach ($bookings as $date) { $booking_dates[] = '"' . $date . '"'; } $booking_dates = '[' . implode(',', $booking_dates) . ']'; ?> <script type='text/javascript'> jQuery(document).ready( function() { jQuery( '#bookingCalendar-<?php echo $args['widget_id']; ?> ' ).bookingCalendar({ bookedDays : <?php echo $booking_dates; ?> }); }) </script> </form> <?php echo $args['after_widget']; } }