Пример #1
0
 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();
     }
 }
Пример #3
0
 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)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFormView.php');
     // Make sure we have a valid term
     $term = $context->get('term');
     if (is_null($term) || !isset($term)) {
         throw new InvalidArgumentException('Missing 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;
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Make sure the student agreed to the terms, if not, send them back to the terms & agreement command
     //$event = $context->get('event');
     // If they haven't agreed, redirect to the agreement
     // TODO: actually check via docusign API
     /*
     if(is_null($event) || !isset($event) || ($event != 'signing_complete' && $event != 'viewing_complete')){
         $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement');
         $agreementCmd->setTerm($term);
         $agreementCmd->setAgreedCommand(CommandFactory::getCommand('ShowHousingApplicationForm'));
         $agreementCmd->redirect();
     }
     */
     // Check to see if the student's PIN is enabled. Don't let the student apply if the PIN is disabled.
     if ($student->pinDisabled()) {
         $pinCmd = CommandFactory::getCommand('ShowPinDisabled');
         $pinCmd->redirect();
     }
     // Check to see if the user has an existing application for the term in question
     $existingApplication = HousingApplication::getApplicationByUser($student->getUsername(), $term);
     // Check for an in-progress application on the context, ignore any exceptions (in case there isn't an application on the context)
     try {
         //TODO check to see if it looks like there might be something on the context before trying this
         $existingApplication = HousingApplicationFactory::getApplicationFromContext($context, $term, $student, $appType);
     } catch (Exception $e) {
         // ignored
         $contextApplication = NULL;
     }
     $appView = new HousingApplicationFormView($student, $term, $existingApplication);
     $context->setContent($appView->show());
 }
 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 execute(CommandContext $context)
 {
     if (!Current_User::allow('withdrawn_search')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to makr applications withdrawn.');
     }
     $id = $context->get('appId');
     if (!isset($id) || is_null($id)) {
         throw new InvalidArugumentException('Missing application id.');
     }
     PHPWS_Core::initModclass('hms', 'HousingApplicationFactory.php');
     $app = HousingApplicationFactory::getApplicationById($context->get('appId'));
     $app->setWithdrawn(1);
     $app->save();
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Application successfully marked as withdrawn.');
     $context->goBack();
 }
 public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     // If we're coming from the special needs page, save any special needs flags the student selected
     if (array_key_exists('special_needs', $context->getParams())) {
         $this->saveSpecialNeeds($context);
     }
     // If they haven't agreed, redirect to the agreement
     // TODO: actually check via docusign API
     $event = $context->get('event');
     if (is_null($event) || !isset($event) || $event != 'signing_complete' && $event != 'viewing_complete') {
         $returnCmd = CommandFactory::getCommand('ShowFreshmenApplicationReview');
         $returnCmd->setTerm($term);
         $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement');
         $agreementCmd->setTerm($term);
         $agreementCmd->setAgreedCommand($returnCmd);
         $agreementCmd->redirect();
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $errorCmd = CommandFactory::getCommand('ShowHousingApplicationForm');
     $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::getApplicationFromSession($_SESSION['application_data'], $term, $student, $appType);
     } catch (Exception $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage());
         $errorCmd->redirect();
     }
     PHPWS_Core::initModClass('hms', 'FreshmenApplicationReview.php');
     $view = new FreshmenApplicationReview($student, $term, $application);
     $context->setContent($view->show());
 }
 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();
 }
 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
     $this->setAppId($context->get('applicationId'));
     if (!isset($this->applicationId) || is_null($this->applicationId)) {
         throw new InvalidArgumentException('Missing housing application id.');
     }
     $application = HousingApplicationFactory::getApplicationById($this->applicationId);
     $application->setCancelled(0);
     $application->setCancelledBy(null);
     $application->setCancelledReason(null);
     $application->setCancelledOn(null);
     $application->save();
     HMS_Activity_Log::log_activity($application->getUsername(), ACTIVITY_REINSTATE_APPLICATION, UserStatus::getUsername());
     $returnCmd = CommandFactory::getCommand('ShowStudentProfile');
     $returnCmd->setBannerId($application->getBannerId());
     $returnCmd->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)
 {
     $applicationId = $context->get('applicationId');
     if (!isset($applicationId)) {
         throw new InvalidArgumentException('Missing application id.');
     }
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     $application = HousingApplicationFactory::getApplicationById($applicationId);
     $student = $application->getStudent();
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     // Decide which term to use - If this application is in a past fall term, then use the current term
     $term = $application->getTerm();
     if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) {
         $assignmentTerm = Term::getCurrentTerm();
     } else {
         $assignmentTerm = $term;
     }
     $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm);
     PHPWS_Core::initModClass('hms', 'HousingApplicationCancelView.php');
     $view = new HousingApplicationCancelView($student, $application, $assignment);
     echo $view->show();
     exit;
 }
 public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Recreate the agreedToCommand
     $agreedCmd = CommandFactory::getCommand($context->get('onAgreeAction'));
     $agreedCmd->setTerm($term);
     $roommateRequestId = $context->get('roommateRequestId');
     if (isset($roommateRequestId) && $roommateRequestId != null) {
         $agreedCmd->setRoommateRequestId($roommateRequestId);
     }
     //$submitCmd = CommandFactory::getCommand('AgreeToTerms');
     //$submitCmd->setTerm($term);
     //$submitCmd->setAgreedCmd($agreedCmd);
     $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;
     }
     $application = HousingApplicationFactory::getApplicationFromSession($_SESSION['application_data'], $term, $student, $appType);
     $docusignCmd = CommandFactory::getCommand('BeginDocusign');
     $docusignCmd->setTerm($term);
     $docusignCmd->setReturnCmd($agreedCmd);
     $docusignCmd->setParentName($application->getEmergencyContactName());
     $docusignCmd->setParentEmail($application->getEmergencyContactEmail());
     PHPWS_Core::initModClass('hms', 'TermsAgreementView.php');
     $agreementView = new TermsAgreementView($term, $docusignCmd, $student);
     $context->setContent($agreementView->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());
 }
