public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'cancel_housing_application')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to cancel housing applications.'); } // Check for a housing application id $applicationId = $context->get('applicationId'); if (!isset($applicationId) || is_null($applicationId)) { throw new InvalidArgumentException('Missing housing application id.'); } // Check for a cancellation reason $cancelReason = $context->get('cancel_reason'); if (!isset($cancelReason) || is_null($cancelReason)) { throw new InvalidArgumentException('Missing cancellation reason.'); } // Load the housing application PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); $application = HousingApplicationFactory::getApplicationById($applicationId); // Load the student $student = $application->getStudent(); $username = $student->getUsername(); $term = $application->getTerm(); // Load the cancellation reasons $reasons = HousingApplication::getCancellationReasons(); // Check for an assignment and remove it // Decide which term to use - If this application is in a past fall term, then use the current term if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) { $assignmentTerm = Term::getCurrentTerm(); } else { $assignmentTerm = $term; } PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm); if (isset($assignment)) { // TODO: Don't hard code cancellation refund percentage HMS_Assignment::unassignStudent($student, $assignmentTerm, 'Application cancellation: ' . $reasons[$cancelReason], UNASSIGN_CANCEL, 100); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($username, $term); if (!is_null($rlcAssignment)) { $rlcAssignment->delete(); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcApplication = HMS_RLC_Application::getApplicationByUsername($username, $term); if (!is_null($rlcApplication)) { $rlcApplication->denied = 1; $rlcApplication->save(); HMS_Activity_Log::log_activity($username, ACTIVITY_DENIED_RLC_APPLICATION, \Current_User::getUsername(), Term::toString($term) . ' Denied RLC Application due to Contract Cancellation'); } // Cancel the application $application->cancel($cancelReason); $application->save(); echo 'success'; exit; }
public function getMenuBlockView(Student $student) { PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'RlcSelfSelectionMenuBlockView.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm()); $roomAssignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $this->getTerm()); $roommateRequests = HMS_Lottery::get_lottery_roommate_invites($student->getUsername(), $this->term); return new RlcSelfSelectionMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $rlcAssignment, $roomAssignment, $roommateRequests); }
public function 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 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()); }
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 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(); }
/** * 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; }
/** * 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'); } }
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) { 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()); }