function compute_roomcounts($allBookings) { $this->roomcounts = array(); $this->bookingcounts = array(); $this->guestcounts = array(); $allRooms = retrieve_all_rooms($this->date); foreach ($allRooms as $aRoom) { $this->bookingcounts[substr($aRoom, 0, 3)] = 0; $this->roomcounts[substr($aRoom, 0, 3)] = 0; $this->guestcounts[substr($aRoom, 0, 3)] = 0; } $this->bookingcounts["other"] = 0; $this->roomcounts["other"] = 0; $this->guestcounts["other"] = 0; foreach ($allBookings as $aBooking) { if ($aBooking->get_date_in() < $this->date) { $bStart = mktime(0, 0, 0, substr($this->date, 3, 2), substr($this->date, 6, 2), substr($this->date, 0, 2)); } else { $bStart = mktime(0, 0, 0, substr($aBooking->get_date_in(), 3, 2), substr($aBooking->get_date_in(), 6, 2), substr($aBooking->get_date_in(), 0, 2)); } $bEnd = mktime(0, 0, 0, substr($aBooking->get_date_out(), 3, 2), substr($aBooking->get_date_out(), 6, 2), substr($aBooking->get_date_out(), 0, 2)); $days = round(($bEnd - $bStart) / 86400); $bRoom = $aBooking->get_room_no(); $bGuests = sizeof($aBooking->get_occupants()); if (!$bRoom || $bRoom == "UNK") { $this->bookingcounts["other"] += 1; $this->roomcounts["other"] += $days; $this->guestcounts["other"] += $bGuests; } else { $this->bookingcounts[$bRoom] += 1; $this->roomcounts[$bRoom] += $days; $this->guestcounts[$bRoom] += $bGuests; } } }
function __construct($id) { $mm = substr($id, 3, 2); $dd = substr($id, 6, 2); $yy = substr($id, 0, 2); if (!checkdate($mm, $dd, $yy)) { $this->id = null; echo "Error: invalid date for RoomLog constructor " . $mm . $dd . $yy; return false; } $my_date = mktime(0, 0, 0, $mm, $dd, $yy); $this->id = date("y-m-d", $my_date); $this->month = date("M", $my_date); $this->day = date("D", $my_date); $this->year = date("Y", $my_date); $this->day_of_week = date("N", $my_date); $this->day_of_year = date("z", $my_date) + 1; $this->day_of_month = date("d", $my_date); $this->month_num = date("m", $my_date); $this->rooms = retrieve_all_rooms($this->id); // get all room_no:booking_id pairs for this date $this->log_notes = ""; $this->status = "unpublished"; return true; }