Ejemplo n.º 1
0
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     // Select all cancelled apps for the given term
     $db = new PHPWS_DB('hms_new_application');
     $db->addWhere('cancelled', 1);
     $db->addWhere('term', $this->term);
     $results = $db->select();
     // Initialize storage for processed rows
     $this->rows = array();
     // Get friendly cancellation reasons from HousingApplication
     $reasons = HousingApplication::getCancellationReasons();
     // Process and store each result
     foreach ($results as $app) {
         $row = array();
         $row['bannerId'] = $app['banner_id'];
         $row['username'] = $app['username'];
         $row['gender'] = HMS_Util::formatGender($app['gender']);
         $row['application_term'] = $app['application_term'];
         $row['student_type'] = $app['student_type'];
         $row['cancelled_reason'] = $reasons[$app['cancelled_reason']];
         $row['cancelled_on'] = HMS_Util::get_long_date($app['cancelled_on']);
         $row['cancelled_by'] = $app['cancelled_by'];
         $this->rows[] = $row;
     }
 }
Ejemplo n.º 2
0
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     $halls = HMS_Residence_Hall::get_halls($this->term);
     $rows = array();
     foreach ($halls as $hall) {
         if ($hall->count_avail_lottery_rooms('1') || $hall->count_avail_lottery_rooms('0')) {
             $row = array();
             $row['HALL_NAME'] = $hall->getHallName();
             $row['MALE_FREE'] = $hall->count_avail_lottery_rooms('1');
             $row['FEMALE_FREE'] = $hall->count_avail_lottery_rooms('0');
             $rooms = $hall->get_rooms();
             $roomRows = "";
             foreach ($rooms as $room) {
                 if ($room->count_avail_lottery_beds() > 0) {
                     $roomRow = "<tr><td>";
                     $roomRow = $roomRow . $room->getRoomNumber();
                     $roomRow = $roomRow . "</td><td>";
                     $roomRow = $roomRow . HMS_Util::formatGender($room->getGender());
                     $roomRow = $roomRow . "</td><td>";
                     $roomRow = $roomRow . $room->count_avail_lottery_beds();
                     $roomRow = $roomRow . "</td></tr>";
                     $roomRows = $roomRows . $roomRow;
                 }
             }
             $row['ROOMS'] = $roomRows;
             $rows[] = $row;
         }
     }
     $this->data = $rows;
 }
Ejemplo n.º 3
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.º 4
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));
    }
Ejemplo n.º 5
0
 public function execute(CommandContext $context)
 {
     $pdo = PdoFactory::getPdoInstance();
     $hall_id = (int) $context->get('hallId');
     $prep = $pdo->prepare('select id, floor_number, gender_type from hms_floor where residence_hall_id=? and is_online=1 order by floor_number');
     $prep->execute(array($hall_id));
     $rows = $prep->fetchAll(PDO::FETCH_ASSOC);
     if (empty($rows)) {
         return null;
     }
     foreach ($rows as $k => $r) {
         $gender = HMS_Util::formatGender($r['gender_type']);
         $rows[$k]['title'] = $r['floor_number'] . ' - ' . $gender;
     }
     $context->setContent(json_encode($rows));
 }
