I am excited about the possibility in this module and having researched it I find that many hotels (and camping sites) have a challenge that needs addressing. At certain times of the year (as you noted in your video) there is very high demand. But left unchecked you could find everyone books just the weekends in July (but not the weekdays). What is needed is a rule that says something like If booking is between 1/7/11 and 20/7/11 and booking is <6 days then nothing available and show message "as this is high season we are only taking bookings for full weeks at present"

I am looking for guidance as to how to create such a useful rule please

Comments

ronald_istos’s picture

Category: support » feature

Interesting idea and I definitely see a use case for things. Partially links to the already suggested idea of a minimum period use case. Hopefully we can get back to this soon.

ronald_istos’s picture

Title: Classy rules » Ability to flexibly define length of booking periods and rates for those periods

changed title to make it clearer

donquixote’s picture

This is actually three things:
1) minimum duration to stay
2) Make weekends more expensive than weekdays
3) fixed day of the week for arrival / departure. E.g. you can only book from Saturday to next Saturday. This would split the year in weeks instead of days.

(just noticed that the other issue is closed as duplicate, #1496286: A minimum booking period)

My own use case is number (3), I am building for a chalet where people can book a week Sat-Sat, but not just a day.

artatac’s picture

StatusFileSize
new16.77 KB

patxh attached for adding the features as described above - please consider rolling into module

1an_m’s picture

Fantastic! This solves one issue for me, my use case requires specifying a minimum 7 night stay for high season.

When I apply the patch, I get an error message that the hunk patching rooms_unit.info failed, but the patch seems to work anyway. (I can specify a minimum 7 night stay under bookings settings, and update the availability of rooms for a specified time frame to "available for minimum stay")

Any chance you could make a patch for one of the other components mentioned immediately above the post with your patch?
3) fixed day of the week for arrival / departure. E.g. you can only book from Saturday to next Saturday.

I am far from having the skills to do it myself, and note that it took ~44 weeks from the time that you posted the original feature request, to posting the patch to implement it.

Ian

codesmith’s picture

I installed the patch to get the minimum number of nights. Mixed results.

1) Got an error while install patching but seemed to still work ok.

patch -p1 < minimumstay-1265276-4.patch
patching file modules/rooms_availability/includes/rooms_availability.booking_event.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] y
Hunk #1 succeeded at 246 with fuzz 2 (offset 6 lines).
patching file modules/rooms_availability/rooms_availability.module
patching file modules/rooms_booking/includes/rooms_booking.availability_agent.inc
patching file modules/rooms_booking_manager/rooms_booking_manager.module
patching file modules/rooms_unit/rooms_unit.info
Hunk #1 FAILED at 21.
1 out of 1 hunk FAILED -- saving rejects to file modules/rooms_unit/rooms_unit.info.rej
patching file modules/rooms_unit/rooms_unit.module
patching file rooms_ui.module
codesmith:rooms codesmith$ cat modules/rooms_unit/rooms_unit.info.rej
***************
*** 21,24 ****
  files[] = views/rooms_unit_handler_unit_operations_field.inc
  files[] = views/rooms_unit_handler_unit_type_field.inc
  
- files[] = test/rooms_unit_test.test--- 21,24 ----
  files[] = views/rooms_unit_handler_unit_operations_field.inc
  files[] = views/rooms_unit_handler_unit_type_field.inc
  
+ files[] = test/rooms_unit_test.test

2) Under Booking Settings I set minimum length to 2 days and under "Valid Availability States" checked only "Rooms marked as available with inimum stay" (Note misspelling)

3) Did a search for rooms and no rooms were available - for any combo of dates. If I also select the "Valid Availability State" of "Rooms marked as available" then I get results.

hooligangel’s picture

My use case is (3) above: fixed day of the week for arrival / departure, plus 7 day stay period.
The clients arrive on Saturday (Sunday) afternoon and leave on next Saturday (Sunday) morning (7 night stay). Another option - monthly rentals that splits the year in months.

