views:

245

answers:

0

I’ve built a site in ExpressionEngine for some holiday apartments (EE1.6.8), that uses two related weblogs for bookings.

‘apartments’ & ‘booking’

Bookings are set up as weblog entries using the entry_date for arrival and expiration_date for leaving date, and are related back to the apartment that is booked.

I’ve built a page that lists which apartments are available on a given date, using the URL to pass the date to the weblog:entries tag. (eg /checkdate/2010/05/07)

My problem is that it only works for entries where the entry_date exactly matches the date in the URL.

So for example if I have a booking: entry_date 2010/05/05 expiration_date 2010/05/12 (one week) and I enter a date in between these dates (eg 2010/05/08), the apartment is listed as available, which is bad (for me!)

Is there a way (preferably without delving into the repeet plugin, which gives me nightmares) to be able to pull out an entry from a set date range? Perhaps with the sql plugin?

At the moment I have some code that builds a list of entry_ids of booked apartments:

{exp:weblog:entries weblog="booking" show_future_entries="yes" status="Unpaid|Paid|Deposit|Complimentary"}
    {related_entries id="booking_apartment"}
        <?php $exclude_ids .='{entry_id}|';?>
    {/related_entries}
{/exp:weblog:entries}

I’m awful with sql, but is there a way of replicating the above but with a mysql query, looking at the whole ‘live’ date range?

Thank you!