It is not possible to make reservations for an item without an emty timepart between reservations.
I cannot make reservation 1 between 09:30-10:00 and reservation 2 for the same item between 10:00-10:30. The next reservation after 10:00 is from 10h:01m. The end time and start time are conflicting, I think.

In our sitiuation we have a 30 min reservation time period (a default date setting) and this is a problem.

Is it possible to make the reservation time an in between time in stead of from-to? Or maybe by reducing the end time with a second.

Comments

darrick’s picture

Title: Time between 2 reservations » Support back to back reservations
Category: bug » feature
Priority: Normal » Minor

This would be moderately difficult to fix. One problem is the conflict grid only works in 15 minute increments. The code would need to be audited to find the spots where reservation a to < reservation b and changed to reservation a to <= reservation b. I'm a bit to busy right now but would welcome a patch.

mhamilton’s picture

The workaround we went with was to change MERCI granularity down to minutes as opposed to the 15 minute increments and make reservations up to the 59 or 29 mark. I.E. 1:00 - 1:29, next reservation 1:30 -1:59.

Obviously you're going to be losing a minute per reservation, and in the long run this may add up in reporting, but it's something.

Darrick or Kevin is there any reason to not go with this method?

Anonymous’s picture

Our workaround, patching date.module and merci reservation content type:

It creates one date popup (booking only on the selected date) a pop up start time (24h format) and booking time span (1, 2, 3, .. 8 hour). To create a back to back reservation the time span (end time) is saved as full hour minus one minute: One hour booking from 10:00-11:00 is saved as 10:00-10:59.

workaround:
Install date.module and merci.module (....)
For one calendar pop-up install the date patch: http://drupal.org/node/127200#comment-3902902
For patching date-popup, install the date patch http://drupal.org/files/issues/233047-date-timepicker-alternative_0.patch
Replace the content in /date/date_popup/lib/date_popup.timedropdown.js with the code (Pimm thanks for the code).

Setup date.module and date_popup(!) to your needs and change the 'To date' setup (!) in field_merci_date in reservations contenttype (you can make it visable in Merci settings).

/**
 * Attaches dropdown select behavior to time textfields.
 */
Drupal.behaviors.datePopupTimeDropdown = function (context) {
	for (var id in Drupal.settings.datePopup) {
		var datePopup = Drupal.settings.datePopup[id];
		var $timeWrapper = $('#' + id).parent();
		if (datePopup.func == "timeEntry" && false == $timeWrapper.hasClass("timeDropdown-processed")) {
			// Hide the real field.
			$timeWrapper.addClass("timeDropdown-processed").attr("style", "display: none");
			// The from field should be replaced by the hour count field, and the duration field.
			if (/\-value\-/.test(id)) {
				// Compute default values.
				var current = $('#' + id).val();
				if (current != undefined && current.length) {
					defaultHour = current.substr(0, 2);
				}
				// Generate the dropdowns.
				var hourDropdown = '<select id="' + id + '-hours">';
				for (var i = 0; i < 24; i++) {
					var val = i;
					if (i < 10) {
						val = '0' + val;
					}
					hourDropdown += '<option value="' + val + '"' + (i == defaultHour ? ' selected="selected"' : '') + '>' + i + ':00</option>';
				}
				hourDropdown += '</select>';
				var durationDropdown = "<select id=\"" + id + "-duration\">";
				for (var index = 1; index < 9; index++) {
					durationDropdown += "<option value=\"" + index + "\"" + function() {
						if (1 == index) {
							return " selected=\"selected\"";
						} else {
							return "";
						}
					}() + ">" + index + " " + function() {
						if (1 == index) {
							return "uur";
						} else {
							return "uren";
						}
					}() + "</option>";
				}
				durationDropdown += "</select>";
				var dropdowns = '<span id="datedroplabel">' + Drupal.t('at') + '</span> ' + hourDropdown + "gedurende " + durationDropdown;
				$timeWrapper.after(dropdowns);
				// Update real time fields on dropdown change.
				$('#' + id + '-hours, #' + id + '-duration').bind('change', id, function(event) {
					var id = event.data;
					var hour = parseInt($("#" + id + "-hours option:selected").val(), 10);
					$("#" + id).val(hour + ":00");
					$("#" + id.replace(/\-value\-/, "-value2-")).val((-1 + hour + parseInt($("#" + id + "-duration option:selected").val(), 10)) + ":59");
				});
			}
		}
	}
};
darrick’s picture

I've thought about this a bit. I would prefer not to change the validation functions to support a reservation time ending at the same exact time and new one begins. I've delved quite a bit into the date and calendar modules. Those modules would consider the reservations to be overlapping and display them as such. The best option is either @markhamilton suggestion.

Given what @cmeasy says. I would implement hook_form_alter and define a reservation length field and hide the reservation to field. Then attach a ahah handler to the length field. When the length field is changed the callback sets the reservation to field and updates the form.

jonscyu’s picture

@mhamilton: I'm trying to set up the same work-around for my own projects. That said I'm not a coder and an was wondering how you were able to set it up with the 1 minute granularity. Would it be possible to post your how-to here? Thanks.

gocaps’s picture

You can change the granularity in the merci.install file:
function _merci_installed_instances() : change 'increment' => '15' to 'increment' => '1'

If you've already installed the module, you can make the change in the database in the field_config_instance table.

I ended up changing the granularity to 1 minute, then I created a Reservation Duration field using hook_form_alter. I ended up using some jquery to take the duration selection and set the "Reservation To" field equal to start time + duration - 1 min.

mhamilton’s picture

Sorry for the delay on this gocaps, I just saw your message recently. Also my post may not make any sense as I had an in depth explanation typed up and unintentionally used one of the HIGHLY USEFUL Apple Magic Mouse shortcuts and found that I'd navigated back 3 pages and lost everything typed.

For gocaps & jonscyu and anyone else that stumbles across this: There's actually an easier and more "Drupal" way to achieve this that doesn't involve any code changes or hacks.

I'm positive our version of MERCI will differ from yours, but you should be able to find the setting at admin/settings/merci. From there you'll see an option to Unlock Core MERCI fields. This will allow you to edit the Datetime field titled field_merci_date on the Reservation content type, and alter the granularity. Without fields unlocked you'll be able to edit the content type, but not this particular (and some other) field(s).

Once unlocked either go to Content Types or the same merci administration page and edit Reservation -> Manage Fields -> Configure (for field_merci_date) then turn Time Increment down to 1.

I 'think' this is how I achieved this, but our initial setup was almost 2 years ago at this point so... fingers crossed. Good luck!

naiamaya’s picture

Would be nice if this was configurable option, so everyone could adapt to their own needs, allowing or not do at the same time the end and the beginning of a book.