mirror of
https://github.com/Alvin-Zilverstand/Spik-en-span.git
synced 2026-03-06 21:36:31 +01:00
updae
This commit is contained in:
18
database.sql
18
database.sql
@@ -1,8 +1,8 @@
|
|||||||
-- Create the database
|
|
||||||
CREATE DATABASE IF NOT EXISTS spik_en_span;
|
CREATE DATABASE IF NOT EXISTS spik_en_span;
|
||||||
USE spik_en_span;
|
USE spik_en_span;
|
||||||
|
|
||||||
-- Table for storing ticket information
|
|
||||||
CREATE TABLE tickets (
|
CREATE TABLE tickets (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
ticket_id VARCHAR(255) NOT NULL UNIQUE,
|
ticket_id VARCHAR(255) NOT NULL UNIQUE,
|
||||||
@@ -13,15 +13,15 @@ CREATE TABLE tickets (
|
|||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Table for storing employee login credentials
|
|
||||||
CREATE TABLE employees (
|
CREATE TABLE employees (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
username VARCHAR(255) NOT NULL UNIQUE,
|
username VARCHAR(255) NOT NULL UNIQUE,
|
||||||
password_hash VARCHAR(255) NOT NULL, -- Store hashed passwords
|
password_hash VARCHAR(255) NOT NULL,
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Table for storing scanned ticket logs
|
|
||||||
CREATE TABLE scanned_tickets (
|
CREATE TABLE scanned_tickets (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
ticket_id VARCHAR(255) NOT NULL,
|
ticket_id VARCHAR(255) NOT NULL,
|
||||||
@@ -30,7 +30,7 @@ CREATE TABLE scanned_tickets (
|
|||||||
UNIQUE (ticket_id)
|
UNIQUE (ticket_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Table for storing unique strings for users
|
|
||||||
CREATE TABLE unique_strings (
|
CREATE TABLE unique_strings (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
user_id INT NOT NULL,
|
user_id INT NOT NULL,
|
||||||
@@ -39,7 +39,7 @@ CREATE TABLE unique_strings (
|
|||||||
FOREIGN KEY (user_id) REFERENCES employees(id) ON DELETE CASCADE
|
FOREIGN KEY (user_id) REFERENCES employees(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Trigger to automatically generate a unique 6-character alphanumeric string for each user
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE TRIGGER generate_unique_code
|
CREATE TRIGGER generate_unique_code
|
||||||
AFTER INSERT ON employees
|
AFTER INSERT ON employees
|
||||||
@@ -51,6 +51,6 @@ BEGIN
|
|||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
-- Insert a default employee account (username: admin, password: password)
|
|
||||||
INSERT INTO employees (username, password_hash)
|
INSERT INTO employees (username, password_hash)
|
||||||
VALUES ('admin', SHA2('password', 256)); -- Replace with a secure password hashing method
|
VALUES ('admin', SHA2('password', 256));
|
||||||
|
|||||||
@@ -32,10 +32,10 @@
|
|||||||
const username = document.getElementById('username').value;
|
const username = document.getElementById('username').value;
|
||||||
const password = document.getElementById('password').value;
|
const password = document.getElementById('password').value;
|
||||||
|
|
||||||
// Placeholder for authentication logic
|
|
||||||
if (username === 'admin' && password === 'password') {
|
if (username === 'admin' && password === 'password') {
|
||||||
alert('Succesvol ingelogd!');
|
alert('Succesvol ingelogd!');
|
||||||
window.location.href = 'qr-scanner.html'; // Redirect to QR scanner page
|
window.location.href = 'qr-scanner.html';
|
||||||
} else {
|
} else {
|
||||||
alert('Ongeldige inloggegevens.');
|
alert('Ongeldige inloggegevens.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ document.getElementById('ticketForm').addEventListener('submit', function (e) {
|
|||||||
const category = document.getElementById('ticketCategory').value;
|
const category = document.getElementById('ticketCategory').value;
|
||||||
const quantity = document.getElementById('ticketQuantity').value;
|
const quantity = document.getElementById('ticketQuantity').value;
|
||||||
|
|
||||||
// Generate a unique ticket ID (for simplicity, using timestamp)
|
|
||||||
const ticketId = `TICKET-${Date.now()}`;
|
const ticketId = `TICKET-${Date.now()}`;
|
||||||
|
|
||||||
// Generate QR code content
|
|
||||||
const qrContent = `Name: ${name}, Email: ${email}, Category: ${category}, Quantity: ${quantity}, Ticket ID: ${ticketId}`;
|
const qrContent = `Name: ${name}, Email: ${email}, Category: ${category}, Quantity: ${quantity}, Ticket ID: ${ticketId}`;
|
||||||
|
|
||||||
// Display QR code (using a library like QRCode.js)
|
|
||||||
const qrCodeContainer = document.getElementById('qrCodeContainer');
|
const qrCodeContainer = document.getElementById('qrCodeContainer');
|
||||||
qrCodeContainer.innerHTML = ''; // Clear previous QR code
|
qrCodeContainer.innerHTML = '';
|
||||||
const qrCode = new QRCode(qrCodeContainer, {
|
const qrCode = new QRCode(qrCodeContainer, {
|
||||||
text: qrContent,
|
text: qrContent,
|
||||||
width: 200,
|
width: 200,
|
||||||
|
|||||||
Reference in New Issue
Block a user