public function show()
 {
     $excess_limit = 3;
     // Number of rows to show by default
     $count = 0;
     $tpl = array();
     $historyRows = array();
     $excessRows = array();
     $historyArray = $this->assignmentHistory->getHistory();
     foreach ($historyArray as $ah) {
         $row = array();
         if (defined($ah->assigned_reason)) {
             $assignedReason = constant($ah->assigned_reason);
             // for pretty text purposes
         } else {
             $assignedReason = $ah->assigned_reason;
         }
         if (defined($ah->removed_reason)) {
             $removedReason = constant($ah->removed_reason);
             // for pretty text purposes
         } else {
             $removedReason = $ah->removed_reason;
         }
         if (!is_null($ah->assigned_on)) {
             $assignedOn = date('M jS, Y \\a\\t g:ia', $ah->assigned_on);
         }
         if (!is_null($ah->removed_on)) {
             $removedOn = date('M jS, Y \\a\\t g:ia', $ah->removed_on);
         }
         $bed = new HMS_Bed($ah->getBedId());
         $row['room'] = $bed->where_am_i();
         $row['term'] = Term::toString($ah->term);
         // Combine for ease of view
         if (isset($ah->assigned_reason)) {
             $row['assignments'] = '<em>' . $assignedReason . '</em>' . ' by ' . $ah->assigned_by . '<br /><span style="font-size:11px;color:#7C7C7C;">on ' . $assignedOn . '</span>';
         } else {
             $row['assignments'] = '<em class="text-muted">None</em>';
         }
         if (isset($ah->removed_reason)) {
             $row['unassignments'] = '<em>' . $removedReason . '</em>' . ' by ' . $ah->removed_by . '<br /><span style="font-size:11px;color:#7C7C7C;">on ' . $removedOn . '</span>';
         } else {
             $row['unassignments'] = '<em class="text-muted">None</em>';
         }
         if ($count++ < $excess_limit) {
             $historyRows[] = $row;
         } else {
             $excessRows[] = $row;
         }
     }
     $tpl['HISTORY'] = $historyRows;
     $tpl['EXTRA_HISTORY'] = $excessRows;
     if (sizeof($historyArray) > $excess_limit) {
         $tpl['SHOW_MORE'] = "[ <a id='showMoreLink'>show more</a> ]";
     }
     return PHPWS_Template::process($tpl, 'hms', 'admin/StudentAssignmentHistoryView.tpl');
 }
 public function show()
 {
     $term = Term::getCurrentTerm();
     $student = StudentFactory::getStudentByBannerId($this->checkin->getBannerId(), $term);
     $bed = new HMS_Bed($this->checkin->getBedId());
     $tpl = array();
     $tpl['NAME'] = $student->getName();
     $tpl['ASSIGNMENT'] = $bed->where_am_i();
     $pdfCmd = CommandFactory::getCommand('GenerateInfoCard');
     $pdfCmd->setCheckinId($this->checkin->getId());
     $tpl['INFO_CARD_LINK'] = $pdfCmd->getLink('Resident Information Card', '_blank');
     return PHPWS_Template::process($tpl, 'hms', 'admin/checkinComplete.tpl');
 }
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     # Get the roommate request record from the database
     $bed = new HMS_Bed($this->request['bed_id']);
     $room = $bed->get_parent();
     $tpl = array();
     $requestor = StudentFactory::getStudentByUsername($this->request['requestor'], $this->term);
     $tpl['REQUESTOR'] = $requestor->getName();
     $tpl['HALL_ROOM'] = $bed->where_am_i();
     # List all the students which will be assigned and their beds
     $beds = $room->get_beds();
     foreach ($beds as $bed) {
         $bed_row = array();
         # Check for an assignment
         $bed->loadAssignment();
         # Check for a reservation
         $reservation = $bed->get_lottery_reservation_info();
         $bed_row['BEDROOM_LETTER'] = $bed->bedroom_label;
         if ($bed->_curr_assignment != NULL) {
             # Bed is assigned
             $roommate = StudentFactory::getStudentByUsername($bed->_curr_assignment->asu_username, $this->term);
             $bed_row['TEXT'] = $roommate->getName();
         } else {
             if ($reservation != NULL) {
                 # Bed is reserved
                 $roommate = StudentFactory::getStudentByUsername($reservation['asu_username'], $this->term);
                 $bed_row['TEXT'] = $roommate->getName() . ' (reserved)';
             } else {
                 $bed_row['TEXT'] = 'Empty';
             }
         }
         $tpl['beds'][] = $bed_row;
     }
     $tpl['MEAL_PLAN'] = HMS_Util::formatMealOption($this->mealPlan);
     PHPWS_Core::initCoreClass('Captcha.php');
     $tpl['CAPTCHA'] = Captcha::get();
     $submitCmd = CommandFactory::getCommand('LotteryConfirmRoommateRequest');
     $submitCmd->setRequestId($this->request['id']);
     $submitCmd->setMealPlan($this->mealPlan);
     $form = new PHPWS_Form();
     $submitCmd->initForm($form);
     $form->addSubmit('confirm', 'Confirm Roommate');
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     Layout::addPageTitle("Lottery Confirm Roommate");
     return PHPWS_Template::process($tpl, 'hms', 'student/lottery_confirm_roommate_request.tpl');
 }
 public function show()
 {
     $approveCmd = CommandFactory::getCommand('RoomChangeStudentApprove');
     $approveCmd->setParticipantId($this->thisParticipant->getId());
     $approveCmd->setRequestId($this->request->getId());
     $declineCmd = CommandFactory::getCommand('RoomChangeStudentDecline');
     $declineCmd->setParticipantId($this->thisParticipant->getId());
     $declineCmd->setRequestId($this->request->getId());
     $form = new PHPWS_Form('roomchange_student_approve');
     $form->addHidden('foo', 'bar');
     $tpl = $form->getTemplate();
     $tpl['APPROVE_URI'] = $approveCmd->getURI();
     $tpl['DECLINE_URI'] = $declineCmd->getURI();
     $requestor = StudentFactory::getStudentByUsername($this->request->getState()->getCommittedBy(), $this->term);
     $tpl['REQUESTOR'] = $requestor->getName();
     // Build the table showing who is moving from/to which beds
     $participantRows = array();
     foreach ($this->participants as $p) {
         $row = array();
         $student = StudentFactory::getStudentByBannerId($p->getBannerId(), $this->term);
         $row['NAME'] = $student->getName();
         // If this participant is the person logged in, bold their name
         if ($student->getBannerId() == $this->thisParticipant->getBannerId()) {
             $row['STRONG_STYLE'] = 'success';
         } else {
             $row['STRONG_STYLE'] = '';
         }
         $fromBed = new HMS_Bed($p->getFromBed());
         $toBed = new HMS_Bed($p->getToBed());
         $row['FROM_BED'] = $fromBed->where_am_i();
         $row['TO_BED'] = $toBed->where_am_i();
         $participantRows[] = $row;
     }
     $tpl['PARTICIPANTS'] = $participantRows;
     PHPWS_Core::initCoreClass('Captcha.php');
     $tpl['CAPTCHA'] = Captcha::get();
     return PHPWS_Template::process($tpl, 'hms', 'student/roomChangeRequestStudentApprove.tpl');
 }
 public function show()
 {
     $historyRows = array();
     foreach ($this->checkins as $checkin) {
         $row = array();
         $bed = new HMS_Bed($checkin->getBedId());
         $row['room'] = $bed->where_am_i();
         $row['term'] = Term::toString($checkin->getTerm());
         $row['checkin'] = date("M j, Y g:i:sa", $checkin->getCheckinDate());
         $checkoutDate = $checkin->getCheckoutDate();
         if (isset($checkoutDate)) {
             $row['checkout'] = date("M j, Y g:i:sa", $checkoutDate);
         } else {
             $row['checkout'] = '';
         }
         $ricCommand = CommandFactory::getCommand('GenerateInfoCard');
         $ricCommand->setCheckinId($checkin->getId());
         $row['action'] = $ricCommand->getLink('Get RIC');
         $historyRows[] = $row;
     }
     $tpl = array();
     $tpl['HISTORY'] = $historyRows;
     return PHPWS_Template::process($tpl, 'hms', 'admin/StudentCheckinHistoryView.tpl');
 }
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     # Get the roommate request record from the database
     $bed = new HMS_Bed($this->request['bed_id']);
     $room = $bed->get_parent();
     $tpl = array();
     $requestor = StudentFactory::getStudentByUsername($this->request['requestor'], $this->term);
     $tpl['REQUESTOR'] = $requestor->getName();
     $tpl['HALL_ROOM'] = $bed->where_am_i();
     # List all the students which will be assigned and their beds
     $beds = $room->get_beds();
     foreach ($beds as $bed) {
         $bed_row = array();
         # Check for an assignment
         $bed->loadAssignment();
         # Check for a reservation
         $reservation = $bed->get_lottery_reservation_info();
         $bed_row['BEDROOM_LETTER'] = $bed->bedroom_label;
         if ($bed->_curr_assignment != NULL) {
             # Bed is assigned
             $roommate = StudentFactory::getStudentByUsername($bed->_curr_assignment->asu_username, $this->term);
             $bed_row['TEXT'] = $roommate->getName();
         } else {
             if ($reservation != NULL) {
                 # Bed is reserved
                 $roommate = StudentFactory::getStudentByUsername($reservation['asu_username'], $this->term);
                 $bed_row['TEXT'] = $roommate->getName() . ' (reserved)';
             } else {
                 $bed_row['TEXT'] = 'Empty';
             }
         }
         $tpl['beds'][] = $bed_row;
     }
     // Check if the student has already completed a housing application
     if ($this->housingApplication != null) {
         // Housing application complete, go straight to confirming roommate
         $submitCmd = CommandFactory::getCommand('LotteryShowConfirmRoommateRequest');
         $submitCmd->setRequestId($this->request['id']);
     } else {
         // No housing application, goto self-select start page for contract and emg contact
         $submitCmd = CommandFactory::getCommand('RlcSelfAssignStart');
         $submitCmd->setTerm($this->term);
         $submitCmd->setRoommateRequestId($this->request['id']);
     }
     $denyCmd = CommandFactory::getCommand('LotteryShowDenyRoommateRequest');
     $denyCmd->setRequestId($this->request['id']);
     $form = new PHPWS_Form();
     $submitCmd->initForm($form);
     # Decide which meal plan drop box to show based on whether or not the chosen room
     # is in a hall which requires a meal plan
     $floor = $room->get_parent();
     $hall = $floor->get_parent();
     if ($hall->meal_plan_required == 0) {
         $form->addDropBox('meal_plan', array(BANNER_MEAL_NONE => _('None'), BANNER_MEAL_LOW => _('Low'), BANNER_MEAL_STD => _('Standard'), BANNER_MEAL_HIGH => _('High'), BANNER_MEAL_SUPER => _('Super')));
     } else {
         $form->addDropBox('meal_plan', array(BANNER_MEAL_LOW => _('Low'), BANNER_MEAL_STD => _('Standard'), BANNER_MEAL_HIGH => _('High'), BANNER_MEAL_SUPER => _('Super')));
         $form->setMatch('meal_plan', BANNER_MEAL_STD);
     }
     // Set meal plan drop down default to what the student selected on the housing re-application.
     if ($this->housingApplication != null) {
         $form->setMatch('meal_plan', $this->housingApplication->getMealPlan());
     }
     $form->addSubmit('accept', 'Accept Roommate');
     $form->addButton('reject', 'Deny Roommate');
     javascript('modules/hms/buttonAction', array('ID' => 'phpws_form_reject', 'URI' => $denyCmd->getURI()));
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     Layout::addPageTitle("Lottery Request Roommate");
     return PHPWS_Template::process($tpl, 'hms', 'student/lottery_roommate_request.tpl');
 }
