Initial Creation
This commit is contained in:
parent
151aa2c662
commit
6d06eea56a
90
auth.php
Normal file
90
auth.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
session_start();
|
||||
require 'db/config.php';
|
||||
|
||||
function loginWorker($userId) {
|
||||
$db = db();
|
||||
$stmt = $db->prepare("SELECT * FROM users WHERE id = ? AND role = 'worker'");
|
||||
$stmt->execute([$userId]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['user_name'] = $user['name'];
|
||||
$_SESSION['role'] = 'worker';
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function loginAdmin($userId, $pin) {
|
||||
$db = db();
|
||||
$stmt = $db->prepare("SELECT * FROM users WHERE id = ? AND role = 'admin'");
|
||||
$stmt->execute([$userId]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user) {
|
||||
// If no PIN set, allow setup (bootstrap mode)
|
||||
if ($user['pin_hash'] === null) {
|
||||
// This is special case, first time login
|
||||
$_SESSION['pending_setup_user_id'] = $user['id'];
|
||||
return 'setup';
|
||||
}
|
||||
|
||||
if (password_verify($pin, $user['pin_hash'])) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['user_name'] = $user['name'];
|
||||
$_SESSION['role'] = 'admin';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function setupAdminPin($userId, $pin) {
|
||||
$db = db();
|
||||
$hash = password_hash($pin, PASSWORD_BCRYPT);
|
||||
$stmt = $db->prepare("UPDATE users SET pin_hash = ? WHERE id = ? AND role = 'admin'");
|
||||
return $stmt->execute([$hash, $userId]);
|
||||
}
|
||||
|
||||
// Check POST requests
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = $_POST['action'] ?? '';
|
||||
|
||||
if ($action === 'login_worker') {
|
||||
if (loginWorker($_POST['user_id'])) {
|
||||
header('Location: dashboard.php');
|
||||
exit;
|
||||
}
|
||||
} elseif ($action === 'login_admin') {
|
||||
$res = loginAdmin($_POST['user_id'], $_POST['pin']);
|
||||
if ($res === true) {
|
||||
header('Location: dashboard.php');
|
||||
exit;
|
||||
} elseif ($res === 'setup') {
|
||||
header('Location: index.php?setup=1');
|
||||
exit;
|
||||
}
|
||||
} elseif ($action === 'setup_pin') {
|
||||
$userId = $_SESSION['pending_setup_user_id'] ?? null;
|
||||
if ($userId && !empty($_POST['pin'])) {
|
||||
if (setupAdminPin($userId, $_POST['pin'])) {
|
||||
unset($_SESSION['pending_setup_user_id']);
|
||||
// Auto login after setup
|
||||
$db = db();
|
||||
$stmt = $db->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->execute([$userId]);
|
||||
$user = $stmt->fetch();
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['user_name'] = $user['name'];
|
||||
$_SESSION['role'] = 'admin';
|
||||
header('Location: dashboard.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: index.php?error=1');
|
||||
exit;
|
||||
}
|
||||
221
dashboard.php
Normal file
221
dashboard.php
Normal file
@ -0,0 +1,221 @@
|
||||
<?php
|
||||
session_start();
|
||||
require 'db/config.php';
|
||||
$db = db();
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$role = $_SESSION['role'];
|
||||
$userName = $_SESSION['user_name'];
|
||||
$userId = $_SESSION['user_id'];
|
||||
|
||||
// Get assigned processes for worker
|
||||
$assignedProcesses = [];
|
||||
if ($role === 'worker') {
|
||||
$stmt = $db->prepare("SELECT assigned_processes FROM users WHERE id = ?");
|
||||
$stmt->execute([$userId]);
|
||||
$res = $stmt->fetch();
|
||||
$assignedProcesses = json_decode($res['assigned_processes'] ?? '[]', true);
|
||||
}
|
||||
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>M-TRACK | Dashboard</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--sidebar-width: 240px;
|
||||
--bg: #f8fafc;
|
||||
--primary: #1e293b;
|
||||
--accent: #3b82f6;
|
||||
--text: #334155;
|
||||
--border: #e2e8f0;
|
||||
}
|
||||
body {
|
||||
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
||||
background-color: var(--bg);
|
||||
color: var(--text);
|
||||
}
|
||||
.sidebar {
|
||||
width: var(--sidebar-width);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: var(--primary);
|
||||
color: white;
|
||||
z-index: 1000;
|
||||
padding: 1.5rem 1rem;
|
||||
}
|
||||
.sidebar h2 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 2rem;
|
||||
padding: 0 0.5rem;
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
.nav-pills .nav-link {
|
||||
color: #94a3b8;
|
||||
font-weight: 500;
|
||||
font-size: 0.875rem;
|
||||
padding: 0.625rem 0.75rem;
|
||||
margin-bottom: 0.25rem;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.nav-pills .nav-link:hover {
|
||||
color: white;
|
||||
background-color: rgba(255,255,255,0.05);
|
||||
}
|
||||
.nav-pills .nav-link.active {
|
||||
color: white;
|
||||
background-color: var(--accent);
|
||||
}
|
||||
.main-content {
|
||||
margin-left: var(--sidebar-width);
|
||||
padding: 2.5rem;
|
||||
}
|
||||
.top-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
.top-bar h1 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: var(--primary);
|
||||
margin: 0;
|
||||
}
|
||||
.user-pill {
|
||||
background: white;
|
||||
border: 1px solid var(--border);
|
||||
padding: 0.375rem 1rem;
|
||||
border-radius: 9999px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.card {
|
||||
background: white;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.card-header {
|
||||
background: white;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 1rem 1.25rem;
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
color: var(--primary);
|
||||
}
|
||||
.badge-process {
|
||||
background: #e2e8f0;
|
||||
color: #475569;
|
||||
font-weight: 600;
|
||||
font-size: 0.75rem;
|
||||
padding: 0.25rem 0.625rem;
|
||||
border-radius: 4px;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="sidebar">
|
||||
<h2>M-TRACK</h2>
|
||||
<nav class="nav nav-pills flex-column">
|
||||
<a class="nav-link active" href="#"><i class="bi bi-grid-fill me-2"></i> Dashboard</a>
|
||||
<?php if ($role === 'admin'): ?>
|
||||
<a class="nav-link" href="#"><i class="bi bi-briefcase me-2"></i> Jobs</a>
|
||||
<a class="nav-link" href="#"><i class="bi bi-boxes me-2"></i> Inventory</a>
|
||||
<a class="nav-link" href="#"><i class="bi bi-people me-2"></i> Users</a>
|
||||
<?php else: ?>
|
||||
<a class="nav-link" href="#"><i class="bi bi-list-task me-2"></i> My Queue</a>
|
||||
<?php endif; ?>
|
||||
<hr class="my-4 border-secondary opacity-25">
|
||||
<a class="nav-link text-danger" href="logout.php"><i class="bi bi-box-arrow-right me-2"></i> Logout</a>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="top-bar">
|
||||
<h1><?= $role === 'admin' ? 'Operations Overview' : 'Work Queue' ?></h1>
|
||||
<div class="user-pill">
|
||||
<i class="bi bi-person-circle text-muted"></i>
|
||||
<?= htmlspecialchars($userName) ?>
|
||||
<span class="text-muted text-uppercase" style="font-size: 0.625rem;"><?= $role ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($role === 'worker'): ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Active Processes:
|
||||
<?php foreach ($assignedProcesses as $proc): ?>
|
||||
<span class="badge-process"><?= strtoupper($proc) ?></span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="card-body py-5 text-center">
|
||||
<div class="mb-3 text-muted" style="font-size: 2rem;"><i class="bi bi-clipboard-check"></i></div>
|
||||
<h5 class="text-muted">No pending operations for your assigned processes.</h5>
|
||||
<p class="text-muted small">New jobs will appear here when ready for production.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="card text-center p-3">
|
||||
<div class="text-muted small fw-bold text-uppercase mb-1">Active Jobs</div>
|
||||
<div class="h3 fw-bold mb-0">0</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-center p-3">
|
||||
<div class="text-muted small fw-bold text-uppercase mb-1">Pending Ops</div>
|
||||
<div class="h3 fw-bold mb-0">0</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-center p-3">
|
||||
<div class="text-muted small fw-bold text-uppercase mb-1">Inventory Alerts</div>
|
||||
<div class="h3 fw-bold mb-0">0</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-center p-3">
|
||||
<div class="text-muted small fw-bold text-uppercase mb-1">Active Workers</div>
|
||||
<div class="h3 fw-bold mb-0">2</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">Production Status</div>
|
||||
<div class="card-body py-5 text-center">
|
||||
<h5 class="text-muted">No production data available yet.</h5>
|
||||
<button class="btn btn-sm btn-primary mt-2">Create First Job</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
31
db/migrate_001_users.php
Normal file
31
db/migrate_001_users.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require 'db/config.php';
|
||||
$db = db();
|
||||
|
||||
try {
|
||||
$db->exec("CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
role ENUM('worker', 'admin') NOT NULL,
|
||||
pin_hash VARCHAR(255) DEFAULT NULL,
|
||||
assigned_processes JSON DEFAULT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)");
|
||||
|
||||
$stmt = $db->query("SELECT COUNT(*) FROM users");
|
||||
if ($stmt->fetchColumn() == 0) {
|
||||
$db->prepare("INSERT INTO users (name, role, assigned_processes) VALUES (?, ?, ?)")
|
||||
->execute(['John Operator', 'worker', json_encode(['cutting', 'welding'])]);
|
||||
$db->prepare("INSERT INTO users (name, role, assigned_processes) VALUES (?, ?, ?)")
|
||||
->execute(['Sarah Smith', 'worker', json_encode(['bending', 'assembly'])]);
|
||||
// Admin user
|
||||
$db->prepare("INSERT INTO users (name, role) VALUES (?, ?)")
|
||||
->execute(['Mike Manager', 'admin']);
|
||||
echo "Users table created and seeded.\n";
|
||||
} else {
|
||||
echo "Users table already exists and is not empty.\n";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
293
index.php
293
index.php
@ -1,150 +1,207 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
session_start();
|
||||
require 'db/config.php';
|
||||
$db = db();
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
header('Location: dashboard.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$workers = $db->query("SELECT * FROM users WHERE role = 'worker'")->fetchAll();
|
||||
$admins = $db->query("SELECT * FROM users WHERE role = 'admin'")->fetchAll();
|
||||
$isSetup = isset($_GET['setup']) && isset($_SESSION['pending_setup_user_id']);
|
||||
?>
|
||||
<!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">
|
||||
<title>M-TRACK | Login</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;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);
|
||||
--bg: #f8fafc;
|
||||
--card-bg: #ffffff;
|
||||
--primary: #1e293b;
|
||||
--accent: #3b82f6;
|
||||
--text: #334155;
|
||||
--border: #e2e8f0;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
||||
background-color: var(--bg);
|
||||
color: var(--text);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
padding: 2.5rem;
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
||||
}
|
||||
.login-header {
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
.login-header h1 {
|
||||
font-weight: 700;
|
||||
font-size: 1.5rem;
|
||||
color: var(--primary);
|
||||
letter-spacing: -0.025em;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
.login-header p {
|
||||
font-size: 0.875rem;
|
||||
color: #64748b;
|
||||
}
|
||||
.nav-tabs {
|
||||
border-bottom: 2px solid var(--border);
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.nav-link {
|
||||
color: #64748b;
|
||||
font-weight: 500;
|
||||
border: none !important;
|
||||
padding: 0.75rem 0;
|
||||
margin-right: 1.5rem;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
.nav-link.active {
|
||||
color: var(--accent) !important;
|
||||
background: none !important;
|
||||
}
|
||||
.nav-link.active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: -2px;
|
||||
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;
|
||||
height: 2px;
|
||||
background-color: var(--accent);
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
.form-label {
|
||||
font-weight: 500;
|
||||
font-size: 0.875rem;
|
||||
color: var(--primary);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
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;
|
||||
.form-select, .form-control {
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
border-color: var(--border);
|
||||
padding: 0.625rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
.form-select:focus, .form-control:focus {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
.btn-primary {
|
||||
background-color: var(--primary);
|
||||
border: none;
|
||||
padding: 0.625rem;
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
border-radius: 4px;
|
||||
width: 100%;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.btn-primary:hover {
|
||||
background-color: #0f172a;
|
||||
}
|
||||
.alert {
|
||||
font-size: 0.8125rem;
|
||||
padding: 0.75rem;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
</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>
|
||||
<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="login-card">
|
||||
<div class="login-header">
|
||||
<h1>M-TRACK</h1>
|
||||
<p>Manufacturing Control System</p>
|
||||
</div>
|
||||
|
||||
<?php if (isset($_GET['error'])): ?>
|
||||
<div class="alert alert-danger">
|
||||
<i class="bi bi-exclamation-circle me-2"></i> Invalid selection or PIN.
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($isSetup): ?>
|
||||
<form action="auth.php" method="POST">
|
||||
<input type="hidden" name="action" value="setup_pin">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Create Admin PIN (4-6 digits)</label>
|
||||
<input type="password" name="pin" class="form-control" required pattern="\d{4,6}" inputmode="numeric">
|
||||
<div class="form-text mt-2">Initial setup for <?= htmlspecialchars($_SESSION['pending_setup_user_id']) ?></div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Set PIN & Login</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<ul class="nav nav-tabs" id="loginTabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="worker-tab" data-bs-toggle="tab" data-bs-target="#worker" type="button" role="tab">Worker</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="admin-tab" data-bs-toggle="tab" data-bs-target="#admin" type="button" role="tab">Admin</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content" id="loginTabsContent">
|
||||
<!-- Worker Tab -->
|
||||
<div class="tab-pane fade show active" id="worker" role="tabpanel">
|
||||
<form action="auth.php" method="POST">
|
||||
<input type="hidden" name="action" value="login_worker">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Select Name</label>
|
||||
<select name="user_id" class="form-select" required>
|
||||
<option value="">Select...</option>
|
||||
<?php foreach ($workers as $w): ?>
|
||||
<option value="<?= $w['id'] ?>"><?= htmlspecialchars($w['name']) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Admin Tab -->
|
||||
<div class="tab-pane fade" id="admin" role="tabpanel">
|
||||
<form action="auth.php" method="POST">
|
||||
<input type="hidden" name="action" value="login_admin">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Select Name</label>
|
||||
<select name="user_id" class="form-select" required>
|
||||
<option value="">Select...</option>
|
||||
<?php foreach ($admins as $a): ?>
|
||||
<option value="<?= $a['id'] ?>"><?= htmlspecialchars($a['name']) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Enter PIN</label>
|
||||
<input type="password" name="pin" class="form-control" placeholder="••••" inputmode="numeric">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
5
logout.php
Normal file
5
logout.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
Loading…
x
Reference in New Issue
Block a user