コード例 #1
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     $term = $context->get('term');
     // Application must exist
     $app = HMS_RLC_Application::getApplicationByUsername(UserStatus::getUsername(), $term);
     if (is_null($app)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'No RLC application exists.');
         $context->goBack();
     } else {
         if (!HMS_RLC_Assignment::checkForAssignment(UserStatus::getUsername(), $term)) {
             // Delete the app
             $app->delete();
             // Log it
             PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
             HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_RLC_APPLICATION_DELETED, UserStatus::getUsername());
             // Show a notification and go back
             NQ::simple('hms', hms\NotificationView::SUCCESS, 'RLC application deleted.');
             $context->goBack();
         } else {
             NQ::simple('hms', hms\NotificationView::WARNING, 'You have already been assigned to an RLC.');
             $context->goBack();
         }
     }
 }
コード例 #2
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'approve_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve RLC applications.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     # Foreach rlc assignment made
     # $app_id is the 'id' column in the 'learning_community_applications' table, tells which student we're assigning
     # $rlc_id is the 'id' column in the 'learning_communitites' table, and refers to the RLC selected for the student
     foreach ($_REQUEST['final_rlc'] as $app_id => $rlc_id) {
         if ($rlc_id <= 0) {
             continue;
         }
         $app = HMS_RLC_Application::getApplicationById($app_id);
         $student = StudentFactory::getStudentByUsername($app->username, $app->term);
         # Insert a new assignment in the 'learning_community_assignment' table
         $assign = new HMS_RLC_Assignment();
         $assign->rlc_id = $rlc_id;
         $assign->gender = $student->getGender();
         $assign->assigned_by = UserStatus::getUsername();
         $assign->application_id = $app->id;
         $assign->state = 'new';
         $assign->save();
         # Log the assignment
         PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
         HMS_Activity_Log::log_activity($app->username, ACTIVITY_ASSIGN_TO_RLC, UserStatus::getUsername(), "New Assignment");
     }
     // Show a success message
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully assigned RLC applicant(s).');
     $context->goBack();
 }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: RlcApplication.php プロジェクト: jlbooker/homestead
 public function getMenuBlockView(Student $student)
 {
     // Get an application if one exists
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     $application = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $this->getTerm());
     // Check for an assignment
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     $assignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm());
     PHPWS_Core::initModClass('hms', 'RlcApplicationMenuView.php');
     return new RlcApplicationMenuView($this->term, $student, $this->getStartDate(), $this->getEditDate(), $this->getEndDate(), $application, $assignment);
 }
コード例 #5
0
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     $tpl = array();
     $tpl['TITLE'] = "Denied RLC Applications - " . Term::toString(Term::getSelectedTerm());
     $tpl['DENIED_PAGER'] = HMS_RLC_Application::denied_pager();
     if (isset($success_msg)) {
         $tpl['SUCCESS_MSG'] = $success_msg;
     }
     if (isset($error_msg)) {
         $tpl['ERROR_MSG'] = $error_msg;
     }
     Layout::addPageTitle("Denied RLC Applications");
     return PHPWS_Template::process($tpl, 'hms', 'admin/view_denied_rlc_applications.tpl');
 }
コード例 #6
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'approve_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve/deny RLC applications.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     $app = HMS_RLC_Application::getApplicationById($context->get('applicationId'));
     $app->denied = 1;
     $app->save();
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     HMS_Activity_Log::log_activity($app->username, 28, Current_User::getUsername(), 'Application Denied');
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Application denied.');
     $context->goBack();
 }
コード例 #7
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'RlcApplicationReView.php');
     $application = new HMS_RLC_Application($context->get('appId'));
     if (is_null($application->username)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There is no RLC application available with that id.');
         $context->goBack();
     }
     // This is used both on the admin side and on the student side, so the permission check is a bit more complex
     if (UserStatus::isAdmin() && !Current_User::allow('view_rlc_applications') || UserStatus::isUser() && $application->getUsername() != UserStatus::getUsername()) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to view this RLC application.');
     }
     try {
         $student = StudentFactory::getStudentByUsername($application->username, $application->term);
     } catch (StudentNotFoundException $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Unknown student.');
         $context->goBack();
     }
     $view = new RlcApplicationReView($student, $application);
     $context->setContent($view->show());
 }
