public function execute() { if (!isset($this->term) || is_null($this->term)) { throw new InvalidArgumentException('Missing term.'); } $halls = ResidenceHallFactory::getHallsForTerm($this->term); foreach ($halls as $hall) { $floors = $hall->get_floors(); $floor_array = array(); foreach ($floors as $floor) { if (is_null($floor->f_movein_time_id)) { $f_time = 'None'; } else { $f_movein = new HMS_Movein_Time($floor->f_movein_time_id); $f_time = $f_movein->get_formatted_begin_end(); } if (is_null($floor->t_movein_time_id)) { $t_time = 'None'; } else { $t_movein = new HMS_Movein_Time($floor->t_movein_time_id); $t_time = $t_movein->get_formatted_begin_end(); } if (is_null($floor->rt_movein_time_id)) { $rt_time = 'None'; } else { $rt_movein = new HMS_Movein_Time($floor->rt_movein_time_id); $rt_time = $rt_movein->get_formatted_begin_end(); } $floor_array[] = array('FLOOR_NUM' => $floor->floor_number, 'F_TIME' => $f_time, 'T_TIME' => $t_time, 'RT_TIME' => $rt_time); } $this->rows[] = array('HALL_NAME' => $hall->hall_name, 'floor_rows' => $floor_array); } }
public function execute() { if (!isset($this->term) || is_null($this->term)) { throw new InvalidArgumentException('Missing term.'); } // Calculate the timestamp from 21 years ago $twentyOneYearsAgo = strtotime("-21 years"); // Get all of the residence halls for this term $halls = ResidenceHallFactory::getHallsForTerm($this->term); foreach ($halls as $hall) { $hallName = $hall->hall_name; $maxOccupancy = $hall->get_number_of_online_nonoverflow_beds(); $currOccupancy = $hall->get_number_of_assignees(); $this->totalCurrOccupancy += $currOccupancy; $males = 0; $females = 0; // Get all the assignments for this hall $results = $hall->get_assignees(); if (empty($results)) { continue; } elseif (PEAR::isError($results)) { throw new DatabaseException($results->toString()); } // foreach assignment, tally up the genders foreach ($results as $assign) { if (strtotime($assign->getDob()) < $twentyOneYearsAgo) { if ($assign->getGender() == MALE) { $males++; $this->totalMales++; } else { if ($assign->getGender() == FEMALE) { $females++; $this->totalFemales++; } } } } if ($males == 0) { $malePercent = 0; } else { $malePercent = round($males / $currOccupancy * 100, 1); } if ($females == 0) { $femalePercent = 0; } else { $femalePercent = round($females / $currOccupancy * 100, 1); } $this->rows[] = array('hallName' => $hallName, 'maxOccupancy' => $maxOccupancy, 'currOccupancy' => $currOccupancy, 'males' => $males, 'malePercent' => $malePercent, 'females' => $females, 'femalePercent' => $femalePercent); } if ($this->totalCurrOccupancy == 0) { $this->totalMalePercent = 0; $this->totalFemalePercent = 0; } else { $this->totalMalePercent = round($this->totalMales / $this->totalCurrOccupancy * 100, 1); $this->totalFemalePercent = round($this->totalFemales / $this->totalCurrOccupancy * 100, 1); } }
/** * Returns a list of hall names in an associative array, where the array key is the hall's database id. * * @param integer $term * @throws InvalidArgumentException * @return multitype:Array */ public static function getHallNamesAssoc($term) { if (!isset($term)) { throw new InvalidArgumentException('Missing term.'); } $hallArray = array(); $halls = ResidenceHallFactory::getHallsForTerm($term); foreach ($halls as $hall) { $hallArray[$hall->id] = $hall->hall_name; } return $hallArray; }
public function show() { $tpl = array(); $tpl['TERM'] = Term::toString($this->term) . ' - ' . Term::toString(Term::getNextTerm($this->term)); $halls = ResidenceHallFactory::getHallsForTerm($this->term); // Check for an RLC Assignment, and that it's in the correct state if ($this->rlcAssignment != null && $this->rlcAssignment->getStateName() == 'selfselect-invite') { $rlcId = $this->rlcAssignment->getRlc()->getId(); } else { $rlcId = null; } // A watch variable, set to true when we find at least one hall that // still has an available bed $somethingsAvailable = false; foreach ($halls as $hall) { $row = array(); $row['HALL_NAME'] = $hall->hall_name; $row['ROW_TEXT_COLOR'] = 'black'; # Make sure we have a room of the specified gender available in the hall (or a co-ed room) if ($hall->count_avail_lottery_rooms($this->student->getGender(), $rlcId) <= 0) { $row['ROW_TEXT_COLOR'] = ' class="text-muted"'; $tpl['hall_list'][] = $row; continue; } else { $somethingsAvailable = true; } $chooseCmd = CommandFactory::getCommand('LotteryChooseHall'); $chooseCmd->setHallId($hall->id); $row['HALL_NAME'] = $chooseCmd->getLink($hall->hall_name); $tpl['hall_list'][] = $row; } if (!$somethingsAvailable) { unset($tpl['hall_list']); $tpl['NOTHING_LEFT'] = ''; } Layout::addPageTitle("Choose Hall"); return PHPWS_Template::process($tpl, 'hms', 'student/lottery_choose_hall.tpl'); }
public function execute() { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); if (!isset($this->term) || is_null($this->term)) { throw new InvalidArgumentException('Missing term.'); } // Get all of the residence halls for this term $halls = ResidenceHallFactory::getHallsForTerm($this->term); foreach ($halls as $hall) { $hallName = $hall->hall_name; $maxOccupancy = $hall->get_number_of_online_nonoverflow_beds(); $currOccupancy = $hall->get_number_of_assignees(); $this->totalCurrOccupancy += $currOccupancy; $males = 0; $females = 0; $coed = 0; // Get all the assignments for this hall, joined up to the // room level so we can determine gender, and joined up to the // hall level so we can limit by hall $db = new PHPWS_DB('hms_assignment'); $db->addColumn('hms_assignment.*'); $db->addColumn('hms_room.gender_type'); $db->addJoin('LEFT', 'hms_assignment', 'hms_bed', 'bed_id', 'id'); $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_assignment.term', $this->term); $db->addWhere('hms_residence_hall.id', $hall->id); $results = $db->select(); if (empty($results)) { continue; } elseif (PEAR::isError($results)) { throw new DatabaseException($results->toString()); } // foreach assignment, tally up the genders foreach ($results as $assign) { if ($assign['gender_type'] == MALE) { $males++; $this->totalMales++; } else { if ($assign['gender_type'] == FEMALE) { $females++; $this->totalFemales++; } else { if ($assign['gender_type'] == COED) { $coed++; $this->totalCoed++; } } } } if ($males == 0) { $malePercent = 0; } else { $malePercent = round($males / $currOccupancy * 100, 1); } if ($females == 0) { $femalePercent = 0; } else { $femalePercent = round($females / $currOccupancy * 100, 1); } if ($coed == 0) { $coedPercent = 0; } else { $coedPercent = round($coed / $currOccupancy * 100, 1); } $this->rows[] = array('hallName' => $hallName, 'maxOccupancy' => $maxOccupancy, 'currOccupancy' => $currOccupancy, 'males' => $males, 'malePercent' => $malePercent, 'females' => $females, 'femalePercent' => $femalePercent, 'coed' => $coed, 'coedPercent' => $coedPercent); } $this->totalMalePercent = round($this->totalMales / $this->totalCurrOccupancy * 100, 1); $this->totalFemalePercent = round($this->totalFemales / $this->totalCurrOccupancy * 100, 1); $this->totalCoedPercent = round($this->totalCoed / $this->totalCurrOccupancy * 100, 1); }
public function getHalls() { return ResidenceHallFactory::getHallsForTerm($this->getTerm()); }
public function execute() { if (!isset($this->term) || is_null($this->term)) { throw new InvalidArgumentException('Missing term.'); } PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); $halls = ResidenceHallFactory::getHallsForTerm($this->term); // accumulatrs for totaling beds across all halls $totalBeds = 0; $totalVacantBeds = 0; $hallArray = array(); foreach ($halls as $hall) { $bedsByHall = 0; $vacantBedsByHall = 0; $floorArray = array(); $floors = $hall->get_floors(); if ($floors == NULL) { continue; } foreach ($floors as $floor) { $vacantBedsByFloor = 0; $totalBedsByFloor = 0; if ($floor->is_online == 0) { $floorArray[$floor->floor_number]['floor_number'] = $floor->floor_number . ' - Offline'; $floorArray[$floor->floor_number]['vacancies_by_floor'] = null; $floorArray[$floor->floor_number]['total_beds_by_floor'] = null; continue; } $rooms = $floor->get_rooms(); if ($rooms == NULL) { continue; } foreach ($rooms as $room) { if ($room->offline == 1) { continue; } $beds = $room->get_beds(); if (!empty($beds)) { foreach ($beds as $bed) { $bedsByHall++; $totalBedsByFloor++; $totalBeds++; if ($bed->has_vacancy()) { $totalVacantBeds++; $vacantBedsByHall++; $vacantBedsByFloor++; } } } } $floorArray[$floor->floor_number]['floor_number'] = $floor->floor_number; $floorArray[$floor->floor_number]['vacancies_by_floor'] = $vacantBedsByFloor; $floorArray[$floor->floor_number]['total_beds_by_floor'] = $totalBedsByFloor; } $hallArray[$hall->hall_name]['hall_name'] = $hall->hall_name; $hallArray[$hall->hall_name]['hall_vacancies'] = $vacantBedsByHall; $hallArray[$hall->hall_name]['hall_total_beds'] = $bedsByHall; ksort($floorArray); $hallArray[$hall->hall_name]['floor_rows'] = $floorArray; } $this->rows = array('total_beds' => $totalBeds, 'vacant_beds' => $totalVacantBeds, 'hall_rows' => $hallArray); }
/** * Returns an array of only the halls with vacancies */ public static function getHallsWithVacancies($term) { $vacant_halls = array(); $halls = ResidenceHallFactory::getHallsForTerm($term); foreach ($halls as $hall) { if ($hall->has_vacancy()) { $vacant_halls[] = $hall; } } return $vacant_halls; }