Example #1
0
 public function show_verify_assignment()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Term.php');
     PHPWS_Core::initModClass('hms', 'HMS_SOAP.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Movein_Time.php');
     $tpl = array();
     $assignment = HMS_Assignment::get_assignment($_SESSION['asu_username'], $_SESSION['application_term']);
     if ($assignment === NULL || $assignment == FALSE) {
         $tpl['NO_ASSIGNMENT'] = "You do not currently have a housing assignment.";
     } else {
         $tpl['ASSIGNMENT'] = $assignment->where_am_i() . '<br />';
         # Determine the student's type and figure out their movein time
         $type = HMS_SOAP::get_student_type($_SESSION['asu_username'], $_SESSION['application_term']);
         if ($type == TYPE_CONTINUING) {
             $movein_time_id = $assignment->get_rt_movein_time_id();
         } elseif ($type == TYPE_TRANFER) {
             $movein_time_id = $assignment->get_t_movein_time_id();
         } else {
             $movein_time_id = $assignment->get_f_movein_time_id();
         }
         if ($movein_time_id == NULL) {
             $tpl['MOVE_IN_TIME'] = 'To be determined<br />';
         } else {
             $movein_times = HMS_Movein_Time::get_movein_times_array($_SESSION['application_term']);
             $tpl['MOVE_IN_TIME'] = $movein_times[$movein_time_id];
         }
     }
     //get the assignees to the room that the bed that the assignment is in
     $assignees = !is_null($assignment) ? $assignment->get_parent()->get_parent()->get_assignees() : NULL;
     $roommates = array();
     if (!is_null($assignees)) {
         foreach ($assignees as $roommate) {
             if ($roommate->asu_username != $_SESSION['asu_username']) {
                 $roommates[] = $roommate->asu_username;
             }
         }
     }
     if (empty($roommates)) {
         $tpl['roommate'][]['ROOMMATE'] = 'You do not have a roommate.';
     } else {
         foreach ($roommates as $roommate) {
             $tpl['roommate'][]['ROOMMATE'] = '' . HMS_SOAP::get_name($roommate) . ' (<a href="mailto:' . $roommate . '@appstate.edu">' . $roommate . '@appstate.edu</a>)';
         }
     }
     $rlc_assignment = HMS_RLC_Assignment::check_for_assignment($_SESSION['asu_username'], $_SESSION['application_term']);
     if ($rlc_assignment == NULL || $rlc_assignment === FALSE) {
         $tpl['RLC'] = "You have not been accepted to an RLC.";
     } else {
         $rlc_list = HMS_Learning_Community::getRlcList();
         $tpl['RLC'] = 'You have been assigned to the ' . $rlc_list[$rlc_assignment['rlc_id']];
     }
     $tpl['MENU_LINK'] = PHPWS_Text::secureLink('Back to Main Menu', 'hms', array('type' => 'student', 'op' => 'show_main_menu'));
     return PHPWS_Template::process($tpl, 'hms', 'student/verify_assignment.tpl');
 }
 public function show()
 {
     //Seriously php?  Can't resolve context without this?  Fail.
     $context = $this->context;
     $template = array();
     $cmd = CommandFactory::getCommand('SubmitRlcApplication');
     $rlc_form2 = new PHPWS_Form();
     $cmd->initForm($rlc_form2);
     // Add hidden fields for fields from page 1
     $rlc_form2->addHidden('first_name', $context->get('first_name'));
     $rlc_form2->addHidden('middle_name', $context->get('middle_name'));
     $rlc_form2->addHidden('last_name', $context->get('last_name'));
     $rlc_form2->addHidden('rlc_first_choice', $context->get('rlc_first_choice'));
     $rlc_form2->addHidden('rlc_second_choice', $context->get('rlc_second_choice'));
     $rlc_form2->addHidden('rlc_third_choice', $context->get('rlc_third_choice'));
     $rlc_form2->addHidden('why_specific_communities', $context->get('why_specific_communities'));
     $rlc_form2->addHidden('strengths_weaknesses', $context->get('strengths_weaknesses'));
     $rlc_form2->addHidden('term', $context->get('term'));
     $rlcIds = array($context->get('rlc_first_choice'), $context->get('rlc_second_choice'), $context->get('rlc_third_choice'));
     for ($i = 0; $i < 3; $i++) {
         # Skip the question lookup if "none" was selected
         if ($rlcIds[$i] == -1) {
             continue;
         }
         $rlc = new HMS_Learning_Community($rlcIds[$i]);
         // If we're missing a question... send them back. We might could throw an exception here.
         $question = $rlc->getFreshmenQuestion();
         if (!isset($question)) {
             NQ::simple('hms', hms\NotificationView::ERROR, "There was an error looking up the community questions.");
             $cmd = CommandFactory::getCommand('ShowRlcApplicationPage1View');
             $cmd->setTerm($context->get('term'));
             $cmd->redirect();
         }
         $rlc_form2->addTextArea("rlc_question_{$i}");
         $rlc_form2->setLabel("rlc_question_{$i}", $rlc->getFreshmenQuestion());
         $rlc_form2->addCssClass("rlc_question_{$i}", 'form-control');
     }
     $rlc_form2->mergeTemplate($template);
     $template = $rlc_form2->getTemplate();
     Layout::addPageTitle("RLC Application");
     javascript('jquery');
     return PHPWS_Template::process($template, 'hms', 'student/rlc_signup_form_page2.tpl');
 }
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Movein_Time.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     $tpl = array();
     $assignment = HMS_Assignment::getAssignment($this->student->getUsername(), $this->term);
     if ($assignment === NULL || $assignment == FALSE) {
         $tpl['NO_ASSIGNMENT'] = "You do not currently have a housing assignment.";
     } else {
         $tpl['ASSIGNMENT'] = $assignment->where_am_i() . '<br />';
         # Determine the student's type and figure out their movein time
         $type = $this->student->getType();
         if ($type == TYPE_CONTINUING) {
             $movein_time_id = $assignment->get_rt_movein_time_id();
         } elseif ($type == TYPE_TRANSFER) {
             $movein_time_id = $assignment->get_t_movein_time_id();
         } else {
             $movein_time_id = $assignment->get_f_movein_time_id();
         }
         if ($movein_time_id == NULL) {
             $tpl['MOVE_IN_TIME'] = 'To be determined<br />';
         } else {
             $movein_times = HMS_Movein_Time::get_movein_times_array($this->term);
             $tpl['MOVE_IN_TIME'] = $movein_times[$movein_time_id];
         }
     }
     //get the assignees to the room that the bed that the assignment is in
     $assignees = !is_null($assignment) ? $assignment->get_parent()->get_parent()->get_assignees() : NULL;
     if (!is_null($assignees)) {
         foreach ($assignees as $roommate) {
             if ($roommate->getUsername() != $this->student->getUsername()) {
                 $assignment = HMS_Assignment::getAssignment($roommate->getUsername(), $this->term);
                 $assignment->loadBed();
                 $label = $assignment->_bed->bedroom_label;
                 $tpl['roommate'][]['ROOMMATE'] = $roommate->getFullName() . ' - ' . $label . ' (' . $roommate->getEmailLink() . ')';
             }
         }
     } else {
         $tpl['roommate'] = 'You do not have a roommate';
     }
     $rlc_assignment = HMS_RLC_Assignment::checkForAssignment($this->student->getUsername(), $this->term);
     if ($rlc_assignment == NULL || $rlc_assignment === FALSE) {
         $tpl['RLC'] = "You have not been accepted to an RLC.";
     } else {
         $rlc_list = HMS_Learning_Community::getRlcList();
         $tpl['RLC'] = 'You have been assigned to the ' . $rlc_list[$rlc_assignment['rlc_id']];
     }
     $tpl['MENU_LINK'] = PHPWS_Text::secureLink('Back to Main Menu', 'hms', array('type' => 'student', 'op' => 'show_main_menu'));
     Layout::addPageTitle("Verify Assignment");
     return PHPWS_Template::process($tpl, 'hms', 'student/verify_assignment.tpl');
 }
