/** * Checks-out all applicable allocations for the given booking id and checkout date. * $bookingId : id of booking to check out * $forDate : date of checkout (default today) * Returns updated BookingSummary for booking id */ function doCheckoutsForBooking($bookingId, $forDate = null) { if ($forDate == null) { $forDate = new DateTime(); } // find all allocations that can be checked-out for the given date and toggle checkout $allocationIds = self::findAllowableCheckoutsForBooking($bookingId, $forDate); foreach ($allocationIds as $allocationId) { self::toggleCheckoutOnBookingDate($allocationId, $forDate); } return BookingDBO::fetchBookingSummaryForId($bookingId); }
/** * Create a sample booking and verify it is saved correctly. * * firstName : first name * lastName : last name * numVisitors : number of guests to add, array indexed by 'M', 'F', 'X'. * resourceId : id of resource to assign to (nullable) * reqRoomSize : requested room size (e.g. 8, 10, 10+, P, etc..) * reqRoomType : requested room type (M/F/X) * dates : array of dates (String) in format dd.MM.yyyy * resourceProps : array of resource property ids (allocate only to resources with these properties) (optional) */ private function createTestBooking($firstName, $lastName, $numVisitors, $resourceId, $reqRoomSize, $reqRoomType, $dates, $resourceProps = array()) { $booking = new AddBooking(); $booking->firstname = $firstName; $booking->lastname = $lastName; $booking->referrer = "Telephone"; $booking->depositPaid = 9.9; $booking->amountToPay = 19.8; $booking->addAllocation($numVisitors, $resourceId, $reqRoomSize, $reqRoomType, $dates, array()); // $resourceProps $errors = $booking->doValidate(); $this->assertEquals(0, sizeof($errors), "Validation error found on AddBooking"); $booking->save(); $this->assert($booking->id > 0, "Expecting booking id to be non-zero"); // verify saved contents // assumes dates are in chronological order $firstDate = array_shift(array_values($dates)); $bookingSummaryArr = BookingDBO::getBookingsForDateRange(DateTime::createFromFormat('!d.m.Y', $firstDate), DateTime::createFromFormat('!d.m.Y', $firstDate), 'checkin', null, null, $lastName); $this->assertEquals(1, sizeof($bookingSummaryArr), "Expecting 1 created booking"); // verify booking summary query brings back the saved values $bookingSummary = array_shift(array_values($bookingSummaryArr)); $this->assertEquals($firstName, $bookingSummary->firstname, "firstname"); $this->assertEquals($lastName, $bookingSummary->lastname, "lastname"); $this->assertEquals("Telephone", $bookingSummary->referrer, "referrer"); $this->assertEquals($numVisitors['M'] + $numVisitors['F'] + $numVisitors['X'], sizeof($bookingSummary->guests), "guests"); $this->assertEquals(sizeof($dates), sizeof($bookingSummary->bookingDates), "bookingDates"); foreach ($dates as $dt) { $this->assert(in_array(DateTime::createFromFormat('!d.m.Y', $dt), $bookingSummary->bookingDates), "Expecting {$dt}"); } }
/** * Loads existing comments from the db. * $bookingId : booking id for this allocation */ function load($bookingId) { $this->comments = BookingDBO::fetchBookingComments($bookingId); }
/** * Loads the data for this object from an existing booking id. * $bookingId : id of existing booking */ function load($bookingId) { $rs = BookingDBO::fetchBookingDetails($bookingId); $this->id = $rs->booking_id; $this->firstname = $rs->firstname; $this->lastname = $rs->lastname; $this->referrer = $rs->referrer; $this->depositPaid = $rs->deposit_paid; $this->amountToPay = $rs->amount_to_pay; $this->allocationTable->load($bookingId); $this->commentLog->load($bookingId); }