Пример #1
0
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'search')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to lookup student names!');
     }
     $student = null;
     $error = new JsonError(403);
     $username = $context->get('username');
     $banner_id = (int) $context->get('banner_id');
     try {
         if ($banner_id) {
             $student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm());
         } elseif (!empty($username)) {
             $student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm());
         } else {
             $error->setMessage('Did not receive Banner ID or user name.');
             $context->setContent(json_encode($error));
         }
         $student->gender_string = HMS_Util::formatGender($student->gender);
         $context->setContent(json_encode($student));
     } catch (\StudentNotFoundException $e) {
         $error->setMessage($e->getMessage());
         $context->setContent(json_encode($error));
     }
 }
 /**
  * (non-PHPdoc)
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     $term = $context->get('term');
     if (!isset($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $user = UserStatus::getUsername();
     $student = StudentFactory::getStudentByUsername($user, $term);
     // Load the student's application. Should be a lottery application.
     $application = HousingApplicationFactory::getAppByStudent($student, $term);
     // If there isn't a valid application in the DB, then we have a problem.
     if (!isset($application) || !$application instanceof LotteryApplication) {
         throw new InvalidArgumentException('Null application object.');
     }
     // Check to make sure the date isn't already set
     $time = $application->getWaitingListDate();
     if (isset($time)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You have already applied for the waiting list.');
         $cmd = CommandFactory::getCommand('ShowStudentMenu');
         $cmd->redirect();
     }
     // Set the date
     $application->setWaitingListDate(time());
     // Save the application again
     $application->save();
     // Log it to the activity log
     HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_REAPP_WAITINGLIST_APPLY, UserStatus::getUsername());
     // Success command
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assign_by_floor')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to assign students by floor.');
     }
     $username = $context->get('username');
     $banner_id = (int) $context->get('banner_id');
     $reason = $context->get('reason');
     $meal_plan = $context->get('meal_plan');
     $bed_id = $context->get('bed_id');
     $term = Term::getSelectedTerm();
     try {
         if ($banner_id) {
             $student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm());
         } elseif (!empty($username)) {
             $student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm());
         } else {
             $context->setContent(json_encode(array('status' => 'failure', 'message' => 'Did not receive Banner ID or user name.')));
             return;
         }
         try {
             HMS_Assignment::assignStudent($student, $term, null, $bed_id, $meal_plan, null, null, $reason);
         } catch (AssignmentException $e) {
             $context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage())));
             return;
         }
         $message = $student->first_name . ' ' . $student->last_name;
         $context->setContent(json_encode(array('status' => 'success', 'message' => $message, 'student' => $student)));
     } catch (\StudentNotFoundException $e) {
         $context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage())));
     }
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'approve_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve RLC applications.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     # Foreach rlc assignment made
     # $app_id is the 'id' column in the 'learning_community_applications' table, tells which student we're assigning
     # $rlc_id is the 'id' column in the 'learning_communitites' table, and refers to the RLC selected for the student
     foreach ($_REQUEST['final_rlc'] as $app_id => $rlc_id) {
         if ($rlc_id <= 0) {
             continue;
         }
         $app = HMS_RLC_Application::getApplicationById($app_id);
         $student = StudentFactory::getStudentByUsername($app->username, $app->term);
         # Insert a new assignment in the 'learning_community_assignment' table
         $assign = new HMS_RLC_Assignment();
         $assign->rlc_id = $rlc_id;
         $assign->gender = $student->getGender();
         $assign->assigned_by = UserStatus::getUsername();
         $assign->application_id = $app->id;
         $assign->state = 'new';
         $assign->save();
         # Log the assignment
         PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
         HMS_Activity_Log::log_activity($app->username, ACTIVITY_ASSIGN_TO_RLC, UserStatus::getUsername(), "New Assignment");
     }
     // Show a success message
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully assigned RLC applicant(s).');
     $context->goBack();
 }
Пример #5
0
 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');
 }
Пример #6
0
 public function execute(CommandContext $context)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id == 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     if (UserStatus::getUsername() != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to reject roommate pairing {$roommate->id}");
     }
     $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term);
     $name = $requestor->getFullName();
     $username = $requestor->getUsername();
     $roommate->delete();
     HMS_Activity_Log::log_activity($roommate->requestor, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestee, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     HMS_Activity_Log::log_activity($roommate->requestee, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestor, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_reject_emails($roommate);
     NQ::Simple('hms', hms\NotificationView::SUCCESS, "<b>You rejected the roommate request from {$name}.</b>  If this was an error, you may re-request using their username, <b>{$username}</b>.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
Пример #7
0
 public function __construct($username)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $student = StudentFactory::getStudentByUsername($username, Term::getCurrentTerm());
     $this->student = $student;
     $this->term = $student->getApplicationTerm();
 }
Пример #8
0
 public function execute()
 {
     $db = PdoFactory::getPdoInstance();
     $query = "SELECT hms_assignment.banner_id, hms_hall_structure.room_number, hms_hall_structure.hall_name\n              FROM hms_assignment\n              JOIN hms_hall_structure\n                  ON hms_assignment.bed_id = hms_hall_structure.bedid\n              WHERE\n                hms_assignment.term = :term and\n                roomid IN (SELECT room_id\n                            FROM hms_learning_community_assignment\n                            JOIN hms_learning_community_applications\n                                ON hms_learning_community_assignment.application_id = hms_learning_community_applications.id\n                            JOIN hms_assignment\n                                ON (hms_learning_community_applications.username = hms_assignment.asu_username AND hms_learning_community_applications.term = hms_assignment.term)\n                            JOIN hms_bed\n                                ON hms_assignment.bed_id = hms_bed.id\n                            JOIN hms_room\n                                ON hms_bed.room_id = hms_room.id\n                            WHERE\n                                hms_learning_community_applications.term = :term)\n              ORDER BY roomid";
     $stmt = $db->prepare($query);
     $params = array('term' => $this->term);
     $stmt->execute($params);
     $queryResult = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $results = array();
     $i = 0;
     $count = 0;
     foreach ($queryResult as $result) {
         $tplVals = array();
         $tplVals['BANNER'] = $result['banner_id'];
         $student = StudentFactory::getStudentByBannerID($result['banner_id'], $this->term);
         $tplVals['USERNAME'] = $student->getUsername();
         $tplVals['FIRST_NAME'] = $student->getFirstName();
         $tplVals['LAST_NAME'] = $student->getLastName();
         $membership = RlcMembershipFactory::getMembership($student, $this->term);
         if ($membership) {
             $tplVals['COMMUNITY'] = $membership->getRlcName();
             $count++;
         } else {
             $tplVals['COMMUNITY'] = '';
         }
         $tplVals['HALL'] = $result['hall_name'];
         $tplVals['ROOM'] = $result['room_number'];
         $results[$i] = $tplVals;
         $i++;
     }
     $this->memberCount = $count;
     $this->data = $results;
 }
 protected function createPairing(HousingApplication $a, HousingApplication $b)
 {
     // Determine lifestyle option
     $option = LO_COED;
     if ($a->lifestyle_option == LO_SINGLE_GENDER || $b->lifestyle_option == LO_SINGLE_GENDER) {
         $option = LO_SINGLE_GENDER;
     }
     try {
         $studentA = StudentFactory::getStudentByUsername($a->username, $this->term);
     } catch (StudentNotFoundException $e) {
         echo 'StudentNotFoundException: ' . $a->username . ' Could not pair ' . $a->username . ', ' . $b->username . "\n";
         return null;
     }
     try {
         $studentB = Studentfactory::getStudentByUsername($b->username, $this->term);
     } catch (StudentNotFoundException $e) {
         echo 'StudentNotFoundException: ' . $b->username . ' Could not pair ' . $a->username . ', ' . $b->username . "\n";
         return null;
     }
     if ($a->getCreatedOn() < $b->getCreatedOn()) {
         $earliestTime = $a->getCreatedOn();
     } else {
         $earliestTime = $b->getCreatedOn();
     }
     // Looks like there is no problem here.
     return new AssignmentPairing($studentA, $studentB, $option, $earliestTime);
 }
Пример #10
0
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'PdoFactory.php');
     $db = PdoFactory::getInstance()->getPdo();
     $query = "SELECT requestor, requestee from hms_roommate\n                  LEFT OUTER JOIN\n                    (select asu_username, hms_room.id as rmid\n                      FROM hms_assignment\n                      JOIN hms_bed ON hms_assignment.bed_id = hms_bed.id\n                      JOIN hms_room ON hms_bed.room_id = hms_room.id\n                      WHERE hms_assignment.term = :term)\n                as requestor_room_id ON requestor_room_id.asu_username = requestor\n                  LEFT OUTER JOIN\n                    (select asu_username, hms_room.id as rmid\n                      FROM hms_assignment\n                      JOIN hms_bed ON hms_assignment.bed_id = hms_bed.id\n                      JOIN hms_room ON hms_bed.room_id = hms_room.id\n                      WHERE hms_assignment.term = :term)\n                AS requestee_room_id ON requestee_room_id.asu_username = requestee\n                  WHERE hms_roommate.term = :term and confirmed = 1 AND\n                  requestor_room_id.rmid != requestee_room_id.rmid";
     // $query = "SELECT hms_assignment.term, hms_assignment.banner_id, hms_hall_structure.banner_building_code, hms_hall_structure.banner_id
     //             as bed_code, hms_new_application.meal_plan FROM hms_assignment
     //               JOIN hms_hall_structure ON
     //                 hms_assignment.bed_id = hms_hall_structure.bedid
     //               LEFT OUTER JOIN hms_new_application ON
     //                 (hms_assignment.banner_id = hms_new_application.banner_id
     //                 AND hms_assignment.term = hms_new_application.term)
     //               WHERE hms_assignment.term IN (:term) ORDER BY hms_assignment.term";
     $stmt = $db->prepare($query);
     $stmt->execute(array('term' => $this->term));
     $queryResult = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $result = array();
     $i = 0;
     foreach ($queryResult as $row) {
         $requestee = StudentFactory::getStudentByUsername($row['requestee'], $this->term);
         $requestor = StudentFactory::getStudentByUsername($row['requestor'], $this->term);
         $row['requestee_banner'] = $requestee->getBannerId();
         $row['requestor_banner'] = $requestor->getBannerId();
         $row['requestee_name'] = $requestee->getFullName();
         $row['requestor_name'] = $requestor->getFullName();
         $result[$i] = $row;
         $i++;
     }
     $this->data = $result;
     $this->mismatchCount = $i;
 }
 /**
  *
  * @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());
 }
Пример #12
0
 /**
  * Main searching function. Does the database lookup and then checks each student though the various functions.
  */
 public function doSearch()
 {
     // Clear all the caches
     StudentDataProvider::clearAllCache();
     $term = $this->term;
     $query = "select DISTINCT * FROM (select hms_new_application.username from hms_new_application WHERE term={$term} AND cancelled != 1 UNION select hms_assignment.asu_username from hms_assignment WHERE term={$term}) as foo";
     $result = PHPWS_DB::getCol($query);
     if (PHPWS_Error::logIfError($result)) {
         throw new Exception($result->toString());
     }
     foreach ($result as $username) {
         $student = null;
         try {
             $student = StudentFactory::getStudentByUsername($username, $term);
         } catch (Exception $e) {
             $this->actions[$username][] = 'WARNING!! Unknown student!';
             // Commenting out the NQ line, since this doesn't work when the search is run from cron/Pulse
             //NQ::simple('hms', hms\NotificationView::WARNING, 'Unknown student: ' . $username);
             continue;
         }
         if ($student->getType() != TYPE_WITHDRAWN && $student->getAdmissionDecisionCode() != ADMISSION_WITHDRAWN_PAID && $student->getAdmissionDecisionCode() != ADMISSION_RESCIND) {
             continue;
         }
         $this->actions[$username][] = $student->getBannerId() . ' (' . $student->getUsername() . ')';
         $this->withdrawnCount++;
         $this->handleApplication($student);
         $this->handleAssignment($student);
         $this->handleRoommate($student);
         $this->handleRlcAssignment($student);
         $this->handleRlcApplication($student);
     }
 }
 public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     if (!isset($term) || is_null($term) || empty($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $feature = ApplicationFeature::getInstanceByNameAndTerm('RlcApplication', $term);
     // Make sure the RLC application feature is enabled
     if (is_null($feature) || !$feature->isEnabled()) {
         NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, RLC applications are not avaialable for this term.");
         $cmd->redirect();
     }
     // Check feature's deadlines
     if ($feature->getStartDate() > time()) {
         NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, it is too soon to fill out an RLC application.");
         $cmd->redirect();
     } else {
         if ($feature->getEndDate() < time()) {
             NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, the RLC application deadline has already passed. Please contact University Housing if you are interested in applying for a RLC.");
             $cmd->redirect();
         }
     }
     // Get the Student object
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm());
     $view = new RlcApplicationPage1View($context, $student);
     $context->setContent($view->show());
 }
