public function getMenuBlockView(Student $student) { PHPWS_Core::initModClass('hms', 'RoomChangeMenuBlockView.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'RoomChangeRequestFactory.php'); $assignment = HMS_Assignment::getAssignment($student->getUsername(), $this->term); $request = RoomChangeRequestFactory::getPendingByStudent($student, $this->term); return new RoomChangeMenuBlockView($student, $this->term, $this->getStartDate(), $this->getEndDate(), $assignment, $request); }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Movein_Time.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $tpl = array(); $assignment = HMS_Assignment::getAssignment($this->student->getUsername(), $this->term); if ($assignment === NULL || $assignment == FALSE) { $tpl['NO_ASSIGNMENT'] = "You do not currently have a housing assignment."; } else { $tpl['ASSIGNMENT'] = $assignment->where_am_i() . '<br />'; # Determine the student's type and figure out their movein time $type = $this->student->getType(); if ($type == TYPE_CONTINUING) { $movein_time_id = $assignment->get_rt_movein_time_id(); } elseif ($type == TYPE_TRANSFER) { $movein_time_id = $assignment->get_t_movein_time_id(); } else { $movein_time_id = $assignment->get_f_movein_time_id(); } if ($movein_time_id == NULL) { $tpl['MOVE_IN_TIME'] = 'To be determined<br />'; } else { $movein_times = HMS_Movein_Time::get_movein_times_array($this->term); $tpl['MOVE_IN_TIME'] = $movein_times[$movein_time_id]; } } //get the assignees to the room that the bed that the assignment is in $assignees = !is_null($assignment) ? $assignment->get_parent()->get_parent()->get_assignees() : NULL; if (!is_null($assignees)) { foreach ($assignees as $roommate) { if ($roommate->getUsername() != $this->student->getUsername()) { $assignment = HMS_Assignment::getAssignment($roommate->getUsername(), $this->term); $assignment->loadBed(); $label = $assignment->_bed->bedroom_label; $tpl['roommate'][]['ROOMMATE'] = $roommate->getFullName() . ' - ' . $label . ' (' . $roommate->getEmailLink() . ')'; } } } else { $tpl['roommate'] = 'You do not have a roommate'; } $rlc_assignment = HMS_RLC_Assignment::checkForAssignment($this->student->getUsername(), $this->term); if ($rlc_assignment == NULL || $rlc_assignment === FALSE) { $tpl['RLC'] = "You have not been accepted to an RLC."; } else { $rlc_list = HMS_Learning_Community::getRlcList(); $tpl['RLC'] = 'You have been assigned to the ' . $rlc_list[$rlc_assignment['rlc_id']]; } $tpl['MENU_LINK'] = PHPWS_Text::secureLink('Back to Main Menu', 'hms', array('type' => 'student', 'op' => 'show_main_menu')); Layout::addPageTitle("Verify Assignment"); return PHPWS_Template::process($tpl, 'hms', 'student/verify_assignment.tpl'); }
public function getMenuBlockView(Student $student) { PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'ReapplicationMenuBlockView.php'); $assignment = HMS_Assignment::getAssignment($student->getUsername(), $this->term); $application = HousingApplication::getApplicationByUser($student->getUsername(), $this->term); if (!$application instanceof LotteryApplication) { $application = null; } $roommateRequests = HMS_Lottery::get_lottery_roommate_invites($student->getUsername(), $this->term); return new ReapplicationMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $assignment, $application, $roommateRequests); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'assignment_maintenance')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to assign students.'); } PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'AssignmentMoveConfirmationView.php'); $student = StudentFactory::getStudentByUsername($context->get('username'), Term::getSelectedTerm()); $assignment = HMS_Assignment::getAssignment($student->getUsername(), Term::getSelectedTerm()); $moveConfirmView = new AssignmentMoveConfirmationView($student, $assignment, $context->get('residence_hall'), $context->get('room'), $context->get('bed'), $context->get('meal_plan'), $context->get('assignment_type'), $context->get('notes')); $context->setContent($moveConfirmView->show()); }
/** * Fetch a roommate's bedroom label and create a link to that room */ private function getRoommateRoomLink($username) { // Get link for roommates' room $rmAssignment = HMS_Assignment::getAssignment($username, $this->term); if (!is_null($rmAssignment)) { $rmAssignment->loadBed(); $editRoomCmd = CommandFactory::getCommand('EditRoomView'); $editRoomCmd->setRoomId($rmAssignment->_bed->room_id); $roomLink = $editRoomCmd->getLink($rmAssignment->_bed->bedroom_label); return $roomLink; } else { return null; } }
/** * Handles looking up and removing assignments * @param Student $student */ private function handleAssignment(Student $student) { // Look for an assignment and delete it $assignment = HMS_Assignment::getAssignment($student->getUsername(), $this->term); if (!is_null($assignment)) { $location = $assignment->where_am_i(); try { //TODO Don't hard-code refund percentage HMS_Assignment::unassignStudent($student, $this->term, 'Automatically removed by Withdrawn Search', UNASSIGN_CANCEL, 100); } catch (Exception $e) { //TODO } $this->actions[$student->getUsername()][] = 'Removed assignment: ' . $location; HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_WITHDRAWN_ASSIGNMENT_DELETED, UserStatus::getUsername(), 'Withdrawn search: ' . $location); } }
/** * Removes/unassignes a student * * Valid values for $reason are defined in defines.php. * * @param Student $student Student to un-assign. * @param String $term The term of the assignment to remove. * @param String $notes Additional notes for the ActivityLog. * @param String $reason Reason string, defined in defines.php * @param Integer $refund Percentage of original charges student should be refunded * @throws PermissionException * @throws InvalidArgumentException * @throws AssignmentException * @throws DatabaseException */ public static function unassignStudent(Student $student, $term, $notes = "", $reason, $refund) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assignment_maintenance')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to unassign students.'); } PHPWS_Core::initModClass('hms', 'BannerQueue.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'AssignmentHistory.php'); PHPWS_Core::initModClass('hms', 'exception/AssignmentException.php'); $username = $student->getUsername(); // Make sure a username was entered if (!isset($username) || $username == '') { throw new InvalidArgumentException('Bad username.'); } $username = strtolower($username); // Check refund field, required field if (!isset($refund) || $refund == '') { throw new InvalidArgumentException('Please enter a refund percentage.'); } // Refund must be numeric if (!is_numeric($refund) || $refund < 0 || $refund > 100) { throw new InvalidArgumentException('The refund percentage must be between 0 and 100 percent.'); } // Must be whole number if (is_float($refund)) { throw new InvalidArgumentException('Only whole number refund percentages are supported, no decimal place is allowed.'); } // Make sure the requested username is actually assigned if (!HMS_Assignment::checkForAssignment($username, $term)) { throw new AssignmentException('Student is not assigned.'); } $assignment = HMS_Assignment::getAssignment($username, $term); if ($assignment == FALSE || $assignment == NULL) { throw new AssignmentException('Could not load assignment object.'); } $bed = $assignment->get_parent(); $room = $bed->get_parent(); $floor = $room->get_parent(); $building = $floor->get_parent(); // Attempt to unassign the student in Banner though SOAP $banner_result = BannerQueue::queueRemoveAssignment($student, $term, $building, $bed, $refund); // Show an error and return if there was an error if ($banner_result !== TRUE) { throw new AssignmentException('Error while adding the assignment removal to the Banner queue.'); } // Record this before we delete from the db $banner_bed_id = $bed->getBannerId(); $banner_building_code = $building->getBannerBuildingCode(); // Attempt to delete the assignment in HMS $result = $assignment->delete(); if (!$result) { throw new DatabaseException($result->toString()); } // Log in the activity log HMS_Activity_Log::log_activity($username, ACTIVITY_REMOVED, UserStatus::getUsername(), $term . ' ' . $banner_building_code . ' ' . $banner_bed_id . ' ' . $notes . 'Refund: ' . $refund); // Insert into history table AssignmentHistory::makeUnassignmentHistory($assignment, $reason); // Generate assignment notices for old roommates $assignees = $room->get_assignees(); // get an array of student objects for those assigned to this room if (sizeof($assignees) > 1) { foreach ($assignees as $roommate) { // Skip this student if ($roommate->getUsername() == $username) { continue; } $roommate_assign = HMS_Assignment::getAssignment($roommate->getUsername(), Term::getSelectedTerm()); $roommate_assign->letter_printed = 0; $roommate_assign->email_sent = 0; $roommate_assign->save(); } } // Show a success message return true; }