Posted by atontimes on November 9, 2010 at 6:15am
5 followers
Jump to:
| Project: | Public Bookings |
| Version: | 6.x-3.0-alpha1 |
| Component: | Public Bookings |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Issue Summary
Hi
I want to create calendar of the booked days on the bookable resource page, for example on the "flat" page. Human will book a nessasary flat to specific date, and on the flat page on booking calendar this dates marked as booked.
How i can did it?
PS, excuse me for my bad english.
Comments
#1
I'm not entirely sure that I understood what you need.
Lets use your example:
You have one system administrating e.g. ten flats for a motel. Each flat has its own page. On this page a calendar is displayed showing for each day whether the given flat is available or not.
Available days are links allowing a user to directly book this flat for the given day, correct?
If yes you could have a look at the Event Booking extension, it might provide the needed functionality. An alternative would be using the "Bookings Free Cache"-submodule (for the display of available times) and an adoption of the "Booking Button"-submodule (for the booking link)
#2
thanks tirsales,
i used calendar_block module for this, this module has hook where i can write some code to display available days for the flat.
It's very cool module.
#3
Fantastic :) Could you share your code? I'm very interested in seeing new ways to display bookings
#4
sure, this is a hook_calendar_block, i used it in the publicbookings.module.
function publicbookings_calendar_block(&$calendar, &$date, $op) {
switch($op) {
case 'alter':
$sql = "SELECT start, end
FROM bookings_schedules
WHERE resource_id = '%s' AND status = '4'";
$q = db_query($sql, $calendar->resource_id);
while ($row = db_fetch_array($q))
{
$start_date = strtotime($row['start']);
$end_date = strtotime($row['end']);
$cur_date = strtotime($date->day.".".$date->month.".".$date->year);
if($start_date <= $cur_date && $end_date >= $cur_date)
{
$date->content = ''.$date->day.'';
}
}
$sql = "SELECT start, end
FROM bookings_schedules
WHERE resource_id = '%s' AND status = '2'";
$q = db_query($sql, $calendar->resource_id);
while ($row = db_fetch_array($q))
{
$start_date = strtotime($row['start']);
$end_date = strtotime($row['end']);
$cur_date = strtotime($date->day.".".$date->month.".".$date->year);
if($start_date <= $cur_date && $end_date >= $cur_date)
{
$date->content = ''.$date->day.'';
}
}
break;
}
}
there i mark calendar of unconfirmed and booked days for the flat.
then, i change some code of calendar_block.module
I was change $calendar object on line 126, i add resource_id param:
// Resource ID used for Booking system
$resource_id = 0;
if (arg(0) == 'node') $resource_id = arg(1);
$calendar = (object) array(
'year' => date('Y'),
'month' => date('m'),
'weekdays' => $weekdays,
'resource_id' => (int)$resource_id,
);
And then i change calendar_block.js file, on line 63 i add this:
ref.ajax_settings.data.resource_id = Drupal.toJson(ref.settings.calendar.resource_id);
Then i put calendar_block block into my page.
That's all.
#5
subscribing
#6
Subscribing.
#7
Its possible to include this next releases? Dont like to code, its more dificult to further updates...
#8
Do you think its possible to use atontimes code in a next release?