Example #4
0
 public function show()
 {
     PHPWS_Core::initCoreClass('Form.php');
     $form = new PHPWS_Form();
     $form->addDropBox('rlc', HMS_Learning_Community::getRlcList());
     $form->setClass('rlc', 'form-control');
     $form->addHidden('module', 'hms');
     $form->addHidden('action', 'ShowSearchByRlc');
     $form->addSubmit('submit', _('Search'));
     $form->setClass('submit', 'btn btn-primary pull-right');
     $tags = $form->getTemplate();
     $tags['TITLE'] = "RLC Search";
     Layout::addPageTitle("RLC Search");
     $final = PHPWS_Template::processTemplate($tags, 'hms', 'admin/search_by_rlc.tpl');
     return $final;
 }
Example #5
0
 /**
  * @see View::show()
  */
 public function show()
 {
     $tags = array();
     $tags['TERM'] = Term::toString(Term::getSelectedTerm());
     $tags['FILTERS'] = $this->getFilters();
     $tags['ASSIGNMENTS_PAGER'] = $this->rlcApplicationPager();
     $exportForm = new PHPWS_Form('export_form');
     $exportCmd = CommandFactory::getCommand('ExportRlcApps');
     $exportCmd->initForm($exportForm);
     $exportForm->addDropBox('rlc_list', HMS_Learning_Community::getRlcList());
     $exportForm->setClass('rlc_list', 'form-control');
     $exportForm->addSubmit('submit', 'Export');
     $exportForm->setClass('submit', 'btn btn-primary');
     $exportForm->mergeTemplate($tags);
     $tags = $exportForm->getTemplate();
     return PHPWS_Template::process($tags, 'hms', 'admin/make_new_rlc_assignments.tpl');
 }
