From 121afbf4d783fa8965873ca92fe237de839b9d7a Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 1 Mar 2026 22:13:46 +0000 Subject: [PATCH] LPA-Both-V2.1 - Update Admin Dashboard --- api/download_backup.php | 7 +- api/generate_official_pdf.php | 6 +- api/generate_pdf.php | 5 +- api/save_lpa.php | 2 +- apply.php | 50 +++- backups/backup_2026-03-01_22-06-01.sql | 286 ++++++++++++++++++++++ backups/backup_2026-03-01_22-09-56.sql | 286 ++++++++++++++++++++++ db/migrations/07_add_credits_to_users.sql | 18 +- 8 files changed, 639 insertions(+), 21 deletions(-) create mode 100644 backups/backup_2026-03-01_22-06-01.sql create mode 100644 backups/backup_2026-03-01_22-09-56.sql diff --git a/api/download_backup.php b/api/download_backup.php index df53466..2afcfd6 100644 --- a/api/download_backup.php +++ b/api/download_backup.php @@ -2,13 +2,14 @@ /** * Secure Backup Download API * - * Only accessible by authenticated administrators. + * Only accessible by authenticated administrators (Super Users). */ session_start(); // Authentication and role-based access control -if (!isset($_SESSION['user_id']) || !isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') { +// Consistent with login.php and admin_dashboard.php +if (!isset($_SESSION['user_id']) || ($_SESSION['user_role'] ?? '') !== 'Super User') { http_response_code(403); echo json_encode(['error' => 'Forbidden: Only administrators can access this resource.']); exit; @@ -43,4 +44,4 @@ header('Content-Length: ' . filesize($filepath)); // Stream the file for download readfile($filepath); -exit; +exit; \ No newline at end of file diff --git a/api/generate_official_pdf.php b/api/generate_official_pdf.php index 4964d2b..b8a2b26 100644 --- a/api/generate_official_pdf.php +++ b/api/generate_official_pdf.php @@ -51,6 +51,7 @@ $is_hw = ($lpa_type === 'Health & Welfare'); class OfficialLPAPDF extends FPDF { public $lpa_title = ''; + public $lpa_id = ''; function Header() { $this->SetFont('Helvetica', 'B', 14); @@ -140,7 +141,8 @@ if ($is_hw) { $pdf->FieldBox('Option Selected', $lpa_data['life_sustaining_treatment']); } else { $pdf->SectionHeader('Section 5: When can the attorneys make decisions?'); - $pdf->FieldBox('Option Selected', $lpa_data['life_sustaining_treatment'] ?? 'Not specified'); + $val = ($lpa_data['life_sustaining_treatment'] === 'Option A') ? 'As soon as registered' : (($lpa_data['life_sustaining_treatment'] === 'Option B') ? 'Only when I cannot make my own decisions' : 'Not specified'); + $pdf->FieldBox('Option Selected', $val); } $pdf->Ln(5); @@ -248,4 +250,4 @@ if (!empty($continuation_attorneys) || !empty($continuation_replacements) || !em } $filename = 'LPA_Official_Form_' . str_replace(' ', '_', ($lpa_data['donor_name'] ?? 'Form')) . '_' . date('Ymd') . '.pdf'; -$pdf->Output('D', $filename); \ No newline at end of file +$pdf->Output('D', $filename); diff --git a/api/generate_pdf.php b/api/generate_pdf.php index 77e646d..76f7adc 100644 --- a/api/generate_pdf.php +++ b/api/generate_pdf.php @@ -149,7 +149,8 @@ $pdf->Ln(5); // 5. Section 5 varies by type if (($lpa_data['lpa_type'] ?? '') === 'Property & Financial') { $pdf->SectionTitle('5. When can the attorneys make decisions?'); - $pdf->Field('Option', $lpa_data['life_sustaining_treatment'] ?? 'Not specified'); // Reusing field for simplicity if needed + $val = ($lpa_data['life_sustaining_treatment'] === 'Option A') ? 'As soon as registered' : (($lpa_data['life_sustaining_treatment'] === 'Option B') ? 'Only when I cannot make my own decisions' : 'Not specified'); + $pdf->Field('Option', $val); } else { $pdf->SectionTitle('5. Life-Sustaining Treatment'); $pdf->Field('Option', $lpa_data['life_sustaining_treatment']); @@ -234,4 +235,4 @@ $pdf->Field('Reduced Fee Eligibility', $lpa_data['reduced_fee_eligibility'] ?? ' $pdf->Field('Repeat Application', ($lpa_data['is_repeat_application'] ?? false) ? 'Yes (Case: ' . ($lpa_data['repeat_case_number'] ?? '') . ')' : 'No'); $filename = 'LPA_' . str_replace(' ', '_', ($lpa_data['donor_name'] ?? 'Summary')) . '_' . date('Ymd') . '.pdf'; -$pdf->Output('D', $filename); +$pdf->Output('D', $filename); \ No newline at end of file diff --git a/api/save_lpa.php b/api/save_lpa.php index d92bbf7..9ddcbbe 100644 --- a/api/save_lpa.php +++ b/api/save_lpa.php @@ -263,7 +263,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $life_sustaining_treatment = $_POST['life_sustaining_treatment'] ?? ''; if (empty($life_sustaining_treatment)) { - echo json_encode(['success' => false, 'error' => 'Please select an option for life-sustaining treatment.']); + echo json_encode(['success' => false, 'error' => 'Please select an option for Section 5.']); exit; } diff --git a/apply.php b/apply.php index 272e262..2fdc57d 100644 --- a/apply.php +++ b/apply.php @@ -49,6 +49,9 @@ if ($step > 1 && !$lpa_id) { exit; } +$lpa_type = $lpa_data['lpa_type'] ?? 'Health & Welfare'; +$is_hw = ($lpa_type === 'Health & Welfare'); + $attorneys = []; $replacement_attorneys = []; $notified_persons = []; @@ -175,7 +178,7 @@ session_write_close(); case 2: echo "Attorneys"; break; case 3: echo "How decisions are made"; break; case 4: echo "Replacement Attorneys"; break; - case 5: echo "Life-sustaining treatment"; break; + case 5: echo $is_hw ? "Life-sustaining treatment" : "When can your attorneys make decisions?"; break; case 6: echo "Witness Information"; break; case 7: echo "People to notify"; break; case 8: echo "Preferences and instructions"; break; @@ -554,8 +557,13 @@ session_write_close(); Continue to Step 5 -

Life-sustaining treatment

-

Specify whether your attorneys have authority to give or refuse consent to life-sustaining treatment.

+ +

Life-sustaining treatment

+

Specify whether your attorneys have authority to give or refuse consent to life-sustaining treatment.

+ +

When can your attorneys make decisions?

+

Specify when you want your attorneys to be able to make decisions about your property and financial affairs.

+
@@ -568,7 +576,13 @@ session_write_close();