本文整理汇总了PHP中PHPWS_Template::parseCurrentBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_Template::parseCurrentBlock方法的具体用法?PHP PHPWS_Template::parseCurrentBlock怎么用?PHP PHPWS_Template::parseCurrentBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWS_Template
的用法示例。
在下文中一共展示了PHPWS_Template::parseCurrentBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
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();
}
示例2: render
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();
}
示例3: render
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();
}
示例4: 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();
}
示例5: render
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();
}
示例6: show
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();
}
示例7: _weekday
/**
* Fills in the header weekdays on the grid layout
*/
public function _weekday($oMonth, PHPWS_Template $oTpl)
{
$day_count = 0;
while ($day = $oMonth->fetch()) {
$day_count++;
$oTpl->setCurrentBlock('calendar-weekdays');
$wData['FULL_WEEKDAY'] = strftime('%A', $day->thisDay(TRUE));
$wData['ABRV_WEEKDAY'] = strftime('%a', $day->thisDay(TRUE));
$wData['LETTER_WEEKDAY'] = substr($wData['ABRV_WEEKDAY'], 0, 1);
$oTpl->setData($wData);
$oTpl->parseCurrentBlock();
if ($day->last) {
break;
}
}
}
示例8: getLikeGroups
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;
}
示例9: doTemplateStuff
/**
* Takes a PHPWS_Template object and plugs the various variables into it
* @param PHPWS_Template $tpl
*
* @return Array template tags
*/
public function doTemplateStuff($tpl)
{
$tpl->setData(array('DATE' => date('F j, Y g:ia'), 'TERM' => Term::toString($this->term)));
if (sizeof($this->actions) < 1) {
$tpl->setData(array('NORESULTS' => 'No withdrawn students found.'));
return $tpl->get();
} else {
$tpl->setData(array('COUNT' => sizeof($this->actions)));
}
foreach ($this->actions as $username => $actions) {
foreach ($actions as $action) {
$tpl->setCurrentBlock('action_repeat');
$tpl->setData(array('ACTION' => $action));
$tpl->parseCurrentBlock();
}
$tpl->setCurrentBlock('user_repeat');
$tpl->setData(array('USERNAME' => $username));
$tpl->parseCurrentBlock();
}
return $tpl->get();
}
示例10: process
public static function process($template, $module, $file, $strict = false, $ignore_cache = false)
{
if (!is_array($template)) {
return PHPWS_Error::log(PHPWS_VAR_TYPE, 'core', 'PHPWS_Template::process', 'template=' . gettype($template));
return NULL;
}
if (PHPWS_Error::isError($template)) {
PHPWS_Error::log($template);
return NULL;
}
if ($strict) {
$tpl = new PHPWS_Template();
$tpl->setFile($file, true);
} else {
$tpl = new PHPWS_Template($module, $file);
}
$tpl->ignore_cache = (bool) $ignore_cache;
if (PHPWS_Error::isError($tpl->error)) {
PHPWS_Error::log($tpl->error);
return _('Template error.');
}
foreach ($template as $key => $value) {
if (!is_array($value) || !isset($tpl->_blocks[$key])) {
continue;
}
foreach ($value as $content) {
$tpl->setCurrentBlock($key);
$tpl->setData($content);
$tpl->parseCurrentBlock();
}
unset($template[$key]);
}
$template['source_http'] = $template['SOURCE_HTTP'] = PHPWS_SOURCE_HTTP;
$tpl->setData($template);
$result = $tpl->get();
if (PHPWS_Error::isError($result)) {
return $result;
}
if (LABEL_TEMPLATES == true) {
$start = "\n<!-- START TPL: " . $tpl->lastTemplatefile . " -->\n";
$end = "\n<!-- END TPL: " . $tpl->lastTemplatefile . " -->\n";
} else {
$start = $end = NULL;
}
if (!isset($result) && RETURN_BLANK_TEMPLATES) {
return $start . $tpl->lastTemplatefile . $end;
} else {
return $start . $result . $end;
}
}
示例11: reappAvailability
/**
* 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();
}
示例12: show
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();
//.........这里部分代码省略.........
示例13: panelLink
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;
}
示例14: dailyReport
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));
//.........这里部分代码省略.........
示例15: slotListing
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;
}