Compare commits

...

1 Commits

Author SHA1 Message Date
Flatlogic Bot
6a72450df9 Autosave: 20260228-190006 2026-02-28 19:00:07 +00:00
8 changed files with 1003 additions and 510 deletions

64
api/chat.php Normal file
View File

@ -0,0 +1,64 @@
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../db/config.php';
require_once __DIR__ . '/../ai/LocalAIApi.php';
$input = json_decode(file_get_contents('php://input'), true);
$message = $input['message'] ?? '';
if (empty($message)) {
echo json_encode(['reply' => "I didn't catch that. Could you repeat?"]);
exit;
}
try {
// 1. Fetch Knowledge Base (FAQs)
$stmt = db()->query("SELECT keywords, answer FROM faqs");
$faqs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$knowledgeBase = "Here is the knowledge base for this website:\n\n";
foreach ($faqs as $faq) {
$knowledgeBase .= "Q: " . $faq['keywords'] . "\nA: " . $faq['answer'] . "\n---\n";
}
// 2. Construct Prompt for AI
$systemPrompt = "You are a helpful, friendly AI assistant for this website. " .
"Use the provided Knowledge Base to answer user questions accurately. " .
"If the answer is found in the Knowledge Base, rephrase it naturally. " .
"If the answer is NOT in the Knowledge Base, use your general knowledge to help, " .
"but politely mention that you don't have specific information about that if it seems like a site-specific question. " .
"Keep answers concise and professional.\n\n" .
$knowledgeBase;
// 3. Call AI API
$response = LocalAIApi::createResponse([
'model' => 'gpt-4o-mini',
'input' => [
['role' => 'system', 'content' => $systemPrompt],
['role' => 'user', 'content' => $message],
]
]);
if (!empty($response['success'])) {
$aiReply = LocalAIApi::extractText($response);
// 4. Save to Database
try {
$stmt = db()->prepare("INSERT INTO messages (user_message, ai_response) VALUES (?, ?)");
$stmt->execute([$message, $aiReply]);
} catch (Exception $e) {
error_log("DB Save Error: " . $e->getMessage());
// Continue even if save fails, so the user still gets a reply
}
echo json_encode(['reply' => $aiReply]);
} else {
// Fallback if AI fails
error_log("AI Error: " . ($response['error'] ?? 'Unknown'));
echo json_encode(['reply' => "I'm having trouble connecting to my brain right now. Please try again later."]);
}
} catch (Exception $e) {
error_log("Chat Error: " . $e->getMessage());
echo json_encode(['reply' => "An internal error occurred."]);
}

119
api/save_lpa.php Normal file
View File

@ -0,0 +1,119 @@
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Check for specific actions first
if (isset($_POST['action']) && $_POST['action'] === 'delete_attorney') {
$attorney_id = isset($_POST['attorney_id']) ? (int)$_POST['attorney_id'] : null;
$lpa_id = isset($_POST['lpa_id']) ? (int)$_POST['lpa_id'] : null;
if (!$attorney_id || !$lpa_id) {
echo json_encode(['success' => false, 'error' => 'Missing IDs for deletion.']);
exit;
}
try {
$stmt = db()->prepare("DELETE FROM lpa_attorneys WHERE id = ? AND lpa_id = ?");
$stmt->execute([$attorney_id, $lpa_id]);
echo json_encode(['success' => true, 'message' => 'Attorney removed.']);
} catch (PDOException $e) {
echo json_encode(['success' => false, 'error' => 'Database error: ' . $e->getMessage()]);
}
exit;
}
$step = isset($_POST['step']) ? (int)$_POST['step'] : 1;
$lpa_id = isset($_POST['lpa_id']) ? (int)$_POST['lpa_id'] : null;
try {
if ($step === 1) {
$lpa_type = $_POST['lpa_type'] ?? '';
$donor_name = $_POST['donor_name'] ?? '';
$other_names = $_POST['other_names'] ?? '';
$donor_dob = $_POST['donor_dob'] ?? '';
$customer_email = $_POST['customer_email'] ?? '';
$address1 = $_POST['donor_address_line1'] ?? '';
$address2 = $_POST['donor_address_line2'] ?? '';
$town = $_POST['donor_town'] ?? '';
$postcode = $_POST['donor_postcode'] ?? '';
if (empty($lpa_type) || empty($donor_name) || empty($donor_dob) || empty($customer_email) || empty($address1) || empty($town) || empty($postcode)) {
echo json_encode(['success' => false, 'error' => 'All fields are required for Step 1, including the address.']);
exit;
}
if ($lpa_id) {
// Update existing
$stmt = db()->prepare("UPDATE lpa_applications SET lpa_type = ?, donor_name = ?, other_names = ?, donor_dob = ?, customer_email = ?, donor_address_line1 = ?, donor_address_line2 = ?, donor_town = ?, donor_postcode = ?, step_reached = GREATEST(step_reached, 1) WHERE id = ?");
$stmt->execute([$lpa_type, $donor_name, $other_names, $donor_dob, $customer_email, $address1, $address2, $town, $postcode, $lpa_id]);
$id = $lpa_id;
} else {
// Create new
$stmt = db()->prepare("INSERT INTO lpa_applications (practice_id, lpa_type, donor_name, other_names, donor_dob, customer_email, donor_address_line1, donor_address_line2, donor_town, donor_postcode, step_reached) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([1, $lpa_type, $donor_name, $other_names, $donor_dob, $customer_email, $address1, $address2, $town, $postcode, 1]);
$id = db()->lastInsertId();
}
echo json_encode(['success' => true, 'id' => $id, 'next_step' => 2, 'message' => 'Step 1 saved successfully.']);
} elseif ($step === 2) {
if (!$lpa_id) {
echo json_encode(['success' => false, 'error' => 'LPA ID is required for Step 2.']);
exit;
}
$title = $_POST['title'] ?? '';
$first_name = $_POST['first_name'] ?? '';
$last_name = $_POST['last_name'] ?? '';
$email = $_POST['email'] ?? '';
$dob = $_POST['dob'] ?? '';
$address1 = $_POST['address_line1'] ?? '';
$address2 = $_POST['address_line2'] ?? '';
$address3 = $_POST['address_line3'] ?? '';
$town = $_POST['town'] ?? '';
$postcode = $_POST['postcode'] ?? '';
$next_action = $_POST['next_action'] ?? 'add_another';
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;
}
$stmt = db()->prepare("INSERT INTO lpa_attorneys (lpa_id, title, first_name, last_name, email, dob, address_line1, address_line2, address_line3, town, postcode) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$lpa_id, $title, $first_name, $last_name, $email, $dob, $address1, $address2, $address3, $town, $postcode]);
// Update step reached
$stmt = db()->prepare("UPDATE lpa_applications SET step_reached = GREATEST(step_reached, 2) WHERE id = ?");
$stmt->execute([$lpa_id]);
$next_step = ($next_action === 'next_step') ? 3 : 2;
echo json_encode(['success' => true, 'id' => $lpa_id, 'next_step' => $next_step, 'message' => 'Attorney saved successfully.']);
} elseif ($step === 3) {
if (!$lpa_id) {
echo json_encode(['success' => false, 'error' => 'LPA ID is required for Step 3.']);
exit;
}
$attorney_decision_type = $_POST['attorney_decision_type'] ?? '';
if (empty($attorney_decision_type)) {
echo json_encode(['success' => false, 'error' => 'Please select how your attorneys should make decisions.']);
exit;
}
$stmt = db()->prepare("UPDATE lpa_applications SET attorney_decision_type = ?, step_reached = GREATEST(step_reached, 3) WHERE id = ?");
$stmt->execute([$attorney_decision_type, $lpa_id]);
echo json_encode(['success' => true, 'id' => $lpa_id, 'next_step' => 4, 'message' => 'Decision-making preference saved.']);
} else {
echo json_encode(['success' => false, 'error' => 'Invalid step provided.']);
}
} catch (PDOException $e) {
error_log($e->getMessage());
echo json_encode(['success' => false, 'error' => 'Database error: ' . $e->getMessage()]);
}
} else {
echo json_encode(['success' => false, 'error' => 'Invalid request method.']);
}

