public function show() { $tpl = array(); if (empty($this->housingApps)) { $tpl['APPLICATIONS_EMPTY'] = 'No applications found.'; return PHPWS_Template::process($tpl, 'hms', 'admin/profileHousingAppList.tpl'); } // Include javascript for cancel application jquery dialog $jsParams = array('LINK_SELECT' => '.cancelAppLink'); javascript('profileCancelApplication', $jsParams, 'mod/hms/'); $app_rows = ""; // Get the list of cancellation reasons $reasons = HousingApplication::getCancellationReasons(); // Show a row for each application foreach ($this->housingApps as $app) { $term = Term::toString($app->getTerm()); $mealPlan = HMS_Util::formatMealOption($app->getMealPlan()); $phone = HMS_Util::formatCellPhone($app->getCellPhone()); $type = $app->getPrintableAppType(); // Clean/dirty and early/late preferences are only fields on the FallApplication if ($app instanceof FallApplication && isset($app->room_condition)) { $clean = $app->room_condition == 1 ? 'Neat' : 'Cluttered'; } else { $clean = ''; } if ($app instanceof FallApplication && isset($app->preferred_bedtime)) { $bedtime = $app->preferred_bedtime == 1 ? 'Early' : 'Late'; } else { $bedtime = ''; } $viewCmd = CommandFactory::getCommand('ShowApplicationView'); $viewCmd->setAppId($app->getId()); $view = $viewCmd->getURI(); $row = array('term' => $term, 'type' => $type, 'meal_plan' => $mealPlan, 'cell_phone' => $phone, 'clean' => $clean, 'bedtime' => $bedtime, 'view' => $view); if ($app->isCancelled()) { $reInstateCmd = CommandFactory::getCommand('ReinstateApplication'); $reInstateCmd->setAppID($app->getId()); $row['reinstate'] = $reInstateCmd->getURI(); $cancelledReason = "({$reasons[$app->getCancelledReason()]})"; $row['cancelledReason'] = $cancelledReason; $row['row_style'] = 'warning'; } else { // Show Cancel Command, if user has permission to cancel apps if (Current_User::allow('hms', 'cancel_housing_application')) { $cancelCmd = CommandFactory::getCommand('ShowCancelHousingApplication'); $cancelCmd->setHousingApp($app); $cancel = $cancelCmd->getURI(); $row['cancel'] = $cancel; } } $app_rows[] = $row; } $tpl['APPLICATIONS'] = $app_rows; return PHPWS_Template::process($tpl, 'hms', 'admin/profileHousingAppList.tpl'); }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); # Get the roommate request record from the database $bed = new HMS_Bed($this->request['bed_id']); $room = $bed->get_parent(); $tpl = array(); $requestor = StudentFactory::getStudentByUsername($this->request['requestor'], $this->term); $tpl['REQUESTOR'] = $requestor->getName(); $tpl['HALL_ROOM'] = $bed->where_am_i(); # List all the students which will be assigned and their beds $beds = $room->get_beds(); foreach ($beds as $bed) { $bed_row = array(); # Check for an assignment $bed->loadAssignment(); # Check for a reservation $reservation = $bed->get_lottery_reservation_info(); $bed_row['BEDROOM_LETTER'] = $bed->bedroom_label; if ($bed->_curr_assignment != NULL) { # Bed is assigned $roommate = StudentFactory::getStudentByUsername($bed->_curr_assignment->asu_username, $this->term); $bed_row['TEXT'] = $roommate->getName(); } else { if ($reservation != NULL) { # Bed is reserved $roommate = StudentFactory::getStudentByUsername($reservation['asu_username'], $this->term); $bed_row['TEXT'] = $roommate->getName() . ' (reserved)'; } else { $bed_row['TEXT'] = 'Empty'; } } $tpl['beds'][] = $bed_row; } $tpl['MEAL_PLAN'] = HMS_Util::formatMealOption($this->mealPlan); PHPWS_Core::initCoreClass('Captcha.php'); $tpl['CAPTCHA'] = Captcha::get(); $submitCmd = CommandFactory::getCommand('LotteryConfirmRoommateRequest'); $submitCmd->setRequestId($this->request['id']); $submitCmd->setMealPlan($this->mealPlan); $form = new PHPWS_Form(); $submitCmd->initForm($form); $form->addSubmit('confirm', 'Confirm Roommate'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); Layout::addPageTitle("Lottery Confirm Roommate"); return PHPWS_Template::process($tpl, 'hms', 'student/lottery_confirm_roommate_request.tpl'); }
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; } }
public function show() { // TODO: Load application in controller and pass it to HousingApplicationView constructor. $application = HousingApplicationFactory::getApplicationById($this->id); $student = StudentFactory::getStudentByUsername($application->username, $application->term); $tpl = array(); //If the application has been submitted plug in the date it was created if (isset($application->created_on)) { $tpl['RECEIVED_DATE'] = "Received on: " . date('d-F-Y h:i:s a', $application->created_on); } if ($application instanceof LotteryApplication && $application->getWaitingListDate() != null) { $tpl['WAITING_LIST_DATE'] = date("d-F-y h:i:sa", $application->getWaitingListDate()); } // Check if the application has been cancelled // isWithdrawn() has been depricated, but I'm leaving it here just for historical sake // on the off-chance that it catches an older application that's withdrawn but not cancelled. if ($application->isCancelled() || $application->isWithdrawn()) { NQ::simple('hms', hms\NotificationView::WARNING, 'This application has been cancelled.'); } $tpl['STUDENT_NAME'] = $student->getFullName(); $tpl['GENDER'] = $student->getPrintableGender(); $tpl['ENTRY_TERM'] = Term::toString($application->term); $tpl['CLASSIFICATION_FOR_TERM_LBL'] = $student->getPrintableClass(); $tpl['STUDENT_STATUS_LBL'] = $student->getPrintableType(); $tpl['MEAL_OPTION'] = HMS_Util::formatMealOption($application->meal_plan); if (isset($application->lifestyle_option)) { $tpl['LIFESTYLE_OPTION'] = $application->lifestyle_option == 1 ? 'Single gender' : 'Co-ed'; } else { $tpl['LIFESTYLE_OPTION'] = 'n/a'; } if (isset($application->preferred_bedtime)) { $tpl['PREFERRED_BEDTIME'] = $application->preferred_bedtime == 1 ? 'Early' : 'Late'; } else { $tpl['PREFERRED_BEDTIME'] = 'n/a'; } if (isset($application->room_condition)) { $tpl['ROOM_CONDITION'] = $application->room_condition == 1 ? 'Neat' : 'Cluttered'; } else { $tpl['ROOM_CONDITION'] = 'n/a'; } if (isset($application->smoking_preference)) { $tpl['SMOKING_PREFERENCE'] = $application->smoking_preference == 1 ? 'No' : 'Yes'; } else { $tpl['SMOKING_PREFERENCE'] = 'n/a'; } if (isset($application->room_type)) { $tpl['ROOM_TYPE'] = $application->room_type == ROOM_TYPE_DOUBLE ? 'Double' : 'Private (if available)'; } $tpl['CELLPHONE'] = ''; if (strlen($application->cell_phone) == 10) { $tpl['CELLPHONE'] .= '(' . substr($application->cell_phone, 0, 3) . ')'; $tpl['CELLPHONE'] .= '-' . substr($application->cell_phone, 3, 3); $tpl['CELLPHONE'] .= '-' . substr($application->cell_phone, 6, 4); } /* Emergency Contact */ $tpl['EMERGENCY_CONTACT_NAME'] = $application->getEmergencyContactName(); $tpl['EMERGENCY_CONTACT_RELATIONSHIP'] = $application->getEmergencyContactRelationship(); $tpl['EMERGENCY_CONTACT_PHONE'] = $application->getEmergencyContactPhone(); $tpl['EMERGENCY_CONTACT_EMAIL'] = $application->getEmergencyContactEmail(); $tpl['EMERGENCY_MEDICAL_CONDITION'] = $application->getEmergencyMedicalCondition(); /* Missing Person */ if (Current_User::allow('hms', 'view_missing_person_info')) { $tpl['MISSING_PERSON_NAME'] = $application->getMissingPersonName(); $tpl['MISSING_PERSON_RELATIONSHIP'] = $application->getMissingPersonRelationship(); $tpl['MISSING_PERSON_PHONE'] = $application->getMissingPersonPhone(); $tpl['MISSING_PERSON_EMAIL'] = $application->getMissingPersonEmail(); } /* Special Needs */ $special_needs = ""; if ($application->physical_disability == 1) { $special_needs = 'Physical disability<br />'; } if ($application->psych_disability) { $special_needs .= 'Psychological disability<br />'; } if ($application->medical_need) { $special_needs .= 'Medical need<br />'; } if ($application->gender_need) { $special_needs .= 'Gender need<br />'; } if ($special_needs == '') { $special_needs = 'None'; } $tpl['SPECIAL_NEEDS_RESULT'] = $special_needs; if ($application instanceof FallApplication) { PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $application->getTerm()); if (!is_null($rlcApp)) { $tpl['RLC_INTEREST_1'] = 'Yes (Completed - Use the main menu to view/modify.)'; } else { $tpl['RLC_INTEREST_1'] = $application->rlc_interest == 0 ? 'No' : 'Yes'; } } if (Current_User::getUsername() == "hms_student") { $tpl['MENU_LINK'] = PHPWS_Text::secureLink('Back to main menu', 'hms', array('type' => 'student', 'op' => 'show_main_menu')); } Layout::addPageTitle("Housing Application"); return PHPWS_Template::process($tpl, 'hms', 'admin/student_application.tpl'); }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Util.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $tpl = array(); $submitCmd = CommandFactory::getCommand('LotteryConfirm'); $submitCmd->setRoomId($this->roomId); $submitCmd->setMealPlan($this->mealPlan); $form = new PHPWS_Form(); $submitCmd->initForm($form); # Add the beds and user names back to the form so they end up in the request in a pretty way foreach ($this->roommates as $key => $value) { if (isset($value) && $value != '') { $form->addHidden("roommates[{$key}]", $value); } } # List the student's room PHPWS_Core::initModClass('hms', 'HMS_Room.php'); $room = new HMS_Room($this->roomId); $tpl['ROOM'] = $room->where_am_i(); # List all the students which will be assigned and their beds $beds = $room->get_beds(); foreach ($beds as $bed) { $bed_row = array(); # Check for an assignment $bed->loadAssignment(); # Check for a reservation $reservation = $bed->get_lottery_reservation_info(); $bedLabel = $room->getRoomNumber(); if ($room->get_number_of_beds() == 4) { $bedLabel = $bedLabel . $bed->getBedroomLabel(); } $bedLabel = $bedLabel . $bed->getLetter(); $bed_row['BED_LABEL'] = $bedLabel; $roommate = null; if ($bed->_curr_assignment != NULL) { # Bed is assigned $roommate = StudentFactory::getStudentByUsername($bed->_curr_assignment->asu_username, $this->term); $bed_row['TEXT'] = $roommate->getName(); } else { if ($reservation != NULL) { # Bed is reserved $roommate = StudentFactory::getStudentByUsername($reservation['asu_username'], $this->term); $bed_row['TEXT'] = $roommate->getName() . ' (reserved)'; } else { # Get the new roommate name out of the request if (!isset($this->roommates[$bed->id]) || $this->roommates[$bed->id] == '') { $bed_row['TEXT'] = 'Empty'; } else { $roommate = StudentFactory::getStudentByUsername($this->roommates[$bed->id], $this->term); $bed_row['TEXT'] = $roommate->getName() . ' ' . $this->roommates[$bed->id]; } } } $tpl['beds'][] = $bed_row; } # Show the meal plan $tpl['MEAL_PLAN'] = HMS_Util::formatMealOption($this->mealPlan); $form->addHidden('meal_plan', $this->mealPlan); PHPWS_Core::initCoreClass('Captcha.php'); $form->addTplTag('CAPTCHA_IMAGE', Captcha::get()); $form->addSubmit('submit_form', 'Confirm room & roommates'); $form->mergeTemplate($tpl); Layout::addPageTitle("Confirm Re-Application"); return PHPWS_Template::process($form->getTemplate(), 'hms', 'student/lottery_confirm.tpl'); }
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 fields for this HousingApplication parent class. Usually called by overriding methods in subclasses (e.g. SummerApplication). * * @return Array Array of fields for this HousingApplication. */ protected function unassignedStudentsFields() { $fields = array(); $fields['banner_id'] = $this->getBannerId(); $fields['username'] = $this->getUsername(); $fields['gender'] = HMS_Util::formatGender($this->getGender()); $fields['application_term'] = Term::toString($this->getApplicationTerm(), true); $fields['student_type'] = HMS_Util::formatType($this->getStudentType()); $fields['meal_plan'] = HMS_Util::formatMealOption($this->getMealPlan()); $fields['created_on'] = HMS_Util::get_long_date($this->getCreatedOn()); $roommate = HMS_Roommate::get_confirmed_roommate($this->getUsername(), $this->getTerm()); if (!is_null($roommate)) { $fields['roommate'] = $roommate->getFullName(); $fields['roommate_id'] = $roommate->getBannerId(); } else { $fields['roommate'] = ''; $fields['roommate_id'] = ''; } return $fields; }