Ejemplo n.º 1
0
 /**
  * Report lists rooms in each residence hall that are still available, along with
  * the available beds in the room.  Also, show the number of beds allocated to the
  * lotter for each residence hall.
  *
  */
 public static function reappAvailability()
 {
     $term = Term::getSelectedTerm();
     // Available rooms in each residence hall.
     $db = new PHPWS_DB('hms_bed');
     $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     //$db->addWhere('hms_bed.ra_bed', 0);
     $db->addWhere('hms_room.private', 0);
     $db->addWhere('hms_room.overflow', 0);
     $db->addWhere('hms_room.reserved', 0);
     $db->addWhere('hms_room.offline', 0);
     $db->addWhere('hms_bed.term', $term);
     $db->addColumn('hms_room.room_number');
     $db->addColumn('hms_bed.bed_letter', null, null, True);
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addGroupBy('hms_residence_hall.hall_name');
     $db->addGroupBy('hms_room.room_number');
     $db->addOrder('hms_residence_hall.hall_name');
     $availRooms = $db->select();
     // Allocated beds for lottery.
     $db = new PHPWS_DB('hms_bed');
     $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     $db->addJoin('RIGHT', 'hms_bed', 'hms_lottery_reservation', 'id', 'bed_id');
     $db->addWhere('hms_lottery_reservation.term', $term);
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addColumn('hms_bed.id', null, null, True);
     $db->addGroupBy('hms_residence_hall.hall_name');
     $db->setIndexBy('hall_name');
     $lotteryBeds = $db->select();
     $tpl = new PHPWS_Template('hms');
     $tpl->setFile('admin/reports/reapp_availability.tpl');
     //
     // "The parent row must be parsed after the child rows."
     // Preload currHall with first residence hall name
     $currHall = $availRooms[0]['hall_name'];
     foreach ($availRooms as $row) {
         // Change halls, create new block.
         if ($currHall != $row['hall_name'] || $currHall == null) {
             $tpl->setCurrentBlock('halls');
             // Get allocated beds for the residence hall.
             $lottCount = isset($lotteryBeds[$currHall]['count']) ? $lotteryBeds[$currHall]['count'] : 0;
             $tpl->setData(array('HALL_NAME' => $currHall, 'LOTTERY_BEDS' => $lottCount));
             $tpl->parseCurrentBlock();
             $currHall = $row['hall_name'];
         }
         // Add room to residence hall template block.
         $tpl->setCurrentBlock('rooms');
         $tpl->setData(array('ROOM_NUM' => $row['room_number'], 'BED_COUNT' => $row['count']));
         $tpl->parseCurrentBlock();
     }
     // Get last residence hall. Can't parse parent before child with template class.
     $tpl->setCurrentBlock('halls');
     $tpl->setData(array('HALL_NAME' => $currHall));
     $tpl->parseCurrentBlock();
     return $tpl->get();
 }
Ejemplo n.º 2
0
 public function execute(CommandContext $context)
 {
     $resultCmd = CommandFactory::getCommand('ShowSendRlcInvites');
     $respondByDate = $context->get('respond_by_date');
     $respondByTime = $context->get('time');
     if (!isset($respondByDate) || $respondByDate == '') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a \'respond by\' date.');
         $resultCmd->redirect();
     }
     $dateParts = explode('/', $respondByDate);
     $respondByTimestamp = mktime($respondByTime, null, null, $dateParts[0], $dateParts[1], $dateParts[2]);
     $term = Term::getSelectedTerm();
     $studentType = $context->get('type');
     if (!isset($studentType)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a student type.');
         $resultCmd->redirect();
     }
     PHPWS_Core::initModClass('hms', 'RlcAssignmentFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcAssignmentInvitedState.php');
     $assignments = RlcAssignmentFactory::getAssignmentsByTermStateType($term, 'new', $studentType);
     if (sizeof($assignments) == 0) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'No invites needed to be sent.');
         $resultCmd->redirect();
     }
     foreach ($assignments as $assign) {
         $assign->changeState(new RlcAssignmentInvitedState($assign, $respondByTimestamp));
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Learning community invites sent.');
     $resultCmd->redirect();
 }