Beispiel #7
0
 /**
  * Sends everyone involved in a room change notice when it is fully approved and
  * can happen in the real world.  Note this is a little different than the other
  * ones because it does the looping itself and sends multiple messages.
  *
  * @param $r RoomChangeRequest The Room Change Request that is in process
  * TODO: Add to/from bed for each participant
  */
 public static function sendRoomChangeInProcessNotice(RoomChangeRequest $r)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $subject = 'Room Change Approved!';
     $template = 'email/roomChangeApprovalNotice.tpl';
     $tags = array('PARTICIPANTS' => array());
     $recipients = array();
     foreach ($r->getParticipants() as $p) {
         $student = Studentfactory::getStudentByBannerID($p->getBannerID(), $r->getTerm());
         $current = new HMS_Bed($p->getFromBed());
         $future = new HMS_Bed($p->getToBed());
         $recipients[] = $student;
         $tags['PARTICIPANTS'][] = array('NAME' => $student->getName(), 'CURRENT_LOCATION' => $current->where_am_i(), 'FUTURE_LOCATION' => $future->where_am_i());
     }
     foreach ($r->getAllPotentialApprovers() as $a) {
         $recipients[] = array($a . TO_DOMAIN => '');
     }
     $message = self::makeSwiftmailMessage(null, $subject, $tags, $template);
     foreach ($recipients as $r) {
         if ($r instanceof Student) {
             $message->setTo($r->getUsername() . TO_DOMAIN);
         } else {
             $message->setTo($r);
         }
         self::sendSwiftmailMessage($message);
     }
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'assignment_notify')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to send assignment notifications.');
     }
     PHPWS_Core::initModClass('hms', 'Term.php');
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Movein_Time.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     // Check if any move-in times are set for the selected term
     $moveinTimes = HMS_Movein_Time::get_movein_times_array(Term::getSelectedTerm());
     // If the array of move-in times ONLY has the zero-th element ['None'] then it's no good
     // Or, of course, if the array is null or emtpy it is no good
     if (count($moveinTimes) <= 1 || is_null($moveinTimes) || empty($moveinTimes)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There are no move-in times set for ' . Term::getPrintableSelectedTerm());
         $context->goBack();
     }
     // Keep track of floors missing move-in times
     $missingMovein = array();
     $term = Term::getSelectedTerm();
     $db = new PHPWS_DB('hms_assignment');
     $db->addWhere('email_sent', 0);
     $db->addWhere('term', $term);
     $result = $db->getObjects("HMS_Assignment");
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     foreach ($result as $assignment) {
         //get the students real name from their asu_username
         $student = StudentFactory::getStudentByUsername($assignment->getUsername(), $term);
         //get the location of their assignment
         PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
         $bed = new HMS_Bed($assignment->getBedId());
         $room = $bed->get_parent();
         $location = $bed->where_am_i() . ' - Bedroom ' . $bed->bedroom_label;
         // Lookup the floor and hall to make sure the
         // assignment notifications flag is true for this hall
         $floor = $room->get_parent();
         $hall = $floor->get_parent();
         if ($hall->assignment_notifications == 0) {
             continue;
         }
         // Get the student type for determining move-in time
         $type = $student->getType();
         // Check for an accepted and confirmed RLC assignment
         $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $term);
         // If there is an assignment, make sure the student "confirmed" the rlc invite
         if (!is_null($rlcAssignment)) {
             if ($rlcAssignment->getStateName() != 'confirmed' && $rlcAssignment->getStateName() != 'selfselect-assigned') {
                 $rlcAssignment = null;
             }
         }
         // Make sure this is re-initialized
         $moveinTimeId = null;
         $rlcSetMoveinTime = false;
         // Determine the move-in time
         if (!is_null($rlcAssignment)) {
             // If there is a 'confirmed' RLC assignment, use the RLC's move-in times
             $rlc = $rlcAssignment->getRlc();
             if ($type == TYPE_CONTINUING) {
                 $moveinTimeId = $rlc->getContinuingMoveinTime();
             } else {
                 if ($type == TYPE_TRANSFER) {
                     $moveinTimeId = $rlc->getTransferMoveinTime();
                 } else {
                     if ($type == TYPE_FRESHMEN) {
                         $moveinTimeId = $rlc->getFreshmenMoveinTime();
                     }
                 }
             }
         }
         // If there's a non-null move-in time ID at this point, then we know the RLC must have set it
         if (!is_null($moveinTimeId)) {
             $rlcSetMoveinTime = true;
         }
         // If the RLC didn't set a movein time, set it according to the floor
         // TODO: Find continuing students by checking the student's application term
         // against the term we're wending assignment notices for
         if (is_null($moveinTimeId)) {
             if ($type == TYPE_CONTINUING) {
                 $moveinTimeId = $assignment->get_rt_movein_time_id();
             } else {
                 if ($type == TYPE_TRANSFER) {
                     $moveinTimeId = $assignment->get_t_movein_time_id();
                 } else {
                     $moveinTimeId = $assignment->get_f_movein_time_id();
                 }
             }
         }
         // Check for missing move-in times
         if ($moveinTimeId == NULL) {
             //test($assignment, 1); // Will only happen if there's no move-in time set for the floor,student type
             // Lets only keep a set of the floors
             if (!in_array($floor, $missingMovein)) {
                 $missingMovein[] = $floor;
             }
             // Missing move-in time, so skip to the next assignment
             continue;
         }
         // TODO: Grab all the move-in times and index them in an array by ID so we don't have to query the DB every single time
         $movein_time_obj = new HMS_Movein_Time($moveinTimeId);
         $movein_time = $movein_time_obj->get_formatted_begin_end();
         // Add a bit of text if the move-in time was for an RLC
         if ($rlcSetMoveinTime) {
             $movein_time .= ' (for the ' . $rlc->get_community_name() . ' Residential Learning Community)';
         }
         //get the list of roommates
         $roommates = array();
         $beds = $room->get_beds();
         foreach ($beds as $bed) {
             $roommate = $bed->get_assignee();
             if ($roommate == false || is_null($roommate) || $roommate->getUsername() == $student->getUsername()) {
                 continue;
             }
             $roommates[] = $roommate->getFullName() . ' (' . $roommate->getUsername() . '@appstate.edu) - Bedroom ' . $bed->bedroom_label;
         }
         // Send the email
         HMS_Email::sendAssignmentNotice($student->getUsername(), $student->getName(), $term, $location, $roommates, $movein_time);
         // Mark the student as having received an email
         $db->reset();
         $db->addWhere('asu_username', $assignment->getUsername());
         $db->addWhere('term', $term);
         $db->addValue('email_sent', 1);
         $rslt = $db->update();
         if (PHPWS_Error::logIfError($rslt)) {
             throw new DatabaseException($result->toString());
         }
     }
     // Check for floors with missing move-in times.
     if (empty($missingMovein) || is_null($missingMovein)) {
         // Ther are none, so show a success message
         NQ::simple('hms', hms\NotificationView::SUCCESS, "Assignment notifications sent.");
     } else {
         // Show a warning for each floor that was missing a move-in time
         foreach ($missingMovein as $floor) {
             $hall = $floor->get_parent();
             $text = $floor->getLink($hall->getHallName() . " floor ") . " move-in times not set.";
             NQ::simple('hms', hms\NotificationView::WARNING, $text);
         }
     }
     $context->goBack();
 }
