/**
  * Generates a template for the rlc sort dropdown box
  *
  * @return string HTML for community selector drop down
  */
 public function getFilters()
 {
     javascript('jquery');
     javascript('modules/hms/page_refresh');
     // Get the list of communities
     $communities = RlcFactory::getRlcList($this->term);
     $communityList = array('0' => 'All');
     foreach ($communities as $key => $val) {
         $communityList[$key] = $val;
     }
     // Initialize form and submit command
     $submitCmd = CommandFactory::getCommand('ShowAssignRlcApplicants');
     $form = new PHPWS_Form('dropdown_selector');
     $submitCmd->initForm($form);
     $form->setMethod('get');
     // Community drop down
     $form->addSelect('rlc', $communityList);
     if (isset($this->rlc) && !is_null($this->rlc)) {
         $form->setMatch('rlc', $this->rlc->getId());
     }
     $form->setClass('rlc', 'form-control');
     $form->setExtra('rlc', 'onChange="refresh_page(\'dropdown_selector\')"');
     // Student Type drop down
     $form->addSelect('student_type', array(0 => 'All', TYPE_CONTINUING => 'Continuing', TYPE_FRESHMEN => 'Freshmen'));
     if (isset($this->studentType)) {
         $form->setMatch('student_type', $this->studentType);
     }
     $form->setClass('student_type', 'form-control');
     $form->setExtra('student_type', 'onChange="refresh_page(\'dropdown_selector\')"');
     return PHPWS_Template::process($form->getTemplate(), 'hms', 'admin/rlcApplicationListFilters.tpl');
 }
 /**
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'view_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to view RLC applications.');
     }
     $community = null;
     $id = $context->get('rlc');
     // If an id was passed in, then try to load that community
     if (isset($id) && $id != 0) {
         PHPWS_Core::initModClass('hms', 'RlcFactory.php');
         $community = RlcFactory::getRlcById($id);
     }
     $studentType = $context->get('student_type');
     if (isset($studentType) && $studentType == '0') {
         $studentType = null;
     }
     $term = Term::getSelectedTerm();
     $view = new RlcAssignmentView($term, $community, $studentType);
     $context->setContent($view->show());
 }
 public function show()
 {
     $tpl = array();
     $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate);
     $tpl['STATUS'] = "";
     if (!is_null($this->rlcAssignment) && !is_null($this->roomAssignment) && $this->rlcAssignment->getStateName() == 'selfselect-assigned') {
         $tpl['ICON'] = FEATURE_COMPLETED_ICON;
         $tpl['SELF_ASSIGNMENT'] = $this->roomAssignment->where_am_i();
         $tpl['ASSIGNED_COMMUNITY_NAME'] = $this->rlcAssignment->getRlcName();
     } else {
         if (!is_null($this->rlcAssignment) && !is_null($this->roomAssignment)) {
             // Student is already assigned, but didn't self-select
             $tpl['ICON'] = FEATURE_LOCKED_ICON;
             $tpl['ASSIGNMENT'] = '';
         } else {
             if (time() < $this->startDate) {
                 // To early
                 $tpl['ICON'] = FEATURE_NOTYET_ICON;
                 $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate);
             } else {
                 if (time() > $this->endDate) {
                     // Too late
                     $tpl['ICON'] = FEATURE_LOCKED_ICON;
                     // fade out header
                     $tpl['STATUS'] = "locked";
                     $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate);
                 } else {
                     if (is_null($this->rlcAssignment)) {
                         // Student has no RLC assignment, therefore is not eligible
                         $tpl['ICON'] = FEATURE_LOCKED_ICON;
                         $tpl['NOT_ELIGIBLE'] = "";
                         //dummy tag, text is in template
                     } else {
                         if ($this->rlcAssignment->getStateName() == 'selfselect-invite') {
                             // Student has a pending invite to self-select a room
                             $tpl['ICON'] = FEATURE_OPEN_ICON;
                             $rlcId = $this->rlcAssignment->getRlcId();
                             $rlcList = RlcFactory::getRlcList($this->term);
                             $tpl['INVITED_COMMUNITY_NAME'] = $rlcList[$rlcId];
                             $cmd = CommandFactory::getCommand('RlcSelfAssignStart');
                             $cmd->setTerm($this->term);
                             $tpl['SELECT_LINK'] = $cmd->getLink('accept the invitation and select a room');
                         } else {
                             // Deadlines are open, but student isn't eligible
                             $tpl['ICON'] = FEATURE_LOCKED_ICON;
                             $tpl['NOT_ELIGIBLE'] = "";
                             //dummy tag, text is in template
                         }
                     }
                 }
             }
         }
     }
     // Show roommate requests, if any
     if (time() > $this->startDate && $this->roommateRequests != false && !is_null($this->roommateRequests) && $this->roomAssignment != true && !PEAR::isError($this->roomAssignment)) {
         $tpl['roommates'] = array();
         $tpl['ROOMMATE_REQUEST'] = '';
         // dummy tag
         foreach ($this->roommateRequests as $invite) {
             $cmd = CommandFactory::getCommand('LotteryShowRoommateRequest');
             $cmd->setRequestId($invite['id']);
             $roommie = StudentFactory::getStudentByUsername($invite['requestor'], $this->term);
             $tpl['roommates'][]['ROOMMATE_LINK'] = $cmd->getLink($roommie->getName());
         }
     }
     return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/rlcSelfSelection.tpl');
 }
 public function show()
 {
     javascript('jquery');
     javascript('jquery_ui');
     javascriptMod('hms', 'StudentProfile');
     $tpl = array();
     $tpl['USERNAME'] = $this->student->getUsername();
     if (Current_User::allow('hms', 'login_as_student')) {
         $loginAsStudent = CommandFactory::getCommand('LoginAsStudent');
         $loginAsStudent->setUsername($this->student->getUsername());
         $tpl['LOGIN_AS_STUDENT_URI'] = $loginAsStudent->getURI();
     }
     $tpl['BANNER_ID'] = $this->student->getBannerId();
     $tpl['NAME'] = $this->student->getFullName();
     $tpl['TERM'] = Term::getPrintableSelectedTerm();
     $tpl['GENDER'] = $this->student->getPrintableGender();
     $tpl['DOB'] = $this->student->getDOB();
     if (strtotime($this->student->getDOB()) < strtotime("-25 years")) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'Student is 25 years old or older!');
     }
     $tpl['CLASS'] = $this->student->getPrintableClass();
     $tpl['TYPE'] = $this->student->getPrintableType();
     $tpl['STUDENT_LEVEL'] = $this->student->getPrintableLevel();
     $tpl['ADMISSION_DECISION'] = $this->student->getAdmissionDecisionCode();
     $tpl['INTERNATIONAL'] = $this->student->isInternational() ? 'Yes' : 'No';
     $tpl['HONORS'] = $this->student->isHonors() ? 'Yes' : 'No';
     $tpl['TEACHING_FELLOW'] = $this->student->isTeachingFellow() ? 'Yes' : 'No';
     $tpl['WATAUGA'] = $this->student->isWataugaMember() ? 'Yes' : 'No';
     if ($this->student->pinDisabled()) {
         NQ::simple('hms', hms\NotificationView::WARNING, "This student's PIN is disabled.");
     }
     try {
         $tpl['APPLICATION_TERM'] = Term::toString($this->student->getApplicationTerm());
     } catch (InvalidTermException $e) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'Application term is bad or missing.');
         $tpl['APPLICATION_TERM'] = 'WARNING: Application Term is bad or missing: "' . $this->student->getApplicationTerm() . '"';
     }
     /*****************
      * Phone Numbers *
      *****************/
     $phoneNumberList = $this->student->getPhoneNumberList();
     if (isset($phoneNumberList) && !is_null($phoneNumberList)) {
         foreach ($this->student->getPhoneNumberList() as $phone_number) {
             $tpl['phone_number'][] = array('NUMBER' => $phone_number);
         }
     }
     /*************
      * Addresses *
      *************/
     foreach ($this->student->getAddressList() as $address) {
         //If it's not a PS or PR address, skip it
         if ($address->atyp_code != 'PR' && $address->atyp_code != 'PS') {
             continue;
         }
         switch ($address->atyp_code) {
             case 'PS':
                 $addr_type = 'Student Address';
                 break;
             case 'PR':
                 $addr_type = 'Permanent Residence Address';
                 break;
             default:
                 $addr_type = 'Unknown-type address';
         }
         $addr_array = array();
         $addr_array['ADDR_TYPE'] = $addr_type;
         $addr_array['ADDRESS_L1'] = $address->line1;
         if (isset($address->line2)) {
             $addr_array['ADDRESS_L2'] = $address->line2;
         }
         if (isset($address->line3)) {
             $addr_array['ADDRESS_L3'] = $address->line3;
         }
         $addr_array['CITY'] = $address->city;
         $addr_array['STATE'] = $address->state;
         $addr_array['ZIP'] = $address->zip;
         $tpl['addresses'][] = $addr_array;
     }
     /**************
      * Assignment *
      **************/
     if (!is_null($this->assignment)) {
         $reassignCmd = CommandFactory::getCommand('ShowAssignStudent');
         $reassignCmd->setUsername($this->student->getUsername());
         $unassignCmd = CommandFactory::getCommand('ShowUnassignStudent');
         $unassignCmd->setUsername($this->student->getUsername());
         $tpl['ASSIGNMENT'] = $this->assignment->where_am_i(true) . ' ' . $reassignCmd->getLink('Reassign') . ' ' . $unassignCmd->getLink('Unassign');
     } else {
         $assignCmd = CommandFactory::getCommand('ShowAssignStudent');
         $assignCmd->setUsername($this->student->getUsername());
         $tpl['NOT_ASSIGNED'] = $assignCmd->getURI();
     }
     /*************
      * Roommates
      *************/
     if (isset($this->roommates) && !empty($this->roommates)) {
         // Remember, student can only have one confirmed or pending request
         // but multiple assigned roommates
         if (isset($this->roommates['PENDING'])) {
             $tpl['pending'][]['ROOMMATE'] = $this->roommates['PENDING'];
         } else {
             if (isset($this->roommates['CONFIRMED'])) {
                 $tpl['confirmed'][]['ROOMMATE'] = $this->roommates['CONFIRMED'];
             } else {
                 if (isset($this->roommates['NO_BED_AVAILABLE'])) {
                     $tpl['error_status'][]['ROOMMATE'] = $this->roommates['NO_BED_AVAILABLE'];
                 } else {
                     if (isset($this->roommates['MISMATCHED_ROOMS'])) {
                         $tpl['error_status'][]['ROOMMATE'] = $this->roommates['MISMATCHED_ROOMS'];
                     }
                 }
             }
         }
         if (isset($this->roommates['ASSIGNED'])) {
             foreach ($this->roommates['ASSIGNED'] as $roommate) {
                 $tpl['assigned'][]['ROOMMATE'] = $roommate;
             }
         }
     }
     /**************
      * RLC Status *
      *************/
     $rlc_names = RlcFactory::getRlcList(Term::getSelectedTerm());
     $rlc_assignment = HMS_RLC_Assignment::getAssignmentByUsername($this->student->getUsername(), Term::getSelectedTerm());
     $rlc_application = HMS_RLC_Application::getApplicationByUsername($this->student->getUsername(), Term::getSelectedTerm());
     if (!is_null($rlc_assignment)) {
         $tpl['RLC_STATUS'] = "This student is assigned to: " . $rlc_names[$rlc_assignment->rlc_id];
     } else {
         if (!is_null($rlc_application)) {
             $rlcViewCmd = CommandFactory::getCommand('ShowRlcApplicationReView');
             $rlcViewCmd->setAppId($rlc_application->getId());
             $tpl['RLC_STATUS'] = "This student has a " . $rlcViewCmd->getLink('pending RLC application') . ".";
         } else {
             $tpl['RLC_STATUS'] = "This student is not in a Learning Community and has no pending application.";
         }
     }
     /*************************
      * Re-application status *
      *************************/
     $reapplication = HousingApplicationFactory::getAppByStudent($this->student, Term::getSelectedTerm());
     # If this is a re-application, then check the special interest group status
     # TODO: incorporate all this into the LotteryApplication class
     if ($reapplication !== FALSE && $reapplication instanceof LotteryApplication) {
         if (isset($reapplication->special_interest) && !is_null($reapplication->special_interest) && !empty($reapplication->special_interest)) {
             # Student has been approved for a special group
             # TODO: format the name according to the specific group (sororities, etc)
             $tpl['SPECIAL_INTEREST'] = $reapplication->special_interest . '(confirmed)';
         } else {
             # Check if the student selected a group on the application, but hasn't been approved
             if (!is_null($reapplication->sorority_pref)) {
                 $tpl['SPECIAL_INTEREST'] = $reapplication->sorority_pref . ' (pending)';
                 //}else if($reapplication->tf_pref == 1){
                 //$tpl['SPECIAL_INTEREST'] = 'Teaching Fellow (pending)';
             } else {
                 if ($reapplication->wg_pref == 1) {
                     $tpl['SPECIAL_INTEREST'] = 'Watauga Global (pending)';
                 } else {
                     if ($reapplication->honors_pref == 1) {
                         $tpl['SPECIAL_INTEREST'] = 'Honors (pending)';
                     } else {
                         if ($reapplication->rlc_interest == 1) {
                             $tpl['SPECIAL_INTEREST'] = 'RLC (pending)';
                         } else {
                             # Student didn't select anything
                             $tpl['SPECIAL_INTEREST'] = 'No';
                         }
                     }
                 }
             }
         }
     } else {
         # Not a re-application, so can't have a special group
         $tpl['SPECIAL_INTEREST'] = 'No';
     }
     /******************
      * Housing Waiver *
      *************/
     $tpl['HOUSING_WAIVER'] = $this->student->housingApplicationWaived() ? 'Yes' : 'No';
     if ($this->student->housingApplicationWaived()) {
         NQ::simple('hms', hms\NotificationView::WARNING, "This student's housing application has been waived for this term.");
     }
     /****************
      * Applications *
      *************/
     $appList = new ProfileHousingAppList($this->applications);
     $tpl['APPLICATIONS'] = $appList->show();
     /*********
      * Assignment History *
      *********/
     $historyArray = StudentAssignmentHistory::getAssignments($this->student->getBannerId());
     $historyView = new StudentAssignmentHistoryView($historyArray);
     $tpl['HISTORY'] = $historyView->show();
     /**********
      * Checkins
      */
     $checkins = CheckinFactory::getCheckinsForStudent($this->student);
     $checkinHistory = new CheckinHistoryView($checkins);
     $tpl['CHECKINS'] = $checkinHistory->show();
     /*********
      * Notes *
      *********/
     $addNoteCmd = CommandFactory::getCommand('AddNote');
     $addNoteCmd->setUsername($this->student->getUsername());
     $form = new PHPWS_Form('add_note_dialog');
     $addNoteCmd->initForm($form);
     $form->addTextarea('note');
     $form->addSubmit('Add Note');
     /********
      * Logs *
      ********/
     $everything_but_notes = HMS_Activity_Log::get_activity_list();
     unset($everything_but_notes[array_search(ACTIVITY_ADD_NOTE, $everything_but_notes)]);
     if (Current_User::allow('hms', 'view_activity_log') && Current_User::allow('hms', 'view_student_log')) {
         PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
         $activityLogPager = new ActivityLogPager($this->student->getUsername(), null, null, true, null, null, $everything_but_notes, true, 10);
         $activityNotePager = new ActivityLogPager($this->student->getUsername(), null, null, true, null, null, array(0 => ACTIVITY_ADD_NOTE), true, 10);
         $tpl['LOG_PAGER'] = $activityLogPager->show();
         $tpl['NOTE_PAGER'] = $activityNotePager->show();
         $logsCmd = CommandFactory::getCommand('ShowActivityLog');
         $logsCmd->setActeeUsername($this->student->getUsername());
         $tpl['LOG_PAGER'] .= $logsCmd->getLink('View more');
         $notesCmd = CommandFactory::getCommand('ShowActivityLog');
         $notesCmd->setActeeUsername($this->student->getUsername());
         $notesCmd->setActivity(array(0 => ACTIVITY_ADD_NOTE));
         $tpl['NOTE_PAGER'] .= $notesCmd->getLink('View more');
     }
     $tpl = array_merge($tpl, $form->getTemplate());
     // TODO logs
     // TODO tabs
     Layout::addPageTitle("Student Profile");
     return PHPWS_Template::process($tpl, 'hms', 'admin/StudentProfile.tpl');
 }