Ejemplo n.º 3
0
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'floor_view')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit floors.');
     }
     // Check for a hall ID
     $floorId = $context->get('floor');
     if (!isset($floorId)) {
         throw new InvalidArgumentException('Missing floor ID.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
     PHPWS_Core::initModClass('hms', 'FloorView.php');
     $floor = new HMS_Floor($floorId);
     if ($floor->term != Term::getSelectedTerm()) {
         $floorCmd = CommandFactory::getCommand('SelectFloor');
         $floorCmd->setTitle('Edit a Floor');
         $floorCmd->setOnSelectCmd(CommandFactory::getCommand('EditFloorView'));
         $floorCmd->redirect();
     }
     $hall = $floor->get_parent();
     $floorView = new FloorView($hall, $floor);
     $context->setContent($floorView->show());
 }
Ejemplo n.º 4
0
 public function execute(CommandContext $context)
 {
     $term = Term::getSelectedTerm();
     $messageAll = Current_User::allow('hms', 'email_all');
     $db = new PHPWS_DB('hms_residence_hall');
     $db->addWhere('term', $term);
     $results = $db->getObjects('HMS_Residence_Hall');
     if (PHPWS_Error::logIfError($results) || is_null($results)) {
         $errorMsg = array();
         if (is_null($results)) {
             $errorMsg['error'] = 'You do not have permission to message any halls, sorry.';
         } else {
             $errorMsg['error'] = 'There was a problem reading the database, please try reloading the page.  If the problem persists contact ESS.';
         }
         echo json_encode($errorMsg);
         exit;
     }
     $permission = new HMS_Permission();
     $data = array();
     foreach ($results as $hall) {
         $somethingEnabled = false;
         $floors = $hall->get_floors();
         unset($obj);
         $obj = new stdClass();
         $obj->name = $hall->getHallName();
         $obj->id = $hall->getId();
         $obj->floors = array();
         //$blah = 'Verify: ' . ($permission->verify(UserStatus::getUsername(), $hall, 'email') ? 'true' : 'false');
         if ($permission->verify(UserStatus::getUsername(), $hall, 'email') || $messageAll) {
             $obj->enabled = true;
             $somethingEnabled = true;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = true;
                 $obj->floors[] = $floor_obj;
             }
         } else {
             $obj->enabled = false;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = $permission->verify(Current_User::getUsername(), $floor, 'email');
                 $obj->floors[] = $floor_obj;
                 if ($floor_obj->enabled) {
                     $somethingEnabled = true;
                 }
             }
         }
         if ($somethingEnabled) {
             $data[] = $obj;
         }
     }
     echo json_encode($data);
     exit;
 }
Ejemplo n.º 5
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());
 }
Ejemplo n.º 6
0
 public function show()
 {
     if (\UserStatus::isGuest()) {
         return '';
     }
     $terms = \Term::getTermsAssoc();
     $current = \Term::getCurrentTerm();
     if (isset($terms[$current])) {
         $terms[$current] .= ' (Current)';
     }
     $form = new \PHPWS_Form('term_selector');
     $cmd = \CommandFactory::getCommand('SelectTerm');
     $cmd->initForm($form);
     $form->addDropBox('term', $terms);
     $tags = $form->getTemplate();
     $currentTerm = \Term::getSelectedTerm();
     $tags['TERM_OPTIONS'] = array();
     foreach ($tags['TERM_VALUE'] as $key => $value) {
         $selected = '';
         if ($key == $currentTerm) {
             $selected = 'selected="selected"';
         }
         $tags['TERM_OPTIONS'][] = array('id' => $key, 'term' => $value, 'selected' => $selected);
     }
     javascript('jquery');
     javascriptMod('hms', 'jqueryCookie');
     javascript('modules/hms/SelectTerm');
     return \PHPWS_Template::process($tags, 'hms', 'admin/SelectTerm.tpl');
 }
 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();
 }