I applied the patch on the clean installation on a windows localhost
(1) where should I put the price for the week?
(2) If the first day is Saturday, Rooms calculates 7 nights but I have to make "minimum stay" as 6 days to make it work from Saturday to Saturday. Then there is a price calculation problem, because the system calculates the stay "Arrival 15-09-2012 departure 22-09-2012" as 6 nights instead of 7 nights.

1an_m’s picture

StatusFileSize
new16.8 KB

Have made a few minor edits to artatac's minimum stay patch from reply #4

  1. Fixed a few typos ('inimum', 'mimimim', 'lenght') in code
  2. Changed references to "Days" to "Nights" and changed comparison code to account for the fact that the number of nights is one less than the count of days (first day to last day, inclusive), as opposed to the difference between first date and last date (see reply #7)

Still reading and learning to try and come up with a solution to the fixed day of week for arrival!

@hooligangel

  1. You don't need to set the price for the week, just for the night! The minimum stay patch will enforce a 7 night minimum stay for you, and regular rooms module will calculate (price for 1 night) x (7 night stay)
  2. Part i) See updated patch.
    Part ii) Calaculation issue where 7 night stay is calculated as 6 nights (eg in 2nd page of booking cart), I think is a rooms module issue, which seems to have been fixed in the current beta4 version (works for me, anyway!)
donquixote’s picture

#8
Probably if you have a week option and a day option, you want the Saturday - Saturday week price to be cheaper than 7x day price.

acrollet’s picture

Status: Active » Needs work

I'd like to review this patch, but it's pretty out of date at this point. Please re-roll against the latest 7.x-1.x-dev, thanks!!

1an_m’s picture

StatusFileSize
new16.86 KB

