Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed redundant update of availability calendar #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions modules/rooms_booking/rooms_booking.module
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,13 @@ class RoomsBookingController extends EntityAPIController {

$entity->rooms_av_update = $responses[$event_id];

// If the event addition was succesful lock the event.
if ($responses[$event_id] == ROOMS_UPDATED) {
$be->lock();
watchdog('rooms_booking', 'Unit availability has been updated.', array(), WATCHDOG_NOTICE);
}
else {
watchdog('rooms_booking', 'Unit availability could not be updated.', array(), WATCHDOG_ERROR);
}
}
}
Expand Down
28 changes: 0 additions & 28 deletions modules/rooms_booking_manager/rooms_booking_manager.module
Original file line number Diff line number Diff line change
Expand Up @@ -1956,34 +1956,6 @@ function rooms_booking_manager_commerce_checkout_complete($order) {
// Line item 'Entity Reference field' that points to the booking.
$line_item->rooms_booking_reference['und'][0]['target_id'] = $booking->booking_id;
commerce_line_item_save($line_item);

// Now let us lock availability
// First - we get an event id.
$id = rooms_availability_assign_id($booking->booking_id, '1');
// Set the start and end dates for the booking event.
// They are the same as the booking above but the end date is not the
// departure date rather it is the last night spend in the room.
$sd = new DateTime($booking->start_date);

// End date is actually a day less.
$ed = new DateTime($line_item->rooms_booking_dates[LANGUAGE_NONE][0]['value2']);
$ed->sub(new DateInterval('P1D'));

// Create a booking event.
$be = new BookingEvent($booking->unit_id, $id, $sd, $ed);

// Call up the UnitCalendar for this unit and add the event to it.
$rc = new UnitCalendar($booking->unit_id);
$responses = $rc->updateCalendar(array($be));

// If the event addition was succesful lock the event.
if ($responses[$id] == ROOMS_UPDATED) {
$be->lock();
watchdog('rooms_booking_manager', 'Unit availability has been updated.', array(), WATCHDOG_NOTICE);
}
else {
watchdog('rooms_booking_manager', 'Unit availability could not be updated.', array(), WATCHDOG_ERROR);
}
}
}
}
Expand Down