Ejemplo n.º 8
0
 public function show()
 {
     $form = new PHPWS_Form('room_change_request');
     /* Cell phone */
     $form->addText('cell_num');
     $form->setLabel('cell_num', 'Cell phone Number');
     $form->addCssClass('cell_num', 'form-control');
     $form->addCheck('cell_opt_out');
     /* Preferences */
     $halls = array(0 => 'Choose from below...');
     $halls = $halls + HMS_Residence_Hall::get_halls_array(Term::getSelectedTerm());
     $form->addRadioAssoc('type', array('switch' => 'I want to change to an open bed.', 'swap' => 'I want to swap beds with someone I know.'));
     /* Swap */
     $form->addText('swap_with');
     $form->setLabel('swap_with', 'ASU Email Address');
     $form->addCssClass('swap_with', 'form-control');
     /* Switch */
     $form->addDropBox('first_choice', $halls);
     $form->setLabel('first_choice', 'First Choice');
     $form->addCssClass('first_choice', 'form-control');
     $form->addDropBox('second_choice', $halls);
     $form->setLabel('second_choice', 'Second Choice');
     $form->addCssClass('second_choice', 'form-control');
     /* Reason */
     $form->addTextArea('reason');
     $form->setLabel('reason', 'Reason');
     $form->addCssClass('reason', 'form-control');
     $form->setRows('reason', 5);
     /* POST location */
     $cmd = CommandFactory::getCommand('SubmitRoomChangeRequest');
     $cmd->initForm($form);
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'hms', 'student/roomChangeRequestForm.tpl');
 }
Ejemplo n.º 9
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;
 }
Ejemplo n.º 10
0
 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())));
     }
 }
Ejemplo n.º 11
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));
     }
 }
Ejemplo n.º 12
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'room_view')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to view rooms.');
     }
     // Check for a  hall ID
     $roomId = $context->get('room');
     if (!isset($roomId)) {
         throw new InvalidArgumentException('Missing room ID.');
     }
     // Load the room
     $room = new HMS_Room($roomId);
     if ($room->term != Term::getSelectedTerm()) {
         $roomCmd = CommandFactory::getCommand('SelectRoom');
         $roomCmd->setTitle('Edit a Room');
         $roomCmd->setOnSelectCmd(CommandFactory::getCommand('EditRoomView'));
         $roomCmd->redirect();
     }
     // Load the floor/hall
     $floor = $room->get_parent();
     $hall = $floor->get_parent();
     // Load the room damages and damage types
     $damageTypes = DamageTypeFactory::getDamageTypeAssoc();
     $roomView = new RoomView($hall, $floor, $room, $damageTypes);
     $context->setContent($roomView->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());
 }
Ejemplo n.º 14
0
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     Layout::addPageTitle("RLC Application Review");
     $tags = array();
     if (UserStatus::isAdmin()) {
         $menuCmd = CommandFactory::getCommand('ShowAssignRlcApplicants');
         $tags['MENU_LINK'] = $menuCmd->getURI();
     } else {
         $menuCmd = CommandFactory::getCommand('ShowStudentMenu');
         $tags['MENU_LINK'] = $menuCmd->getURI();
     }
     $tags['FULL_NAME'] = $this->student->getFullName();
     $tags['STUDENT_TYPE'] = $this->student->getPrintableType();
     $tags['TERM'] = Term::toString($this->application->getTerm());
     $appType = $this->application->getApplicationType();
     if ($appType == RLC_APP_FRESHMEN) {
         $tags['APPLICATION_TYPE'] = 'Freshmen';
     } else {
         if ($appType == RLC_APP_RETURNING) {
             $tags['APPLICATION_TYPE'] = 'Re-application';
         }
     }
     $rlcs = HMS_Learning_Community::getRlcList();
     $tags['FIRST_CHOICE'] = $rlcs[$this->application->rlc_first_choice_id];
     if (isset($this->application->rlc_second_choice_id)) {
         $tags['SECOND_CHOICE'] = $rlcs[$this->application->rlc_second_choice_id];
     }
     if (isset($this->application->rlc_third_choice_id)) {
         $tags['THIRD_CHOICE'] = $rlcs[$this->application->rlc_third_choice_id];
     }
     $tags['WHY_SPECIFIC'] = $this->application->why_specific_communities;
     $tags['STRENGTHS_AND_WEAKNESSES'] = $this->application->strengths_weaknesses;
     $tags['WHY_FIRST_CHOICE'] = $this->application->rlc_question_0;
     if (isset($this->application->rlc_second_choice_id)) {
         $tags['WHY_SECOND_CHOICE'] = $this->application->rlc_question_1;
     }
     if (isset($this->application->rlc_second_choice_id)) {
         $tags['WHY_THIRD_CHOICE'] = $this->application->rlc_question_2;
     }
     // If this application is denied and the person logged in is an admin, show a warning
     if ($this->application->isDenied() && UserStatus::isAdmin()) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'This application has been denied.');
     }
     // Show options depending of status of application.
     if (UserStatus::isAdmin() && Current_User::allow('hms', 'approve_rlc_applications')) {
         if (!$this->application->denied && !HMS_RLC_Assignment::checkForAssignment($this->student->getUsername(), Term::getSelectedTerm())) {
             // Approve application for the community selected from dropdown
             $approvalForm = $this->getApprovalForm();
             $approvalForm->mergeTemplate($tags);
             $tags = $approvalForm->getTemplate();
             // Deny application
             $tags['DENY_APP'] = $this->getDenialLink();
         }
     }
     return PHPWS_Template::process($tags, 'hms', 'student/rlc_application.tpl');
 }
