public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     PHPWS_Core::initModClass('hms', 'OffCampusWaitingListMenuBlockView.php');
     $application = HousingApplicationFactory::getAppByStudent($student, $this->term);
     return new OffCampusWaitingListMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $application);
 }
示例#2
0
 /**
  * Constructor.
  * Requires a Checkin object to get started.
  *
  * @param Checkin $checkin
  */
 public function __construct(Checkin $checkin)
 {
     $this->checkin = $checkin;
     $this->bannerId = $this->checkin->getBannerId();
     $this->term = $this->checkin->getTerm();
     $this->student = StudentFactory::getStudentByBannerId($this->bannerId, $this->term);
     // Lookup the student's housing application
     $this->application = HousingApplicationFactory::getAppByStudent($this->student, $this->term);
     // Create a dummy application if a real one doesn't exist
     if (!isset($this->application)) {
         $this->application = new HousingApplication();
     }
     // Get the hall, floor, and room from the checkin's bed
     $this->bed = new HMS_Bed($this->checkin->getBedId());
     $this->room = $this->bed->get_parent();
     $this->floor = $this->room->get_parent();
     $this->hall = $this->floor->get_parent();
     // Get the damages at check-in time
     $this->checkinDamages = RoomDamageFactory::getDamagesBefore($this->room, $this->checkin->getCheckinDate() + Checkin::CHECKIN_TIMEOUT);
     if (sizeof($this->checkinDamages) <= 0) {
         $this->checkinDamages = array();
     }
     // Get the damages at check-out time
     $this->checkoutDamages = RoomDamageFactory::getDamagesByRoom($this->room);
     if (sizeof($this->checkoutDamages) <= 0) {
         $this->checkoutDamages = array();
     }
 }
 public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     PHPWS_Core::initModClass('hms', 'UpdateEmergencyContactMenuBlockView.php');
     $application = HousingApplicationFactory::getAppByStudent($student, $this->term);
     return new UpdateEmergencyContactMenuBlockView($student, $this->getStartDate(), $this->getEndDate(), $application);
 }
 /**
  * (non-PHPdoc)
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     $term = $context->get('term');
     if (!isset($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $user = UserStatus::getUsername();
     $student = StudentFactory::getStudentByUsername($user, $term);
     // Load the student's application. Should be a lottery application.
     $application = HousingApplicationFactory::getAppByStudent($student, $term);
     // If there isn't a valid application in the DB, then we have a problem.
     if (!isset($application) || !$application instanceof LotteryApplication) {
         throw new InvalidArgumentException('Null application object.');
     }
     // Check to make sure the date isn't already set
     $time = $application->getWaitingListDate();
     if (isset($time)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You have already applied for the waiting list.');
         $cmd = CommandFactory::getCommand('ShowStudentMenu');
         $cmd->redirect();
     }
     // Set the date
     $application->setWaitingListDate(time());
     // Save the application again
     $application->save();
     // Log it to the activity log
     HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_REAPP_WAITINGLIST_APPLY, UserStatus::getUsername());
     // Success command
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
 public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $errorCmd = CommandFactory::getCommand('ShowEmergencyContactForm');
     $errorCmd->setTerm($term);
     // Determine the application type, based on the term
     $sem = Term::getTermSem($term);
     switch ($sem) {
         case TERM_FALL:
             $appType = 'fall';
             break;
         case TERM_SPRING:
             $appType = 'spring';
             break;
         case TERM_SUMMER1:
         case TERM_SUMMER2:
             $appType = 'summer';
             break;
     }
     try {
         $application = HousingApplicationFactory::getAppByStudent($student, $term, $appType);
         // Change the emergency contact and missing person info temporarily, WITHOUT saving
         /* Emergency Contact */
         $application->setEmergencyContactName($context->get('emergency_contact_name'));
         $application->setEmergencyContactRelationship($context->get('emergency_contact_relationship'));
         $application->setEmergencyContactPhone($context->get('emergency_contact_phone'));
         $application->setEmergencyContactEmail($context->get('emergency_contact_email'));
         /* Emergency Medical Condition */
         $application->setEmergencyMedicalCondition($context->get('emergency_medical_condition'));
         /* Missing Person */
         $application->setMissingPersonName($context->get('missing_person_name'));
         $application->setMissingPersonRelationship($context->get('missing_person_relationship'));
         $application->setMissingPersonPhone($context->get('missing_person_phone'));
         $application->setMissingPersonEmail($context->get('missing_person_email'));
     } catch (Exception $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage());
         $errorCmd->redirect();
     }
     PHPWS_Core::initModClass('hms', 'EmergencyContactReview.php');
     $view = new EmergencyContactReview($student, $term, $application);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'lottery_admin')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to administer re-application features.');
     }
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $bannerIds = $context->get('banner_ids');
     $term = Term::getSelectedTerm();
     $bannerIds = explode("\n", $bannerIds);
     foreach ($bannerIds as $bannerId) {
         // Trim any excess whitespace
         $bannerId = trim($bannerId);
         // Skip blank lines
         if ($bannerId == '') {
             continue;
         }
         $student = StudentFactory::getStudentByBannerId($bannerId, $term);
         try {
             $application = HousingApplicationFactory::getAppByStudent($student, $term);
         } catch (StudentNotFoundException $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, "No matching student was found for: {$bannerId}");
             continue;
         }
         if (is_null($application)) {
             NQ::simple('hms', hms\NotificationView::ERROR, "No housing application for: {$bannerId}");
             continue;
         }
         $application->magic_winner = 1;
         try {
             $application->save();
         } catch (Exception $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, "Error setting flag for: {$bannerId}");
             continue;
         }
         NQ::simple('hms', hms\NotificationView::SUCCESS, "Magic flag set for: {$bannerId}");
     }
     $viewCmd = CommandFactory::getCommand('ShowLotteryAutoWinners');
     $viewCmd->redirect();
 }
 /**
  * (non-PHPdoc)
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assignment_maintenance')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to assign students.');
     }
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'AssignStudentView.php');
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     $username = $context->get('username');
     $bedId = $context->get('bedId');
     $term = Term::getSelectedTerm();
     if (isset($bedId) && !is_null($bedId) && !empty($bedId)) {
         $bed = new HMS_Bed($bedId);
     } else {
         $bed = null;
     }
     if (isset($username)) {
         try {
             $student = StudentFactory::getStudentByUsername($context->get('username'), $term);
         } catch (InvalidArgumentException $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage());
             $cmd = CommandFactory::getCommand('ShowAssignStudent');
             $cmd->redirect();
         } catch (StudentNotFoundException $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage());
             $cmd = CommandFactory::getCommand('ShowAssignStudent');
             $cmd->redirect();
         }
         $application = HousingApplicationFactory::getAppByStudent($student, $term);
     } else {
         $student = null;
         $application = null;
     }
     $assignView = new AssignStudentView($student, $bed, $application);
     $context->setContent($assignView->show());
 }
 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());
 }
示例#9
0
 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');
 }
示例#10
0
 /**
  * getAdminCsvRow
  *
  *  This function converts the output of the adminPagerTags function
  * into something that the db pager's csv reporter understands.  It
  * replaces the html name link with a plain text one to avoid it being
  * squelched in the output and changes the case of the array indices
  * so that the column names look like the html report.
  */
 public function getAdminCsvRow()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     $row = array();
     // Get the RLC Application
     $rlcApp = $this->getApplication();
     // Get list of RLC names
     $rlcList = HMS_Learning_Community::getRLCListAbbr();
     // Get the student object
     $student = StudentFactory::getStudentByUsername($this->username, $this->term);
     // Get Housing App object
     $housingApp = HousingApplicationFactory::getAppByStudent($student, $rlcApp->getTerm());
     // Student info
     $row['name'] = $student->getFullName();
     $row['banner_id'] = $student->getBannerId();
     $row['email'] = $student->getUsername();
     $row['gender'] = $student->getPrintableGender();
     // RLC info
     $row['rlc'] = $rlcList[$this->getRlcId()];
     // Address columns
     $addressObj = $student->getAddress();
     if (isset($addressObj) && !is_null($addressObj)) {
         $address = (array) $addressObj;
         unset($address['county']);
         // Remove the county column, don't want it
         unset($address['atyp_code']);
         // Remove the address type column
         $row += $address;
     } else {
         // Provide empty columns so the alignment of the csv file doesn't get screwed up
         $row['line1'] = '';
         $row['line2'] = '';
         $row['city'] = '';
         $row['state'] = '';
         $row['zip'] = '';
     }
     // Phone number
     if ($housingApp instanceof HousingApplication) {
         $cellPhone = $housingApp->getCellPhone();
         if (isset($cellPhone) && $cellPhone != '') {
             $row['cell_phone'] = $cellPhone;
         } else {
             // Provide empty columns so the alignment of the csv file doesn't get screwed up
             $row['cell_phone'] = '';
         }
     } else {
         $row['cell_phone'] = '';
     }
     return $row;
 }
 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', '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();
 }
示例#13
0
 private function sendInvite(Student $student)
 {
     $this->output[] = "Inviting {$student->getUsername()} ({$student->getBannerId()})";
     // Update the winning student's invite
     try {
         $entry = HousingApplicationFactory::getAppByStudent($student, $this->term, 'lottery');
         $entry->invited_on = $this->now;
         $entry->save();
     } catch (Exception $e) {
         $this->output[] = 'Error while trying to select a winning student. Exception: ' . $e->getMessage();
         return;
     }
     // Update the total count
     $this->numInvitesSent['TOTAL']++;
     // Send the notification email
     HMS_Email::send_lottery_invite($student->getUsername(), $student->getName(), $this->academicYear);
     // Log that the invite was sent
     HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_LOTTERY_INVITED, UserStatus::getUsername(), "Expires on " . date('m/d/Y h:i:s a', $this->expireTime));
 }