Пример #1
0
/images/icons/glyphicons/black/24x24/coins.png" alt="Coin icon"><?php 
_e('Price Per Night', THEMENAME);
?>
						</label>
					</div>
					<div class='small-12 large-8 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-4 columns'>
						<div class='button total-price'><?php 
echo est_get_amount(0, $currency, $currency_position);
?>
</div>
					</div>
					<div class='small-12 large-8 columns total-price-label'>
						<h2><?php 
_e('Total Price', THEMENAME);
?>
</h2>
					</div>
				</div>
			</div>

		</article>
	</div>
    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'];
        }
    }
Пример #3
0
function est_action_get_booking_prices()
{
    $currency = get_post_meta($_POST['_est_property_id'], '_est_rent_currency', true);
    $currency_position = get_post_meta($_POST['_est_property_id'], '_est_rent_currency_position', true);
    $_POST['_est_guests'] = empty($_POST['_est_guests']) ? 1 : $_POST['_est_guests'];
    if (empty($_POST['_est_end']) or empty($_POST['_est_start'])) {
        $response['price_per_night'] = est_get_amount(0, $currency, $currency_position);
        $response['total_price'] = est_get_amount(0, $currency, $currency_position);
    } else {
        $booking = new BonsaiBooking($_POST['_est_property_id'], $_POST['_est_guests'], $_POST['_est_start'], $_POST['_est_end']);
        $response['price_per_night'] = est_get_amount($booking->calculatePricePerNight(), $currency, $currency_position);
        $response['total_price'] = est_get_amount($booking->calculateTotalPrice(), $currency, $currency_position);
    }
    echo json_encode($response);
    die;
}
    function widget($args, $instance)
    {
        global $post, $wpdb;
        $bookable = get_post_meta($post->ID, '_est_bookable', true);
        if ($bookable == 'yes') {
            echo $args['before_widget'];
            echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
            $pricing['daily'] = get_post_meta($post->ID, '_est_rent_daily_price', true);
            $pricing['weekly'] = get_post_meta($post->ID, '_est_rent_weekly_price', true);
            $pricing['monthly'] = get_post_meta($post->ID, '_est_rent_monthly_price', true);
            $currency = get_post_meta($post->ID, '_est_rent_currency', true);
            $currency_position = get_post_meta($post->ID, '_est_rent_currency_position', true);
            $pricing = array_filter($pricing);
            if (!empty($pricing)) {
                ?>
			<h5><?php 
                _e('Regular Prices', THEMENAME);
                ?>
</h5>
			<table class="detail-table mb11">
				<tbody>
					<?php 
                if (!empty($pricing['daily'])) {
                    ?>
					<tr>
						<td class="name"><?php 
                    _e('Daily Price');
                    ?>
</td>
						<td class="value"><?php 
                    echo est_get_amount($pricing['daily'], $currency, $currency_position);
                    ?>
</td>
					</tr>
					<?php 
                }
                ?>
					<?php 
                if (!empty($pricing['weekly'])) {
                    ?>
					<tr>
						<td class="name"><?php 
                    _e('Weekly Price');
                    ?>
</td>
						<td class="value"><?php 
                    echo est_get_amount($pricing['weekly'], $currency, $currency_position);
                    ?>
</td>
					</tr>
					<?php 
                }
                ?>
					<?php 
                if (!empty($pricing['monthly'])) {
                    ?>
					<tr>
						<td class="name"><?php 
                    _e('Monthly Price');
                    ?>
</td>
						<td class="value"><?php 
                    echo est_get_amount($pricing['monthly'], $currency, $currency_position);
                    ?>
</td>
					</tr>
					<?php 
                }
                ?>
				</tbody>
			</table>

			<?php 
            }
            $seasonal = get_post_meta($post->ID, '_est_rent_seasonal_price', true);
            if (!empty($seasonal)) {
                foreach ($seasonal as $season) {
                    if (!empty($season['start']) and !empty($season['end'])) {
                        $season_name = !empty($season['name']) ? $season['name'] . ' - <small>' . $season['start'] . ' - ' . $season['end'] . '</small>' : $season['start'] . ' - ' . $season['end'];
                        ?>
				<h5><?php 
                        echo $season_name;
                        ?>
</h5>
				<table class="detail-table mb11">
				<tbody>
					<?php 
                        if (!empty($season['price']['daily'])) {
                            ?>
					<tr>
						<td class="name"><?php 
                            _e('Daily Price');
                            ?>
</td>
						<td class="value"><?php 
                            echo est_get_amount($season['price']['daily'], $currency, $currency_position);
                            ?>
</td>
					</tr>
					<?php 
                        }
                        ?>
					<?php 
                        if (!empty($season['price']['weekly'])) {
                            ?>
					<tr>
						<td class="name"><?php 
                            _e('Weekly Price');
                            ?>
</td>
						<td class="value"><?php 
                            echo est_get_amount($season['price']['weekly'], $currency, $currency_position);
                            ?>
</td>
					</tr>
					<?php 
                        }
                        ?>
					<?php 
                        if (!empty($season['price']['monthly'])) {
                            ?>
					<tr>
						<td class="name"><?php 
                            _e('Monthly Price');
                            ?>
</td>
						<td class="value"><?php 
                            echo est_get_amount($season['price']['monthly'], $currency, $currency_position);
                            ?>
</td>
					</tr>
					<?php 
                        }
                        ?>
				</tbody>
				</table>

			<?php 
                    }
                }
            }
            echo $args['after_widget'];
        }
    }