91
api/telegram_webhook.php Normal file
View File

@ -0,0 +1,91 @@
<?php
require_once __DIR__ . '/../db/config.php';
require_once __DIR__ . '/../ai/LocalAIApi.php';
// Get Telegram Update
$content = file_get_contents("php://input");
$update = json_decode($content, true);
if (!$update || !isset($update['message'])) {
exit;
}
$message = $update['message'];
$chatId = $message['chat']['id'];
$text = $message['text'] ?? '';
if (empty($text)) {
exit;
}
// Get Telegram Token from DB
$stmt = db()->query("SELECT setting_value FROM settings WHERE setting_key = 'telegram_token'");
$token = $stmt->fetchColumn();
if (!$token) {
error_log("Telegram Error: No bot token found in settings.");
exit;
}
function sendTelegramMessage($chatId, $text, $token) {
$url = "https://api.telegram.org/bot$token/sendMessage";
$data = [
'chat_id' => $chatId,
'text' => $text,
'parse_mode' => 'Markdown'
];
$options = [
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
],
];
$context = stream_context_create($options);
return file_get_contents($url, false, $context);
}
// Process with AI (Similar logic to api/chat.php)
try {
// 1. Fetch Knowledge Base
$stmt = db()->query("SELECT keywords, answer FROM faqs");
$faqs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$knowledgeBase = "Here is the knowledge base for this website:\n\n";
foreach ($faqs as $faq) {
$knowledgeBase .= "Q: " . $faq['keywords'] . "\nA: " . $faq['answer'] . "\n---\n";
}
$systemPrompt = "You are a helpful AI assistant integrated with Telegram. " .
"Use the provided Knowledge Base to answer user questions. " .
"Keep answers concise for mobile reading. Use Markdown for formatting.\n\n" .
$knowledgeBase;
// 2. Call AI
$response = LocalAIApi::createResponse([
'model' => 'gpt-4o-mini',
'input' => [
['role' => 'system', 'content' => $systemPrompt],
['role' => 'user', 'content' => $text],
]
]);
if (!empty($response['success'])) {
$aiReply = LocalAIApi::extractText($response);
// 3. Save History
try {
$stmt = db()->prepare("INSERT INTO messages (user_message, ai_response) VALUES (?, ?)");
$stmt->execute(["[Telegram] " . $text, $aiReply]);
} catch (Exception $e) {}
// 4. Send back to Telegram
sendTelegramMessage($chatId, $aiReply, $token);
} else {
sendTelegramMessage($chatId, "I'm sorry, I encountered an error processing your request.", $token);
}
} catch (Exception $e) {
error_log("Telegram Webhook Error: " . $e->getMessage());
}

336
apply.php Normal file
View File

