Compare commits
No commits in common. "ai-dev" and "master" have entirely different histories.
@ -1,56 +0,0 @@
|
||||
:root {
|
||||
--bs-primary: #4F46E5;
|
||||
--bs-primary-rgb: 79, 70, 229;
|
||||
--bs-secondary: #10B981;
|
||||
--bs-light: #F3F4F6;
|
||||
--bs-dark: #111827;
|
||||
--bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bs-light);
|
||||
font-family: var(--bs-font-sans-serif);
|
||||
color: var(--bs-dark);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background-color: var(--bs-primary);
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--bs-primary);
|
||||
border-color: var(--bs-primary);
|
||||
border-radius: 0.375rem;
|
||||
font-weight: 500;
|
||||
transition: background-color 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #4338CA; /* A slightly darker indigo */
|
||||
border-color: #4338CA;
|
||||
}
|
||||
|
||||
.table {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.table th {
|
||||
font-weight: 500;
|
||||
color: #6B7280; /* Subtle Text color */
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
// main.js - for future interactivity
|
||||
@ -5,26 +5,6 @@ define('DB_NAME', 'app_36360');
|
||||
define('DB_USER', 'app_36360');
|
||||
define('DB_PASS', '87b9c9ae-1c07-4a75-9acd-f1a9fa52ffb4');
|
||||
|
||||
/**
|
||||
* Runs database migrations.
|
||||
* @param PDO $pdo
|
||||
*/
|
||||
function run_migrations(PDO $pdo) {
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS schema_migrations (version VARCHAR(255) PRIMARY KEY)");
|
||||
$appliedVersions = $pdo->query("SELECT version FROM schema_migrations")->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
$migrationFiles = glob(__DIR__ . '/migrations/*.sql');
|
||||
foreach ($migrationFiles as $file) {
|
||||
$version = basename($file);
|
||||
if (!in_array($version, $appliedVersions)) {
|
||||
$script = file_get_contents($file);
|
||||
$pdo->exec($script);
|
||||
$stmt = $pdo->prepare("INSERT INTO schema_migrations (version) VALUES (?)");
|
||||
$stmt->execute([$version]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function db() {
|
||||
static $pdo;
|
||||
if (!$pdo) {
|
||||
@ -32,7 +12,6 @@ function db() {
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]);
|
||||
run_migrations($pdo);
|
||||
}
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
CREATE TABLE IF NOT EXISTS employees (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
first_name VARCHAR(100) NOT NULL,
|
||||
last_name VARCHAR(100) NOT NULL,
|
||||
email VARCHAR(100) UNIQUE NOT NULL,
|
||||
designation VARCHAR(100),
|
||||
base_salary DECIMAL(10, 2) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
290
index.php
290
index.php
@ -1,170 +1,150 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
$pdo = db();
|
||||
$errors = [];
|
||||
$success_message = '';
|
||||
|
||||
// Handle POST request to add a new employee
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$first_name = trim($_POST['first_name'] ?? '');
|
||||
$last_name = trim($_POST['last_name'] ?? '');
|
||||
$email = trim($_POST['email'] ?? '');
|
||||
$designation = trim($_POST['designation'] ?? '');
|
||||
$base_salary = trim($_POST['base_salary'] ?? '');
|
||||
|
||||
// Validation
|
||||
if (empty($first_name)) $errors[] = 'First name is required.';
|
||||
if (empty($last_name)) $errors[] = 'Last name is required.';
|
||||
if (empty($email)) {
|
||||
$errors[] = 'Email is required.';
|
||||
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$errors[] = 'Invalid email format.';
|
||||
}
|
||||
if (empty($designation)) $errors[] = 'Designation is required.';
|
||||
if (empty($base_salary)) {
|
||||
$errors[] = 'Base salary is required.';
|
||||
} elseif (!is_numeric($base_salary) || $base_salary < 0) {
|
||||
$errors[] = 'Base salary must be a positive number.';
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT INTO employees (first_name, last_name, email, designation, base_salary) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$first_name, $last_name, $email, $designation, $base_salary]);
|
||||
$success_message = "Employee ''' . htmlspecialchars($first_name . ' ' . $last_name) . ''' added successfully!";
|
||||
} catch (PDOException $e) {
|
||||
if ($e->errorInfo[1] == 1062) { // Duplicate entry
|
||||
$errors[] = "An employee with this email already exists.";
|
||||
} else {
|
||||
$errors[] = "Database error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch all employees
|
||||
$stmt = $pdo->query("SELECT id, first_name, last_name, email, designation, base_salary FROM employees ORDER BY created_at DESC");
|
||||
$employees = $stmt->fetchAll();
|
||||
|
||||
$project_name = htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'SalaryBook');
|
||||
$project_description = htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'Smart Payroll Management System');
|
||||
$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.0">
|
||||
<title><?= $project_name ?> - Employee Management</title>
|
||||
<meta name="description" content="<?= $project_description ?>">
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<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;500;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
|
||||
<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>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/"><?= $project_name ?></a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4">
|
||||
|
||||
<?php if (!empty($success_message)): ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
<?= $success_message ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<ul class="mb-0">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<li><?= $error ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-4 mb-4">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<h1 class="card-title h5 mb-3">Add New Employee</h1>
|
||||
<form action="index.php" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="first_name" class="form-label">First Name</label>
|
||||
<input type="text" class="form-control" id="first_name" name="first_name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="last_name" class="form-label">Last Name</label>
|
||||
<input type="text" class="form-control" id="last_name" name="last_name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email Address</label>
|
||||
<input type="email" class="form-control" id="email" name="email" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="designation" class="form-label">Designation</label>
|
||||
<input type="text" class="form-control" id="designation" name="designation" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="base_salary" class="form-label">Base Salary ($)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="base_salary" name="base_salary" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100">Add Employee</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-8">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title h5 mb-3">Current Employees</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Designation</th>
|
||||
<th class="text-end">Salary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($employees)): ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted">No employees found. Add one to get started!</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($employees as $employee): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($employee['first_name'] . ' ' . $employee['last_name']) ?></td>
|
||||
<td><?= htmlspecialchars($employee['email']) ?></td>
|
||||
<td><?= htmlspecialchars($employee['designation']) ?></td>
|
||||
<td class="text-end">$<?= number_format($employee['base_salary'], 2) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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 class="text-center text-muted py-4 mt-auto">
|
||||
<p>© <?= date('Y') ?> <?= $project_name ?>. All rights reserved.</p>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user