Пример #16
0
 /**
  * Returns an array of HousingApplication objects, one object for each application the
  * given student has completed. All parameters are optional.
  * Returns false if the request cannot be compelted for any reason.
  *
  * TODO depricate this and do it better
  *
  * @param string $username
  * @param string $banner_id
  * @param string $term
  *
  * @return mixed <NULL, FallApplication>
  */
 public static function getAllApplications($username = null, $banner_id = null, $term = null)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     $db = new PHPWS_DB('hms_new_application');
     if (!is_null($banner_id)) {
         $db->addWhere('banner_id', $banner_id);
     }
     if (!is_null($username)) {
         $db->addWhere('username', $username, 'ILIKE');
     }
     if (!is_null($term)) {
         $db->addWhere('term', $term);
     }
     $result = $db->select();
     $apps = array();
     foreach ($result as $app) {
         $apps[] = HousingApplicationFactory::getApplicationById($app['id']);
     }
     return $apps;
 }
Пример #17
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');
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     PHPWS_Core::initModClass('hms', 'exception/InvalidTermException.php');
     $term = $context->get('term');
     $username = UserStatus::getUsername();
     $student = StudentFactory::getStudentByUsername($username, $term);
     $sem = Term::getTermSem($term);
     // Check for an existing application and delete it
     $app_result = HousingApplication::checkForApplication($username, $term);
     // If there's an existing housing application, handle deleting it
     if ($app_result !== FALSE) {
         switch ($sem) {
             case TERM_SPRING:
                 $application = new SpringApplication($app_result['id']);
                 break;
             case TERM_SUMMER1:
             case TERM_SUMMER2:
                 $application = new SummerApplication($app_result['id']);
                 break;
             case TERM_FALL:
                 $application = new FallApplication($app_result['id']);
                 break;
             default:
                 throw new InvalidTermException('Invalid term specified.');
         }
         // Save the old created on dates for re-use on new application
         $oldCreatedOn = $application->getCreatedOn();
         $oldCreatedBy = $application->getCreatedBy();
         $application->delete();
     }
     switch ($sem) {
         case TERM_FALL:
             $appType = 'fall';
             break;
         case TERM_SPRING:
             $appType = 'spring';
             break;
         case TERM_SUMMER1:
         case TERM_SUMMER2:
             $appType = 'summer';
             break;
         default:
             throw new Exception('Unknown application type');
     }
     $application = HousingApplicationFactory::getApplicationFromSession($_SESSION['application_data'], $term, $student, $appType);
     // If old created dates exist, use them as the 'created on' dates
     if (isset($oldCreatedOn)) {
         $application->setCreatedOn($oldCreatedOn);
         $application->setCreatedBy($oldCreatedBy);
     }
     $application->setCancelled(0);
     // Hard code a summer meal option for all summer applications.
     // Application for other terms use whatever the student selected
     if ($sem == TERM_SUMMER1 || $sem == TERM_SUMMER2) {
         $application->setMealPlan(BANNER_MEAL_5WEEK);
     }
     $result = $application->save();
     if ($result == TRUE) {
         // Log the fact that the application was submitted
         PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
         HMS_Activity_Log::log_activity($username, ACTIVITY_SUBMITTED_APPLICATION, $username);
         try {
             // report the application to banner;
             $application->reportToBanner();
         } catch (Exception $e) {
             // ignore any errors reporting this to banner, they'll be logged and admins notified
             // we've saved the student's application locally, so it's ok if this doesn't work
         }
         // Send the email confirmation
         PHPWS_Core::initModClass('hms', 'HMS_Email.php');
         HMS_Email::send_hms_application_confirmation($student, $application->getTerm());
     }
     $friendly_term = Term::toString($application->getTerm());
     NQ::simple('hms', hms\NotificationView::SUCCESS, "Your application for {$friendly_term} was successfully processed!  You will receive an email confirmation in the next 24 hours.");
     PHPWS_Core::initModClass('hms', 'applicationFeature/RlcApplication.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     $rlcReg = new RLCApplicationRegistration();
     if (ApplicationFeature::isEnabledForStudent($rlcReg, $term, $student) && HMS_RLC_Application::checkForApplication($student->getUsername(), $term) == FALSE && $application->rlc_interest == 1) {
         $rlcCmd = CommandFactory::getCommand('ShowRlcApplicationPage1View');
         $rlcCmd->setTerm($term);
         $rlcCmd->redirect();
     } else {
         $successCmd = CommandFactory::getCommand('ShowStudentMenu');
         $successCmd->redirect();
     }
 }