Ejemplo n.º 6
0
    public function execute()
    {
        $db = new PHPWS_DB();
        $query = <<<EOF
SELECT
        assign.banner_id,
        assign.asu_username,
        bed.bed_letter,
        bed.bedroom_label,
        room.room_number,
        floor.floor_number,
        hall.hall_name

FROM
        hms_assignment as assign
        LEFT JOIN hms_bed as bed on assign.bed_id=bed.id
        LEFT JOIN hms_room as room on bed.room_id=room.id
        LEFT JOIN hms_floor as floor on room.floor_id=floor.id
        LEFT JOIN hms_residence_hall as hall on floor.residence_hall_id=hall.id
WHERE
        assign.term = '{$this->term}'
ORDER BY
        hall.hall_name,
        floor.floor_number,
        room.room_number,
        bed.bedroom_label,
        bed.bed_letter
EOF;
        $result = $db->select(null, $query);
        if (PEAR::isError($result)) {
            throw new DatabaseException($result->toString());
        }
        $final_rows = array();
        foreach ($result as $row) {
            $hall_name = $row['hall_name'];
            $student = StudentFactory::getStudentByBannerId($row['banner_id'], $this->term);
            $row['name'] = $student->getFullName();
            $row['dob'] = $student->getDOB();
            $row['year'] = $student->getClass();
            $row['gender'] = HMS_Util::formatGender($student->getGender());
            $final_rows[$hall_name][] = $row;
        }
        $this->rows =& $final_rows;
    }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     //TODO check for a hallId
     $hall = new HMS_Residence_Hall($context->get('hallId'));
     $floors = $hall->getFloorsWithVacancies();
     $json_floors = array();
     $json_floors[0] = 'Select ...';
     foreach ($floors as $floor) {
         unset($text);
         $text = $floor->floor_number;
         if ($hall->gender_type == COED && $floor->gender_type != COED) {
             $text .= ' (' . HMS_Util::formatGender($floor->gender_type) . ')';
         }
         $json_floors[$floor->id] = $text;
     }
     $context->setContent(json_encode($json_floors));
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     //TODO check for a floorId
     $floor = new HMS_Floor($context->get('floorId'));
     $rooms = $floor->getRoomsWithVacancies();
     $json_rooms = array();
     $json_rooms[0] = 'Select ...';
     foreach ($rooms as $room) {
         unset($text);
         $text = $room->room_number;
         if ($floor->gender_type == COED) {
             $text .= ' (' . HMS_Util::formatGender($room->gender_type) . ')';
         }
         if ($room->ra == 1) {
             $text .= ' (RA)';
         }
         $json_rooms[$room->id] = $text;
     }
     $context->setContent(json_encode($json_rooms));
 }
Ejemplo n.º 9
0
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $db = new PHPWS_DB('hms_assignment');
     $db->addColumn('hms_assignment.banner_id');
     $db->addColumn('hms_assignment.reason');
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addColumn('hms_room.room_number');
     $db->addColumn('hms_new_application.cell_phone');
     $db->addWhere('hms_assignment.term', $this->term);
     $db->addJoin('LEFT OUTER', 'hms_assignment', 'hms_bed', 'bed_id', 'id');
     $db->addJoin('LEFT OUTER', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT OUTER', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT OUTER', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     $db->addJoin('LEFT OUTER', 'hms_assignment', 'hms_new_application', 'banner_id', 'banner_id AND hms_assignment.term = hms_new_application.term');
     $results = $db->select();
     if (PHPWS_Error::logIfError($results)) {
         return $results;
     }
     foreach ($results as $row) {
         try {
             $student = StudentFactory::getStudentByBannerId($row['banner_id'], $this->term);
             $bannerId = $student->getBannerId();
             $username = $student->getUsername();
             $first = $student->getFirstName();
             $middle = $student->getMiddleName();
             $last = $student->getLastName();
             $type = $student->getType();
             $appTerm = $student->getApplicationTerm();
             $cellPhone = $row['cell_phone'];
             $assignmentType = $row['reason'];
             $gender = HMS_Util::formatGender($student->getGender());
             $dob = $student->getDob();
             $room = $row['hall_name'] . ' ' . $row['room_number'];
             $address = $student->getAddress(NULL);
             if (!$address || !isset($address) || is_null($address)) {
                 $line1 = "";
                 $line2 = "";
                 $line3 = "";
                 $city = "";
                 $state = "";
                 $zip = "";
             } else {
                 $line1 = $address->line1;
                 $line2 = $address->line2;
                 $line3 = $address->line3;
                 $city = $address->city;
                 $state = $address->state;
                 $zip = $address->zip;
             }
         } catch (StudentNotFoundException $e) {
             $bannerId = $row['banner_id'];
             $username = '';
             $first = '';
             $middle = '';
             $last = '';
             $gender = '';
             $dob = '';
             $type = '';
             $cellPhone = '';
             $line1 = '';
             $line2 = '';
             $line3 = '';
             $city = '';
             $state = '';
             $zip = '';
             $appTerm = '';
             $assignmentType = '';
             $room = '';
         }
         $this->rows[] = array($username, $bannerId, $first, $middle, $last, $gender, $dob, $type, $appTerm, $cellPhone, $assignmentType, $room, $line1, $line2, $line3, $city, $state, $zip);
     }
 }
