public function __construct($sendMagicWinners, $sendReminders, array $inviteCounts) { // Gender and classes $this->genders = array(MALE, FEMALE); $this->classes = array(CLASS_SENIOR, CLASS_JUNIOR, CLASS_SOPHOMORE); // Send magic winners? $this->sendMagicWinners = $sendMagicWinners; // Send reminders? $this->sendReminders = $sendReminders; // Invite counts to be sent $this->inviteCounts = $inviteCounts; // One-time date/time calculations, setup for later on $this->term = PHPWS_Settings::get('hms', 'lottery_term'); $this->year = Term::getTermYear($this->term); $this->academicYear = Term::toString($this->term) . ' - ' . Term::toString(Term::getNextTerm($this->term)); $this->now = time(); $this->expireTime = $this->now + INVITE_TTL_HRS * 3600; // Hard Cap $this->hardCap = LotteryProcess::getHardCap(); // Soft caps $this->jrSoftCap = LotteryProcess::getJrSoftCap(); $this->srSoftCap = LotteryProcess::getSrSoftCap(); // Invites Sent by this process so far this run $this->numInvitesSent['TOTAL'] = 0; foreach ($this->classes as $c) { foreach ($this->genders as $g) { $this->numInvitesSent[$c][$g] = 0; } } $this->output = array(); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::toString($this->term); $tpl['NEXT_TERM'] = Term::toString(Term::getNextTerm($this->term)); $form = new PHPWS_Form('waitinglist-signup'); $submitCmd = CommandFactory::getCommand('WaitingListSignup'); $submitCmd->initForm($form); $form->addSubmit('Sign up'); $form->addHidden('term', $this->term); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'student/waitinglistSignup.tpl'); }
public function show() { $tpl = array(); if (Term::getTermSem($this->term) == TERM_FALL) { // If it's fall, then it's really the fall & spring terms $tpl['TERM'] = Term::toString($this->term) . ' - ' . Term::toString(Term::getNextTerm($this->term)); } else { $tpl['TERM'] = Term::toString($this->term); } $contactFormLink = CommandFactory::getCommand('ShowContactForm')->getLink('contact University Housing'); // In case there are no features enabled for this term $tpl['BLOCKS'][] = array('BLOCK' => 'Your application has been cancelled for this term. If this is an error please ' . $contactFormLink . '.'); return PHPWS_Template::process($tpl, 'hms', 'student/studentMenuTermBlock.tpl'); }
public function show() { $tpl = array(); $tpl['ENTRY_TERM'] = Term::toString($this->student->getApplicationTerm()); $tpl['REQUIRED_TERMS'] = array(); $appsOnFile = HousingApplication::getAllApplicationsForStudent($this->student); # Make a list of the terms the student has completed $termsOnFile = array(); if (isset($appsOnFile) && !is_null($appsOnFile)) { foreach ($appsOnFile as $term => $app) { $termsOnFile[] = $term; } } foreach ($this->requiredTerms as $t) { if ($t['required'] == 0) { continue; } $completed = ''; if (in_array($t['term'], $termsOnFile)) { $completed = ' <span style="color: #0000AA">(Completed)</span>'; } // If the application is cancelled, overwrite the "complete" text with "cancelled" if (isset($appsOnFile[$t['term']]) && $appsOnFile[$t['term']]->isCancelled()) { $completed = ' <span style="color: #F00">(Cancelled)</span>'; } if (Term::getTermSem($t['term']) == TERM_FALL) { $tpl['REQUIRED_TERMS'][] = array('REQ_TERM' => Term::toString($t['term']) . ' - ' . Term::toString(Term::getNextTerm($t['term'])), 'COMPLETED' => $completed); } else { $tpl['REQUIRED_TERMS'][] = array('REQ_TERM' => Term::toString($t['term']), 'COMPLETED' => $completed); } } $contactCmd = CommandFactory::getCommand('ShowContactForm'); $tpl['CONTACT_LINK'] = $contactCmd->getLink('contact us'); # Setup the form for the 'continue' button. $form = new PHPWS_Form(); $this->submitCmd->initForm($form); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); $studentType = $this->student->getType(); Layout::addPageTitle("Welcome"); if (count($appsOnFile) > 0) { // User is now past step one. No longer just welcoming, we are now welcoming back. return PHPWS_Template::process($tpl, 'hms', 'student/welcome_back_screen.tpl'); } if ($studentType == TYPE_FRESHMEN || $studentType == TYPE_NONDEGREE || $this->student->isInternational()) { return PHPWS_Template::process($tpl, 'hms', 'student/welcome_screen_freshmen.tpl'); } else { return PHPWS_Template::process($tpl, 'hms', 'student/welcome_screen_transfer.tpl'); } }
public function show() { // Get the enabled features $features = ApplicationFeature::getEnabledFeaturesForStudent($this->student, $this->term); $tpl = array(); if (Term::getTermSem($this->term) == TERM_FALL) { // If it's fall, then it's really the fall & spring terms $tpl['TERM'] = Term::toString($this->term) . ' - ' . Term::toString(Term::getNextTerm($this->term)); } else { $tpl['TERM'] = Term::toString($this->term); } // In case there are no features enabled for this term if (empty($features)) { $tpl['BLOCKS'][] = array('BLOCK' => 'There are no options currently available to you for this term.'); } foreach ($features as $feat) { $tpl['BLOCKS'][] = array('BLOCK' => $feat->getMenuBlockView($this->student)->show()); } return PHPWS_Template::process($tpl, 'hms', 'student/studentMenuTermBlock.tpl'); }
public function show() { $tpl = array(); $termList = array(); // Current term $currTerm = Term::getCurrentTerm(); $termList[] = $currTerm; // Always add the current term // Find the next two summer terms (could be next year if Fall // is the current term, could be this year if Spring is current term) $summerTerm1 = $currTerm; while (Term::getTermSem($summerTerm1) != TERM_SUMMER1) { $summerTerm1 = Term::getNextTerm($summerTerm1); } $summerTerm2 = Term::getNextTerm($summerTerm1); $currSem = Term::getTermSem($currTerm); if ($currSem == TERM_SUMMER1) { // If the current term is Summer 1, then we've already added it above, // so just add summer 2 $termList[] = Term::getNextTerm($currTerm); } else { if ($currSem != TERM_SUMMER2) { // Add both of the next summer terms then $termList[] = $summerTerm1; $termList[] = $summerTerm2; } } // Re-application term if ($this->lotteryTerm > $currTerm) { // If the lottery term is in the future $termList[] = $this->lotteryTerm; } foreach ($termList as $t) { $termBlock = new StudentMenuTermBlock($this->student, $t); $tpl['TERMBLOCK'][] = array('TERMBLOCK_CONTENT' => $termBlock->show()); } Layout::addPageTitle("Main Menu"); return PHPWS_Template::process($tpl, 'hms', 'student/returningMenu.tpl'); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::toString($this->term) . ' - ' . Term::toString(Term::getNextTerm($this->term)); $halls = ResidenceHallFactory::getHallsForTerm($this->term); // Check for an RLC Assignment, and that it's in the correct state if ($this->rlcAssignment != null && $this->rlcAssignment->getStateName() == 'selfselect-invite') { $rlcId = $this->rlcAssignment->getRlc()->getId(); } else { $rlcId = null; } // A watch variable, set to true when we find at least one hall that // still has an available bed $somethingsAvailable = false; foreach ($halls as $hall) { $row = array(); $row['HALL_NAME'] = $hall->hall_name; $row['ROW_TEXT_COLOR'] = 'black'; # Make sure we have a room of the specified gender available in the hall (or a co-ed room) if ($hall->count_avail_lottery_rooms($this->student->getGender(), $rlcId) <= 0) { $row['ROW_TEXT_COLOR'] = ' class="text-muted"'; $tpl['hall_list'][] = $row; continue; } else { $somethingsAvailable = true; } $chooseCmd = CommandFactory::getCommand('LotteryChooseHall'); $chooseCmd->setHallId($hall->id); $row['HALL_NAME'] = $chooseCmd->getLink($hall->hall_name); $tpl['hall_list'][] = $row; } if (!$somethingsAvailable) { unset($tpl['hall_list']); $tpl['NOTHING_LEFT'] = ''; } Layout::addPageTitle("Choose Hall"); return PHPWS_Template::process($tpl, 'hms', 'student/lottery_choose_hall.tpl'); }
public function show() { $tpl = array(); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); $tpl['STATUS'] = ""; $hardCapReached = LotteryProcess::hardCapReached($this->term); if (!is_null($this->assignment)) { // Student has already been assigned. $tpl['ICON'] = FEATURE_COMPLETED_ICON; //$tpl['ASSIGNED'] = $this->assignment->where_am_i(); $tpl['ASSIGNED'] = ''; } else { if ($hardCapReached) { // Hard cap has been reached $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['HARD_CAP'] = ""; // dummy tag } else { if (!is_null($this->application) && $this->application->isWinner()) { // Student has won, let them choose their room $tpl['ICON'] = FEATURE_OPEN_ICON; $chooseRoomCmd = CommandFactory::getCommand('LotteryShowChooseHall'); $tpl['SELECT_LINK'] = $chooseRoomCmd->getLink('Click here to select your room'); } else { if (!is_null($this->application)) { // Student has already re-applied $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['ALREADY_APPLIED'] = ""; // dummy tag, text is in template } else { if (time() < $this->startDate) { // Too early $tpl['ICON'] = FEATURE_NOTYET_ICON; $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate); } else { if (time() > $this->endDate) { // Too late $tpl['ICON'] = FEATURE_LOCKED_ICON; // fade out header $tpl['STATUS'] = "locked"; $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate); } else { if (HMS_Lottery::determineEligibility(UserStatus::getUsername())) { $tpl['ICON'] = FEATURE_OPEN_ICON; $reAppCommand = CommandFactory::getCommand('ShowReApplication'); $reAppCommand->setTerm($this->term); $tpl['ELIGIBLE'] = ""; //dummy tag, text is in template $tpl['LOTTERY_TERM_1'] = Term::toString($this->term); $tpl['NEXT_TERM_1'] = Term::toString(Term::getNextTerm($this->term)); $tpl['ENTRY_LINK'] = $reAppCommand->getLink('Click here to re-apply.'); } else { $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['NOT_ELIGIBLE'] = ""; //dummy tag, text is in template $tpl['LOTTERY_TERM_2'] = Term::toString($this->term); $tpl['NEXT_TERM_2'] = Term::toString(Term::getNextTerm($this->term)); } } } } } } } if (!$hardCapReached && time() > $this->startDate) { if ($this->roommateRequests != FALSE && !is_null($this->roommateRequests) && $this->assignment != TRUE && !PEAR::isError($this->assignment)) { $tpl['roommates'] = array(); $tpl['ROOMMATE_REQUEST'] = ''; // dummy tag foreach ($this->roommateRequests as $invite) { $cmd = CommandFactory::getCommand('LotteryShowRoommateRequest'); $cmd->setRequestId($invite['id']); $roommie = StudentFactory::getStudentByUsername($invite['requestor'], $this->term); $tpl['roommates'][]['ROOMMATE_LINK'] = $cmd->getLink($roommie->getName()); //$tpl['roommates'][]['ROOMMATE_LINK'] = PHPWS_Text::secureLink(HMS_SOAP::get_name($invite['requestor']), 'hms', array('type'=>'student', 'op'=>'lottery_show_roommate_request', 'id'=>$invite['id'])); } } } return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/reApplicationMenuBlock.tpl'); }
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 show() { PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); javascript('jquery'); javascript('jquery_ui'); $tpl = array(); $tpl['TERM'] = Term::toString($this->term) . ' - ' . Term::toString(Term::getNextTerm($this->term)); $tpl['FALL_TERM'] = Term::toString($this->term); /* * onSubmit command */ $form = new PHPWS_Form(); $submitCmd = CommandFactory::getCommand('ReApplicationFormSubmit'); $submitCmd->setTerm($this->term); $submitCmd->initForm($form); /* * Contact info */ if (isset($_REQUEST['number'])) { $form->addText('number', $_REQUEST['number']); } else { $form->addText('number'); } $form->setSize('number', 10); $form->setMaxSize('number', 10); $form->addCssClass('number', 'form-control'); $form->addCheck('do_not_call', 1); /********************* * 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'); /* 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()); } */ /* * Meal Plan */ $mealPlans = array(BANNER_MEAL_LOW => _('Low'), BANNER_MEAL_STD => _('Standard'), BANNER_MEAL_HIGH => _('High'), BANNER_MEAL_SUPER => _('Super')); $form->addDropBox('meal_plan', $mealPlans); $form->setLabel('meal_plan', 'Meal plan: '); $form->setMatch('meal_plan', BANNER_MEAL_STD); $form->addCssClass('meal_plan', 'form-control'); /* * Special interest stuff */ // RLC $form->addCheck('rlc_interest', array('rlc_interest')); $form->setLabel('rlc_interest', "I'm interested in applying for (or continuing in) a Residential Learning Community."); /* * Special needs */ $form->addCheck('special_need', array('special_need')); $form->setLabel('special_need', array('Yes, I require special needs housing.')); if (isset($_REQUEST['special_need'])) { $form->setMatch('special_need', $_REQUEST['special_need']); } /* * Early Release */ $nextTerm = Term::toString(Term::getNextTerm($this->term)); $reasons = array(); $reasons['no'] = "No, I'll be staying through {$nextTerm}."; $reasons['grad'] = "Graduating in December"; $reasons['student_teaching'] = "Student Teaching in Spring"; $reasons['internship'] = "ASU-sponsored Internship"; $reasons['transfer'] = "Transferring to other University"; $reasons['withdraw'] = "Withdrawing"; $reasons['marriage'] = "Getting married"; $reasons['study_abroad'] = "Study Abroad for Spring"; $reasons['intl_exchange'] = "International exchange ending"; $form->addDropBox('early_release', $reasons); $form->setLabel('early_release', 'Will you apply for early release?'); $form->setMatch('early_release', 'no'); $form->addCssClass('early_release', 'form-control'); /* * Contract */ $form->addCheck('deposit_check', array('deposit_check')); $form->setLabel('deposit_check', 'I understand & acknowledge that if I cancel my License Contract my student account will be charged <strong>$250</strong>. If I cancel my License Contract after July 1, I will be liable for the entire amount of the on-campus housing fees for the Fall semester.'); $form->addSubmit('submit', 'Submit re-application'); $form->mergeTemplate($tpl); Layout::addPageTitle("Re-Application Form"); return PHPWS_Template::process($form->getTemplate(), 'hms', 'student/reapplicationForm.tpl'); }
public static function send_roommate_reminder_emails($term) { PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModclass('hms', 'StudentFactory.php'); // Get a list of outstanding roommate requests, send them reminder emails $query = "select hms_lottery_reservation.* FROM hms_lottery_reservation\n LEFT OUTER JOIN (SELECT asu_username FROM hms_assignment WHERE term={$term} AND lottery = 1) as foo ON hms_lottery_reservation.asu_username = foo.asu_username\n WHERE foo.asu_username IS NULL\n AND hms_lottery_reservation.expires_on > " . time(); $result = PHPWS_DB::getAll($query); if (PEAR::isError($result)) { PHPWS_Error::log($result); test($result, 1); } $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term)); foreach ($result as $row) { $student = StudentFactory::getStudentByUsername($row['asu_username'], $term); $requestor = StudentFactory::getStudentByUsername($row['requestor'], $term); $bed = new HMS_Bed($row['bed_id']); $hall_room = $bed->where_am_i(); HMS_Email::send_lottery_roommate_reminder($row['asu_username'], $student->getName(), $row['expires_on'], $requestor->getName(), $hall_room, $year); HMS_Activity_Log::log_activity($row['asu_username'], ACTIVITY_LOTTERY_ROOMMATE_REMINDED, 'hms'); } }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'WaitingListApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); $term = $context->get('term'); $errorCmd = CommandFactory::getCommand('ShowOffCampusWaitListApplication'); $errorCmd->setTerm($term); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Data sanity checking $doNotCall = $context->get('do_not_call'); $areaCode = $context->get('area_code'); $exchange = $context->get('exchange'); $number = $context->get('number'); if (is_null($doNotCall)) { // do not call checkbox was not selected, so check the number if (is_null($areaCode) || is_null($exchange) || is_null($number)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please provide a cell-phone number or click the checkbox stating that you do not wish to share your number with us.'); $errorCmd->redirect(); } } if (!is_null($doNotCall)) { $cellPhone = null; } else { $cellPhone = $areaCode . $exchange . $number; } $mealPlan = $context->get('meal_plan'); $specialNeeds = $context->get('special_needs'); $physicalDisability = isset($specialNeeds['physical_disability']) ? 1 : 0; $psychDisability = isset($specialNeeds['psych_disability']) ? 1 : 0; $genderNeed = isset($specialNeeds['gender_need']) ? 1 : 0; $medicalNeed = isset($specialNeeds['medical_need']) ? 1 : 0; $international = $student->isInternational(); $application = new WaitingListApplication(0, $term, $student->getBannerId(), $student->getUsername(), $student->getGender(), $student->getType(), $student->getApplicationTerm(), $cellPhone, $mealPlan, $physicalDisability, $psychDisability, $genderNeed, $medicalNeed, $international); $application->setEmergencyContactName($context->get('emergency_contact_name')); $application->setEmergencyContactRelationship($context->get('emergency_contact_relationship')); $application->setEmergencyContactPhone($context->get('emergency_contact_phone')); $application->setEmergencyContactEmail($context->get('emergency_contact_email')); $application->setEmergencyMedicalCondition($context->get('emergency_medical_condition')); $application->setMissingPersonName($context->get('missing_person_name')); $application->setMissingPersonRelationship($context->get('missing_person_relationship')); $application->setMissingPersonPhone($context->get('missing_person_phone')); $application->setMissingPersonEmail($context->get('missing_person_email')); try { $application->save(); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error saving your application. Please try again or contact the Department of University Housing.'); $errorCmd->redirect(); } // Log the fact that the entry was saved HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ENTRY, UserStatus::getUsername()); // Send a confirmation email $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term)); HMS_Email::sendWaitListApplicationConfirmation($student, $year); // Show a sucess message and redirect to the main menu NQ::simple('hms', hms\NotificationView::SUCCESS, 'Your application to the Open Waiting List was submitted successfully.'); $cmd = CommandFactory::getCommand('ShowStudentMenu'); $cmd->redirect(); }
public function execute(CommandContext $context) { $currentTerm = Term::getCurrentTerm(); $username = UserStatus::getUsername(); # Create a contact form command, redirect to it in case of error. $contactCmd = CommandFactory::getCommand('ShowContactForm'); //TODO add try catch blocks here for StudentNotFound exception $student = StudentFactory::getStudentByUsername($username, $currentTerm); $applicationTerm = $student->getApplicationTerm(); // In case this is a new freshmen, they'll likely have no student type in the "current" term. // So, instead, we need to lookup the student in their application term. if ($applicationTerm > $currentTerm) { $student = StudentFactory::getStudentByUsername($username, $applicationTerm); } $studentType = $student->getType(); $studentClass = $student->getClass(); $dob = $student->getDob(); # Check for banner errors in any of these calls if (empty($applicationTerm) || empty($studentType) || empty($studentClass) || empty($dob) || is_null($dob)) { # TODO: HMS_Mail here PHPWS_Error::log('Initial banner lookup failed', 'hms', 'show_welcome_screen', "username: "******"too early" message if (!Term::isValidTerm($applicationTerm)) { PHPWS_Core::initModClass('hms', 'WelcomeScreenViewInvalidTerm.php'); $view = new WelcomeScreenViewInvalidTerm($applicationTerm, $contactCmd); $context->setContent($view->show()); return; } # Make sure the student doesn't already have an assignment on file for the current term if (HMS_Assignment::checkForAssignment($username, $currentTerm)) { # No idea what's going on here, send to a contact page $contactCmd->redirect(); } # Check to see if the user has an application on file already for every required term # If so, forward to main menu $requiredTerms = HousingApplication::checkAppliedForAllRequiredTerms($student); if (count($requiredTerms) > 0) { # Student is missing a required application, so redirect to the application form for that term $appCmd = CommandFactory::getCommand('ShowHousingApplicationWelcome'); $appCmd->setTerm($requiredTerms[0]); $appCmd->redirect(); } else { $menuCmd = CommandFactory::getCommand('ShowFreshmenMainMenu'); $menuCmd->redirect(); } } } }
public function show() { $tpl = array(); $tpl['NAME'] = $this->student->getFullName(); $tpl['TERM'] = Term::toString($this->term) . ' - ' . Term::toString(Term::getNextTerm($this->term)); $form = new PHPWS_Form(); $submitCmd = CommandFactory::getCommand('ReApplicationWaitingListFormSubmit'); $submitCmd->setTerm($this->term); $submitCmd->initForm($form); if (isset($_REQUEST['area_code'])) { $form->addText('area_code', $_REQUEST['area_code']); } else { $form->addText('area_code'); } $form->setSize('area_code', 3); $form->setMaxSize('area_code', 3); if (isset($_REQUEST['exchange'])) { $form->addText('exchange', $_REQUEST['exchange']); } else { $form->addText('exchange'); } $form->setSize('exchange', 3); $form->setMaxSize('exchange', 3); if (isset($_REQUEST['number'])) { $form->addText('number', $_REQUEST['number']); } else { $form->addText('number'); } $form->setSize('number', 4); $form->setMaxSize('number', 4); $form->addCheck('do_not_call', 1); /********************* * Emergency Contact * *********************/ $form->addText('emergency_contact_name'); $form->addText('emergency_contact_relationship'); $form->addText('emergency_contact_phone'); $form->addText('emergency_contact_email'); $form->addTextArea('emergency_medical_condition'); /* 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->addText('missing_person_relationship'); $form->addText('missing_person_phone'); $form->addText('missing_person_email'); /* 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()); } */ $mealPlans = array(BANNER_MEAL_LOW => _('Low'), BANNER_MEAL_STD => _('Standard'), BANNER_MEAL_HIGH => _('High'), BANNER_MEAL_SUPER => _('Super')); $form->addDropBox('meal_plan', $mealPlans); $form->setLabel('meal_plan', 'Meal plan: '); $form->setMatch('meal_plan', BANNER_MEAL_STD); $form->addCheck('special_need', array('special_need')); $form->setLabel('special_need', array('Yes, I require special needs housing.')); if (isset($_REQUEST['special_need'])) { $form->setMatch('special_need', $_REQUEST['special_need']); } $form->addCheck('deposit_check', array('deposit_check')); $form->setLabel('deposit_check', 'I understand & acknowledge that if I cancel my License Contract after I am assigned a space in a residence hall my student account will be charged $250. If I cancel my License Contract after July 1, I will be liable for the entire amount of the on-campus housing fees for the Fall semester.'); $form->addSubmit('submit', 'Submit waiting list application'); $form->mergeTemplate($tpl); return PHPWS_Template::process($form->getTemplate(), 'hms', 'student/reapplicationOffcampus.tpl'); }
public function show() { $tpl = array(); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); $tpl['STATUS'] = ""; if (isset($this->assignment) && $this->assignment->getStateName() == 'declined') { // Student declined the invite $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['DECLINED'] = ""; //dummy tag } else { if (isset($this->application) && !is_null($this->application->id) && isset($this->assignment) && $this->assignment->getStateName() == 'confirmed') { // Student has applied, been accepted, been invited, and confirmed that invitation to a particular community. The student can no longer view/edit the application. $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['CONFIRMED_RLC_NAME'] = $this->assignment->getRlcName(); } else { if (isset($this->assignment) && $this->assignment->getStateName() == 'invited') { // Studnet has applied, been assigned, and been sent an invite email $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['INVITED_COMMUNITY_NAME'] = $this->assignment->getRlcName(); $acceptCmd = CommandFactory::getCommand('ShowAcceptRlcInvite'); $acceptCmd->setTerm($this->term); $tpl['INVITED_CONFIRM_LINK'] = $acceptCmd->getLink('accept or decline your invitation'); } else { if (!is_null($this->rlcApp)) { // Student has already re-applied $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['ALREADY_APPLIED'] = ""; // dummy tag, text is in template } else { if (time() < $this->startDate) { // Too early $tpl['ICON'] = FEATURE_NOTYET_ICON; $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate); } else { if (time() > $this->endDate) { // Too late $tpl['ICON'] = FEATURE_LOCKED_ICON; // fade out header $tpl['STATUS'] = "locked"; $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate); } else { // Student has not re-applied yet if (is_null($this->application)) { # No housing application, therefore not eligible $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['NOT_ELIGIBLE'] = ""; //dummy tag, text is in template $tpl['LOTTERY_TERM_2'] = Term::toString($this->term); $tpl['NEXT_TERM_2'] = Term::toString(Term::getNextTerm($this->term)); } else { # Eligible $tpl['ICON'] = FEATURE_OPEN_ICON; $reAppCommand = CommandFactory::getCommand('ShowRlcReapplication'); $reAppCommand->setTerm($this->term); $tpl['ELIGIBLE'] = ""; //dummy tag, text is in template $tpl['LOTTERY_TERM_1'] = Term::toString($this->term); $tpl['NEXT_TERM_1'] = Term::toString(Term::getNextTerm($this->term)); $tpl['ENTRY_LINK'] = $reAppCommand->getLink('Click here to re-apply.'); } } } } } } } return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/rlcReapplicationMenuBlock.tpl'); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'LotteryApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); // TODO Use the HousingApplicationFactory class to get all this data $term = $context->get('term'); # Double check that the student is eligible if (!HMS_Lottery::determineEligibility(UserStatus::getUsername())) { NQ::simple('hms', hms\NotificationView::ERROR, 'You are not eligible to re-apply for on-campus housing for this semester.'); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $menuCmd->redirect(); } $errorCmd = CommandFactory::getCommand('ShowReApplication'); $errorCmd->setTerm($term); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Data sanity checking $doNotCall = $context->get('do_not_call'); $number = $context->get('number'); if (is_null($doNotCall)) { // do not call checkbox was not selected, so check the number if (is_null($number)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please provide a cell-phone number or click the checkbox stating that you do not wish to share your number with us.'); $errorCmd->redirect(); } } if (!is_null($doNotCall)) { $cellPhone = null; } else { $cellPhone = $number; } $mealPlan = $context->get('meal_plan'); $specialNeeds = $context->get('special_needs'); $physicalDisability = isset($specialNeeds['physical_disability']) ? 1 : 0; $psychDisability = isset($specialNeeds['psych_disability']) ? 1 : 0; $genderNeed = isset($specialNeeds['gender_need']) ? 1 : 0; $medicalNeed = isset($specialNeeds['medical_need']) ? 1 : 0; /** * Special interest housing groups */ // Sororities - If they checked the box, and their pref is APH, // then record her sorority choice $sororityCheck = $context->get('sorority_check'); if (isset($sororityCheck) && $context->get('sorority_pref') == 'aph') { $sororityPref = $context->get('sorority_drop'); } else { $sororityPref = null; } // Teaching Fellows, Watauga Global, and Honors //$tfPref = ($context->get('tf_pref') == 'with_tf')?1:0; $wgPref = $context->get('wg_pref') == 'with_wg' ? 1 : 0; $honorsPref = $context->get('honors_pref') == 'with_honors' ? 1 : 0; // Learning Community Interest $rlcInterest = $context->get('rlc_interest'); $rlcInterest = isset($rlcInterest) ? 1 : 0; // Contract early release $earlyRelease = $context->get('early_release'); if ($earlyRelease == 'no') { $earlyRelease = NULL; } // International $international = $student->isInternational(); $magicWinner = 0; // The student's type should always be 'C' (continuing), // even if thes student began in the Spring. $studentType = 'C'; /************************** * Emergency Contact Info * */ $application = new LotteryApplication(0, $term, $student->getBannerId(), $student->getUsername(), $student->getGender(), $studentType, $student->getApplicationTerm(), $cellPhone, $mealPlan, $physicalDisability, $psychDisability, $genderNeed, $medicalNeed, $international, NULL, $magicWinner, $sororityPref, $wgPref, $honorsPref, $rlcInterest, $earlyRelease); $application->setEmergencyContactName($context->get('emergency_contact_name')); $application->setEmergencyContactRelationship($context->get('emergency_contact_relationship')); $application->setEmergencyContactPhone($context->get('emergency_contact_phone')); $application->setEmergencyContactEmail($context->get('emergency_contact_email')); $application->setEmergencyMedicalCondition($context->get('emergency_medical_condition')); $application->setMissingPersonName($context->get('missing_person_name')); $application->setMissingPersonRelationship($context->get('missing_person_relationship')); $application->setMissingPersonPhone($context->get('missing_person_phone')); $application->setMissingPersonEmail($context->get('missing_person_email')); try { $application->save(); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error saving your re-application. Please try again or contact the Department of University Housing.'); $errorCmd->redirect(); } // Log the fact that the entry was saved HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ENTRY, UserStatus::getUsername()); // Send email confirmation PHPWS_Core::initModClass('hms', 'HMS_Email.php'); $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term)); HMS_Email::send_lottery_application_confirmation($student, $year); // Show success message NQ::simple('hms', hms\NotificationView::SUCCESS, 'Your re-application was submitted successfully.'); // Redirect to the RLC Reapplication form is the student is interested in RLCs, otherwise, show the student menu if ($rlcInterest == 1) { $cmd = CommandFactory::getCommand('ShowRlcReapplication'); $cmd->setTerm($term); } else { $cmd = CommandFactory::getCommand('ShowStudentMenu'); } $cmd->redirect(); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $roomId = $context->get('roomId'); $roommates = $context->get('roommates'); $mealPlan = $context->get('mealPlan'); $term = PHPWS_Settings::get('hms', 'lottery_term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); $errorCmd = CommandFactory::getCommand('LotteryShowConfirm'); $errorCmd->setRoomId($roomId); $errorCmd->setRoommates($roommates); $errorCmd->setMealPlan($mealPlan); $successCmd = CommandFactory::getCommand('LotteryShowConfirmed'); $successCmd->setRoomId($roomId); PHPWS_Core::initCoreClass('Captcha.php'); $captcha = Captcha::verify(TRUE); // returns the words entered if correct, FALSE otherwise //$captcha = TRUE; if ($captcha === FALSE) { NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, the words you eneted were incorrect. Please try again.'); $errorCmd->redirect(); } PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Room.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php'); $room = new HMS_Room($roomId); // Check for an RLC assignment in the self-select status $rlcAssignment = RlcMembershipFactory::getMembership($student, $term); // Check roommates for validity foreach ($roommates as $bed_id => $username) { // Double check the student is valid try { $roommate = StudentFactory::getStudentByUsername($username, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not a valid student. Please choose a different roommate."); $errorCmd->redirect(); } // Make sure the bed is still empty $bed = new HMS_Bed($bed_id); if ($bed->has_vacancy() != TRUE) { NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.'); $errorCmd->redirect(); } // Make sure none of the needed beds are reserved if ($bed->is_lottery_reserved()) { NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.'); $errorCmd->redirect(); } // Double check the genders are all the same as the person logged in if ($student->getGender() != $roommate->getGender()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender."); $errorCmd->redirect(); } // Double check the genders are the same as the room (as long as the room isn't AUTO) if ($room->gender_type != AUTO && $roommate->getGender() != $room->gender_type) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender."); $errorCmd->redirect(); } // If this student is an RLC-self-selection, then each roommate must be in the same RLC and in the selfselect-invite state too if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { // This student is an RLC-self-select, so check the roommate's RLC status $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term); // Make sure the roommate is a member of the same RLC and is eligible for self-selection if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$roommate} must be a member of the same learning community as you, and must also be eligible for self-selction."); $errorCmd->redirect(); } // Otherwise (if not RLC members), make sure each roommate is eligible } else { if (HMS_Lottery::determineEligibility($username) !== TRUE) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not eligible for assignment."); $errorCmd->redirect(); } } // If this student is a self-select RLC member, then this student must also be a self-select RLC member of the same RLC if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term); if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} must be a member of the same learning community as you, and must also be eligible for self-selction."); $errorCmd->redirect(); } } } // If the room's gender is 'AUTO' and no one is assigned to it yet, switch it to the student's gender if ($room->gender_type == AUTO && $room->get_number_of_assignees() == 0) { $room->gender_type = $student->getGender(); $room->save(); } // Assign the student to the requested bed $bed_id = array_search(UserStatus::getUsername(), $roommates); // Find the bed id of the student who's logged in try { $result = HMS_Assignment::assignStudent($student, PHPWS_Settings::get('hms', 'lottery_term'), NULL, $bed_id, $mealPlan, 'Confirmed lottery invite', TRUE, ASSIGN_LOTTERY); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error creating your room assignment. Please try again or contact University Housing.'); $errorCmd->redirect(); } // Log the assignment HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ROOM_CHOSEN, UserStatus::getUsername(), 'Captcha: ' . $captcha); // Update the student's meal plan in the housing application, just for future reference $app = HousingApplication::getApplicationByUser($student->getUsername(), $term); $app->setMealPlan($mealPlan); $app->save(); // If this student was an RLC self-select, update the RLC memberhsip state if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment)); } foreach ($roommates as $bed_id => $username) { // Skip the current user if ($username == $student->getUsername()) { continue; } # Reserve the bed for the roommate $expires_on = time() + INVITE_TTL_HRS * 3600; $bed = new HMS_Bed($bed_id); if (!$bed->lottery_reserve($username, $student->getUsername(), $expires_on)) { NQ::smiple('hms', hms\NotificationView::WARNING, "You were assigned, but there was a problem reserving space for your roommates. Please contact University Housing."); $successCmd->redirect(); } HMS_Activity_Log::log_activity($username, ACTIVITY_LOTTERY_REQUESTED_AS_ROOMMATE, $student->getUsername(), 'Expires: ' . HMS_Util::get_long_date_time($expires_on)); # Invite the selected roommates $roomie = StudentFactory::getStudentByUsername($username, $term); $term = PHPWS_Settings::get('hms', 'lottery_term'); $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term)); HMS_Email::send_lottery_roommate_invite($roomie, $student, $expires_on, $room->where_am_i(), $year); } HMS_Email::send_lottery_assignment_confirmation($student, $room->where_am_i(), $term); $successCmd->redirect(); }
/** * Returns an array of the terms which this student can potentially apply for. * * @param Student $student * * @return multitype:multitype:number unknown multitype:number string */ public static function getAvailableApplicationTermsForStudent(Student $student) { $availableTerms = array(); $applicationTerm = $student->getApplicationTerm(); $sem = Term::getTermSem($applicationTerm); switch ($sem) { case TERM_SPRING: case TERM_FALL: $availableTerms[] = array('term' => $applicationTerm, 'required' => 1); break; case TERM_SUMMER1: $availableTerms[] = array('term' => $applicationTerm, 'required' => 1); $summer2Term = Term::getNextTerm($applicationTerm); $availableTerms[] = array('term' => $summer2Term, 'required' => 0); $fallTerm = Term::getNextTerm($summer2Term); $availableTerms[] = array('term' => $fallTerm, 'required' => 1); break; case TERM_SUMMER2: $availableTerms[] = array('term' => $applicationTerm, 'required' => 1); $fallTerm = Term::getNextTerm($applicationTerm); $availableTerms[] = array('term' => $fallTerm, 'required' => 1); break; } return $availableTerms; }