I have re-rolled the patch against 7.x-1.x-dev as requested.

  • Thanks to artatac for original patch!
  • Fixed date comparison for minimum stay (to account for updated code in availability results page.)
  • Also added code for color picker for Minimum Stay (under "Calendar Color Codes" in Booking Settings page (.../admin/rooms/config/bookings).

All works as expected on my test site.

1an_m

acrollet’s picture

Assigned: Unassigned » ronald_istos
Status: Needs work » Needs review
StatusFileSize
new19.8 KB

@1an_m: thanks much for re-rolling! I'm attaching an updated patch with a wording change and some formatting fixes, but overall the patch works for me and meets the basic use case. I'd really like to see the ability to set different minimum stay lengths for different units/time periods, but I don't know if that should be a reason not to get this in now - assigning to Ronald for review/comment.

1an_m’s picture

I agree that a more flexible approach as you suggested would be good.

I am currently working on adding fixed day of the week for arrival to the patch as it stands, but thought it would be worth discussing the possible use cases before going too far down that road.

For my own use case, adding the fixed arrival day of week to the current patch would be fine (I need to be able to specify min stay 7 days, Saturday to Saturday, and apply to all units for a given time period). Doing this should be fairly straightforward

  • add dropdown list to rooms_ui.module with 8 values: 'unspecified' + one for each weekday
  • add a variable, comparison code, and output code to rooms_booking_manager.module near the changes for the minimum stay patch

However I'm not sure if there is a use case for a more complex /flexible application of the fixed arrival day of week. ie do we need to allow for

  • more than one specified arrival day of week
  • fixed arrival day of week independent of miniumum stay
roman_pro’s picture

Any updates on this? Particularly I'm interested in the fixed day of arrival feature and may help with implementation.

mabo1972’s picture

Category: feature » support

I applied the patch #12 but the "minimum stay" feature does not work.
In the Booking Settings i configure a minimum stay for 7 days.

but I still can book all rooms for 2 or less than 7 days

junkbox’s picture

Tried applying this patch and got many HUNK errors, is this patch valid against the current release candidate (rc2) or the newest dev build? I currently have rc2 installed but will migrate to dev if the patch is actually valid it against it still. If neither of those are true, then is there any intention of re-rolling to be compatible with either dev or current release candidate?
I'm trying to diff them in an IDE and not having much luck as it looks like there's been some structural changes in rooms_availability and rooms_booking and there's a few HUNKS that no longer seem to appear in the files they were previously in when the patch in #12 was re-rolled namely:

HUNK 6: \modules\rooms_booking_manager\rooms_booking_manager.module
HUNK 7: \modules\rooms_booking\includes\rooms_booking.availability_agent.inc
HUNK 8: \modules\rooms_availability\includes\rooms_availability.booking_event.inc
HUNK 15: \modules\rooms_availability\rooms_availability.module

junkbox’s picture

So, for the most part the patch in #12 can be gone through Hunk by hunk and applied OK. The only bit that has changed drastically seems to be this (in modules/rooms_booking_manager/rooms_booking_manager.module):

@@ -744,19 +782,22 @@ function book_units_per_type_form_submit(&$form, &$form_state) {
       if ($unit_order['quantity'] > 0) {
         for ($i = 1; $i <= $unit_order['quantity']; $i++) {
           $agent = new AvailabilityAgent($sd->format($date_format), $ed->format($date_format), 1, 1, array(), array($type));
-          $agent->setValidStates(variable_get('rooms_valid_availability_states', array(ROOMS_AVAILABLE, ROOMS_ON_REQUEST)));
+          $agent->setValidStates(variable_get('rooms_valid_availability_states', array(ROOMS_AVAILABLE, ROOMS_ON_REQUEST, ROOMS_MINIMUM_STAY)));
 
           $units_per_type = $agent->checkAvailability();
           $available_units = $units_per_type[$type][$price_level];
 
           $unit = array_pop($available_units);
+          if ($unit['state'] !== ROOMS_MINIMUM_STAY_NOT_MET) {
+            // Create line item
+            $line_item = rooms_create_line_item($unit, $agent);
 
-          // Create line item
-          $line_item = rooms_create_line_item($unit, $agent);
-
-          // Add line item to cart
-          if (!empty($line_item)) {
-            $line_item = commerce_cart_product_add($user->uid, $line_item, FALSE);
+            // Add line item to cart
+            if (!empty($line_item)) {
+              $line_item = commerce_cart_product_add($user->uid, $line_item, FALSE);
+            }
+          } else {
+            drupal_set_message("Could not adding booking to cart, minimum stay not met.");
           }
         }
       }

Can anyone familiar with the above function lead me in the right direction? I'm confused as to the changes made between the patch in #12 and the current Release Candidate (rc2). With a little help I'd be happy to test the implementation against rc2 and Diff out a re-roll to be current. Like I said the above is the only part I can't wrap my skull around.

eebanos’s picture

Patch http://drupal.org/files/rooms-minimumstay-1265276-12.patch doesn´t work on the last dev version.

artatac’s picture

Hi Ronald
Is this a candidate for inclusion as a base feature? please. could it be a priority

junkbox’s picture

@artatac, curious as well did this feature make it into 7.x-1.0 I'm still able to assist but have to roll this thing out without it for now on rc3(with the dev fixes).

PN1’s picture

Thanks for Rooms!
Please integrate to

Rooms

the minimum amoung of days/nights

minimumstay

function as standard. Will be great.

PN1’s picture

Version: 7.x-1.x-dev » 7.x-1.0
Component: Rooms Availability » Rooms Pricing
Category: support » bug
Priority: Normal » Major
Status: Needs review » Postponed (maintainer needs more info)

I installed the patch "rooms-minimumstay-1265276-12.patch via
Patch Manager (Info about Patch Manager module patch_manager)
In Rooms administration

Booking Settings

can´t see the field for minimum days restriction and the reservation process still allows to order one night.

I am patch newbie but please how to let the patch work?

URL to patch: www.testuj-to.cz/sites/default/files/patches/rooms-minimumstay-1265276-12.patch
folder atributes are on: default 555 (tried too 777),files 777,patches 775, rooms-minimumstay-1265276-12.patch 775 (tried too 777)
URL to node shows only in german language mutation (patch): http://www.testuj-to.cz/node/340

artatac’s picture

StatusFileSize
new24.31 KB

here is a revised patch that works with 7.x-1.0-rc3.1+22-dev

try it out at http://bookpitches.co.uk/ by booking a less than 4 days 20-31 oct

PN1’s picture

StatusFileSize
new76.21 KB

Hello artatac,

thanks for your reply and link!
But I tried to make reservation for just 1 night and provided it on http://bookpitches.co.uk/ without any problems...
Reservation for one night-bookpitches.co_.uk_4_.jpg
So the patch is unfortunately not working.

1an_m’s picture

PN1
The test website does work as advised! If you look carefully in your screenshot at the dates you chose, you will notice that they are in November, not in October (20-31) when the minimum stay requirement is set.

artatac
Thanks for the updated patch. It doesn't apply cleanly against the current dev version (but that is because of a typo in modules/rooms_unit/rooms_unit.admin.inc line 383 unites =/ unit, and not your patch). I also noticed that in the Bookings Settings page (site_url/admin/rooms/config/bookings) there is something not quite right about the underlying code, since the color settings for "Room available with mimimum stay" appears outside the box that contains the rest of the Calendar color codes. I haven't had a chance to look into this yet.

artatac’s picture

Interesting

I no longer have access to my programmer so if (you/someone) has a chance to upload a patch that will work with the latest dev, we can ensure that this feature is not lost

PN1’s picture

StatusFileSize
new61.21 KB

hello 1an_m,
thanks for your reaction!
Yes you right, I overlooked the right term.
I tried to make reservation in the right term (from 21-31 October) for just 2 nights and the system
doesn´t allow to provide it on http://bookpitches.co.uk/ So its working right.
bookpitches.co_.uk__2.jpg

I downloaded the patch https://drupal.org/files/minimum-stay-1265276-thing.patch
an will try it again.

1an_m’s picture

@artatac

Do you have an approximate date for that the patch was first applied successfully on your test site? I am trying to reroll the patch against current dev version, but need to find a commit for which the patch applied cleanly. From the info that you provided ("works with 7.x-1.0-rc3.1+22-dev") it looks like it is around 19 Apr 2013, but a more accurate date would help to identify the correct start date for rerolling the patch.

artatac’s picture

Sure the patch was created on the 29th July. if there is info/timestamp within the Drupal site that would help more then let me know. Also I have zipped a working test site with the db file on the root and placed it at http://bookpitches.co.uk/aapitches05.zip
Also in the spirit of community helping each other I was hoping that you could point me to someone who could fix the fact that the availability search is not used to populate the booking>person/children e.g.: http://bookpitches.co.uk/demo/booking for say "Group size 3 Children 1" > Search for availability
If you then chose 1 unit the Persons default to the max (6)
and children to 0
these should inherit from the availability search or users have to reinput the details. Happy to pay for this change if required

summit’s picture

Hi,
@artatac, hopefully you keep updating your site in the open. Would love to see this evolve! I think drupal has lots of ingredients to get this working, if this booking dialog becomes stable!
Greetings, Martijn

artatac’s picture

Hi just seeing if your revised patch is working with the latest dev and if I could have it. I am trying to get another issue patched https://drupal.org/node/2113209 but would like to get it patched against latest dev rather than my rooms version that works for me

1an_m’s picture

StatusFileSize
new24.41 KB

@artatac
Here is the revised patch. Sorry it took a while (I have a real job also!).
Thanks very much for your info and the zipped copy of your test site, which enabled me to sort out the issues.

I removed some whitespace errors, and moved the minimum stay options on Bookings Settings page [siteurladmin/rooms/config/bookings] to be within the drop-down menu "Calendar Color Codes & Labels".

There was also a change affecting rooms_unit_admin.inc, which I removed. see #1990710: possible typo in rooms_unit_admin.inc. This is fixed in 7.x-1.0 and also master, but not yet in 7.x-1.x (dev) for some reason.

Anyway, I have tested the patch and it seems to work for me, let me know ...

artatac’s picture

StatusFileSize
new225.32 KB

Hi

I have tried it and at e.g. http://bookpitches.co.uk/demo3/booking/2013-11-18/2013-11-19/1?rooms_gro... (set Nov 8-31 min booking 3 days)

All settings seem correct but booking is allowed to go ahead without warning. Zip of patched latest rooms dev FYI

Regards

Joe

ps also created css to tidy look when adding children/age (screenshot attached)

artatac’s picture

StatusFileSize
new18.68 KB

oops screen shot
screen

1an_m’s picture

Hi artatac,

I can't tell why minimum stay is not being enforced on your test site in the date range you have set. Without admin access I can't check if availability for all your "rooms" is set to minimum stay over this date range. Also wondering how you updated rooms project to current dev? (rooms.info still has version = "7.x-1.0-rc3.1+22-dev")

It does work on my own test site (rooms project dev version obtained with git clone, then patch applied with git apply).

artatac’s picture

Issue summary: View changes

Retried using git and now working well. Thank you

1an_m’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new24.37 KB

Uploaded new version of patch.
Functionality the same, corrected a few typos

@ronald_istos
could this be considered for inclusion please

1an_m’s picture

StatusFileSize
new24.46 KB

Re-rolled patch for latest dev

1an_m’s picture

StatusFileSize
new24.36 KB

Accidentally re-introduced change made in recent commit on dev. Attached rerolled patch without this error.

akanbiabubakar’s picture

Was anyone able to solve item 3 on this post?:

This is actually three things:
1) minimum duration to stay
2) Make weekends more expensive than weekdays
3) fixed day of the week for arrival / departure. E.g. you can only book from Saturday to next Saturday. This would split the year in weeks instead of days.

