This commit is contained in:
Flatlogic Bot 2025-09-26 09:39:29 +00:00
parent 4a78d2b539
commit a5bc44b0ba
6 changed files with 315 additions and 125 deletions

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

@ -0,0 +1,16 @@
body {
background-color: #F3F4F6;
font-family: 'Inter', sans-serif;
}
.hero {
background: linear-gradient(to right, #3B82F6, #60A5FA);
color: white;
}
.card {
background-color: #FFFFFF;
border-radius: 8px;
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

@ -0,0 +1,38 @@
document.addEventListener('DOMContentLoaded', function () {
const addVisitorBtn = document.getElementById('add-visitor');
const visitorsContainer = document.getElementById('visitors-container');
let visitorCount = 1;
addVisitorBtn.addEventListener('click', function () {
visitorCount++;
const visitorTemplate = `
<div class="visitor-group border-t mt-4 pt-4">
<h3 class="text-lg font-semibold">Visitor ${visitorCount}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-2">
<div>
<label for="visitor_full_name_${visitorCount}" class="block text-sm font-medium text-gray-700">Full Name</label>
<input type="text" id="visitor_full_name_${visitorCount}" name="visitors[${visitorCount}][full_name]" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div>
<label for="visitor_id_or_passport_${visitorCount}" class="block text-sm font-medium text-gray-700">National ID or Passport Number</label>
<input type="text" id="visitor_id_or_passport_${visitorCount}" name="visitors[${visitorCount}][id_or_passport]" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div>
<label for="visitor_id_image_${visitorCount}" class="block text-sm font-medium text-gray-700">Scanned ID/Passport Image</label>
<input type="file" id="visitor_id_image_${visitorCount}" name="visitors[${visitorCount}][id_image]" class="mt-1 block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 focus:outline-none" required>
</div>
<div>
<label for="visitor_mobile_phone_${visitorCount}" class="block text-sm font-medium text-gray-700">Mobile Phone Number</label>
<input type="text" id="visitor_mobile_phone_${visitorCount}" name="visitors[${visitorCount}][mobile_phone]" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div class="md:col-span-2">
<label for="visitor_mailing_address_${visitorCount}" class="block text-sm font-medium text-gray-700">Mailing Address</label>
<textarea id="visitor_mailing_address_${visitorCount}" name="visitors[${visitorCount}][mailing_address]" rows="3" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required></textarea>
</div>
</div>
</div>
`;
visitorsContainer.insertAdjacentHTML('beforeend', visitorTemplate);
});
});

View File

@ -15,3 +15,12 @@ function db() {
}
return $pdo;
}
function run_migrations() {
$pdo = db();
$migrations = glob(__DIR__ . '/migrations/*.sql');
foreach ($migrations as $migration) {
$sql = file_get_contents($migration);
$pdo->exec($sql);
}
}

View File

@ -0,0 +1,29 @@
CREATE TABLE IF NOT EXISTS submissions (
id INT AUTO_INCREMENT PRIMARY KEY,
full_name VARCHAR(255) NOT NULL,
id_or_passport VARCHAR(255) NOT NULL,
id_image_path VARCHAR(255) NOT NULL,
gender VARCHAR(50) NOT NULL,
birth_date DATE NOT NULL,
mobile_phone VARCHAR(50) NOT NULL,
mailing_address TEXT NOT NULL,
start_visit_date DATE NOT NULL,
end_visit_date DATE NOT NULL,
purpose_of_visit TEXT NOT NULL,
visit_category VARCHAR(255) NOT NULL,
visit_location_lat VARCHAR(255) NOT NULL,
visit_location_lon VARCHAR(255) NOT NULL,
official_letter_path VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS visitors (
id INT AUTO_INCREMENT PRIMARY KEY,
submission_id INT NOT NULL,
full_name VARCHAR(255) NOT NULL,
id_or_passport VARCHAR(255) NOT NULL,
id_image_path VARCHAR(255) NOT NULL,
mobile_phone VARCHAR(50) NOT NULL,
mailing_address TEXT NOT NULL,
FOREIGN KEY (submission_id) REFERENCES submissions(id) ON DELETE CASCADE
);

269
index.php
View File

@ -1,131 +1,160 @@
<?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');
?>
<!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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Security Clearance Application</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
<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>
</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 class="hero py-16">
<div class="container mx-auto text-center">
<h1 class="text-4xl font-bold">Security Clearance Application</h1>
<p class="mt-4 text-lg">Republic of Indonesia</p>
</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>
<div class="container mx-auto py-12">
<div class="card p-8 max-w-4xl mx-auto">
<?php if (isset($_GET['success']) && $_GET['success'] === 'true'): ?>
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative" role="alert">
<strong class="font-bold">Success!</strong>
<span class="block sm:inline">Your application has been submitted.</span>
</div>
<?php elseif (isset($_GET['success']) && $_GET['success'] === 'false'): ?>
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
<strong class="font-bold">Error!</strong>
<span class="block sm:inline">There was a problem with your submission. Please try again.</span>
</div>
<?php endif; ?>
<form action="submit.php" method="POST" enctype="multipart/form-data" class="mt-8 space-y-6">
<!-- Applicant Information -->
<div>
<h2 class="text-2xl font-bold">Applicant Information</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-4">
<div>
<label for="full_name" class="block text-sm font-medium text-gray-700">Full Name</label>
<input type="text" id="full_name" name="full_name" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div>
<label for="id_or_passport" class="block text-sm font-medium text-gray-700">National ID or Passport Number</label>
<input type="text" id="id_or_passport" name="id_or_passport" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div>
<label for="id_image" class="block text-sm font-medium text-gray-700">Scanned ID/Passport Image</label>
<input type="file" id="id_image" name="id_image" class="mt-1 block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 focus:outline-none" required>
</div>
<div>
<label for="gender" class="block text-sm font-medium text-gray-700">Gender</label>
<select id="gender" name="gender" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
<option>Male</option>
<option>Female</option>
</select>
</div>
<div>
<label for="birth_date" class="block text-sm font-medium text-gray-700">Birth Date</label>
<input type="date" id="birth_date" name="birth_date" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div>
<label for="mobile_phone" class="block text-sm font-medium text-gray-700">Mobile Phone Number</label>
<input type="text" id="mobile_phone" name="mobile_phone" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div class="md:col-span-2">
<label for="mailing_address" class="block text-sm font-medium text-gray-700">Mailing Address</label>
<textarea id="mailing_address" name="mailing_address" rows="3" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required></textarea>
</div>
</div>
</div>
<!-- Visit Details -->
<div class="pt-6">
<h2 class="text-2xl font-bold">Visit Details</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-4">
<div>
<label for="start_visit_date" class="block text-sm font-medium text-gray-700">Start Visit Date</label>
<input type="date" id="start_visit_date" name="start_visit_date" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div>
<label for="end_visit_date" class="block text-sm font-medium text-gray-700">End Visit Date</label>
<input type="date" id="end_visit_date" name="end_visit_date" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div class="md:col-span-2">
<label for="purpose_of_visit" class="block text-sm font-medium text-gray-700">Purpose of Visit</label>
<textarea id="purpose_of_visit" name="purpose_of_visit" rows="3" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required></textarea>
</div>
<div>
<label for="visit_category" class="block text-sm font-medium text-gray-700">Visit Category</label>
<select id="visit_category" name="visit_category" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
<option>Official Visit</option>
<option>Recreational Visit</option>
<option>Maintenance</option>
</select>
</div>
<div>
<label for="official_letter" class="block text-sm font-medium text-gray-700">Official Letter/Memo (if applicable)</label>
<input type="file" id="official_letter" name="official_letter" class="mt-1 block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 focus:outline-none">
</div>
<div>
<label for="visit_location_lat" class="block text-sm font-medium text-gray-700">Visit Location (Latitude)</label>
<input type="text" id="visit_location_lat" name="visit_location_lat" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div>
<label for="visit_location_lon" class="block text-sm font-medium text-gray-700">Visit Location (Longitude)</label>
<input type="text" id="visit_location_lon" name="visit_location_lon" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
</div>
</div>
<!-- Visitor Details -->
<div class="pt-6">
<h2 class="text-2xl font-bold">Visitor Details</h2>
<div id="visitors-container">
<div class="visitor-group">
<h3 class="text-lg font-semibold">Visitor 1</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-2">
<div>
<label for="visitor_full_name_1" class="block text-sm font-medium text-gray-700">Full Name</label>
<input type="text" id="visitor_full_name_1" name="visitors[1][full_name]" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div>
<label for="visitor_id_or_passport_1" class="block text-sm font-medium text-gray-700">National ID or Passport Number</label>
<input type="text" id="visitor_id_or_passport_1" name="visitors[1][id_or_passport]" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div>
<label for="visitor_id_image_1" class="block text-sm font-medium text-gray-700">Scanned ID/Passport Image</label>
<input type="file" id="visitor_id_image_1" name="visitors[1][id_image]" class="mt-1 block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 focus:outline-none" required>
</div>
<div>
<label for="visitor_mobile_phone_1" class="block text-sm font-medium text-gray-700">Mobile Phone Number</label>
<input type="text" id="visitor_mobile_phone_1" name="visitors[1][mobile_phone]" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
</div>
<div class="md:col-span-2">
<label for="visitor_mailing_address_1" class="block text-sm font-medium text-gray-700">Mailing Address</label>
<textarea id="visitor_mailing_address_1" name="visitors[1][mailing_address]" rows="3" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required></textarea>
</div>
</div>
</div>
</div>
<button type="button" id="add-visitor" class="mt-4 px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300">Add Another Visitor</button>
</div>
<div class="pt-6">
<button type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Submit Application
</button>
</div>
</form>
</div>
</div>
<script src="assets/js/main.js"></script>
</body>
</html>

69
submit.php Normal file
View File

@ -0,0 +1,69 @@
<?php
require_once __DIR__ . '/db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
run_migrations();
$pdo = db();
// Handle file uploads
$id_image_path = 'uploads/' . basename($_FILES['id_image']['name']);
move_uploaded_file($_FILES['id_image']['tmp_name'], $id_image_path);
$official_letter_path = null;
if (isset($_FILES['official_letter']) && $_FILES['official_letter']['error'] === UPLOAD_ERR_OK) {
$official_letter_path = 'uploads/' . basename($_FILES['official_letter']['name']);
move_uploaded_file($_FILES['official_letter']['tmp_name'], $official_letter_path);
}
// Insert into submissions table
$stmt = $pdo->prepare("
INSERT INTO submissions (full_name, id_or_passport, id_image_path, gender, birth_date, mobile_phone, mailing_address, start_visit_date, end_visit_date, purpose_of_visit, visit_category, visit_location_lat, visit_location_lon, official_letter_path)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
");
$stmt->execute([
$_POST['full_name'],
$_POST['id_or_passport'],
$id_image_path,
$_POST['gender'],
$_POST['birth_date'],
$_POST['mobile_phone'],
$_POST['mailing_address'],
$_POST['start_visit_date'],
$_POST['end_visit_date'],
$_POST['purpose_of_visit'],
$_POST['visit_category'],
$_POST['visit_location_lat'],
$_POST['visit_location_lon'],
$official_letter_path
]);
$submission_id = $pdo->lastInsertId();
// Insert into visitors table
if (isset($_POST['visitors'])) {
foreach ($_POST['visitors'] as $visitor) {
$visitor_id_image_path = 'uploads/' . basename($visitor['id_image']['name']);
move_uploaded_file($visitor['id_image']['tmp_name'], $visitor_id_image_path);
$stmt = $pdo->prepare("
INSERT INTO visitors (submission_id, full_name, id_or_passport, id_image_path, mobile_phone, mailing_address)
VALUES (?, ?, ?, ?, ?, ?)
");
$stmt->execute([
$submission_id,
$visitor['full_name'],
$visitor['id_or_passport'],
$visitor_id_image_path,
$visitor['mobile_phone'],
$visitor['mailing_address']
]);
}
}
header('Location: /?success=true');
} catch (Exception $e) {
error_log($e->getMessage());
header('Location: /?success=false');
}
}