コード例 #8
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'approve_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve/deny RLC applications.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     $app = HMS_RLC_Application::getApplicationById($context->get('applicationId'));
     $app->denied = 0;
     $app->save();
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     HMS_Activity_Log::log_activity($app->username, 29, UserStatus::getUsername(), "Application un-denied");
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Application un-denied.');
     $successCmd = CommandFactory::getCommand('ShowDeniedRlcApplicants');
     $successCmd->redirect();
 }
コード例 #9
0
 public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'RlcReapplicationMenuBlockView.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     $application = HousingApplication::getApplicationByUser($student->getUsername(), $this->term);
     if (!$application instanceof LotteryApplication) {
         $application = null;
     }
     $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $this->term);
     if (!$rlcApp instanceof HMS_RLC_Application) {
         $rlcApp = null;
     }
     // Check for an assignment
     $assignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm());
     return new RlcReapplicationMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $application, $rlcApp, $assignment);
 }
コード例 #10
0
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'email_rlc_rejections')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to send RLC rejections.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'Term.php');
     $term = Term::getSelectedTerm();
     $deniedApps = HMS_RLC_Application::getNonNotifiedDeniedApplicantsByTerm($term);
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     $email = new HMS_Email();
     foreach ($deniedApps as $app) {
         $student = StudentFactory::getStudentByUsername($app['username'], $term);
         $email->sendRlcApplicationRejected($student, $term);
         $application = HMS_RLC_Application::getApplicationById($app['id']);
         $application->setDeniedEmailSent(1);
         $application->save();
     }
     NQ::Simple('hms', hms\NotificationView::SUCCESS, 'RLC rejection emails sent.');
     $context->goBack();
 }
コード例 #11
0
 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();
 }
コード例 #12
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Commands for re-directing later
     $formCmd = CommandFactory::getCommand('ShowRlcReapplication');
     $formCmd->setTerm($term);
     // $menuCmd = CommandFactory::getCommand('ShowStudentMenu');
     // Pull in data for local use
     $rlcOpt = $context->get('rlc_opt');
     $rlcChoice1 = $context->get('rlc_choice_1');
     $rlcChoice2 = $context->get('rlc_choice_2');
     $rlcChoice3 = $context->get('rlc_choice_3');
     $why = $context->get('why_this_rlc');
     $contribute = $context->get('contribute_gain');
     // Change any 'none's into null
     if ($rlcChoice2 == 'none') {
         $rlcChoice2 = null;
     }
     if ($rlcChoice3 == 'none') {
         $rlcChoice3 = null;
     }
     # Get the list of RLCs that the student is eligible for
     # Note: hard coded to 'C' because we know they're continuing at this point.
     # This accounts for freshmen addmitted in the spring, who will still have the 'F' type.
     $communities = HMS_Learning_Community::getRlcListReapplication(false, 'C');
     # Look up any existing RLC assignment (for the current term, should be the Spring term)
     $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), Term::getPrevTerm(Term::getCurrentTerm()));
     // Sanity checking on user-supplied data
     // If the student is already in an RLC, and the student is eligible to reapply for that RLC (RLC always takes returners,
     // or the RLC is in the list of communities this student is eligible for), then check to make the user chose something for the re-apply option.
     if (!is_null($rlcAssignment) && (array_key_exists($rlcAssignment->getRlcId(), $communities) || $rlcAssignment->getRlc()->getMembersReapply() == 1) && is_null($rlcOpt)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose whether you would like to continue in your currnet RLC, or apply for a different community.');
         $formCmd->redirect();
     }
     // If the user is 'contining' in his/her current RLC, then figure that out and set it
     if (!is_null($rlcOpt) && $rlcOpt == 'continue') {
         $rlcChoice1 = $rlcAssignment->getRLC()->get_id();
         $rlcChoice2 = NULL;
         $rlcChoice3 = NULL;
     } else {
         // User either can't 'continue' or didn't want to. Check that the user supplied rankings isstead.
         // Make sure a first choice was made
         if ($rlcChoice1 == 'select') {
             NQ::simple('hms', hms\NotificationView::ERROR, 'You must choose a community as your "first choice".');
             $formCmd->redirect();
         }
         if (isset($rlcChoice2) && $rlcChoice1 == $rlcChoice2 || isset($rlcChoice2) && isset($rlcChoice3) && $rlcChoice2 == $rlcChoice3 || isset($rlcChoice3) && $rlcChoice1 == $rlcChoice3) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'You cannot choose the same community twice.');
             $formCmd->redirect();
         }
     }
     // Check the short answer questions
     if (empty($why) || empty($contribute)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please respond to both of the short answer questions.');
         $formCmd->redirect();
     }
     $wordLimit = 500;
     if (str_word_count($why) > $wordLimit) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your answer to question number one is too long. Please limit your response to 500 words or less.');
         $formCmd->redirect();
     }
     $wordLimit = 500;
     if (str_word_count($contribute) > $wordLimit) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your answer to question number two is too long. Please limit your response to 500 words or less.');
         $formCmd->redirect();
     }
     $app = new HMS_RLC_Application();
     $app->setUsername($student->getUsername());
     $app->setFirstChoice($rlcChoice1);
     $app->setSecondChoice($rlcChoice2);
     $app->setThirdChoice($rlcChoice3);
     $app->setWhySpecificCommunities($why);
     $app->setStrengthsWeaknesses($contribute);
     $_SESSION['RLC_REAPP'] = $app;
     // Redirect to the page 2 view command
     $page2cmd = CommandFactory::getCommand('ShowRlcReapplicationPageTwo');
     $page2cmd->setTerm($term);
     $page2cmd->redirect();
 }
