function testBookingModule() { $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($b->get_id() == $today . "Meghan2075551234"); $this->assertEqual($b->get_date_submitted(), $today); $this->assertTrue($b->get_date_in() == ""); $this->assertEqual($b->get_guest_id(), "Meghan2075551234"); $this->assertEqual($b->get_status(), "pending"); $this->assertEqual($b->get_room_no(), ""); $this->assertEqual($b->get_patient(), "Tiny"); $occ = $b->get_occupants(); $this->assertTrue(in_array("Jean:father", $occ)); $this->assertEqual($b->get_linked_room(), ""); $this->assertEqual($b->get_date_out(), ""); $this->assertEqual($b->get_referred_by(), "Millie2073631234"); $this->assertEqual($b->get_hospital(), "Maine Med"); $this->assertEqual($b->get_department(), "SCU"); $this->assertEqual($b->get_payment_arrangement(), "\$10 per night"); $this->assertEqual($b->overnight_use(), ""); $this->assertEqual($b->day_use(), ""); $this->assertEqual($b->get_mgr_notes(), ""); $this->assertEqual($b->get_flag(), "new"); for ($i = 0; $i < 11; $i++) { $this->assertEqual($b->get_health_question($i), "0"); } $b->add_occupant("Jordan", "brother"); $this->assertEqual(sizeof($b->get_occupants()), 4); $b->remove_occupant("Jordan"); $this->assertEqual(sizeof($b->get_occupants()), 3); echo "testBooking complete"; }
function build_POST_booking($primaryGuest, $referralid) { $current_date = date("y-m-d"); $referred_by = trim(str_replace("'", "\\'", htmlentities($_POST['referred_by']))); $hospital = trim(str_replace("'", "\\'", htmlentities($_POST['hospital']))); $department = trim(str_replace("'", "\\'", htmlentities($_POST['dept']))); if ($_POST['payment'] != "other") { $payment = "10 per night"; } else { $payment = trim(str_replace("'", "\\'", htmlentities($_POST['payment_description']))); } $notes = trim(str_replace("'", "\\'", htmlentities($_POST['notes']))); $healthvalues = array("flu", "shingles", "tb", "strep", "lice", "whoopingcough", "measles", "nomeaslesshot", "chickenpox", "chickenpoxshot", "hepatitisb"); $health_questions = ""; for ($i = 1; $i <= 11; $i++) { if ($_POST['health'] && in_array($healthvalues[$i - 1], $_POST['health'])) { $health_questions .= "1"; } else { $health_questions .= "0"; } } if ($_POST['visitOrWC'] == "Will Call") { $date_in = "Will Call"; } else { if ($_POST['date_in_year'] && $_POST['date_in_month'] && $_POST['date_in_day']) { $date_in = $_POST['date_in_year'] . '-' . $_POST['date_in_month'] . '-' . $_POST['date_in_day']; } } if ($referralid) { $pendingBooking = retrieve_dbBookings($referralid); $pendingBooking->set_health_questions($health_questions); $pendingBooking->set_payment_arrangement($payment); $pendingBooking->set_mgr_notes($notes); $pendingBooking->set_referred_by($referred_by); $pendingBooking->set_hospital($hospital); $pendingBooking->set_department($department); $pendingBooking->remove_occupants(); } else { $pendingBooking = new Booking($current_date, $date_in, $primaryGuest->get_id(), "pending", "", $primaryGuest->get_patient_name(), array(), array(), null, null, $referred_by, $hospital, $department, $health_questions, $payment, $_POST['overnight'], $_POST['day'], $notes, "new"); } $pendingBooking->add_occupant($primaryGuest->get_first_name() . " " . $primaryGuest->get_last_name(), $primaryGuest->get_patient_relation()); for ($count = 1; $count <= 4; $count++) { if ($_POST['additional_guest_' . $count] != "") { $pendingBooking->add_occupant($_POST['additional_guest_' . $count], $_POST['additional_guest_' . $count . '_relation']); } } insert_dbBookings($pendingBooking); return $pendingBooking; }