Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I would like to make a view displaying how many nights are booked in a particular month. I thought that just counting the number of days that are 'unavailable' in a month would do it, but I cannot find the field where room X at date Y is set to unavailable.
It is not the booking status field anyway, that field is switched to 1 as soon as a booking is confirmed, but such a booking can consist of any number of days. So which field should I use?
Comment | File | Size | Author |
---|---|---|---|
#6 | rooms_occupancy_rate_report.txt | 10.25 KB | LeDucDuBleuet |
Comments
Comment #1
LeDucDuBleuet CreditAttribution: LeDucDuBleuet commentedI would also like to know the best approach to provide such a report for occupancy rate?
Any hint would be greatly appreciated, thank you.
Comment #2
plopescHello,
Here is a brief example of how you can extract this kind of information.
You should implement something like this in a custom module.
Hope this helps.
Comment #3
TheoRichel CreditAttribution: TheoRichel commentedThank you very much. I am sure this is very useful, but alas I am not a programmer and wouldnt know what to do with this.
Comment #4
LeDucDuBleuet CreditAttribution: LeDucDuBleuet commentedI created a view to report the occupancy rate using PHP so you need to have the module https://www.drupal.org/project/views_php enabled. The code is pretty simple and it should work by simply importing the view in your system but your mileage may vary. Contact me privately if you need my services to adapt it to your needs.
I tried to make the view as generic as possible, I hope this helps!
Comment #5
LeDucDuBleuet CreditAttribution: LeDucDuBleuet commentedI am marking this issue as "Needs work" because the view needs adjusting before it can work on a specific site.
Comment #6
LeDucDuBleuet CreditAttribution: LeDucDuBleuet commentedHere is an updated view which will show the units occupancy rate for the last 365 days and will import cleanly in a system with a basic rooms installation. The previous one was using a content type specific to our system, sorry to have miss this...
Comment #7
TheoRichel CreditAttribution: TheoRichel commentedThanks very much LeDucDuBleuet, your view works wonderful
Comment #8
dorys CreditAttribution: dorys commentedThis is a great View. I am just wondering if there is anyway to add a date filter so instead of
$start_date = new Datetime ('now - 364 days');
$end_date = new Datetime ('now');
both start date and end date are filterable?