Ejemplo n.º 15
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'WithdrawnSearch.php');
     $term = Term::getSelectedTerm();
     $search = new WithdrawnSearch($term);
     $search->doSearch();
     $context->setContent($search->getHTMLView());
 }
Ejemplo n.º 16
0
 public function execute(CommandContext $context)
 {
     $term = new Term(Term::getSelectedTerm());
     $term->setDocusignTemplate($context->get('template'));
     $term->setDocusignUnder18Template($context->get('under18_template'));
     $term->save();
     $cmd = CommandFactory::getCommand('ShowEditTerm');
     $cmd->redirect();
 }
Ejemplo n.º 17
0
 public function execute(CommandContext $context)
 {
     $term = Term::getSelectedTerm();
     $pdo = PdoFactory::getPdoInstance();
     $prep = $pdo->prepare("select id, hall_name as title from hms_residence_hall where term=? and is_online=1 order by hall_name");
     $prep->execute(array($term));
     $halls = $prep->fetchAll(PDO::FETCH_ASSOC);
     $context->setContent(json_encode($halls));
 }
Ejemplo n.º 18
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)
 {
     if (!Current_User::allow('hms', 'damage_assessment')) {
         throw new PermissionException('You do not have permission to perform room damage assessment.');
     }
     $tpl = array();
     $tpl['TERM'] = Term::getSelectedTerm();
     javascript('jquery');
     $context->setContent(PHPWS_Template::process($tpl, 'hms', 'admin/roomDamageAssessment.tpl'));
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'SelectHallView.php');
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     $term = Term::getSelectedTerm();
     $halls = HMS_Residence_Hall::get_halls_array($term);
     $onSelectCmd = CommandFactory::getCommand($context->get('onSelectAction'));
     $hallView = new SelectHallView($onSelectCmd, $halls, $context->get('title'), $term);
     $context->setContent($hallView->show());
 }
