public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'approve_rlc_applications')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to approve RLC applications.'); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); # Foreach rlc assignment made # $app_id is the 'id' column in the 'learning_community_applications' table, tells which student we're assigning # $rlc_id is the 'id' column in the 'learning_communitites' table, and refers to the RLC selected for the student foreach ($_REQUEST['final_rlc'] as $app_id => $rlc_id) { if ($rlc_id <= 0) { continue; } $app = HMS_RLC_Application::getApplicationById($app_id); $student = StudentFactory::getStudentByUsername($app->username, $app->term); # Insert a new assignment in the 'learning_community_assignment' table $assign = new HMS_RLC_Assignment(); $assign->rlc_id = $rlc_id; $assign->gender = $student->getGender(); $assign->assigned_by = UserStatus::getUsername(); $assign->application_id = $app->id; $assign->state = 'new'; $assign->save(); # Log the assignment PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($app->username, ACTIVITY_ASSIGN_TO_RLC, UserStatus::getUsername(), "New Assignment"); } // Show a success message NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully assigned RLC applicant(s).'); $context->goBack(); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'approve_rlc_applications')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to approve/deny RLC applications.'); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); // Remove assignment $assignment = HMS_RLC_Assignment::getAssignmentById($context->get('assignId')); $rlcName = $assignment->getRlcName(); $rlcApp = $assignment->getApplication(); if (!is_null($assignment)) { $assignment->delete(); } else { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not find an RLC assignment with that id.'); } HMS_Activity_Log::log_activity($rlcApp->getUsername(), ACTIVITY_RLC_UNASSIGN, Current_User::getUsername(), "Removed from {$rlcName}"); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Removed from RLC'); // Deny application $rlcApp->denied = 1; $rlcApp->save(); NQ::simple('hms', hms\NotificationView::SUCCESS, 'RLC Application denied'); HMS_Activity_Log::log_activity($rlcApp->getUsername(), ACTIVITY_DENIED_RLC_APPLICATION, Current_User::getUsername(), 'RLC Application Denied'); $context->goBack(); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $term = $context->get('term'); // Application must exist $app = HMS_RLC_Application::getApplicationByUsername(UserStatus::getUsername(), $term); if (is_null($app)) { NQ::simple('hms', hms\NotificationView::ERROR, 'No RLC application exists.'); $context->goBack(); } else { if (!HMS_RLC_Assignment::checkForAssignment(UserStatus::getUsername(), $term)) { // Delete the app $app->delete(); // Log it PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_RLC_APPLICATION_DELETED, UserStatus::getUsername()); // Show a notification and go back NQ::simple('hms', hms\NotificationView::SUCCESS, 'RLC application deleted.'); $context->goBack(); } else { NQ::simple('hms', hms\NotificationView::WARNING, 'You have already been assigned to an RLC.'); $context->goBack(); } } }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); Layout::addPageTitle("RLC Application Review"); $tags = array(); if (UserStatus::isAdmin()) { $menuCmd = CommandFactory::getCommand('ShowAssignRlcApplicants'); $tags['MENU_LINK'] = $menuCmd->getURI(); } else { $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $tags['MENU_LINK'] = $menuCmd->getURI(); } $tags['FULL_NAME'] = $this->student->getFullName(); $tags['STUDENT_TYPE'] = $this->student->getPrintableType(); $tags['TERM'] = Term::toString($this->application->getTerm()); $appType = $this->application->getApplicationType(); if ($appType == RLC_APP_FRESHMEN) { $tags['APPLICATION_TYPE'] = 'Freshmen'; } else { if ($appType == RLC_APP_RETURNING) { $tags['APPLICATION_TYPE'] = 'Re-application'; } } $rlcs = HMS_Learning_Community::getRlcList(); $tags['FIRST_CHOICE'] = $rlcs[$this->application->rlc_first_choice_id]; if (isset($this->application->rlc_second_choice_id)) { $tags['SECOND_CHOICE'] = $rlcs[$this->application->rlc_second_choice_id]; } if (isset($this->application->rlc_third_choice_id)) { $tags['THIRD_CHOICE'] = $rlcs[$this->application->rlc_third_choice_id]; } $tags['WHY_SPECIFIC'] = $this->application->why_specific_communities; $tags['STRENGTHS_AND_WEAKNESSES'] = $this->application->strengths_weaknesses; $tags['WHY_FIRST_CHOICE'] = $this->application->rlc_question_0; if (isset($this->application->rlc_second_choice_id)) { $tags['WHY_SECOND_CHOICE'] = $this->application->rlc_question_1; } if (isset($this->application->rlc_second_choice_id)) { $tags['WHY_THIRD_CHOICE'] = $this->application->rlc_question_2; } // If this application is denied and the person logged in is an admin, show a warning if ($this->application->isDenied() && UserStatus::isAdmin()) { NQ::simple('hms', hms\NotificationView::WARNING, 'This application has been denied.'); } // Show options depending of status of application. if (UserStatus::isAdmin() && Current_User::allow('hms', 'approve_rlc_applications')) { if (!$this->application->denied && !HMS_RLC_Assignment::checkForAssignment($this->student->getUsername(), Term::getSelectedTerm())) { // Approve application for the community selected from dropdown $approvalForm = $this->getApprovalForm(); $approvalForm->mergeTemplate($tags); $tags = $approvalForm->getTemplate(); // Deny application $tags['DENY_APP'] = $this->getDenialLink(); } } return PHPWS_Template::process($tags, 'hms', 'student/rlc_application.tpl'); }
public function show_verify_assignment() { PHPWS_Core::initModClass('hms', 'HMS_Term.php'); PHPWS_Core::initModClass('hms', 'HMS_SOAP.php'); 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'); $tpl = array(); $assignment = HMS_Assignment::get_assignment($_SESSION['asu_username'], $_SESSION['application_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 = HMS_SOAP::get_student_type($_SESSION['asu_username'], $_SESSION['application_term']); if ($type == TYPE_CONTINUING) { $movein_time_id = $assignment->get_rt_movein_time_id(); } elseif ($type == TYPE_TRANFER) { $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($_SESSION['application_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; $roommates = array(); if (!is_null($assignees)) { foreach ($assignees as $roommate) { if ($roommate->asu_username != $_SESSION['asu_username']) { $roommates[] = $roommate->asu_username; } } } if (empty($roommates)) { $tpl['roommate'][]['ROOMMATE'] = 'You do not have a roommate.'; } else { foreach ($roommates as $roommate) { $tpl['roommate'][]['ROOMMATE'] = '' . HMS_SOAP::get_name($roommate) . ' (<a href="mailto:' . $roommate . '@appstate.edu">' . $roommate . '@appstate.edu</a>)'; } } $rlc_assignment = HMS_RLC_Assignment::check_for_assignment($_SESSION['asu_username'], $_SESSION['application_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')); return PHPWS_Template::process($tpl, 'hms', 'student/verify_assignment.tpl'); }
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) { // Get an application if one exists PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $application = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $this->getTerm()); // Check for an assignment PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $assignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm()); PHPWS_Core::initModClass('hms', 'RlcApplicationMenuView.php'); return new RlcApplicationMenuView($this->term, $student, $this->getStartDate(), $this->getEditDate(), $this->getEndDate(), $application, $assignment); }
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 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 execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $term = $context->get('term'); if (!isset($term)) { throw new InvalidArgumentException('Missing term!'); } $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername(UserStatus::getUsername(), $term); $rlcApplication = $rlcAssignment->getApplication(); PHPWS_Core::initModClass('hms', 'AcceptRlcInviteView.php'); $view = new AcceptRlcInviteView($rlcApplication, $rlcAssignment, $term); $context->setContent($view->show()); }
public function execute(CommandContext $context) { $term = $context->get('term'); if (!isset($term)) { throw new InvalidArgumentException('Missing term!'); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentConfirmedState.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentDeclinedState.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername(UserStatus::getUsername(), $term); $rlcApplication = $rlcAssignment->getApplication(); $student = StudentFactory::getStudentByUsername($rlcApplication->getUsername(), $rlcApplication->getTerm()); $acceptStatus = $context->get('acceptance'); $termsCheck = $context->get('terms_cond'); if ($acceptStatus == 'accept' && !isset($termsCheck)) { // Student accepted the invite, but didn't check the terms/conditions box $errorCmd = CommandFactory::getCommand('ShowAcceptRlcInvite'); $errorCmd->setTerm($term); NQ::simple('hms', hms\NotificationView::ERROR, 'Please check the box indicating that you agree to the learning communitiy terms and conditions.'); $errorCmd->redirect(); } else { if ($acceptStatus == 'accept' && isset($termsCheck)) { // Student accepted the invite and checked the terms/conditions box $rlcAssignment->changeState(new RlcAssignmentConfirmedState($rlcAssignment)); NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have <strong>accepted</strong> your Residential Learning Community invitation.'); // Log this! HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_ACCEPT_RLC_INVITE, UserStatus::getUsername(), $rlcAssignment->getRlcName()); $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); } else { if ($acceptStatus == 'decline') { // student declined $rlcAssignment->changeState(new RlcAssignmentDeclinedState($rlcAssignment)); NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have <strong>declined</strong> your Residential Learning Community invitation.'); // Log this! HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_DECLINE_RLC_INVITE, UserStatus::getUsername(), $rlcAssignment->getRlcName()); $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); } else { // Didn't choose $errorCmd = CommandFactory::getCommand('ShowAcceptRlcInvite'); $errorCmd->setTerm($term); NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose to either accept or decline your learning community invitation.'); $errorCmd->redirect(); } } } $context->setContent('confirmed or denied'); }
public function getMenuBlockView(Student $student) { PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'RlcReapplicationMenuBlockView.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $application = HousingApplication::getApplicationByUser($student->getUsername(), $this->term); if (!$application instanceof LotteryApplication) { $application = null; } $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $this->term); if (!$rlcApp instanceof HMS_RLC_Application) { $rlcApp = null; } // Check for an assignment $assignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm()); return new RlcReapplicationMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $application, $rlcApp, $assignment); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'RlcSelfAssignStartView.php'); PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $term = $context->get('term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); $housingApp = HousingApplicationFactory::getAppByStudent($student, $term); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $term); $errorCmd = CommandFactory::getCommand('ShowStudentMenu'); // Double check that the student has an RLC application, and that it's in the 'invited' state if ($rlcAssignment == null) { NQ::simple('hms', hms\NotificationView::ERROR, "You're not eligible for RLC self-selection because you have not been assigned to a Learning Community."); $errorCmd->redirect(); } if ($rlcAssignment->getStateName() != 'selfselect-invite') { NQ::simple('hms', hms\NotificationView::ERROR, "You're not eligible for RLC self-selection because you have not been invited for self-selection."); $errorCmd->redirect(); } $roommateRequestId = $context->get('roommateRequestId'); $view = new RlcSelfAssignStartView($student, $term, $rlcAssignment, $housingApp, $roommateRequestId); $context->setContent($view->show()); }
/** * Handles removing RLC assignments. * @param Student $student */ private function handleRlcAssignment(Student $student) { # Check for and delete any learning community assignments $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->term); if (!is_null($rlcAssignment)) { $rlc = new HMS_Learning_Community($rlcAssignment->getRlcId()); //TODO catch/handle exceptions $rlcAssignment->delete(); $this->actions[$student->getUsername()][] = 'Removed RLC assignment: ' . $rlc->get_community_name(); HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_WITHDRAWN_RLC_APP_DENIED, UserStatus::getUsername(), 'Withdrawn search'); } }
/** * Sets up the pager object for searching questionnairs. * * @return String HTML output */ public static function profile_search_pager($term) { // get the current student's gender PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm()); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $student->getApplicationTerm()); $gender = $student->getGender(); PHPWS_Core::initCoreClass('DBPager.php'); $pageTags = array(); $pageTags['USERNAME'] = _('Email'); $pageTags['FIRST_NAME'] = _('First Name'); $pageTags['LAST_NAME'] = _('Last Name'); $pageTags['ACTIONS'] = _('Action'); $pager = new DBPager('hms_student_profiles', 'RoommateProfile'); $pager->db->addWhere('term', $term); // Check to see if user is assigned to an RLC $rlc_assignment = HMS_RLC_Assignment::checkForAssignment($student->getUsername(), $student->getApplicationTerm()); if ($rlc_assignment != false) { // User is assigned to an RLC, only show results from other students in the same RLC $pager->db->addJoin('LEFT OUTER', 'hms_student_profiles', 'hms_learning_community_applications', 'username', 'username'); $pager->db->addJoin('LEFT OUTER', 'hms_learning_community_assignment', 'hms_learning_community_applications', 'application_id', 'id'); $pager->db->addWhere('hms_learning_community_assignment.rlc_id', $rlc_assignment['rlc_id']); // $pager->db->setTestMode(); } // If an ASU username was entered, just use that. Otherwise, use the rest of the fields. if (isset($_REQUEST['asu_username']) && $_REQUEST['asu_username'] != '') { $pager->addWhere('hms_student_profiles.username', $_REQUEST['asu_username'], 'ILIKE'); $_SESSION['profile_search_asu_username'] = $_REQUEST['asu_username']; } else { $m = new RoommateProfile(); $hobbiesCount = count($m->hobbies_array); // Hobby check boxes for ($x = 0; $x < $hobbiesCount; $x++) { if (isset($_REQUEST['hobbies_checkbox'][$m->hobbies_array[$x]])) { $pager->addWhere('hms_student_profiles.' . $m->hobbies_array[$x], 1, '='); $_SESSION['hobbies_checkbox'][$m->hobbies_array[$x]] = 1; } } $musicCount = count($m->music_array); // Music check boxes for ($x = 0; $x < $musicCount; $x++) { if (isset($_REQUEST['music_checkbox'][$m->music_array[$x]])) { $pager->addWhere('hms_student_profiles.' . $m->music_array[$x], 1, '='); $_SESSION['hobbies_checkbox'][$m->music_array[$x]] = 1; } } $studyCount = count($m->study_array); // Study times for ($x = 0; $x < $studyCount; $x++) { if (isset($_REQUEST['study_times'][$m->study_array[$x]])) { $pager->addWhere('hms_student_profiles.' . $m->study_array[$x], 1, '='); $_SESSION['study_times'][$m->study_array[$x]] = 1; } } $dropDownCount = count($m->drop_down_array); // Drop downs for ($x = 0; $x < $dropDownCount; $x++) { if (isset($_REQUEST[$m->drop_down_array[$x]]) && $_REQUEST[$m->drop_down_array[$x]] != 0) { $pager->addWhere('hms_student_profiles.' . $m->drop_down_array[$x], $_REQUEST[$m->drop_down_array[$x]], '='); $_SESSION[$m->drop_down_array[$x]] = $_REQUEST[$m->drop_down_array[$x]]; } } $langCount = count($m->lang_array); // Spoken Languages for ($x = 0; $x < $langCount; $x++) { if (isset($_REQUEST['language_checkbox'][$m->lang_array[$x]])) { $pager->addWhere('hms_student_profiles.' . $m->lang_array[$x], 1, '='); $_SESSION['language_checkbox'][$m->lang_array[$x]] = 1; } } } // Join with hms_application table on username to make sure genders match. $pager->db->addJoin('LEFT OUTER', 'hms_student_profiles', 'hms_new_application', 'username', 'username'); // $pager->addWhere('hms_student_profiles.user_id','hms_application.asu_username','ILIKE'); $pager->addWhere('hms_new_application.gender', $gender, '='); // Don't list the current user as a match $pager->addWhere('hms_student_profiles.username', UserStatus::getUsername(), 'NOT LIKE'); $pager->db->addOrder('username', 'ASC'); $pager->setModule('hms'); $pager->setTemplate('student/profile_search_pager.tpl'); $pager->setLink('index.php?module=hms'); $pager->setEmptyMessage("No matches found. Try broadening your search by selecting fewer criteria."); $pager->addRowTags('getPagerTags'); $pager->addPageTags($pageTags); return $pager->get(); }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Util.php'); $tpl = array(); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); $tpl['STATUS'] = ""; if (isset($this->assignment) && $this->assignment->getStateName() == 'declined') { // Student declined the invite $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['DECLINED'] = ""; //dummy tag } else { if (isset($this->application) && !is_null($this->application->id) && isset($this->assignment) && $this->assignment->getStateName() == 'confirmed') { // Student has applied, been accepted, been invited, and confirmed that invitation to a particular community. The student can no longer view/edit the application. $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['CONFIRMED_RLC_NAME'] = $this->assignment->getRlcName(); } else { if (isset($this->assignment) && $this->assignment->getStateName() == 'invited') { // Studnet has applied, been assigned, and been sent an invite email $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['INVITED_COMMUNITY_NAME'] = $this->assignment->getRlcName(); $acceptCmd = CommandFactory::getCommand('ShowAcceptRlcInvite'); $acceptCmd->setTerm($this->term); $tpl['INVITED_CONFIRM_LINK'] = $acceptCmd->getLink('accept or decline your invitation'); } else { if (isset($this->application) && !is_null($this->application->id)) { $tpl['ICON'] = FEATURE_COMPLETED_ICON; // Let student view their application $viewCmd = CommandFactory::getCommand('ShowRlcApplicationReView'); $viewCmd->setAppId($this->application->getId()); $tpl['VIEW_APP'] = $viewCmd->getLink('view your application'); // The student can also delete their application if // they aren't already assigned PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); if (!HMS_RLC_Assignment::checkForAssignment(UserStatus::getUsername(), $this->term)) { $delCmd = CommandFactory::getCommand('DeleteRlcApplication'); $delCmd->setTerm($this->term); $confCmd = CommandFactory::getCommand('JSConfirm'); $confCmd->setLink('delete your application'); $confCmd->setTitle('delete your application'); $confCmd->setQuestion('Are you sure you want to delete your RLC Application?'); $confCmd->setOnConfirmCommand($delCmd); $tpl['DELETE_TEXT'] = 'You may also '; $tpl['DELETE_APP'] = $confCmd->getLink('delete your application') . '.'; } if (time() < $this->editDate) { $newCmd = CommandFactory::getCommand('ShowRlcApplicationView'); $newCmd->setTerm($this->term); $tpl['NEW_APP'] = $newCmd->getLink('submit a new application'); } } else { if (time() < $this->startDate) { $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate); } else { if (time() > $this->endDate) { $tpl['ICON'] = FEATURE_LOCKED_ICON; // fade out header $tpl['STATUS'] = "locked"; $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate); } else { $tpl['ICON'] = FEATURE_OPEN_ICON; $applyCmd = CommandFactory::getCommand('ShowRlcApplicationView'); $applyCmd->setTerm($this->term); $tpl['APP_NOW'] = $applyCmd->getLink('Apply for a Residential Learning Community now.'); } } } } } } Layout::addPageTitle("RLC Application Menu"); return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/RlcApplicationMenuBlock.tpl'); }
public function execute(CommandContext $context) { // Check to see if the user is coming back from DocuSign contract $event = $context->get('event'); if (isset($event) && $event != null && ($event == 'signing_complete' || $event == 'viewing_complete')) { $roommateRequestId = $context->get('roommateRequestId'); if (isset($roommateRequestId) && $roommateRequestId != null) { $roommateCmd = CommandFactory::getCommand('LotteryShowRoommateRequest'); $roommateCmd->setRequestId($roommateRequestId); $roommateCmd->redirect(); } else { $hallCmd = CommandFactory::getCommand('LotteryShowChooseHall'); $hallCmd->redirect(); } } $term = $context->get('term'); $errorCmd = CommandFactory::getCommand('RlcSelfAssignStart'); $errorCmd->setTerm($term); // Load the student $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Load the RLC Assignment $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $term); // Check for accept or decline status $acceptance = $context->get('acceptance'); if (!isset($acceptance) || $acceptance == null) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please indicate whether you accept or decline this invitation.'); $errorCmd->redirect(); } // Student declined if ($acceptance == 'decline') { // student declined $rlcAssignment->changeState(new RlcAssignmentDeclinedState($rlcAssignment)); NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have <strong>declined</strong> your Residential Learning Community invitation.'); // Log this! HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_DECLINE_RLC_INVITE, UserStatus::getUsername(), $rlcAssignment->getRlcName()); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $menuCmd->redirect(); } $termsCheck = $context->get('terms_cond'); // Make sure student accepted the terms if ($acceptance == 'accept' && !isset($termsCheck)) { // Student accepted the invite, but didn't check the terms/conditions box NQ::simple('hms', hms\NotificationView::ERROR, 'Please check the box indicating that you agree to the learning communitiy terms and conditions.'); $errorCmd->redirect(); } // Check phone number $cellPhone = $context->get('cellphone'); $doNotCall = $context->get('do_not_call'); if (is_null($doNotCall) && (!isset($cellPhone) || $cellPhone == '')) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please enter your cell phone number, or check the box to indicate you do not want to give a phone number.'); $errorCmd->redirect(); } /* Emergency Contact Sanity Checking */ $emergencyName = $context->get('emergency_contact_name'); $emergencyRelationship = $context->get('emergency_contact_relationship'); $emergencyPhone = $context->get('emergency_contact_phone'); $emergencyEmail = $context->get('emergency_contact_email'); if (empty($emergencyName) || empty($emergencyRelationship) || empty($emergencyPhone) || empty($emergencyEmail)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please complete all of the emergency contact person information.'); $errorCmd->redirect(); } /* Missing Persons Sanity Checking */ $missingPersonName = $context->get('missing_person_name'); $missingPersonRelationship = $context->get('missing_person_relationship'); $missingPersonPhone = $context->get('missing_person_phone'); $missingPersonEmail = $context->get('missing_person_email'); if (empty($missingPersonName) || empty($missingPersonRelationship) || empty($missingPersonPhone) || empty($missingPersonEmail)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please complete all of the missing persons contact information.'); $errorCmd->redirect(); } // Check for an existing housing application $housingApp = HousingApplicationFactory::getAppByStudent($student, $term, 'lottery'); if (is_null($housingApp)) { // Make a new Housing Application // TODO: imporve this to mirror the regular housing application... $housingApp = new LotteryApplication(0, $term, $student->getBannerId(), $student->getUsername(), $student->getGender(), 'C', $student->getApplicationTerm(), $cellPhone, BANNER_MEAL_STD, 0, 0, 0, 0, $student->isInternational(), NULL, 0, 0, 0, 0, 0, null); } else { // Update the existing cell phone $housingApp->setCellPhone($cellPhone); $housingApp->setEmergencyContactName($emergencyName); $housingApp->setEmergencyContactRelationship($emergencyRelationship); $housingApp->setEmergencyContactPhone($emergencyPhone); $housingApp->setEmergencyContactEmail($emergencyEmail); $housingApp->setMissingPersonName($missingPersonName); $housingApp->setMissingPersonRelationship($missingPersonRelationship); $housingApp->setMissingPersonPhone($missingPersonPhone); $housingApp->setMissingPersonEmail($missingPersonEmail); } $housingApp->save(); $returnCmd = CommandFactory::getCommand('RlcSelfSelectInviteSave'); $returnCmd->setTerm($term); // If we're confirming a roommate request, then set the ID on the return command $roommateRequestId = $context->get('roommateRequestId'); if (isset($roommateRequestId) && $roommateRequestId != null) { $returnCmd->setRoommateRequestId($roommateRequestId); } $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement'); $agreementCmd->setTerm($term); $agreementCmd->setAgreedCommand($returnCmd); $agreementCmd->redirect(); }
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(); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HousingApplication.php'); $term = $context->get('term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Commands for re-directing later $formCmd = CommandFactory::getCommand('ShowRlcReapplication'); $formCmd->setTerm($term); // $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); // Pull in data for local use $rlcOpt = $context->get('rlc_opt'); $rlcChoice1 = $context->get('rlc_choice_1'); $rlcChoice2 = $context->get('rlc_choice_2'); $rlcChoice3 = $context->get('rlc_choice_3'); $why = $context->get('why_this_rlc'); $contribute = $context->get('contribute_gain'); // Change any 'none's into null if ($rlcChoice2 == 'none') { $rlcChoice2 = null; } if ($rlcChoice3 == 'none') { $rlcChoice3 = null; } # Get the list of RLCs that the student is eligible for # Note: hard coded to 'C' because we know they're continuing at this point. # This accounts for freshmen addmitted in the spring, who will still have the 'F' type. $communities = HMS_Learning_Community::getRlcListReapplication(false, 'C'); # Look up any existing RLC assignment (for the current term, should be the Spring term) $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), Term::getPrevTerm(Term::getCurrentTerm())); // Sanity checking on user-supplied data // If the student is already in an RLC, and the student is eligible to reapply for that RLC (RLC always takes returners, // or the RLC is in the list of communities this student is eligible for), then check to make the user chose something for the re-apply option. if (!is_null($rlcAssignment) && (array_key_exists($rlcAssignment->getRlcId(), $communities) || $rlcAssignment->getRlc()->getMembersReapply() == 1) && is_null($rlcOpt)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose whether you would like to continue in your currnet RLC, or apply for a different community.'); $formCmd->redirect(); } // If the user is 'contining' in his/her current RLC, then figure that out and set it if (!is_null($rlcOpt) && $rlcOpt == 'continue') { $rlcChoice1 = $rlcAssignment->getRLC()->get_id(); $rlcChoice2 = NULL; $rlcChoice3 = NULL; } else { // User either can't 'continue' or didn't want to. Check that the user supplied rankings isstead. // Make sure a first choice was made if ($rlcChoice1 == 'select') { NQ::simple('hms', hms\NotificationView::ERROR, 'You must choose a community as your "first choice".'); $formCmd->redirect(); } if (isset($rlcChoice2) && $rlcChoice1 == $rlcChoice2 || isset($rlcChoice2) && isset($rlcChoice3) && $rlcChoice2 == $rlcChoice3 || isset($rlcChoice3) && $rlcChoice1 == $rlcChoice3) { NQ::simple('hms', hms\NotificationView::ERROR, 'You cannot choose the same community twice.'); $formCmd->redirect(); } } // Check the short answer questions if (empty($why) || empty($contribute)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please respond to both of the short answer questions.'); $formCmd->redirect(); } $wordLimit = 500; if (str_word_count($why) > $wordLimit) { NQ::simple('hms', hms\NotificationView::ERROR, 'Your answer to question number one is too long. Please limit your response to 500 words or less.'); $formCmd->redirect(); } $wordLimit = 500; if (str_word_count($contribute) > $wordLimit) { NQ::simple('hms', hms\NotificationView::ERROR, 'Your answer to question number two is too long. Please limit your response to 500 words or less.'); $formCmd->redirect(); } $app = new HMS_RLC_Application(); $app->setUsername($student->getUsername()); $app->setFirstChoice($rlcChoice1); $app->setSecondChoice($rlcChoice2); $app->setThirdChoice($rlcChoice3); $app->setWhySpecificCommunities($why); $app->setStrengthsWeaknesses($contribute); $_SESSION['RLC_REAPP'] = $app; // Redirect to the page 2 view command $page2cmd = CommandFactory::getCommand('ShowRlcReapplicationPageTwo'); $page2cmd->setTerm($term); $page2cmd->redirect(); }
/** * Depricated per ticket #530 * @deprecated */ public function check_rlc_assignments() { PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $resulta = HMS_RLC_Assignment::checkForAssignment($this->requestor, $this->term); $resultb = HMS_RLC_Assignment::checkForAssignment($this->requestee, $this->term); if ($resulta === false && $resultb === false) { return true; } if ($resulta !== false && $resultb !== false) { if ($resulta['rlc_id'] == $resultb['rlc_id']) { return true; } } return false; }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'add_rlc_members')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to view RLC members.'); } PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'RlcApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php'); // Get the selected term $term = Term::getSelectedTerm(); // Get the request community $communityId = $context->get('communityId'); if (!isset($communityId) || $communityId == '') { throw new InvalidArgumentException('Missing community id.'); } $community = new HMS_Learning_Community($communityId); // Get banner ID list and make sure it has content $bannerIds = $context->get('banner_id_list'); if (!isset($bannerIds) || $bannerIds == '') { $errorCmd = CommandFactory::getCommand('ShowAdminAddRlcMember'); $errorCmd->setCommunity($community); $errorCmd->redirect(); } // Break up string into an array of individual ids $bannerIds = explode("\n", $bannerIds); foreach ($bannerIds as $banner) { // Clean up the banner id $banner = trim($banner); // Skip blank lines if ($banner == '') { continue; } // Get the student try { $student = StudentFactory::getStudentByBannerId($banner, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "Couldn't find a student with ID: {$e->getRequestedId()}"); continue; } catch (InvalidArgumentException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "This doesn't look like a banner ID: {$banner}"); continue; } // Check for an existing housing application $housingApp = HousingApplicationFactory::getAppByStudent($student, $term); // If no housing app, show a warning if (is_null($housingApp)) { NQ::simple('hms', hms\NotificationView::WARNING, "No housing application found for: {$student->getName()}({$student->getBannerID()})"); } // Check for an existing learning community application $rlcApp = RlcApplicationFactory::getApplication($student, $term); if ($rlcApp == null) { // Create a new learning community application $rlcApp = new HMS_RLC_Application(); $rlcApp->setUsername($student->getUsername()); $rlcApp->setDateSubmitted(time()); $rlcApp->setFirstChoice($community->getId()); $rlcApp->setSecondChoice(null); $rlcApp->setThirdChoice(null); $rlcApp->setWhySpecificCommunities('Application created administratively.'); $rlcApp->setStrengthsWeaknesses(''); $rlcApp->setRLCQuestion0(null); $rlcApp->setRLCQuestion1(null); $rlcApp->setRLCQuestion2(null); $rlcApp->setEntryTerm($term); if ($student->getType() == TYPE_CONTINUING) { $rlcApp->setApplicationType(RLC_APP_RETURNING); } else { $rlcApp->setApplicationType(RLC_APP_FRESHMEN); } $rlcApp->save(); } else { // Reset the application's denial flag, see #1026 $rlcApp->setDenied(0); $rlcApp->save(); // RLC application already exists NQ::simple('hms', hms\NotificationView::WARNING, "RLC application already exists for {$student->getName()}({$student->getBannerID()})"); } // Check for RLC membership $membership = RlcMembershipFactory::getMembership($student, $term); if ($membership !== false) { NQ::simple('hms', hms\NotificationView::ERROR, "RLC membership already exists for {$student->getName()}({$student->getBannerID()})"); continue; } // Check Student's Eligibility $eligibility = HMS_Lottery::determineEligibility($student->getUsername()); if ($eligibility == false) { NQ::simple('hms', hms\NotificationView::ERROR, "{$student->getName()} ({$student->getBannerID()}) is not currently eligible for housing"); continue; } // Create RLC Membership $membership = new HMS_RLC_Assignment(); $membership->rlc_id = $community->getId(); $membership->gender = $student->getGender(); $membership->assigned_by = UserStatus::getUsername(); $membership->application_id = $rlcApp->id; $membership->state = 'new'; $membership->save(); } $successCmd = CommandFactory::getCommand('ShowViewByRlc'); $successCmd->setRlcId($community->getId()); $successCmd->redirect(); }
public function show() { javascript('jquery'); javascript('jquery_ui'); javascriptMod('hms', 'StudentProfile'); $tpl = array(); $tpl['USERNAME'] = $this->student->getUsername(); if (Current_User::allow('hms', 'login_as_student')) { $loginAsStudent = CommandFactory::getCommand('LoginAsStudent'); $loginAsStudent->setUsername($this->student->getUsername()); $tpl['LOGIN_AS_STUDENT_URI'] = $loginAsStudent->getURI(); } $tpl['BANNER_ID'] = $this->student->getBannerId(); $tpl['NAME'] = $this->student->getFullName(); $tpl['TERM'] = Term::getPrintableSelectedTerm(); $tpl['GENDER'] = $this->student->getPrintableGender(); $tpl['DOB'] = $this->student->getDOB(); if (strtotime($this->student->getDOB()) < strtotime("-25 years")) { NQ::simple('hms', hms\NotificationView::WARNING, 'Student is 25 years old or older!'); } $tpl['CLASS'] = $this->student->getPrintableClass(); $tpl['TYPE'] = $this->student->getPrintableType(); $tpl['STUDENT_LEVEL'] = $this->student->getPrintableLevel(); $tpl['ADMISSION_DECISION'] = $this->student->getAdmissionDecisionCode(); $tpl['INTERNATIONAL'] = $this->student->isInternational() ? 'Yes' : 'No'; $tpl['HONORS'] = $this->student->isHonors() ? 'Yes' : 'No'; $tpl['TEACHING_FELLOW'] = $this->student->isTeachingFellow() ? 'Yes' : 'No'; $tpl['WATAUGA'] = $this->student->isWataugaMember() ? 'Yes' : 'No'; if ($this->student->pinDisabled()) { NQ::simple('hms', hms\NotificationView::WARNING, "This student's PIN is disabled."); } try { $tpl['APPLICATION_TERM'] = Term::toString($this->student->getApplicationTerm()); } catch (InvalidTermException $e) { NQ::simple('hms', hms\NotificationView::WARNING, 'Application term is bad or missing.'); $tpl['APPLICATION_TERM'] = 'WARNING: Application Term is bad or missing: "' . $this->student->getApplicationTerm() . '"'; } /***************** * Phone Numbers * *****************/ $phoneNumberList = $this->student->getPhoneNumberList(); if (isset($phoneNumberList) && !is_null($phoneNumberList)) { foreach ($this->student->getPhoneNumberList() as $phone_number) { $tpl['phone_number'][] = array('NUMBER' => $phone_number); } } /************* * Addresses * *************/ foreach ($this->student->getAddressList() as $address) { //If it's not a PS or PR address, skip it if ($address->atyp_code != 'PR' && $address->atyp_code != 'PS') { continue; } switch ($address->atyp_code) { case 'PS': $addr_type = 'Student Address'; break; case 'PR': $addr_type = 'Permanent Residence Address'; break; default: $addr_type = 'Unknown-type address'; } $addr_array = array(); $addr_array['ADDR_TYPE'] = $addr_type; $addr_array['ADDRESS_L1'] = $address->line1; if (isset($address->line2)) { $addr_array['ADDRESS_L2'] = $address->line2; } if (isset($address->line3)) { $addr_array['ADDRESS_L3'] = $address->line3; } $addr_array['CITY'] = $address->city; $addr_array['STATE'] = $address->state; $addr_array['ZIP'] = $address->zip; $tpl['addresses'][] = $addr_array; } /************** * Assignment * **************/ if (!is_null($this->assignment)) { $reassignCmd = CommandFactory::getCommand('ShowAssignStudent'); $reassignCmd->setUsername($this->student->getUsername()); $unassignCmd = CommandFactory::getCommand('ShowUnassignStudent'); $unassignCmd->setUsername($this->student->getUsername()); $tpl['ASSIGNMENT'] = $this->assignment->where_am_i(true) . ' ' . $reassignCmd->getLink('Reassign') . ' ' . $unassignCmd->getLink('Unassign'); } else { $assignCmd = CommandFactory::getCommand('ShowAssignStudent'); $assignCmd->setUsername($this->student->getUsername()); $tpl['NOT_ASSIGNED'] = $assignCmd->getURI(); } /************* * Roommates *************/ if (isset($this->roommates) && !empty($this->roommates)) { // Remember, student can only have one confirmed or pending request // but multiple assigned roommates if (isset($this->roommates['PENDING'])) { $tpl['pending'][]['ROOMMATE'] = $this->roommates['PENDING']; } else { if (isset($this->roommates['CONFIRMED'])) { $tpl['confirmed'][]['ROOMMATE'] = $this->roommates['CONFIRMED']; } else { if (isset($this->roommates['NO_BED_AVAILABLE'])) { $tpl['error_status'][]['ROOMMATE'] = $this->roommates['NO_BED_AVAILABLE']; } else { if (isset($this->roommates['MISMATCHED_ROOMS'])) { $tpl['error_status'][]['ROOMMATE'] = $this->roommates['MISMATCHED_ROOMS']; } } } } if (isset($this->roommates['ASSIGNED'])) { foreach ($this->roommates['ASSIGNED'] as $roommate) { $tpl['assigned'][]['ROOMMATE'] = $roommate; } } } /************** * RLC Status * *************/ $rlc_names = RlcFactory::getRlcList(Term::getSelectedTerm()); $rlc_assignment = HMS_RLC_Assignment::getAssignmentByUsername($this->student->getUsername(), Term::getSelectedTerm()); $rlc_application = HMS_RLC_Application::getApplicationByUsername($this->student->getUsername(), Term::getSelectedTerm()); if (!is_null($rlc_assignment)) { $tpl['RLC_STATUS'] = "This student is assigned to: " . $rlc_names[$rlc_assignment->rlc_id]; } else { if (!is_null($rlc_application)) { $rlcViewCmd = CommandFactory::getCommand('ShowRlcApplicationReView'); $rlcViewCmd->setAppId($rlc_application->getId()); $tpl['RLC_STATUS'] = "This student has a " . $rlcViewCmd->getLink('pending RLC application') . "."; } else { $tpl['RLC_STATUS'] = "This student is not in a Learning Community and has no pending application."; } } /************************* * Re-application status * *************************/ $reapplication = HousingApplicationFactory::getAppByStudent($this->student, Term::getSelectedTerm()); # If this is a re-application, then check the special interest group status # TODO: incorporate all this into the LotteryApplication class if ($reapplication !== FALSE && $reapplication instanceof LotteryApplication) { if (isset($reapplication->special_interest) && !is_null($reapplication->special_interest) && !empty($reapplication->special_interest)) { # Student has been approved for a special group # TODO: format the name according to the specific group (sororities, etc) $tpl['SPECIAL_INTEREST'] = $reapplication->special_interest . '(confirmed)'; } else { # Check if the student selected a group on the application, but hasn't been approved if (!is_null($reapplication->sorority_pref)) { $tpl['SPECIAL_INTEREST'] = $reapplication->sorority_pref . ' (pending)'; //}else if($reapplication->tf_pref == 1){ //$tpl['SPECIAL_INTEREST'] = 'Teaching Fellow (pending)'; } else { if ($reapplication->wg_pref == 1) { $tpl['SPECIAL_INTEREST'] = 'Watauga Global (pending)'; } else { if ($reapplication->honors_pref == 1) { $tpl['SPECIAL_INTEREST'] = 'Honors (pending)'; } else { if ($reapplication->rlc_interest == 1) { $tpl['SPECIAL_INTEREST'] = 'RLC (pending)'; } else { # Student didn't select anything $tpl['SPECIAL_INTEREST'] = 'No'; } } } } } } else { # Not a re-application, so can't have a special group $tpl['SPECIAL_INTEREST'] = 'No'; } /****************** * Housing Waiver * *************/ $tpl['HOUSING_WAIVER'] = $this->student->housingApplicationWaived() ? 'Yes' : 'No'; if ($this->student->housingApplicationWaived()) { NQ::simple('hms', hms\NotificationView::WARNING, "This student's housing application has been waived for this term."); } /**************** * Applications * *************/ $appList = new ProfileHousingAppList($this->applications); $tpl['APPLICATIONS'] = $appList->show(); /********* * Assignment History * *********/ $historyArray = StudentAssignmentHistory::getAssignments($this->student->getBannerId()); $historyView = new StudentAssignmentHistoryView($historyArray); $tpl['HISTORY'] = $historyView->show(); /********** * Checkins */ $checkins = CheckinFactory::getCheckinsForStudent($this->student); $checkinHistory = new CheckinHistoryView($checkins); $tpl['CHECKINS'] = $checkinHistory->show(); /********* * Notes * *********/ $addNoteCmd = CommandFactory::getCommand('AddNote'); $addNoteCmd->setUsername($this->student->getUsername()); $form = new PHPWS_Form('add_note_dialog'); $addNoteCmd->initForm($form); $form->addTextarea('note'); $form->addSubmit('Add Note'); /******** * Logs * ********/ $everything_but_notes = HMS_Activity_Log::get_activity_list(); unset($everything_but_notes[array_search(ACTIVITY_ADD_NOTE, $everything_but_notes)]); if (Current_User::allow('hms', 'view_activity_log') && Current_User::allow('hms', 'view_student_log')) { PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); $activityLogPager = new ActivityLogPager($this->student->getUsername(), null, null, true, null, null, $everything_but_notes, true, 10); $activityNotePager = new ActivityLogPager($this->student->getUsername(), null, null, true, null, null, array(0 => ACTIVITY_ADD_NOTE), true, 10); $tpl['LOG_PAGER'] = $activityLogPager->show(); $tpl['NOTE_PAGER'] = $activityNotePager->show(); $logsCmd = CommandFactory::getCommand('ShowActivityLog'); $logsCmd->setActeeUsername($this->student->getUsername()); $tpl['LOG_PAGER'] .= $logsCmd->getLink('View more'); $notesCmd = CommandFactory::getCommand('ShowActivityLog'); $notesCmd->setActeeUsername($this->student->getUsername()); $notesCmd->setActivity(array(0 => ACTIVITY_ADD_NOTE)); $tpl['NOTE_PAGER'] .= $notesCmd->getLink('View more'); } $tpl = array_merge($tpl, $form->getTemplate()); // TODO logs // TODO tabs Layout::addPageTitle("Student Profile"); return PHPWS_Template::process($tpl, 'hms', 'admin/StudentProfile.tpl'); }
public function show() { $tpl = new PHPWS_Template('hms'); if (!$tpl->setFile('admin/reports/hall_overview.tpl')) { return 'Template error.'; } $rlcs = HMS_Learning_Community::getRlcList(); $rlcs_abbr = HMS_Learning_Community::getRLCListAbbr(); $tpl->setData(array('HALL' => $this->hall->hall_name, 'TERM' => Term::getPrintableSelectedTerm())); if ($this->nakedDisplay) { $menuCmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu'); $tpl->setData(array('MAINTENANCE' => $menuCmd->getLink('Main Menu'))); } $class = 'toggle1'; $this->hall->loadFloors(); foreach ($this->hall->_floors as $floor) { $floor->loadRooms(); if (!isset($floor->_rooms)) { continue; } if ($floor->rlc_id != NULL) { $floor_rlc = $rlcs[$floor->rlc_id]; } else { $floor_rlc = ''; } foreach ($floor->_rooms as $room) { $extra_attribs = ''; if ($room->isOffline()) { $extra_attribs .= 'Offline '; } if ($room->isReserved()) { $extra_attribs .= 'Reserved '; } if ($room->isRa()) { $extra_attribs .= 'RA '; } if ($room->isPrivate()) { $extra_attribs .= 'Private '; } if ($room->isOverflow()) { $extra_attribs .= 'Overflow '; } if ($room->isParlor()) { $extra_attribs .= 'Parlor '; } if ($room->isADA()) { $extra_attribs .= 'ADA'; } if ($room->isHearingImpaired()) { $extra_attribs .= 'Hearing Impaired'; } if ($room->bathEnSuite()) { $extra_attribs .= 'Bath en Suite'; } $room->loadBeds(); if (empty($room->_beds)) { $tpl->setCurrentBlock('room_repeat'); $tpl->setData(array('EXTRA_ATTRIBS' => $extra_attribs, 'ROOM_NUMBER' => $room->getLink('Room'))); $tpl->parseCurrentBlock(); continue; } foreach ($room->_beds as $bed) { $bed->loadAssignment(); $tpl->setCurrentBlock('bed_repeat'); $bed_link = $bed->getLink(); if (isset($bed->_curr_assignment)) { $username = $bed->_curr_assignment->asu_username; try { $student = StudentFactory::getStudentByUsername($username, $this->hall->term); } catch (StudentNotFoundException $e) { $student = null; NQ::simple('hms', hms\NotificationView::WARNING, "Could not find data for: {$username}"); } $assign_rlc = HMS_RLC_Assignment::checkForAssignment($username, $this->hall->term); //false or index if ($assign_rlc != FALSE) { $rlc_abbr = $rlcs_abbr[$assign_rlc['rlc_id']]; //get the abbr for the rlc } else { $rlc_abbr = ''; } // Alternating background colors if ($class == 'toggle1') { $class = 'toggle2'; } else { $class = 'toggle1'; } if (is_null($student)) { $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => 'UNKNOWN', 'USERNAME' => $username, 'BANNER_ID' => '', 'TOGGLE' => $class, 'RLC_ABBR' => $rlc_abbr)); } else { $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => $student->getProfileLink(), 'USERNAME' => $student->getUsername(), 'BANNER_ID' => $student->getBannerId(), 'TOGGLE' => $class, 'RLC_ABBR' => $rlc_abbr)); } } else { $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => $bed->get_assigned_to_link(), 'VACANT' => '')); } $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock('room_repeat'); $tpl->setData(array('EXTRA_ATTRIBS' => $extra_attribs, 'ROOM_NUMBER' => $room->getLink('Room'))); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock('floor_repeat'); $tpl->setData(array('FLOOR_NUMBER' => $floor->getLink('Floor'), 'FLOOR_RLC' => $floor_rlc)); $tpl->parseCurrentBlock(); } if ($this->nakedDisplay) { Layout::nakedDisplay($tpl->get(), 'Building overview for ' . $this->hall->hall_name, TRUE); } Layout::addPageTitle("Hall Overview"); return $tpl->get(); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'RlcReapplicationView.php'); PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $errorCmd = CommandFactory::getCommand('ShowStudentMenu'); $term = $context->get('term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Check deadlines PHPWS_Core::initModClass('hms', 'ApplicationFeature.php'); $feature = ApplicationFeature::getInstanceByNameAndTerm('RlcReapplication', $term); if (is_null($feature) || !$feature->isEnabled()) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, RLC re-applications are not avaialable for this term."); $errorCmd->redirect(); } if ($feature->getStartDate() > time()) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, it is too soon to submit a RLC re-application."); $errorCmd->redirect(); } else { if ($feature->getEndDate() < time()) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, the RLC re-application deadline has already passed. Please contact University Housing if you are interested in applying for a RLC."); $errorCmd->redirect(); } } // Double check the the student is eligible $housingApp = HousingApplication::getApplicationByUser($student->getUsername(), $term); if (!$housingApp instanceof LotteryApplication) { NQ::simple('hms', hms\NotificationView::ERROR, 'You are not eligible to re-apply for a Residential Learning Community.'); $errorCmd->redirect(); } // Make sure that the student has not already applied for this term $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $term); if (!is_null($rlcApp)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You have already re-applied for a Residential Learning Community for this term.'); $errorCmd->redirect(); } // Look up any existing RLC assignment (for the fall term; current term should be the Spring term, so the previous term should be the Fall) $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), Term::getPrevTerm(Term::getCurrentTerm())); // Get the list of RLCs that the student is eligible for // Note: hard coded to 'C' because we know they're continuing at this point. // This accounts for freshmen addmitted in the spring, who will still have the 'F' type. $communities = HMS_Learning_Community::getRlcListReapplication(false, 'C'); // If the student has an existing assignment, and that community always allows returning students, then make sure the community is in the list (if it's not already) if (isset($rlcAssignment)) { // Load the RLC $rlc = $rlcAssignment->getRlc(); // If members can always reapply, make sure community id exists as an array index if ($rlc->getMembersReapply() == 1 && !isset($communities[$rlc->get_id()])) { $communities[$rlc->get_id()] = $rlc->get_community_name(); } } session_write_close(); session_start(); if (isset($_SESSION['RLC_REAPP'])) { $reApp = $_SESSION['RLC_REAPP']; } else { $reApp = null; } $view = new RlcReapplicationView($student, $term, $rlcAssignment, $communities, $reApp); $context->setContent($view->show()); }
/** * 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 auto_assign($test = 0) { PHPWS_Core::initModClass('hms', 'HMS_Room.php'); PHPWS_Core::initModClass('hms', 'HousingApplication.php'); // TODO update this to use HousignAssignment PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'BannerQueue.php'); $term = Term::get_selected_term(); // In both cases: Random, and include Banner info $f_rooms = HMS_Room::get_all_free_rooms($term, FEMALE, TRUE); $m_rooms = HMS_Room::get_all_free_rooms($term, MALE, TRUE); $roommates = HMS_Roommate::get_all_confirmed_roommates($term, TRUE); $applicants = HousingApplication::getAllFreshmenApplications($term, 'gender', 'hms_fall_application.lifestyle_option', 'hms_fall_application.preferred_bedtime', 'hms_fall_application.room_condition', 'random'); $problems = array(); $rlcs = array(); $assigns = array(); $notices = array(); $successes = array(); $assigned = array(); reset($f_rooms); reset($m_rooms); $i_f_count = count($f_rooms); $i_m_count = count($m_rooms); // Assign Roommates reset($roommates); foreach ($roommates as $pair) { $a = HousingApplication::getApplicationByUser($pair['requestor'], $term); if (in_array($a->username, $assigned)) { $notices[] = "<strong>{$a->username}</strong> already scheduled for assignment."; continue; } $rlc = HMS_RLC_Assignment::checkForAssignment($a->username, $term); if ($rlc !== FALSE) { $rlcs[] = "Skipping <strong>{$a->username}</strong>; assigned to an RLC."; continue; } $b = HousingApplication::getApplicationByUser($pair['requestee'], $term); if (in_array($b->username, $assigned)) { $notices[] = "<strong>{$b->username}</strong> already scheduled for assignment."; continue; } $rlc = HMS_RLC_Assignment::checkForAssignment($b->username, $term); if ($rlc !== FALSE) { $rlcs[] = "Skipping <strong>{$b->username}</strong>; assigned to an RLC."; continue; } if (is_null($a->id)) { $problems[] = "Could not assign <strong>{$a->username}</strong> with roommate <strong>{$b->username}</strong>; {$a->username} does not have an application."; continue; } if (is_null($b->id)) { $problems[] = "Could not assign <strong>{$a->username}</strong> with roommate <strong>{$b->username}</strong>; {$b->username} does not have an application."; continue; } if ($a->gender != $b->gender) { $problems[] = "Epic FAIL... <strong>{$a->username}</strong> and <strong>{$b->username}</strong> are not the same gender."; continue; } $ass = HMS_Assignment::get_assignment($a->username, $term); if (is_a($ass, 'HMS_Assignment')) { $bbc = $ass->get_banner_building_code(); $bed = $ass->get_banner_bed_id(); $assigns[] = "Could not assign <strong>{$a->username}</strong>; already assigned to <strong>{$bbc} {$bed}</strong>"; continue; } $ass = HMS_Assignment::get_assignment($b->username, $term); if (is_a($ass, 'HMS_Assignment')) { $bbc = $ass->get_banner_building_code(); $bed = $ass->get_banner_bed_id(); $assigns[] = "Could not assign <strong>{$b->username}</strong>; already assigned to <strong>{$bbc} {$bed}</strong>"; continue; } $room = $a->gender == FEMALE ? array_shift($f_rooms) : ($a->gender == MALE ? array_shift($m_rooms) : 'badgender'); if (is_null($room)) { $problems[] = "Could not assign <strong>{$a->username}</strong>; out of empty " . ($a->gender ? 'male' : 'female') . ' rooms.'; $problems[] = "Could not assign <strong>{$b->username}</strong>; out of empty " . ($b->gender ? 'male' : 'female') . ' rooms.'; continue; } else { if ($room === 'badgender') { $problems[] = "Could not assign <strong>{$a->username}</strong>; {$a->gender} is not a valid gender."; continue; } } // Prepare for assignment $room =& new HMS_Room($room); $room->loadBeds(); $bed_a_text = $room->_beds[0]->get_banner_building_code() . ' ' . $room->_beds[0]->banner_id; $bed_b_text = $room->_beds[1]->get_banner_building_code() . ' ' . $room->_beds[1]->banner_id; if ($test) { $successes[] = HMS_Autoassigner::record_success('TEST Requested', $a, $b, $bed_a_text); $successes[] = HMS_Autoassigner::record_success('TEST Requested', $b, $a, $bed_b_text); } else { $result = HMS_Autoassigner::assign($a, $room->_beds[0], $term); if ($result === TRUE) { $successes[] = HMS_Autoassigner::record_success('Requested', $a, $b, $bed_a_text); $assigned[] = $a->username; } else { $problems[] = $result; } if (!is_null($b->id)) { $result = HMS_Autoassigner::assign($b, $room->_beds[1], $term); if ($result === TRUE) { $successes[] = HMS_Autoassigner::record_success('Requested', $b, $a, $bed_b_text); $assigned[] = $b->username; } else { $problems[] = $result; } } } } reset($applicants); while (count($applicants) > 0) { $a = array_shift($applicants); if ($a === FALSE) { continue; } if (!isset($a)) { continue; } if (in_array($a->username, $assigned)) { $notices[] = "<strong>{$a->username}</strong> already scheduled for assignment."; continue; } $rlc = HMS_RLC_Assignment::checkForAssignment($a->username, $term); if ($rlc !== FALSE) { $rlcs[] = "Skipping <strong>{$a->username}</strong>; assigned to an RLC."; continue; } $b = array_shift($applicants); if (in_array($b->username, $assigned)) { $notices[] = "<strong>{$b->username}</strong> already scheduled for assignment."; array_unshift($applicants, $a); continue; } $rlc = HMS_RLC_Assignment::checkForAssignment($b->username, $term); if ($rlc !== FALSE) { $rlcs[] = "Skipping <strong>{$b->username}</strong>; assigned to an RLC."; array_unshift($applicants, $a); continue; } if ($a->gender != $b->gender) { array_unshift($applicants, $b); $b = NULL; continue; } $ass = HMS_Assignment::get_assignment($a->username, $term); if (is_a($ass, 'HMS_Assignment')) { $bbc = $ass->get_banner_building_code(); $bed = $ass->get_banner_bed_id(); $assigns[] = "Could not assign <strong>{$a->username}</strong>; already assigned to <strong>{$bbc} {$bed}</strong>"; array_unshift($applicants, $b); continue; } $ass = HMS_Assignment::get_assignment($b->username, $term); if (is_a($ass, 'HMS_Assignment')) { $bbc = $ass->get_banner_building_code(); $bed = $ass->get_banner_bed_id(); $assigns[] = "Could not assign <strong>{$b->username}</strong>; already assigned to <strong>{$bbc} {$bed}</strong>"; array_unshift($applicants, $a); continue; } // Determine Room Gender $room = $a->gender == FEMALE ? array_shift($f_rooms) : ($a->gender == MALE ? array_shift($m_rooms) : 'badgender'); // We could be out of rooms or have database corruption if (is_null($room)) { $problems[] = "Could not assign <strong>{$a->username}</strong>; out of " . ($a->gender ? 'male' : 'female') . ' rooms.'; $problems[] = "Could not assign <strong>{$b->username}</strong>; out of " . ($b->gender ? 'male' : 'female') . ' rooms.'; continue; } else { if ($room === 'badgender') { $problems[] = "Could not assign <strong>{$a->username}</strong>; {$a->gender} is not a valid gender."; continue; } } // Prepare for assignment $room =& new HMS_Room($room); $room->loadBeds(); $bed_a_text = $room->_beds[0]->get_banner_building_code() . ' ' . $room->_beds[0]->banner_id; $bed_b_text = $room->_beds[1]->get_banner_building_code() . ' ' . $room->_beds[1]->banner_id; if ($test) { $successes[] = HMS_Autoassigner::record_success('TEST Auto', $a, $b, $bed_a_text); $successes[] = HMS_Autoassigner::record_success('TEST Auto', $b, $a, $bed_b_text); } else { $result = HMS_Autoassigner::assign($a, $room->_beds[0], $term); if ($result === TRUE) { $successes[] = HMS_Autoassigner::record_success('Auto', $a, $b, $bed_a_text); $assigned[] = $a->username; } else { $problems[] = $result; } if (!is_null($b->id)) { $result = HMS_Autoassigner::assign($b, $room->_beds[1], $term); if ($result === TRUE) { $successes[] = HMS_Autoassigner::record_success('Auto', $b, $a, $bed_b_text); $assigned[] = $b->username; } else { $problems[] = $result; } } } } $f_f_count = count($f_rooms); $f_m_count = count($m_rooms); usort($successes, array('HMS_Autoassigner', 'sort_successes')); $content = '<h1>Autoassigner Results - ' . date('Y-m-d') . '</h1>'; $content .= '<h2>Total Assignments: ' . count($assigned) . '</h2>'; $content .= "<p>Began with {$i_f_count} female rooms and {$i_m_count} male rooms</p>"; $content .= "<p>Ended with {$f_f_count} female rooms and {$f_m_count} male rooms</p>"; $content .= '<h2>Assignment Report (' . count($successes) . ')</h2>'; $content .= '<table><tr>'; $content .= '<th>Type</th><th>Bed A</th><th>Code A</th><th>Bed B</th><th>Code B</th><th>Room</th>'; $content .= '</tr>'; foreach ($successes as $success) { $content .= '<tr>'; $content .= '<td>' . $success['type'] . '</td>'; $content .= '<td>' . $success['a'] . '</td>'; $content .= '<td>' . $success['a_code'] . '</td>'; $content .= '<td>' . $success['room'] . '</td>'; $content .= '<td>' . $success['b'] . '</td>'; $content .= '<td>' . $success['b_code'] . '</td>'; $content .= "</tr>\n"; } $content .= '</tr></table>'; sort($problems); $content .= '<h2>Problems (' . count($problems) . ')</h2>'; $content .= implode("<br />\n", $problems); sort($rlcs); $content .= '<h2>Skipped for RLC (' . count($rlcs) . ')</h2>'; $content .= implode("<br />\n", $rlcs); sort($assigns); $content .= '<h2>Skipped, already assigned (' . count($assigns) . ')</h2>'; $content .= implode("<br />\n", $assigns); sort($notices); $content .= '<h2>Notices (' . count($notices) . ')</h2>'; $content .= implode("<br />\n", $notices); Layout::nakedDisplay($content, NULL, TRUE); }