コード例 #13
0
 public function getAdminPagerTags()
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'Term.php');
     $student = StudentFactory::getStudentByUsername($this->username, Term::getCurrentTerm());
     $rlc_list = HMS_Learning_Community::getRlcList();
     $tags = array();
     $tags['NAME'] = $student->getProfileLink();
     $rlcCmd = CommandFactory::getCommand('ShowRlcApplicationReView');
     $rlcCmd->setAppId($this->getId());
     $tags['1ST_CHOICE'] = $rlcCmd->getLink($rlc_list[$this->getFirstChoice()], '_blank');
     if (isset($rlc_list[$this->getSecondChoice()])) {
         $tags['2ND_CHOICE'] = $rlc_list[$this->getSecondChoice()];
     }
     if (isset($rlc_list[$this->getThirdChoice()])) {
         $tags['3RD_CHOICE'] = $rlc_list[$this->getThirdChoice()];
     }
     $tags['FINAL_RLC'] = HMS_RLC_Application::generateRLCDropDown($rlc_list, $this->getID());
     $tags['CLASS'] = $student->getClass();
     //        $tags['SPECIAL_POP']    = ;
     //        $tags['MAJOR']          = ;
     //        $tags['HS_GPA']         = ;
     $tags['GENDER'] = $student->getPrintableGender();
     $tags['DATE_SUBMITTED'] = date('d-M-y', $this->getDateSubmitted());
     $denyCmd = CommandFactory::getCommand('DenyRlcApplication');
     $denyCmd->setApplicationId($this->getID());
     $tags['DENY'] = $denyCmd->getLink('Deny');
     return $tags;
 }
コード例 #14
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');
 }
コード例 #15
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcReapplicationView.php');
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     $errorCmd = CommandFactory::getCommand('ShowStudentMenu');
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Check deadlines
     PHPWS_Core::initModClass('hms', 'ApplicationFeature.php');
     $feature = ApplicationFeature::getInstanceByNameAndTerm('RlcReapplication', $term);
     if (is_null($feature) || !$feature->isEnabled()) {
         NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, RLC re-applications are not avaialable for this term.");
         $errorCmd->redirect();
     }
     if ($feature->getStartDate() > time()) {
         NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, it is too soon to submit a RLC re-application.");
         $errorCmd->redirect();
     } else {
         if ($feature->getEndDate() < time()) {
             NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, the RLC re-application deadline has already passed. Please contact University Housing if you are interested in applying for a RLC.");
             $errorCmd->redirect();
         }
     }
     // Double check the the student is eligible
     $housingApp = HousingApplication::getApplicationByUser($student->getUsername(), $term);
     if (!$housingApp instanceof LotteryApplication) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You are not eligible to re-apply for a Residential Learning Community.');
         $errorCmd->redirect();
     }
     // Make sure that the student has not already applied for this term
     $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $term);
     if (!is_null($rlcApp)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You have already re-applied for a Residential Learning Community for this term.');
         $errorCmd->redirect();
     }
     // Look up any existing RLC assignment (for the fall term; current term should be the Spring term, so the previous term should be the Fall)
     $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), Term::getPrevTerm(Term::getCurrentTerm()));
     // Get the list of RLCs that the student is eligible for
     // Note: hard coded to 'C' because we know they're continuing at this point.
     // This accounts for freshmen addmitted in the spring, who will still have the 'F' type.
     $communities = HMS_Learning_Community::getRlcListReapplication(false, 'C');
     // If the student has an existing assignment, and that community always allows returning students, then make sure the community is in the list (if it's not already)
     if (isset($rlcAssignment)) {
         // Load the RLC
         $rlc = $rlcAssignment->getRlc();
         // If members can always reapply, make sure community id exists as an array index
         if ($rlc->getMembersReapply() == 1 && !isset($communities[$rlc->get_id()])) {
             $communities[$rlc->get_id()] = $rlc->get_community_name();
         }
     }
     session_write_close();
     session_start();
     if (isset($_SESSION['RLC_REAPP'])) {
         $reApp = $_SESSION['RLC_REAPP'];
     } else {
         $reApp = null;
     }
     $view = new RlcReapplicationView($student, $term, $rlcAssignment, $communities, $reApp);
     $context->setContent($view->show());
 }