Ejemplo n.º 21
0
 public function show()
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'edit_terms')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit terms.');
     }
     $printable = Term::getPrintableSelectedTerm();
     $tpl = array();
     $tpl['TITLE'] = dgettext('hms', 'Term settings for ') . $printable;
     $newTermCmd = CommandFactory::getCommand('ShowCreateTerm');
     $tpl['NEW_TERM_URI'] = $newTermCmd->getURI();
     // Is this the Current Term?
     if (Term::isCurrentTermSelected()) {
         $tpl['CURRENT_TERM_TEXT'] = dgettext('hms', 'This term is the <strong>active term</strong>.  To make another term active, please select it from the list at the top-left.');
     } else {
         $tpl['CURRENT_TERM_TEXT'] = dgettext('hms', 'This term is <strong>not</strong> the active term.');
         if (Current_User::allow('hms', 'activate_term')) {
             $cmd = CommandFactory::getCommand('SetCurrentTerm');
             $cmd->setTerm(Term::getSelectedTerm());
             $tpl['SET_TERM_URI'] = $cmd->getURI();
             $tpl['SET_TERM_TEXT'] = "Make <strong>{$printable}</strong> the Current Term";
         }
     }
     // What's with the Banner Queue?
     $term = new Term(Term::getSelectedTerm());
     if ($term->getBannerQueue()) {
         $tpl['QUEUE_ENABLED'] = '';
         $count = $term->getQueueCount();
         $tpl['BANNER_QUEUE_COUNT'] = $count;
         if ($count > 0) {
             $cmd = CommandFactory::getCommand('ProcessBannerQueue');
             $cmd->setTerm(Term::getSelectedTerm());
             $tpl['BANNER_QUEUE_PROCESS_URI'] = $cmd->getURI();
         } else {
             $cmd = CommandFactory::getCommand('DisableBannerQueue');
             $cmd->setTerm(Term::getSelectedTerm());
             $tpl['BANNER_QUEUE_LINK'] = $cmd->getLink('Disable');
         }
     } else {
         $tpl['QUEUE_DISABLED'] = '';
         $cmd = CommandFactory::getCommand('EnableBannerQueue');
         $cmd->setTerm(Term::getSelectedTerm());
         $tpl['BANNER_QUEUE_LINK'] = $cmd->getLink('Enable');
     }
     // Terms and Conditions
     PHPWS_Core::initModClass('hms', 'TermsConditionsAdminView.php');
     $tcav = new TermsConditionsAdminView($this->term);
     $tpl['TERMS_CONDITIONS_CONTENT'] = $tcav->show();
     // Features and Deadlines
     PHPWS_Core::initModClass('hms', 'ApplicationFeatureListView.php');
     $aflv = new ApplicationFeatureListView(Term::getSelectedTerm());
     $tpl['FEATURES_DEADLINES_CONTENT'] = $aflv->show();
     Layout::addPageTitle("Term Settings");
     return PHPWS_Template::process($tpl, 'hms', 'admin/TermEditView.tpl');
 }
Ejemplo n.º 22
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'AssignByFloorView.php');
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     $term = Term::getSelectedTerm();
     $halls = HMS_Residence_Hall::getHallsDropDownValues($term);
     $onSelectCmd = CommandFactory::getCommand($context->get('onSelectAction'));
     $onSelectCmd->setFloorId($context->get('floor'));
     $floorView = new AssignByFloorView($onSelectCmd, $halls, $context->get('title'), $term);
     $context->setContent($floorView->show());
 }
Ejemplo n.º 23
0
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'edit_terms')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit terms.');
     }
     PHPWS_Core::initModClass('hms', 'TermEditView.php');
     $term = new Term(Term::getSelectedTerm());
     $termView = new TermEditView($term);
     $context->setContent($termView->show());
 }
Ejemplo n.º 24
0
 /**
  *
  * @param CommandContext $context
  * @throws PermissionException
  */
 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 unassign students.');
     }
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     $username = $context->get('username');
     $unassignReason = $context->get('unassignment_type');
     $cmd = CommandFactory::getCommand('ShowUnassignStudent');
     // $cmd->setUsername($username);
     if (!isset($username) || is_null($username)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid or missing username.');
         $cmd->redirect();
     }
     // Make sure a valid reason was chosen
     if (!isset($unassignReason) || $unassignReason == -1) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a valid reason.');
         $cmd->setUsername($username);
         $cmd->redirect();
     }
     // Check refund percentage field
     $refund = $context->get('refund');
     // Is a required field
     if (!isset($refund) || $refund == '') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please enter a refund percentage.');
         $cmd->redirect();
     }
     // Must be numeric
     if (!is_numeric($refund) || $refund < 0 || $refund > 100) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'The refund percentage must be between 0 and 100 percent.');
         $cmd->redirect();
     }
     // Must be whole number
     if (is_float($refund)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Only whole number refund percentages are supported, no decimal place is allowed.');
         $cmd->redirect();
     }
     $term = Term::getSelectedTerm();
     $student = StudentFactory::getStudentByUsername($username, $term);
     $notes = $context->get('note');
     try {
         HMS_Assignment::unassignStudent($student, $term, $notes, $unassignReason, $refund);
     } catch (Exception $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Error: ' . $e->getMessage());
         $cmd->setUsername($username);
         $cmd->redirect();
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully unassigned ' . $student->getFullName());
     $cmd->redirect();
 }