@ -0,0 +1,336 @@
<?php
require_once 'db/config.php';
$project_name = $_SERVER['PROJECT_NAME'] ?? 'LPA Builder';
$step = isset($_GET['step']) ? (int)$_GET['step'] : 1;
$lpa_id = isset($_GET['id']) ? (int)$_GET['id'] : null;
$lpa_data = null;
if ($lpa_id) {
$stmt = db()->prepare("SELECT * FROM lpa_applications WHERE id = ?");
$stmt->execute([$lpa_id]);
$lpa_data = $stmt->fetch();
}
// Redirect to step 1 if no ID but step > 1
if ($step > 1 && !$lpa_id) {
header("Location: apply.php?step=1");
exit;
}
$attorneys = [];
if ($lpa_id && ($step === 2 || $step === 3)) {
$stmt = db()->prepare("SELECT * FROM lpa_attorneys WHERE lpa_id = ?");
$stmt->execute([$lpa_id]);
$attorneys = $stmt->fetchAll();
}
$num_attorneys = count($attorneys);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Start Application <?php echo htmlspecialchars($project_name); ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/custom.css" rel="stylesheet">
</head>
<body class="bg-light">
<nav class="navbar navbar-expand-lg bg-white border-bottom shadow-sm">
<div class="container">
<a class="navbar-brand d-flex align-items-center" href="/">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2 text-primary"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
<span class="fw-bold"><?php echo htmlspecialchars($project_name); ?></span>
</a>
<a href="/dashboard.php" class="btn btn-sm btn-outline-secondary">Back to Dashboard</a>
</div>
</nav>
<div class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="mb-5">
<div class="d-flex justify-content-between align-items-center mb-2">
<span class="small fw-semibold text-muted text-uppercase tracking-wider">Step <?php echo $step; ?> of 4</span>
<span class="small fw-semibold text-primary">
<?php
switch($step) {
case 1: echo "Donor Information & Address"; break;
case 2: echo "Attorneys"; break;
case 3: echo "How decisions are made"; break;
case 4: echo "Review & Submit"; break;
}
?>
</span>
</div>
<div class="progress" style="height: 6px;">
<div class="progress-bar" role="progressbar" style="width: <?php echo ($step * 25); ?>%" aria-valuenow="<?php echo ($step * 25); ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<div class="card p-4 p-md-5">
<?php if ($step === 1): ?>
<h2 class="h4 fw-bold mb-4">Let's get started.</h2>
<p class="text-muted mb-5">Please select the type of LPA and provide the donor's details and address. You can save your progress and return later.</p>
<form id="lpaFormStep1" class="lpa-form" method="POST" action="api/save_lpa.php">
<input type="hidden" name="step" value="1">
<?php if ($lpa_id): ?><input type="hidden" name="lpa_id" value="<?php echo $lpa_id; ?>"><?php endif; ?>
<div class="mb-4">
<label class="form-label fw-semibold">Type of LPA</label>
<div class="row g-3">
<div class="col-md-6">
<input type="radio" class="btn-check" name="lpa_type" id="type_hw" value="Health & Welfare" <?php echo ($lpa_data && $lpa_data['lpa_type'] === 'Health & Welfare') ? 'checked' : 'checked'; ?>>
<label class="btn btn-outline-secondary w-100 p-3 text-start h-100" for="type_hw">
<div class="fw-bold text-dark mb-1">Health & Welfare</div>
<div class="small text-muted">Decisions about medical care, moving into care, and daily routine.</div>
</label>
</div>
<div class="col-md-6">
<input type="radio" class="btn-check" name="lpa_type" id="type_pf" value="Property & Financial" <?php echo ($lpa_data && $lpa_data['lpa_type'] === 'Property & Financial') ? 'checked' : ''; ?>>
<label class="btn btn-outline-secondary w-100 p-3 text-start h-100" for="type_pf">
<div class="fw-bold text-dark mb-1">Property & Financial</div>
<div class="small text-muted">Managing bank accounts, paying bills, and selling property.</div>
</label>
</div>
</div>
</div>
<hr class="my-5 text-muted opacity-25">
<div class="row g-4">
<div class="col-12">
<h3 class="h6 fw-bold text-uppercase tracking-wider text-muted mb-3">Basic Information</h3>
</div>
<div class="col-12">
<label for="donor_name" class="form-label fw-semibold">Donor Full Name</label>
<input type="text" class="form-control" id="donor_name" name="donor_name" placeholder="As shown on official ID" value="<?php echo htmlspecialchars($lpa_data['donor_name'] ?? ''); ?>" required>
</div>
<div class="col-12">
<label for="other_names" class="form-label fw-semibold">Other names (Optional)</label>
<input type="text" class="form-control" id="other_names" name="other_names" placeholder="Any other names you are or have been known by" value="<?php echo htmlspecialchars($lpa_data['other_names'] ?? ''); ?>">
</div>
<div class="col-md-6">
<label for="donor_dob" class="form-label fw-semibold">Date of Birth</label>
<input type="date" class="form-control" id="donor_dob" name="donor_dob" value="<?php echo $lpa_data['donor_dob'] ?? ''; ?>" required>
</div>
<div class="col-md-6">
<label for="customer_email" class="form-label fw-semibold">Your Email Address</label>
<input type="email" class="form-control" id="customer_email" name="customer_email" placeholder="To track your progress" value="<?php echo htmlspecialchars($lpa_data['customer_email'] ?? ''); ?>" required>
</div>
<div class="col-12 mt-5">
<h3 class="h6 fw-bold text-uppercase tracking-wider text-muted mb-3">Donor Address</h3>
</div>
<div class="col-12">
<label for="donor_address_line1" class="form-label fw-semibold">Address Line 1</label>
<input type="text" class="form-control" id="donor_address_line1" name="donor_address_line1" placeholder="House number and street" value="<?php echo htmlspecialchars($lpa_data['donor_address_line1'] ?? ''); ?>" required>
</div>
<div class="col-12">
<label for="donor_address_line2" class="form-label fw-semibold">Address Line 2 (Optional)</label>
<input type="text" class="form-control" id="donor_address_line2" name="donor_address_line2" placeholder="Apartment, suite, unit, etc." value="<?php echo htmlspecialchars($lpa_data['donor_address_line2'] ?? ''); ?>">
</div>
<div class="col-md-8">
<label for="donor_town" class="form-label fw-semibold">Town / City</label>
<input type="text" class="form-control" id="donor_town" name="donor_town" value="<?php echo htmlspecialchars($lpa_data['donor_town'] ?? ''); ?>" required>
</div>
<div class="col-md-4">
<label for="donor_postcode" class="form-label fw-semibold">Postcode</label>
<input type="text" class="form-control" id="donor_postcode" name="donor_postcode" value="<?php echo htmlspecialchars($lpa_data['donor_postcode'] ?? ''); ?>" required>
</div>
</div>
<div class="mt-5 d-flex justify-content-between align-items-center">
<a href="/dashboard.php" class="btn btn-link text-decoration-none text-muted p-0">Cancel</a>
<button type="submit" class="btn btn-primary btn-lg px-5">Continue to Step 2</button>
</div>
</form>
<?php elseif ($step === 2): ?>
<h2 class="h4 fw-bold mb-4">Attorneys</h2>
<p class="text-muted mb-5">Add the people who will make decisions for you. You can add multiple attorneys. They must be over 18 and have mental capacity.</p>
<?php if (!empty($attorneys)): ?>
<div class="mb-5">
<h3 class="h6 fw-bold text-uppercase tracking-wider text-muted mb-3">Currently Added Attorneys</h3>
<div class="list-group shadow-sm">
<?php foreach ($attorneys as $attorney): ?>
<div class="list-group-item p-3 d-flex justify-content-between align-items-center">
<div>
<div class="fw-bold"><?php echo htmlspecialchars(($attorney['title'] ? $attorney['title'] . ' ' : '') . $attorney['first_name'] . ' ' . $attorney['last_name']); ?></div>
<div class="small text-muted"><?php echo htmlspecialchars($attorney['email']); ?> &bull; <?php echo htmlspecialchars($attorney['postcode']); ?></div>
</div>
<button type="button" class="btn btn-sm btn-outline-danger btn-delete-attorney" data-id="<?php echo $attorney['id']; ?>" data-lpa-id="<?php echo $lpa_id; ?>">Remove</button>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<div class="card bg-light border-0 p-4 mb-4">
<h3 class="h6 fw-bold mb-4">Add an Attorney</h3>
<form id="lpaFormStep2" class="lpa-form" method="POST" action="api/save_lpa.php">
<input type="hidden" name="step" value="2">
<input type="hidden" name="lpa_id" value="<?php echo $lpa_id; ?>">
<div class="row g-3">
<div class="col-md-2">
<label for="title" class="form-label fw-semibold">Title</label>
<input type="text" class="form-control" id="title" name="title" placeholder="Mr/Ms" required>
</div>
<div class="col-md-5">
<label for="first_name" class="form-label fw-semibold">First Name</label>
<input type="text" class="form-control" id="first_name" name="first_name" required>
</div>
<div class="col-md-5">
<label for="last_name" class="form-label fw-semibold">Last Name</label>
<input type="text" class="form-control" id="last_name" name="last_name" required>
</div>
<div class="col-md-6">
<label for="email" class="form-label fw-semibold">Email Address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="col-md-6">
<label for="dob" class="form-label fw-semibold">Date of Birth</label>
<input type="date" class="form-control" id="dob" name="dob" required>
</div>
<div class="col-12 mt-4">
<label class="form-label fw-bold small text-uppercase">Attorney Address</label>
</div>
<div class="col-12">
<label for="address_line1" class="form-label fw-semibold">Address Line 1</label>
<input type="text" class="form-control" id="address_line1" name="address_line1" required>
</div>
<div class="col-12">
<label for="address_line2" class="form-label fw-semibold">Address Line 2 (Optional)</label>
<input type="text" class="form-control" id="address_line2" name="address_line2">
</div>
<div class="col-12">
<label for="address_line3" class="form-label fw-semibold">Address Line 3 (Optional)</label>
<input type="text" class="form-control" id="address_line3" name="address_line3">
</div>
<div class="col-md-8">
<label for="town" class="form-label fw-semibold">Town / City</label>
<input type="text" class="form-control" id="town" name="town" required>
</div>
<div class="col-md-4">
<label for="postcode" class="form-label fw-semibold">Postcode</label>
<input type="text" class="form-control" id="postcode" name="postcode" required>
</div>
</div>
<div class="mt-4 d-flex gap-3">
<button type="submit" name="next_action" value="add_another" class="btn btn-outline-primary w-100">Add Another Attorney</button>
<button type="submit" name="next_action" value="next_step" class="btn btn-primary w-100">Save & Continue to Step 3</button>
</div>
</form>
</div>
<div class="mt-5 d-flex justify-content-between align-items-center">
<a href="apply.php?step=1&id=<?php echo $lpa_id; ?>" class="btn btn-link text-decoration-none text-muted p-0">Back to Step 1</a>
<?php if (!empty($attorneys)): ?>
<a href="apply.php?step=3&id=<?php echo $lpa_id; ?>" class="btn btn-primary btn-lg px-5">Continue to Step 3</a>
<?php endif; ?>
</div>
<?php elseif ($step === 3): ?>
<h2 class="h4 fw-bold mb-4">How should your attorneys make decisions?</h2>
<p class="text-muted mb-5">Specify how you want your attorneys to work together when making decisions on your behalf.</p>
<form id="lpaFormStep3" class="lpa-form" method="POST" action="api/save_lpa.php">
<input type="hidden" name="step" value="3">
<input type="hidden" name="lpa_id" value="<?php echo $lpa_id; ?>">
<div class="row g-3">
<div class="col-12">
<div class="form-check p-0 mb-3">
<input type="radio" class="btn-check" name="attorney_decision_type" id="dec_one" value="I only appointed one attorney"
<?php echo ($num_attorneys === 1) ? 'checked' : ''; ?>
<?php echo ($num_attorneys > 1) ? 'disabled' : ''; ?> required>
<label class="btn btn-outline-secondary w-100 p-3 text-start h-100 d-flex align-items-center <?php echo ($num_attorneys > 1) ? 'opacity-50' : ''; ?>" for="dec_one">
<div class="flex-grow-1">
<div class="fw-bold text-dark mb-1">I only appointed one attorney</div>
<div class="small text-muted">Select this if you only have one person acting as your attorney.</div>
</div>
<div class="ms-3">
<div class="form-check-input-placeholder"></div>
</div>
</label>
</div>
<div class="form-check p-0 mb-3">
<input type="radio" class="btn-check" name="attorney_decision_type" id="dec_js" value="Jointly and severally"
<?php echo ($lpa_data && $lpa_data['attorney_decision_type'] === 'Jointly and severally') ? 'checked' : ''; ?>
<?php echo ($num_attorneys === 1) ? 'disabled' : ''; ?>>
<label class="btn btn-outline-secondary w-100 p-3 text-start h-100 d-flex align-items-center <?php echo ($num_attorneys === 1) ? 'opacity-50' : ''; ?>" for="dec_js">
<div class="flex-grow-1">
<div class="fw-bold text-dark mb-1">Jointly and severally</div>
<div class="small text-muted">Attorneys can make decisions together or on their own.</div>
</div>
<div class="ms-3">
<div class="form-check-input-placeholder"></div>
</div>
</label>
</div>
<div class="form-check p-0 mb-3">
<input type="radio" class="btn-check" name="attorney_decision_type" id="dec_j" value="Jointly"
<?php echo ($lpa_data && $lpa_data['attorney_decision_type'] === 'Jointly') ? 'checked' : ''; ?>
<?php echo ($num_attorneys === 1) ? 'disabled' : ''; ?>>
<label class="btn btn-outline-secondary w-100 p-3 text-start h-100 d-flex align-items-center <?php echo ($num_attorneys === 1) ? 'opacity-50' : ''; ?>" for="dec_j">
<div class="flex-grow-1">
<div class="fw-bold text-dark mb-1">Jointly</div>
<div class="small text-muted">Attorneys must agree on all decisions together.</div>
</div>
<div class="ms-3">
<div class="form-check-input-placeholder"></div>
</div>
</label>
</div>
<div class="form-check p-0 mb-3">
<input type="radio" class="btn-check" name="attorney_decision_type" id="dec_some" value="Jointly for some decisions, jointly and severally for other decisions"
<?php echo ($lpa_data && $lpa_data['attorney_decision_type'] === 'Jointly for some decisions, jointly and severally for other decisions') ? 'checked' : ''; ?>
<?php echo ($num_attorneys === 1) ? 'disabled' : ''; ?>>
<label class="btn btn-outline-secondary w-100 p-3 text-start h-100 d-flex align-items-center <?php echo ($num_attorneys === 1) ? 'opacity-50' : ''; ?>" for="dec_some">
<div class="flex-grow-1">
<div class="fw-bold text-dark mb-1">Jointly for some decisions, jointly and severally for other decisions</div>
<div class="small text-muted">You can specify which decisions must be made together.</div>
</div>
<div class="ms-3">
<div class="form-check-input-placeholder"></div>
</div>
</label>
</div>
</div>
</div>
<?php if ($num_attorneys === 1): ?>
<input type="hidden" name="attorney_decision_type" value="I only appointed one attorney">
<?php endif; ?>
<div class="mt-5 d-flex justify-content-between align-items-center">
<a href="apply.php?step=2&id=<?php echo $lpa_id; ?>" class="btn btn-link text-decoration-none text-muted p-0">Back to Step 2</a>
<button type="submit" class="btn btn-primary btn-lg px-5">Continue to Step 4</button>
</div>
</form>
<?php elseif ($step === 4): ?>
<h2 class="h4 fw-bold mb-4">Review & Submit</h2>
<p class="text-muted mb-5">Review all the information you have provided before submitting your application. (Step 4 implementation in progress)</p>
<div class="mt-5 d-flex justify-content-between align-items-center">
<a href="apply.php?step=3&id=<?php echo $lpa_id; ?>" class="btn btn-link text-decoration-none text-muted p-0">Back to Step 3</a>
<a href="/dashboard.php" class="btn btn-primary btn-lg px-5">Go to Dashboard</a>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>