コード例 #16
0
 public function show()
 {
     PHPWS_Core::initCoreClass('Form.php');
     $form = new PHPWS_Form();
     $submitCmd = CommandFactory::getCommand('HousingApplicationFormSubmit');
     $submitCmd->setTerm($this->term);
     $submitCmd->initForm($form);
     $tpl = array();
     /****************
      * Display Info *
      ****************/
     $tpl['STUDENT_NAME'] = $this->student->getFullName();
     $tpl['GENDER'] = $this->student->getPrintableGender();
     $tpl['ENTRY_TERM'] = Term::toString($this->student->getApplicationTerm());
     $tpl['CLASSIFICATION_FOR_TERM_LBL'] = HMS_Util::formatClass($this->student->getClass());
     $tpl['STUDENT_STATUS_LBL'] = HMS_Util::formatType($this->student->getType());
     $tpl['TERM'] = Term::toString($this->term);
     /**************
      * Cell Phone *
      **************/
     $form->addText('number');
     $form->setSize('number', 10);
     $form->setMaxSize('number', 10);
     $form->addCssClass('number', 'form-control');
     if (!is_null($this->existingApplication)) {
         $form->setValue('number', substr($this->existingApplication->getCellPhone(), 0));
     }
     $form->addCheck('do_not_call', 1);
     if (!is_null($this->existingApplication) && is_null($this->existingApplication->getCellPhone())) {
         $form->setMatch('do_not_call', 1);
     }
     // This is just getting worse and worse.
     // TODO: this, correctly.
     $sem = Term::getTermSem($this->term);
     if ($sem == TERM_SPRING || $sem == TERM_FALL) {
         /*************
          * Lifestyle *
          *************/
         // TODO: get rid of the magic numbers!!!
         $form->addDropBox('lifestyle_option', array('1' => _('Single Gender Building'), '2' => _('Co-Ed Building')));
         if (!is_null($this->existingApplication)) {
             $form->setMatch('lifestyle_option', $this->existingApplication->getLifestyleOption());
         } else {
             $form->setMatch('lifestyle_option', '1');
         }
         $form->addCssClass('lifestyle_option', 'form-control');
         /************
          * Bed time *
          ************/
         // TODO: magic numbers
         $form->addDropBox('preferred_bedtime', array('1' => _('Early'), '2' => _('Late')));
         $form->setClass('preferred_bedtime', 'form-control');
         if (!is_null($this->existingApplication)) {
             $form->setMatch('preferred_bedtime', $this->existingApplication->getPreferredBedtime());
         } else {
             $form->setMatch('preferred_bedtime', '1');
         }
         /******************
          * Room condition *
          ******************/
         //TODO: magic numbers
         $form->addDropBox('room_condition', array('1' => _('Neat'), '2' => _('Cluttered')));
         if (!is_null($this->existingApplication)) {
             $form->setMatch('room_condition', $this->existingApplication->getRoomCondition());
         } else {
             $form->setMatch('room_condition', '1');
         }
         $form->addCssClass('room_condition', 'form-control');
     } else {
         if ($sem == TERM_SUMMER1 || $sem == TERM_SUMMER2) {
             /* Private room option for Summer terms */
             $form->addDropBox('room_type', array(ROOM_TYPE_DOUBLE => 'Two person', ROOM_TYPE_PRIVATE => 'Private (if available)'));
             $form->setClass('room_type', 'form-control');
             if (!is_null($this->existingApplication)) {
                 $form->setMatch('room_type', $this->existingApplication->getRoomType());
             } else {
                 $form->setMatch('room_type', '0');
             }
         }
     }
     /*********************
      * Smoking Preference *
      *********************/
     $form->addDropBox('smoking_preference', array('1' => _('No'), '2' => _('Yes')));
     if (!is_null($this->existingApplication)) {
         $form->setMatch('smoking_preference', $this->existingApplication->getSmokingPreference());
     } else {
         $form->setMatch('smoking_preference', '1');
     }
     $form->addCssClass('smoking_preference', 'form-control');
     /***************
      * Meal Option *
      ***************/
     if ($sem == TERM_FALL || $sem == TERM_SPRING) {
         if ($this->student->getType() == TYPE_FRESHMEN) {
             $mealOptions = array(BANNER_MEAL_STD => 'Standard', BANNER_MEAL_HIGH => 'High', BANNER_MEAL_SUPER => 'Super');
         } else {
             $mealOptions = array(BANNER_MEAL_LOW => _('Low'), BANNER_MEAL_STD => _('Standard'), BANNER_MEAL_HIGH => _('High'), BANNER_MEAL_SUPER => _('Super'));
         }
     } else {
         if ($sem == TERM_SUMMER1 || $sem == TERM_SUMMER2) {
             $mealOptions = array(BANNER_MEAL_5WEEK => 'Summer 5-Week Plan');
         }
     }
     $form->addDropBox('meal_option', $mealOptions);
     $form->setClass('meal_option', 'form-control');
     $form->setMatch('meal_option', BANNER_MEAL_STD);
     $form->addCssClass('meal_option', 'form-control');
     if (!is_null($this->existingApplication)) {
         $form->setMatch('meal_option', $this->existingApplication->getMealPlan());
     } else {
         $form->setMatch('meal_option', BANNER_MEAL_STD);
     }
     /*********************
      * Emergency Contact *
      *********************/
     $form->addText('emergency_contact_name');
     $form->addCssClass('emergency_contact_name', 'form-control');
     $form->addText('emergency_contact_relationship');
     $form->addCssClass('emergency_contact_relationship', 'form-control');
     $form->addText('emergency_contact_phone');
     $form->addCssClass('emergency_contact_phone', 'form-control');
     $form->addText('emergency_contact_email');
     $form->addCssClass('emergency_contact_email', 'form-control');
     $form->addTextArea('emergency_medical_condition');
     $form->addCssClass('emergency_medical_condition', 'form-control');
     $form->setRows('emergency_medical_condition', 4);
     if (!is_null($this->existingApplication)) {
         $form->setValue('emergency_contact_name', $this->existingApplication->getEmergencyContactName());
         $form->setValue('emergency_contact_relationship', $this->existingApplication->getEmergencyContactRelationship());
         $form->setValue('emergency_contact_phone', $this->existingApplication->getEmergencyContactPhone());
         $form->setValue('emergency_contact_email', $this->existingApplication->getEmergencyContactEmail());
         $form->setValue('emergency_medical_condition', $this->existingApplication->getEmergencyMedicalCondition());
     }
     /**
      * Missing Person
      */
     $form->addText('missing_person_name');
     $form->addCssClass('missing_person_name', 'form-control');
     $form->addText('missing_person_relationship');
     $form->addCssClass('missing_person_relationship', 'form-control');
     $form->addText('missing_person_phone');
     $form->addCssClass('missing_person_phone', 'form-control');
     $form->addText('missing_person_email');
     $form->addCssClass('missing_person_email', 'form-control');
     if (!is_null($this->existingApplication)) {
         $form->setValue('missing_person_name', $this->existingApplication->getMissingPersonName());
         $form->setValue('missing_person_relationship', $this->existingApplication->getMissingPersonRelationship());
         $form->setValue('missing_person_phone', $this->existingApplication->getMissingPersonPhone());
         $form->setValue('missing_person_email', $this->existingApplication->getMissingPersonEmail());
     }
     /**
      * Special needs
      */
     $tpl['SPECIAL_NEEDS_TEXT'] = '';
     // setting this template variable to anything causes the special needs text to be displayed
     $form->addCheck('special_need', array('special_need'));
     $form->setLabel('special_need', array('Yes, I require special needs housing.'));
     if (isset($this->existingApplication)) {
         if (!is_null($this->existingApplication->physical_disability) && $this->existingApplication->physical_disability != "0" || !is_null($this->existingApplication->psych_disability) && $this->existingApplication->psych_disability != "0" || !is_null($this->existingApplication->medical_need) && $this->existingApplication->medical_need != "0" || !is_null($this->existingApplication->gender_need) && $this->existingApplication->gender_need != "0") {
             $form->setMatch('special_need', 'special_need');
         }
     }
     if (isset($_REQUEST['special_needs'])) {
         $form->addHidden('special_needs', $_REQUEST['special_needs']);
     }
     /*******
      * RLC *
      *******/
     PHPWS_Core::initModClass('hms', 'applicationFeature/RlcApplication.php');
     $rlcReg = new RLCApplicationRegistration();
     if (HMS_RLC_Application::checkForApplication($this->student->getUsername(), $this->term) == TRUE) {
         // Student has an RLC application on file already
         $tpl['RLC_SUBMITTED'] = '';
         $form->addHidden('rlc_interest', 0);
     } else {
         if (ApplicationFeature::isEnabledForStudent($rlcReg, $this->term, $this->student)) {
             // Feature is enabled, but student hasn't submitted one yet
             $form->addRadio('rlc_interest', array(0, 1));
             $form->setLabel('rlc_interest', array(_("No"), _("Yes")));
             if (!is_null($this->existingApplication) && !is_null($this->existingApplication->getRLCInterest())) {
                 $form->setMatch('rlc_interest', 'rlc_interest');
             } else {
                 $form->setMatch('rlc_interest', '0');
             }
         } else {
             // Feature is not enabled
             $form->addHidden('rlc_interest', 0);
         }
     }
     $tpl['CONTINUE_BTN'] = '';
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     Layout::addPageTitle("Housing Application Form");
     return PHPWS_Template::process($tpl, 'hms', 'student/student_application.tpl');
 }