Ejemplo n.º 25
0
 public function show()
 {
     $pager = new DBPager('hms_roommate', 'HMS_Roommate');
     $pager->db->addWhere('confirmed', 1);
     $pager->db->addWhere('term', Term::getSelectedTerm());
     $pager->setModule('hms');
     $pager->setTemplate('admin/roommate_pager.tpl');
     $pager->addRowTags('get_roommate_pager_tags');
     $pager->setEmptyMessage('No roommate groups found.');
     # Setup searching on the requestor and requestee columns
     $pager->setSearch('requestor', 'requestee');
     return $pager->get();
 }
 public function execute(CommandContext $context)
 {
     if (!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', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'AssignmentMoveConfirmationView.php');
     $student = StudentFactory::getStudentByUsername($context->get('username'), Term::getSelectedTerm());
     $assignment = HMS_Assignment::getAssignment($student->getUsername(), Term::getSelectedTerm());
     $moveConfirmView = new AssignmentMoveConfirmationView($student, $assignment, $context->get('residence_hall'), $context->get('room'), $context->get('bed'), $context->get('meal_plan'), $context->get('assignment_type'), $context->get('notes'));
     $context->setContent($moveConfirmView->show());
 }
Ejemplo n.º 27
0
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     $tpl = array();
     $tpl['TITLE'] = "Denied RLC Applications - " . Term::toString(Term::getSelectedTerm());
     $tpl['DENIED_PAGER'] = HMS_RLC_Application::denied_pager();
     if (isset($success_msg)) {
         $tpl['SUCCESS_MSG'] = $success_msg;
     }
     if (isset($error_msg)) {
         $tpl['ERROR_MSG'] = $error_msg;
     }
     Layout::addPageTitle("Denied RLC Applications");
     return PHPWS_Template::process($tpl, 'hms', 'admin/view_denied_rlc_applications.tpl');
 }
Ejemplo n.º 28
0
 public static function execute()
 {
     session_start();
     PHPWS_Core::initModClass('hms', 'Term.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('users', 'Users.php');
     PHPWS_Core::initModClass('users', 'Current_User.php');
     PHPWS_Core::initModClass('hms', 'UserStatus.php');
     $errors = null;
     $term = Term::getSelectedTerm();
     $db1 = Database::newDB();
     $t1 = $db1->addTable('hms_new_application');
     $t1->addFieldConditional('term', $term);
     $t1->addField('username');
     $db2 = Database::newDB();
     $t2 = $db2->addTable('hms_assignment');
     $t2->addFieldConditional('term', $term);
     $t2->addField('asu_username');
     $union = new \Database\Union(array($db1, $db2));
     $result = $union->select();
     if (empty($result)) {
         return 'No assignments or applications. Check your database.';
     }
     $count = 0;
     $error_count = 0;
     $_SESSION['User'] = new PHPWS_User();
     $_SESSION['User']->username = '******';
     $_SESSION['User']->display_name = 'Nightly Cache';
     foreach ($result as $row) {
         $count++;
         try {
             //asking for the student updates the cache since the ttl is zero
             StudentFactory::getStudentByUsername($row['username'], $term);
         } catch (Exception $e) {
             $errors[] = $e->getMessage() . "\n";
             $error_count++;
         }
         if ($error_count >= HMS_CACHE_ERROR_THRESHOLD) {
             throw new \Exception(HMS_CACHE_ERROR_THRESHOLD . ' errors occurred. Shutting down cache prematurely.');
         }
     }
     $message = "{$count} student records cached.\n";
     if (!empty($errors)) {
         $message .= "Errors occurred:\n";
         $message .= implode("\n", $errors);
     }
     return $message;
 }
Ejemplo n.º 29
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'Autoassigner.php');
     // TODO: PULSE!
     echo "<html><head><title>AUTOASSIGNER TEST MODE</title></head><body><pre>\n\n";
     echo "AUTOASSIGNER 1970s MODE\n\n";
     try {
         $assigner = new Autoassigner(Term::getSelectedTerm());
         $assigner->autoassign();
     } catch (Exception $e) {
         echo "EXCEPTION CAUGHT: " . $e->getMessage() . "<br /><br />\n\n";
         var_dump($e->getTrace());
     }
     echo "</pre></body></html>\n\n";
     exit(0);
 }
 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 unassign students.');
     }
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'UnassignStudentView.php');
     $username = $context->get('username');
     if (isset($username) && !is_null($username) && $username != '') {
         $student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm());
     } else {
         $student = NULL;
     }
     $unassignView = new UnassignStudentView($student);
     $context->setContent($unassignView->show());
 }