public function show() { PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); $tpl = array(); $template = new PHPWS_Template('hms'); $template->setFile('admin/review_hall_email.tpl'); if (is_array($this->floors)) { foreach ($this->floors as $floorId) { $floor = new HMS_Floor(); $floor->id = $floorId; $floor->load(); $floor->loadHall(); $tpl['halls'][$floor->_hall->getHallName()][] = 'Floor ' . $floor->getFloorNumber(); } } else { $floor = new HMS_Floor(); $floor->id = $this->floors; $floor->load(); $floor->loadHall(); $tpl['halls'][$floor->_hall->getHallName()][] = 'Floor ' . $floor->getFloorNumber(); } $tpl['FROM'] = $this->anonymous && Current_User::allow('hms', 'anonymous_notifications') ? FROM_ADDRESS : Current_User::getUsername() . '@' . DOMAIN_NAME; $tpl['SUBJECT'] = $this->subject; $tpl['BODY'] = preg_replace('/\\n/', '<br />', $this->body); $editCmd = CommandFactory::getCommand('ShowHallNotificationEdit'); $tpl['EDIT_URI'] = $editCmd->getUri(); /* $form->addHidden('anonymous', isset($this->anonymous) ? $this->anonymous : ''); $form->addHidden('subject', $this->subject); $form->addHidden('body', $this->body); $form->addHidden('hall', $this->halls); $form->addHidden('floor', $this->floors); $form->addSubmit('back', 'Edit Message'); */ $form2 = new PHPWS_Form('review_email'); $sendCmd = CommandFactory::getCommand('SendNotificationEmails'); $sendCmd->initForm($form2); $form2->addHidden('anonymous', isset($this->anonymous) ? $this->anonymous : ''); $form2->addHidden('subject', $this->subject); $form2->addHidden('body', $this->body); $form2->addHidden('hall', $this->halls); $form2->addHidden('floor', $this->floors); foreach ($tpl['halls'] as $hall => $floors) { foreach ($floors as $floor) { $template->setCurrentBlock('floors'); $template->setData(array("FLOOR" => $floor)); $template->parseCurrentBlock(); } $template->setCurrentBlock('halls'); $template->setData(array("HALL" => $hall)); $template->parseCurrentBlock(); } $form2->mergeTemplate($tpl); $tpl = $form2->getTemplate(); $template->setCurrentBlock('remainder'); $template->setData($tpl); $template->parseCurrentBlock(); return $template->get(); }
protected function render() { parent::render(); $this->tpl['TERM'] = Term::toString($this->report->getTerm()); $halls = $this->report->getHalls(); // Need to create our own Template object $myTpl = new PHPWS_Template('hms'); $myTpl->setFile('admin/reports/AssignmentTypeByFloor.tpl'); // Set the existing tags $myTpl->setData($this->tpl); $hallTags = array(); foreach ($halls as $hall) { $hallCounts = $this->report->getCountsForHall($hall); // Hall totals summary foreach ($hallCounts as $hallCount) { $myTpl->setCurrentBlock('hall_totals'); $myTpl->setData(array('HALL_TOTAL_TYPE' => constant($hallCount['reason']), 'HALL_TOTAL_COUNT' => $hallCount['count'])); $myTpl->parseCurrentBlock(); } $floors = $hall->get_floors(); foreach ($floors as $floor) { $counts = $this->report->getCountsForFloor($floor); foreach ($counts as $countRow) { $myTpl->setCurrentBlock('floor_counts'); $myTpl->setData(array('TYPE' => constant($countRow['reason']), 'COUNT' => $countRow['count'])); $myTpl->parseCurrentBlock(); } // Floor tags $myTpl->setCurrentBlock('floors'); $myTpl->setData(array('FLOOR_NUMBER' => HMS_Util::ordinal($floor->getFloorNumber()))); $myTpl->parseCurrentBlock(); } // Set hall tags $hallTags['HALL_NAME'] = $hall->getHallName(); $hallTags['HALL_OCCUPANCY'] = $hall->get_number_of_assignees(); $hallTags['HALL_CAPACITY'] = $hall->countNominalBeds(); $myTpl->setCurrentBlock('hall_repeat'); $myTpl->setData($hallTags); $myTpl->parseCurrentBlock(); } //return PHPWS_Template::process($this->tpl, 'hms', 'admin/reports/AssignmentTypeByFloor.tpl'); return $myTpl->get(); }
public function render() { $hall = null; $tpl = new PHPWS_Template('hms'); $tpl->setFile('admin/reports/FloorRoster.tpl'); $rows =& $this->report->rows; foreach ($rows as $hall_name => $hall) { foreach ($hall as $row) { $row['bedroom_label'] = strtoupper($row['bedroom_label']); $tpl->setCurrentBlock('room-rows'); $tpl->setData($row); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock('hall-rows'); $tpl->setData(array('HALL' => $hall_name)); $tpl->parseCurrentBlock(); } $content = $tpl->get(); $this->pdf->set_html($content); $this->pdf->render(); }
protected function render() { parent::render(); $rows = $this->report->getRows(); $tpl = new PHPWS_Template('hms'); $tpl->setFile('admin/reports/MoveInTimes.tpl'); foreach ($rows as $hall) { $tpl->setCurrentBlock('floor-rows'); foreach ($hall['floor_rows'] as $floor) { $tpl->setData($floor); $tpl->parseCurrentBlock(); } unset($hall['floor-rows']); $tpl->setCurrentBlock('hall-rows'); $tpl->setData($hall); $tpl->parseCurrentBlock(); } $this->tpl['TERM'] = Term::toString($this->report->getTerm()); $tpl->setCurrentBlock(); $tpl->setData($this->tpl); $tpl->parseCurrentBlock(); return $tpl->get(); }
protected function render() { parent::render(); $rows = $this->report->getRows(); $tpl = new PHPWS_Template('hms'); $tpl->setFile('admin/reports/HallOccupancy.tpl'); foreach ($rows['hall_rows'] as $hall) { $tpl->setCurrentBlock('floor-rows'); foreach ($hall['floor_rows'] as $floor) { $tpl->setData($floor); $tpl->parseCurrentBlock(); } unset($hall['floor-rows']); $tpl->setCurrentBlock('hall-rows'); $tpl->setData($hall); $tpl->parseCurrentBlock(); } $this->tpl['TERM'] = Term::toString($this->report->getTerm()); $tpl->setCurrentBlock(); $tpl->setData(array('total_beds' => $rows['total_beds'], 'vacant_beds' => $rows['vacant_beds'])); $tpl->setData($this->tpl); $tpl->parseCurrentBlock(); return $tpl->get(); }
public function show() { $tpl = new PHPWS_Template('hms'); $tpl->setFile('admin/floor_assignment.tpl'); $this->floor->loadRooms(); javascript('jquery_ui'); javascript('modules/hms/floor_assignment'); $this->floor->loadHall(); $hall = $this->floor->_hall; $tpl->setCurrentBlocK('title'); $tpl->setData(array('TITLE' => HMS_Util::ordinal($this->floor->getFloorNumber()) . ' Floor - ' . $hall->getHallName() . ' - ' . Term::getPrintableSelectedTerm())); foreach ($this->floor->_rooms as $room) { $room->loadBeds(); foreach ($room->_beds as $bed) { $tpl->setCurrentBlock('bed-list'); $tpl->setData(array('BED_ID' => $bed->id)); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock('room-list'); $tpl->setData(array('ROOM' => $room->room_number)); $tpl->parseCurrentBlock(); } return $tpl->get(); }
public function dailyReport($print = false) { PHPWS_Core::initCoreClass('Link.php'); $this->loadStaffList(); if (empty($this->staff_list)) { $this->content = dgettext('checkin', 'No staff have been created.'); return; } $tpl = array(); if (isset($_GET['udate'])) { $udate = (int) $_GET['udate']; } elseif (isset($_GET['cdate'])) { $udate = strtotime($_GET['cdate']); } else { $udate = mktime(0, 0, 0); } $current_date = strftime('%m/%d/%Y', $udate); $this->title = sprintf(dgettext('checkin', 'Report for %s'), strftime('%e %B, %Y', $udate)); if (!$print) { $form = new PHPWS_Form('report-date'); $form->setMethod('get'); $form->addHidden('module', 'checkin'); $form->addText('cdate', $current_date); $form->setExtra('cdate', 'class="datepicker"'); $form->addHidden('aop', 'report'); $form->setLabel('cdate', dgettext('checkin', 'Date')); $form->addSubmit('daily_report', dgettext('checkin', 'Go')); $tpl = $form->getTemplate(); javascript('datepicker'); $tpl['PRINT_LINK'] = PHPWS_Text::secureLink(dgettext('checkin', 'Print view'), 'checkin', array('aop' => 'report', 'print' => 1, 'udate' => $udate, 'daily_report' => 1)); $tpl['REPEAT_VISITS'] = PHPWS_Text::moduleLink(dgettext('checkin', 'Repeat visits'), 'checkin', array('aop' => 'repeats', 'date' => $udate)); } $tObj = new PHPWS_Template('checkin'); $tObj->setFile('daily_report.tpl'); $this->loadStaffList(); $reasons = $this->getReasons(); if (empty($reasons)) { $reasons[0] = dgettext('checkin', 'No reason'); } PHPWS_Core::initModClass('checkin', 'Visitors.php'); $db = new PHPWS_DB('checkin_visitor'); $db->addWhere('start_meeting', $udate, '>='); $db->addWhere('end_meeting', $udate + 86400, '<'); $db->addWhere('finished', 1); $db->setIndexBy('assigned', true); $visitors = $db->getObjects('Checkin_Visitor'); foreach ($this->staff_list as $staff) { $row = array(); $row['NAME_LABEL'] = dgettext('checkin', 'Name, Reason, & Note'); $row['WAITED_LABEL'] = dgettext('checkin', 'Waited'); $row['SPENT_LABEL'] = dgettext('checkin', 'Visited'); $row['ARRIVAL_LABEL'] = dgettext('checkin', 'Arrived'); $average_wait = $total_wait = $count = $total_spent = $total_visit = 0; if (isset($visitors[$staff->id])) { foreach ($visitors[$staff->id] as $vis) { $wait = $vis->start_meeting - $vis->arrival_time; $spent = $vis->end_meeting - $vis->start_meeting; if (isset($reasons[$vis->reason])) { $reason = $reasons[$vis->reason]; } else { $reason = '<em>' . dgettext('checkin', 'System missing reason') . '</em>'; } $tObj->setCurrentBlock('subrow'); $data = array('VIS_NAME' => PHPWS_Text::moduleLink($vis->getName(), 'checkin', array('aop' => 'visitor_report', 'vis_id' => $vis->id)), 'REASON' => $reason, 'ARRIVAL' => strftime('%r', $vis->arrival_time), 'NOTE' => $vis->note, 'WAITED' => Checkin::timeWaiting($wait), 'SPENT' => Checkin::timeWaiting($spent)); if (!empty($vis->email)) { $data['EMAIL'] = '<a href="mailto:' . $vis->email . '">' . $vis->email . '</a>'; } $tObj->setData($data); $tObj->parseCurrentBlock(); if ($spent >= 0) { $count++; $total_wait += $wait; $total_spent += $spent; } } //prevent divide by zero if ($count >= 1) { $average_wait = floor($total_wait / $count); } else { $average_wait = 0; } } else { $tObj->setCurrentBlock('message'); $tObj->setData(array('NOBODY' => dgettext('checkin', 'No visitors seen'))); $tObj->parseCurrentBlock(); } $tObj->setCurrentBlock('row'); $link = new PHPWS_Link($staff->display_name, 'checkin', array('aop' => 'month_report', 'staff_id' => $staff->id, 'date' => $udate), true); $link->setTitle(dgettext('checkin', 'See monthly totals')); $row['DISPLAY_NAME'] = $link->get(); $row['VISITORS_SEEN'] = sprintf(dgettext('checkin', 'Visitors seen: %s'), $count); if ($count) { $row['TOTAL_SPENT'] = sprintf(dgettext('checkin', 'Total time in meeting: %s'), Checkin::timeWaiting($total_spent)); $row['TOTAL_WAIT'] = sprintf(dgettext('checkin', 'Total wait time: %s'), Checkin::timeWaiting($total_wait)); $row['AVERAGE_WAIT'] = sprintf(dgettext('checkin', 'Average wait time: %s'), Checkin::timeWaiting($average_wait)); } $tObj->setData($row); $tObj->parseCurrentBlock(); } $start_date = mktime(0, 0, 0, date('m', $udate), 1, date('Y', $udate)); $end_date = mktime(0, -1, 0, date('m', $udate) + 1, 1, date('Y', $udate)); $tObj->setData($tpl); $this->content = $tObj->get(); }
public function display() { $tpl = new PHPWS_Template(); $tpl->setFile("setup/templates/setup.tpl", true); if (is_array($this->content)) { $content = PHPWS_Text::tag_implode('p', $this->content); } else { $content =& $this->content; } if (!empty($this->messages)) { if (is_array($this->messages)) { $message = PHPWS_Text::tag_implode('p', $this->messages); } else { $message =& $this->messages; } } else { $message = null; } $tpl->setData(array('TITLE' => $this->title, 'CONTENT' => $content, 'MESSAGE' => $message)); echo $tpl->get(); exit; }
public function week() { if (PHPWS_Settings::get('calendar', 'use_calendar_style')) { Layout::addStyle('calendar'); } $start_day = PHPWS_Settings::get('calendar', 'starting_day'); $current_weekday = date('w', $this->calendar->current_date); if ($current_weekday != $start_day) { $week_start = $current_weekday - $start_day; } else { $week_start = 0; } $startdate = $this->calendar->current_date - 86400 * $week_start; $enddate = $startdate + 86400 * 7 - 1; $this->calendar->loadEventList($startdate, $enddate); if (PHPWS_Settings::get('calendar', 'use_calendar_style')) { Layout::addStyle('calendar'); } $tpl = new PHPWS_Template('calendar'); $tpl->setFile('view/week.tpl'); $start_range = strftime(CALENDAR_WEEK_HEADER, $startdate); if (date('Y', $startdate) != date('Y', $enddate)) { $start_range .= strftime(', %Y', $startdate); } if (date('m', $startdate) == date('m', $enddate)) { $end_range = strftime('%e, %Y', $enddate); } else { $end_range = strftime(CALENDAR_WEEK_HEADER, $enddate); $end_range .= strftime(', %Y', $enddate); } $events_found = false; for ($i = $startdate; $i <= $enddate; $i += 86400) { $day_result = $this->getDaysEvents($i, $tpl); if ($day_result) { $events_found = true; $link = PHPWS_Text::linkAddress('calendar', array('date' => $i, 'view' => 'day')); $day_tpl['FULL_WEEKDAY'] = sprintf('<a href="%s">%s</a>', $link, strftime('%A', $i)); $day_tpl['ABBR_WEEKDAY'] = sprintf('<a href="%s">%s</a>', $link, strftime('%a', $i)); $day_tpl['DAY_NUMBER'] = sprintf('<a href="%s">%s</a>', $link, strftime('%e', $i)); $tpl->setCurrentBlock('days'); $tpl->setData($day_tpl); $tpl->parseCurrentBlock(); } } if (!$events_found) { $tpl->setVariable('MESSAGE', dgettext('calendar', 'No events this week.')); } $main_tpl = $this->viewLinks('week'); $main_tpl['DAY_RANGE'] = '<a href="index.php?module=calendar&view=grid&date=' . $startdate . '">' . sprintf(dgettext('calendar', 'From %s to %s'), $start_range, $end_range) . '</a>'; $main_tpl['SCHEDULE_TITLE'] = $this->calendar->schedule->title; $main_tpl['FULL_YEAR'] = strftime('%Y', $this->calendar->current_date); $main_tpl['ABRV_YEAR'] = strftime('%y', $this->calendar->current_date); $main_tpl['SCHEDULE_PICK'] = $this->schedulePick(); $main_tpl['PICK'] = $this->getDatePick(); $main_tpl['SUGGEST'] = $this->suggestLink(); $main_tpl['DOWNLOAD'] = $this->downloadLink($startdate, $enddate); if ($this->calendar->schedule->checkPermissions()) { $main_tpl['ADD_EVENT'] = '<button class="add-event btn btn-success" data-view="week" data-schedule-id="' . $this->calendar->schedule->id . '" data-date="' . $this->calendar->current_date * 1000 . '"><i class="fa fa-plus"></i> ' . dgettext('calendar', 'Add event') . '</button>'; } $tpl->setData($main_tpl); return $tpl->get(); }
/** * Inserts the content data into the current theme */ public static function loadTheme($theme, $template) { $tpl = new PHPWS_Template(); $tpl->setRoot(PHPWS_SOURCE_DIR); $themeDir = Layout::getThemeDir(); if (PHPWS_Error::isError($themeDir)) { PHPWS_Error::log($themeDir); PHPWS_Core::errorPage(); } $result = $tpl->setFile($themeDir . 'theme.tpl', TRUE); if (PHPWS_Error::isError($result)) { return $result; } if (!empty($GLOBALS['Layout_Collapse'])) { $template['COLLAPSE'] = 'id="layout-collapse"'; } $template['THEME_DIRECTORY'] = Layout::getThemeDirRoot() . $theme . '/'; $template['THEME_HTTP'] = Layout::getThemeHttpRoot() . $theme . '/'; $template['SOURCE_THEME_HTTP'] = PHPWS_SOURCE_HTTP . 'themes/'; $template['SOURCE_THEME_DIR'] = PHPWS_SOURCE_DIR . 'themes/'; $tpl->setData($template); return $tpl; }
/** * Returns an array of template tags for a HTML view of the output. * @array Array array of template tags for a HTML view of the output. */ public function getHTMLView() { $tpl = new PHPWS_Template('hms'); if (!$tpl->setFile('admin/withdrawnSearchOutput.tpl')) { return 'Template error...'; } return $this->doTemplateStuff($tpl); }
public static function getLikeGroups($name, PHPWS_Group $group) { $name = preg_replace('/[^\\w]/', '', $name); $db = \Database::newDB(); $ug = $db->addTable('users_groups'); $ug->addField('id'); $ug->addField('name'); $ug->addField('user_id'); $u = $db->addTable('users', null, false); $u->addField('display_name'); $cond = $db->createConditional($ug->getField('user_id'), $u->getField('id')); $db->joinResources($ug, $u, $cond, 'outer'); $ug->addFieldConditional('name', "%{$name}%", 'LIKE'); $members = $group->getMembers(); if (isset($members)) { $ug->addFieldConditional('id', $members, 'not in'); } $groups = $db->select(); $tpl = new PHPWS_Template('users'); $tpl->setFile('forms/likeGroups.tpl'); $count = 0; $vars['action'] = 'admin'; $vars['command'] = 'addMember'; $vars['group_id'] = $group->getId(); foreach ($groups as $member) { if (isset($members)) { if (in_array($member['id'], $members)) { continue; } } $vars['member'] = $member['id']; $link = PHPWS_Text::secureLink('<i class="fa fa-plus"></i> ' . dgettext('users', 'Add'), 'users', $vars, NULL, dgettext('users', 'Add this user to this group.'), 'btn btn-sm btn-success'); $tpl->setCurrentBlock('row'); if (!empty($member['display_name'])) { $tpl->setData(array('NAME' => $member['name'] . ' (' . $member['display_name'] . ')', 'ADD' => $link)); } else { $tpl->setData(array('NAME' => $member['name'], 'ADD' => $link)); } $tpl->parseCurrentBlock(); } $content = $tpl->get(); return $content; }
public static function processTemplate($template, $module, $file, $defaultTpl = true) { if ($defaultTpl) { return PHPWS_Template::process($template, $module, $file); } else { $tpl = new PHPWS_Template($module); $tpl->setFile($file, true); $tpl->setData($template); return $tpl->get(); } }
/** * 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(); }
public function slotListing() { $slots = $this->sheet->getAllSlots(); $tpl = new PHPWS_Template('signup'); $tpl->setFile('report.tpl'); foreach ($slots as $slot) { $slot->loadPeeps(); $peep_count = 0; if ($slot->_peeps) { foreach ($slot->_peeps as $peep) { $tpl->setCurrentBlock('peeps'); $tpl->setData(array('FIRST_NAME' => $peep->first_name, 'LAST_NAME' => $peep->last_name)); $tpl->parseCurrentBlock(); $peep_count++; } } $openings_left = $slot->openings - $peep_count; if ($openings_left) { for ($i = 0; $i < $openings_left; $i++) { $tpl->setCurrentBlock('spaces'); $tpl->setData(array('SPACE' => ' ')); $tpl->parseCurrentBlock(); } } $tpl->setCurrentBlock('slot'); $tpl->setData(array('SLOT_TITLE' => $slot->title, 'PRINT' => dgettext('signup', 'Print page'))); $tpl->parseCurrentBlock(); } $tpl->setData(array('REPORT_TITLE' => $this->sheet->title)); echo $tpl->get(); exit; }
public function show() { $tpl = new PHPWS_Template('hms'); if (!$tpl->setFile('admin/reports/hall_overview.tpl')) { return 'Template error.'; } $rlcs = HMS_Learning_Community::getRlcList(); $rlcs_abbr = HMS_Learning_Community::getRLCListAbbr(); $tpl->setData(array('HALL' => $this->hall->hall_name, 'TERM' => Term::getPrintableSelectedTerm())); if ($this->nakedDisplay) { $menuCmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu'); $tpl->setData(array('MAINTENANCE' => $menuCmd->getLink('Main Menu'))); } $class = 'toggle1'; $this->hall->loadFloors(); foreach ($this->hall->_floors as $floor) { $floor->loadRooms(); if (!isset($floor->_rooms)) { continue; } if ($floor->rlc_id != NULL) { $floor_rlc = $rlcs[$floor->rlc_id]; } else { $floor_rlc = ''; } foreach ($floor->_rooms as $room) { $extra_attribs = ''; if ($room->isOffline()) { $extra_attribs .= 'Offline '; } if ($room->isReserved()) { $extra_attribs .= 'Reserved '; } if ($room->isRa()) { $extra_attribs .= 'RA '; } if ($room->isPrivate()) { $extra_attribs .= 'Private '; } if ($room->isOverflow()) { $extra_attribs .= 'Overflow '; } if ($room->isParlor()) { $extra_attribs .= 'Parlor '; } if ($room->isADA()) { $extra_attribs .= 'ADA'; } if ($room->isHearingImpaired()) { $extra_attribs .= 'Hearing Impaired'; } if ($room->bathEnSuite()) { $extra_attribs .= 'Bath en Suite'; } $room->loadBeds(); if (empty($room->_beds)) { $tpl->setCurrentBlock('room_repeat'); $tpl->setData(array('EXTRA_ATTRIBS' => $extra_attribs, 'ROOM_NUMBER' => $room->getLink('Room'))); $tpl->parseCurrentBlock(); continue; } foreach ($room->_beds as $bed) { $bed->loadAssignment(); $tpl->setCurrentBlock('bed_repeat'); $bed_link = $bed->getLink(); if (isset($bed->_curr_assignment)) { $username = $bed->_curr_assignment->asu_username; try { $student = StudentFactory::getStudentByUsername($username, $this->hall->term); } catch (StudentNotFoundException $e) { $student = null; NQ::simple('hms', hms\NotificationView::WARNING, "Could not find data for: {$username}"); } $assign_rlc = HMS_RLC_Assignment::checkForAssignment($username, $this->hall->term); //false or index if ($assign_rlc != FALSE) { $rlc_abbr = $rlcs_abbr[$assign_rlc['rlc_id']]; //get the abbr for the rlc } else { $rlc_abbr = ''; } // Alternating background colors if ($class == 'toggle1') { $class = 'toggle2'; } else { $class = 'toggle1'; } if (is_null($student)) { $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => 'UNKNOWN', 'USERNAME' => $username, 'BANNER_ID' => '', 'TOGGLE' => $class, 'RLC_ABBR' => $rlc_abbr)); } else { $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => $student->getProfileLink(), 'USERNAME' => $student->getUsername(), 'BANNER_ID' => $student->getBannerId(), 'TOGGLE' => $class, 'RLC_ABBR' => $rlc_abbr)); } } else { $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => $bed->get_assigned_to_link(), 'VACANT' => '')); } $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock('room_repeat'); $tpl->setData(array('EXTRA_ATTRIBS' => $extra_attribs, 'ROOM_NUMBER' => $room->getLink('Room'))); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock('floor_repeat'); $tpl->setData(array('FLOOR_NUMBER' => $floor->getLink('Floor'), 'FLOOR_RLC' => $floor_rlc)); $tpl->parseCurrentBlock(); } if ($this->nakedDisplay) { Layout::nakedDisplay($tpl->get(), 'Building overview for ' . $this->hall->hall_name, TRUE); } Layout::addPageTitle("Hall Overview"); return $tpl->get(); }
public static function panelLink($fly_out = false) { Layout::addStyle('controlpanel', 'panel_link.css'); $reg_link = PHPWS_Text::quickLink(dgettext('controlpanel', 'Control Panel'), 'controlpanel', array('command' => 'panel_view')); if (!$fly_out) { return $reg_link->get(); } javascript('jquery'); javascriptMod('controlpanel', 'subpanel'); $reg_link->setId('cp-panel-link'); $all_tabs = PHPWS_ControlPanel::loadTabs(); $all_links = PHPWS_ControlPanel::getAllLinks(true); $tpl = new PHPWS_Template('controlpanel'); $tpl->setFile('subpanel.tpl'); $authkey = Current_User::getAuthKey(); if (!empty($all_links)) { foreach ($all_links as $tab => $links) { foreach ($links as $link) { $tpl->setCurrentBlock('links'); $tpl->setData(array('LINK' => sprintf('<a href="%s&authkey=%s">%s</a>', $link->url, $authkey, str_replace(' ', ' ', $link->label)))); $tpl->parseCurrentBlock(); } $tab_link = $all_tabs[$tab]->link . '&tab=' . $all_tabs[$tab]->id; $tpl->setCurrentBlock('tab'); $tpl->setData(array('TAB_TITLE' => sprintf('<a href="%s">%s</a>', $tab_link, $all_tabs[$tab]->title))); $tpl->parseCurrentBlock(); } } $tpl->setCurrentBlock(); $tpl->setData(array('CP_LINK' => $reg_link->get())); $tpl->parseCurrentBlock(); $submenu = $tpl->get(); return $submenu; }