コード例 #17
0
 /**
  * TODO: Deprecate this and/or move to RlcMembershipFactory
  * @see RlcMembershipFactory
  *
  * @param unknown $username
  * @param unknown $term
  * @throws DatabaseException
  * @return NULL|HMS_RLC_Assignment
  */
 public static function getAssignmentByUsername($username, $term)
 {
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     $app = HMS_RLC_Application::getApplicationByUsername($username, $term);
     if (is_null($app)) {
         return null;
     }
     $assignment = new HMS_RLC_Assignment();
     $db = new PHPWS_DB('hms_learning_community_assignment');
     $db->addWhere('application_id', $app->id);
     $result = $db->loadObject($assignment);
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     if (is_null($assignment->id)) {
         return null;
     }
     return $assignment;
 }
コード例 #18
0
ファイル: HMS_Roommate.php プロジェクト: jlbooker/homestead
 /**
  * Depricated per ticket #530
  * @deprecated
  */
 public function check_rlc_applications()
 {
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     $result = HMS_RLC_Application::checkForApplication($this->requestor, $this->term, false);
     $resultb = HMS_RLC_Application::checkForApplication($this->requestee, $this->term, false);
     if ($result === false && $resultb === false) {
         return true;
     }
     if ($result === false || $resultb === false) {
         return false;
     }
     // Check to see if any of a's choices match any of b's choices
     if ($result['rlc_first_choice_id'] == $resultb['rlc_first_choice_id'] || $result['rlc_first_choice_id'] == $resultb['rlc_second_choice_id'] || $result['rlc_first_choice_id'] == $resultb['rlc_third_choice_id'] || $result['rlc_second_choice_id'] == $resultb['rlc_first_choice_id'] || $result['rlc_second_choice_id'] == $resultb['rlc_second_choice_id'] || $result['rlc_second_choice_id'] == $resultb['rlc_third_choice_id'] || $result['rlc_third_choice_id'] == $resultb['rlc_first_choice_id'] || $result['rlc_third_choice_id'] == $resultb['rlc_second_choice_id'] || $result['rlc_third_choice_id'] == $resultb['rrlc_third_choice_id']) {
         return true;
     }
     return false;
 }
