public function __construct() { include 'permission_levels.php'; $enabled_features = explode(',', strtoupper(ENABLED_FEATURES)); foreach ($PERM_LEVELS as $i => $detail) { list($define_symbol, $desc, $feature_code) = $detail; define('PERM_' . $define_symbol, $i); if (empty($feature_code) || in_array($feature_code, $enabled_features)) { $this->_permission_levels[$i] = $desc; } } if (!empty($_REQUEST['logout'])) { $this->_logOut(); } else { if (empty($_SESSION['user']) && !empty($_POST['username'])) { // process the login form if (array_get($_SESSION, 'login_key', NULL) != $_POST['login_key']) { $this->_error = 'Login Key Incorrect. Please try again.'; return; } $user_details = $this->_findUser($_POST['username'], $_POST['password']); if (is_null($user_details)) { $this->_error = 'Incorrect username or password'; } else { // Log the user in // Recreate session when logging in session_regenerate_id(); $_SESSION = array(); $_SESSION['user'] = $user_details; $_SESSION['login_time'] = time(); $_SESSION['last_activity_time'] = time(); include_once 'include/size_detector.class.php'; SizeDetector::processRequest(); } } } if (!empty($_SESSION['user'])) { if (defined('SESSION_TIMEOUT_MINS') && constant('SESSION_TIMEOUT_MINS')) { if ((time() - $_SESSION['last_activity_time']) / 60 > SESSION_TIMEOUT_MINS) { // They have been idle too long $this->_logOut(); } } if (defined('SESSION_MAXLENGTH_MINS') && constant('SESSION_MAXLENGTH_MINS')) { if ((time() - $_SESSION['login_time']) / 60 > SESSION_MAXLENGTH_MINS) { // They have been logged in too long $this->_logOut(); } } $_SESSION['last_activity_time'] = time(); $res = $GLOBALS['db']->query('SET @current_user_id = ' . (int) $_SESSION['user']['id']); if (PEAR::isError($res)) { trigger_error('Failed to set user id in database', E_USER_ERROR); } } }
function printForm($prefix = '', $fields = NULL) { include_once 'include/size_detector.class.php'; if ($GLOBALS['system']->featureEnabled('PHOTOS') && (is_null($fields) || in_array('photo', $fields))) { $this->fields['photo'] = array('divider_before' => true); // fake field for interface purposes if ($this->id && !SizeDetector::isNarrow()) { ?> <div class="person-photo-container"> <img src="?call=photo&familyid=<?php echo (int) $this->id; ?> " /> </div> <?php } } parent::printForm($prefix, $fields); unset($this->fields['photo']); }
function printForm($prefix = '', $fields = NULL) { include_once 'include/size_detector.class.php'; if ($GLOBALS['system']->featureEnabled('PHOTOS') && (is_null($fields) || in_array('photo', $fields)) && !SizeDetector::isNarrow()) { $this->fields['photo'] = array('divider_before' => true); // fake field for interface purposes if ($this->id) { ?> <div class="person-photo-container"> <img src="?call=photo&personid=<?php echo (int) $this->id; ?> " /> </div> <?php } } if (!$this->id) { unset($this->fields['familyid']); } parent::printForm($prefix, $fields); unset($this->fields['photo']); if (empty($fields) || in_array('custom', $fields)) { $customFields = $this->getCustomFields(); $dummyField = new Custom_Field(); if ($customFields) { ?> <hr /> <div class="form-horizontal"> <?php foreach ($customFields as $fieldid => $fieldDetails) { $dummyField->populate($fieldid, $fieldDetails); $tableClass = $fieldDetails['allow_multiple'] ? 'expandable' : ''; $values = isset($this->_custom_values[$fieldid]) ? $this->_custom_values[$fieldid] : array(''); if ($fieldDetails['divider_before']) { echo '<hr />'; } ?> <div class="control-group"> <?php if (strlen($fieldDetails['heading_before'])) { ?> <h4><?php echo ents($fieldDetails['heading_before']); ?> </h4> <?php } ?> <label class="control-label" for="custom_<?php echo $fieldid; ?> "><?php echo ents($fieldDetails['name']); ?> </label> <div class="controls"> <table class="<?php echo $tableClass; ?> "> <?php foreach ($values as $value) { ?> <tr><td> <?php $dummyField->printWidget($value); ?> </td></tr> <?php } ?> </table> </div> </div> <?php } ?> </div> <?php } } }
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; }
function print_widget($name, $params, $value) { $classes = array_get($params, 'class', ''); if (!array_get($params, 'allow_empty', 1)) { $classes .= ' compulsory'; } $attrs = array(); foreach (array_get($params, 'attrs', array()) as $attr => $val) { $attrs[] = $attr . '="' . ents($val) . '"'; } $attrs = implode(' ', $attrs); switch ($params['type']) { case 'phone': $lengths = get_valid_phone_number_lengths($params['formats']); $width = max(get_phone_format_lengths($params['formats'])); ?> <input name="<?php echo $name; ?> " type="tel" size="<?php echo $width; ?> " value="<?php echo format_phone_number($value, $params['formats']); ?> " class="phone-number" validlengths="<?php echo implode(',', $lengths); ?> " <?php echo $attrs; ?> /> <?php break; case 'bibleref': require_once 'bible_ref.class.php'; $br = new bible_ref($value); $value = $br->toShortString(); $params['class'] = 'bible-ref'; // fall through // fall through case 'text': case 'email': $maxlength_exp = empty($params['maxlength']) ? '' : 'maxlength="' . $params['maxlength'] . '"'; if (array_get($params, 'height', 1) > 1) { $cols_exp = empty($params['width']) ? '' : 'cols="' . $params['width'] . '"'; ?> <textarea name="<?php echo $name; ?> " rows="<?php echo $params['height']; ?> " <?php echo $cols_exp; ?> class="<?php echo trim($classes); ?> " <?php echo $maxlength_exp; ?> ><?php echo ents($value); ?> </textarea> <?php } else { $width_exp = empty($params['width']) ? '' : 'size="' . $params['width'] . '"'; $regex_exp = empty($params['regex']) ? '' : 'regex="' . trim($params['regex'], '/ ') . '"'; $autocomplete_exp = isset($params['autocomplete']) ? 'autocomplete=' . ($params['autocomplete'] ? 'on' : 'off') . '"' : ''; ?> <input type="<?php echo $params['type']; ?> " name="<?php echo $name; ?> " value="<?php echo ents($value); ?> " class="<?php echo trim($classes); ?> " <?php echo implode(' ', array($maxlength_exp, $width_exp, $regex_exp, $autocomplete_exp)); ?> <?php echo $attrs; ?> /> <?php } break; case 'html': static $includedCK = false; if (!$includedCK) { ?> <script src="<?php echo BASE_URL . 'resources/ckeditor/ckeditor.js'; ?> "></script> <?php } ?> <textarea class="ckeditor" name="<?php echo $name; ?> " <?php echo $attrs; ?> ><?php echo $value; ?> </textarea> <?php break; case 'int': $classes .= ' int-box'; $width_exp = ''; if (!empty($params['width'])) { $width_exp = 'size="' . $params['width'] . '" '; } else { $width_exp = 'size="3" '; } ?> <input type="text" name="<?php echo $name; ?> " value="<?php echo $value; ?> " class="<?php echo trim($classes); ?> " <?php echo $width_exp; ?> <?php echo $attrs; ?> /> <?php break; case 'select': $our_val = is_array($value) ? $value : ($value === '' ? array() : array("{$value}")); foreach ($our_val as $k => $v) { $our_val[$k] = "{$v}"; } if (array_get($params, 'style', 'dropbox') == 'colour-buttons') { ?> <div class="radio-button-group <?php echo array_get($params, 'class', ''); ?> " <?php if (!SizeDetector::isNarrow()) { echo ' tabindex="1"'; } ?> > <input type="hidden" name="<?php echo $name; ?> " value="<?php echo reset($our_val); ?> " /> <?php foreach ($params['options'] as $k => $v) { $classes = 'btn value-' . $k; if (in_array("{$k}", $our_val, true)) { $classes .= ' active'; } ?> <div class="<?php echo $classes; ?> " title="<?php echo $v; ?> " data-val="<?php echo $k; ?> " > <?php echo strtoupper($v[0]); ?> </div> <?php } ?> </div> <?php } else { if (array_get($params, 'allow_multiple')) { $height = array_get($params, 'height', min(count($params['options']), 4)); if (substr($name, -2) != '[]') { $name .= '[]'; } $style = 'height: ' . $height * 1.8 . 'em'; $classes .= ' multi-select'; // the empty onclick below is to make labels work on iOS // see http://stackoverflow.com/questions/5421659/html-label-command-doesnt-work-in-iphone-browser ?> <div class="<?php echo $classes; ?> " style="<?php echo $style; ?> " tabindex="0" onclick="" <?php echo $attrs; ?> > <?php foreach ($params['options'] as $k => $v) { $checked_exp = in_array("{$k}", $our_val, true) ? ' checked="checked"' : ''; $disabled_exp = !empty($params['disabled_prefix']) && strpos($k, $params['disabled_prefix']) === 0 ? ' disabled="disabled" ' : ''; ?> <label class="checkbox" title="<?php echo ents($v); ?> "> <input type="checkbox" name="<?php echo $name; ?> " value="<?php echo $k; ?> " <?php echo $checked_exp . $disabled_exp; ?> > <?php echo ents($v); ?> </label> <?php } ?> </div> <?php } else { ?> <select name="<?php echo $name; ?> " class="<?php echo $classes; ?> " <?php echo $attrs; ?> > <?php if (array_get($params, 'allow_empty') && !array_get($params, 'allow_multiple')) { ?> <option value=""><?php echo array_get($params, 'empty_text', '(None)'); ?> </option> <?php } foreach (array_get($params, 'options', array()) as $k => $v) { $selected_exp = in_array("{$k}", $our_val, true) ? ' selected="selected"' : ''; $disabled_exp = !empty($params['disabled_prefix']) && strpos($k, $params['disabled_prefix']) === 0 ? ' disabled="disabled" ' : ''; ?> <option value="<?php echo $k; ?> "<?php echo $selected_exp . $disabled_exp; ?> ><?php echo ents($v); ?> </option> <?php } ?> </select> <?php } } break; case 'date': $day_year_classes = trim($classes . ' int-box'); if (FALSE === strpos($name, '[')) { $name_template = $name . '%s'; } else { $name_template = substr($name, 0, strpos($name, '[')) . '%s' . substr($name, strpos($name, '[')); } $months = array(); if (array_get($params, 'allow_empty', false)) { $months[''] = '(Month)'; } for ($i = 1; $i < 13; $i++) { $months[$i] = date(array_get($params, 'month_format', 'F'), strtotime("2007-{$i}-01")); } if (empty($value)) { $value = date('Y-m-d'); } // blank dates not allowed list($year_val, $month_val, $day_val) = explode('-', substr($value, 0, 10)); ?> <span class="nowrap" <?php echo $attrs; ?> > <input type="text" name="<?php printf($name_template, '_d'); ?> " class="day-box <?php echo $day_year_classes; ?> " size="2" maxlength="2" value="<?php echo $day_val; ?> " placeholder="DD" /><select name="<?php printf($name_template, '_m'); ?> " class="month-box <?php echo $classes; ?> "> <?php foreach ($months as $i => $month_name) { $selected = $i == $month_val ? ' selected="selected"' : ''; ?> <option value="<?php echo $i; ?> "<?php echo $selected; ?> ><?php echo $month_name; ?> </option> <?php } ?> </select><input type="text" name="<?php printf($name_template, '_y'); ?> " class="year-box <?php echo $day_year_classes; ?> " size="4" maxlength="4" value="<?php echo $year_val; ?> " placeholder="YYYY"/> </span> <?php break; case 'reference': if (!empty($params['references'])) { $where = array(); if (!empty($params['filter']) && is_array($params['filter'])) { $where = $params['filter']; } $where_logic = array_get($params, 'filter_logic', 'AND'); $options = $GLOBALS['system']->getDBObjectData($params['references'], $where, $where_logic, array_get($params, 'order_by')); $dummy = new $params['references'](); $our_val = is_array($value) ? $value : (empty($value) ? array() : array($value)); if (!empty($params['filter']) && is_callable($params['filter'])) { foreach ($options as $i => $o) { $dummy->populate($i, $o); if (!in_array($i, $our_val) && !$params['filter']($dummy)) { unset($options[$i]); } } } $params['options'] = array(); foreach ($options as $k => $details) { $dummy->populate($k, $details); $params['options'][$k] = $dummy->toString(); } $params['type'] = 'select'; print_widget($name, $params, $value); } break; case 'bitmask': $value = (int) $value; ?> <div class="bitmask-boxes"> <?php $percol = false; $cols = 3; require_once 'include/size_detector.class.php'; if (SizeDetector::getWidth()) { if (SizeDetector::isNarrow()) { $cols = 1; } else { if (SizeDetector::isMedium()) { $cols = 2; } } } if ($cols > 1) { $percol = ceil(count($params['options']) / $cols); ?> <div class="bitmask-column" <?php echo $attrs; ?> > <?php } $i = 0; foreach ($params['options'] as $k => $v) { $checked_exp = ($value & (int) $k) == $k ? 'checked="checked"' : ''; // the empty onclick below is to make labels work on iOS // see http://stackoverflow.com/questions/5421659/html-label-command-doesnt-work-in-iphone-browser ?> <label class="checkbox" onclick=""> <input type="checkbox" name="<?php echo ents($name); ?> []" value="<?php echo ents($k); ?> " <?php echo $checked_exp; ?> > <?php echo nbsp(ents($v)); ?> </label> <?php if ($percol && ++$i % $percol == 0) { ?> </div> <div> <?php } } if ($percol) { ?> </div> <?php } ?> </div> <?php break; } }
public function printForm($prefix = 0) { if (empty($this->_persons)) { return 0; } $GLOBALS['system']->includeDBClass('person'); $dummy = new Person(); ?> <table class="table table-condensed table-auto-width valign-middle"> <?php $is_first = TRUE; foreach ($this->_persons as $personid => $details) { $dummy->populate($personid, $details); ?> <tr> <?php if (!SizeDetector::isNarrow()) { ?> <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($details['first_name'] . ' ' . $details['last_name']); ?> </td> <?php if (!SizeDetector::isNarrow()) { ?> <td> <?php if ($this->groupid) { echo ents($details['membership_status']); } else { $dummy->printFieldValue('status'); } ?> </td> <?php } ?> <td class="narrow"> <?php $this->printWidget($prefix, $personid); ?> </td> <?php if (!SizeDetector::isNarrow()) { ?> <td class="action-cell narrow"> <a class="med-popup" tabindex="-1" href="?view=persons&personid=<?php echo $personid; ?> "><i class="icon-user"></i>View</a> <a class="med-popup" tabindex="-1" href="?view=_edit_person&personid=<?php echo $personid; ?> "><i class="icon-wrench"></i>Edit</a> <a class="med-popup" tabindex="-1" href="?view=_add_note_to_person&personid=<?php echo $personid; ?> "><i class="icon-pencil"></i>Add Note</a> </td> <?php } ?> </tr> <?php $is_first = FALSE; } ?> </table> <?php return count($this->_persons); }
<?php include dirname(dirname(dirname(__FILE__))) . '/templates/head.template.php'; ?> </head> <body id="login"> <form method="post" id="login-box" class="well disable-submit-buttons" action="<?php echo build_url(array('logout' => NULL)); ?> " target="_top"> <input type="hidden" name="login_key" value="<?php echo $login_key; ?> " /> <?php require_once 'include/size_detector.class.php'; SizeDetector::printFormFields(); ?> <div id="login-header"> <h1><?php echo ents(SYSTEM_NAME); ?> </h1> </div> <div id="login-body"> <noscript> <div class="alert"><strong>Error: Javascript is Disabled</strong><br />For Jethro to function correctly you must enable javascript, which is done most simply by lowering the security level your browser uses for this website</div> </noscript> <?php if (!empty($this->_error)) { echo '<div class="alert alert-error">' . $this->_error . '</div>'; } else {
function printForm() { $GLOBALS['system']->includeDBClass('person'); $person = new Person(); $person->fields['first_name']['width'] = 11; $person->fields['last_name']['width'] = 11; $person->fields['email']['width'] = 25; ?> <form method="post" id="add-family" class="form-horizontal"> <input type="hidden" name="new_family_submitted" value="1" /> <div class=""> <label>Family Name:</label> <?php $this->_family->printFieldInterface('family_name'); ?> </div> <div> <h3>Family Members</h3> <table class="expandable"> <?php include_once 'include/size_detector.class.php'; if (SizeDetector::isNarrow()) { ?> <tr> <td> <div class="compact-2col family-member-box"> <label>First Name</label> <label>Last Name</label> <div><?php $person->printFieldInterface('first_name', 'members_0_'); ?> </div> <div class="last_name preserve-value"><?php $person->printFieldInterface('last_name', 'members_0_'); ?> </div> <label>Gender</label> <label>Age</label> <div><?php $person->printFieldInterface('gender', 'members_0_'); ?> </div> <div><?php $person->printFieldInterface('age_bracket', 'members_0_'); ?> </div> <label>Status</label> <label>Congregation</label> <div class="person-status preserve-value"><?php $person->printFieldInterface('status', 'members_0_'); ?> </div> <div class="congregation"><?php $person->printFieldInterface('congregationid', 'members_0_'); ?> </div> <label>Mobile</label> <label>Email</label> <div><?php $person->printFieldInterface('mobile_tel', 'members_0_'); ?> </div> <div><?php $person->printFieldInterface('email', 'members_0_'); ?> </div> </div> </td> </tr> <?php } else { ?> <thead> <tr> <td>First Name</td> <td>Last Name</td> <td>Gender</td> <td>Age</td> <td>Status</td> <td>Cong.</td> <td>Mobile Tel</td> <td>Email</td> </tr> <thead> <tbody> <tr> <td><?php $person->printFieldInterface('first_name', 'members_0_'); ?> </td> <td class="last_name preserve-value"><?php $person->printFieldInterface('last_name', 'members_0_'); ?> </td> <td><?php $person->printFieldInterface('gender', 'members_0_'); ?> </td> <td><?php $person->printFieldInterface('age_bracket', 'members_0_'); ?> </td> <td class="person-status preserve-value"><?php $person->printFieldInterface('status', 'members_0_'); ?> </td> <td class="congregation preserve-value"><?php $person->printFieldInterface('congregationid', 'members_0_'); ?> </td> <td><?php $person->printFieldInterface('mobile_tel', 'members_0_'); ?> </td> <td><?php $person->printFieldInterface('email', 'members_0_'); ?> </td> </tr> </tbody> <?php } ?> </table> </div> <h3>Family Details <small>(optional)</small></h3> <?php $this->_family->fields['family_name']['readonly'] = 1; $this->_family->printForm(); $this->_family->fields['family_name']['readonly'] = 0; ?> <?php if ($GLOBALS['user_system']->havePerm(PERM_EDITNOTE)) { ?> <div <?php echo REQUIRE_INITIAL_NOTE ? '' : 'class="optional"'; ?> > <h3>Initial Note <small>(<?php echo REQUIRE_INITIAL_NOTE ? 'required' : 'optional'; ?> )</small></h3> <?php $GLOBALS['system']->includeDBClass('family_note'); $note = new Family_Note(); $note->printForm('initial_note_'); ?> </div> <?php } if ($plan_chooser = Action_Plan::getMultiChooser('execute_plan', 'create_family')) { ?> <h3>Action plans <small>(optional)</small></h3> <p>Execute the following action plans for the new family: </p> <div class="indent-left"> <?php echo $plan_chooser; ?> <p>Reference date for plans: <?php print_widget('plan_reference_date', array('type' => 'date'), NULL); ?> </p> </div> <?php } ?> <h3>Create</h3> <div class="align-right"> <input type="submit" class="btn" value="Create Family" /> <input type="button" class="back btn" value="Cancel" /> </div> </form> <?php }
function _printSummaryRows() { parent::_printSummaryRows(); include_once 'include/size_detector.class.php'; if (SizeDetector::isNarrow()) { ?> <tr class="divider-before"> <td colspan="2" id="family-members-container"> <h4> Members:</h4> <?php } else { ?> <tr class="divider-before"> <th>Members</th> <td id="family-members-container"> <?php } $persons = $this->getMemberData(); $show_actions = !empty($this->id); // hide actions if this is a "draft" family if (isset($this->_tmp['show_member_callback'])) { call_user_func($this->_tmp['show_member_callback'], $persons); } else { if (empty($this->_tmp['abbreviate_member_list'])) { ?> <div style="float: left" id="member-details-container"> <?php // full blown version $special_fields = array('congregation'); if (!empty($this->_tmp['member_list_special_fields'])) { $special_fields = $this->_tmp['member_list_special_fields']; } include 'templates/person_list.template.php'; ?> </div> <?php if ($GLOBALS['system']->featureEnabled('PHOTOS') && $this->id) { ?> <div style="float: left; " id="family-photos-container"> <?php foreach ($persons as $personid => $details) { ?> <a href="?view=persons&personid=<?php echo (int) $personid; ?> "><img title="<?php echo ents($details['first_name'] . ' ' . $details['last_name']); ?> " src="?call=person_photo&personid=<?php echo (int) $personid; ?> " /></a> <?php } ?> </div> <?php } } else { // abbreviated version $GLOBALS['system']->includeDBClass('person'); $dummy_person = new Person(); ?> <table> <?php foreach ($persons as $id => $person) { $dummy_person->populate($id, $person); $tr_class = $person['status'] == 'archived' ? ' class="archived"' : ''; ?> <tr<?php echo $tr_class; ?> > <td class="nowrap"><a href="?view=persons&personid=<?php echo $id; ?> "><?php echo ents($dummy_person->toString()); ?> </a></td> <td><?php $dummy_person->printFieldValue('gender'); ?> </td> <td><?php $dummy_person->printFieldValue('age_bracket'); ?> </td> </tr> <?php } ?> </table> <?php } } ?> </td> </tr> <?php }
echo 'Add as a '; Person_Group::printMembershipStatusChooser('membership_status'); echo ' of '; $can_add_group = Person_Group::printChooser('groupid', 0, array_keys($groups)); ?> </div> <div class="modal-footer"> <input type="submit" class="btn" value="Go" accesskey="s" onclick="if (!$('[name=groupid]').val()) { alert('Choose a group first'); return false; }" /> <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> </div> </form> </div> <?php } // -------- CHECK PERMISSIONS AND ASSEMBLE DATA ------------- // $accordion = SizeDetector::getWidth() && SizeDetector::isNarrow(); $tabs = array('basic' => 'Basic Details'); if ($GLOBALS['user_system']->havePerm(PERM_VIEWNOTE)) { $notes = $person->getNotesHistory(); $tabs['notes'] = 'Notes (' . count($notes) . ')'; } if ($can_add_group || count($groups) > 1) { $tabs['groups'] = 'Groups (' . count($groups) . ')'; } if ($GLOBALS['user_system']->havePerm(PERM_VIEWATTENDANCE)) { $tabs['attendance'] = 'Attendance'; } if ($GLOBALS['user_system']->havePerm(PERM_VIEWROSTER)) { $tabs['rosters'] = 'Rosters'; } if (!$accordion && ($GLOBALS['user_system']->havePerm(PERM_VIEWNOTE) || !$GLOBALS['system']->featureEnabled('NOTES'))) {
?> > <td><?php echo (int) $id; ?> </td> <td><?php echo ents($details['family_name']); ?> </td> <td><?php echo ents($details['members']); ?> </td> <?php if (!SizeDetector::isNarrow()) { ?> <td><?php echo ents($details['home_tel']); ?> </td> <?php } ?> <td class="action-cell narrow"> <a href="?view=families&familyid=<?php echo $id; ?> "><i class="icon-user"></i>View</a> <?php if ($GLOBALS['user_system']->havePerm(PERM_EDITPERSON)) {
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'; }
function printForm($prefix = 0) { require_once 'include/size_detector.class.php'; $order = defined('ATTENDANCE_LIST_ORDER') ? constant('ATTENDANCE_LIST_ORDER') : self::LIST_ORDER_DEFAULT; if ($this->congregationid) { $conds = array('congregationid' => $this->congregationid, '!status' => 'archived'); if (strlen($this->age_bracket)) { $conds['age_bracket'] = $this->age_bracket; } $members = $GLOBALS['system']->getDBObjectData('person', $conds, 'AND', $order); } else { $group =& $GLOBALS['system']->getDBObject('person_group', $this->groupid); $members =& $group->getMembers(FALSE, $order); if (strlen($this->age_bracket)) { // Not the most efficient but it's a problem when it's a problem foreach ($members as $i => $person) { if ($person['age_bracket'] != $this->age_bracket) { unset($members[$i]); } } } } $GLOBALS['system']->includeDBClass('person'); $dummy = new Person(); ?> <table class="table table-condensed table-auto-width valign-middle"> <?php $is_first = TRUE; foreach ($members as $personid => $details) { $v = isset($this->_attendance_records[$personid]) ? $this->_attendance_records[$personid] ? 'present' : 'absent' : (empty($this->_attendance_records) ? '' : 'unknown'); $dummy->populate($personid, $details); ?> <tr> <?php if (!SizeDetector::isNarrow()) { ?> <td><?php echo $personid; ?> </td> <?php } if ($this->show_photos) { ?> <td> <img style="width: 50px; max-width: 50px" src="?call=person_photo&personid=<?php echo (int) $personid; ?> " /> </td> <?php } ?> <td><?php echo ents($details['last_name']); ?> </td> <td><?php echo ents($details['first_name']); ?> </td> <?php if (!SizeDetector::isNarrow()) { ?> <td> <?php if ($this->groupid) { echo ents($details['membership_status']); } else { $dummy->printFieldValue('status'); } ?> </td> <?php } ?> <td class="narrow"> <?php print_widget('attendances[' . $prefix . '][' . $personid . ']', array('options' => array('unknown' => '?', 'present' => 'Present', 'absent' => 'Absent'), 'type' => 'select', 'style' => 'colour-buttons', 'class' => $is_first ? 'autofocus' : ''), $v); ?> </td> <?php if (!SizeDetector::isNarrow()) { ?> <td class="action-cell narrow"> <a class="med-popup" tabindex="-1" href="?view=persons&personid=<?php echo $personid; ?> "><i class="icon-user"></i>View</a> <a class="med-popup" tabindex="-1" href="?view=_edit_person&personid=<?php echo $personid; ?> "><i class="icon-wrench"></i>Edit</a> <a class="med-popup" tabindex="-1" href="?view=_add_note_to_person&personid=<?php echo $personid; ?> "><i class="icon-pencil"></i>Add Note</a> </td> <?php } ?> </tr> <?php $is_first = FALSE; } ?> </table> <?php return count($members); }