function testdbBookingsModule() { // create a booking and test inserting and retrieving it from dbBookings $today = date('y-m-d'); $b = new Booking($today, "", "Meghan2075551234", "pending", "", "Tiny", array("Meghan:mother", "Jean:father", "Teeny:sibling"), array(), "", "", "Millie2073631234", "Maine Med", "SCU", "00000000000", "\$10 per night", "", "", "", "new"); $this->assertTrue(insert_dbBookings($b)); $this->assertTrue(retrieve_dbBookings($b->get_id())); //$this->assertTrue(in_array("Meghan2077291234", $b->get_guest_id())); //checks that the initial status is "pending" $this->assertTrue(retrieve_dbBookings($b->get_id())->get_status(), "pending"); //checks that initial flag is "new" $this->assertTrue(retrieve_dbBookings($b->get_id())->get_flag(), "new"); $pending_bookings = retrieve_all_pending_dbBookings(); // $this->assertEqual($pending_bookings[0]->get_id(), $b->get_id()); // make some changes and test updating it in the database // Add a loaner to the booking $b->add_loaner("remote3"); $b->add_occupant("Jordan", "brother"); $b->set_flag("viewed"); $this->assertTrue($b->assign_room("126", $today)); $bretrieved = retrieve_dbBookings($b->get_id()); $this->assertTrue(in_array("Jordan: brother", $bretrieved->get_occupants())); $this->assertTrue(in_array("remote3", $bretrieved->get_loaners())); $this->assertEqual($bretrieved->get_status(), "active"); $this->assertEqual($bretrieved->get_id(), $b->get_id()); $this->assertEqual($bretrieved->get_room_no(), "126"); $today = date('y-m-d'); $this->assertEqual($bretrieved->get_date_in(), $today); $this->assertEqual($bretrieved->get_flag(), "viewed"); //tests updating after a checkout $this->assertTrue($bretrieved->check_out($today)); $bretrieved2 = retrieve_dbBookings($b->get_id()); $this->assertEqual($bretrieved2->get_status(), "closed"); $this->assertEqual($bretrieved2->get_date_out(), $today); //tests the delete function $this->assertTrue(delete_dbBookings($b->get_id())); $this->assertFalse(retrieve_dbBookings($b->get_id())); echo "testdbBookings complete"; }
include_once "roomLogView.inc"; //echo ("</table>"); } else { echo "<h3 style=\"text-align:center\">Roomlog for " . $formattedDate . " not found</h3><br>"; // Display a form that let's you choose another date display_navigation($date); } ?> <!-- Display a list of pending bookings --> <h4 style="text-align:center"> Pending Bookings (and dates submitted)</h4> <form style="text-align:center" name="chooseBooking" action="viewBookings.php" target="_blank"> <select name="bookingid"> <?php // Grab a list of all pending bookings $pendingBookings = retrieve_all_pending_dbBookings(date("y-m-d")); if ($pendingBookings) { // Make each booking id a menu item foreach ($pendingBookings as $booking) { echo "<option value='" . $booking->get_id() . "'>"; $person = retrieve_dbPersons(substr($booking->get_id(), 8)); if ($person) { echo $person->get_first_name() . " " . $person->get_last_name() . " (" . date_string(substr($booking->get_id(), 0, 8)) . ")"; } else { echo $booking->get_id(); } echo "</option>"; } // Then add a button echo "<input type=\"submit\" value=\"View Booking\"/>"; }
if ($_GET['r'] != 'r') { //determines whether to append an r parameter to a particular sort link if ($s == 'flag') { $r5 = "&r=r"; } elseif ($s == 'datein') { $r4 = "&r=r"; } elseif ($s == 'patient') { $r3 = "&r=r"; } elseif ($s == 'guest') { $r2 = "&r=r"; } else { $r1 = "&r=r"; } } //retrieve all the pending bookings $pending_bookings = retrieve_all_pending_dbBookings(); $num_bookings = sizeof($pending_bookings); //handles the case when there are no pending bookings if ($num_bookings == 0) { echo "<p><b> There are currently no pending bookings. </b>"; } else { //sort based on the sort parameter usort($pending_bookings, $sort); //reverse the sort if r is set if ($_GET['r'] == 'r') { $pending_bookings = array_reverse($pending_bookings); } echo "<p>"; if ($num_bookings != 1) { echo "There are currently " . $num_bookings . " pending bookings: "; } else {