Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d5d2597c6 |
34
api/tickets.php
Normal file
34
api/tickets.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
|
||||
if ($method === 'GET') {
|
||||
$stmt = $pdo->query("SELECT * FROM tickets ORDER BY created_at DESC");
|
||||
echo json_encode($stmt->fetchAll());
|
||||
}
|
||||
elseif ($method === 'POST') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
if (empty($data['title'])) {
|
||||
throw new Exception("Title is required");
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO tickets (title, description, priority, status) VALUES (?, ?, ?, 'Open')");
|
||||
$stmt->execute([
|
||||
$data['title'],
|
||||
$data['description'] ?? '',
|
||||
$data['priority'] ?? 'Medium'
|
||||
]);
|
||||
|
||||
echo json_encode(['success' => true, 'id' => $pdo->lastInsertId()]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
70
assets/css/custom.css
Normal file
70
assets/css/custom.css
Normal file
@ -0,0 +1,70 @@
|
||||
:root {
|
||||
--primary-color: #0f172a;
|
||||
--accent-color: #3b82f6;
|
||||
--bg-color: #fcfcfc;
|
||||
--border-color: #e2e8f0;
|
||||
--text-main: #1e293b;
|
||||
--text-muted: #64748b;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-main);
|
||||
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: 4px;
|
||||
font-weight: 500;
|
||||
font-size: 13px;
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--primary-color);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #1e293b;
|
||||
border-color: #1e293b;
|
||||
}
|
||||
|
||||
.table {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.table th {
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.05em;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.badge {
|
||||
font-weight: 500;
|
||||
border-radius: 2px;
|
||||
padding: 0.35em 0.5em;
|
||||
}
|
||||
|
||||
.priority-High { background-color: #fee2e2; color: #991b1b; }
|
||||
.priority-Medium { background-color: #fef3c7; color: #92400e; }
|
||||
.priority-Low { background-color: #dcfce7; color: #166534; }
|
||||
|
||||
.status-Open { color: #3b82f6; }
|
||||
.status-In-Progress { color: #f59e0b; }
|
||||
.status-Closed { color: #6b7280; text-decoration: line-through; }
|
||||
78
assets/js/main.js
Normal file
78
assets/js/main.js
Normal file
@ -0,0 +1,78 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const ticketForm = document.getElementById('ticketForm');
|
||||
const ticketList = document.getElementById('ticketList');
|
||||
|
||||
const fetchTickets = async () => {
|
||||
try {
|
||||
const response = await fetch('api/tickets.php');
|
||||
const tickets = await response.json();
|
||||
renderTickets(tickets);
|
||||
} catch (error) {
|
||||
console.error('Error fetching tickets:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const renderTickets = (tickets) => {
|
||||
ticketList.innerHTML = tickets.map(ticket => `
|
||||
<tr>
|
||||
<td><span class="text-muted">#${ticket.id}</span></td>
|
||||
<td class="fw-semibold">${escapeHtml(ticket.title)}</td>
|
||||
<td><span class="badge priority-${ticket.priority}">${ticket.priority}</span></td>
|
||||
<td><span class="fw-medium status-${ticket.status.replace(' ', '-')}">${ticket.status}</span></td>
|
||||
<td class="text-muted">${new Date(ticket.created_at).toLocaleDateString()}</td>
|
||||
<td class="text-end">
|
||||
<button class="btn btn-sm btn-link text-decoration-none p-0" onclick="viewDetails(${ticket.id})">View</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
};
|
||||
|
||||
const escapeHtml = (text) => {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
};
|
||||
|
||||
ticketForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(ticketForm);
|
||||
const data = Object.fromEntries(formData.entries());
|
||||
|
||||
try {
|
||||
const response = await fetch('api/tickets.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type: application/json' },
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
ticketForm.reset();
|
||||
const modal = bootstrap.Modal.getInstance(document.getElementById('createTicketModal'));
|
||||
modal.hide();
|
||||
fetchTickets();
|
||||
showNotification('Ticket created successfully');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error creating ticket:', error);
|
||||
}
|
||||
});
|
||||
|
||||
const showNotification = (message) => {
|
||||
// Simple toast or alert
|
||||
const toast = document.createElement('div');
|
||||
toast.className = 'position-fixed bottom-0 end-0 p-3';
|
||||
toast.style.zIndex = '1100';
|
||||
toast.innerHTML = `
|
||||
<div class="toast show align-items-center text-white bg-dark border-0" role="alert">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body">${message}</div>
|
||||
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.body.appendChild(toast);
|
||||
setTimeout(() => toast.remove(), 3000);
|
||||
};
|
||||
|
||||
fetchTickets();
|
||||
});
|
||||
8
db/migrations/001_create_tickets_table.sql
Normal file
8
db/migrations/001_create_tickets_table.sql
Normal file
@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS tickets (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
priority ENUM('Low', 'Medium', 'High') DEFAULT 'Medium',
|
||||
status ENUM('Open', 'In Progress', 'Closed') DEFAULT 'Open',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
232
index.php
232
index.php
@ -2,149 +2,109 @@
|
||||
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');
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Support Ticketing System';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<!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" />
|
||||
<title>Support Tickets</title>
|
||||
|
||||
<?php if ($projectDescription): ?>
|
||||
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<meta property="twitter:image" content="<?= 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;700&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>
|
||||
|
||||
<nav class="navbar navbar-expand-lg py-3 sticky-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand fw-bold text-dark" href="/">Tickets.</a>
|
||||
<div class="d-flex align-items-center">
|
||||
<button class="btn btn-primary d-flex align-items-center" data-bs-toggle="modal" data-bs-target="#createTicketModal">
|
||||
New Ticket
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
</nav>
|
||||
|
||||
<main class="container py-5">
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8">
|
||||
<h1 class="h4 fw-bold mb-1">Issue Overview</h1>
|
||||
<p class="text-muted small">Manage and track your support requests</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card bg-white">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="ps-4">ID</th>
|
||||
<th>Subject</th>
|
||||
<th>Priority</th>
|
||||
<th>Status</th>
|
||||
<th>Date Created</th>
|
||||
<th class="text-end pe-4">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="ticketList">
|
||||
<!-- Loaded via JS -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="createTicketModal" tabindex="-1">
|
||||
<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">Create New Ticket</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="ticketForm">
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-semibold">Title</label>
|
||||
<input type="text" name="title" class="form-control" placeholder="Brief summary of the issue" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-semibold">Priority</label>
|
||||
<select name="priority" class="form-select">
|
||||
<option value="Low">Low</option>
|
||||
<option value="Medium" selected>Medium</option>
|
||||
<option value="High">High</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-semibold">Description</label>
|
||||
<textarea name="description" class="form-control" rows="4" placeholder="Describe the problem in detail"></textarea>
|
||||
</div>
|
||||
<div class="d-grid pt-2">
|
||||
<button type="submit" class="btn btn-primary">Submit Ticket</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user