コード例 #19
0
 public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm());
     $errorCmd = CommandFactory::getCommand('ShowRlcApplicationView');
     $errorCmd->setTerm($term);
     $choice1 = new HMS_Learning_Community($context->get('rlc_first_choice'));
     $choice2 = new HMS_Learning_Community($context->get('rlc_second_choice'));
     $choice3 = new HMS_Learning_Community($context->get('rlc_third_choice'));
     if (!$choice1->allowStudentType($student->getType()) || $choice2->id != -1 && !$choice2->allowStudentType($student->getType()) || $choice3->id != -1 && !$choice3->allowStudentType($student->getType())) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, you cannot apply for the selected RLC. Please contact University Housing if you believe this to be in error.');
         $errorCmd->redirect();
     }
     // Check the lengths of the responses to the short answer questions
     $question0 = $context->get('rlc_question_0');
     $question1 = $context->get('rlc_question_1');
     $question2 = $context->get('rlc_question_2');
     $whySpecific = $context->get('why_specific_communities');
     $strengthsWeaknesses = $context->get('strengths_weaknesses');
     if (str_word_count($whySpecific) > HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your respose to the question is too long. Please limit your response to ' . HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT . ' words.');
         $errorCmd->redirect();
     }
     if (str_word_count($strengthsWeaknesses) > HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your respose to the question is too long. Please limit your response to ' . HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT . ' words.');
         $errorCmd->redirect();
     }
     if (str_word_count($question0) > HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your respose to the first question is too long. Please limit your response to ' . HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT . ' words.');
         $errorCmd->redirect();
     }
     if (str_word_count($question1) > HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your respose to the second question is too long. Please limit your response to ' . HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT . ' words.');
         $errorCmd->redirect();
     }
     if (str_word_count($question2) > HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your respose to the third question is too long. Please limit your response to ' . HMS_RLC_Application::RLC_RESPONSE_WORD_LIMIT . ' words.');
         $errorCmd->redirect();
     }
     // Check for an existing application and delete it
     $oldApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $term);
     if (isset($oldApp) && $oldApp->id != NULL) {
         //TODO check if the student has already been assigned to an RLC via the old application
         // Delete the old application to make way for this one
         try {
             $oldApp->delete();
         } catch (Exception $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, an error occured while attempting to replace your existing Residential Learning Community Application.  If this problem persists please contact University Housing.');
             $errorCmd->redirect();
         }
     }
     // Setup the new application
     $application = new HMS_RLC_Application();
     $application->setUsername($student->getUsername());
     $application->setDateSubmitted(time());
     $application->setFirstChoice($context->get('rlc_first_choice'));
     $application->setSecondChoice($choice2->id > 0 ? $choice2->id : NULL);
     $application->setThirdChoice($choice3->id > 0 ? $choice3->id : NULL);
     $application->setWhySpecificCommunities($context->get('why_specific_communities'));
     $application->setStrengthsWeaknesses($context->get('strengths_weaknesses'));
     $application->setRLCQuestion0($context->get('rlc_question_0'));
     $application->setRLCQuestion1(is_null($context->get('rlc_question_1')) ? '' : $context->get('rlc_question_1'));
     $application->setRLCQuestion2(is_null($context->get('rlc_question_2')) ? '' : $context->get('rlc_question_2'));
     $application->setEntryTerm($context->get('term'));
     $application->setApplicationType(RLC_APP_FRESHMEN);
     try {
         $application->save();
     } catch (Exception $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, an error occured while attempting to submit your application.  If this problem persists please contact University Housing.');
         $errorCmd->redirect();
     }
     # Log that this happened
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_SUBMITTED_RLC_APPLICATION, $student->getUsername());
     # Send the notification email
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_rlc_application_confirmation($student);
     # Show a success message and redirect
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Your Residential Learning Community (RLC) application has been successfully submitted. You should receive a confirmation email (sent to your Appalachian State email account) soon. Notification of your acceptance into an RLC will also be sent to your Appalachian State email account.  Please continue to check your ASU email account regularly.  For more information on the RLC acceptance timeline or frequently asked questions, please visit <a href="http://housing.appstate.edu/rlc" target="_blank">housing.appstate.edu/rlc</a>.');
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
コード例 #20
0
 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();
     }
 }