Beispiel #5
0
 public function show()
 {
     $tpl = array();
     $tpl['HALL_NAME'] = $this->hall->getLink();
     $tpl['FLOOR_NUMBER_LINK'] = $this->floor->getLink('Floor');
     $tpl['FLOOR_NUMBER'] = $this->floor->where_am_i();
     $tpl['TERM'] = Term::getPrintableSelectedTerm();
     $cmd = CommandFactory::getCommand('AddRoom');
     $cmd->floor = $this->floor->id;
     $form = new PHPWS_Form();
     $cmd->initForm($form);
     $form->addText('room_number');
     $form->addCssClass('room_number', 'form-control');
     $form->addHidden('hall_id', $this->hall->id);
     $form->addHidden('floor_id', $this->floor->id);
     if ($this->floor->gender_type == COED) {
         $form->addDropBox('gender_type', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC));
         $form->addCssClass('gender_type', 'form-control');
         $form->setMatch('gender_type', HMS_Util::formatGender($this->floor->gender_type));
     } else {
         $form->addDropBox('gender_type', array($this->floor->gender_type => HMS_Util::formatGender($this->floor->gender_type)));
         $form->setReadOnly('gender_type', true);
     }
     // Always show the option to set the default gender
     $defGenders = array(FEMALE => FEMALE_DESC, MALE => MALE_DESC);
     if ($this->floor->gender_type == MALE) {
         unset($defGenders[FEMALE]);
     }
     if ($this->floor->gender_type == FEMALE) {
         unset($defGenders[MALE]);
     }
     $form->addDropBox('default_gender', $defGenders);
     $form->addCssClass('default_gender', 'form-control');
     if ($this->floor->gender_type != COED) {
         $form->setMatch('default_gender', $this->floor->gender_type);
     }
     // Add a dropbox to for rlc
     $form->addDropBox('rlc_reserved', array("0" => "None") + RlcFactory::getRlcList(Term::getSelectedTerm()));
     $form->setLabel('rlc_reserved', 'Reserved for RLC');
     $form->addCssClass('rlc_reserved', 'form-control');
     $form->addCheck('offline', 1);
     $form->setLabel('offline', 'Offline');
     $form->addCheck('reserved', 1);
     $form->setLabel('reserved', 'Reserved');
     $form->addCheck('ra', 1);
     $form->setLabel('ra', 'Reserved for RA');
     $form->addCheck('private', 1);
     $form->setLabel('private', 'Private');
     $form->addCheck('overflow', 1);
     $form->setLabel('overflow', 'Overflow');
     $form->addCheck('parlor', 1);
     $form->setLabel('parlor', 'Parlor');
     $form->addCheck('ada', 1);
     $form->setLabel('ada', 'ADA');
     $form->addCheck('hearing_impaired', 1);
     $form->setLabel('hearing_impaired', 'Hearing Impaired');
     $form->addCheck('bath_en_suite', 1);
     $form->setLabel('bath_en_suite', 'Bath en Suite');
     $form->addSubmit('submit', 'Submit');
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'hms', 'admin/addRoom.tpl');
 }