Example #6
0
 public static function sendRlcInviteEmail(Student $student, HMS_Learning_Community $community, $term, $respondByTimestamp)
 {
     $to = $student->getUsername() . TO_DOMAIN;
     $subject = 'Response Needed: Residential Learning Community Invitation';
     $tags = array();
     $tags['NAME'] = $student->getName();
     $tags['COMMUNITY_NAME'] = $community->get_community_name();
     $tags['TERM'] = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term));
     $tags['COMMUNITY_TERMS_CONDITIONS'] = $community->getTermsConditions();
     $tags['RESPOND_BY'] = date("l, F jS, Y", $respondByTimestamp) . ' at ' . date("ga", $respondByTimestamp);
     HMS_Email::send_template_message($to, $subject, 'email/RlcInvite.tpl', $tags);
 }
 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();
 }
 public function getDeniedPagerTags()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     $student = StudentFactory::getStudentByUsername($this->username, $this->term);
     $tags = array();
     $rlc_list = HMS_Learning_Community::getRlcList();
     $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['CLASS'] = $student->getClass();
     $tags['GENDER'] = $student->getGender();
     $tags['DATE_SUBMITTED'] = date('d-M-y', $this->getDateSubmitted());
     $unDenyCmd = CommandFactory::getCommand('UnDenyRlcApplication');
     $unDenyCmd->setApplicationId($this->id);
     $tags['ACTION'] = $unDenyCmd->getLink('Un-Deny');
     return $tags;
 }
