From 8d5d2597c6c5fa7ad291be12f9dd9222c3ceebfc Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sat, 14 Feb 2026 23:14:09 +0000 Subject: [PATCH] V1.0001 --- api/tickets.php | 34 +++ assets/css/custom.css | 70 +++++++ assets/js/main.js | 78 +++++++ db/migrations/001_create_tickets_table.sql | 8 + index.php | 232 +++++++++------------ 5 files changed, 286 insertions(+), 136 deletions(-) create mode 100644 api/tickets.php create mode 100644 assets/css/custom.css create mode 100644 assets/js/main.js create mode 100644 db/migrations/001_create_tickets_table.sql diff --git a/api/tickets.php b/api/tickets.php new file mode 100644 index 0000000..c6c2771 --- /dev/null +++ b/api/tickets.php @@ -0,0 +1,34 @@ +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()]); +} diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..f38a369 --- /dev/null +++ b/assets/css/custom.css @@ -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; } diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..3a40485 --- /dev/null +++ b/assets/js/main.js @@ -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 => ` + + #${ticket.id} + ${escapeHtml(ticket.title)} + ${ticket.priority} + ${ticket.status} + ${new Date(ticket.created_at).toLocaleDateString()} + + + + + `).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 = ` + + `; + document.body.appendChild(toast); + setTimeout(() => toast.remove(), 3000); + }; + + fetchTickets(); +}); diff --git a/db/migrations/001_create_tickets_table.sql b/db/migrations/001_create_tickets_table.sql new file mode 100644 index 0000000..ce96ff8 --- /dev/null +++ b/db/migrations/001_create_tickets_table.sql @@ -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 +); diff --git a/index.php b/index.php index 7205f3d..8b4583f 100644 --- a/index.php +++ b/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'] ?? ''; ?> - - - New Style - - - - - - - - - - - - - - - - - - - + + + Support Tickets + + + + + + + + + + + + + + -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

+ +
- + + +
+
+
+

Issue Overview

+

Manage and track your support requests

+
+
+ +
+
+ + + + + + + + + + + + + + +
IDSubjectPriorityStatusDate CreatedActions
+
+
+
+ + + + + +