first one

This commit is contained in:
Flatlogic Bot 2026-02-16 11:41:41 +00:00
parent 0a5bf79655
commit c6859bf3de
5 changed files with 379 additions and 141 deletions

27
api/register_clergy.php Normal file
View File

@ -0,0 +1,27 @@
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../db/config.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
echo json_encode(['success' => false, 'error' => 'Invalid request method.']);
exit;
}
$firstName = trim($_POST['first_name'] ?? '');
$lastName = trim($_POST['last_name'] ?? '');
$rank = trim($_POST['clergy_rank'] ?? '');
$metropolis = trim($_POST['metropolis_name'] ?? '');
$email = trim($_POST['email'] ?? '');
if (empty($firstName) || empty($lastName) || empty($rank) || empty($metropolis)) {
echo json_encode(['success' => false, 'error' => 'All required fields must be filled.']);
exit;
}
try {
$stmt = db()->prepare("INSERT INTO clergy (first_name, last_name, clergy_rank, metropolis_name, email) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$firstName, $lastName, $rank, $metropolis, $email]);
echo json_encode(['success' => true]);
} catch (Exception $e) {
echo json_encode(['success' => false, 'error' => 'Database error: ' . $e->getMessage()]);
}

91
assets/css/custom.css Normal file
View File

@ -0,0 +1,91 @@
/* Custom styles for Clergy Registry Admin */
body {
background-color: #F9FAFB;
color: #111827;
font-family: 'Inter', -apple-system, sans-serif;
font-size: 14px;
letter-spacing: -0.01em;
}
.sidebar {
background-color: #FFFFFF;
border-right: 1px solid #E5E7EB;
min-height: 100vh;
}
.nav-link {
color: #4B5563;
padding: 0.75rem 1rem;
border-radius: 4px;
margin-bottom: 0.25rem;
}
.nav-link:hover, .nav-link.active {
background-color: #F3F4F6;
color: #111827;
}
.card {
background-color: #FFFFFF;
border: 1px solid #E5E7EB;
border-radius: 4px;
box-shadow: none;
}
.stat-card {
padding: 1.5rem;
}
.stat-value {
font-size: 1.5rem;
font-weight: 600;
color: #111827;
}
.stat-label {
color: #6B7280;
font-size: 0.875rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.table thead th {
background-color: #F9FAFB;
color: #6B7280;
font-weight: 500;
text-transform: uppercase;
font-size: 0.75rem;
letter-spacing: 0.05em;
border-bottom: 1px solid #E5E7EB;
}
.btn-primary {
background-color: #111827;
border-color: #111827;
border-radius: 4px;
padding: 0.5rem 1rem;
font-weight: 500;
}
.btn-primary:hover {
background-color: #1F2937;
border-color: #1F2937;
}
.badge-active {
background-color: #D1FAE5;
color: #065F46;
font-weight: 500;
padding: 0.25rem 0.5rem;
border-radius: 4px;
}
.form-control {
border-radius: 4px;
border: 1px solid #D1D5DB;
}
.form-control:focus {
border-color: #111827;
box-shadow: 0 0 0 1px #111827;
}

53
assets/js/main.js Normal file
View File

@ -0,0 +1,53 @@
document.addEventListener('DOMContentLoaded', function() {
const registerForm = document.getElementById('registerClergyForm');
if (registerForm) {
registerForm.addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(this);
const submitBtn = this.querySelector('button[type="submit"]');
submitBtn.disabled = true;
submitBtn.innerHTML = 'Registering...';
fetch('api/register_clergy.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
showToast('Success', 'Clergy member registered successfully.');
setTimeout(() => location.reload(), 1500);
} else {
showToast('Error', data.error || 'Failed to register clergy.');
submitBtn.disabled = false;
submitBtn.innerHTML = 'Register Clergy';
}
})
.catch(error => {
showToast('Error', 'An unexpected error occurred.');
submitBtn.disabled = false;
submitBtn.innerHTML = 'Register Clergy';
});
});
}
});
function showToast(title, message) {
const toastContainer = document.getElementById('toastContainer');
const toastHtml = `
<div class="toast show border-0 card" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header border-0 pb-0">
<strong class="me-auto">${title}</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body pt-1">
${message}
</div>
</div>
`;
toastContainer.innerHTML = toastHtml;
setTimeout(() => {
toastContainer.innerHTML = '';
}, 5000);
}

