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() { 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'); }
/** * 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 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(); }
/** * 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 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); }