View File

@ -1,346 +1,114 @@
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
:root {
--color-bg: #ffffff;
--color-text: #1a1a1a;
--color-primary: #2563EB; /* Vibrant Blue */
--color-secondary: #000000;
--color-accent: #A3E635; /* Lime Green */
--color-surface: #f8f9fa;
--font-heading: 'Space Grotesk', sans-serif;
--font-body: 'Inter', sans-serif;
--border-width: 2px;
--shadow-hard: 5px 5px 0px #000;
--shadow-hover: 8px 8px 0px #000;
--radius-pill: 50rem;
--radius-card: 1rem;
--primary: #0F172A;
--secondary: #334155;
--accent: #2563EB;
--background: #F8FAFC;
--surface: #FFFFFF;
--border: #E2E8F0;
--text-main: #1E293B;
--text-muted: #64748B;
--radius: 4px;
}
body {
font-family: var(--font-body);
background-color: var(--color-bg);
color: var(--color-text);
overflow-x: hidden;
font-family: 'Inter', system-ui, -apple-system, sans-serif;
background-color: var(--background);
color: var(--text-main);
line-height: 1.5;
font-size: 0.9375rem;
}
h1, h2, h3, h4, h5, h6, .navbar-brand {
font-family: var(--font-heading);
letter-spacing: -0.03em;
h1, h2, h3, h4, h5, h6 {
color: var(--primary);
font-weight: 600;
letter-spacing: -0.025em;
}
/* Utilities */
.text-primary { color: var(--color-primary) !important; }
.bg-black { background-color: #000 !important; }
.text-white { color: #fff !important; }
.shadow-hard { box-shadow: var(--shadow-hard); }
.border-2-black { border: var(--border-width) solid #000; }
.py-section { padding-top: 5rem; padding-bottom: 5rem; }
/* Navbar */
.navbar {
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
border-bottom: var(--border-width) solid transparent;
transition: all 0.3s;
padding-top: 1rem;
padding-bottom: 1rem;
background-color: var(--surface);
border-bottom: 1px solid var(--border);
padding: 1rem 0;
}
.navbar.scrolled {
border-bottom-color: #000;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.brand-text {
font-size: 1.5rem;
font-weight: 800;
}
.nav-link {
font-weight: 500;
color: var(--color-text);
margin-left: 1rem;
position: relative;
}
.nav-link:hover, .nav-link.active {
color: var(--color-primary);
}
/* Buttons */
.btn {
font-weight: 700;
font-family: var(--font-heading);
padding: 0.8rem 2rem;
border-radius: var(--radius-pill);
border: var(--border-width) solid #000;
transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
box-shadow: var(--shadow-hard);
}
.btn:hover {
transform: translate(-2px, -2px);
box-shadow: var(--shadow-hover);
}
.btn:active {
transform: translate(2px, 2px);
box-shadow: 0 0 0 #000;
border-radius: var(--radius);
font-weight: 500;
padding: 0.5rem 1rem;
transition: all 0.2s;
}
.btn-primary {
background-color: var(--color-primary);
border-color: #000;
color: #fff;
background-color: var(--primary);
border-color: var(--primary);
}
.btn-primary:hover {
background-color: #1d4ed8;
border-color: #000;
color: #fff;
background-color: #1E293B;
border-color: #1E293B;
}
.btn-outline-dark {
background-color: #fff;
color: #000;
.card {
background-color: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.btn-cta {
background-color: var(--color-accent);
color: #000;
.form-control, .form-select {
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 0.625rem;
}
.btn-cta:hover {
background-color: #8cc629;
color: #000;
.form-control:focus, .form-select:focus {
border-color: var(--accent);
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
/* Hero Section */
.hero-section {
min-height: 100vh;
padding-top: 80px;
.progress {
height: 0.5rem;
border-radius: 9999px;
background-color: var(--border);
}
.background-blob {
position: absolute;
border-radius: 50%;
filter: blur(80px);
opacity: 0.6;
z-index: 1;
.progress-bar {
background-color: var(--accent);
}
.blob-1 {
top: -10%;
right: -10%;
width: 600px;
height: 600px;
background: radial-gradient(circle, var(--color-accent), transparent);
}
.blob-2 {
bottom: 10%;
left: -10%;
width: 500px;
height: 500px;
background: radial-gradient(circle, var(--color-primary), transparent);
}
.highlight-text {
background: linear-gradient(120deg, transparent 0%, transparent 40%, var(--color-accent) 40%, var(--color-accent) 100%);
background-repeat: no-repeat;
background-size: 100% 40%;
background-position: 0 88%;
padding: 0 5px;
}
.dot { color: var(--color-primary); }
.badge-pill {
display: inline-block;
padding: 0.5rem 1rem;
border: 2px solid #000;
border-radius: 50px;
font-weight: 700;
background: #fff;
box-shadow: 4px 4px 0 #000;
font-family: var(--font-heading);
font-size: 0.9rem;
}
/* Marquee */
.marquee-container {
overflow: hidden;
white-space: nowrap;
border-top: 2px solid #000;
border-bottom: 2px solid #000;
}
.rotate-divider {
transform: rotate(-2deg) scale(1.05);
z-index: 10;
position: relative;
margin-top: -50px;
margin-bottom: 30px;
}
.marquee-content {
display: inline-block;
animation: marquee 20s linear infinite;
font-family: var(--font-heading);
font-weight: 700;
font-size: 1.5rem;
letter-spacing: 2px;
}
@keyframes marquee {
0% { transform: translateX(0); }
100% { transform: translateX(-50%); }
}
/* Portfolio Cards */
.project-card {
border: 2px solid #000;
border-radius: var(--radius-card);
overflow: hidden;
background: #fff;
transition: transform 0.3s ease;
box-shadow: var(--shadow-hard);
height: 100%;
display: flex;
flex-direction: column;
}
.project-card:hover {
transform: translateY(-10px);
box-shadow: 8px 8px 0 #000;
}
.card-img-holder {
height: 250px;
display: flex;
align-items: center;
justify-content: center;
border-bottom: 2px solid #000;
position: relative;
font-size: 4rem;
}
.placeholder-art {
transition: transform 0.3s ease;
}
.project-card:hover .placeholder-art {
transform: scale(1.2) rotate(10deg);
}
.bg-soft-blue { background-color: #e0f2fe; }
.bg-soft-green { background-color: #dcfce7; }
.bg-soft-purple { background-color: #f3e8ff; }
.bg-soft-yellow { background-color: #fef9c3; }
.category-tag {
position: absolute;
top: 15px;
right: 15px;
background: #000;
color: #fff;
padding: 5px 12px;
border-radius: 20px;
font-size: 0.75rem;
font-weight: 700;
}
.card-body { padding: 1.5rem; }
.link-arrow {
text-decoration: none;
color: #000;
font-weight: 700;
.status-badge {
display: inline-flex;
align-items: center;
margin-top: auto;
padding: 0.25rem 0.5rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 600;
}
.link-arrow i { transition: transform 0.2s; margin-left: 5px; }
.link-arrow:hover i { transform: translateX(5px); }
.status-draft { background-color: #FEF3C7; color: #92400E; }
.status-completed { background-color: #DCFCE7; color: #166534; }
/* About */
.about-image-stack {
position: relative;
height: 400px;
width: 100%;
.section-padding { padding: 4rem 0; }
/* Custom Step 3 Decision Styling */
.btn-check:checked + .btn-outline-secondary {
border-color: var(--accent);
background-color: rgba(37, 99, 235, 0.05);
color: var(--text-main);
}
.stack-card {
position: absolute;
width: 80%;
height: 100%;
border-radius: var(--radius-card);
border: 2px solid #000;
box-shadow: var(--shadow-hard);
left: 10%;
transform: rotate(-3deg);
background-size: cover;
}
/* Forms */
.form-control {
border: 2px solid #000;
border-radius: 0.5rem;
padding: 1rem;
font-weight: 500;
background: #f8f9fa;
}
.form-control:focus {
box-shadow: 4px 4px 0 var(--color-primary);
border-color: #000;
background: #fff;
}
/* Animations */
.animate-up {
opacity: 0;
transform: translateY(30px);
animation: fadeUp 0.8s ease forwards;
}
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
@keyframes fadeUp {
to {
opacity: 1;
transform: translateY(0);
}
}
/* Social */
.social-links a {
transition: transform 0.2s;
.form-check-input-placeholder {
width: 20px;
height: 20px;
border: 2px solid var(--border);
border-radius: 50%;
display: inline-block;
}
.social-links a:hover {
transform: scale(1.2) rotate(10deg);
color: var(--color-accent) !important;
transition: all 0.2s;
}
/* Responsive */
@media (max-width: 991px) {
.rotate-divider {
transform: rotate(0);
margin-top: 0;
margin-bottom: 2rem;
}
.hero-section {
padding-top: 120px;
text-align: center;
min-height: auto;
padding-bottom: 100px;
}
.display-1 { font-size: 3.5rem; }
.blob-1 { width: 300px; height: 300px; right: -20%; }
.blob-2 { width: 300px; height: 300px; left: -20%; }
.btn-check:checked + .btn-outline-secondary .form-check-input-placeholder {
border-color: var(--accent);
background-color: var(--accent);
box-shadow: inset 0 0 0 3px white;
}

View File

@ -1,73 +1,86 @@
document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('DOMContentLoaded', function() {
// Select all forms with the class lpa-form
const lpaForms = document.querySelectorAll('.lpa-form');
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
lpaForms.forEach(form => {
form.addEventListener('submit', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const submitBtn = document.activeElement && document.activeElement.type === 'submit' ? document.activeElement : form.querySelector('button[type="submit"]');
const originalBtnText = submitBtn.innerText;
const targetElement = document.querySelector(targetId);
if (targetElement) {
// Close mobile menu if open
const navbarToggler = document.querySelector('.navbar-toggler');
const navbarCollapse = document.querySelector('.navbar-collapse');
if (navbarCollapse.classList.contains('show')) {
navbarToggler.click();
// Show loading state
submitBtn.disabled = true;
const originalHTML = submitBtn.innerHTML;
submitBtn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span> Saving...';
const formData = new FormData(form);
// If the button clicked was one of the Step 2 buttons, ensure next_action is set
if (form.id === 'lpaFormStep2' && document.activeElement && document.activeElement.name === 'next_action') {
formData.set('next_action', document.activeElement.value);
}
fetch('api/save_lpa.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Show success state
submitBtn.classList.remove('btn-primary', 'btn-secondary', 'btn-outline-primary');
submitBtn.classList.add('btn-success');
submitBtn.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2"><polyline points="20 6 9 17 4 12"></polyline></svg> Saved!';
setTimeout(() => {
// Go to next step or reload to add another
window.location.href = 'apply.php?step=' + data.next_step + '&id=' + data.id;
if (data.next_step === parseInt(new URLSearchParams(window.location.search).get('step'))) {
window.location.reload();
}
}, 800);
} else {
alert(data.error || 'An error occurred. Please try again.');
submitBtn.disabled = false;
submitBtn.innerHTML = originalHTML;
submitBtn.classList.remove('btn-success');
}
})
.catch(error => {
console.error('Error:', error);
alert('Something went wrong. Please check your connection.');
submitBtn.disabled = false;
submitBtn.innerHTML = originalHTML;
});
});
});
// Scroll with offset
const offset = 80;
const elementPosition = targetElement.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - offset;
// Handle attorney deletion
const deleteBtns = document.querySelectorAll('.btn-delete-attorney');
deleteBtns.forEach(btn => {
btn.addEventListener('click', function() {
if (confirm('Are you sure you want to remove this attorney?')) {
const attorneyId = btn.getAttribute('data-id');
const lpaId = btn.getAttribute('data-lpa-id') || new URLSearchParams(window.location.search).get('id');
window.scrollTo({
top: offsetPosition,
behavior: "smooth"
const formData = new FormData();
formData.append('action', 'delete_attorney');
formData.append('attorney_id', attorneyId);
formData.append('lpa_id', lpaId);
fetch('api/save_lpa.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
window.location.reload();
} else {
alert(data.error || 'Failed to remove attorney.');
}
});
}
});
});
// Navbar scroll effect
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('scrolled', 'shadow-sm', 'bg-white');
navbar.classList.remove('bg-transparent');
} else {
navbar.classList.remove('scrolled', 'shadow-sm', 'bg-white');
navbar.classList.add('bg-transparent');
}
});
// Intersection Observer for fade-up animations
const observerOptions = {
threshold: 0.1,
rootMargin: "0px 0px -50px 0px"
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-up');
entry.target.style.opacity = "1";
observer.unobserve(entry.target); // Only animate once
}
});
}, observerOptions);
// Select elements to animate (add a class 'reveal' to them in HTML if not already handled by CSS animation)
// For now, let's just make sure the hero animations run.
// If we want scroll animations, we'd add opacity: 0 to elements in CSS and reveal them here.
// Given the request, the CSS animation I added runs on load for Hero.
// Let's make the project cards animate in.
const projectCards = document.querySelectorAll('.project-card');
projectCards.forEach((card, index) => {
card.style.opacity = "0";
card.style.animationDelay = `${index * 0.1}s`;
observer.observe(card);
});
});

139
dashboard.php Normal file
View File

@ -0,0 +1,139 @@
<?php
require_once 'db/config.php';
$project_name = $_SERVER['PROJECT_NAME'] ?? 'LPA Builder';
$lpas = [];
try {
$stmt = db()->prepare("SELECT * FROM lpa_applications ORDER BY created_at DESC");
$stmt->execute();
$lpas = $stmt->fetchAll();
} catch (PDOException $e) {
error_log($e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Customer Dashboard <?php echo htmlspecialchars($project_name); ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/custom.css" rel="stylesheet">
</head>
<body class="bg-light">
<nav class="navbar navbar-expand-lg bg-white border-bottom shadow-sm">
<div class="container">
<a class="navbar-brand d-flex align-items-center" href="/">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2 text-primary"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
<span class="fw-bold"><?php echo htmlspecialchars($project_name); ?></span>
</a>
<div class="d-flex align-items-center">
<span class="me-3 d-none d-md-inline text-muted small">Practice: Elite Estate Planning</span>
<a href="/apply.php" class="btn btn-primary btn-sm px-3">Start New LPA</a>
</div>
</div>
</nav>
<div class="container py-5">
<div class="row align-items-center mb-5">
<div class="col">
<h1 class="h3 fw-bold mb-1">Your Applications</h1>
<p class="text-muted small mb-0">Track and manage your Lasting Powers of Attorney progress.</p>
</div>
<div class="col-auto">
<?php if (count($lpas) > 0): ?>
<a href="/apply.php" class="btn btn-outline-primary px-4">New Application</a>
<?php endif; ?>
</div>
</div>
<?php if (isset($_GET['completed_step'])): ?>
<div class="alert alert-success alert-dismissible fade show border-0 shadow-sm mb-4" role="alert">
<div class="d-flex align-items-center">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2"><polyline points="20 6 9 17 4 12"></polyline></svg>
<span>Step <?php echo (int)$_GET['completed_step']; ?> saved successfully! You can continue where you left off.</span>
</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php elseif (isset($_GET['new_lpa'])): ?>
<div class="alert alert-success alert-dismissible fade show border-0 shadow-sm mb-4" role="alert">
<div class="d-flex align-items-center">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2"><polyline points="20 6 9 17 4 12"></polyline></svg>
<span>LPA application started successfully! Our practice has been notified of your progress.</span>
</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php endif; ?>
<div class="card border-0 shadow-sm overflow-hidden">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="bg-light">
<tr class="small text-uppercase tracking-wider">
<th class="ps-4 py-3 border-bottom-0">Type</th>
<th class="py-3 border-bottom-0">Donor</th>
<th class="py-3 border-bottom-0">Progress</th>
<th class="py-3 border-bottom-0">Status</th>
<th class="py-3 border-bottom-0 text-end pe-4">Actions</th>
</tr>
</thead>
<tbody>
<?php if (count($lpas) > 0): ?>
<?php foreach ($lpas as $lpa): ?>
<tr>
<td class="ps-4 py-4">
<div class="d-flex align-items-center">
<div class="me-3 text-primary bg-primary-subtle p-2 rounded">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
</div>
<div>
<div class="fw-bold text-dark mb-0"><?php echo htmlspecialchars($lpa['lpa_type']); ?></div>
<div class="text-muted small">Started <?php echo date('M d, Y', strtotime($lpa['created_at'])); ?></div>
</div>
</div>
</td>
<td>
<div class="fw-medium text-dark"><?php echo htmlspecialchars($lpa['donor_name']); ?></div>
<div class="text-muted small"><?php echo htmlspecialchars($lpa['customer_email']); ?></div>
</td>
<td style="width: 200px;">
<div class="d-flex align-items-center">
<div class="progress flex-grow-1 me-2" style="height: 6px;">
<?php $percent = round(($lpa['step_reached'] / 4) * 100); ?>
<div class="progress-bar bg-primary" role="progressbar" style="width: <?php echo $percent; ?>%" aria-valuenow="<?php echo $percent; ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<span class="small text-muted"><?php echo $percent; ?>%</span>
</div>
</td>
<td>
<span class="status-badge status-draft"><?php echo ucfirst($lpa['status']); ?></span>
</td>
<td class="text-end pe-4">
<?php
$next_step = ($lpa['step_reached'] < 4) ? $lpa['step_reached'] + 1 : 4;
?>
<a href="/apply.php?step=<?php echo $next_step; ?>&id=<?php echo $lpa['id']; ?>" class="btn btn-sm btn-outline-secondary px-3">Continue</a>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" class="py-5 text-center">
<div class="mb-3">
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="text-muted"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>
</div>
<h5 class="fw-bold text-dark">No applications yet</h5>
<p class="text-muted small mb-4">Start your first LPA application to secure your future.</p>
<a href="/apply.php" class="btn btn-primary px-4">Start Application</a>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

249
index.php
View File

@ -1,150 +1,113 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
$project_name = $_SERVER['PROJECT_NAME'] ?? 'LPA Builder';
$project_desc = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Create your UK Lasting Power of Attorney in minutes.';
$project_img = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($project_name); ?> — Modern Estate Planning</title>
<meta name="description" content="<?php echo htmlspecialchars($project_desc); ?>">
<!-- Open Graph / Twitter -->
<meta property="og:type" content="website">
<meta property="og:title" content="<?php echo htmlspecialchars($project_name); ?>">
<meta property="og:description" content="<?php echo htmlspecialchars($project_desc); ?>">
<meta property="og:image" content="<?php echo htmlspecialchars($project_img); ?>">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="<?php echo htmlspecialchars($project_img); ?>">
<!-- Bootstrap 5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/custom.css" rel="stylesheet">
</head>
<body>
<main>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
</div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
<nav class="navbar navbar-expand-lg">
<div class="container">
<a class="navbar-brand d-flex align-items-center" href="/">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
<span class="fw-bold"><?php echo htmlspecialchars($project_name); ?></span>
</a>
<div class="d-flex align-items-center">
<a href="/dashboard.php" class="btn btn-link text-decoration-none text-muted me-3">Login</a>
<a href="/apply.php" class="btn btn-primary px-4">Get Started</a>
</div>
</div>
</nav>
<header class="section-padding bg-white border-bottom">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6">
<span class="badge bg-primary-subtle text-primary border border-primary-subtle mb-3">UK COMPLIANT</span>
<h1 class="display-4 fw-bold mb-4">Lasting Power of Attorney, simplified.</h1>
<p class="lead text-muted mb-5">Our staged questionnaire guides you through creating a legally compliant UK LPA in minutes. Trusted by professional estate planning practices.</p>
<div class="d-flex flex-wrap gap-3">
<a href="/apply.php" class="btn btn-primary btn-lg px-5">Start Application</a>
<a href="#how-it-works" class="btn btn-outline-secondary btn-lg">How it works</a>
</div>
</div>
<div class="col-lg-5 offset-lg-1 mt-5 mt-lg-0">
<div class="card p-2 border-0 shadow-sm">
<img src="<?php echo htmlspecialchars($project_img ?: 'https://images.unsplash.com/photo-1589829545856-d10d557cf95f?auto=format&fit=crop&q=80&w=1000'); ?>" class="img-fluid rounded" alt="LPA Service">
</div>
</div>
</div>
</div>
</header>
<section id="how-it-works" class="section-padding">
<div class="container">
<div class="row text-center mb-5">
<div class="col-lg-8 mx-auto">
<h2 class="fw-bold">Seamless Document Creation</h2>
<p class="text-muted">A structured path to protecting your future, managed by your professional advisor.</p>
</div>
</div>
<div class="row g-4">
<div class="col-md-4">
<div class="card h-100 p-4 border-0">
<div class="mb-3 text-primary">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>
</div>
<h5 class="fw-bold">1. Digital Questionnaire</h5>
<p class="text-muted small mb-0">Complete a simple, staged online form at your own pace. Save your progress anytime.</p>
</div>
</div>
<div class="col-md-4">
<div class="card h-100 p-4 border-0">
<div class="mb-3 text-primary">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>
</div>
<h5 class="fw-bold">2. Professional Review</h5>
<p class="text-muted small mb-0">Your estate planning practice reviews the information for accuracy and compliance.</p>
</div>
</div>
<div class="col-md-4">
<div class="card h-100 p-4 border-0">
<div class="mb-3 text-primary">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>
</div>
<h5 class="fw-bold">3. Secure Generation</h5>
<p class="text-muted small mb-0">Instantly generate and download your legally-formatted OPG documents ready for signing.</p>
</div>
</div>
</div>
</div>
</section>
<footer class="py-5 border-top bg-white">
<div class="container text-center text-muted">
<p class="small">&copy; <?php echo date('Y'); ?> <?php echo htmlspecialchars($project_name); ?>. All rights reserved.</p>
<div class="d-flex justify-content-center gap-3">
<a href="#" class="text-decoration-none text-muted small">Terms</a>
<a href="#" class="text-decoration-none text-muted small">Privacy</a>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
</html>