I'm working at a booking application for my company where employees can book an instrument for a day or more.
So I created a Booking Content Type with a Date field (from to date) with granularity set to Day
But I noticed that if I book something from day 1 to day 5 then I try to book from day 5 to day 7 the system accept that because the date is from day 1 h 00:00 to day 5 h 00:00 so the second booking isn't overlapping

I don't know how ResConf does the check on the dates, but is there the chance to let it look only up to the day without checking the hours?

Comments

deviantintegral’s picture

Version: 6.x-2.0 » 6.x-2.x-dev
Category: support » feature

It partially depends on how Date is storing dates for when the date granularity is "Day". Do we know for sure it's using midnight?

The module is built so that, like a calendar, events overlapping on a minute don't block availability. Day-bookings break that assumption, as the end date should be blocked.

I think the best solution is to have it check the granularity setting of the field, and if it's set to "day" (or month / year?) use a different algorithm.

garg’s picture

I'm new to drupal so I'm trying to figure out how I can check the granularity set for the datetime field for the content type. If it is set to "day" then I think changing the query to:

      $query = "SELECT DISTINCT nid FROM $date_table
      WHERE('%s' >= $start_field_name AND '%s' <= $end_field_name)
      OR('%s' >= $start_field_name AND '%s' <= $end_field_name)
      OR('%s' <= $start_field_name AND '%s' >= $end_field_name)";

Where I have changed

      WHERE('%s' > $start_field_name AND '%s' < $end_field_name)

to

      WHERE('%s' >= $start_field_name AND '%s' <= $end_field_name)

appears to work so that if there exists an event from

17-Feb to 19-Feb

Then events from
15-Feb to 17-Feb
and
19-Feb to 23-Feb

will cause a conflict.

deviantintegral’s picture

You should be able to get the field information by calling content_fields($date_field). Install the devel module and dpr() the return of that function to check. Then you should be able to wrap an if around $query to set it properly.

keyiyek’s picture

@garg: I'm new too, where can I find this query?

ok I found it, thanks it works!

Balbo’s picture

@garg: I'm new too, where can I find this query?

:-/

ohthehugemanatee’s picture

Status: Active » Closed (fixed)