public function execute(CommandContext $context) { // Check permissions if (!Current_User::allow('hms', 'checkin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to checkin students.'); } $term = Term::getSelectedTerm(); $bannerId = $context->get('bannerId'); $hallId = $context->get('hallId'); $errorCmd = CommandFactory::getCommand('ShowCheckinStart'); if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing Banner ID.'); $errorCmd->redirect(); } if (!isset($hallId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.'); $errorCmd->redirect(); } // Check the Banner ID if (preg_match("/[\\d]{9}/", $bannerId) == false) { NQ::simple('hms', hms\NotificationView::ERROR, 'Imporperly formatted Banner ID.'); $errorCmd->redirect(); } // Try to lookup the student in Banner try { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not locate a student with that Banner ID.'); $errorCmd->redirect(); } // Make sure the student is assigned in the current term $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $term); if (!isset($assignment) || is_null($assignment)) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' is not assigned for ' . Term::toString($term) . '. Please contact the University Housing Assignments Office at 828-262-6111.'); $errorCmd->redirect(); } // Make sure the student's assignment matches the hall the user selected $bed = $assignment->get_parent(); $room = $bed->get_parent(); $floor = $room->get_parent(); $hall = $floor->get_parent(); if ($hallId != $hall->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, 'Wrong hall! ' . $student->getName() . ' is assigned to ' . $assignment->where_am_i()); $errorCmd->redirect(); } // Load any existing check-in $checkin = CheckinFactory::getLastCheckinByBannerId($bannerId, $term); // If there is a checkin for the same bed, and the difference between the current time and the checkin time is // greater than 48 hours, then show an error. if (!is_null($checkin)) { $checkoutDate = $checkin->getCheckoutDate(); if ($checkin->getBedId() == $bed->getId() && !isset($checkoutDate) && time() - $checkin->getCheckinDate() > Checkin::CHECKIN_TIMEOUT) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' has already checked in to ' . $assignment->where_am_i()); $errorCmd->redirect(); } } $view = new CheckinFormView($student, $assignment, $hall, $floor, $room, $checkin); $context->setContent($view->show()); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'cancel_housing_application')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to cancel housing applications.'); } // Check for a housing application id $applicationId = $context->get('applicationId'); if (!isset($applicationId) || is_null($applicationId)) { throw new InvalidArgumentException('Missing housing application id.'); } // Check for a cancellation reason $cancelReason = $context->get('cancel_reason'); if (!isset($cancelReason) || is_null($cancelReason)) { throw new InvalidArgumentException('Missing cancellation reason.'); } // Load the housing application PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); $application = HousingApplicationFactory::getApplicationById($applicationId); // Load the student $student = $application->getStudent(); $username = $student->getUsername(); $term = $application->getTerm(); // Load the cancellation reasons $reasons = HousingApplication::getCancellationReasons(); // Check for an assignment and remove it // Decide which term to use - If this application is in a past fall term, then use the current term if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) { $assignmentTerm = Term::getCurrentTerm(); } else { $assignmentTerm = $term; } PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm); if (isset($assignment)) { // TODO: Don't hard code cancellation refund percentage HMS_Assignment::unassignStudent($student, $assignmentTerm, 'Application cancellation: ' . $reasons[$cancelReason], UNASSIGN_CANCEL, 100); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($username, $term); if (!is_null($rlcAssignment)) { $rlcAssignment->delete(); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcApplication = HMS_RLC_Application::getApplicationByUsername($username, $term); if (!is_null($rlcApplication)) { $rlcApplication->denied = 1; $rlcApplication->save(); HMS_Activity_Log::log_activity($username, ACTIVITY_DENIED_RLC_APPLICATION, \Current_User::getUsername(), Term::toString($term) . ' Denied RLC Application due to Contract Cancellation'); } // Cancel the application $application->cancel($cancelReason); $application->save(); echo 'success'; exit; }
public function getMenuBlockView(Student $student) { PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'RlcSelfSelectionMenuBlockView.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm()); $roomAssignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $this->getTerm()); $roommateRequests = HMS_Lottery::get_lottery_roommate_invites($student->getUsername(), $this->term); return new RlcSelfSelectionMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $rlcAssignment, $roomAssignment, $roommateRequests); }
public function execute() { PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $db = new PHPWS_DB('hms_new_application'); $db->addColumn('hms_new_application.*'); $db->addWhere('term', $this->term); $db->addWhere('cancelled', 0); $term = Term::getTermSem($this->term); if ($term == TERM_FALL) { $db->addJoin('LEFT', 'hms_new_application', 'hms_fall_application', 'id', 'id'); $db->addColumn('hms_fall_application.*'); } else { if ($term == TERM_SUMMER1 || $term == TERM_SUMMER2) { $db->addJoin('LEFT', 'hms_new_application', 'hms_summer_application', 'id', 'id'); $db->addColumn('hms_summer_application.*'); } } $result = $db->select(); $app = array(); foreach ($result as $app) { $username = $app['username']; $bannerId = $app['banner_id']; $type = $app['student_type']; $cellPhone = $app['cell_phone']; $date = date('n/j/Y', $app['created_on']); $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $this->term); if (!is_null($assignment)) { $room = $assignment->where_am_i(); } else { $room = ''; } $student = StudentFactory::getStudentByBannerId($bannerId, $this->term); $first = $student->getFirstName(); $middle = $student->getMiddleName(); $last = $student->getLastName(); $gender = $student->getPrintableGender(); $birthday = date("m/d/Y", $student->getDobDateTime()->getTimestamp()); $address = $student->getAddress(NULL); if ($term == TERM_SPRING || $term == TERM_FALL) { $lifestyle = $app['lifestyle_option'] == 1 ? 'Single Gender' : 'Co-Ed'; } else { $lifestyle = $app['room_type'] == 1 ? 'Single Room' : 'Double Room'; } if (!is_null($address) && $address !== false) { $this->rows[] = array($username, $bannerId, $first, $middle, $last, $gender, $type, $cellPhone, $room, $date, $address->line1, $address->line2, $address->line3, $address->city, $address->state, $address->zip, $birthday, $lifestyle); } else { $this->rows[] = array($username, $bannerId, $first, $middle, $last, '', $type, $cellPhone, $room, $date, '', '', '', '', '', '', $lifestyle); } } }
public function execute(CommandContext $context) { $term = Term::getCurrentTerm(); // Get the current student $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Check for an assignment $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $term); // If not assigned, then redirect to the main menu with an error if (is_null($assignment)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You do not have a room assignment for the current semester.'); $cmd = CommandFactory::getCommand('ShowStudentMenu'); $cmd->redirect(); } $tpl['NAME'] = $student->getFullName(); $tpl['ASSIGNMENT'] = $assignment->where_am_i(); $tpl['TERM'] = Term::toString($term); $context->setContent(\PHPWS_Template::process($tpl, 'hms', 'student/residenceVerification.tpl')); }
public function execute(CommandContext $context) { $applicationId = $context->get('applicationId'); if (!isset($applicationId)) { throw new InvalidArgumentException('Missing application id.'); } PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); $application = HousingApplicationFactory::getApplicationById($applicationId); $student = $application->getStudent(); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); // Decide which term to use - If this application is in a past fall term, then use the current term $term = $application->getTerm(); if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) { $assignmentTerm = Term::getCurrentTerm(); } else { $assignmentTerm = $term; } $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm); PHPWS_Core::initModClass('hms', 'HousingApplicationCancelView.php'); $view = new HousingApplicationCancelView($student, $application, $assignment); echo $view->show(); exit; }
/** * $roommates is the focus of getProfileView(). It's structure is helpful in * StudentProfileView. It also makes it a little easier to recognize which roommmates * are requested ones so they can be emphasized in the template (admin/fancy-student-info.tpl) * Note that a student can only have a single pending/confirmed roommate request but multiple * assigned roommates! * */ public function getProfileView() { PHPWS_Core::initModClass('hms', 'StudentProfileView.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); $studentUsername = $this->student->getUsername(); $assignment = HMS_Assignment::getAssignmentByBannerId($this->student->getBannerId(), $this->term); $pendingRoommate = HMS_Roommate::get_pending_roommate($studentUsername, $this->term); $confirmedRoommate = HMS_Roommate::get_confirmed_roommate($studentUsername, $this->term); if (!is_null($assignment)) { $assignedRoommates = $assignment->get_parent()->get_parent()->get_assignees(); } // // If student is assigned to room... // if (!is_null($assignment)) { foreach ($assignedRoommates as $roomie) { // make sure $roomie isn't the student being profiled or the requested roomies if ($roomie != FALSE && $roomie->getUsername() != $studentUsername) { $roomieUsername = $roomie->getUsername(); if (is_null($confirmedRoommate) || $roomieUsername != $confirmedRoommate->getUsername()) { if (is_null($pendingRoommate) || $roomieUsername != $pendingRoommate->getUsername()) { // Get student object and room link $roomLink = $this->getRoommateRoomLink($roomie->getUsername()); // if $roomie was assigned but not requested $this->roommates['ASSIGNED'][] = $roomie->getProfileLink() . " - {$roomLink}"; } } } } } // // Check status of requested roommates // if (!is_null($confirmedRoommate)) { if (!is_null($assignment)) { $confirmedRmAssignment = HMS_Assignment::getAssignment($confirmedRoommate->getUsername(), $this->term); if (!is_null($confirmedRmAssignment)) { // if confirmed roommate is assigned to different room than profile student if ($assignment->get_parent()->room_id != $confirmedRmAssignment->get_parent()->room_id) { $this->setRoommateVar($confirmedRoommate, "confirmed", "mismatched_rooms"); } else { $this->setRoommateVar($confirmedRoommate, "confirmed"); } } else { // if profile student's room is full if (!$assignment->get_parent()->get_parent()->has_vacancy()) { $this->setRoommateVar($confirmedRoommate, "confirmed", "no_bed_available"); } else { $this->setRoommateVar($confirmedRoommate, "confirmed"); } } } else { $this->setRoommateVar($confirmedRoommate, "confirmed"); } } else { if (!is_null($pendingRoommate)) { if (!is_null($assignment)) { $pendingRmAssignment = HMS_Assignment::getAssignment($pendingRoommate->getUsername(), $this->term); if (!is_null($pendingRmAssignment)) { // if pending roommate is assigned to different room than profile student if ($assignment->get_parent()->room_id != $pendingRmAssignment->get_parent()->room_id) { $this->setRoommateVar($pendingRoommate, "pending", "mismatched_rooms"); } else { $this->setRoommateVar($pendingRoommate, "pending"); } } else { // if profile student's room is full if (!$assignment->get_parent()->get_parent()->has_vacancy()) { $this->setRoommateVar($pendingRoommate, "pending", "no_bed_available"); } else { $this->setRoommateVar($pendingRoommate, "pending"); } } } else { $this->setRoommateVar($pendingRoommate, "pending"); } } } $applications = HousingApplication::getAllApplicationsForStudent($this->student); $subTypeApps = array(); // Convert each of the general HousingApplication objets to its specific sub type (e.g. FallApplication) foreach ($applications as $app) { $subTypeApps[] = HousingApplicationFactory::getApplicationById($app->id); } return new StudentProfileView($this->student, $subTypeApps, $assignment, $this->roommates); }
/** * Returns this rlc application (and assignment) as array of fields for CSV export * * @return Array */ public function viewByRLCExportFields() { PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $row = array(); // Get the Student object try { $student = StudentFactory::getStudentByUsername($this->username, Term::getSelectedTerm()); } catch (StudentNotFoundException $e) { // Catch the StudentNotFound exception in the odd case that someone doesn't exist. // Show a warning message and skip the rest of the method NQ::simple('hms', hms\NotificationView::WARNING, "No student found with username: {$this->username}."); $row['username'] = $this->username; $row['name'] = 'UNKNOWN - INVALID'; return $tags; } $row['name'] = $student->getFullName(); $row['gender'] = $student->getPrintableGender(); $row['student_type'] = $student->getPrintableType(); $row['username'] = $student->getUsername(); $row['banner_id'] = $student->getBannerId(); /*** Assignment Status/State ***/ // Lookup the assignmnet (used later as well) $assign = HMS_RLC_Assignment::getAssignmentByUsername($this->username, $this->term); $state = $assign->getStateName(); if ($state == 'confirmed') { $row['state'] = 'confirmed'; } else { if ($state == 'declined') { $row['state'] = 'declined'; } else { if ($state == 'new') { $row['state'] = 'not invited'; } else { if ($state == 'invited') { $row['state'] = 'pending'; } else { $row['state'] = ''; } } } } // Check for/display room assignment $roomAssign = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), Term::getSelectedTerm()); if (isset($roomAssign)) { $row['room_assignment'] = $roomAssign->where_am_i(); } else { $row['room_assignment'] = 'n/a'; } /*** Roommates ***/ // Show all possible roommates for this application PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $allRoommates = HMS_Roommate::get_all_roommates($this->username, $this->term); $row['roommates'] = 'N/A'; // Default text if (sizeof($allRoommates) > 1) { // Don't show all the roommates $row['roommates'] = "Multiple Requests"; } elseif (sizeof($allRoommates) == 1) { // Get other roommate $otherGuy = StudentFactory::getStudentByUsername($allRoommates[0]->get_other_guy($this->username), $this->term); $row['roommates'] = $otherGuy->getFullName(); // If roommate is pending then show little status message if (!$allRoommates[0]->confirmed) { $row['roommates'] .= " (Pending)"; } } return $row; }
public function execute(CommandContext $context) { // Get input $requestId = $context->get('requestId'); // Get the current term $term = Term::getCurrentTerm(); // Load the request $request = RoomChangeRequestFactory::getRequestById($requestId); // Load the participants $participants = $request->getParticipants(); // Make sure everyone is checked into their current assignments if (!$request->allParticipantsCheckedIn()) { // Return the user to the room change request page // NB, don't need an error message here because it should already be printed // by the RoomChangeParticipantView. $cmd = CommandFactory::getCommand('ShowManageRoomChange'); $cmd->setRequestId($requestId); $cmd->redirect(); } // Transition the request to 'Approved' $request->transitionTo(new RoomChangeStateApproved($request, time(), null, UserStatus::getUsername())); // Remove each participants existing assignment foreach ($participants as $participant) { $bannerId = $participant->getBannerId(); // Lookup the student $student = StudentFactory::getStudentByBannerId($bannerId, $term); // Save student object for later $this->students[$bannerId] = $student; // Save student's current assignment reason for later re-use $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $term); //TODO - Student might not be assigned!! $this->assignmentReasons[$bannerId] = $assignment->getReason(); // Remove existing assignment // TODO: Don't hard code refund percentage HMS_Assignment::unassignStudent($student, $term, 'Room Change Request Approved', UNASSIGN_CHANGE, 100); } // Create new assignments for each participant foreach ($participants as $participant) { // Grab the student object which was previously saved $student = $this->students[$participant->getBannerId()]; // Create each new assignment HMS_Assignment::assignStudent($student, $term, null, $participant->getToBed(), BANNER_MEAL_STD, 'Room Change Approved', FALSE, $this->assignmentReasons[$bannerId]); // Release bed reservation $bed = new HMS_Bed($participant->getToBed()); $bed->clearRoomChangeReserved(); $bed->save(); } // Transition each participant to 'In Process' foreach ($participants as $participant) { $participant->transitionTo(new ParticipantStateInProcess($participant, time(), null, UserStatus::getUsername())); // TODO: Send notifications } // Notify everyone that they can do the move HMS_Email::sendRoomChangeInProcessNotice($request); // Notify roommates that their circumstances are going to change foreach ($request->getParticipants() as $p) { $student = $this->students[$p->getBannerId()]; // New Roommate $newbed = new HMS_Bed($p->getToBed()); $newroom = $newbed->get_parent(); foreach ($newroom->get_assignees() as $a) { if ($a instanceof Student && $a->getBannerID() != $p->getBannerID()) { HMS_Email::sendRoomChangeApprovedNewRoommateNotice($a, $student); } } // Old Roommate $oldbed = new HMS_Bed($p->getFromBed()); $oldroom = $oldbed->get_parent(); foreach ($oldroom->get_assignees() as $a) { if ($a instanceof Student && $a->getBannerID() != $p->getBannerID()) { HMS_Email::sendRoomChangeApprovedOldRoommateNotice($a, $student); } } } // Return the user to the room change request page $cmd = CommandFactory::getCommand('ShowManageRoomChange'); $cmd->setRequestId($requestId); $cmd->redirect(); }
public function execute(CommandContext $context) { // Cmd to redirect to when we're done or upon error. $formCmd = CommandFactory::getCommand('ShowRoomChangeRequestForm'); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); // Get input $cellNum = $context->get('cell_num'); $optOut = $context->get('cell_opt_out'); $firstHallPref = $context->get('first_choice'); $secondHallPref = $context->get('second_choice'); $term = Term::getCurrentTerm(); // Create the student object $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Make sure the student is currently assigned $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $term); if (is_null($assignment)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You are not currently assigned to a room, so you cannot request a room change.'); $menuCmd->redirect(); } // Get the HMS_Bed object corresponding to the student's current assignment $bed = $assignment->get_parent(); $room = $bed->get_parent(); // Check for an existing room change request $changeReq = RoomChangeRequestFactory::getPendingByStudent($student, $term); if (!is_null($changeReq)) { // has pending request NQ::simple('hms', hms\NotificationView::ERROR, 'You already have a pending room change request. You cannot submit another request until your pending request is processed.'); $menuCmd->redirect(); } // Check that a cell phone number was provided, or that the opt-out box was checked. if ((!isset($cellNum) || empty($cellNum)) && !isset($optOut)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please provide a cell phone number or check the box indicating you do not wish to provide it.'); $formCmd->redirect(); } // Check the format of the cell phone number if (isset($cellNum)) { // Filter out non-numeric characters $cellNum = preg_replace("/[^0-9]/", '', $cellNum); } $reason = $context->get('reason'); // Make sure a 'reason' was provided. if (!isset($reason) || empty($reason)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please provide a brief explaniation of why you are requesting a room change.'); $formCmd->redirect(); } $type = $context->get('type'); // Extra sanity checks if we're doing a switch if ($type == 'swap') { $switchUsername = $context->get('swap_with'); // Can't switch with yourself if ($student->getUsername() == $switchUsername) { NQ::simple('hms', hms\NotificationView::ERROR, "You can't swtich rooms with yourself. Please choose someone other than yourself."); $formCmd->redirect(); } // Load the other student try { $swapStudent = StudentFactory::getStudentByUsername($switchUsername, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, we could not find a student with the user name '{$switchUsername}'. Please double-check the user name of the student you would like to switch places with."); $formCmd->redirect(); } // Make sure the student is assigned $swapAssignment = HMS_Assignment::getAssignmentByBannerId($swapStudent->getBannerId(), $term); if (is_null($swapAssignment)) { NQ::simple('hms', hms\NotificationView::ERROR, "{$swapStudent->getName()} is not currently assigned. Please choose another student to switch rooms with."); $formCmd->redirect(); } // Make sure the other student's room is the same gender as this room $swapBed = $swapAssignment->get_parent(); $swapRoom = $swapBed->get_parent(); if ($swapRoom->getGender() != $room->getGender()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$swapStudent->getName()} is assigned to a room of a different gender than you. Please choose student of the same gender as yourself to switch rooms with."); $formCmd->redirect(); } // Check to see if the other student is already involved in a room change request $swapStudentReq = RoomChangeRequestFactory::getPendingByStudent($swapStudent, $term); if (!is_null($swapStudentReq)) { // has pending request NQ::simple('hms', hms\NotificationView::ERROR, 'The student you are requesting to swap with already has a pending room change request. You cannot request to swap with him/her until the pending request is processed.'); $menuCmd->redirect(); } } //create the request object $request = new RoomChangeRequest($term, $reason); $request->save(); // Main participant $participant = new RoomChangeParticipant($request, $student, $bed); if (isset($cellNum)) { $participant->setCellPhone($cellNum); } // Switching to a different room, so set params on main participant if ($type == 'switch') { // preferences if (!empty($firstHallPref)) { $hall = new HMS_Residence_Hall($firstHallPref); if (!is_null($hall->getId())) { $participant->setHallPref1($hall); } } if (!empty($secondHallPref)) { $hall = new HMS_Residence_Hall($secondHallPref); if (!is_null($hall->getId())) { $participant->setHallPref2($hall); } } // Save the main participant and its state $participant->save(); // No further approval is required so we skip a step HMS_Email::sendRoomChangeCurrRDNotice($request); } else { if ($type == 'swap') { // Swapping with another student, so handle the other particpant // Set main participant's toBed to other student's bed $participant->setToBed($swapBed); // Create the other participant $swapParticipant = new RoomChangeParticipant($request, $swapStudent, $swapBed); // Set other student's toBed to main participant's bed $swapParticipant->setToBed($bed); $swapParticipant->save(); // Save the main participant and its state $participant->save(); // Send "request needs your approval" to other students // TODO: When you add the ability to have many people on this request, you will // need to put a foreach loop here or something. HMS_Email::sendRoomChangeParticipantNotice($participant, $swapParticipant); } } // Immediately transition to the StudentApproved state. $participant->transitionTo(new ParticipantStateStudentApproved($participant, time(), null, UserStatus::getUsername())); HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_ROOM_CHANGE_SUBMITTED, UserStatus::getUsername(FALSE), $reason); // Email sender with acknowledgment HMS_Email::sendRoomChangeRequestReceivedConfirmation($student); if ($type == 'switch') { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Your room change request has been received and is pending approval. You will be contacted by your Residence Director (RD) in the next 24-48 hours regarding your request.'); } else { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Your room change request has been received. The student(s) you selected to swap with must sign-in and agree to the request. It will then be forwarded to your Residence Director and the Housing Assignments Office for approval.'); } $menuCmd->redirect(); }
public function execute(CommandContext $context) { // Check permissions if (!Current_User::allow('hms', 'checkin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to checkin students.'); } $bannerId = $context->get('bannerId'); $hallId = $context->get('hallId'); // Check for key code $keyCode = $context->get('key_code'); if (!isset($keyCode) || $keyCode == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Please enter a key code.'); $errorCmd = CommandFactory::getCommand('ShowCheckinForm'); $errorCmd->setBannerId($bannerId); $errorCmd->setHallId($hallId); $errorCmd->redirect(); } $term = Term::getSelectedTerm(); // Lookup the student $student = StudentFactory::getStudentByBannerId($bannerId, $term); // Get the student's current assignment $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $term); $bed = $assignment->get_parent(); // Get the currently logged in user $currUser = Current_User::getUsername(); // Check for an existing Check-in $checkin = CheckinFactory::getCheckinByBed($student, $bed); // If there's not already a checkin for this bed, create a new one if (is_null($checkin)) { $checkin = new Checkin($student, $bed, $term, $currUser, $keyCode); } else { if ($checkin->getBedId() == $bed->getId() && time() - $checkin->getCheckinDate() < Checkin::CHECKIN_TIMEOUT) { // Check-in already exists, and it's within the timout window, so we'll overwrite the existing checkin $updatedCheckin = new Checkin($student, $bed, $term, $currUser, $keyCode); $updatedCheckin->substitueForExistingCheckin($checkin); // Use the old checkin to replace this one $checkin = $updatedCheckin; } else { // There's an existing checkin, but it's after the timeout, so we need to make a new checkin $checkin = new Checkin($student, $bed, $term, $currUser, $keyCode); } } $checkin->save(); // Add this to the activity log HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_CHECK_IN, UserStatus::getUsername(), $assignment->where_am_i()); // Generate the RIC PHPWS_Core::initModClass('hms', 'InfoCard.php'); PHPWS_Core::initModClass('hms', 'InfoCardPdfView.php'); $infoCard = new InfoCard($checkin); $infoCardView = new InfoCardPdfView(); $infoCardView->addInfoCard($infoCard); // Send confirmation Email with the RIC form to the student PHPWS_Core::initModClass('hms', 'HMS_Email.php'); HMS_Email::sendCheckinConfirmation($student, $infoCard, $infoCardView); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Checkin successful.'); // Redirect to success page with option to print check-in document. $cmd = CommandFactory::getCommand('ShowCheckinDocument'); $cmd->setBannerId($student->getBannerId()); $cmd->setCheckinId($checkin->getId()); $cmd->redirect(); }