private function printFormParallel() { $params = array(); if ($this->_age_brackets) { $params['(age_bracket'] = $this->_age_brackets; } if ($this->_statuses) { $params['(status'] = $this->_statuses; } $totalPersons = Attendance_Record_Set::getPersonDataForCohorts($this->_cohortids, $params); $totalPrinted = 0; $cancelURL = build_url(array('*' => NULL, 'view' => 'attendance__record', 'cohortids' => $this->_cohortids, 'attendance_date' => $this->_attendance_date, 'release' => 1)); $dummy = new Person(); ?> <table class="table table-condensed table-auto-width valign-middle"> <thead> <tr> <?php if (SizeDetector::isWide()) { ?> <th>ID</th> <?php } if ($this->_show_photos) { ?> <th> </th> </td> <?php } ?> <th><?php echo _('Name'); ?> </th> <?php if (SizeDetector::isWide()) { ?> <th><?php echo _('Status'); ?> </th> <?php } foreach ($this->_record_sets as $prefix => $set) { ?> <th class="center"><?php echo $set->getCohortName(); ?> </th> <?php } if (SizeDetector::isWide()) { ?> <th><?php echo _('Actions'); ?> </th> <?php } ?> </tr> </thead> <tbody> <?php foreach ($totalPersons as $personid => $detail) { ?> <tr> <?php if (SizeDetector::isWide()) { ?> <td><?php echo $personid; ?> </td> <?php } if ($this->_show_photos) { ?> <td> <a class="med-popup" tabindex="-1" href="?view=persons&personid=<?php echo $personid; ?> "> <img style="width: 50px; max-width: 50px" src="?call=photo&personid=<?php echo (int) $personid; ?> " /> </a> </td> <?php } ?> <td><?php echo ents($detail['first_name'] . ' ' . $detail['last_name']); ?> </td> <?php if (SizeDetector::isWide()) { ?> <td class=""><?php $dummy->printFieldValue('status', $detail['status']); ?> </td> <?php } foreach ($this->_record_sets as $prefix => $set) { ?> <td class="parallel-attendance"> <?php $totalPrinted += $set->printWidget($prefix, $personid); ?> </td> <?php } if (SizeDetector::isWide()) { ?> <td class="action-cell narrow"> <a class="med-popup" tabindex="-1" href="?view=persons&personid=<?php echo $personid; ?> "><i class="icon-user"></i><?php echo _('View'); ?> </a> <a class="med-popup" tabindex="-1" href="?view=_edit_person&personid=<?php echo $personid; ?> "><i class="icon-wrench"></i><?php echo _('Edit'); ?> </a> <a class="med-popup" tabindex="-1" href="?view=_add_note_to_person&personid=<?php echo $personid; ?> "><i class="icon-pencil"></i><?php echo _('Add Note'); ?> </a> </td> <?php } ?> </tr> <?php } ?> <tr class="headcount"> <th class="right" colspan="<?php echo 1 + 2 * (int) SizeDetector::isWide() + (int) $this->_show_photos; ?> "><?php echo _('Total Headcount:'); ?> </th> <?php foreach ($this->_record_sets as $prefix => $set) { ?> <td class="center parallel-attendance"><?php $set->printHeadcountField(); ?> </td> <?php } ?> <td> </td> </tr> </tbody> </table> <input type="submit" class="btn" value="Save All Attendances" /> <a href="<?php echo $cancelURL; ?> " class="btn">Cancel</a> <?php return $totalPrinted; }
private function _printResultsTabular() { $GLOBALS['system']->includeDBClass('attendance_record_set'); $GLOBALS['system']->includeDBClass('person'); $dummy = new Person(); $all_persons = Attendance_Record_Set::getPersonIDsForCohorts($this->cohortids); $all_dates = $all_attendances = $all_totals = $all_headcounts = array(); if (!empty($this->cohortids)) { foreach ($this->cohortids as $cohortid) { $congid = $groupid = NULL; list($type, $id) = explode('-', $cohortid); if ($type == 'c') { $congid = $id; } if ($type == 'g') { $groupid = $id; } list($cdates, $cattendances, $ctotals) = Attendance_Record_Set::getAttendances((array) $congid, $groupid, $this->age_bracket, $this->start_date, $this->end_date); $hc = Headcount::fetchRange($congid ? 'congregation' : 'person_group', $congid ? $congid : $groupid, $this->start_date, $this->end_date); foreach ($hc as $date => $c) { $all_headcounts[$date][$cohortid] = $c; } $all_dates = array_merge($all_dates, $cdates); foreach ($ctotals as $date => $t) { $all_totals[$date][$cohortid] = $t; } foreach ($cattendances as $personid => $cat) { $all_persons[$personid]['cohortids'][] = $cohortid; foreach ($cat as $k => $v) { if (!in_array($k, array('first_name', 'last_name', 'membership_status', 'status'))) { $all_attendances[$personid][$cohortid][$k] = $v; } } } } } $all_dates = array_unique($all_dates); ?> <table class="table table-hover table-condensed table-auto-width valign-middle table-bordered parallel-attendance-report"> <thead> <tr> <th <?php if ($this->format != 'totals') { echo 'rowspan="2"'; } ?> >Name</th> <?php if (SizeDetector::isWide()) { ?> <th <?php if ($this->format != 'totals') { echo 'rowspan="2"'; } ?> >Status</th> <?php } if ($this->format == 'totals') { $colspan = 1; } else { $colspan = count($this->cohortids); } foreach ($all_dates as $date) { $classes = 'center nowrap'; if ($this->format != 'totals') { $classes .= ' new-cohort'; } ?> <th class="<?php echo $classes; ?> " colspan="<?php echo $colspan; ?> "><?php echo format_date($date); ?> </th> <?php } ?> <th <?php if ($this->format != 'totals') { echo 'rowspan="2"'; } ?> ></th> <th class="narrow selector form-inline" rowspan="2"><input type="checkbox" class="select-all" title="Select all" /></th> </tr> <?php if ($this->format != 'totals') { ?> <tr> <?php foreach ($all_dates as $date) { $first = TRUE; foreach ($this->cohortids as $cohortid) { $name = ''; list($type, $id) = explode('-', $cohortid); if ($type == 'c') { $congregation = $GLOBALS['system']->getDBObject('congregation', $id); $name = $congregation->getValue('name'); } else { if ($type == 'g') { $group =& $GLOBALS['system']->getDBObject('person_group', $id); $name = $group->getValue('name'); } } $short = reset(explode(' ', $name)); if (strlen($short) > 5 && !preg_match('/[0-9]/', $short)) { $short = substr($short, 0, 3) . '…'; } $class = $first ? 'new-cohort' : ''; ?> <th class="nowrap <?php echo $class; ?> " title="<?php echo ents($name); ?> "><?php echo ents($short); ?> </th> <?php $first = FALSE; } } ?> </tr> <?php } ?> </thead> <tbody> <?php foreach ($all_persons as $personid => $details) { if (!isset($all_attendances[$personid])) { continue; } ?> <tr <?php if ($details['status'] == 'archived') { echo 'class="archived"'; } ?> > <td class="nowrap"> <?php echo ents($details['first_name'] . ' ' . $details['last_name']); ?> </td> <?php if (SizeDetector::isWide()) { ?> <td><?php $dummy->printFieldValue('status', $details['status']); ?> </th> <?php } foreach ($all_dates as $date) { $first = TRUE; if ($this->format == 'totals') { $score = ''; foreach ($this->cohortids as $cohortid) { $catt = array_get($all_attendances[$personid], $cohortid, array()); $x = array_get($catt, $date, ''); if (strlen($x)) { $score = (int) $score + $x; } } $class = $this->classes[$score > 0 ? 1 : $score]; if ($score === '') { $score = '?'; } echo '<td class="center ' . $class . '">' . $score . '</td>'; } else { foreach ($this->cohortids as $cohortid) { if (!in_array($cohortid, array_get($all_persons[$personid], 'cohortids', array()))) { $class = 'disabled'; $letter = ''; } else { $catt = array_get($all_attendances[$personid], $cohortid, array()); $v = array_get($catt, $date, ''); $letter = $this->letters[$v]; $class = $this->classes[$v]; } if ($first) { $class .= ' new-cohort'; } echo '<td class="' . $class . '">' . $letter . '</td>'; $first = FALSE; } } } $this->_printActionsAndSelector($personid); ?> </tr> <?php } ?> </tbody> <?php if ($this->format != 'totals') { // headcounts don't make sense when we collapse groups down into totals $colspan = SizeDetector::isWide() ? 'colspan="2"' : ''; ?> <tfoot class="attendance-stats"> <tr class="headcount"> <th <?php echo $colspan; ?> >Total Headcount</th> <?php foreach ($all_dates as $date) { $hc = array_get($all_headcounts, $date, array()); foreach ($this->cohortids as $cohortid) { ?> <td> <?php echo array_get($hc, $cohortid, ''); ?> </td> <?php } } ?> <td colspan="2"> </td> </tr> <tr class="present"> <th <?php echo $colspan; ?> >Total Present</th> <?php foreach ($all_dates as $date) { $tots = array_get($all_totals, $date, array()); foreach ($this->cohortids as $cohortid) { ?> <td> <?php echo array_get(array_get($tots, $cohortid, array()), 1, 0); ?> </td> <?php } } ?> <td colspan="2"> </td> </tr> <tr class="absent"> <th <?php echo $colspan; ?> >Total Absent</th> <?php foreach ($all_dates as $date) { $tots = array_get($all_totals, $date, array()); foreach ($this->cohortids as $cohortid) { ?> <td> <?php echo array_get(array_get($tots, $cohortid, array()), 0, 0); ?> </td> <?php } } ?> <td colspan="2"> </td> </tr> <tr class="extras"> <th <?php echo $colspan; ?> >Extras</th> <?php foreach ($all_dates as $date) { $tots = array_get($all_totals, $date, array()); $hc = array_get($all_headcounts, $date, array()); foreach ($this->cohortids as $cohortid) { $present = array_get(array_get($tots, $cohortid, array()), 1, 0); $absent = array_get(array_get($tots, $cohortid, array()), 0, 0); $headcount = array_get($hc, $cohortid, NULL); ?> <td> <?php if ($headcount) { echo $headcount - $present - $absent; } ?> </td> <?php } } ?> <td colspan="2"> </td> </tr> </tfoot> <?php } ?> </table> <?php include 'templates/bulk_actions.template.php'; }