<?php

/*
        $this->start = Carbon::createFromFormat( 'Y-m-d', $start );
        $this->end = Carbon::createFromFormat( 'Y-m-d', $end );
        $this->nights = $this->start->diffInDays( $this->end, false );
        $this->property = $this->getProperty();
        $this->min_nights = $this->getMinNights();
        $this->max_nights = $this->getMaxNights();
        $this->min_guests = $this->getMinGuests();
        $this->max_guests = $this->getMaxGuests();
        $this->booking_interval = $this->getBookingInterval();
        $this->bookable = $this->getBookable();
*/
$booking = new BonsaiBooking(75, 2, '2013-06-28', '2013-06-29');
echo $booking->calculateTotalPrice();
<?php

/*
Template Name: Booking Page
*/
if (!empty($_GET['overview'])) {
    $modify_url = get_permalink() . '/?' . str_replace('&overview=true', '', $_SERVER['QUERY_STRING']);
    $booking = new BonsaiBooking($_GET['_est_property_id'], $_GET['_est_guests'], $_GET['_est_start'], $_GET['_est_end']);
    $booking->checkBooking();
    if (empty($_GET['_est_name'])) {
        $booking->errors->addError('Please tell us your name', 'To complete your booking we need to know your name, please full the field out', 'Name', __LINE__);
    }
    if (empty($_GET['_est_email'])) {
        $booking->errors->addError('Please tell us your email', 'To complete your booking we need to know your email, please full the field out', 'Email', __LINE__);
    }
    if ($booking->errors->hasError()) {
        $_SESSION['booking'] = $booking;
        header('Location: ' . $modify_url);
    }
}
get_header();
?>
<div class='row mt44'>
	<div class='large-9 small-12 columns centered small-centered'>
		<h1 class='floating-title mb44'><?php 
the_title();
?>
</h1>

<?php 
if (!empty($_GET['_est_property_id']) and empty($_GET['est_success'])) {
function est_intercept_ipn()
{
    $data = wp_parse_args($_POST['custom']);
    $data['_est_email'] = $_POST['payer_email'];
    $details = array('_est_name' => $data['n'], '_est_email' => $_POST['e'], '_est_phone' => $data['p']);
    $booking = new BonsaiBooking($data['_est_property_id'], $data['_est_guests'], $data['_est_start'], $data['_est_end'], $details);
    if (!empty($_POST['e'])) {
        $_POST['_est_email'] = $_POST['e'];
    }
    $booking_id = $booking->insertBooking($_POST);
    est_send_booking_emails($booking_id, $data);
}