Beispiel #9
0
 public static function send_roommate_reminder_emails($term)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     PHPWS_Core::initModclass('hms', 'StudentFactory.php');
     // Get a list of outstanding roommate requests, send them reminder emails
     $query = "select hms_lottery_reservation.* FROM hms_lottery_reservation\n                LEFT OUTER JOIN (SELECT asu_username FROM hms_assignment WHERE term={$term} AND lottery = 1) as foo ON hms_lottery_reservation.asu_username = foo.asu_username\n                WHERE foo.asu_username IS NULL\n                AND hms_lottery_reservation.expires_on > " . time();
     $result = PHPWS_DB::getAll($query);
     if (PEAR::isError($result)) {
         PHPWS_Error::log($result);
         test($result, 1);
     }
     $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term));
     foreach ($result as $row) {
         $student = StudentFactory::getStudentByUsername($row['asu_username'], $term);
         $requestor = StudentFactory::getStudentByUsername($row['requestor'], $term);
         $bed = new HMS_Bed($row['bed_id']);
         $hall_room = $bed->where_am_i();
         HMS_Email::send_lottery_roommate_reminder($row['asu_username'], $student->getName(), $row['expires_on'], $requestor->getName(), $hall_room, $year);
         HMS_Activity_Log::log_activity($row['asu_username'], ACTIVITY_LOTTERY_ROOMMATE_REMINDED, 'hms');
     }
 }