Example #9
0
 /**
  * Handles removing RLC assignments.
  * @param Student $student
  */
 private function handleRlcAssignment(Student $student)
 {
     # Check for and delete any learning community assignments
     $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->term);
     if (!is_null($rlcAssignment)) {
         $rlc = new HMS_Learning_Community($rlcAssignment->getRlcId());
         //TODO catch/handle exceptions
         $rlcAssignment->delete();
         $this->actions[$student->getUsername()][] = 'Removed RLC assignment: ' . $rlc->get_community_name();
         HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_WITHDRAWN_RLC_APP_DENIED, UserStatus::getUsername(), 'Withdrawn search');
     }
 }
 /**
  * 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;
 }
Example #11
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;
 }
Example #12
0
 public function show()
 {
     $tpl = new PHPWS_Template('hms');
     if (!$tpl->setFile('admin/reports/hall_overview.tpl')) {
         return 'Template error.';
     }
     $rlcs = HMS_Learning_Community::getRlcList();
     $rlcs_abbr = HMS_Learning_Community::getRLCListAbbr();
     $tpl->setData(array('HALL' => $this->hall->hall_name, 'TERM' => Term::getPrintableSelectedTerm()));
     if ($this->nakedDisplay) {
         $menuCmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu');
         $tpl->setData(array('MAINTENANCE' => $menuCmd->getLink('Main Menu')));
     }
     $class = 'toggle1';
     $this->hall->loadFloors();
     foreach ($this->hall->_floors as $floor) {
         $floor->loadRooms();
         if (!isset($floor->_rooms)) {
             continue;
         }
         if ($floor->rlc_id != NULL) {
             $floor_rlc = $rlcs[$floor->rlc_id];
         } else {
             $floor_rlc = '';
         }
         foreach ($floor->_rooms as $room) {
             $extra_attribs = '';
             if ($room->isOffline()) {
                 $extra_attribs .= 'Offline ';
             }
             if ($room->isReserved()) {
                 $extra_attribs .= 'Reserved ';
             }
             if ($room->isRa()) {
                 $extra_attribs .= 'RA ';
             }
             if ($room->isPrivate()) {
                 $extra_attribs .= 'Private ';
             }
             if ($room->isOverflow()) {
                 $extra_attribs .= 'Overflow ';
             }
             if ($room->isParlor()) {
                 $extra_attribs .= 'Parlor ';
             }
             if ($room->isADA()) {
                 $extra_attribs .= 'ADA';
             }
             if ($room->isHearingImpaired()) {
                 $extra_attribs .= 'Hearing Impaired';
             }
             if ($room->bathEnSuite()) {
                 $extra_attribs .= 'Bath en Suite';
             }
             $room->loadBeds();
             if (empty($room->_beds)) {
                 $tpl->setCurrentBlock('room_repeat');
                 $tpl->setData(array('EXTRA_ATTRIBS' => $extra_attribs, 'ROOM_NUMBER' => $room->getLink('Room')));
                 $tpl->parseCurrentBlock();
                 continue;
             }
             foreach ($room->_beds as $bed) {
                 $bed->loadAssignment();
                 $tpl->setCurrentBlock('bed_repeat');
                 $bed_link = $bed->getLink();
                 if (isset($bed->_curr_assignment)) {
                     $username = $bed->_curr_assignment->asu_username;
                     try {
                         $student = StudentFactory::getStudentByUsername($username, $this->hall->term);
                     } catch (StudentNotFoundException $e) {
                         $student = null;
                         NQ::simple('hms', hms\NotificationView::WARNING, "Could not find data for: {$username}");
                     }
                     $assign_rlc = HMS_RLC_Assignment::checkForAssignment($username, $this->hall->term);
                     //false or index
                     if ($assign_rlc != FALSE) {
                         $rlc_abbr = $rlcs_abbr[$assign_rlc['rlc_id']];
                         //get the abbr for the rlc
                     } else {
                         $rlc_abbr = '';
                     }
                     // Alternating background colors
                     if ($class == 'toggle1') {
                         $class = 'toggle2';
                     } else {
                         $class = 'toggle1';
                     }
                     if (is_null($student)) {
                         $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => 'UNKNOWN', 'USERNAME' => $username, 'BANNER_ID' => '', 'TOGGLE' => $class, 'RLC_ABBR' => $rlc_abbr));
                     } else {
                         $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => $student->getProfileLink(), 'USERNAME' => $student->getUsername(), 'BANNER_ID' => $student->getBannerId(), 'TOGGLE' => $class, 'RLC_ABBR' => $rlc_abbr));
                     }
                 } else {
                     $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => $bed->get_assigned_to_link(), 'VACANT' => ''));
                 }
                 $tpl->parseCurrentBlock();
             }
             $tpl->setCurrentBlock('room_repeat');
             $tpl->setData(array('EXTRA_ATTRIBS' => $extra_attribs, 'ROOM_NUMBER' => $room->getLink('Room')));
             $tpl->parseCurrentBlock();
         }
         $tpl->setCurrentBlock('floor_repeat');
         $tpl->setData(array('FLOOR_NUMBER' => $floor->getLink('Floor'), 'FLOOR_RLC' => $floor_rlc));
         $tpl->parseCurrentBlock();
     }
     if ($this->nakedDisplay) {
         Layout::nakedDisplay($tpl->get(), 'Building overview for ' . $this->hall->hall_name, TRUE);
     }
     Layout::addPageTitle("Hall Overview");
     return $tpl->get();
 }
 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();
 }
 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());
 }
 public function show()
 {
     Layout::addPageTitle("RLC Application");
     javascript('jquery');
     $jsVars = array('ELEMENTS_TO_BIND' => '"#phpws_form_rlc_first_choice","#phpws_form_rlc_second_choice","#phpws_form_rlc_third_choice"', 'ACTION' => 'AjaxGetRLCExtraInfo');
     javascript('modules/hms/formDialog', $jsVars);
     $context = $this->context;
     $template = array();
     $rlc_form = new PHPWS_Form();
     $page2Cmd = CommandFactory::getCommand('ShowRlcApplicationPage2View');
     $page2Cmd->setTerm($context->get('term'));
     $page2Cmd->initForm($rlc_form);
     // 1. Rank Your RLC Choices
     // Get the list of RLCs from the database that this student is allowed to apply for and which are not hidden
     $rlcList = HMS_Learning_Community::getRlcList(false, $this->student->getType());
     // Add an inital element to the list.
     $rlc_choices = array("-1" => "Select") + $rlcList;
     // Make a copy of the RLC choices list, replacing "Select" with "None".
     // To be used with the second and third RLC choices
     $rlc_choices_none = array('-1' => "None") + $rlcList;
     $rlc_form->addDropBox('rlc_first_choice', $rlc_choices);
     $rlc_form->addCssClass('rlc_first_choice', 'form-control');
     $rlc_form->setLabel('rlc_first_choice', 'First Choice: ');
     if (!is_null($context->get('rlc_first_choice'))) {
         $rlc_form->setMatch('rlc_first_choice', $context->get('rlc_first_choice'));
         // Select previous choice
     } else {
         $rlc_form->setMatch('rlc_first_choice', -1);
         // Select the default
     }
     $rlc_form->addDropBox('rlc_second_choice', $rlc_choices_none);
     $rlc_form->addCssClass('rlc_second_choice', 'form-control');
     $rlc_form->setLabel('rlc_second_choice', 'Second Choice: ');
     if (!is_null($context->get('rlc_second_choice'))) {
         $rlc_form->setMatch('rlc_second_choice', $context->get('rlc_second_choice'));
         // Select previous choice
     } else {
         $rlc_form->setMatch('rlc_second_choice', -1);
         // Select the default
     }
     $rlc_form->addDropBox('rlc_third_choice', $rlc_choices_none);
     $rlc_form->addCssClass('rlc_third_choice', 'form-control');
     $rlc_form->setLabel('rlc_third_choice', 'Third Choice: ');
     if (!is_null($context->get('rlc_third_choice'))) {
         $rlc_form->setMatch('rlc_third_choice', $context->get('rlc_third_choice'));
     } else {
         $rlc_form->setMatch('rlc_third_choice', -1);
         // Select the default
     }
     // 2. About Your Choices
     if (!is_null($context->get('why_specific_communities'))) {
         $rlc_form->addTextarea('why_specific_communities', $context->get('why_specific_communities'));
     } else {
         $rlc_form->addTextarea('why_specific_communities');
     }
     $rlc_form->setLabel('why_specific_communities', 'Why are you interested in the specific communities you have chosen?');
     if (!is_null($context->get('strengths_weaknesses'))) {
         $rlc_form->addTextarea('strengths_weaknesses', $context->get('strengths_weaknesses'));
     } else {
         $rlc_form->addTextarea('strengths_weaknesses');
     }
     $rlc_form->setLabel('strengths_weaknesses', 'What are your strengths and in what areas would you like to improve?');
     $rlc_form->mergeTemplate($template);
     $template = $rlc_form->getTemplate();
     return PHPWS_Template::process($template, 'hms', 'student/rlc_signup_form_page1.tpl');
 }
Example #16
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'learning_community_maintenance')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit learning communities.');
     }
     // If we have an id, load the community with that id.. otherwise, create a new community
     if (!is_null($context->get('id'))) {
         $community = new HMS_Learning_Community($context->get('id'));
     } else {
         $community = new HMS_Learning_Community();
     }
     // TODO add appropriate sanity checking...
     /*** General Settings ***/
     $community->set_community_name($context->get('community_name'));
     $community->set_abbreviation($context->get('abbreviation'));
     $capacity = $context->get('capacity');
     if (!isset($capacity) || empty($capacity)) {
         $capacity = 0;
         NQ::simple('hms', hms\NotificationView::WARNING, "The community's capacity was set to 0.");
     }
     $community->set_capacity($capacity);
     /*** RLC-specific move-in times ***/
     // Freshmen
     $fMoveinTime = $context->get('f_movein_time');
     if ($fMoveinTime == 0) {
         $community->setFreshmenMoveinTime(null);
     } else {
         $community->setFreshmenMoveinTime($fMoveinTime);
     }
     // Transfer
     $tMoveinTime = $context->get('t_movein_time');
     if ($tMoveinTime == 0) {
         $community->setTransferMoveinTime(null);
     } else {
         $community->setTransferMoveinTime($tMoveinTime);
     }
     // Continuing
     $cMoveinTime = $context->get('c_movein_time');
     if ($cMoveinTime == 0) {
         $community->setContinuingMoveinTime(null);
     } else {
         $community->setContinuingMoveinTime($cMoveinTime);
     }
     /*** Student Types Allowed to Apply ***/
     $community->hide = is_null($context->get('hide')) ? 0 : $context->get('hide');
     $community->setAllowedStudentTypes($context->get('student_types'));
     $community->setAllowedReapplicationStudentTypes($context->get('reapplication_student_types'));
     if (is_null($context->get('members_reapply'))) {
         $community->setMembersReapply(0);
     } else {
         $community->setMembersReapply(1);
     }
     /*** Application Questions ***/
     $community->setFreshmenQuestion($context->get('freshmen_question'));
     $community->setReturningQuestion($context->get('returning_question'));
     /*** Terms & Conditions ***/
     $community->setTermsConditions($context->get('terms_conditions'));
     // Save it
     $community->save();
     // View command for the RLC editt page
     $viewCommand = CommandFactory::getCommand('ShowAddRlc');
     $viewCommand->setId($community->getId());
     // Show a success message and redirect
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'The RLC was saved successfully.');
     $viewCommand->redirect();
 }