From e1f682ee18df9cbfb3a6b79a1e5bbbf804269b8c Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 1 Mar 2026 20:47:55 +0000 Subject: [PATCH] Autosave: 20260301-204755 --- api/save_lpa.php | 20 +++++++++ apply.php | 105 +++++++++++++++++++++++++---------------------- 2 files changed, 76 insertions(+), 49 deletions(-) diff --git a/api/save_lpa.php b/api/save_lpa.php index c7e82f7..231db69 100644 --- a/api/save_lpa.php +++ b/api/save_lpa.php @@ -161,6 +161,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $postcode = $_POST['postcode'] ?? ''; $next_action = $_POST['next_action'] ?? 'add_another'; + // Check if all primary fields are empty + $is_empty = empty($first_name) && empty($last_name) && empty($email) && empty($dob) && empty($address1) && empty($town) && empty($postcode); + + if ($is_empty) { + // If empty, check if we have at least one attorney + $check = db()->prepare("SELECT count(*) FROM lpa_attorneys WHERE lpa_id = ? AND type = 'primary'"); + $check->execute([$lpa_id]); + $count = (int)$check->fetchColumn(); + + if ($count > 0) { + // Success, move to next step if requested + $next_step = ($next_action === 'next_step') ? 3 : 2; + echo json_encode(['success' => true, 'id' => (int)$lpa_id, 'next_step' => $next_step, 'message' => 'Moving to next step.']); + exit; + } else { + echo json_encode(['success' => false, 'error' => 'At least one attorney must be added.']); + exit; + } + } + if (empty($first_name) || empty($last_name) || empty($email) || empty($dob) || empty($address1) || empty($town) || empty($postcode)) { echo json_encode(['success' => false, 'error' => 'All fields are required to save an attorney.']); exit; diff --git a/apply.php b/apply.php index 096d17f..d35b741 100644 --- a/apply.php +++ b/apply.php @@ -164,7 +164,7 @@ foreach ($notified_persons as $np) {
-
+
Step of 14 @@ -191,7 +191,7 @@ foreach ($notified_persons as $np) {
-
+

Let's get started.

Please select the type of LPA and provide the donor's details and address. You can save your progress and return later.

@@ -252,7 +252,7 @@ foreach ($notified_persons as $np) {
- +
@@ -264,7 +264,7 @@ foreach ($notified_persons as $np) {
-
+
Cancel
@@ -299,25 +299,26 @@ foreach ($notified_persons as $np) {
+
- + >
- + >
- + >
- + >
- + >
@@ -326,7 +327,7 @@ foreach ($notified_persons as $np) {
- + >
@@ -338,11 +339,11 @@ foreach ($notified_persons as $np) {
- + >
- + >
@@ -353,7 +354,7 @@ foreach ($notified_persons as $np) {
-
+
Back to Step 1 Continue to Step 3 @@ -435,7 +436,7 @@ foreach ($notified_persons as $np) { -
+
Back to Step 2
@@ -524,9 +525,9 @@ foreach ($notified_persons as $np) {
-
+

Life-sustaining treatment

@@ -537,10 +538,10 @@ foreach ($notified_persons as $np) {
-
-
+
+
required> -
+
> -
+
+
+ Back to Step 4 + +
+
- -
- Back to Step 4 - -

Witness Information

Provide the details of the person who will witness the donor's signature.

- +
@@ -610,7 +614,7 @@ foreach ($notified_persons as $np) {
-
+
Back to Step 5
@@ -689,14 +693,17 @@ foreach ($notified_persons as $np) {
- - + +
- @@ -722,9 +729,9 @@ foreach ($notified_persons as $np) {
-
+
Back to Step 7 - +
@@ -766,9 +773,9 @@ foreach ($notified_persons as $np) {
-
+
Back to Step 8 - +
@@ -838,9 +845,9 @@ foreach ($notified_persons as $np) {
-
+
Back to Step 9 - +
@@ -855,7 +862,7 @@ foreach ($notified_persons as $np) {
required> -