View File

@ -0,0 +1,20 @@
-- Initial schema for Clergy Registry
CREATE TABLE IF NOT EXISTS clergy (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
clergy_rank VARCHAR(100) NOT NULL,
metropolis_name VARCHAR(255) NOT NULL,
email VARCHAR(255),
status VARCHAR(50) DEFAULT 'Active',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Seed data for testing
INSERT INTO clergy (first_name, last_name, clergy_rank, metropolis_name, email)
SELECT 'Ioannis', 'Papadopoulos', 'Archimandrite', 'Metropolis of Athens', 'ioannis.p@example.gr'
WHERE NOT EXISTS (SELECT 1 FROM clergy WHERE email = 'ioannis.p@example.gr');
INSERT INTO clergy (first_name, last_name, clergy_rank, metropolis_name, email)
SELECT 'Dimitrios', 'Georgiou', 'Priest', 'Metropolis of Thessaloniki', 'dimitrios.g@example.gr'
WHERE NOT EXISTS (SELECT 1 FROM clergy WHERE email = 'dimitrios.g@example.gr');

329
index.php
View File

@ -1,150 +1,197 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
require_once __DIR__ . '/db/config.php';
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!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'] ?? '';
// Fetch clergy data
$stmt = db()->query("SELECT * FROM clergy ORDER BY created_at DESC");
$clergyList = $stmt->fetchAll();
// Stats
$totalClergy = count($clergyList);
$activeAssignments = $totalClergy; // Simplified for MVP
$title = $_SERVER['PROJECT_NAME'] ?? 'Clergy Registry';
$description = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Digital Registry and Payroll System for Clergy in Greece';
$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>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($title); ?></title>
<!-- SEO and Dynamic Meta Tags -->
<?php if ($description): ?>
<meta name="description" content="<?php echo htmlspecialchars($description); ?>">
<meta property="og:description" content="<?php echo htmlspecialchars($description); ?>">
<meta property="twitter:description" content="<?php echo htmlspecialchars($description); ?>">
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<meta property="og:image" content="<?php echo htmlspecialchars($projectImageUrl); ?>">
<meta property="twitter:image" content="<?php echo htmlspecialchars($projectImageUrl); ?>">
<?php endif; ?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
<link href="assets/css/custom.css?v=<?php echo time(); ?>" 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 class="container-fluid">
<div class="row">
<!-- Sidebar -->
<nav class="col-md-2 d-none d-md-block sidebar py-4">
<div class="px-3 mb-4">
<h5 class="fw-bold mb-0 text-dark">Registry Admin</h5>
<small class="text-muted">Greece Clergy System</small>
</div>
<div class="nav flex-column px-2">
<a class="nav-link active" href="index.php">Dashboard</a>
<a class="nav-link" href="#">Clergy Directory</a>
<a class="nav-link" href="#">Payroll Runs</a>
<a class="nav-link" href="#">Organizations</a>
<a class="nav-link" href="#">Reports</a>
<div class="mt-auto pt-4">
<a class="nav-link text-danger" href="#">Logout</a>
</div>
</div>
</nav>
<!-- Main Content -->
<main class="col-md-10 ms-sm-auto px-md-4 py-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center mb-4">
<h1 class="h4 fw-bold mb-0">Registry Dashboard</h1>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#registerModal">
Register New Clergy
</button>
</div>
<!-- Stats -->
<div class="row g-4 mb-5">
<div class="col-md-3">
<div class="card stat-card shadow-sm border-0">
<div class="stat-label">Total Clergy</div>
<div class="stat-value"><?php echo $totalClergy; ?></div>
</div>
</div>
<div class="col-md-3">
<div class="card stat-card shadow-sm border-0">
<div class="stat-label">Active Assignments</div>
<div class="stat-value"><?php echo $activeAssignments; ?></div>
</div>
</div>
<div class="col-md-3">
<div class="card stat-card shadow-sm border-0">
<div class="stat-label">Metropolises</div>
<div class="stat-value">2</div>
</div>
</div>
<div class="col-md-3">
<div class="card stat-card shadow-sm border-0">
<div class="stat-label">Pending Payroll</div>
<div class="stat-value">€0.00</div>
</div>
</div>
</div>
<!-- Clergy Directory -->
<div class="card mb-4 border-0 shadow-sm overflow-hidden">
<div class="px-3 py-3 border-bottom d-flex align-items-center justify-content-between">
<h6 class="mb-0 fw-bold">Recent Registrations</h6>
<small class="text-muted">Viewing latest entries</small>
</div>
<div class="table-responsive">
<table class="table align-middle mb-0">
<thead>
<tr>
<th>Name</th>
<th>Rank</th>
<th>Metropolis</th>
<th>Email</th>
<th>Status</th>
<th>Registered</th>
</tr>
</thead>
<tbody>
<?php foreach ($clergyList as $row): ?>
<tr>
<td>
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($row['first_name'] . ' ' . $row['last_name']); ?></div>
</td>
<td><span class="text-secondary"><?php echo htmlspecialchars($row['clergy_rank']); ?></span></td>
<td><?php echo htmlspecialchars($row['metropolis_name']); ?></td>
<td><?php echo htmlspecialchars($row['email']); ?></td>
<td><span class="badge-active">Active</span></td>
<td class="text-muted"><?php echo date('M d, Y', strtotime($row['created_at'])); ?></td>
</tr>
<?php endforeach; ?>
<?php if (empty($clergyList)): ?>
<tr>
<td colspan="6" class="text-center py-4 text-muted">No records found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</main>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</div>
<!-- Register Modal -->
<div class="modal fade" id="registerModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content border-0 shadow-lg">
<div class="modal-header border-0 pb-0">
<h5 class="modal-title fw-bold">Register New Clergy</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body pt-3">
<form id="registerClergyForm">
<div class="row g-3">
<div class="col-md-6">
<label class="form-label small fw-semibold">First Name</label>
<input type="text" name="first_name" class="form-control" placeholder="e.g. Ioannis" required>
</div>
<div class="col-md-6">
<label class="form-label small fw-semibold">Last Name</label>
<input type="text" name="last_name" class="form-control" placeholder="e.g. Papadopoulos" required>
</div>
<div class="col-md-12">
<label class="form-label small fw-semibold">Clergy Rank</label>
<select name="clergy_rank" class="form-control" required>
<option value="">Select Rank...</option>
<option value="Archbishop">Archbishop</option>
<option value="Metropolitan">Metropolitan</option>
<option value="Bishop">Bishop</option>
<option value="Archimandrite">Archimandrite</option>
<option value="Priest">Priest</option>
<option value="Deacon">Deacon</option>
</select>
</div>
<div class="col-md-12">
<label class="form-label small fw-semibold">Metropolis / Diocese</label>
<input type="text" name="metropolis_name" class="form-control" placeholder="e.g. Metropolis of Athens" required>
</div>
<div class="col-md-12">
<label class="form-label small fw-semibold">Email Address</label>
<input type="email" name="email" class="form-control" placeholder="name@diocese.gr">
</div>
</div>
<div class="mt-4 text-end">
<button type="button" class="btn text-muted me-2" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Register Clergy</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Toast Container -->
<div id="toastContainer" class="toast-container position-fixed bottom-0 end-0 p-3"></div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>