コード例 #21
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');
 }
コード例 #22
0
 /**
  * Get form for approving application for specific community.
  */
 private function getApprovalForm()
 {
     $approveForm = new PHPWS_Form('approve_form');
     $approveForm->addSubmit('approve', 'Approve');
     $approveForm->addCssClass('approve', 'btn btn-md btn-success');
     $approveCmd = CommandFactory::getCommand('AssignRlcApplicants');
     $tpl = array();
     $tpl['RLC_LIST'] = HMS_RLC_Application::generateRLCDropDown(HMS_Learning_Community::getRlcList(), $this->application->id);
     $approveForm->mergeTemplate($tpl);
     $approveCmd->initForm($approveForm);
     return $approveForm;
 }
コード例 #23
0
 /**
  * Handles removing RLC applications.
  * @param Student $student
  */
 private function handleRlcApplication(Student $student)
 {
     // Mark any RLC applications as denied
     $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $this->term);
     if (!is_null($rlcApp)) {
         // TODO catch/handle exceptions
         $rlcApp->delete();
         $this->actions[$student->getUsername()][] = 'Marked RLC application as denied.';
         HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_WITHDRAWN_RLC_APP_DENIED, UserStatus::getUsername(), 'Withdrawn search');
     }
 }
コード例 #24
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     session_write_close();
     session_start();
     $menuCmd = CommandFactory::getCommand('ShowStudentMenu');
     if (!isset($_SESSION['RLC_REAPP'])) {
         $menuCmd->redirect();
     }
     $reApp = $_SESSION['RLC_REAPP'];
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $errorCmd = CommandFactory::getCommand('ShowRlcReapplicationPageTwo');
     $errorCmd->setTerm($term);
     // Double check the the student is eligible
     $housingApp = HousingApplication::getApplicationByUser($student->getUsername(), $term);
     if (!$housingApp instanceof LotteryApplication) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You are not eligible to re-apply for a Learning Community.');
         $menuCmd->redirect();
     }
     // Make sure the user doesn't already have an application on file for this term
     $app = HMS_RLC_Application::checkForApplication($student->getUsername(), $term);
     if ($app !== FALSE) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'You have already re-applied for a Learning Community for that term.');
         $menuCmd->redirect();
     }
     # Look up any existing RLC assignment (for the current term, should be the Spring term)
     //$rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), Term::getPrevTerm(Term::getCurrentTerm()));
     $question0 = $context->get('rlc_question_0');
     $question1 = $context->get('rlc_question_1');
     $question2 = $context->get('rlc_question_2');
     $reApp->rlc_question_0 = $question0;
     $reApp->rlc_question_1 = $question1;
     $reApp->rlc_question_2 = $question2;
     $_SESSION['RLC_REAPP'] = $reApp;
     //$rlcChoice0 = $reApp->rlc_first_choice_id;
     $rlcChoice1 = $reApp->rlc_second_choice_id;
     $rlcChoice2 = $reApp->rlc_third_choice_id;
     if (isset($rlcChoice1) && (!isset($question1) || empty($question1))) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please respond to all of the short answer questions.');
         $errorCmd->redirect();
     }
     if (isset($rlcChoice2) && (!isset($question2) || empty($question2))) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please respond to all of the short answer questions.');
         $errorCmd->redirect();
     }
     // Check response lengths
     $wordLimit = 500;
     if (str_word_count($question0) > $wordLimit) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your answer to question number one is too long. Please limit your response to 500 words or less.');
         $errorCmd->redirect();
     }
     if (isset($rlcChoice2) && str_word_count($question1) > $wordLimit) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your answer to question number two is too long. Please limit your response to 500 words or less.');
         $errorCmd->redirect();
     }
     if (isset($rlcChoice3) && str_word_count($question2) > $wordLimit) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Your answer to question number three is too long. Please limit your response to 500 words or less.');
         $errorCmd->redirect();
     }
     $reApp->setDateSubmitted(time());
     $reApp->setRLCQuestion0($question0);
     $reApp->setRLCQuestion1($question1);
     $reApp->setRLCQuestion2($question2);
     $reApp->setTerm($term);
     $reApp->setApplicationType(RLC_APP_RETURNING);
     $reApp->setDeniedEmailSent(0);
     $reApp->save();
     unset($_SESSION['RLC_REAPP']);
     // Redirect back to the main menu
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Your Residential Learning Community Re-application was saved successfully.');
     $menuCmd->redirect();
 }