Пример #14
0
 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)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id = 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     $username = UserStatus::getUsername();
     if ($username != $roommate->requestor && $username != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}");
     }
     PHPWS_Core::initCoreClass('Captcha.php');
     // get other roommate
     $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term);
     $form = new PHPWS_Form();
     $cmd = CommandFactory::getCommand('RoommateBreak');
     $cmd->setRoommateId($id);
     $cmd->initForm($form);
     $form->addTplTag('CAPTCHA_IMAGE', Captcha::get());
     $form->addTplTag('NAME', $other->getFullName());
     $form->addSubmit('Confirm');
     $form->addCssClass('submit', 'btn btn-danger');
     $context->setContent(PHPWS_Template::process($form->getTemplate(), 'hms', 'student/roommate_break_confirm.tpl'));
 }
 /**
  * (non-PHPdoc)
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $term = $context->get('term');
     // Check if the student has already applied. If so, redirect to the student menu
     $app = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term);
     if (isset($result) && $result->getApplicationType == 'offcampus_waiting_list') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You have already enrolled on the on-campus housing Open Waiting List for this term.');
         $menuCmd = CommandFactory::getCommand('ShowStudentMenu');
         $menuCmd->redirect();
     }
     // Make sure the student agreed to the terms, if not, send them back to the terms & agreement command
     $event = $context->get('event');
     $_SESSION['application_data'] = array();
     // If they haven't agreed, redirect to the agreement
     if (is_null($event) || !isset($event) || $event != 'signing_complete' && $event != 'viewing_complete') {
         $onAgree = CommandFactory::getCommand('ShowOffCampusWaitListApplication');
         $onAgree->setTerm($term);
         $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement');
         $agreementCmd->setTerm($term);
         $agreementCmd->setAgreedCommand($onAgree);
         $agreementCmd->redirect();
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     PHPWS_Core::initModClass('hms', 'ReApplicationOffCampusFormView.php');
     $view = new ReApplicationOffCampusFormView($student, $term);
     $context->setContent($view->show());
 }
 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();
 }
Пример #18
0
 /**
  * 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();
     }
 }
Пример #19
0
 /**
  * Generates the activity log table
  */
 public function getPagerTags()
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $tpl = array();
     try {
         $student = StudentFactory::getStudentByUsername($this->get_user_id(), Term::getSelectedTerm());
     } catch (StudentNotFoundException $e) {
         NQ::simple('hms', hms\NotificationView::WARNING, "Could not find data for student: {$this->get_user_id()}");
         $student = null;
     }
     if (is_null($student)) {
         $tpl['ACTEE'] = 'UNKNOWN';
     } else {
         $tpl['ACTEE'] = $student->getProfileLink();
     }
     if (strcmp($this->get_user_id(), $this->get_actor()) == 0) {
         $tpl['ACTOR'] = NULL;
     } else {
         $tpl['ACTOR'] = $this->get_actor();
     }
     $time = $this->get_timestamp();
     $tpl['DATE'] = date('j M Y', $time);
     $tpl['TIME'] = date('g:i a', $time);
     $tpl['ACTIVITY'] = $this->get_text_activity();
     $notes = $this->get_notes();
     if (!is_null($notes)) {
         $tpl['NOTES'] = $notes;
     }
     return $tpl;
 }
 public function execute(CommandContext $context)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id == 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     $username = UserStatus::getUsername();
     if ($username != $roommate->requestor) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}");
     }
     $roommate->delete();
     $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term);
     HMS_Activity_Log::log_activity($other->getUsername(), ACTIVITY_STUDENT_CANCELLED_ROOMMATE_REQUEST, $username, "{$username} cancelled roommate request");
     HMS_Activity_Log::log_activity($username, ACTIVITY_STUDENT_CANCELLED_ROOMMATE_REQUEST, $other->getUsername(), "{$username} cancelled roommate request");
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_cancel_emails($roommate);
     $name = $other->getFullName();
     NQ::Simple('hms', hms\NotificationView::SUCCESS, "You have cancelled your roommate request for {$name}.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
Пример #21
0
 public function show()
 {
     $username = UserStatus::getUsername();
     $currentTerm = Term::getCurrentTerm();
     $student = StudentFactory::getStudentByUsername($username, $currentTerm);
     $applicationTerm = $student->getApplicationTerm();
     $tpl = array();
     $tpl['TITLE'] = 'Contact Form';
     $form = new PHPWS_Form();
     $form->addText('name');
     $form->setLabel('name', 'Name');
     $form->addText('email');
     $form->setLabel('email', 'Email Address');
     $form->addText('phone');
     $form->setLabel('phone', 'Phone number');
     $form->addDropBox('stype', array('F' => 'New Freshmen', 'T' => 'Transfer', 'C' => 'Returning'));
     $form->setLabel('stype', 'Classification');
     $form->addTextArea('comments');
     $form->setLabel('comments', 'Question, Comments, or Description of the Problem');
     $form->addSubmit('Submit');
     $form->mergeTemplate($tpl);
     $cmd = CommandFactory::getCommand('SubmitContactForm');
     $cmd->setUsername($username);
     $cmd->setApplicationTerm($applicationTerm);
     $cmd->setStudentType($student->getType());
     $cmd->initForm($form);
     $tpl = $form->getTemplate();
     //var_dump($tpl);exit;
     return PHPWS_Template::process($tpl, 'hms', 'student/contact_page.tpl');
 }
Пример #22
0
 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());
 }
 public function execute(CommandContext $context)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id == 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     $username = UserStatus::getUsername();
     if ($username != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to display confirmation screen for pairing {$roommate->id}");
     }
     $tpl = array();
     $acceptCmd = CommandFactory::getCommand('ShowRoommateConfirmAccept');
     $acceptCmd->setRoommateId($roommate->id);
     $tpl['ACCEPT'] = $acceptCmd->getURI();
     $rejectCmd = CommandFactory::getCommand('RoommateReject');
     $rejectCmd->setRoommateId($roommate->id);
     $tpl['DECLINE'] = $rejectCmd->getURI();
     $cancelCmd = CommandFactory::getCommand('ShowStudentMenu');
     $tpl['CANCEL'] = $cancelCmd->getURI();
     $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term);
     $tpl['REQUESTOR_NAME'] = $requestor->getFullName();
     $context->setContent(PHPWS_Template::process($tpl, 'hms', 'student/roommate_accept_reject_screen.tpl'));
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $errorCmd = CommandFactory::getCommand('ShowReApplication');
     $errorCmd->setTerm($term);
     $depositAgreed = $context->get('deposit_check');
     if (is_null($depositAgreed)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must check the box indicating you understand the License Contract deposit fees.');
         $errorCmd->redirect();
     }
     // Data sanity checking
     $doNotCall = $context->get('do_not_call');
     $number = $context->get('number');
     if (is_null($doNotCall)) {
         // do not call checkbox was not selected, so check the number
         if (is_null($number)) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'Please provide a cell-phone number or click the checkbox stating that you do not wish to share your number with us.');
             $errorCmd->redirect();
         }
     }
     //$mealPlan = $context->get('meal_plan');
     /* Emergency Contact Sanity Checking */
     $emergencyName = $context->get('emergency_contact_name');
     $emergencyRelationship = $context->get('emergency_contact_relationship');
     $emergencyPhone = $context->get('emergency_contact_phone');
     $emergencyEmail = $context->get('emergency_contact_email');
     if (empty($emergencyName) || empty($emergencyRelationship) || empty($emergencyPhone) || empty($emergencyEmail)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please complete all of the emergency contact person information.');
         $errorCmd->redirect();
     }
     /* Missing Persons Sanity Checking */
     $missingPersonName = $context->get('missing_person_name');
     $missingPersonRelationship = $context->get('missing_person_relationship');
     $missingPersonPhone = $context->get('missing_person_phone');
     $missingPersonEmail = $context->get('missing_person_email');
     if (empty($missingPersonName) || empty($missingPersonRelationship) || empty($missingPersonPhone) || empty($missingPersonEmail)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please complete all of the missing persons contact information.');
         $errorCmd->redirect();
     }
     $specialNeed = $context->get('special_need');
     if (isset($specialNeed)) {
         $onSubmitCmd = CommandFactory::getCommand('ReApplicationFormSave');
         $onSubmitCmd->loadContext($context);
         $onSubmitCmd->setTerm($term);
         $specialNeedCmd = CommandFactory::getCommand('ShowSpecialNeedsForm');
         $specialNeedCmd->setTerm($term);
         $specialNeedCmd->setVars($context->getParams());
         $specialNeedCmd->setOnSubmitCmd($onSubmitCmd);
         $specialNeedCmd->redirect();
     } else {
         $reviewCmd = CommandFactory::getCommand('ReApplicationFormSave');
         $reviewCmd->setTerm($term);
         $reviewCmd->loadContext($context);
         $reviewCmd->redirect();
     }
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'FreshmenMainMenuView.php');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm());
     $view = new FreshmenMainMenuView($student);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php');
     $requestId = $context->get('requestId');
     $mealPlan = $context->get('mealPlan');
     $errorCmd = CommandFactory::getCommand('LotteryShowConfirmRoommateRequest');
     $errorCmd->setRequestId($requestId);
     $errorCmd->setMealPlan($mealPlan);
     // Confirm the captcha
     PHPWS_Core::initCoreClass('Captcha.php');
     $captcha = Captcha::verify(TRUE);
     if ($captcha === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'The words you entered were incorrect. Please try again.');
         $errorCmd->redirect();
     }
     // Check for a meal plan
     if (!isset($mealPlan) || $mealPlan == '') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a meal plan.');
         $errorCmd->redirect();
     }
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Update the meal plan field on the application
     $app = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term);
     $app->setMealPlan($mealPlan);
     try {
         $app->save();
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     // Try to actually make the assignment
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     try {
         HMS_Lottery::confirm_roommate_request(UserStatus::getUsername(), $requestId, $mealPlan);
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     # Log the fact that the roommate was accepted and successfully assigned
     HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_CONFIRMED_ROOMMATE, UserStatus::getUsername(), "Captcha: \"{$captcha}\"");
     // Check for an RLC membership and update status if necessary
     // If this student was an RLC self-select, update the RLC memberhsip state
     $rlcAssignment = RlcMembershipFactory::getMembership($student, $term);
     if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') {
         $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment));
     }
     $invite = HMS_Lottery::get_lottery_roommate_invite_by_id($requestId);
     $successCmd = CommandFactory::getCommand('LotteryShowConfirmedRoommateThanks');
     $successCmd->setRequestId($requestId);
     $successCmd->redirect();
 }