Beispiel #6
0
 /**
  * DBPager row method for the floor edit pager.
  *
  * @return Array
  */
 public function get_row_edit()
 {
     javascript('jquery');
     $tpl = array();
     $tpl['ID'] = $this->id;
     $tpl['ROOM_NUMBER'] = PHPWS_Text::secureLink($this->room_number, 'hms', array('action' => 'EditRoomView', 'room' => $this->id));
     if (Current_User::allow('hms', 'room_structure') && $this->get_number_of_assignees() == 0) {
         $deleteRoomCmd = CommandFactory::getCommand('DeleteRoom');
         $deleteRoomCmd->setRoomId($this->id);
         $deleteRoomCmd->setFloorId($this->floor_id);
         $confirm = array();
         $confirm['QUESTION'] = 'Are you sure want to delete room ' . $this->room_number . '?';
         $confirm['ADDRESS'] = $deleteRoomCmd->getURI();
         $confirm['LINK'] = 'Delete';
         $tpl['DELETE'] = Layout::getJavascript('confirm', $confirm);
     }
     $form = new PHPWS_Form($this->id);
     $form->addSelect('gender_type', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, COED => COED_DESC, AUTO => AUTO_DESC));
     $form->setMatch('gender_type', $this->gender_type);
     $form->setExtra('gender_type', 'onChange="submit_form(this, true)"');
     $form->addSelect('default_gender', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, AUTO => AUTO_DESC));
     $form->setMatch('default_gender', $this->default_gender);
     $form->setExtra('default_gender', 'onChange="submit_form(this, true)"');
     $form->addSelect('rlc_reserved', array('-1' => 'Select RLC') + RlcFactory::getRlcList($this->term));
     $form->setMatch('rlc_reserved', $this->getReservedRlcId());
     $form->setExtra('rlc_reserved', 'onChange="submit_form(this, true)"');
     $form->addCheck('offline', 'yes');
     $form->setMatch('offline', $this->offline == 1 ? 'yes' : 0);
     $form->setExtra('offline', 'onChange="submit_form(this, false)"');
     $form->addCheck('reserved', 'yes');
     $form->setMatch('reserved', $this->reserved == 1 ? 'yes' : 0);
     $form->setExtra('reserved', 'onChange="submit_form(this, false)"');
     $form->addCheck('ra', 'yes');
     $form->setMatch('ra', $this->ra == 1 ? 'yes' : 0);
     $form->setExtra('ra', 'onChange="submit_form(this, false)"');
     $form->addCheck('private', 'yes');
     $form->setMatch('private', $this->private == 1 ? 'yes' : 0);
     $form->setExtra('private', 'onChange="submit_form(this, false)"');
     $form->addCheck('overflow', 'yes');
     $form->setMatch('overflow', $this->overflow == 1 ? 'yes' : 0);
     $form->setExtra('overflow', 'onChange="submit_form(this, false)"');
     $form->addCheck('ada', 'yes');
     $form->setMatch('ada', $this->isAda() ? 'yes' : 0);
     $form->setExtra('ada', 'onChange="submit_form(this, false)"');
     $form->addHidden('action', 'UpdateRoomField');
     $form->addHidden('room', $this->id);
     $form->mergeTemplate($tpl);
     //test($form->getTemplate(),1);
     return $form->getTemplate();
 }