Пример #19
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));
 }
Пример #20
0
 /**
  * $roommates is the focus of getProfileView(). It's structure is helpful in
  * StudentProfileView.  It also makes it a little easier to recognize which roommmates
  * are requested ones so they can be emphasized in the template (admin/fancy-student-info.tpl)
  * Note that a student can only have a single pending/confirmed roommate request but multiple
  * assigned roommates!
  *
  */
 public function getProfileView()
 {
     PHPWS_Core::initModClass('hms', 'StudentProfileView.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     $studentUsername = $this->student->getUsername();
     $assignment = HMS_Assignment::getAssignmentByBannerId($this->student->getBannerId(), $this->term);
     $pendingRoommate = HMS_Roommate::get_pending_roommate($studentUsername, $this->term);
     $confirmedRoommate = HMS_Roommate::get_confirmed_roommate($studentUsername, $this->term);
     if (!is_null($assignment)) {
         $assignedRoommates = $assignment->get_parent()->get_parent()->get_assignees();
     }
     //
     // If student is assigned to room...
     //
     if (!is_null($assignment)) {
         foreach ($assignedRoommates as $roomie) {
             // make sure $roomie isn't the student being profiled or the requested roomies
             if ($roomie != FALSE && $roomie->getUsername() != $studentUsername) {
                 $roomieUsername = $roomie->getUsername();
                 if (is_null($confirmedRoommate) || $roomieUsername != $confirmedRoommate->getUsername()) {
                     if (is_null($pendingRoommate) || $roomieUsername != $pendingRoommate->getUsername()) {
                         // Get student object and room link
                         $roomLink = $this->getRoommateRoomLink($roomie->getUsername());
                         // if $roomie was assigned but not requested
                         $this->roommates['ASSIGNED'][] = $roomie->getProfileLink() . " - {$roomLink}";
                     }
                 }
             }
         }
     }
     //
     // Check status of requested roommates
     //
     if (!is_null($confirmedRoommate)) {
         if (!is_null($assignment)) {
             $confirmedRmAssignment = HMS_Assignment::getAssignment($confirmedRoommate->getUsername(), $this->term);
             if (!is_null($confirmedRmAssignment)) {
                 // if confirmed roommate is assigned to different room than profile student
                 if ($assignment->get_parent()->room_id != $confirmedRmAssignment->get_parent()->room_id) {
                     $this->setRoommateVar($confirmedRoommate, "confirmed", "mismatched_rooms");
                 } else {
                     $this->setRoommateVar($confirmedRoommate, "confirmed");
                 }
             } else {
                 // if profile student's room is full
                 if (!$assignment->get_parent()->get_parent()->has_vacancy()) {
                     $this->setRoommateVar($confirmedRoommate, "confirmed", "no_bed_available");
                 } else {
                     $this->setRoommateVar($confirmedRoommate, "confirmed");
                 }
             }
         } else {
             $this->setRoommateVar($confirmedRoommate, "confirmed");
         }
     } else {
         if (!is_null($pendingRoommate)) {
             if (!is_null($assignment)) {
                 $pendingRmAssignment = HMS_Assignment::getAssignment($pendingRoommate->getUsername(), $this->term);
                 if (!is_null($pendingRmAssignment)) {
                     // if pending roommate is assigned to different room than profile student
                     if ($assignment->get_parent()->room_id != $pendingRmAssignment->get_parent()->room_id) {
                         $this->setRoommateVar($pendingRoommate, "pending", "mismatched_rooms");
                     } else {
                         $this->setRoommateVar($pendingRoommate, "pending");
                     }
                 } else {
                     // if profile student's room is full
                     if (!$assignment->get_parent()->get_parent()->has_vacancy()) {
                         $this->setRoommateVar($pendingRoommate, "pending", "no_bed_available");
                     } else {
                         $this->setRoommateVar($pendingRoommate, "pending");
                     }
                 }
             } else {
                 $this->setRoommateVar($pendingRoommate, "pending");
             }
         }
     }
     $applications = HousingApplication::getAllApplicationsForStudent($this->student);
     $subTypeApps = array();
     // Convert each of the general HousingApplication objets to its specific sub type (e.g. FallApplication)
     foreach ($applications as $app) {
         $subTypeApps[] = HousingApplicationFactory::getApplicationById($app->id);
     }
     return new StudentProfileView($this->student, $subTypeApps, $assignment, $this->roommates);
 }
Пример #21
0
 public function show()
 {
     // TODO: Load application in controller and pass it to HousingApplicationView constructor.
     $application = HousingApplicationFactory::getApplicationById($this->id);
     $student = StudentFactory::getStudentByUsername($application->username, $application->term);
     $tpl = array();
     //If the application has been submitted plug in the date it was created
     if (isset($application->created_on)) {
         $tpl['RECEIVED_DATE'] = "Received on: " . date('d-F-Y h:i:s a', $application->created_on);
     }
     if ($application instanceof LotteryApplication && $application->getWaitingListDate() != null) {
         $tpl['WAITING_LIST_DATE'] = date("d-F-y h:i:sa", $application->getWaitingListDate());
     }
     // Check if the application has been cancelled
     // isWithdrawn() has been depricated, but I'm leaving it here just for historical sake
     // on the off-chance that it catches an older application that's withdrawn but not cancelled.
     if ($application->isCancelled() || $application->isWithdrawn()) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'This application has been cancelled.');
     }
     $tpl['STUDENT_NAME'] = $student->getFullName();
     $tpl['GENDER'] = $student->getPrintableGender();
     $tpl['ENTRY_TERM'] = Term::toString($application->term);
     $tpl['CLASSIFICATION_FOR_TERM_LBL'] = $student->getPrintableClass();
     $tpl['STUDENT_STATUS_LBL'] = $student->getPrintableType();
     $tpl['MEAL_OPTION'] = HMS_Util::formatMealOption($application->meal_plan);
     if (isset($application->lifestyle_option)) {
         $tpl['LIFESTYLE_OPTION'] = $application->lifestyle_option == 1 ? 'Single gender' : 'Co-ed';
     } else {
         $tpl['LIFESTYLE_OPTION'] = 'n/a';
     }
     if (isset($application->preferred_bedtime)) {
         $tpl['PREFERRED_BEDTIME'] = $application->preferred_bedtime == 1 ? 'Early' : 'Late';
     } else {
         $tpl['PREFERRED_BEDTIME'] = 'n/a';
     }
     if (isset($application->room_condition)) {
         $tpl['ROOM_CONDITION'] = $application->room_condition == 1 ? 'Neat' : 'Cluttered';
     } else {
         $tpl['ROOM_CONDITION'] = 'n/a';
     }
     if (isset($application->smoking_preference)) {
         $tpl['SMOKING_PREFERENCE'] = $application->smoking_preference == 1 ? 'No' : 'Yes';
     } else {
         $tpl['SMOKING_PREFERENCE'] = 'n/a';
     }
     if (isset($application->room_type)) {
         $tpl['ROOM_TYPE'] = $application->room_type == ROOM_TYPE_DOUBLE ? 'Double' : 'Private (if available)';
     }
     $tpl['CELLPHONE'] = '';
     if (strlen($application->cell_phone) == 10) {
         $tpl['CELLPHONE'] .= '(' . substr($application->cell_phone, 0, 3) . ')';
         $tpl['CELLPHONE'] .= '-' . substr($application->cell_phone, 3, 3);
         $tpl['CELLPHONE'] .= '-' . substr($application->cell_phone, 6, 4);
     }
     /* Emergency Contact */
     $tpl['EMERGENCY_CONTACT_NAME'] = $application->getEmergencyContactName();
     $tpl['EMERGENCY_CONTACT_RELATIONSHIP'] = $application->getEmergencyContactRelationship();
     $tpl['EMERGENCY_CONTACT_PHONE'] = $application->getEmergencyContactPhone();
     $tpl['EMERGENCY_CONTACT_EMAIL'] = $application->getEmergencyContactEmail();
     $tpl['EMERGENCY_MEDICAL_CONDITION'] = $application->getEmergencyMedicalCondition();
     /* Missing Person */
     if (Current_User::allow('hms', 'view_missing_person_info')) {
         $tpl['MISSING_PERSON_NAME'] = $application->getMissingPersonName();
         $tpl['MISSING_PERSON_RELATIONSHIP'] = $application->getMissingPersonRelationship();
         $tpl['MISSING_PERSON_PHONE'] = $application->getMissingPersonPhone();
         $tpl['MISSING_PERSON_EMAIL'] = $application->getMissingPersonEmail();
     }
     /* Special Needs */
     $special_needs = "";
     if ($application->physical_disability == 1) {
         $special_needs = 'Physical disability<br />';
     }
     if ($application->psych_disability) {
         $special_needs .= 'Psychological disability<br />';
     }
     if ($application->medical_need) {
         $special_needs .= 'Medical need<br />';
     }
     if ($application->gender_need) {
         $special_needs .= 'Gender need<br />';
     }
     if ($special_needs == '') {
         $special_needs = 'None';
     }
     $tpl['SPECIAL_NEEDS_RESULT'] = $special_needs;
     if ($application instanceof FallApplication) {
         PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
         $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $application->getTerm());
         if (!is_null($rlcApp)) {
             $tpl['RLC_INTEREST_1'] = 'Yes (Completed - Use the main menu to view/modify.)';
         } else {
             $tpl['RLC_INTEREST_1'] = $application->rlc_interest == 0 ? 'No' : 'Yes';
         }
     }
     if (Current_User::getUsername() == "hms_student") {
         $tpl['MENU_LINK'] = PHPWS_Text::secureLink('Back to main menu', 'hms', array('type' => 'student', 'op' => 'show_main_menu'));
     }
     Layout::addPageTitle("Housing Application");
     return PHPWS_Template::process($tpl, 'hms', 'admin/student_application.tpl');
 }
