function printView($start_date = NULL, $end_date = NULL, $editing = FALSE, $public = FALSE) { if (empty($this->_members)) { return; } if (!$editing && !$public) { $my_email = $GLOBALS['user_system']->getCurrentUser('email'); } $GLOBALS['system']->includeDBClass('service'); $dummy_service = new Service(); if (is_null($start_date)) { $start_date = date('Y-m-d'); } $service_params = array('congregationid' => $this->getCongregations(), '>date' => date('Y-m-d', strtotime($start_date . ' -1 day'))); if (!is_null($end_date)) { $service_params['<date'] = date('Y-m-d', strtotime($end_date . ' +1 day')); } $services = $GLOBALS['system']->getDBObjectData('service', $service_params, 'AND', 'date'); $to_print = array(); foreach ($services as $id => $service_details) { $service_details['id'] = $id; $to_print[$service_details['date']]['service'][$service_details['congregationid']] = $service_details; $to_print[$service_details['date']]['assignments'] = array(); } foreach ($this->getAssignments($start_date, $end_date) as $date => $date_assignments) { $to_print[$date]['assignments'] = $date_assignments; } ksort($to_print); $role_objects = array(); $this_sunday = date('Y-m-d', strtotime('Sunday')); if (empty($to_print)) { if ($public) { ?> <div class="alert alert-error">This roster is empty for the current date range.</div> <?php } else { ?> <div class="alert alert-error">There are no services during the date range specified. Please try a different date range, or create some services using the 'Edit service program' page.</div> <?php } return; } if ($editing) { $show_lock_fail_msg = false; $show_group_denied_msg = false; foreach ($this->_members as $id => &$details) { if (!empty($details['role_id'])) { $role = $GLOBALS['system']->getDBObject('roster_role', $details['role_id']); if (!($role->canAcquireLock('assignments') && $role->acquireLock('assignments'))) { $details['readonly'] = true; $show_lock_fail_msg = true; } if (!$role->canEditAssignments()) { $details['readonly'] = true; $show_group_denied_msg = true; } } } if ($show_lock_fail_msg) { print_message("Some of the roles in this roster are currently being edited by another user. To edit assignments for these roles, wait until the other user finishes then try again.", 'failure'); } if ($show_group_denied_msg) { print_message("There are some roles in this roster which you are not able to edit because they refer to a volunteer group you do not have access to."); } ?> <form method="post" class="warn-unsaved bubble-option-props"> <script> $(document).ready(function() { setTimeout('showLockExpiryWarning()', <?php echo (strtotime('+' . LOCK_LENGTH, 0) - 60) * 1000; ?> ); setTimeout('showLockExpiredWarning()', <?php echo strtotime('+' . LOCK_LENGTH, 0) * 1000; ?> ); $('table.roster select').keypress(function() { handleRosterChange(this); }).change(function() { handleRosterChange(this); }); $('table.roster input.person-search-single, table.roster input.person-search-multiple').each(function() { this.onchange = function() { handleRosterChange(this); }; }); $('table.roster > tbody > tr').each(function() { updateClashesForRow($(this)); }); }); function handleRosterChange(inputField) { var row = null; if ($(inputField).hasClass('person-search-single') || $(inputField).hasClass('person-search-multiple')) { row = $(inputField).parents('tr:first'); } else if (inputField.tagName == 'SELECT' || inputField.type == 'hidden') { var expandableParent = $(inputField).parents('table.expandable'); if (expandableParent.length) { var row = $(inputField).parents('table:first').parents('tr:first'); } else { var row = $(inputField).parents('tr:first'); } } if (row) { updateClashesForRow(row); } } function updateClashesForRow(row) { var uses = new Object(); // Deal with the single person choosers and select boxes first var sameRowInputs = row.find('input.person-search-single, select'); sameRowInputs.removeClass('clash'); sameRowInputs.each(function() { var thisElt = this; var thisVal = 0; if (this.className == 'person-search-single') { var hiddenInput = document.getElementsByName(this.id.substr(0, this.id.length-6))[0]; thisVal = hiddenInput.value; } else if (this.tagName == 'SELECT') { thisVal = this.value; } if (thisVal != 0) { if (!uses[thisVal]) { uses[thisVal] = new Array(); } uses[thisVal].push(thisElt); } }); // Now add the multi person choosers row.find('ul.multi-person-finder li').removeClass('clash').each(function() { var thisVal = $(this).find('input')[0].value; if (thisVal != 0) { if (!uses[thisVal]) { uses[thisVal] = new Array(); } uses[thisVal].push(this); } }); for (i in uses) { if (uses[i].length > 1) { for (j in uses[i]) { if (typeof uses[i][j] == 'function') continue; $(uses[i][j]).addClass('clash'); } } } } </script> <?php } ?> <table class="table roster" border="1" cellspacing="0" cellpadding="1"> <?php $this->_printTableHeader($editing, $public); ?> <tbody> <?php foreach ($to_print as $date => $ddetail) { if ($public && empty($ddetail['assignments'])) { continue; } $class_clause = $date == $this_sunday ? 'class="tblib-hover"' : ''; ?> <tr <?php echo $class_clause; ?> > <td class="nowrap"> <?php echo '<strong>' . str_replace(' ', ' ', date('j M y', strtotime($date))) . '</strong>'; if (!$editing && !$public) { $emails = array(); foreach ($ddetail['assignments'] as $roleid => $assignees) { foreach ($assignees as $pid => $pdetails) { if (!empty($pdetails['email']) && $pdetails['email'] != $my_email) { $emails[] = $pdetails['email']; } } } $emails = array_unique($emails); if (!empty($emails)) { ?> <p class="smallprint no-print"> <a href="<?php echo get_email_href($my_email, NULL, $emails, date('jS F', strtotime($date))); ?> " <?php echo email_link_extras(); ?> >Email All</a> <?php if (defined('SMS_HTTP_URL') && constant('SMS_HTTP_URL') && $GLOBALS['user_system']->havePerm(PERM_SENDSMS)) { ?> | <span class="clickable" onclick="$(this).parent().next('form').toggle(); $(this).parents('tr:first').addClass('tblib-hover')">SMS All</span> <?php } ?> </p> <?php if (defined('SMS_HTTP_URL') && constant('SMS_HTTP_URL') && $GLOBALS['user_system']->havePerm(PERM_SENDSMS)) { $url = build_url(array('view' => '_send_sms_http', 'roster_view' => $this->id, 'start_date' => $date, 'end_date' => $date)); ?> <form method="post" action="<?php echo $url; ?> " style="position: absolute; display: none"> <div class="standard" style="border-width: 2px; border-radius: 8px"> <h3>Send SMS</h3> <textarea name="message" rows="5" cols="30" maxlength="<?php echo SMS_MAX_LENGTH; ?> "></textarea> <br /> <input type="submit" value="Send" /> <input type="button" onclick="$(this).parents('form').toggle(); $(this).parents('tr:first').removeClass('tblib-hover')" value="Cancel" /> </div> </form> <?php } } } ?> </td> <?php $last_congid = NULL; foreach ($this->_members as $id => $mdetail) { $td_class = ''; if ($mdetail['congregationid'] != $last_congid) { $td_class = 'thick-left-border'; $last_congid = $mdetail['congregationid']; } ?> <td class="<?php echo $td_class; ?> "> <?php if ($mdetail['role_id']) { if ($editing && empty($mdetail['readonly'])) { $currentval = array(); foreach (array_get($ddetail['assignments'], $mdetail['role_id'], array()) as $pid => $pdetails) { $currentval[$pid] = $pdetails['name']; } if (empty($role_objects[$mdetail['role_id']])) { $role_objects[$mdetail['role_id']] =& $GLOBALS['system']->getDBObject('roster_role', $mdetail['role_id']); } if (empty($role_objects[$mdetail['role_id']])) { // must've been a problem continue; } $role_objects[$mdetail['role_id']]->printChooser($date, $currentval); } else { $names = array(); foreach (array_get($ddetail['assignments'], $mdetail['role_id'], array()) as $personid => $vs) { if (!$public) { $n = '<a href="' . BASE_URL . '?view=persons&personid=' . $personid . '" title="Assigned by ' . ents($vs['assigner']) . ' on ' . format_datetime($vs['assignedon']) . '">' . nbsp(ents($vs['name'])) . '</a>'; if (empty($vs['email'])) { $n .= ' <img src="' . BASE_URL . 'resources/img/no_email.png" style="display:inline" title="No Email Address" />'; } $names[] = $n; } else { $names[] = nbsp($vs['name']); } } echo implode("<br />", $names); } } else { if (!empty($ddetail['service'][$mdetail['congregationid']])) { if ($public && (!defined('SHOW_SERVICE_NOTES_PUBLICLY') || !SHOW_SERVICE_NOTES_PUBLICLY)) { // no notes in public view unset($ddetail['service'][$mdetail['congregationid']]['notes']); } $dummy_service->populate($ddetail['service'][$mdetail['congregationid']]['id'], $ddetail['service'][$mdetail['congregationid']]); $dummy_service->printFieldvalue($mdetail['service_field']); } } ?> </td> <?php } if (!$public && count($this->_members) > REPEAT_DATE_THRESHOLD) { ?> <td class="nowrap thick-left-border"> <strong><?php echo str_replace(' ', ' ', date('j M y', strtotime($date))); ?> </strong> </td> <?php } ?> </tr> <?php } ?> </tbody> <?php if (!$public && count($to_print) > 6) { $this->_printTableFooter($editing, $public); } ?> </table> <?php if ($editing) { ?> <input type="submit" class="btn" value="Save" accesskey="s" /> </form> <?php } }
/** * Print the value of a field to the HTML interface * * Subclasses should add links and other HTML markup by overriding this */ public function printFieldValue($name, $value = null) { if (!isset($this->fields[$name])) { trigger_error('Cannot get value for field ' . ents($name) . ' - field does not exist', E_USER_WARNING); return NULL; } if (is_null($value)) { $value = $this->values[$name]; } if ($name == 'history' && !empty($value)) { ?> <table class="history table table-full-width table-striped"> <?php foreach ($value as $time => $detail) { ?> <tr> <th class="narrow"><?php echo format_datetime($time); ?> </th> <td><?php echo nl2br(ents($detail)); ?> </td> </tr> <?php } ?> </table> <?php } else { if ($this->fields[$name]['type'] == 'bitmask') { $percol = false; if (!empty($this->fields[$name]['cols']) && (int) $this->fields[$name]['cols'] > 1) { $percol = ceil(count($this->fields[$name]['options']) / $this->fields[$name]['cols']); } $i = 0; foreach ($this->fields[$name]['options'] as $k => $v) { $checked_exp = ($value & (int) $k) == $k ? 'checked="checked"' : ''; ?> <label class="checkbox"> <input type="checkbox" disabled="disabled" name="<?php echo ents($name); ?> []" value="<?php echo ents($k); ?> " id="<?php echo ents($name . '_' . $k); ?> " <?php echo $checked_exp; ?> > <?php echo nbsp(ents($v)); ?> </label> <?php } } else { if ($this->fields[$name]['type'] == 'text' && array_get($this->fields[$name], 'height', 1) > 1) { echo nl2br(ents($this->getFormattedValue($name, $value))); } else { if ($this->fields[$name]['type'] == 'phone') { echo '<a href="tel:' . $value . '">' . ents($this->getFormattedValue($name, $value)) . '</a>'; } else { if ($this->fields[$name]['type'] == 'email') { $personName = $this->values[$name] == $value ? $this->values['first_name'] . ' ' . $this->values['last_name'] : ''; echo '<a href="' . get_email_href($value, $personName) . '" ' . email_link_extras() . '>' . ents($value) . '</a>'; } else { if ($this->fields[$name]['type'] == 'html') { echo $this->getFormattedValue($name, $value); } else { echo ents($this->getFormattedValue($name, $value)); } } } } } } }
private function printPopup($emails, $archived, $blanks) { $public = array_get($_REQUEST, 'method') == 'public'; ?> <html> <head> <title>Jethro PMM - selected emails</title> <?php include 'templates/head.template.php'; ?> </head> <body> <div id="body"> <?php $chunks = array_chunk($emails, EMAIL_CHUNK_SIZE); if (count($chunks) == 1) { $this->printArchivedWarning($archived); ?> <br /> <div class="align-center"><a class="btn btn-primary" href="<?php echo $this->getHref($emails, $public); ?> " <?php echo email_link_extras(); ?> >Email selected persons now</a></div> <?php } else { ?> <h1>Send Email</h1> <?php $this->printArchivedWarning($archived); ?> <p style="line-height: 50px"> <?php foreach ($chunks as $i => $chunk) { ?> <a class="btn" href="<?php echo $this->getHref($chunk, $public); ?> " onclick="this.style.textDecoration='line-through'" <?php echo email_link_extras(); ?> >Email Batch #<?php echo $i + 1; ?> </a> <?php } ?> </p> <?php } $this->printBlanks($blanks); ?> </div> </body> </html> <?php }
echo implode(' ', $links); ?> </div> <?php } $family->printSummary($accordion ? TRUE : FALSE); ?> <div class="align-right"> <?php $links = array(); if ($family->getPostalAddress() != '') { $links[] = '<a href="?call=envelopes&familyid=' . $family->id . '" class="envelope-popup"><i class="icon-envelope"></i>Print Envelope</a>'; } $all_emails = $family->getAllEmailAddrs(); if (!empty($all_emails)) { $links[] = '<a href="' . get_email_href($all_emails) . '" ' . email_link_extras() . '><i class="icon-email">@</i>Email All</a>'; } echo implode(' ', $links); ?> </div> <?php echo $panel_footer; /**************** NOTES TAB ****************/ if ($GLOBALS['user_system']->havePerm(PERM_VIEWNOTE)) { printf($panel_header, 'notes', 'Notes (' . count($notes) . ')', ''); $show_edit_link = FALSE; if ($GLOBALS['user_system']->havePerm(PERM_EDITNOTE)) { ?> <div class="align-right"> <?php $members = $family->getMemberData();
echo ' • '; echo ents($dummy->getFormattedValue('gender')); echo '<br />'; echo ents($dummy->getFormattedValue('status')); echo ' • '; echo ents($dummy->getFormattedValue('congregationid')); ?> </div> </div> </a> <?php } $all_emails = $family->getAllEmailAddrs(); if (!empty($all_emails)) { echo '<a class="pull-right" href="' . get_email_href($all_emails) . '" ' . email_link_extras() . '><i class="icon-email">@</i>Email All</a>'; } ?> <br class="clearfix" /> <?php include 'templates/bulk_actions.template.php'; ?> </form> </div> </div> <?php if (!$accordion && $GLOBALS['system']->featureEnabled('PHOTOS')) {
function printView($start_date = NULL, $end_date = NULL, $editing = FALSE, $public = FALSE) { if (empty($this->_members)) { return; } if (!$editing && !$public) { $my_email = $GLOBALS['user_system']->getCurrentUser('email'); } $GLOBALS['system']->includeDBClass('service'); $dummy_service = new Service(); if (is_null($start_date)) { $start_date = date('Y-m-d'); } $service_params = array('congregationid' => $this->getCongregations(), '>date' => date('Y-m-d', strtotime($start_date . ' -1 day'))); if (!is_null($end_date)) { $service_params['<date'] = date('Y-m-d', strtotime($end_date . ' +1 day')); } $services = $GLOBALS['system']->getDBObjectData('service', $service_params, 'AND', 'date'); $to_print = array(); foreach ($services as $id => $service_details) { $service_details['id'] = $id; $to_print[$service_details['date']]['service'][$service_details['congregationid']] = $service_details; $to_print[$service_details['date']]['assignments'] = array(); } $haveHidden = FALSE; foreach ($this->getAssignments($start_date, $end_date) as $date => $date_assignments) { $to_print[$date]['assignments'] = $date_assignments; foreach ($date_assignments as $rid => $asns) { foreach ($asns as $pid => $dets) { if ($dets['assigneehidden']) { $haveHidden = TRUE; } break 2; } } } ksort($to_print); $role_objects = array(); $this_sunday = date('Y-m-d', strtotime('Sunday')); if (empty($to_print)) { if ($public) { ?> <div class="alert alert-error">This roster is empty for the current date range.</div> <?php } else { ?> <div class="alert alert-error">There are no services during the date range specified. Please try a different date range, or create some services using the 'Edit service program' page.</div> <?php } return; } if (!$public && $haveHidden) { if ($editing) { print_message("Some allocations can't be edited because they involve persons you do not have permission to view", 'warning'); } else { print_message("This roster includes some persons that you do not have permission to view", 'warning'); } } if ($editing) { $show_lock_fail_msg = false; $show_group_denied_msg = false; foreach ($this->_members as $id => &$details) { if (!empty($details['role_id'])) { $role = $GLOBALS['system']->getDBObject('roster_role', $details['role_id']); if (!($role->canAcquireLock('assignments') && $role->acquireLock('assignments'))) { $details['readonly'] = true; $show_lock_fail_msg = true; } if (!$role->canEditAssignments()) { $details['readonly'] = true; $show_group_denied_msg = true; } } } if ($show_lock_fail_msg) { print_message("Some of the roles in this roster are currently being edited by another user. To edit assignments for these roles, wait until the other user finishes then try again.", 'failure'); } if ($show_group_denied_msg) { print_message("There are some roles in this roster which you are not able to edit because they refer to a volunteer group you do not have access to."); } ?> <form id="roster" method="post" class="warn-unsaved bubble-option-props" data-lock-length="<?php echo LOCK_LENGTH; ?> "> <?php } ?> <div id="choose-assignee-modal" class="modal hide fade" role="dialog" aria-hidden="true"> <div class="modal-header"> <h4>Choose assignee</h4> </div> <div class="modal-body"> <?php Person::printSingleFinder('personid', NULL); ?> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" id="choose-assignee-save">Save</button> <button class="btn" data-dismiss="modal"id="choose-assignee-cancel">Cancel</button> </div> </div> <table class="table roster" border="1" cellspacing="0" cellpadding="1"> <?php $this->_printTableHeader($editing, $public); ?> <tbody> <?php foreach ($to_print as $date => $ddetail) { if ($public && empty($ddetail['assignments'])) { continue; } $class_clause = $date == $this_sunday ? 'class="tblib-hover"' : ''; ?> <tr <?php echo $class_clause; ?> > <td class="nowrap"> <?php echo '<strong>' . str_replace(' ', ' ', date('j M y', strtotime($date))) . '</strong>'; if (!$editing && !$public) { $emails = array(); foreach ($ddetail['assignments'] as $roleid => $assignees) { foreach ($assignees as $pid => $pdetails) { if (!empty($pdetails['email']) && $pdetails['email'] != $my_email) { $emails[] = $pdetails['email']; } } } $emails = array_unique($emails); if (!empty($emails)) { ?> <p class="smallprint no-print"> <a href="<?php echo get_email_href($my_email, NULL, $emails, date('jS F', strtotime($date))); ?> " <?php echo email_link_extras(); ?> >Email All</a> <?php if (defined('SMS_HTTP_URL') && constant('SMS_HTTP_URL') && $GLOBALS['user_system']->havePerm(PERM_SENDSMS)) { ?> | <span class="clickable" onclick="$(this).parent().next('form').toggle(); $(this).parents('tr:first').addClass('tblib-hover')">SMS All</span> <?php } ?> </p> <?php if (defined('SMS_HTTP_URL') && constant('SMS_HTTP_URL') && $GLOBALS['user_system']->havePerm(PERM_SENDSMS)) { $url = build_url(array('view' => '_send_sms_http', 'roster_view' => $this->id, 'start_date' => $date, 'end_date' => $date)); ?> <form method="post" action="<?php echo $url; ?> " style="position: absolute; display: none"> <div class="well well-small"> <h3>Send SMS</h3> <textarea name="message" rows="5" cols="30" maxlength="<?php echo SMS_MAX_LENGTH; ?> "></textarea> <br /> <input class="btn" type="submit" value="Send" /> <input class="btn" type="button" onclick="$(this).parents('form').toggle(); $(this).parents('tr:first').removeClass('tblib-hover')" value="Cancel" /> </div> </form> <?php } } } ?> </td> <?php $last_congid = NULL; foreach ($this->_members as $id => $mdetail) { $td_class = ''; if ($mdetail['congregationid'] != $last_congid) { $td_class = 'thick-left-border'; $last_congid = $mdetail['congregationid']; } ?> <td class="<?php echo $td_class; ?> "> <?php if ($mdetail['role_id']) { $haveHidden = FALSE; foreach (array_get($ddetail['assignments'], $mdetail['role_id'], array()) as $pid => $pdetails) { if ($pdetails['assigneehidden']) { $haveHidden = TRUE; } } if ($editing && empty($mdetail['readonly']) && !$haveHidden) { $currentval = array(); foreach (array_get($ddetail['assignments'], $mdetail['role_id'], array()) as $pid => $pdetails) { $currentval[$pid] = $pdetails['name']; } if (empty($role_objects[$mdetail['role_id']])) { $role_objects[$mdetail['role_id']] =& $GLOBALS['system']->getDBObject('roster_role', $mdetail['role_id']); } if (empty($role_objects[$mdetail['role_id']])) { // must've been a problem continue; } $role_objects[$mdetail['role_id']]->printChooser($date, $currentval); } else { $names = array(); foreach (array_get($ddetail['assignments'], $mdetail['role_id'], array()) as $personid => $vs) { if (!$public && !$vs['assigneehidden']) { $n = '<a href="' . BASE_URL . '?view=persons&personid=' . $personid . '" title="Assigned by ' . ents($vs['assigner']) . ' on ' . format_datetime($vs['assignedon']) . '">' . nbsp(ents($vs['name'])) . '</a>'; if ('' === $vs['email']) { $n .= ' <img src="' . BASE_URL . 'resources/img/no_email.png" style="display:inline" title="No Email Address" />'; } $names[] = $n; } else { $names[] = nbsp($vs['name']); } } echo implode("<br />", $names); } } else { if (!empty($ddetail['service'][$mdetail['congregationid']])) { if ($public && (!defined('SHOW_SERVICE_NOTES_PUBLICLY') || !SHOW_SERVICE_NOTES_PUBLICLY)) { // no notes in public view unset($ddetail['service'][$mdetail['congregationid']]['notes']); } $dummy_service->populate($ddetail['service'][$mdetail['congregationid']]['id'], $ddetail['service'][$mdetail['congregationid']]); $dummy_service->printFieldvalue($mdetail['service_field']); } } ?> </td> <?php } if (!$public && count($this->_members) > REPEAT_DATE_THRESHOLD) { ?> <td class="nowrap thick-left-border"> <strong><?php echo str_replace(' ', ' ', date('j M y', strtotime($date))); ?> </strong> </td> <?php } ?> </tr> <?php } ?> </tbody> <?php if (!$public && count($to_print) > 6) { $this->_printTableFooter($editing, $public); } ?> </table> <?php if ($editing) { ?> <input type="submit" class="btn" value="Save" accesskey="s" /> </form> <?php } }