I had to solve it crudely, works for me, but I believe you guys would do a better job of it.

ronald_istos’s picture

Category: Bug report » Feature request

Moving this to a feature request - we will be working on this in the next couple of weeks.

1an_m’s picture

Issue tags: +Needs reroll

patch at #39 (minimum_stay-1265276-39.patch) is stale, needs reroll

kevster’s picture

Would br great to get a re-roll on #39 to work with the new stable rooms 1.2 - I did try to apply the patch but it only partially applie ddue I suspect to code changes. I would do this myself but apologies for not having the skills to do this.

Im happy to test any re-rolls. Many thx - Kevin

1an_m’s picture

StatusFileSize
new26.53 KB

Have been working on a re-roll. Almost complete: as it stands,

  • works if Rooms availability search settings (lowermost tab on /admin/rooms/config/bookings) Results Presentation Mode is set to "Show availability on a per-type basis."
  • the other option ("Show availability of individual units.") works (ie no units shown in search results if minimum stay requirement is not satisfied by the chosen booking dates), but there is no explanatory message shown to the website user (message in code is not currently displayed)

Let me know if you find other issues

@ronald_istos: any update on when/if this feature might be added?

ronald_istos’s picture

Hi - we've been working on a more generalised "Constraints" module that integrates with both Unit Types and Units. You can check out progress on our Github repository - https://github.com/BluesparkLabs/DrupalRoomsModule.

The idea is that you activate this extra module to get this functionality since it may not be something everyone needs.

1an_m’s picture

Thanks,

The new "Constraints" module looks great. Looking forward to being able to set

  • minimum stay
  • maximum stay
  • start day

for a range of dates
for a unit or all units

This will satisfy the requirements outlined in the first few comments, in a very configurable way.

Looks like the admin settings for this not yet exposed to site administrator, but appears that some of the existing patch may be helpful in this regard.

kevster’s picture

Great - many thx @1an_m I will test that as keen to get a project live asap and great news @ronald_istos look forward to that contrib module!

kevster’s picture

Hi @1an_m,

I just applied the patch #44 against rooms 1.2 and had to manually patch rooms_booking_manager.module and rooms_ui.module as it only partially applied. Once I worked out that I had to set the bookable units to "availability for min stay" it all seems to work fine.

I also set Valid availability states under booking settings to "Units marked as available with minimum stay". Many thx!

acrollet’s picture

Status: Needs review » Closed (fixed)

Please have a look at https://www.drupal.org/project/rooms_availability_constraints for this functionality.

googletorp’s picture

Issue tags: -Needs reroll