Beispiel #7
0
 /**
  * @see View::show()
  */
 public function show()
 {
     $jsParams = array('LINK_SELECT' => '#addDamageLink');
     javascript('addRoomDamage', $jsParams, 'mod/hms/');
     // Drop down enhancements for room damage dialog
     javascript('chosen', null, 'mod/hms/');
     /*** Header Info ***/
     $tpl = array();
     $tpl['TERM'] = Term::getPrintableSelectedTerm();
     $tpl['HALL_NAME'] = $this->hall->getLink();
     $tpl['FLOOR_NUMBER'] = $this->floor->getLink('Floor');
     /*** Page Title ***/
     $tpl['ROOM'] = $this->room->getRoomNumber();
     /*** Room Attributes Labels ***/
     if ($this->room->isOffline()) {
         $tpl['OFFLINE_ATTRIB'] = 'Offline';
     }
     if ($this->room->isReserved()) {
         $tpl['RESERVED_ATTRIB'] = 'Reserved';
     }
     if ($this->room->isRa()) {
         $tpl['RA_ATTRIB'] = 'RA';
     }
     if ($this->room->isPrivate()) {
         $tpl['PRIVATE_ATTRIB'] = 'Private';
     }
     if ($this->room->isOverflow()) {
         $tpl['OVERFLOW_ATTRIB'] = 'Overflow';
     }
     if ($this->room->isParlor()) {
         $tpl['PARLOR_ATTRIB'] = 'Parlor';
     }
     if ($this->room->isADA()) {
         $tpl['ADA_ATTRIB'] = 'ADA';
     }
     if ($this->room->isHearingImpaired()) {
         $tpl['HEARING_ATTRIB'] = 'Hearing Impaired';
     }
     if ($this->room->bathEnSuite()) {
         $tpl['BATHENSUITE_ATTRIB'] = 'Bath en Suite';
     }
     $number_of_assignees = $this->room->get_number_of_assignees();
     $tpl['NUMBER_OF_BEDS'] = $this->room->get_number_of_beds();
     $tpl['NUMBER_OF_ASSIGNEES'] = $number_of_assignees;
     $form = new PHPWS_Form();
     $submitCmd = CommandFactory::getCommand('EditRoom');
     $submitCmd->setRoomId($this->room->id);
     $submitCmd->initForm($form);
     $form->addText('room_number', $this->room->getRoomNumber());
     $form->setLabel('room_number', 'Room Number');
     $form->addCssClass('room_number', 'form-control');
     /*** Room Gender ***/
     if ($number_of_assignees == 0) {
         // Room is empty, show the drop down so the user can change the gender
         $roomGenders = array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, AUTO => AUTO_DESC);
         // Check if the user is allowed to set rooms to co-ed, if so add Co-ed to the drop down
         if (Current_User::allow('hms', 'coed_rooms')) {
             $roomGenders[COED] = COED_DESC;
         }
         $form->addDropBox('gender_type', $roomGenders);
         $form->setMatch('gender_type', $this->room->gender_type);
         $form->addCssClass('gender_type', 'form-control');
     } else {
         // Room is not empty so just show the gender (no drop down)
         $tpl['GENDER_MESSAGE'] = HMS_Util::formatGender($this->room->getGender());
         // Add a hidden variable for 'gender_type' so it will be defined upon submission
         $form->addHidden('gender_type', $this->room->gender_type);
         // Show the reason the gender could not be changed.
         if ($number_of_assignees != 0) {
             $tpl['GENDER_REASON'] = 'Remove occupants to change room gender.';
         }
     }
     //Always show the option to set the default gender
     $form->addDropBox('default_gender', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, AUTO => AUTO_DESC));
     $form->setLabel('default_gender', 'Default Gender');
     $form->setMatch('default_gender', $this->room->default_gender);
     $form->addCssClass('default_gender', 'form-control');
     $form->addDropBox('rlc_reserved', array("0" => "Choose RLC") + RlcFactory::getRlcList($this->room->getTerm()));
     $form->setLabel('rlc_reserved', 'Reserved for RLC');
     $form->setMatch('rlc_reserved', $this->room->getReservedRlcId());
     $form->addCssClass('rlc_reserved', 'form-control');
     $form->addCheck('offline', 1);
     $form->setLabel('offline', 'Offline');
     $form->setMatch('offline', $this->room->isOffline());
     $form->addCheck('reserved', 1);
     $form->setLabel('reserved', 'Reserved');
     $form->setMatch('reserved', $this->room->isReserved());
     $form->addCheck('ra', 1);
     $form->setLabel('ra', 'Reserved for RA');
     $form->setMatch('ra', $this->room->isRa());
     $form->addCheck('private', 1);
     $form->setLabel('private', 'Private');
     $form->setMatch('private', $this->room->isPrivate());
     $form->addCheck('overflow', 1);
     $form->setLabel('overflow', 'Overflow');
     $form->setMatch('overflow', $this->room->isOverflow());
     $form->addCheck('parlor', 1);
     $form->setLabel('parlor', 'Parlor');
     $form->setMatch('parlor', $this->room->isParlor());
     $form->addCheck('ada', 1);
     $form->setLabel('ada', 'ADA');
     $form->setMatch('ada', $this->room->isAda());
     $form->addCheck('hearing_impaired', 1);
     $form->setLabel('hearing_impaired', 'Hearing Impaired');
     $form->setMatch('hearing_impaired', $this->room->isHearingImpaired());
     $form->addCheck('bath_en_suite', 1);
     $form->setLabel('bath_en_suite', 'Bath en Suite');
     $form->setMatch('bath_en_suite', $this->room->bathEnSuite());
     $form->addSubmit('submit', 'Submit');
     // Assignment pagers
     $tpl['BED_PAGER'] = HMS_Bed::bed_pager_by_room($this->room->id);
     // if the user has permission to view the form but not edit it then
     // disable it
     if (Current_User::allow('hms', 'room_view') && !Current_User::allow('hms', 'room_attributes') && !Current_User::allow('hms', 'room_structure')) {
         $form_vars = get_object_vars($form);
         $elements = $form_vars['_elements'];
         foreach ($elements as $element => $value) {
             $form->setDisabled($element);
         }
     }
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     $reasonsList = HMS_Room::listReserveReasons();
     $tpl['ATHLETICS_OPTIONS'] = $reasonsList['Athletics'];
     $tpl['SPECIAL_NEEDS_OPTIONS'] = $reasonsList['SpecialNeeds'];
     $tpl['SCHOLARS_OPTIONS'] = $reasonsList['ScholarsOrganizations'];
     $tpl['MISC_OPTIONS'] = $reasonsList['Miscellaneous'];
     if ($this->room->getReservedReason() == "") {
         $tpl['CURRENT_REASON'] = 'none';
     } else {
         $tpl['CURRENT_REASON'] = $this->room->getReservedReason();
     }
     $tpl['RESERVED_NOTES'] = $this->room->getReservedNotes();
     Layout::addPageTitle("Edit Room");
     $tpl['ROOM_DAMAGE_LIST'] = $this->roomDamagePager();
     if (Current_User::allow('hms', 'add_room_dmg')) {
         $dmgCmd = CommandFactory::getCommand('ShowAddRoomDamage');
         $dmgCmd->setRoom($this->room);
         $tpl['ADD_DAMAGE_URI'] = $dmgCmd->getURI();
     }
     return PHPWS_Template::process($tpl, 'hms', 'admin/edit_room.tpl');
 }
