# Location settings recovery, absentee dashboard, and report center

## Objective
Repair the blank location-settings page, add meaningful current-day absentee information to Attendance, and replace the direct PDF link with a complete reports center for absentee/member reporting and contact workflows. Fix TCPDF so PDFs work without GD or Imagick.

## Application and scope
Real PHP app at `C:\xampp\htdocs\jsowbkm` using PDO/MySQL and the shared admin shell.

Modify/create:
- `admin/location_settings.php`
- `admin/welcome.php`
- `admin/portal.php`
- new `admin/reports.php`
- `admin/generate_pdf.php`
- `assets/portal/css/admin.css`
- `assets/portal/js/admin.js` only when needed for toast/copy/contact interaction

Do not modify DB schema or unrelated processing endpoints.

## Critical bugs
1. `location_settings.php` calls `adminShellHeader($dbh,$staff,...)` without assigning `$staff`; restore `$staff=appRequireStaff($dbh)` before permission checks. Ensure runtime warnings remain hidden from UI and page content displays.
2. `generate_pdf.php` embeds transparent PNG logo twice. TCPDF requires GD/Imagick to decode it, but neither is guaranteed. Rebuild PDF output as text/table/vector-only and do not call any image methods or include `<img>`. Do not require new PHP extensions.

## Absentee definition
An absentee today is an Active Member in `tblmembers` for whom no `tblattendance` row exists with the same `member_id` and `attendance_date=CURRENT_DATE()`. Use `NOT EXISTS`, not `NOT IN`. This is church-wide and should be labeled clearly. Display today’s service context if one is scheduled. If no service is scheduled today, show the records as “not checked in today” and explain that absence is only meaningful on a service day.

## Attendance welcome page
- Keep current checked-in register.
- Add summary cards: active members, present today, absent/not checked in today, attendance rate (guard division by zero).
- Add a clear “Absentees today” section with searchable responsive records: photo/fallback if useful, name, member ID, phone, ministry, contact actions.
- Individual contact: `tel:` Call and `sms:` Text with safely normalized phone URI. Do not expose phone numbers to users without `attendance.view` (page already requires it).
- Link to the new Reports center.
- Keep mobile server-rendered `data-label` attributes.

## Reports center
Create `admin/reports.php`, require `reports.view`, and use `admin_shell.php`/`admin.css` only.

Content:
- Report overview cards with live counts and explanatory labels.
- Absentee report panel: date defaults to today; for now the on-page actionable queue may be current day. Show absentee list with search, member, ID, phone, ministry, individual Call/Text.
- Contact tools:
  - “Copy all numbers” copies newline/comma-safe normalized absentee phone list and reports success via toast/status.
  - “Prepare group text” may use a standards-tolerant `sms:` URI with comma-separated sanitized numbers and a prefilled pastoral follow-up message. Clearly label that support varies by device and never auto-send.
  - Calling everyone cannot be automatic; present a call queue with individual call controls. Do not claim bulk calling.
- Download options:
  - Absentees today PDF
  - Full member directory PDF
  - Attendance today PDF
- Useful non-PDF options can include printable view or CSV only if implemented fully; no placeholder/dead buttons.
- Explain report access and church-wide scope.

## PDF endpoint
Refactor `admin/generate_pdf.php`:
- Bootstrap shared app and require `reports.view`.
- Accept an allowlisted `type`: `members`, `absentees`, `attendance`; default `members` for backwards compatibility.
- Query appropriate records with prepared/controlled SQL.
- Escape all table content for TCPDF HTML (`htmlspecialchars`).
- Pure text/vector document header; no PNG/JPG/SVG/logo images and no `setHeaderData` image path.
- Sensible columns, title, current date, row count, empty state, footer/page numbers.
- Content-Disposition inline/download behavior may remain inline.
- No GD/Imagick dependency.

## Portal
Change Reports app destination from `generate_pdf.php` to `reports`. Preserve permission filtering.

## Visual direction
Use the established strong church-photo overlay, centered responsive shell, lemon-green accent, and frosted glass panels. The report center should feel like a calm pastoral operations console, not an accounting spreadsheet. Contact actions should be obvious without becoming visually noisy.

## Responsive/accessibility
- 1440, 1024, 768, 430, 375 widths; no horizontal page overflow.
- Tables stack into readable records on mobile with server labels.
- Buttons/links at least 44px; keyboard focus; clear statuses and toast feedback.
- Do not use native alert().
- Group SMS wording must be privacy-conscious and explicit that the device will open a draft.

## Verification
- PHP `-n -l` all changed/new PHP.
- Runtime-load location settings with an authenticated/representative session when possible or at least confirm `$staff` assignment.
- Confirm generate_pdf.php contains no image methods, `<img>`, or logo path and that all three types reach TCPDF output without the alpha-channel error.
- Confirm absentee SQL counts match an independent SQL query.
- Update asset cache keys where necessary.