Пример #27
0
    public function execute(CommandContext $context)
    {
        $newrows = array();
        $pdo = PdoFactory::getPdoInstance();
        $floor_id = (int) $context->get('floorId');
        $query = <<<EOF
select\troom.id as room_id,
\troom.room_number,
\troom.gender_type,
\tbed.id as bed_id,
\tbed.bedroom_label,
\tbed.bed_letter,
\tassign.banner_id,
\tassign.meal_option,
        assign.asu_username
from  \thms_room as room
\tfull join
\t\thms_bed as bed on room.id=bed.room_id
\tfull join
\t\thms_assignment as assign on bed.id=assign.bed_id
where\troom.floor_id = :floor_id
order by room_number asc, bedroom_label, bed_letter;
EOF;
        $prep = $pdo->prepare($query);
        $prep->execute(array(':floor_id' => $floor_id));
        $rows = $prep->fetchAll(PDO::FETCH_ASSOC);
        if (empty($rows)) {
            $context->setContent(json_encode(array()));
            return;
        }
        $count = -1;
        $room_number_track = 0;
        foreach ($rows as $k => $v) {
            $gender = HMS_Util::formatGender($v['gender_type']);
            if ($v['banner_id']) {
                $student = StudentFactory::getStudentByBannerID($v['banner_id'], Term::getSelectedTerm());
                if ($student) {
                    $v['student'] = $student->first_name . ' ' . $student->last_name;
                } else {
                    $v['student'] = null;
                }
            } else {
                $v['student'] = null;
            }
            if ($v['room_number'] != $room_number_track) {
                $count++;
                $newrows[$count]['room_number'] = $v['room_number'];
                $newrows[$count]['gender'] = $gender;
                $newrows[$count]['beds'][] = $v;
                $room_number_track = $v['room_number'];
            } else {
                $newrows[$count]['beds'][] = $v;
            }
        }
        $context->setContent(json_encode($newrows));
    }
 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 execute(CommandContext $context)
 {
     $term = Term::getCurrentTerm();
     // Create the student
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // If the student has a pending request load it from the db
     $request = RoomChangeRequestFactory::getPendingByStudent($student, $term);
     $view = new RoomChangeRequestForm($student, $term);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     if (!isset($term) || is_null($term) || empty($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $view = new RlcApplicationPage1View($context, $student);
     $context->setContent($view->show());
 }