Initial commit of the Asset Management System, including project structure, Docker configuration, database migrations, and core application files. Added user authentication, asset management features, and basic UI components.
This commit is contained in:
14
database/migrations/001_create_users_table.sql
Normal file
14
database/migrations/001_create_users_table.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
role ENUM('admin', 'auditor', 'employee') NOT NULL DEFAULT 'employee',
|
||||
passhash VARCHAR(255) NOT NULL,
|
||||
active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
locale VARCHAR(5) NOT NULL DEFAULT 'de',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_email (email),
|
||||
INDEX idx_role (role),
|
||||
INDEX idx_active (active)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
10
database/migrations/002_create_password_resets_table.sql
Normal file
10
database/migrations/002_create_password_resets_table.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE password_resets (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
token VARCHAR(255) UNIQUE NOT NULL,
|
||||
expires_at TIMESTAMP NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
INDEX idx_token (token),
|
||||
INDEX idx_expires_at (expires_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
8
database/migrations/003_create_categories_table.sql
Normal file
8
database/migrations/003_create_categories_table.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE categories (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) UNIQUE NOT NULL,
|
||||
description TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_name (name)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
11
database/migrations/004_create_locations_table.sql
Normal file
11
database/migrations/004_create_locations_table.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE locations (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) UNIQUE NOT NULL,
|
||||
address TEXT,
|
||||
contact_person VARCHAR(255),
|
||||
contact_email VARCHAR(255),
|
||||
contact_phone VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_name (name)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
11
database/migrations/005_create_departments_table.sql
Normal file
11
database/migrations/005_create_departments_table.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE departments (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) UNIQUE NOT NULL,
|
||||
cost_center VARCHAR(50),
|
||||
manager VARCHAR(255),
|
||||
manager_email VARCHAR(255),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_name (name),
|
||||
INDEX idx_cost_center (cost_center)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
34
database/migrations/006_create_assets_table.sql
Normal file
34
database/migrations/006_create_assets_table.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
CREATE TABLE assets (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
inventarnummer VARCHAR(255) UNIQUE NOT NULL,
|
||||
bezeichnung VARCHAR(500) NOT NULL,
|
||||
kategorie_id INT,
|
||||
standort_id INT,
|
||||
abteilung_id INT,
|
||||
raum VARCHAR(100),
|
||||
lieferant VARCHAR(255),
|
||||
seriennummer VARCHAR(255),
|
||||
anschaffungsdatum DATE,
|
||||
anschaffungspreis DECIMAL(10,2),
|
||||
garantie_bis DATE,
|
||||
zustand ENUM('neu', 'gut', 'befriedigend', 'schlecht', 'defekt') DEFAULT 'gut',
|
||||
status ENUM('aktiv', 'inaktiv', 'ausgemustert') DEFAULT 'aktiv',
|
||||
kostenstelle VARCHAR(50),
|
||||
notizen TEXT,
|
||||
created_by INT,
|
||||
updated_by INT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (kategorie_id) REFERENCES categories(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (standort_id) REFERENCES locations(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (abteilung_id) REFERENCES departments(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_inventarnummer (inventarnummer),
|
||||
INDEX idx_kategorie_id (kategorie_id),
|
||||
INDEX idx_standort_id (standort_id),
|
||||
INDEX idx_status (status),
|
||||
INDEX idx_seriennummer (seriennummer),
|
||||
INDEX idx_anschaffungsdatum (anschaffungsdatum),
|
||||
INDEX idx_garantie_bis (garantie_bis)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
15
database/migrations/007_create_asset_assignments_table.sql
Normal file
15
database/migrations/007_create_asset_assignments_table.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE asset_assignments (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
asset_id INT NOT NULL,
|
||||
user_id INT NOT NULL,
|
||||
von DATE NOT NULL,
|
||||
bis DATE,
|
||||
kommentar TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (asset_id) REFERENCES assets(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
INDEX idx_asset_id (asset_id),
|
||||
INDEX idx_user_id (user_id),
|
||||
INDEX idx_von (von),
|
||||
INDEX idx_bis (bis)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
16
database/migrations/008_create_asset_files_table.sql
Normal file
16
database/migrations/008_create_asset_files_table.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE asset_files (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
asset_id INT NOT NULL,
|
||||
filename VARCHAR(255) NOT NULL,
|
||||
original_filename VARCHAR(255) NOT NULL,
|
||||
path VARCHAR(500) NOT NULL,
|
||||
mime VARCHAR(100) NOT NULL,
|
||||
size INT NOT NULL,
|
||||
uploaded_by INT,
|
||||
uploaded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (asset_id) REFERENCES assets(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (uploaded_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_asset_id (asset_id),
|
||||
INDEX idx_uploaded_by (uploaded_by),
|
||||
INDEX idx_uploaded_at (uploaded_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
15
database/migrations/009_create_inventories_table.sql
Normal file
15
database/migrations/009_create_inventories_table.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE inventories (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
started_by INT,
|
||||
started_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
closed_at TIMESTAMP NULL,
|
||||
status ENUM('offen', 'abgeschlossen') DEFAULT 'offen',
|
||||
kommentar TEXT,
|
||||
FOREIGN KEY (started_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_started_by (started_by),
|
||||
INDEX idx_status (status),
|
||||
INDEX idx_started_at (started_at),
|
||||
INDEX idx_closed_at (closed_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
19
database/migrations/010_create_inventory_items_table.sql
Normal file
19
database/migrations/010_create_inventory_items_table.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
CREATE TABLE inventory_items (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
inventory_id INT NOT NULL,
|
||||
asset_id INT NOT NULL,
|
||||
soll_status ENUM('aktiv', 'inaktiv', 'ausgemustert') NOT NULL,
|
||||
ist_status ENUM('gefunden', 'nicht_gefunden', 'defekt', 'verschoben') NOT NULL,
|
||||
checked_at TIMESTAMP NULL,
|
||||
checked_by INT,
|
||||
bemerkung TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (inventory_id) REFERENCES inventories(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (asset_id) REFERENCES assets(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (checked_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_inventory_id (inventory_id),
|
||||
INDEX idx_asset_id (asset_id),
|
||||
INDEX idx_checked_by (checked_by),
|
||||
INDEX idx_ist_status (ist_status),
|
||||
UNIQUE KEY unique_inventory_asset (inventory_id, asset_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
16
database/migrations/011_create_audit_log_table.sql
Normal file
16
database/migrations/011_create_audit_log_table.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE audit_log (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT,
|
||||
action VARCHAR(50) NOT NULL,
|
||||
table_name VARCHAR(100) NOT NULL,
|
||||
record_id INT NOT NULL,
|
||||
old_value JSON,
|
||||
new_value JSON,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_user_id (user_id),
|
||||
INDEX idx_action (action),
|
||||
INDEX idx_table_name (table_name),
|
||||
INDEX idx_record_id (record_id),
|
||||
INDEX idx_created_at (created_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
6
database/seeds/001_seed_users.sql
Normal file
6
database/seeds/001_seed_users.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
-- Insert default admin user
|
||||
-- Password: Admin!234 (will be changed on first login)
|
||||
INSERT INTO users (name, email, role, passhash, active, locale) VALUES
|
||||
('Administrator', 'admin@example.com', 'admin', '$argon2id$v=19$m=65536,t=4,p=1$dXNlcl9zYWx0$hashed_password_here', TRUE, 'de'),
|
||||
('Max Mustermann', 'max.mustermann@example.com', 'auditor', '$argon2id$v=19$m=65536,t=4,p=1$dXNlcl9zYWx0$hashed_password_here', TRUE, 'de'),
|
||||
('Anna Schmidt', 'anna.schmidt@example.com', 'employee', '$argon2id$v=19$m=65536,t=4,p=1$dXNlcl9zYWx0$hashed_password_here', TRUE, 'de');
|
||||
11
database/seeds/002_seed_categories.sql
Normal file
11
database/seeds/002_seed_categories.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
INSERT INTO categories (name, description) VALUES
|
||||
('Computer & Hardware', 'Desktop-Computer, Laptops, Server und Zubehör'),
|
||||
('Netzwerk & Kommunikation', 'Router, Switches, Telefone, WLAN-Geräte'),
|
||||
('Büroausstattung', 'Tische, Stühle, Schränke, Drucker'),
|
||||
('Software & Lizenzen', 'Betriebssysteme, Anwendungssoftware, Lizenzen'),
|
||||
('Fahrzeuge & Transport', 'Firmenwagen, Gabelstapler, Transportgeräte'),
|
||||
('Werkzeuge & Maschinen', 'Handwerkzeuge, Maschinen, Produktionsanlagen'),
|
||||
('Sicherheit & Überwachung', 'Kameras, Alarmanlagen, Zutrittskontrollen'),
|
||||
('Möbel & Einrichtung', 'Büromöbel, Einrichtungsgegenstände'),
|
||||
('Elektronik & Unterhaltung', 'TV-Geräte, Audio-Systeme, Präsentationstechnik'),
|
||||
('Sonstiges', 'Verschiedene andere Anlagen und Gegenstände');
|
||||
6
database/seeds/003_seed_locations.sql
Normal file
6
database/seeds/003_seed_locations.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
INSERT INTO locations (name, address, contact_person, contact_email, contact_phone) VALUES
|
||||
('Hauptsitz - Gebäude A', 'Musterstraße 1, 12345 Musterstadt', 'Peter Müller', 'peter.mueller@example.com', '+49 123 456789'),
|
||||
('Niederlassung - Gebäude B', 'Beispielweg 15, 54321 Beispielort', 'Maria Weber', 'maria.weber@example.com', '+49 987 654321'),
|
||||
('Lager - Gebäude C', 'Industriepark 7, 67890 Industriestadt', 'Hans Schmidt', 'hans.schmidt@example.com', '+49 555 123456'),
|
||||
('Außenstelle Nord', 'Nordstraße 42, 11111 Nordstadt', 'Lisa Fischer', 'lisa.fischer@example.com', '+49 111 222333'),
|
||||
('Außenstelle Süd', 'Südallee 8, 99999 Südstadt', 'Tom Wagner', 'tom.wagner@example.com', '+49 999 888777');
|
||||
11
database/seeds/004_seed_departments.sql
Normal file
11
database/seeds/004_seed_departments.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
INSERT INTO departments (name, cost_center, manager, manager_email) VALUES
|
||||
('Geschäftsführung', 'GF-001', 'Dr. Michael Bauer', 'michael.bauer@example.com'),
|
||||
('IT & Systemadministration', 'IT-001', 'Sarah Klein', 'sarah.klein@example.com'),
|
||||
('Buchhaltung & Finanzen', 'BU-001', 'Frank Meyer', 'frank.meyer@example.com'),
|
||||
('Personal & Verwaltung', 'PE-001', 'Claudia Schulz', 'claudia.schulz@example.com'),
|
||||
('Vertrieb & Marketing', 'VM-001', 'Andreas Wolf', 'andreas.wolf@example.com'),
|
||||
('Produktion & Fertigung', 'PR-001', 'Robert Koch', 'robert.koch@example.com'),
|
||||
('Einkauf & Logistik', 'EL-001', 'Petra Lange', 'petra.lange@example.com'),
|
||||
('Forschung & Entwicklung', 'FE-001', 'Dr. Thomas Richter', 'thomas.richter@example.com'),
|
||||
('Kundenservice', 'KS-001', 'Nina Becker', 'nina.becker@example.com'),
|
||||
('Qualitätssicherung', 'QS-001', 'Markus Hoffmann', 'markus.hoffmann@example.com');
|
||||
11
database/seeds/005_seed_sample_assets.sql
Normal file
11
database/seeds/005_seed_sample_assets.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
INSERT INTO assets (inventarnummer, bezeichnung, kategorie_id, standort_id, abteilung_id, raum, lieferant, seriennummer, anschaffungsdatum, anschaffungspreis, garantie_bis, zustand, status, kostenstelle, notizen, created_by) VALUES
|
||||
('PC-2024-001', 'Dell OptiPlex 7090 Desktop Computer', 1, 1, 2, 'Büro 101', 'Dell Technologies', 'SN123456789', '2024-01-15', 899.00, '2027-01-15', 'neu', 'aktiv', 'IT-001', 'Standard-Arbeitsplatz', 1),
|
||||
('PC-2024-002', 'HP EliteBook 840 G8 Laptop', 1, 1, 2, 'Büro 102', 'HP Inc.', 'SN987654321', '2024-02-01', 1299.00, '2027-02-01', 'neu', 'aktiv', 'IT-001', 'Mobiler Arbeitsplatz', 1),
|
||||
('NET-2024-001', 'Cisco Catalyst 2960 Switch', 2, 1, 2, 'Serverraum', 'Cisco Systems', 'SN456789123', '2024-01-10', 450.00, '2027-01-10', 'neu', 'aktiv', 'IT-001', '24-Port Switch', 1),
|
||||
('BÜRO-2024-001', 'Herman Miller Aeron Bürostuhl', 3, 1, 4, 'Büro 103', 'Herman Miller', 'SN789123456', '2024-03-01', 850.00, '2027-03-01', 'neu', 'aktiv', 'PE-001', 'Ergonomischer Bürostuhl', 1),
|
||||
('SW-2024-001', 'Microsoft Office 365 Business Premium', 4, 1, 2, 'Virtuell', 'Microsoft', 'LIC-2024-001', '2024-01-01', 12.50, '2025-01-01', 'neu', 'aktiv', 'IT-001', 'Jährliche Lizenz', 1),
|
||||
('FAHR-2024-001', 'VW Passat Variant Firmenwagen', 5, 1, 1, 'Parkplatz A1', 'Volkswagen AG', 'SN111222333', '2024-01-20', 35000.00, '2027-01-20', 'neu', 'aktiv', 'GF-001', 'Geschäftsführer', 1),
|
||||
('WERK-2024-001', 'Bosch Professional Bohrmaschine', 6, 3, 6, 'Werkstatt', 'Bosch', 'SN444555666', '2024-02-15', 89.00, '2026-02-15', 'neu', 'aktiv', 'PR-001', 'Werkstattausstattung', 1),
|
||||
('SICH-2024-001', 'Hikvision IP-Kamera', 7, 1, 2, 'Eingang', 'Hikvision', 'SN777888999', '2024-01-05', 120.00, '2027-01-05', 'neu', 'aktiv', 'IT-001', 'Überwachungskamera', 1),
|
||||
('MÖB-2024-001', 'IKEA BEKANT Schreibtisch', 8, 1, 4, 'Büro 104', 'IKEA', 'SN000111222', '2024-03-10', 199.00, '2027-03-10', 'neu', 'aktiv', 'PE-001', 'Standard-Schreibtisch', 1),
|
||||
('ELEK-2024-001', 'Samsung 55" Smart TV', 9, 1, 5, 'Konferenzraum', 'Samsung Electronics', 'SN333444555', '2024-02-20', 599.00, '2027-02-20', 'neu', 'aktiv', 'VM-001', 'Präsentationstechnik', 1);
|
||||
Reference in New Issue
Block a user