Technical details:
If configuration have no 'Date To', calculate end of the event via fixed length from configuration.
If 'Date To' is present, use this value instead of fixed to calculate event length and calculate using this value for conflicts.

Related issues:
http://drupal.org/node/507176#comment-1813208

Comments

fatro’s picture

I really need this feature.

bradezone’s picture

I actually needed some functionality like this, so I wrote a bit of code to help me out. I've enjoyed this module--definitely better than some of the other ones that try to do similar things. But in my case I wanted to reserve times for multiple places, in my case conference rooms, so I just added an extra dropdown field to my content type. For the following code, my goal was to make things happen quickly, so I haven't abstracted any of my field names. But maybe it will help the developer add this functionality in the near future. For now you have to substitute the following:
* "reservation" needs to be the machine readable name of your content type that has the meeting fields.
* "meetingtime" would be the machine readable name for your meeting time "from" and "to" fields.
* "conferenceroom" is the extra field I added so I can reserve the same time for multiple places.

The code below simply checks to see if a time has already been reserved for the room that falls between the start and end times chosen in the form, and invalidates the form if so. This needs to be added to the bottom of the "booking_timeslots_validate" function which is at the bottom of the "booking_timeslots.module" file...

$datetime1 = date('Y-m-d H:i:s',
strtotime($form['field_meetingtime'][0]['#value']['value']['date'] . ' ' . $form['field_meetingtime'][0]['#value']['value']['time'])
);
$datetime2 = date('Y-m-d H:i:s',
strtotime($form['field_meetingtime'][0]['#value']['value2']['date'] . ' ' . $form['field_meetingtime'][0]['#value']['value2']['time'])
);
$result = db_query("SELECT * FROM {node} n, {content_type_reservation} r WHERE n.nid = r.nid
AND r.field_conferenceroom_value = '%s' AND ((r.field_meetingtime_value < '%s' AND r.field_meetingtime_value2 > '%s')
OR (r.field_meetingtime_value < '%s' AND r.field_meetingtime_value2 > '%s'))",
$form['field_conferenceroom']['#value']['value'], $datetime1, $datetime1, $datetime2, $datetime2
);
if ($node = db_fetch_object($result)) {
form_set_error('field_meetingtime', t('This room has already been reserved during this time. Please try again.'));
}

aimevp’s picture

Is there a quick and dirty way to help me with this problem?
Inspired by Bradezone's code i made the following validation code that seems to be working (I know it's awefull, am not used to work in drupal code):

$dt1 = $form_state['values']['field_res_when'][0]['value'];
$dt2 = $form_state['values']['field_res_when'][0]['value2'];
$error = 0;
$error_txt = "";


$sql1 = "
	SELECT COUNT(*) FROM {node} n, {content_type_reservatie} r 
	WHERE n.nid = r.nid
	AND (r.field_res_when_value = '%s' AND r.field_res_when_value2 = '%s')
";

$result1 = db_query($sql1, $dt1, $dt2);
$cnt1 = db_result($result1);

if($cnt1 > 0){
$error++; 
$error_txt .= t('Allready booked.');
}



$sql2 = "
	SELECT COUNT(*) FROM {node} n, {content_type_reservatie} r 
	WHERE n.nid = r.nid
	AND (r.field_res_when_value = '%s' OR r.field_res_when_value2 = '%s')
";

$result2 = db_query($sql2, $dt1, $dt2);
$cnt2 = db_result($result2);

if($cnt2 > 0){
$error++; 
$error_txt .= t('One or more dates are allready booked.');
}



// Bestaat het ene of het andere al???

$sql3 = "
	SELECT COUNT(*) FROM {node} n, {content_type_reservatie} r 
	WHERE n.nid = r.nid
	AND (r.field_res_when_value < '%s' AND r.field_res_when_value2 > '%s')
";

$result3 = db_query($sql3, $dt1, $dt2);
$cnt3 = db_result($result3);

if($cnt3 > 0){
$error++;  
$error_txt .= t('Overlapping bookings are not alowed.');
}


if($error > 0){
form_set_error('field_res_when', $error_txt);
}

This seems to do the job in preventing people to make overlapping bookings. My problem now is the calendar. People were now able to select their own start and end time but in the calender only the start time is shown as "booked". Could someone help me with customizing the calendar-day.tpl.php so that it shows booked between the 2 time settings.

Example:

User selected start: 15:00h, end: 20:00h
Current page shows: 15:00 is booked, the rest shows link to book (however with my code i just showed you, people will get error if they select for example 19:00h).
What i'd like to show: between 15:00 and 20:00 everything booked.

I don't mind if it's dirty coding, I just really need this to work. I'll be carefull when installing updates.

Thanks in advance,
Hatznie.

kenorb’s picture

Status: Active » Postponed
kenorb’s picture

Component: Code » booking_timeslots
Status: Postponed » Fixed

Time slots conflicts are checked by booking_timeslots_check_slot_availability() in booking_timeslots_validate().
Raise separate bug reports, if there are any.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.