Ejemplo n.º 10
0
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'SpringApplication.php');
     PHPWS_Core::initModClass('hms', 'SummerApplication.php');
     PHPWS_Core::initModClass('hms', 'FallApplication.php');
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $term = $this->term;
     $sem = Term::getTermSem($term);
     // List of student 'application terms' which we'll consider as 'Freshmen' for term we're looking at
     // E.g. Students with an applicationt erm in Summer 1, Summer 2, and Fall all count as Freshmen for Fall.
     $applicationTerms = array();
     $db = new PHPWS_DB('hms_new_application');
     $db->addColumn('hms_new_application.banner_id');
     $db->addColumn('hms_new_application.username');
     $db->addColumn('hms_new_application.term');
     $db->addColumn('hms_new_application.gender');
     $db->addColumn('hms_new_application.application_term');
     $db->addColumn('hms_new_application.student_type');
     $db->addColumn('hms_new_application.cell_phone');
     $db->addColumn('hms_new_application.meal_plan');
     $db->addColumn('hms_new_application.physical_disability');
     $db->addColumn('hms_new_application.psych_disability');
     $db->addColumn('hms_new_application.medical_need');
     $db->addColumn('hms_new_application.gender_need');
     $db->addColumn('hms_new_application.international');
     $db->addColumn('hms_new_application.created_on');
     // Join for additional application data based on semester
     switch ($sem) {
         case TERM_SUMMER1:
         case TERM_SUMMER2:
             $db->addJoin('', 'hms_new_application', 'hms_summer_application', 'id', 'id');
             $db->addColumn('hms_summer_application.*');
             $applicationTerms[] = $term;
             $db->addWhere('application_type', 'summer');
             break;
         case TERM_FALL:
             $db->addJoin('', 'hms_new_application', 'hms_fall_application', 'id', 'id');
             $db->addColumn('hms_fall_application.*');
             // Add the summer 1 and summe 2 application terms
             $summer2 = Term::getPrevTerm($term);
             $summer1 = Term::getPrevTerm($summer2);
             $applicationTerms[] = $summer1;
             $applicationTerms[] = $summer2;
             $applicationTerms[] = $term;
             $db->addWhere('application_type', 'fall');
             break;
         case TERM_SPRING:
             $db->addJoin('', 'hms_new_application', 'hms_spring_application', 'id', 'id');
             $db->addColumn('hms_spring_application.*');
             $applicationTerms[] = $term;
             $db->addWhere('application_type', 'spring');
             break;
         default:
             // error
             throw new InvalidArgumentException('Invalid term specified.');
     }
     // Join for un-assigned students
     $db->addJoin('LEFT OUTER', 'hms_new_application', 'hms_assignment', 'banner_id', 'banner_id AND hms_new_application.term = hms_assignment.term');
     $db->addWhere('hms_assignment.banner_id', 'NULL');
     $db->addWhere('hms_new_application.term', $term);
     $db->addWhere('hms_new_application.student_type', 'F');
     // Don't show students who have cancelled applications
     $db->addWhere('hms_new_application.cancelled', 0);
     // Limit by application term
     foreach ($applicationTerms as $t) {
         $db->addWhere('application_term', $t, '=', 'OR', 'app_term_group');
     }
     // Sort by gender, then application date (earliest to latest)
     $db->addOrder(array('gender ASC', 'created_on ASC'));
     $results = $db->select();
     if (PHPWS_Error::isError($results)) {
         throw new DatabaseException($results->toString());
     }
     // Post-processing, cleanup, making it pretty
     foreach ($results as $row) {
         // Updates counts
         $this->total++;
         if ($row['gender'] == MALE) {
             $this->male++;
         } else {
             if ($row['gender'] == FEMALE) {
                 $this->female++;
             }
         }
         $row['application_term'] = Term::toString($row['application_term']);
         $row['gender'] = HMS_Util::formatGender($row['gender']);
         $row['created_on'] = HMS_Util::get_short_date_time($row['created_on']);
         $row['meal_plan'] = HMS_Util::formatMealOption($row['meal_plan']);
         $row['lifestyle_option'] = HMS_Util::formatLifestyle($row['lifestyle_option']);
         $row['room_condition'] = HMS_Util::formatRoomCondition($row['room_condition']);
         $row['preferred_bedtime'] = HMS_Util::formatBedtime($row['preferred_bedtime']);
         // Roommates
         $roommie = HMS_Roommate::get_confirmed_roommate($row['username'], $this->term);
         if (!is_null($roommie)) {
             $row['roommate'] = $roommie->getUsername();
             $row['roommate_banner_id'] = $roommie->getBannerId();
         }
         // Copy the cleaned up row to the member var for data
         $this->data[] = $row;
     }
 }
