/** * Constructor. * Requires a Checkin object to get started. * * @param Checkin $checkin */ public function __construct(Checkin $checkin) { $this->checkin = $checkin; $this->bannerId = $this->checkin->getBannerId(); $this->term = $this->checkin->getTerm(); $this->student = StudentFactory::getStudentByBannerId($this->bannerId, $this->term); // Lookup the student's housing application $this->application = HousingApplicationFactory::getAppByStudent($this->student, $this->term); // Create a dummy application if a real one doesn't exist if (!isset($this->application)) { $this->application = new HousingApplication(); } // Get the hall, floor, and room from the checkin's bed $this->bed = new HMS_Bed($this->checkin->getBedId()); $this->room = $this->bed->get_parent(); $this->floor = $this->room->get_parent(); $this->hall = $this->floor->get_parent(); // Get the damages at check-in time $this->checkinDamages = RoomDamageFactory::getDamagesBefore($this->room, $this->checkin->getCheckinDate() + Checkin::CHECKIN_TIMEOUT); if (sizeof($this->checkinDamages) <= 0) { $this->checkinDamages = array(); } // Get the damages at check-out time $this->checkoutDamages = RoomDamageFactory::getDamagesByRoom($this->room); if (sizeof($this->checkoutDamages) <= 0) { $this->checkoutDamages = array(); } }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'RoomDamageFactory.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'CheckinFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); $term = Term::getSelectedTerm(); // Get the total damages assessed for each student $damages = RoomDamageFactory::getAssessedDamagesStudentTotals($term); foreach ($damages as $dmg) { $student = StudentFactory::getStudentByBannerId($dmg['banner_id'], $term); // Get the student's last checkout // (NB: the damages may be for multiple check-outs, // but we'll just take the last one) $checkout = CheckinFactory::getLastCheckoutForStudent($student); $bed = new HMS_Bed($checkout->getBedId()); $room = $bed->get_parent(); $floor = $room->get_parent(); $hall = $floor->get_parent(); $coordinators = $hall->getCoordinators(); if ($coordinators != null) { $coordinatorName = $coordinators[0]->getDisplayName(); $coordinatorEmail = $coordinators[0]->getEmail(); } else { $coordinatorName = '(No coordinator set for this hall.)'; $coordinatorEmail = '(No coordinator set for this hall.)'; } HMS_Email::sendDamageNotification($student, $term, $dmg['sum'], $coordinatorName, $coordinatorEmail); } // Show a success message and redirect back to the main admin menu NQ::simple('hms', hms\NotificationView::SUCCESS, 'Room damage noties sent.'); $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu'); $cmd->redirect(); }
public function show() { $tpl = array(); // Check for an empty array of requests if (sizeof($this->requests) == 0) { $tpl['NO_REQUESTS'] = 'No pending requests found.'; return PHPWS_Template::process($tpl, 'hms', 'admin/roomChangeListView.tpl'); } javascriptMod('hms', 'livestamp'); $tpl['REQUESTS'] = array(); foreach ($this->requests as $request) { $row = array(); $participants = $request->getParticipants(); $participantNames = array(); foreach ($participants as $p) { $student = StudentFactory::getStudentByBannerId($p->getBannerId(), $this->term); $participantNames[] = $student->getName(); } $row['participants'] = implode(', ', $participantNames); $mgmtCmd = CommandFactory::getCommand('ShowManageRoomChange'); $mgmtCmd->setRequestId($request->getId()); $row['manage'] = $mgmtCmd->getURI(); $row['last_updated_timestamp'] = $request->getLastUpdatedTimestamp(); $row['last_updated_date'] = date("M j @ g:ia", $request->getLastUpdatedTimestamp()); $tpl['REQUESTS'][] = $row; } return PHPWS_Template::process($tpl, 'hms', 'admin/roomChangeListView.tpl'); }
public function execute() { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); if (!isset($this->term) || is_null($this->term)) { throw new InvalidArgumentException('Missing term.'); } $db = new PHPWS_DB('hms_new_application'); $db->addColumn('banner_id'); $db->addColumn('username'); $db->addWhere('term', $this->term); $results = $db->select(); if (empty($results)) { return; } elseif (PEAR::isError($results)) { throw new DatabaseException($results->toString()); } $twentyFiveYearsAgo = strtotime("-25 years"); foreach ($results as $student) { try { $sf = StudentFactory::getStudentByBannerId($student['banner_id'], $this->term); $dob = $sf->getDOB(); if (strtotime($dob) > $twentyFiveYearsAgo) { continue; } $student['dob'] = $dob; $student['full_name'] = $sf->getFullName(); $this->all_rows[] = $student; } catch (Exception $e) { $student['dob'] = $student['full_name'] = null; $this->problems[] = $student['banner_id']; } } }
public function execute(CommandContext $context) { // Check permissions if (!Current_User::allow('hms', 'checkin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to checkin students.'); } $term = Term::getSelectedTerm(); $bannerId = $context->get('bannerId'); $hallId = $context->get('hallId'); $errorCmd = CommandFactory::getCommand('ShowCheckinStart'); if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing Banner ID.'); $errorCmd->redirect(); } if (!isset($hallId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.'); $errorCmd->redirect(); } // Check the Banner ID if (preg_match("/[\\d]{9}/", $bannerId) == false) { NQ::simple('hms', hms\NotificationView::ERROR, 'Imporperly formatted Banner ID.'); $errorCmd->redirect(); } // Try to lookup the student in Banner try { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not locate a student with that Banner ID.'); $errorCmd->redirect(); } // Make sure the student is assigned in the current term $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $term); if (!isset($assignment) || is_null($assignment)) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' is not assigned for ' . Term::toString($term) . '. Please contact the University Housing Assignments Office at 828-262-6111.'); $errorCmd->redirect(); } // Make sure the student's assignment matches the hall the user selected $bed = $assignment->get_parent(); $room = $bed->get_parent(); $floor = $room->get_parent(); $hall = $floor->get_parent(); if ($hallId != $hall->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, 'Wrong hall! ' . $student->getName() . ' is assigned to ' . $assignment->where_am_i()); $errorCmd->redirect(); } // Load any existing check-in $checkin = CheckinFactory::getLastCheckinByBannerId($bannerId, $term); // If there is a checkin for the same bed, and the difference between the current time and the checkin time is // greater than 48 hours, then show an error. if (!is_null($checkin)) { $checkoutDate = $checkin->getCheckoutDate(); if ($checkin->getBedId() == $bed->getId() && !isset($checkoutDate) && time() - $checkin->getCheckinDate() > Checkin::CHECKIN_TIMEOUT) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' has already checked in to ' . $assignment->where_am_i()); $errorCmd->redirect(); } } $view = new CheckinFormView($student, $assignment, $hall, $floor, $room, $checkin); $context->setContent($view->show()); }
/** * * @param RoomChangeParticipant $participant The RoomChangeParticipant this view represents * @param RoomChangeRequest $request * @param array<RoomChangeParticipant> $participants All participants on this request */ public function __construct(RoomChangeParticipant $participant, RoomChangeRequest $request, array $participants) { $this->participant = $participant; $this->request = $request; $this->participants = $participants; $this->student = StudentFactory::getStudentByBannerId($this->participant->getBannerId(), Term::getSelectedTerm()); }
public function execute() { PHPWS_Core::initModClass('hms', 'HMS_Util.php'); $db = PdoFactory::getPdoInstance(); $query = 'SELECT hms_new_application.username, hms_new_application.banner_id, hms_lottery_application.early_release FROM hms_new_application JOIN hms_lottery_application ON hms_new_application.id = hms_lottery_application.id WHERE (hms_new_application.term = :term AND hms_lottery_application.early_release IS NOT NULL) ORDER BY hms_lottery_application.early_release ASC, hms_new_application.username ASC'; $stmt = $db->prepare($query); $stmt->execute(array('term' => $this->term)); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($results as $row) { $this->total++; if ($row['early_release'] == 'transfer') { $row['early_release'] = 'Transferring to another university'; $this->transferTotal++; } else { if ($row['early_release'] == 'grad') { $row['early_release'] = 'Graduating in December'; $this->gradTotal++; } else { if ($row['early_release'] == 'student_teaching') { $row['early_release'] = 'Student Teaching'; $this->teachingTotal++; } else { if ($row['early_release'] == 'internship') { $row['early_release'] = 'Internship'; $this->internTotal++; } else { if ($row['early_release'] == 'withdraw') { $row['early_release'] = 'Withdrawal'; $this->withdrawTotal++; } else { if ($row['early_release'] == 'marriage') { $row['early_release'] = 'Getting Married'; $this->marriageTotal++; } else { if ($row['early_release'] == 'study_abroad') { $row['early_release'] = 'Studying abroad for the Spring'; $this->abroadTotal++; } else { if ($row['early_release'] == 'intl_exchange') { $row['early_release'] = 'International Exchange Ending'; $this->internationalTotal++; } } } } } } } } $row['name'] = StudentFactory::getStudentByBannerId($row['banner_id'], $this->term)->getFullName(); $this->data[] = $row; } }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'CheckinFactory.php'); PHPWS_Core::initModClass('hms', 'RoomDamageFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModClass('hms', 'BedFactory.php'); $term = Term::getCurrentTerm(); $bannerId = $context->get('bannerId'); $hallId = $context->get('hallId'); $errorCmd = CommandFactory::getCommand('ShowCheckoutStart'); if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing student ID.'); $errorCmd->redirect(); } if (!isset($hallId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.'); $errorCmd->redirect(); } // If search string is all numeric, make sure it looks like a valid Banner ID if (is_numeric($bannerId) && preg_match("/[\\d]{9}/", $bannerId) == false) { NQ::simple('hms', hms\NotificationView::ERROR, 'Imporperly formatted Banner ID.'); $errorCmd->redirect(); } // Try to lookup the student in Banner try { // If it's all numeric assume it's a student ID, otherwise assume it's a username if (is_numeric($bannerId) && strlen((string) $bannerId) == 9) { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } else { $student = StudentFactory::getStudentByUsername($bannerId, $term); } } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not locate a student with that Banner ID.'); $errorCmd->redirect(); } // Find the earliest checkin that matches hall the user selected $hall = new HMS_Residence_Hall($hallId); $checkin = CheckinFactory::getPendingCheckoutForStudentByHall($student, $hall); if (!isset($checkin)) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, we couldn't find a matching check-in at {$hall->getHallName()} for this student to check-out of."); $errorCmd->redirect(); } $bed = BedFactory::getBedByPersistentId($checkin->getBedPersistentId(), $term); $room = $bed->get_parent(); // Get the damages for this student's room $damages = RoomDamageFactory::getDamagesByRoom($room); PHPWS_Core::initModClass('hms', 'CheckoutFormView.php'); $view = new CheckoutFormView($student, $hall, $room, $bed, $damages, $checkin); $context->setContent($view->show()); }
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() { $term = Term::getCurrentTerm(); $student = StudentFactory::getStudentByBannerId($this->checkin->getBannerId(), $term); $bed = new HMS_Bed($this->checkin->getBedId()); $tpl = array(); $tpl['NAME'] = $student->getName(); $tpl['ASSIGNMENT'] = $bed->where_am_i(); $pdfCmd = CommandFactory::getCommand('GenerateInfoCard'); $pdfCmd->setCheckinId($this->checkin->getId()); $tpl['INFO_CARD_LINK'] = $pdfCmd->getLink('Resident Information Card', '_blank'); return PHPWS_Template::process($tpl, 'hms', 'admin/checkinComplete.tpl'); }
public function execute(CommandContext $context) { // Get input $requestId = $context->get('requestId'); $participantId = $context->get('participantId'); // Command for showing the request, redirected to on success/error $cmd = CommandFactory::getCommand('ShowManageRoomChange'); $cmd->setRequestId($requestId); // Load the request $request = RoomChangeRequestFactory::getRequestById($requestId); // Load the participant $participant = RoomChangeParticipantFactory::getParticipantById($participantId); // Load the Student $student = StudentFactory::getStudentByBannerId($participant->getBannerId(), $request->getTerm()); // Check permissions. Must be the participant or an admin if (UserStatus::getUsername() != $student->getUsername() && !Current_User::allow('hms', 'admin_approve_room_change')) { throw new PermissionException('You do not have permission to appove this room change.'); } // Check for CAPTCHA if this is the student; admins don't need a CAPTCHA $captchaResult = Captcha::verify(true); if (UserStatus::getUsername() == $student->getUsername() && $captchaResult === false) { // Failed the captcha NQ::simple('hms', hms\NotificationView::ERROR, "You didn't type the magic words correctly. Please try again."); $cmd = CommandFactory::getCommand('ShowRoomChangeRequestApproval'); $cmd->redirect(); } // If there was a captcha, then log the activity if ($captchaResult !== false) { HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_ROOM_CHANGE_AGREED, UserStatus::getUsername(FALSE), 'Request id: ' . $requestId . ' Captcha: ' . $captchaResult); } // Transition to StudentApproved state $participant->transitionTo(new ParticipantStateStudentApproved($participant, time(), null, UserStatus::getUsername())); // If all students have approved, notify RDs if ($request->isApprovedByAllParticipants()) { HMS_Email::sendRoomChangeCurrRDNotice($request); } // If the student is logged in, redirect to the main menu, other wise go back to the room change management view if (UserStatus::getUsername() == $student->getUsername()) { NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have agreed to the room change request. You will be notified by email when the reqeust is approved or denied.'); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $menuCmd->redirect(); } else { $cmd->redirect(); } }
public function execute() { $db = new PHPWS_DB(); $query = <<<EOF SELECT assign.banner_id, assign.asu_username, bed.bed_letter, bed.bedroom_label, room.room_number, floor.floor_number, hall.hall_name FROM hms_assignment as assign LEFT JOIN hms_bed as bed on assign.bed_id=bed.id LEFT JOIN hms_room as room on bed.room_id=room.id LEFT JOIN hms_floor as floor on room.floor_id=floor.id LEFT JOIN hms_residence_hall as hall on floor.residence_hall_id=hall.id WHERE assign.term = '{$this->term}' ORDER BY hall.hall_name, floor.floor_number, room.room_number, bed.bedroom_label, bed.bed_letter EOF; $result = $db->select(null, $query); if (PEAR::isError($result)) { throw new DatabaseException($result->toString()); } $final_rows = array(); foreach ($result as $row) { $hall_name = $row['hall_name']; $student = StudentFactory::getStudentByBannerId($row['banner_id'], $this->term); $row['name'] = $student->getFullName(); $row['dob'] = $student->getDOB(); $row['year'] = $student->getClass(); $row['gender'] = HMS_Util::formatGender($student->getGender()); $final_rows[$hall_name][] = $row; } $this->rows =& $final_rows; }
public function execute() { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $this->data = array(); $query = "SELECT hms_assignment.id, hms_assignment.banner_id, hms_assignment.asu_username, hms_new_application.cell_phone, hms_room.room_number, hms_floor.floor_number, hms_residence_hall.hall_name FROM hms_assignment LEFT JOIN (SELECT username, MAX(term) AS mterm FROM hms_new_application GROUP BY username) AS a ON hms_assignment.asu_username = a.username LEFT JOIN hms_new_application ON a.username = hms_new_application.username AND a.mterm = hms_new_application.term LEFT JOIN hms_bed ON hms_assignment.bed_id = hms_bed.id LEFT JOIN hms_room ON hms_bed.room_id = hms_room.id LEFT JOIN hms_floor ON hms_room.floor_id = hms_floor.id LEFT JOIN hms_residence_hall ON hms_floor.residence_hall_id = hms_residence_hall.id WHERE ( hms_assignment.term = {$this->term}) ORDER BY hms_residence_hall.id ASC"; $results = PHPWS_DB::getAll($query); if (PHPWS_Error::logIfError($results)) { throw new DatabaseException($results->toString()); } foreach ($results as $result) { try { $student = StudentFactory::getStudentByBannerId($result['banner_id'], $this->term); } catch (Exception $e) { $this->data[] = array($result['hall_name'], $result['floor_number'], $result['room_number'], 'ERROR', 'ERROR', 'ERROR', $result['cell_phone'], $result['asu_username'] . "@appstate.edu"); continue; } $this->data[] = array($result['hall_name'], $result['floor_number'], $result['room_number'], $student->getLastName(), $student->getFirstName(), $result['banner_id'], $result['cell_phone'], $result['asu_username'] . "@appstate.edu"); } }
public function show() { $terms = HousingApplication::getAvailableApplicationTermsForStudent($this->student); $applications = HousingApplication::getAllApplicationsForStudent($this->student); $tpl = array(); foreach ($terms as $t) { # If the student has a withdrawn application, # then show a message instead of the normal menu block. if (isset($applications[$t['term']]) && $applications[$t['term']]->isCancelled()) { $termBlock = new StudentMenuWithdrawnTermBlock($this->student, $t['term']); } else { // Look up the student again in each term, because student type can change depending on which term we ask about $student = StudentFactory::getStudentByBannerId($this->student->getBannerId(), $t['term']); $termBlock = new StudentMenuTermBlock($student, $t['term']); } $tpl['TERMBLOCK'][] = array('TERMBLOCK_CONTENT' => $termBlock->show()); } Layout::addPageTitle("Main Menu"); return PHPWS_Template::process($tpl, 'hms', 'student/freshmenMenu.tpl'); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'lottery_admin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to administer re-application features.'); } PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $bannerIds = $context->get('banner_ids'); $term = Term::getSelectedTerm(); $bannerIds = explode("\n", $bannerIds); foreach ($bannerIds as $bannerId) { // Trim any excess whitespace $bannerId = trim($bannerId); // Skip blank lines if ($bannerId == '') { continue; } $student = StudentFactory::getStudentByBannerId($bannerId, $term); try { $application = HousingApplicationFactory::getAppByStudent($student, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "No matching student was found for: {$bannerId}"); continue; } if (is_null($application)) { NQ::simple('hms', hms\NotificationView::ERROR, "No housing application for: {$bannerId}"); continue; } $application->magic_winner = 1; try { $application->save(); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, "Error setting flag for: {$bannerId}"); continue; } NQ::simple('hms', hms\NotificationView::SUCCESS, "Magic flag set for: {$bannerId}"); } $viewCmd = CommandFactory::getCommand('ShowLotteryAutoWinners'); $viewCmd->redirect(); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assignment_maintenance')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to assign students.'); } PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); $term = Term::getSelectedTerm(); try { if (preg_match('/^[0-9]{9}$/', $context->get('username'))) { $student = StudentFactory::getStudentByBannerId($context->get('username'), $term); } else { $student = StudentFactory::getStudentByUsername(strtolower(trim($context->get('username'))), $term); } } catch (StudentNotFoundException $e) { echo json_encode(array('success' => false, 'message' => $e->getMessage())); exit; } catch (Exception $e) { echo json_encode(array('success' => false, 'message' => $e->getMessage())); exit; } $bed = $context->get('bed'); $plan = $context->get('mealplan'); $reason = $context->get('assignmenttype'); if (HMS_Assignment::checkForAssignment($student->getUsername(), $term)) { echo json_encode(array('success' => false, 'message' => 'Error: Student is already assigned elsewhere, please unassign this student first.')); exit; } try { HMS_Assignment::assignStudent($student, $term, NULL, $bed, $plan, '', false, $reason); } catch (AssignmentException $e) { echo json_encode(array('success' => false, 'message' => $e->getMessage())); exit; } echo json_encode(array('success' => true, 'message' => 'Student assigned!')); exit; }
public function show() { $approveCmd = CommandFactory::getCommand('RoomChangeStudentApprove'); $approveCmd->setParticipantId($this->thisParticipant->getId()); $approveCmd->setRequestId($this->request->getId()); $declineCmd = CommandFactory::getCommand('RoomChangeStudentDecline'); $declineCmd->setParticipantId($this->thisParticipant->getId()); $declineCmd->setRequestId($this->request->getId()); $form = new PHPWS_Form('roomchange_student_approve'); $form->addHidden('foo', 'bar'); $tpl = $form->getTemplate(); $tpl['APPROVE_URI'] = $approveCmd->getURI(); $tpl['DECLINE_URI'] = $declineCmd->getURI(); $requestor = StudentFactory::getStudentByUsername($this->request->getState()->getCommittedBy(), $this->term); $tpl['REQUESTOR'] = $requestor->getName(); // Build the table showing who is moving from/to which beds $participantRows = array(); foreach ($this->participants as $p) { $row = array(); $student = StudentFactory::getStudentByBannerId($p->getBannerId(), $this->term); $row['NAME'] = $student->getName(); // If this participant is the person logged in, bold their name if ($student->getBannerId() == $this->thisParticipant->getBannerId()) { $row['STRONG_STYLE'] = 'success'; } else { $row['STRONG_STYLE'] = ''; } $fromBed = new HMS_Bed($p->getFromBed()); $toBed = new HMS_Bed($p->getToBed()); $row['FROM_BED'] = $fromBed->where_am_i(); $row['TO_BED'] = $toBed->where_am_i(); $participantRows[] = $row; } $tpl['PARTICIPANTS'] = $participantRows; PHPWS_Core::initCoreClass('Captcha.php'); $tpl['CAPTCHA'] = Captcha::get(); return PHPWS_Template::process($tpl, 'hms', 'student/roomChangeRequestStudentApprove.tpl'); }
public function execute(CommandContext $context) { // Check permissions if (!Current_User::allow('hms', 'checkin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to checkin students.'); } PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $term = Term::getCurrentTerm(); $bannerId = $context->get('banner_id'); $hallId = $context->get('residence_hall_hidden'); $errorCmd = CommandFactory::getCommand('ShowCheckinStart'); if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing Banner ID.'); $errorCmd->redirect(); } if (!isset($hallId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.'); $errorCmd->redirect(); } if (preg_match("/^[\\d]{9}\$/", $bannerId) == false) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, that didn't look like a valid ID number. Please try again."); $errorCmd->redirect(); } // Try to lookup the student in Banner try { StudentFactory::getStudentByBannerId($bannerId, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not locate a student with that Banner ID.'); $errorCmd->redirect(); } // Everything checks out, so redirect to the form $cmd = CommandFactory::getCommand('ShowCheckinForm'); $cmd->setBannerId($bannerId); $cmd->setHallId($hallId); $cmd->redirect(); }
public function execute() { PHPWS_Core::initModClass('hms', 'PdoFactory.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $db = PdoFactory::getInstance()->getPdo(); $query = "select hall_name, room_number, hms_room_damage_responsibility.banner_id, amount, hms_damage_type.description, to_timestamp(CAST(assessed_on as integer)), assessed_by, hms_room_damage.note from hms_room_damage_responsibility JOIN hms_room_damage ON hms_room_damage_responsibility.damage_id = hms_room_damage.id JOIN hms_room ON (hms_room.persistent_id = hms_room_damage.room_persistent_id AND hms_room_damage.term = hms_room.term) JOIN hms_floor ON hms_room.floor_id = hms_floor.id JOIN hms_residence_hall ON hms_floor.residence_hall_id = hms_residence_hall.id JOIN hms_damage_type ON hms_room_damage.damage_type = hms_damage_type.id WHERE hms_room_damage.term = :term and state = 'assessed' and amount != 0 ORDER BY assessed_on, banner_id"; $stmt = $db->prepare($query); $stmt->execute(array('term' => $this->term)); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($results as $row) { try { $student = StudentFactory::getStudentByBannerId($row['banner_id'], $this->term); $row['first_name'] = $student->getFirstName(); $row['last_name'] = $student->getLastName(); $row['email'] = $student->getUsername(); } catch (StudentNotFoundException $e) { $row['first_name'] = 'NOT FOUND'; $row['last_name'] = 'NOT FOUND'; $row['email'] = 'NOT FOUND'; } $this->rows[] = $row; } }
public function execute() { PHPWS_Core::initModClass('hms', 'PdoFactory.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $db = PdoFactory::getInstance()->getPdo(); $query = " select hms_assignment.banner_id, hall_name, floor_number, room_number from hms_assignment join hms_bed on hms_assignment.bed_id = hms_bed.id join hms_room on hms_bed.room_id = hms_room.id join hms_floor on hms_room.floor_id = hms_floor.id join hms_residence_hall on hms_floor.residence_hall_id = hms_residence_hall.id where hms_bed.ra = 1 and hms_assignment.term = :term"; $stmt = $db->prepare($query); $stmt->execute(array('term' => $this->term)); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($results as $row) { try { $student = StudentFactory::getStudentByBannerId($row['banner_id'], $this->term); $row['first_name'] = $student->getFirstName(); $row['last_name'] = $student->getLastName(); $row['email'] = $student->getUsername(); } catch (StudentNotFoundException $e) { $row['first_name'] = 'NOT FOUND'; $row['last_name'] = 'NOT FOUND'; $row['email'] = 'NOT FOUND'; } $this->rows[] = $row; } }
public function execute() { PHPWS_Core::initModClass('hms', 'PdoFactory.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $db = PdoFactory::getInstance()->getPdo(); $query = "select hall_name, room_number, hms_checkin.banner_id, to_timestamp(checkout_date), checkout_by from hms_checkin JOIN hms_bed ON (hms_checkin.bed_persistent_id = hms_bed.persistent_id AND hms_checkin.term = hms_bed.term) JOIN hms_room ON hms_bed.room_id = hms_room.id JOIN hms_floor ON hms_room.floor_id = hms_floor.id JOIN hms_residence_hall ON hms_floor.residence_hall_id = hms_residence_hall.id WHERE hms_checkin.term = :term and key_not_returned = 1 ORDER BY checkout_date"; $stmt = $db->prepare($query); $stmt->execute(array('term' => $this->term)); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($results as $row) { try { $student = StudentFactory::getStudentByBannerId($row['banner_id'], $this->term); $row['first_name'] = $student->getFirstName(); $row['last_name'] = $student->getLastName(); $row['email'] = $student->getUsername(); } catch (StudentNotFoundException $e) { $row['first_name'] = 'NOT FOUND'; $row['last_name'] = 'NOT FOUND'; $row['email'] = 'NOT FOUND'; } $this->rows[] = $row; } }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'search')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to search for students.'); } PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'StudentProfile.php'); $username = $context->get('username'); $bannerId = $context->get('bannerId'); $term = Term::getSelectedTerm(); try { if (isset($bannerId)) { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } else { $student = StudentFactory::getStudentByUsername($username, $term); } } catch (InvalidArgumentException $e) { NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage()); /* $cmd = CommandFactory::getCommand('ShowStudentSearch'); $cmd->setUsername($userid); $cmd->redirect(); */ $context->goBack(); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage()); /* $cmd = CommandFactory::getCommand('ShowStudentSearch'); $cmd->setUsername($userid); $cmd->redirect(); */ $context->goBack(); } $profile = new StudentProfile($student, $term); $context->setContent($profile->getProfileView()->show()); }
public function execute(CommandContext $context) { // Get input $requestId = $context->get('requestId'); $participantId = $context->get('participantId'); // Load the request $request = RoomChangeRequestFactory::getRequestById($requestId); // Load the participant $participant = RoomChangeParticipantFactory::getParticipantById($participantId); // Load the Student $student = StudentFactory::getStudentByBannerId($participant->getBannerId(), $request->getTerm()); // Check permissions. Must be the participant or an admin if (UserStatus::getUsername() != $student->getUsername() && !Current_User::allow('hms', 'admin_approve_room_change')) { throw new PermissionException('You do not have permission to decline this room change.'); } // Check for CAPTCHA if this is the student; admins don't need a CAPTCHA $captchaResult = Captcha::verify(true); if ($captchaResult === false) { // Failed the captcha NQ::simple('hms', hms\NotificationView::ERROR, "You didn't type the magic words correctly. Please try again."); $cmd = CommandFactory::getCommand('ShowRoomChangeRequestApproval'); $cmd->redirect(); } HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_ROOM_CHANGE_DECLINE, UserStatus::getUsername(FALSE), 'Request id: ' . $requestId . ' Captcha: ' . $captchaResult); // Transition request to cancelled status $request->transitionTo(new RoomChangeStateCancelled($request, time(), null, UserStatus::getUsername())); // Transition all participants to cancelled // TODO... Do this in the cancelled transition? $participants = $request->getParticipants(); foreach ($participants as $p) { $p->transitionTo(new ParticipantStateCancelled($p, time(), null, UserStatus::getUsername())); } // TODO Notify everyone that the request was cancelled NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have declined the room change request.'); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $menuCmd->redirect(); }
public function allParticipantsCheckedIn() { // Make sure each participant is checked-into his/her current assignment foreach ($this->getParticipants() as $participant) { // Load the 'from' Bed object $bed = new HMS_Bed($participant->getFromBed()); // Load the student $student = StudentFactory::getStudentByBannerId($participant->getBannerId(), Term::getSelectedTerm()); // Search for the check-in $checkin = CheckinFactory::getCheckinByBed($student, $bed); if ($checkin == null || $checkin != null && $checkin->getCheckoutDate() != null) { return false; } } return true; }
private function getSummary(array $assignments) { // Create the summary array for this set of assignments and initialize it $summary = array(); $this->initializeArray($summary); foreach ($assignments as $assign) { // Create the student object //TODO use banner IDs try { $student = StudentFactory::getStudentByBannerId($assign['banner_id'], $this->term); } catch (Exception $e) { $this->problems[] = $assign['banner_id'] . ': Unknown student'; $summary['OTHER']++; continue; } // Get the student's gener in numeric form $gender = $student->getGender(); // Check the gender for bad data if (!isset($gender) || $gender === NULL || $gender != MALE && $gender != FEMALE) { $this->problems[] = $assign['asu_username'] . ': Gender is unrecognized (' . $gender . ')'; $summary['OTHER']++; continue; } # Get the class of the student for this assignment $class = $student->getClass(); # Check the class for bad data if (!isset($class) || $class === NULL || $class != CLASS_FRESHMEN && $class != CLASS_SOPHOMORE && $class != CLASS_JUNIOR && $class != CLASS_SENIOR) { //$this->problems[] = $assign['asu_username'] . ': Class is unrecognized ('. $class .')'; $summary['OTHER']++; continue; } // Get the type of the student for this assignment $type = $student->getType(); // Check the type for bad data if (!isset($type) || $type === NULL || $type != TYPE_FRESHMEN && $type != TYPE_TRANSFER && $type != TYPE_CONTINUING && $type != TYPE_READMIT && $type != TYPE_RETURNING) { //$this->problems[] = $assign['asu_username'] . ': Type is unrecognized ('. $type .')'; $summary['OTHER']++; continue; } // Force returing and re-admit types to be type continuing if ($type == TYPE_RETURNING || $type == TYPE_READMIT) { $type = TYPE_CONTINUING; } // If student type is freshmen, force class to freshmen if ($type == TYPE_FRESHMEN) { $class = CLASS_FRESHMEN; } $summary[$type][$class][$gender]++; } return $summary; }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'add_rlc_members')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to view RLC members.'); } PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'RlcApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php'); // Get the selected term $term = Term::getSelectedTerm(); // Get the request community $communityId = $context->get('communityId'); if (!isset($communityId) || $communityId == '') { throw new InvalidArgumentException('Missing community id.'); } $community = new HMS_Learning_Community($communityId); // Get banner ID list and make sure it has content $bannerIds = $context->get('banner_id_list'); if (!isset($bannerIds) || $bannerIds == '') { $errorCmd = CommandFactory::getCommand('ShowAdminAddRlcMember'); $errorCmd->setCommunity($community); $errorCmd->redirect(); } // Break up string into an array of individual ids $bannerIds = explode("\n", $bannerIds); foreach ($bannerIds as $banner) { // Clean up the banner id $banner = trim($banner); // Skip blank lines if ($banner == '') { continue; } // Get the student try { $student = StudentFactory::getStudentByBannerId($banner, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "Couldn't find a student with ID: {$e->getRequestedId()}"); continue; } catch (InvalidArgumentException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "This doesn't look like a banner ID: {$banner}"); continue; } // Check for an existing housing application $housingApp = HousingApplicationFactory::getAppByStudent($student, $term); // If no housing app, show a warning if (is_null($housingApp)) { NQ::simple('hms', hms\NotificationView::WARNING, "No housing application found for: {$student->getName()}({$student->getBannerID()})"); } // Check for an existing learning community application $rlcApp = RlcApplicationFactory::getApplication($student, $term); if ($rlcApp == null) { // Create a new learning community application $rlcApp = new HMS_RLC_Application(); $rlcApp->setUsername($student->getUsername()); $rlcApp->setDateSubmitted(time()); $rlcApp->setFirstChoice($community->getId()); $rlcApp->setSecondChoice(null); $rlcApp->setThirdChoice(null); $rlcApp->setWhySpecificCommunities('Application created administratively.'); $rlcApp->setStrengthsWeaknesses(''); $rlcApp->setRLCQuestion0(null); $rlcApp->setRLCQuestion1(null); $rlcApp->setRLCQuestion2(null); $rlcApp->setEntryTerm($term); if ($student->getType() == TYPE_CONTINUING) { $rlcApp->setApplicationType(RLC_APP_RETURNING); } else { $rlcApp->setApplicationType(RLC_APP_FRESHMEN); } $rlcApp->save(); } else { // Reset the application's denial flag, see #1026 $rlcApp->setDenied(0); $rlcApp->save(); // RLC application already exists NQ::simple('hms', hms\NotificationView::WARNING, "RLC application already exists for {$student->getName()}({$student->getBannerID()})"); } // Check for RLC membership $membership = RlcMembershipFactory::getMembership($student, $term); if ($membership !== false) { NQ::simple('hms', hms\NotificationView::ERROR, "RLC membership already exists for {$student->getName()}({$student->getBannerID()})"); continue; } // Check Student's Eligibility $eligibility = HMS_Lottery::determineEligibility($student->getUsername()); if ($eligibility == false) { NQ::simple('hms', hms\NotificationView::ERROR, "{$student->getName()} ({$student->getBannerID()}) is not currently eligible for housing"); continue; } // Create RLC Membership $membership = new HMS_RLC_Assignment(); $membership->rlc_id = $community->getId(); $membership->gender = $student->getGender(); $membership->assigned_by = UserStatus::getUsername(); $membership->application_id = $rlcApp->id; $membership->state = 'new'; $membership->save(); } $successCmd = CommandFactory::getCommand('ShowViewByRlc'); $successCmd->setRlcId($community->getId()); $successCmd->redirect(); }
public function execute(CommandContext $context) { // Check permissions if (!Current_User::allow('hms', 'checkin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to checkin students.'); } $bannerId = $context->get('bannerId'); $hallId = $context->get('hallId'); // Check for key code $keyCode = $context->get('key_code'); if (!isset($keyCode) || $keyCode == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Please enter a key code.'); $errorCmd = CommandFactory::getCommand('ShowCheckinForm'); $errorCmd->setBannerId($bannerId); $errorCmd->setHallId($hallId); $errorCmd->redirect(); } $term = Term::getSelectedTerm(); // Lookup the student $student = StudentFactory::getStudentByBannerId($bannerId, $term); // Get the student's current assignment $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $term); $bed = $assignment->get_parent(); // Get the currently logged in user $currUser = Current_User::getUsername(); // Check for an existing Check-in $checkin = CheckinFactory::getCheckinByBed($student, $bed); // If there's not already a checkin for this bed, create a new one if (is_null($checkin)) { $checkin = new Checkin($student, $bed, $term, $currUser, $keyCode); } else { if ($checkin->getBedId() == $bed->getId() && time() - $checkin->getCheckinDate() < Checkin::CHECKIN_TIMEOUT) { // Check-in already exists, and it's within the timout window, so we'll overwrite the existing checkin $updatedCheckin = new Checkin($student, $bed, $term, $currUser, $keyCode); $updatedCheckin->substitueForExistingCheckin($checkin); // Use the old checkin to replace this one $checkin = $updatedCheckin; } else { // There's an existing checkin, but it's after the timeout, so we need to make a new checkin $checkin = new Checkin($student, $bed, $term, $currUser, $keyCode); } } $checkin->save(); // Add this to the activity log HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_CHECK_IN, UserStatus::getUsername(), $assignment->where_am_i()); // Generate the RIC PHPWS_Core::initModClass('hms', 'InfoCard.php'); PHPWS_Core::initModClass('hms', 'InfoCardPdfView.php'); $infoCard = new InfoCard($checkin); $infoCardView = new InfoCardPdfView(); $infoCardView->addInfoCard($infoCard); // Send confirmation Email with the RIC form to the student PHPWS_Core::initModClass('hms', 'HMS_Email.php'); HMS_Email::sendCheckinConfirmation($student, $infoCard, $infoCardView); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Checkin successful.'); // Redirect to success page with option to print check-in document. $cmd = CommandFactory::getCommand('ShowCheckinDocument'); $cmd->setBannerId($student->getBannerId()); $cmd->setCheckinId($checkin->getId()); $cmd->redirect(); }
public function execute(CommandContext $context) { $term = $context->get('term'); if (!isset($term)) { throw new InvalidArgumentException('Missing term.'); } // Get the list of floors which the current user has permission to assess // Get the list of role memberships this user has $hms_perm = new HMS_Permission(); $memberships = $hms_perm->getMembership('assess_damage', NULL, UserStatus::getUsername()); if (empty($memberships)) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException("You do not have permission to assess damages on any residence halls or floors."); } // Use the roles to instantiate a list of floors this user has access to $floors = array(); foreach ($memberships as $member) { if ($member['class'] == 'hms_residence_hall') { $hall = new HMS_Residence_Hall($member['instance']); if (!is_array($floors)) { $floors = array(); } $hallFloors = $hall->getFloors(); if (!is_array($hallFloors)) { $hallFloors = array(); } $floors = array_merge($floors, $hallFloors); } else { if ($member['class'] == 'hms_floor') { $floors[] = new HMS_Floor($member['instance']); } else { throw new Exception('Unknown object type.'); } } } // Remove duplicate floors $uniqueFloors = array(); foreach ($floors as $floor) { $uniqueFloors[$floor->getId()] = $floor; } // Filter the list of floors for just the term we're interested in foreach ($uniqueFloors as $k => $f) { if ($f->getTerm() != $term) { unset($uniqueFloors[$k]); } } // Get the list of damages with pending assessments on those floors $damages = RoomDamageFactory::getDamagesToAssessByFloor($uniqueFloors, $term); $roomList = array(); // For each damage, get the list of responsible students foreach ($damages as &$dmg) { $pId = $dmg->getRoomPersistentId(); $dmg->responsibilities = RoomDamageResponsibilityFactory::getResponsibilitiesByDmg($dmg); foreach ($dmg->responsibilities as &$resp) { $student = StudentFactory::getStudentByBannerId($resp->getBannerId(), $term); $resp->studentName = $student->getName(); } $roomList[$dmg->getRoomPersistentId()][] = $dmg; } $rooms = array(); foreach ($roomList as $pId => $dmgList) { $roomObj = RoomFactory::getRoomByPersistentId($pId, $term); $roomObj->hallName = $roomObj->get_parent()->get_parent()->getHallName(); $roomObj->damages = $dmgList; $rooms[] = $roomObj; } // JSON enocde it all and send it to Angular $context->setContent(json_encode($rooms)); }
public function execute() { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $db = new PHPWS_DB('hms_assignment'); $db->addColumn('hms_assignment.banner_id'); $db->addColumn('hms_assignment.reason'); $db->addColumn('hms_residence_hall.hall_name'); $db->addColumn('hms_room.room_number'); $db->addColumn('hms_new_application.cell_phone'); $db->addWhere('hms_assignment.term', $this->term); $db->addJoin('LEFT OUTER', 'hms_assignment', 'hms_bed', 'bed_id', 'id'); $db->addJoin('LEFT OUTER', 'hms_bed', 'hms_room', 'room_id', 'id'); $db->addJoin('LEFT OUTER', 'hms_room', 'hms_floor', 'floor_id', 'id'); $db->addJoin('LEFT OUTER', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id'); $db->addJoin('LEFT OUTER', 'hms_assignment', 'hms_new_application', 'banner_id', 'banner_id AND hms_assignment.term = hms_new_application.term'); $results = $db->select(); if (PHPWS_Error::logIfError($results)) { return $results; } foreach ($results as $row) { try { $student = StudentFactory::getStudentByBannerId($row['banner_id'], $this->term); $bannerId = $student->getBannerId(); $username = $student->getUsername(); $first = $student->getFirstName(); $middle = $student->getMiddleName(); $last = $student->getLastName(); $type = $student->getType(); $appTerm = $student->getApplicationTerm(); $cellPhone = $row['cell_phone']; $assignmentType = $row['reason']; $gender = HMS_Util::formatGender($student->getGender()); $dob = $student->getDob(); $room = $row['hall_name'] . ' ' . $row['room_number']; $address = $student->getAddress(NULL); if (!$address || !isset($address) || is_null($address)) { $line1 = ""; $line2 = ""; $line3 = ""; $city = ""; $state = ""; $zip = ""; } else { $line1 = $address->line1; $line2 = $address->line2; $line3 = $address->line3; $city = $address->city; $state = $address->state; $zip = $address->zip; } } catch (StudentNotFoundException $e) { $bannerId = $row['banner_id']; $username = ''; $first = ''; $middle = ''; $last = ''; $gender = ''; $dob = ''; $type = ''; $cellPhone = ''; $line1 = ''; $line2 = ''; $line3 = ''; $city = ''; $state = ''; $zip = ''; $appTerm = ''; $assignmentType = ''; $room = ''; } $this->rows[] = array($username, $bannerId, $first, $middle, $last, $gender, $dob, $type, $appTerm, $cellPhone, $assignmentType, $room, $line1, $line2, $line3, $city, $state, $zip); } }
public function execute(CommandContext $context) { // Get input $requestId = $context->get('requestId'); // Get the current term $term = Term::getCurrentTerm(); // Load the request $request = RoomChangeRequestFactory::getRequestById($requestId); // Load the participants $participants = $request->getParticipants(); // Make sure everyone is checked into their current assignments if (!$request->allParticipantsCheckedIn()) { // Return the user to the room change request page // NB, don't need an error message here because it should already be printed // by the RoomChangeParticipantView. $cmd = CommandFactory::getCommand('ShowManageRoomChange'); $cmd->setRequestId($requestId); $cmd->redirect(); } // Transition the request to 'Approved' $request->transitionTo(new RoomChangeStateApproved($request, time(), null, UserStatus::getUsername())); // Remove each participants existing assignment foreach ($participants as $participant) { $bannerId = $participant->getBannerId(); // Lookup the student $student = StudentFactory::getStudentByBannerId($bannerId, $term); // Save student object for later $this->students[$bannerId] = $student; // Save student's current assignment reason for later re-use $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $term); //TODO - Student might not be assigned!! $this->assignmentReasons[$bannerId] = $assignment->getReason(); // Remove existing assignment // TODO: Don't hard code refund percentage HMS_Assignment::unassignStudent($student, $term, 'Room Change Request Approved', UNASSIGN_CHANGE, 100); } // Create new assignments for each participant foreach ($participants as $participant) { // Grab the student object which was previously saved $student = $this->students[$participant->getBannerId()]; // Create each new assignment HMS_Assignment::assignStudent($student, $term, null, $participant->getToBed(), BANNER_MEAL_STD, 'Room Change Approved', FALSE, $this->assignmentReasons[$bannerId]); // Release bed reservation $bed = new HMS_Bed($participant->getToBed()); $bed->clearRoomChangeReserved(); $bed->save(); } // Transition each participant to 'In Process' foreach ($participants as $participant) { $participant->transitionTo(new ParticipantStateInProcess($participant, time(), null, UserStatus::getUsername())); // TODO: Send notifications } // Notify everyone that they can do the move HMS_Email::sendRoomChangeInProcessNotice($request); // Notify roommates that their circumstances are going to change foreach ($request->getParticipants() as $p) { $student = $this->students[$p->getBannerId()]; // New Roommate $newbed = new HMS_Bed($p->getToBed()); $newroom = $newbed->get_parent(); foreach ($newroom->get_assignees() as $a) { if ($a instanceof Student && $a->getBannerID() != $p->getBannerID()) { HMS_Email::sendRoomChangeApprovedNewRoommateNotice($a, $student); } } // Old Roommate $oldbed = new HMS_Bed($p->getFromBed()); $oldroom = $oldbed->get_parent(); foreach ($oldroom->get_assignees() as $a) { if ($a instanceof Student && $a->getBannerID() != $p->getBannerID()) { HMS_Email::sendRoomChangeApprovedOldRoommateNotice($a, $student); } } } // Return the user to the room change request page $cmd = CommandFactory::getCommand('ShowManageRoomChange'); $cmd->setRequestId($requestId); $cmd->redirect(); }