Beispiel #10
0
 private function sendRoommateReminderEmails()
 {
     // Get a list of outstanding roommate requests, send them reminder emails
     $query = "select hms_lottery_reservation.* FROM hms_lottery_reservation\n                        LEFT OUTER JOIN (SELECT asu_username FROM hms_assignment WHERE term={$this->term}) as foo ON hms_lottery_reservation.asu_username = foo.asu_username\n                        WHERE foo.asu_username IS NULL\n                        AND hms_lottery_reservation.term = {$this->term}\n                        AND hms_lottery_reservation.expires_on > " . $this->now;
     $result = PHPWS_DB::getAll($query);
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     foreach ($result as $row) {
         $student = StudentFactory::getStudentByUsername($row['asu_username'], $this->term);
         $requestor = StudentFactory::getStudentByUsername($row['requestor'], $this->term);
         $bed = new HMS_Bed($row['bed_id']);
         $hall_room = $bed->where_am_i();
         HMS_Email::send_lottery_roommate_reminder($row['asu_username'], $student->getName(), $row['expires_on'], $requestor->getName(), $hall_room, $this->academicYear);
         HMS_Activity_Log::log_activity($row['asu_username'], ACTIVITY_LOTTERY_ROOMMATE_REMINDED, UserStatus::getUsername());
     }
 }
 public function show()
 {
     $tpl = array();
     // Student info
     $tpl['NAME'] = $this->student->getProfileLink();
     $tpl['BANNER_ID'] = $this->student->getBannerId();
     // Participant ID
     // $tpl['PARTICIPANT_ID'] = $this->participant->getId();
     $tpl['CELL_PHONE'] = $this->participant->getCellPhone();
     // Hall Preferences
     $pref1 = $this->participant->getHallPref1();
     $pref2 = $this->participant->getHallPref2();
     if (!is_null($pref1)) {
         $hall1 = new HMS_Residence_Hall($pref1);
         $hallName = $hall1->getHallName();
         // Check if there's also a second hall preference
         if (!is_null($pref2)) {
             $hall2 = new HMS_Residence_Hall($pref2);
             $hallName .= ', ' . $hall2->getHallName();
         }
         $tpl['HALL_PREF'] = $hallName;
     }
     // From bed
     $fromBed = new HMS_Bed($this->participant->getFromBed());
     $tpl['FROM_ROOM'] = $fromBed->where_am_i();
     // To bed
     $toBedId = $this->participant->getToBed();
     if (isset($toBedId)) {
         // If there's already a bed set, show the selected bed
         $toBed = new HMS_Bed($toBedId);
         $tpl['TO_ROOM'] = $toBed->where_am_i();
     }
     /**
      * Check to see if the state is already approved or completed
      */
     $requestState = $this->request->getState();
     if ($requestState instanceof RoomChangeStatePending || $requestState instanceof RoomChangeStateHold) {
         /**
          * Check that the participant is checked into their current assignment
          */
         $checkin = CheckinFactory::getCheckinByBed($this->student, $fromBed);
         if ($checkin == null || $checkin != null && $checkin->getCheckoutDate() != null) {
             NQ::simple('hms', hms\NotificationView::ERROR, "{$this->student->getName()} is not checked-in at his/her current assignment. This must be fixed before this room change can be given final approval.");
         }
     }
     /**
      * **
      * Show approval buttons based on participant's current state
      */
     $particpantState = $this->participant->getState();
     $form = new PHPWS_Form('participant_form');
     if ($particpantState instanceof ParticipantStateNew) {
         // Particpant is in new state, waiting on this student'a approval
         // If the student is logged in, or the user is an admin, show the approve button
         if (UserStatus::getUsername() == $this->student->getUsername() || Current_User::allow('hms', 'admin_approve_room_change')) {
             $approveCmd = CommandFactory::getCommand('RoomChangeStudentApprove');
             $approveCmd->setParticipantId($this->participant->getId());
             $approveCmd->setRequestId($this->request->getId());
             $approveCmd->initForm($form);
             $form->mergeTemplate($tpl);
             $tpl = $form->getTemplate();
             $tpl['APPROVE_BTN'] = '';
             // dummy tag for approve button
         }
     } else {
         if ($particpantState instanceof ParticipantStateStudentApproved) {
             // Participant is in StudentApproved state
             // Get current list of RDs for this participant
             $rds = $this->participant->getCurrentRdList();
             // If current user is an RD for the "from bed" or an admin
             if (in_array(UserStatus::getUsername(), $rds) || Current_User::allow('hms', 'admin_approve_room_change')) {
                 if (!isset($toBedId) && count($this->participants) == 1) {
                     /*
                      * If there's only one particpant and the toBed is not already set,
                      * and the currnent user if the participants current RD, then show the bed selector
                      *
                      * Limit to 1 participant since room selection is for room "switch" requests only, not swaps.
                      * For swaps, the destination bed is already known and is not editable.
                      */
                     // Show the "select a bed" dialog, values are loaded via AJAX
                     $form->addDropBox('bed_select', array('-1' => 'Loading...'));
                     $form->addHidden('gender', $this->student->getGender());
                 }
                 $approveCmd = CommandFactory::getCommand('RoomChangeCurrRdApprove');
                 $approveCmd->setParticipantId($this->participant->getId());
                 $approveCmd->setRequestId($this->request->getId());
                 $approveCmd->initForm($form);
                 $form->mergeTemplate($tpl);
                 $tpl = $form->getTemplate();
                 $tpl['APPROVE_BTN'] = '';
                 // dummy tag for approve button
             }
         } else {
             if ($particpantState instanceof ParticipantStateCurrRdApproved) {
                 // Current RD has approved, Future RD needs to approve
                 // If current user if future RD or admin, show the approve button
                 // Get list of future RDs for "to bed"
                 $rds = $this->participant->getFutureRdList();
                 // Only future RDs and admins can approve
                 if (in_array(UserStatus::getUsername(), $rds) || Current_User::allow('hms', 'admin_approve_room_change')) {
                     $approveCmd = CommandFactory::getCommand('RoomChangeFutureRdApprove');
                     $approveCmd->setParticipantId($this->participant->getId());
                     $approveCmd->setRequestId($this->request->getId());
                     $approveCmd->initForm($form);
                     $form->mergeTemplate($tpl);
                     $tpl = $form->getTemplate();
                     $tpl['APPROVE_BTN'] = '';
                 }
             }
         }
     }
     // Show the edit link for to room if request type is a "switch", user has permissions, and status allows it
     // TODO
     /*** Participant History ***/
     $states = RoomChangeParticipantStateFactory::getStateHistory($this->participant);
     if (!is_null($states)) {
         $stateRows = array();
         foreach ($states as $historyState) {
             $stateRows[] = array('STATE_NAME' => $historyState->getFriendlyName(), 'EFFECTIVE_DATE' => date('M j, Y g:ia', $historyState->getEffectiveDate()), 'COMMITTED_BY' => $historyState->getCommittedBy());
         }
     }
     $tpl['history_rows'] = $stateRows;
     return PHPWS_Template::process($tpl, 'hms', 'admin/roomChangeParticipantView.tpl');
 }