Ejemplo n.º 11
0
 public function get_pager_by_hall_tags()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     $tpl = array();
     $tpl['FLOOR_NUMBER'] = $this->getLink();
     $tpl['GENDER_TYPE'] = HMS_Util::formatGender($this->gender_type);
     $tpl['IS_ONLINE'] = $this->is_online ? 'Yes' : 'No';
     return $tpl;
 }
Ejemplo n.º 12
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');
 }
Ejemplo n.º 13
0
 /**
  * DBPager row method for the floor view
  *
  * @return Array
  */
 public function get_row_tags()
 {
     $tpl = array();
     $tpl['ID'] = $this->id;
     $tpl['ROOM_NUMBER'] = $this->getLink();
     $tpl['GENDER_TYPE'] = HMS_Util::formatGender($this->gender_type);
     $tpl['DEFAULT_GENDER'] = HMS_Util::formatGender($this->default_gender);
     $rlcList = RlcFactory::getRlcList($this->term);
     $rlcReservation = $this->getReservedRlcId();
     if ($rlcReservation != null) {
         $tpl['RLC_RESERVED'] = $rlcList[$rlcReservation];
     }
     $tpl['RA'] = $this->isRa() ? 'Yes' : 'No';
     $tpl['PRIVATE'] = $this->isPrivate() ? 'Yes' : 'No';
     $tpl['OVERFLOW'] = $this->isOverflow() ? 'Yes' : 'No';
     $tpl['RESERVED'] = $this->isReserved() ? 'Yes' : 'No';
     $tpl['OFFLINE'] = $this->isOffline() ? 'Yes' : 'No';
     $tpl['ADA'] = $this->isADA() ? 'Yes' : 'No';
     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';
     }
     return $tpl;
 }
Ejemplo n.º 14
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');
 }
Ejemplo n.º 15
0
 /**
  * Returns the fields for this HousingApplication parent class. Usually called by overriding methods in subclasses (e.g. SummerApplication).
  *
  * @return Array Array of fields for this HousingApplication.
  */
 protected function unassignedStudentsFields()
 {
     $fields = array();
     $fields['banner_id'] = $this->getBannerId();
     $fields['username'] = $this->getUsername();
     $fields['gender'] = HMS_Util::formatGender($this->getGender());
     $fields['application_term'] = Term::toString($this->getApplicationTerm(), true);
     $fields['student_type'] = HMS_Util::formatType($this->getStudentType());
     $fields['meal_plan'] = HMS_Util::formatMealOption($this->getMealPlan());
     $fields['created_on'] = HMS_Util::get_long_date($this->getCreatedOn());
     $roommate = HMS_Roommate::get_confirmed_roommate($this->getUsername(), $this->getTerm());
     if (!is_null($roommate)) {
         $fields['roommate'] = $roommate->getFullName();
         $fields['roommate_id'] = $roommate->getBannerId();
     } else {
         $fields['roommate'] = '';
         $fields['roommate_id'] = '';
     }
     return $fields;
 }