public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'cancel_housing_application')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to cancel housing applications.'); } // Check for a housing application id $applicationId = $context->get('applicationId'); if (!isset($applicationId) || is_null($applicationId)) { throw new InvalidArgumentException('Missing housing application id.'); } // Check for a cancellation reason $cancelReason = $context->get('cancel_reason'); if (!isset($cancelReason) || is_null($cancelReason)) { throw new InvalidArgumentException('Missing cancellation reason.'); } // Load the housing application PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); $application = HousingApplicationFactory::getApplicationById($applicationId); // Load the student $student = $application->getStudent(); $username = $student->getUsername(); $term = $application->getTerm(); // Load the cancellation reasons $reasons = HousingApplication::getCancellationReasons(); // Check for an assignment and remove it // Decide which term to use - If this application is in a past fall term, then use the current term if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) { $assignmentTerm = Term::getCurrentTerm(); } else { $assignmentTerm = $term; } PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm); if (isset($assignment)) { // TODO: Don't hard code cancellation refund percentage HMS_Assignment::unassignStudent($student, $assignmentTerm, 'Application cancellation: ' . $reasons[$cancelReason], UNASSIGN_CANCEL, 100); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($username, $term); if (!is_null($rlcAssignment)) { $rlcAssignment->delete(); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcApplication = HMS_RLC_Application::getApplicationByUsername($username, $term); if (!is_null($rlcApplication)) { $rlcApplication->denied = 1; $rlcApplication->save(); HMS_Activity_Log::log_activity($username, ACTIVITY_DENIED_RLC_APPLICATION, \Current_User::getUsername(), Term::toString($term) . ' Denied RLC Application due to Contract Cancellation'); } // Cancel the application $application->cancel($cancelReason); $application->save(); echo 'success'; exit; }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'HousingApplicationFormView.php'); // Make sure we have a valid term $term = $context->get('term'); if (is_null($term) || !isset($term)) { throw new InvalidArgumentException('Missing term.'); } // Determine the application type, based on the term $sem = Term::getTermSem($term); switch ($sem) { case TERM_FALL: $appType = 'fall'; break; case TERM_SPRING: $appType = 'spring'; break; case TERM_SUMMER1: case TERM_SUMMER2: $appType = 'summer'; break; } $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Make sure the student agreed to the terms, if not, send them back to the terms & agreement command //$event = $context->get('event'); // If they haven't agreed, redirect to the agreement // TODO: actually check via docusign API /* if(is_null($event) || !isset($event) || ($event != 'signing_complete' && $event != 'viewing_complete')){ $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement'); $agreementCmd->setTerm($term); $agreementCmd->setAgreedCommand(CommandFactory::getCommand('ShowHousingApplicationForm')); $agreementCmd->redirect(); } */ // Check to see if the student's PIN is enabled. Don't let the student apply if the PIN is disabled. if ($student->pinDisabled()) { $pinCmd = CommandFactory::getCommand('ShowPinDisabled'); $pinCmd->redirect(); } // Check to see if the user has an existing application for the term in question $existingApplication = HousingApplication::getApplicationByUser($student->getUsername(), $term); // Check for an in-progress application on the context, ignore any exceptions (in case there isn't an application on the context) try { //TODO check to see if it looks like there might be something on the context before trying this $existingApplication = HousingApplicationFactory::getApplicationFromContext($context, $term, $student, $appType); } catch (Exception $e) { // ignored $contextApplication = NULL; } $appView = new HousingApplicationFormView($student, $term, $existingApplication); $context->setContent($appView->show()); }
public function showForStudent(Student $student, $term) { // for freshmen if ($student->getApplicationTerm() > Term::getCurrentTerm()) { return true; } // for returning students (summer terms) if ($term > $student->getApplicationTerm() && $term != PHPWS_Settings::get('hms', 'lottery_term') && (Term::getTermSem($term) == TERM_SUMMER1 || Term::getTermSem($term) == TERM_SUMMER2)) { return true; } return false; }
public function execute() { PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $db = new PHPWS_DB('hms_new_application'); $db->addColumn('hms_new_application.*'); $db->addWhere('term', $this->term); $db->addWhere('cancelled', 0); $term = Term::getTermSem($this->term); if ($term == TERM_FALL) { $db->addJoin('LEFT', 'hms_new_application', 'hms_fall_application', 'id', 'id'); $db->addColumn('hms_fall_application.*'); } else { if ($term == TERM_SUMMER1 || $term == TERM_SUMMER2) { $db->addJoin('LEFT', 'hms_new_application', 'hms_summer_application', 'id', 'id'); $db->addColumn('hms_summer_application.*'); } } $result = $db->select(); $app = array(); foreach ($result as $app) { $username = $app['username']; $bannerId = $app['banner_id']; $type = $app['student_type']; $cellPhone = $app['cell_phone']; $date = date('n/j/Y', $app['created_on']); $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $this->term); if (!is_null($assignment)) { $room = $assignment->where_am_i(); } else { $room = ''; } $student = StudentFactory::getStudentByBannerId($bannerId, $this->term); $first = $student->getFirstName(); $middle = $student->getMiddleName(); $last = $student->getLastName(); $gender = $student->getPrintableGender(); $birthday = date("m/d/Y", $student->getDobDateTime()->getTimestamp()); $address = $student->getAddress(NULL); if ($term == TERM_SPRING || $term == TERM_FALL) { $lifestyle = $app['lifestyle_option'] == 1 ? 'Single Gender' : 'Co-Ed'; } else { $lifestyle = $app['room_type'] == 1 ? 'Single Room' : 'Double Room'; } if (!is_null($address) && $address !== false) { $this->rows[] = array($username, $bannerId, $first, $middle, $last, $gender, $type, $cellPhone, $room, $date, $address->line1, $address->line2, $address->line3, $address->city, $address->state, $address->zip, $birthday, $lifestyle); } else { $this->rows[] = array($username, $bannerId, $first, $middle, $last, '', $type, $cellPhone, $room, $date, '', '', '', '', '', '', $lifestyle); } } }
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 showForStudent(Student $student, $term) { // Freshmen only if ($student->getApplicationTerm() > Term::getCurrentTerm()) { return true; } // Possibly available for continuing students in the summer terms (this is sort of a hack) //TODO: find a better way to implement this $termSem = Term::getTermSem($term); if ($student->getApplicationTerm() <= Term::getCurrentTerm() && ($termSem == TERM_SUMMER1 || $termSem == TERM_SUMMER2)) { return true; } return false; }
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 execute(CommandContext $context) { $term = $context->get('term'); // If we're coming from the special needs page, save any special needs flags the student selected if (array_key_exists('special_needs', $context->getParams())) { $this->saveSpecialNeeds($context); } // If they haven't agreed, redirect to the agreement // TODO: actually check via docusign API $event = $context->get('event'); if (is_null($event) || !isset($event) || $event != 'signing_complete' && $event != 'viewing_complete') { $returnCmd = CommandFactory::getCommand('ShowFreshmenApplicationReview'); $returnCmd->setTerm($term); $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement'); $agreementCmd->setTerm($term); $agreementCmd->setAgreedCommand($returnCmd); $agreementCmd->redirect(); } $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); $errorCmd = CommandFactory::getCommand('ShowHousingApplicationForm'); $errorCmd->setTerm($term); // Determine the application type, based on the term $sem = Term::getTermSem($term); switch ($sem) { case TERM_FALL: $appType = 'fall'; break; case TERM_SPRING: $appType = 'spring'; break; case TERM_SUMMER1: case TERM_SUMMER2: $appType = 'summer'; break; } try { $application = HousingApplicationFactory::getApplicationFromSession($_SESSION['application_data'], $term, $student, $appType); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage()); $errorCmd->redirect(); } PHPWS_Core::initModClass('hms', 'FreshmenApplicationReview.php'); $view = new FreshmenApplicationReview($student, $term, $application); $context->setContent($view->show()); }
public function execute(CommandContext $context) { $term = $context->get('term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); $errorCmd = CommandFactory::getCommand('ShowEmergencyContactForm'); $errorCmd->setTerm($term); // Determine the application type, based on the term $sem = Term::getTermSem($term); switch ($sem) { case TERM_FALL: $appType = 'fall'; break; case TERM_SPRING: $appType = 'spring'; break; case TERM_SUMMER1: case TERM_SUMMER2: $appType = 'summer'; break; } try { $application = HousingApplicationFactory::getAppByStudent($student, $term, $appType); // Change the emergency contact and missing person info temporarily, WITHOUT saving /* Emergency Contact */ $application->setEmergencyContactName($context->get('emergency_contact_name')); $application->setEmergencyContactRelationship($context->get('emergency_contact_relationship')); $application->setEmergencyContactPhone($context->get('emergency_contact_phone')); $application->setEmergencyContactEmail($context->get('emergency_contact_email')); /* Emergency Medical Condition */ $application->setEmergencyMedicalCondition($context->get('emergency_medical_condition')); /* Missing Person */ $application->setMissingPersonName($context->get('missing_person_name')); $application->setMissingPersonRelationship($context->get('missing_person_relationship')); $application->setMissingPersonPhone($context->get('missing_person_phone')); $application->setMissingPersonEmail($context->get('missing_person_email')); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage()); $errorCmd->redirect(); } PHPWS_Core::initModClass('hms', 'EmergencyContactReview.php'); $view = new EmergencyContactReview($student, $term, $application); $context->setContent($view->show()); }
private function getCumulativeCountsByTerm($term) { // If the report is for fall, we really want Summer 1 and Summer 2 applications terms too. // So, build a list of extra application terms we should use. $extraTerms = array(); if (Term::getTermSem($term) == TERM_FALL) { // Compute the Summer 2 term $t = Term::getPrevTerm($term); $extraTerms[] = $t; // Computer the SUmmer 1 term $t = Term::getPrevTerm($t); $extraTerms[] = $t; } // Create the where clause, start by adding the requested term $termClause = "application_term = {$term}"; // Add any extra terms, if any. if (count($extraTerms) > 0) { foreach ($extraTerms as $t) { $termClause .= " OR application_term = {$t}"; } } // Build the query /* Query with human readable dates $query = "select to_char(date_trunc('day',timestamp 'epoch' + created_on * interval '1 second'), 'Mon DD, YYYY') as date, count(created_on) as daily_count, sum(count(created_on)) OVER (ORDER BY to_char(date_trunc('day',timestamp 'epoch' + created_on * interval '1 second'), 'Mon DD, YYYY')) as running_total FROM hms_new_application WHERE term = 201340 AND ($termClause) AND student_type = 'F' AND application_type = 'fall' GROUP BY date ORDER BY date"; */ PHPWS_Core::initModClass('hms', 'PdoFactory.php'); $db = PdoFactory::getInstance()->getPdo(); $query = "SELECT\n date_part('epoch', date_trunc('day',timestamp 'epoch' + created_on * interval '1 second')) as date,\n SUM(COUNT(created_on)) OVER (ORDER BY date_part('epoch', date_trunc('day',timestamp 'epoch' + created_on * interval '1 second'))) as running_total\n FROM hms_new_application\n WHERE term = :term\n AND ({$termClause})\n AND student_type = 'F'\n AND cancelled = 0\n GROUP BY date\n ORDER BY date"; $stmt = $db->prepare($query); $stmt->bindParam(':term', $term); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; }
private function getCumulativeCountsByTerm($term) { // If the report is for the fall, we want continuing students with // application terms <= the spring term. if (Term::getTermSem($term) == TERM_FALL) { $year = Term::getTermYear($term); $applicationTerm = $year . TERM_SPRING; } else { // For any other term, we want the application term <= the previous term $applicationTerm = Term::getPrevTerm($term); } PHPWS_Core::initModClass('hms', 'PdoFactory.php'); $db = PdoFactory::getInstance()->getPdo(); $query = "SELECT\n date_part('epoch', date_trunc('day',timestamp 'epoch' + cancelled_on * interval '1 second')) as date,\n SUM(COUNT(cancelled_on)) OVER (ORDER BY date_part('epoch', date_trunc('day',timestamp 'epoch' + cancelled_on * interval '1 second'))) as running_total\n FROM hms_new_application\n WHERE term = :term\n and application_term <= {$applicationTerm}\n and cancelled = 1\n and cancelled_reason NOT IN ('offer_made', 'before_assignment')\n GROUP BY date\n ORDER BY date;"; $stmt = $db->prepare($query); $stmt->bindParam(':term', $term); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; }
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 execute(CommandContext $context) { $applicationId = $context->get('applicationId'); if (!isset($applicationId)) { throw new InvalidArgumentException('Missing application id.'); } PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); $application = HousingApplicationFactory::getApplicationById($applicationId); $student = $application->getStudent(); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); // Decide which term to use - If this application is in a past fall term, then use the current term $term = $application->getTerm(); if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) { $assignmentTerm = Term::getCurrentTerm(); } else { $assignmentTerm = $term; } $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm); PHPWS_Core::initModClass('hms', 'HousingApplicationCancelView.php'); $view = new HousingApplicationCancelView($student, $application, $assignment); echo $view->show(); exit; }
public function execute(CommandContext $context) { $term = $context->get('term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Recreate the agreedToCommand $agreedCmd = CommandFactory::getCommand($context->get('onAgreeAction')); $agreedCmd->setTerm($term); $roommateRequestId = $context->get('roommateRequestId'); if (isset($roommateRequestId) && $roommateRequestId != null) { $agreedCmd->setRoommateRequestId($roommateRequestId); } //$submitCmd = CommandFactory::getCommand('AgreeToTerms'); //$submitCmd->setTerm($term); //$submitCmd->setAgreedCmd($agreedCmd); $sem = Term::getTermSem($term); switch ($sem) { case TERM_FALL: $appType = 'fall'; break; case TERM_SPRING: $appType = 'spring'; break; case TERM_SUMMER1: case TERM_SUMMER2: $appType = 'summer'; break; } $application = HousingApplicationFactory::getApplicationFromSession($_SESSION['application_data'], $term, $student, $appType); $docusignCmd = CommandFactory::getCommand('BeginDocusign'); $docusignCmd->setTerm($term); $docusignCmd->setReturnCmd($agreedCmd); $docusignCmd->setParentName($application->getEmergencyContactName()); $docusignCmd->setParentEmail($application->getEmergencyContactEmail()); PHPWS_Core::initModClass('hms', 'TermsAgreementView.php'); $agreementView = new TermsAgreementView($term, $docusignCmd, $student); $context->setContent($agreementView->show()); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', '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(); } }
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'); }
/** * Sends an individual assignment notice message. * * @param String $to ASU username * @param String $name Student's first and last name * @param String $term * @param String $location * @param Array $roommates * @param String $moveinTime */ public static function sendAssignmentNotice($to, $name, $term, $location, array $roommates, $moveinTime) { $tpl = array(); $tpl['NAME'] = $name; $tpl['TERM'] = Term::toString($term); $tpl['LOCATION'] = $location; $tpl['MOVE_IN_TIME'] = $moveinTime; $tpl['DATE'] = strftime("%B %d, %Y"); if (!empty($roommates)) { foreach ($roommates as $roommate) { $tpl['roommates'][] = array('ROOMMATE' => $roommate); } } $sem = Term::getTermSem($term); switch ($sem) { case TERM_SPRING: HMS_Email::send_template_message($to . TO_DOMAIN, 'Housing Assignment Notice!', 'email/assignment_notice_spring.tpl', $tpl); break; case TERM_SUMMER1: case TERM_SUMMER2: HMS_Email::send_template_message($to . TO_DOMAIN, 'Housing Assignment Notice!', 'email/assignment_notice_summer.tpl', $tpl); break; case TERM_FALL: /* if($returning == TRUE){ HMS_Email::send_template_message($to . TO_DOMAIN, 'Housing Assignment Notice!', 'email/assignment_notice_returning.tpl', $tpl); }else{ HMS_Email::send_template_message($to . TO_DOMAIN, 'Housing Assignment Notice!', 'email/assignment_notice.tpl', $tpl); } */ HMS_Email::send_template_message($to . TO_DOMAIN, 'Housing Assignment Notice!', 'email/assignment_notice.tpl', $tpl); break; } }
public function show() { $tpl = array(); $tpl['REVIEW_MSG'] = ''; // set this to show the review message $tpl['STUDENT_NAME'] = $this->student->getFullName(); $tpl['GENDER'] = $this->student->getPrintableGender(); $tpl['ENTRY_TERM'] = Term::toString($this->term); $tpl['CLASSIFICATION_FOR_TERM_LBL'] = $this->student->getPrintableClass(); $tpl['STUDENT_STATUS_LBL'] = $this->student->getPrintableType(); // TODO: This, right $sem = Term::getTermSem($this->term); if ($sem == TERM_SPRING || $sem == TERM_FALL) { $tpl['LIFESTYLE_OPTION'] = $this->app->getLifestyleOption() == 1 ? 'Single gender' : 'Co-ed'; $tpl['PREFERRED_BEDTIME'] = $this->app->getPreferredBedtime() == 1 ? 'Early' : 'Late'; $tpl['ROOM_CONDITION'] = $this->app->getRoomCondition() == 1 ? 'Neat' : 'Cluttered'; } else { if ($sem == 20 || $sem == 30) { $tpl['ROOM_TYPE'] = $this->app->getRoomType() == 0 ? 'Two person' : 'Private (if available)'; } } $tpl['SMOKING_PREFERENCE'] = $this->app->getSmokingPreference() == 1 ? 'No' : 'Yes'; $tpl['MEAL_OPTION'] = HMS_Util::formatMealOption($this->app->getMealPlan()); /* Cell Phone */ $tpl['CELLPHONE'] = is_null($this->app->getCellPhone()) ? "(not provided)" : $this->app->getCellPhone(); /* Emergency Contact */ $tpl['EMERGENCY_CONTACT_NAME'] = $this->app->getEmergencyContactName(); $tpl['EMERGENCY_CONTACT_RELATIONSHIP'] = $this->app->getEmergencyContactRelationship(); $tpl['EMERGENCY_CONTACT_PHONE'] = $this->app->getEmergencyContactPhone(); $tpl['EMERGENCY_CONTACT_EMAIL'] = $this->app->getEmergencyContactEmail(); $tpl['EMERGENCY_MEDICAL_CONDITION'] = $this->app->getEmergencyMedicalCondition(); /* Missing Person */ $tpl['MISSING_PERSON_NAME'] = $this->app->getMissingPersonName(); $tpl['MISSING_PERSON_RELATIONSHIP'] = $this->app->getMissingPersonRelationship(); $tpl['MISSING_PERSON_PHONE'] = $this->app->getMissingPersonPhone(); $tpl['MISSING_PERSON_EMAIL'] = $this->app->getMissingPersonEmail(); /* Special Needs */ $special_needs = ""; if (isset($this->app->physical_disability)) { $special_needs = 'Physical disability<br />'; } if (isset($this->app->psych_disability)) { $special_needs .= 'Psychological disability<br />'; } if (isset($this->app->medical_need)) { $special_needs .= 'Medical need<br />'; } if (isset($this->app->gender_need)) { $special_needs .= 'Gender need<br />'; } if ($special_needs == '') { $special_needs = 'None'; } $tpl['SPECIAL_NEEDS_RESULT'] = $special_needs; /* RLC Interest */ if (Term::getTermSem($this->term) == TERM_FALL) { $tpl['RLC_REVIEW'] = $this->app->rlc_interest == 0 ? 'No' : 'Yes'; } $form = new PHPWS_Form('hidden_form'); $submitCmd = CommandFactory::getCommand('HousingApplicationConfirm'); $submitCmd->setVars($_REQUEST); $submitCmd->initForm($form); $tpl['CONFIRM_BTN'] = ''; // Dummy template var to turn on confirm button $redoCmd = CommandFactory::getCommand('ShowHousingApplicationForm'); $redoCmd->setTerm($this->term); $redoCmd->setVars($_REQUEST); $tpl['REDO_BUTTON'] = $redoCmd->getURI(); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'student/student_application.tpl'); }
/** * Returns the earliest check-in for the given student, in the given hall, which the student * has not checked out of yet. * //TODO update for persistent ID */ public static function getPendingCheckoutForStudentByHall(Student $student, HMS_Residence_Hall $hall) { $db = new PHPWS_DB('hms_checkin'); // Join the hall structure $db->addJoin('', 'hms_checkin', 'hms_hall_structure', 'bed_id', 'bedid'); $db->addWhere('banner_id', $student->getBannerId()); // Smarter term logic: If it's Spring or Summer 2 then we can also look in the previous term $term = $hall->getTerm(); $sem = Term::getTermSem($term); if ($sem == TERM_SPRING || $sem == TERM_SUMMER2) { $db->addWhere('term', $term, '=', 'OR', 'term_group'); $db->addWhere('term', Term::getPrevTerm($term), '=', 'OR', 'term_group'); } else { $db->addWhere('term', $term); } // Checkin bed ID must be in the request hall //$db->addWhere('hms_hall_structure.hallid', $hall->getId()); $db->addWhere('checkout_date', null, 'IS NULL'); $db->addOrder(array('hms_checkin.checkin_date ASC')); // Earliest checkin first $checkin = new RestoredCheckin(); $result = $db->loadObject($checkin); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } if ($checkin->getId() == null) { return null; } return $checkin; }
/** * Returns a string representation of the integer form of a term. * @param Integer $term * @param Boolean $concat Whether or not to concatenate the year and term together (can return a array instead). * @throws InvalidTermException */ public static function toString($term, $concat = true) { $result = array(); // Grab the year from the entry_term $result['year'] = Term::getTermYear($term); // Grab the term from the entry_term $sem = Term::getTermSem($term); if ($sem == TERM_SPRING) { $result['term'] = SPRING; } else { if ($sem == TERM_SUMMER1) { $result['term'] = SUMMER1; } else { if ($sem == TERM_SUMMER2) { $result['term'] = SUMMER2; } else { if ($sem == TERM_FALL) { $result['term'] = FALL; } else { PHPWS_Core::initModClass('hms', 'exception/InvalidTermException.php'); throw new InvalidTermException("Bad term: {$term}"); } } } } if ($concat) { return $result['term'] . ' ' . $result['year']; } else { return $result; } }
public function execute() { $semester = Term::getTermSem(Term::getSelectedTerm()); if ($semester != TERM_FALL && $semester != TERM_SPRING) { throw new InvalidArgumentException('Term must be Fall or Spring.'); } PHPWS_Core::initModClass('hms', 'FallApplication.php'); PHPWS_Core::initModClass('hms', 'SpringApplication.php'); $table2 = $semester == TERM_FALL ? 'hms_fall_application' : 'hms_spring_application'; /* * Male Coed total */ $db = new PHPWS_DB('hms_new_application'); $db->addJoin('left', 'hms_new_application', $table2, 'id', 'id'); $db->addWhere($table2 . '.lifestyle_option', COED); $db->addWhere('term', $this->term); $db->addWhere('gender', MALE); $db->addWhere('student_type', TYPE_FRESHMEN); $db->addColumn('id', null, 'total', TRUE); $result = $db->select('row'); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } $this->maleCoed = $result['total']; /* * Male Single Gender total */ $db = new PHPWS_DB('hms_new_application'); $db->addJoin('left', 'hms_new_application', $table2, 'id', 'id'); $db->addWhere($table2 . '.lifestyle_option', COED, '<>'); // <> == '!='; $db->addWhere('term', $this->term); $db->addWhere('gender', MALE); $db->addWhere('student_type', TYPE_FRESHMEN); $db->addColumn('id', null, 'total', TRUE); $result = $db->select('row'); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } $this->maleSingle = $result['total']; /* * Female Coed total */ $db = new PHPWS_DB('hms_new_application'); $db->addJoin('left', 'hms_new_application', $table2, 'id', 'id'); $db->addWhere($table2 . '.lifestyle_option', COED); $db->addWhere('term', $this->term); $db->addWhere('gender', FEMALE); $db->addWhere('student_type', TYPE_FRESHMEN); $db->addColumn('id', null, 'total', TRUE); $result = $db->select('row'); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } $this->femaleCoed = $result['total']; /* * Female Single Gender */ $db = new PHPWS_DB('hms_new_application'); $db->addJoin('left', 'hms_new_application', $table2, 'id', 'id'); $db->addWhere($table2 . '.lifestyle_option', COED, '<>'); // <> == '!='; $db->addWhere('term', $this->term); $db->addWhere('gender', FEMALE); $db->addWhere('student_type', TYPE_FRESHMEN); $db->addColumn('id', null, 'total', TRUE); $result = $db->select('row'); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } $this->femaleSingle = $result['total']; }
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 load it $application = NULL; $app_result = HousingApplication::checkForApplication($username, $term); 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.'); } } else { // TODO What if there is no application found? Should I cry? // Execution shouldn't be able to make it this far if an application doesn't exist. throw new Exception('No application found.'); } // Update the Emergency Contact and Missing Person information // TODO Sanity check all this new contact information /* Emergency Contact */ $application->setEmergencyContactName($context->get('emergency_contact_name')); $application->setEmergencyContactRelationship($context->get('emergency_contact_relationship')); $application->setEmergencyContactPhone($context->get('emergency_contact_phone')); $application->setEmergencyContactEmail($context->get('emergency_contact_email')); /* Emergency Medical Condition */ $application->setEmergencyMedicalCondition($context->get('emergency_medical_condition')); /* Missing Person */ $application->setMissingPersonName($context->get('missing_person_name')); $application->setMissingPersonRelationship($context->get('missing_person_relationship')); $application->setMissingPersonPhone($context->get('missing_person_phone')); $application->setMissingPersonEmail($context->get('missing_person_email')); // Save the modified application $result = $application->save(); if ($result == TRUE) { // Log the fact that the application updated PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($username, ACTIVITY_EMERGENCY_CONTACT_UPDATED, $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_emergency_contact_updated_confirmation($student, $application->getTerm()); } // Notify user of success //$friendly_term = Term::toString($application->getTerm()); //NQ::simple('hms', hms\NotificationView::SUCCESS, "Your Emergency Contact & Missing Person information for $friendly_term was successfully modified! You will receive an email confirmation in the next 24 hours."); // Redirect to the student menu $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); }
public function execute() { if (!isset($this->term) || is_null($this->term)) { throw new InvalidArgumentException('Missing term.'); } $sem = Term::getTermSem($this->term); switch ($sem) { case TERM_FALL: $db = new PHPWS_DB('hms_fall_application'); $db->addJoin('LEFT OUTER', 'hms_fall_application', 'hms_new_application', 'id', 'id'); break; case TERM_SPRING: $db = new PHPWS_DB('hms_spring_application'); $db->addJoin('LEFT OUTER', 'hms_spring_application', 'hms_new_application', 'id', 'id'); break; case TERM_SUMMER1: case TERM_SUMMER2: $db = new PHPWS_DB('hms_summer_application'); $db->addJoin('LEFT OUTER', 'hms_summer_application', 'hms_new_application', 'id', 'id'); break; } $db->addColumn('hms_new_application.*'); // Only applications for the selected term $db->addWhere('hms_new_application.term', $this->term); // Only non-cancelled applications $db->addWhere('hms_new_application.cancelled', 0); $results = $db->select(); if (PHPWS_Error::logIfError($results)) { throw new DatabaseException($results->toString()); } $types = array(TYPE_FRESHMEN, TYPE_TRANSFER, TYPE_CONTINUING, TYPE_NONDEGREE); $genders = array(MALE, FEMALE); // Initalize the array for totals foreach ($types as $t) { foreach ($genders as $g) { $this->applicationTotals[$t][$g] = 0; } } foreach ($genders as $g) { $this->cancelledTotals[$g] = 0; } // Calculate the sub-totals foreach ($results as $application) { // Adjust the student types to count 'readmit' and 'returning' as 'continuing' instead if ($application['student_type'] == TYPE_READMIT || $application['student_type'] == TYPE_RETURNING) { $studentType = TYPE_CONTINUING; } else { $studentType = $application['student_type']; } $this->applicationTotals[$studentType][$application['gender']]++; } // Male sub-total foreach ($types as $type) { $this->maleTotals[] = $this->applicationTotals[$type][MALE]; $this->maleSubTotal += $this->applicationTotals[$type][MALE]; } // Female sub-total foreach ($types as $type) { $this->femaleTotals[] = $this->applicationTotals[$type][FEMALE]; $this->femaleSubTotal += $this->applicationTotals[$type][FEMALE]; } // Type sums foreach ($types as $type) { $this->typeTotals[$type] = array_sum($this->applicationTotals[$type]); } // Sub-total $this->subTotal = $this->femaleSubTotal + $this->maleSubTotal; /**** * Count the cancelled applications */ $db->resetWhere(); // Only applications for the selected term $db->addWhere('hms_new_application.term', $this->term); // Only cancelled applications $db->addWhere('hms_new_application.cancelled', 1); $results = $db->select(); if (PHPWS_Error::logIfError($results)) { throw new DatabaseException($results->toString()); } foreach ($results as $application) { $this->cancelledTotals[$application['gender']]++; } // Cancelled sub-total $this->cancelledSubTotal = $this->cancelledTotals[FEMALE] + $this->cancelledTotals[MALE]; // Gender totals $this->maleGrandTotal = $this->maleSubTotal + $this->cancelledTotals[MALE]; $this->femaleGrandTotal = $this->femaleSubTotal + $this->cancelledTotals[FEMALE]; // Grand total $this->total = $this->subTotal + $this->cancelledSubTotal; }
public function can_live_together() { $requestor = strToLower($this->requestor); $requestee = strToLower($this->requestee); $term = $this->term; // Check if the requestor has a confirmed roommate if (HMS_Roommate::has_confirmed_roommate($requestor, $term)) { return E_ROOMMATE_ALREADY_CONFIRMED; } // Check if the requestee has a confirmed roommate if (HMS_Roommate::has_confirmed_roommate($requestee, $term)) { return E_ROOMMATE_REQUESTED_CONFIRMED; } // Use SOAP for the rest of the checks $requestor_info = StudentFactory::getStudentByUsername($requestor, $term); // Make sure the requestee is actually a user try { $requestee_info = StudentFactory::getStudentByUsername($requestee, $term); } catch (StudentNotFoundException $snfe) { return E_ROOMMATE_USER_NOINFO; } // Make sure we have compatible genders if ($requestor_info->getGender() != $requestee_info->getGender()) { return E_ROOMMATE_GENDER_MISMATCH; } PHPWS_Core::initModClass('hms', 'HousingApplication.php'); // Make sure the requestee has filled out an application if (HousingApplication::checkForApplication($requestee, $term) === false) { return E_ROOMMATE_NO_APPLICATION; } // Students can only request a student of the same "type" // This is based on the application term (because students starting // in the summer will have different types). The students must have // the same application term, unless either student's application // term is a summer session of the same year /* if ($requestor_info->getType() != $requestee_info->getType()) { return E_ROOMMATE_TYPE_MISMATCH; }*/ $aTerm = $requestor_info->getApplicationTerm(); $aYear = Term::getTermYear($aTerm); $aSem = Term::getTermSem($aTerm); $bTerm = $requestee_info->getApplicationTerm(); $bYear = Term::getTermYear($bTerm); $bSem = Term::getTermSem($bTerm); // There's a mismatch if the years don't match OR (the years match AND (either student started in the Spring)) // This allows people with summer application terms to request each other, but prevents continuing students from requesting each other // (even if the one student started in the Spring and has a 'F' student type at the time the request is made) if ($aYear != $bYear || $aYear == $bYear && ($aSem == TERM_SPRING && $bSem != TERM_SPRING || $bSem == TERM_SPRING && $aSem != TERM_SPRING)) { return E_ROOMMATE_TYPE_MISMATCH; } // Transfer students can only request other transfers - Prevents freshmen from requesting transfers and vice versa if ($requestor_info->getType() == TYPE_TRANSFER && $requestee_info->getType() != TYPE_TRANSFER || $requestee_info->getType() == TYPE_TRANSFER && $requestor_info->getType() != TYPE_TRANSFER) { return E_ROOMMATE_TYPE_MISMATCH; } /* // Make sure RLC Applications are compatible if (!$this->check_rlc_applications()) { return E_ROOMMATE_RLC_APPLICATION; } // If either student is assigned to an RLC, do not allow the request if (!$this->check_rlc_assignments()) { return E_ROOMMATE_RLC_ASSIGNMENT; } */ return E_SUCCESS; }
public function execute() { PHPWS_Core::initModClass('hms', 'HMS_Util.php'); PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'SpringApplication.php'); PHPWS_Core::initModClass('hms', 'SummerApplication.php'); PHPWS_Core::initModClass('hms', 'FallApplication.php'); PHPWS_Core::initModClass('hms', 'LotteryApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $term = $this->term; $sem = Term::getTermSem($term); $db = new PHPWS_DB('hms_new_application'); $db->addColumn('hms_new_application.*'); $applicationClassName = ''; // Join for additional application data based on semester switch ($sem) { case TERM_SUMMER1: case TERM_SUMMER2: $db->addJoin('', 'hms_new_application', 'hms_summer_application', 'id', 'id'); $db->addColumn('hms_summer_application.*'); $applicationClassName = 'SummerApplication'; //$db->addWhere('application_type', 'summer'); break; case TERM_FALL: $db->addJoin('', 'hms_new_application', 'hms_fall_application', 'id', 'id'); $db->addColumn('hms_fall_application.*'); $applicationClassName = 'FallApplication'; //$db->addWhere('application_type', 'fall'); break; case TERM_SPRING: $db->addJoin('', 'hms_new_application', 'hms_spring_application', 'id', 'id'); $db->addColumn('hms_spring_application.*'); $applicationClassName = 'SpringApplication'; //$db->addWhere('application_type', 'spring'); break; default: // error throw new InvalidArgumentException('Invalid term specified.'); } // Limit to the given term $db->addWhere('hms_new_application.term', $term); // Join for un-assigned students $db->addJoin('LEFT OUTER', 'hms_new_application', 'hms_assignment', 'banner_id', 'banner_id AND hms_new_application.term = hms_assignment.term'); $db->addWhere('hms_assignment.banner_id', 'NULL'); // Don't show students who are type 'W' or have cancelled applications $db->addWhere('hms_new_application.cancelled', 0); // Sort by gender, then application date (earliest to latest) $db->addOrder(array('student_type ASC', 'gender ASC', 'created_on ASC')); $results = $db->getObjects($applicationClassName); if (PHPWS_Error::isError($results)) { throw new DatabaseException($results->toString()); } // Post-processing, cleanup, making it pretty foreach ($results as $app) { // Updates counts $this->total++; if ($app->getGender() == MALE) { $this->male++; } else { if ($app->getGender() == FEMALE) { $this->female++; } } // Copy the cleaned up row to the member var for data $this->data[] = $app->unassignedStudentsFields(); } }
public function execute() { PHPWS_Core::initModClass('hms', 'HMS_Util.php'); PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'SpringApplication.php'); PHPWS_Core::initModClass('hms', 'SummerApplication.php'); PHPWS_Core::initModClass('hms', 'FallApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $term = $this->term; $sem = Term::getTermSem($term); // List of student 'application terms' which we'll consider as 'Freshmen' for term we're looking at // E.g. Students with an applicationt erm in Summer 1, Summer 2, and Fall all count as Freshmen for Fall. $applicationTerms = array(); $db = new PHPWS_DB('hms_new_application'); $db->addColumn('hms_new_application.banner_id'); $db->addColumn('hms_new_application.username'); $db->addColumn('hms_new_application.term'); $db->addColumn('hms_new_application.gender'); $db->addColumn('hms_new_application.application_term'); $db->addColumn('hms_new_application.student_type'); $db->addColumn('hms_new_application.cell_phone'); $db->addColumn('hms_new_application.meal_plan'); $db->addColumn('hms_new_application.physical_disability'); $db->addColumn('hms_new_application.psych_disability'); $db->addColumn('hms_new_application.medical_need'); $db->addColumn('hms_new_application.gender_need'); $db->addColumn('hms_new_application.international'); $db->addColumn('hms_new_application.created_on'); // Join for additional application data based on semester switch ($sem) { case TERM_SUMMER1: case TERM_SUMMER2: $db->addJoin('', 'hms_new_application', 'hms_summer_application', 'id', 'id'); $db->addColumn('hms_summer_application.*'); $applicationTerms[] = $term; $db->addWhere('application_type', 'summer'); break; case TERM_FALL: $db->addJoin('', 'hms_new_application', 'hms_fall_application', 'id', 'id'); $db->addColumn('hms_fall_application.*'); // Add the summer 1 and summe 2 application terms $summer2 = Term::getPrevTerm($term); $summer1 = Term::getPrevTerm($summer2); $applicationTerms[] = $summer1; $applicationTerms[] = $summer2; $applicationTerms[] = $term; $db->addWhere('application_type', 'fall'); break; case TERM_SPRING: $db->addJoin('', 'hms_new_application', 'hms_spring_application', 'id', 'id'); $db->addColumn('hms_spring_application.*'); $applicationTerms[] = $term; $db->addWhere('application_type', 'spring'); break; default: // error throw new InvalidArgumentException('Invalid term specified.'); } // Join for un-assigned students $db->addJoin('LEFT OUTER', 'hms_new_application', 'hms_assignment', 'banner_id', 'banner_id AND hms_new_application.term = hms_assignment.term'); $db->addWhere('hms_assignment.banner_id', 'NULL'); $db->addWhere('hms_new_application.term', $term); $db->addWhere('hms_new_application.student_type', 'F'); // Don't show students who have cancelled applications $db->addWhere('hms_new_application.cancelled', 0); // Limit by application term foreach ($applicationTerms as $t) { $db->addWhere('application_term', $t, '=', 'OR', 'app_term_group'); } // Sort by gender, then application date (earliest to latest) $db->addOrder(array('gender ASC', 'created_on ASC')); $results = $db->select(); if (PHPWS_Error::isError($results)) { throw new DatabaseException($results->toString()); } // Post-processing, cleanup, making it pretty foreach ($results as $row) { // Updates counts $this->total++; if ($row['gender'] == MALE) { $this->male++; } else { if ($row['gender'] == FEMALE) { $this->female++; } } $row['application_term'] = Term::toString($row['application_term']); $row['gender'] = HMS_Util::formatGender($row['gender']); $row['created_on'] = HMS_Util::get_short_date_time($row['created_on']); $row['meal_plan'] = HMS_Util::formatMealOption($row['meal_plan']); $row['lifestyle_option'] = HMS_Util::formatLifestyle($row['lifestyle_option']); $row['room_condition'] = HMS_Util::formatRoomCondition($row['room_condition']); $row['preferred_bedtime'] = HMS_Util::formatBedtime($row['preferred_bedtime']); // Roommates $roommie = HMS_Roommate::get_confirmed_roommate($row['username'], $this->term); if (!is_null($roommie)) { $row['roommate'] = $roommie->getUsername(); $row['roommate_banner_id'] = $roommie->getBannerId(); } // Copy the cleaned up row to the member var for data $this->data[] = $row; } }
/** * 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; }