Beispiel #8
0
 public function show()
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'floor_view')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You are not allowed to edit or view floors.');
     }
     javascript('jquery_ui');
     $floor_num = $this->floor->getFloorNumber();
     // Setup the title and color of the title bar
     $tpl = array();
     $tpl['FLOOR_NUMBER'] = HMS_Util::ordinal($floor_num);
     $tpl['TERM'] = Term::getPrintableSelectedTerm();
     $submitCmd = CommandFactory::getCommand('EditFloor');
     $submitCmd->setFloorId($this->floor->getId());
     $form = new PHPWS_Form();
     $submitCmd->initForm($form);
     $tpl['HALL_NAME'] = $this->hall->getLink();
     $tpl['NUMBER_OF_ROOMS'] = $this->floor->get_number_of_rooms();
     $tpl['NUMBER_OF_BEDS'] = $this->floor->get_number_of_beds();
     $tpl['NOMINAL_BEDS'] = $this->floor->countNominalBeds();
     $tpl['NUMBER_OF_ASSIGNEES'] = $this->floor->get_number_of_assignees();
     if (!$this->floor->isOnline()) {
         $tpl['OFFLINE_ATTRIB'] = 'Offline';
     }
     $form->addDropBox('gender_type', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, COED => COED_DESC));
     $form->setMatch('gender_type', $this->floor->gender_type);
     $form->addCssClass('gender_type', 'form-control');
     $form->addCheck('is_online', 1);
     $form->setMatch('is_online', $this->floor->is_online);
     $movein_times = HMS_Movein_Time::get_movein_times_array();
     $form->addDropBox('f_movein_time', $movein_times);
     $form->addCssClass('f_movein_time', 'form-control');
     if (!isset($this->floor->f_movein_time_id)) {
         $form->setMatch('f_movein_time', 0);
     } else {
         $form->setMatch('f_movein_time', $this->floor->f_movein_time_id);
     }
     $form->addDropBox('t_movein_time', $movein_times);
     $form->addCssClass('t_movein_time', 'form-control');
     if (!isset($this->floor->t_movein_time_id)) {
         $form->setMatch('t_movein_time', 0);
     } else {
         $form->setMatch('t_movein_time', $this->floor->t_movein_time_id);
     }
     $form->addDropBox('rt_movein_time', $movein_times);
     $form->addCssClass('rt_movein_time', 'form-control');
     if (!isset($this->floor->rt_movein_time_id)) {
         $form->setMatch('rt_movein_time', 0);
     } else {
         $form->setMatch('rt_movein_time', $this->floor->rt_movein_time_id);
     }
     // Get a list of the RLCs indexed by id
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     $learning_communities = RlcFactory::getRlcList($this->floor->getTerm());
     $learning_communities[0] = 'None';
     $form->addDropBox('floor_rlc_id', $learning_communities);
     $form->addCssClass('floor_rlc_id', 'form-control');
     if (isset($this->floor->rlc_id)) {
         $tpl['RLC_NAME'] = $learning_communities[$this->floor->rlc_id];
         $form->setMatch('floor_rlc_id', $this->floor->rlc_id);
     } else {
         $form->setMatch('floor_rlc_id', 0);
     }
     PHPWS_Core::initModClass('filecabinet', 'Cabinet.php');
     if (isset($this->floor->floor_plan_image_id)) {
         $manager = Cabinet::fileManager('floor_plan_image_id', $this->floor->floor_plan_image_id);
     } else {
         $manager = Cabinet::fileManager('floor_plan_image_id');
     }
     $manager->maxImageWidth(300);
     $manager->maxImageHeight(300);
     $manager->imageOnly(false, false);
     $form->addTplTag('FILE_MANAGER', $manager->get());
     $form->addHidden('type', 'floor');
     $form->addHidden('op', 'edit_floor');
     $tpl['STATIC_ROOM_PAGER'] = HMS_Room::room_pager_by_floor($this->floor->id);
     $tpl['DYNAMIC_ROOM_PAGER'] = HMS_Room::room_pager_by_floor($this->floor->id, true);
     // if the user has permission to view the form but not edit it then
     // disable it
     if (Current_User::allow('hms', 'floor_view') && !Current_User::allow('hms', 'floor_attributes') && !Current_User::allow('hms', 'floor_structure')) {
         $form_vars = get_object_vars($form);
         $elements = $form_vars['_elements'];
         foreach ($elements as $element => $value) {
             $form->setDisabled($element);
         }
     }
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     if (Current_User::allow('hms', 'edit_role_members')) {
         javascript('modules/hms/role_editor');
         $tpl['ROLE_EDITOR'] = PHPWS_Template::process(array('CLASS_NAME' => "'HMS_Floor'", 'ID' => $this->floor->id), 'hms', 'admin/role_editor.tpl');
     }
     Layout::addPageTitle("Edit Floor");
     return PHPWS_Template::process($tpl, 'hms', 'admin/edit_floor.tpl');
 }