Пример #22
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)
 {
     if (!Current_User::allow('hms', 'add_rlc_members')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to view RLC members.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcApplicationFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     // Get the selected term
     $term = Term::getSelectedTerm();
     // Get the request community
     $communityId = $context->get('communityId');
     if (!isset($communityId) || $communityId == '') {
         throw new InvalidArgumentException('Missing community id.');
     }
     $community = new HMS_Learning_Community($communityId);
     // Get banner ID list and make sure it has content
     $bannerIds = $context->get('banner_id_list');
     if (!isset($bannerIds) || $bannerIds == '') {
         $errorCmd = CommandFactory::getCommand('ShowAdminAddRlcMember');
         $errorCmd->setCommunity($community);
         $errorCmd->redirect();
     }
     // Break up string into an array of individual ids
     $bannerIds = explode("\n", $bannerIds);
     foreach ($bannerIds as $banner) {
         // Clean up the banner id
         $banner = trim($banner);
         // Skip blank lines
         if ($banner == '') {
             continue;
         }
         // Get the student
         try {
             $student = StudentFactory::getStudentByBannerId($banner, $term);
         } catch (StudentNotFoundException $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, "Couldn't find a student with ID: {$e->getRequestedId()}");
             continue;
         } catch (InvalidArgumentException $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, "This doesn't look like a banner ID: {$banner}");
             continue;
         }
         // Check for an existing housing application
         $housingApp = HousingApplicationFactory::getAppByStudent($student, $term);
         // If no housing app, show a warning
         if (is_null($housingApp)) {
             NQ::simple('hms', hms\NotificationView::WARNING, "No housing application found for: {$student->getName()}({$student->getBannerID()})");
         }
         // Check for an existing learning community application
         $rlcApp = RlcApplicationFactory::getApplication($student, $term);
         if ($rlcApp == null) {
             // Create a new learning community application
             $rlcApp = new HMS_RLC_Application();
             $rlcApp->setUsername($student->getUsername());
             $rlcApp->setDateSubmitted(time());
             $rlcApp->setFirstChoice($community->getId());
             $rlcApp->setSecondChoice(null);
             $rlcApp->setThirdChoice(null);
             $rlcApp->setWhySpecificCommunities('Application created administratively.');
             $rlcApp->setStrengthsWeaknesses('');
             $rlcApp->setRLCQuestion0(null);
             $rlcApp->setRLCQuestion1(null);
             $rlcApp->setRLCQuestion2(null);
             $rlcApp->setEntryTerm($term);
             if ($student->getType() == TYPE_CONTINUING) {
                 $rlcApp->setApplicationType(RLC_APP_RETURNING);
             } else {
                 $rlcApp->setApplicationType(RLC_APP_FRESHMEN);
             }
             $rlcApp->save();
         } else {
             // Reset the application's denial flag, see #1026
             $rlcApp->setDenied(0);
             $rlcApp->save();
             // RLC application already exists
             NQ::simple('hms', hms\NotificationView::WARNING, "RLC application already exists for {$student->getName()}({$student->getBannerID()})");
         }
         // Check for RLC membership
         $membership = RlcMembershipFactory::getMembership($student, $term);
         if ($membership !== false) {
             NQ::simple('hms', hms\NotificationView::ERROR, "RLC membership already exists for {$student->getName()}({$student->getBannerID()})");
             continue;
         }
         // Check Student's Eligibility
         $eligibility = HMS_Lottery::determineEligibility($student->getUsername());
         if ($eligibility == false) {
             NQ::simple('hms', hms\NotificationView::ERROR, "{$student->getName()} ({$student->getBannerID()}) is not currently eligible for housing");
             continue;
         }
         // Create RLC Membership
         $membership = new HMS_RLC_Assignment();
         $membership->rlc_id = $community->getId();
         $membership->gender = $student->getGender();
         $membership->assigned_by = UserStatus::getUsername();
         $membership->application_id = $rlcApp->id;
         $membership->state = 'new';
         $membership->save();
     }
     $successCmd = CommandFactory::getCommand('ShowViewByRlc');
     $successCmd->setRlcId($community->getId());
     $successCmd->redirect();
 }
 public function 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();
 }