1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-10 18:08:36 +02:00
parent db8f07a192
commit 4078440633
2 changed files with 426 additions and 44 deletions

View file

@ -144,7 +144,7 @@ function openInfoPointMenu()
if jobPermissions.showLicenseInfo then
table.insert(menuOptions, {
title = 'Lizenz Informationen',
description = 'Informationen zu verfügbaren Lizenzen',
description = jobPermissions.canManageLicenses and 'Lizenz-Informationen anzeigen und verwalten' or 'Informationen zu verfügbaren Lizenzen',
icon = 'id-card',
onSelect = function()
showLicenseInfo()
@ -235,10 +235,15 @@ end
-- Event erstellen Dialog
function createEventDialog()
local categoryOptions = {}
for _, category in pairs(Config.EventCategories) do
table.insert(categoryOptions, {value = category, label = category})
end
local input = lib.inputDialog('Event erstellen', {
{type = 'input', label = 'Titel', required = true, max = 100},
{type = 'textarea', label = 'Beschreibung', max = 500},
{type = 'select', label = 'Kategorie', options = Config.EventCategories, required = true},
{type = 'select', label = 'Kategorie', options = categoryOptions, required = true},
{type = 'input', label = 'Ort', max = 100},
{type = 'date', label = 'Datum', required = true},
{type = 'time', label = 'Uhrzeit', required = true}
@ -333,10 +338,15 @@ end
-- Vorfall melden Dialog
function reportIncidentDialog()
local categoryOptions = {}
for _, category in pairs(Config.IncidentCategories) do
table.insert(categoryOptions, {value = category, label = category})
end
local input = lib.inputDialog('Vorfall melden', {
{type = 'input', label = 'Titel', required = true, max = 100},
{type = 'textarea', label = 'Beschreibung', required = true, max = 500},
{type = 'select', label = 'Kategorie', options = Config.IncidentCategories, required = true},
{type = 'select', label = 'Kategorie', options = categoryOptions, required = true},
{type = 'input', label = 'Ort', max = 100}
})
@ -394,16 +404,25 @@ function showJobOffers()
})
lib.showContext('infopoint_job_offers')
end, nil)
end, job)
end
-- Job-Angebot Details anzeigen
function showJobOfferDetails(offer)
local createdDate = os.date('%d.%m.%Y %H:%M', os.time({
year = tonumber(string.sub(offer.created_at, 1, 4)),
month = tonumber(string.sub(offer.created_at, 6, 7)),
day = tonumber(string.sub(offer.created_at, 9, 10)),
hour = tonumber(string.sub(offer.created_at, 12, 13)),
min = tonumber(string.sub(offer.created_at, 15, 16))
}))
lib.alertDialog({
header = offer.title,
content = 'Job: ' .. offer.job_name .. '\n\n' ..
'Gehalt: ' .. (offer.salary or 'Verhandelbar') .. '\n\n' ..
'Kontakt: ' .. (offer.contact or 'Nicht angegeben') .. '\n\n' ..
'Erstellt am: ' .. createdDate .. '\n\n' ..
'Anforderungen:\n' .. (offer.requirements or 'Keine besonderen Anforderungen') .. '\n\n' ..
'Beschreibung:\n' .. (offer.description or 'Keine Beschreibung verfügbar'),
centered = true,
@ -417,8 +436,8 @@ function createJobOfferDialog()
{type = 'input', label = 'Titel', required = true, max = 100},
{type = 'textarea', label = 'Beschreibung', max = 500},
{type = 'textarea', label = 'Anforderungen', max = 300},
{type = 'input', label = 'Gehalt', max = 50},
{type = 'input', label = 'Kontakt', max = 100}
{type = 'input', label = 'Gehalt', placeholder = 'z.B. $2500/Woche', max = 50},
{type = 'input', label = 'Kontakt', placeholder = 'Telefonnummer oder Name', max = 100}
})
if input then
@ -437,40 +456,213 @@ end
-- Lizenz Informationen anzeigen
function showLicenseInfo()
QBCore.Functions.TriggerCallback('infopoint:getLicenseInfo', function(licenses)
local licenseOptions = {}
if #licenses == 0 then
table.insert(licenseOptions, {
title = 'Keine Informationen verfügbar',
description = 'Du hast keine Berechtigung diese Informationen zu sehen',
icon = 'info'
})
else
for _, license in pairs(licenses) do
QBCore.Functions.TriggerCallback('infopoint:canManageLicenses', function(canManage)
local licenseOptions = {}
if #licenses == 0 then
table.insert(licenseOptions, {
title = license.type,
description = 'Preis: ' .. license.price .. '\nAnforderungen: ' .. license.requirements,
icon = 'id-card'
title = 'Keine Lizenz-Informationen verfügbar',
description = 'Derzeit sind keine Lizenz-Informationen hinterlegt',
icon = 'info'
})
else
for _, license in pairs(licenses) do
table.insert(licenseOptions, {
title = license.license_type,
description = 'Preis: ' .. (license.price or 'Nicht angegeben') .. '\nBearbeitungszeit: ' .. (license.processing_time or 'Nicht angegeben'),
icon = 'id-card',
onSelect = function()
showLicenseDetails(license, canManage)
end
})
end
end
-- Management-Optionen für berechtigte Jobs
if canManage then
table.insert(licenseOptions, {
title = ' Neue Lizenz-Information hinzufügen',
description = 'Neue Lizenz-Information erstellen',
icon = 'plus',
onSelect = function()
createLicenseInfoDialog()
end
})
end
end
table.insert(licenseOptions, {
title = '← Zurück',
icon = 'arrow-left',
table.insert(licenseOptions, {
title = '← Zurück',
icon = 'arrow-left',
onSelect = function()
openInfoPointMenu()
end
})
lib.registerContext({
id = 'infopoint_licenses',
title = 'Lizenz Informationen',
options = licenseOptions
})
lib.showContext('infopoint_licenses')
end)
end)
end
-- Lizenz Details anzeigen
function showLicenseDetails(license, canManage)
local menuOptions = {
{
title = 'Details anzeigen',
description = 'Vollständige Informationen anzeigen',
icon = 'info',
onSelect = function()
openInfoPointMenu()
lib.alertDialog({
header = license.license_type,
content = 'Preis: ' .. (license.price or 'Nicht angegeben') .. '\n\n' ..
'Bearbeitungszeit: ' .. (license.processing_time or 'Nicht angegeben') .. '\n\n' ..
'Gültigkeitsdauer: ' .. (license.valid_duration or 'Nicht angegeben') .. '\n\n' ..
'Anforderungen:\n' .. (license.requirements or 'Keine Anforderungen angegeben') .. '\n\n' ..
'Beschreibung:\n' .. (license.description or 'Keine Beschreibung verfügbar'),
centered = true,
cancel = true
})
end
}
}
if canManage then
table.insert(menuOptions, {
title = '✏️ Bearbeiten',
description = 'Lizenz-Information bearbeiten',
icon = 'edit',
onSelect = function()
editLicenseInfoDialog(license)
end
})
lib.registerContext({
id = 'infopoint_licenses',
title = 'Lizenz Informationen',
options = licenseOptions
table.insert(menuOptions, {
title = '🗑️ Löschen',
description = 'Lizenz-Information löschen',
icon = 'trash',
onSelect = function()
lib.alertDialog({
header = 'Lizenz-Information löschen',
content = 'Bist du sicher, dass du die Lizenz-Information für "' .. license.license_type .. '" löschen möchtest?',
centered = true,
cancel = true,
labels = {
cancel = 'Abbrechen',
confirm = 'Löschen'
}
}, function(confirmed)
if confirmed then
TriggerServerEvent('infopoint:deleteLicenseInfo', license.id)
Wait(500)
showLicenseInfo() -- Zurück zur Übersicht
end
end)
end
})
end
table.insert(menuOptions, {
title = '← Zurück',
icon = 'arrow-left',
onSelect = function()
showLicenseInfo()
end
})
lib.registerContext({
id = 'license_details',
title = license.license_type,
options = menuOptions
})
lib.showContext('license_details')
end
-- Lizenz-Information erstellen Dialog
function createLicenseInfoDialog()
local licenseTypeOptions = {}
for _, licenseType in pairs(Config.DefaultLicenseTypes) do
table.insert(licenseTypeOptions, {value = licenseType, label = licenseType})
end
table.insert(licenseTypeOptions, {value = 'custom', label = 'Benutzerdefiniert'})
local input = lib.inputDialog('Lizenz-Information erstellen', {
{type = 'select', label = 'Lizenz-Typ', options = licenseTypeOptions, required = true},
{type = 'input', label = 'Benutzerdefinierter Typ (falls ausgewählt)', max = 100},
{type = 'input', label = 'Preis', placeholder = 'z.B. $500', max = 50},
{type = 'textarea', label = 'Anforderungen', max = 500},
{type = 'textarea', label = 'Beschreibung', max = 500},
{type = 'input', label = 'Bearbeitungszeit', placeholder = 'z.B. 1-2 Werktage', max = 100},
{type = 'input', label = 'Gültigkeitsdauer', placeholder = 'z.B. 5 Jahre', max = 100}
})
if input then
local licenseType = input[1] == 'custom' and input[2] or input[1]
lib.showContext('infopoint_licenses')
end)
if not licenseType or licenseType == '' then
QBCore.Functions.Notify('Bitte gib einen Lizenz-Typ an!', 'error')
return
end
local licenseData = {
license_type = licenseType,
price = input[3],
requirements = input[4],
description = input[5],
processing_time = input[6],
valid_duration = input[7]
}
TriggerServerEvent('infopoint:createLicenseInfo', licenseData)
Wait(500)
showLicenseInfo() -- Zurück zur Übersicht
end
end
-- Lizenz-Information bearbeiten Dialog
function editLicenseInfoDialog(license)
local licenseTypeOptions = {}
for _, licenseType in pairs(Config.DefaultLicenseTypes) do
table.insert(licenseTypeOptions, {value = licenseType, label = licenseType})
end
table.insert(licenseTypeOptions, {value = 'custom', label = 'Benutzerdefiniert'})
local input = lib.inputDialog('Lizenz-Information bearbeiten', {
{type = 'select', label = 'Lizenz-Typ', options = licenseTypeOptions, required = true, default = license.license_type},
{type = 'input', label = 'Benutzerdefinierter Typ (falls ausgewählt)', max = 100},
{type = 'input', label = 'Preis', placeholder = 'z.B. $500', max = 50, default = license.price},
{type = 'textarea', label = 'Anforderungen', max = 500, default = license.requirements},
{type = 'textarea', label = 'Beschreibung', max = 500, default = license.description},
{type = 'input', label = 'Bearbeitungszeit', placeholder = 'z.B. 1-2 Werktage', max = 100, default = license.processing_time},
{type = 'input', label = 'Gültigkeitsdauer', placeholder = 'z.B. 5 Jahre', max = 100, default = license.valid_duration}
})
if input then
local licenseType = input[1] == 'custom' and input[2] or input[1]
if not licenseType or licenseType == '' then
QBCore.Functions.Notify('Bitte gib einen Lizenz-Typ an!', 'error')
return
end
local licenseData = {
license_type = licenseType,
price = input[3],
requirements = input[4],
description = input[5],
processing_time = input[6],
valid_duration = input[7]
}
TriggerServerEvent('infopoint:updateLicenseInfo', license.id, licenseData)
Wait(500)
showLicenseInfo() -- Zurück zur Übersicht
end
end
-- Hilfsfunktion für table.contains
@ -483,7 +675,8 @@ function table.contains(table, element)
return false
end
-- Event Listener für Daten-Refresh
-- Event für Daten-Refresh
RegisterNetEvent('infopoint:refreshData', function()
-- Hier könntest du lokale Daten aktualisieren wenn nötig
-- Hier könnten wir bei Bedarf Daten neu laden
end)

View file

@ -46,6 +46,84 @@ CreateThread(function()
active BOOLEAN DEFAULT TRUE
)
]])
-- Neue Tabelle für Lizenz-Informationen
MySQL.query([[
CREATE TABLE IF NOT EXISTS infopoint_license_info (
id INT AUTO_INCREMENT PRIMARY KEY,
license_type VARCHAR(100) NOT NULL,
price VARCHAR(50),
requirements TEXT,
description TEXT,
processing_time VARCHAR(100),
valid_duration VARCHAR(100),
created_by VARCHAR(50),
updated_by VARCHAR(50),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
active BOOLEAN DEFAULT TRUE
)
]])
-- Standard Lizenz-Informationen einfügen falls nicht vorhanden
MySQL.query('SELECT COUNT(*) as count FROM infopoint_license_info', {}, function(result)
if result[1].count == 0 then
local defaultLicenses = {
{
license_type = 'Führerschein',
price = '$500',
requirements = 'Mindestalter 18 Jahre, Theorieprüfung bestehen, Praktische Prüfung bestehen',
description = 'Berechtigt zum Führen von PKW und leichten Nutzfahrzeugen',
processing_time = '1-2 Werktage',
valid_duration = 'Unbegrenzt'
},
{
license_type = 'Waffenschein',
price = '$2000',
requirements = 'Saubere Akte, Psychologisches Gutachten, Waffenprüfung bestehen, Mindestalter 21 Jahre',
description = 'Berechtigt zum Führen von Schusswaffen',
processing_time = '2-4 Wochen',
valid_duration = '5 Jahre'
},
{
license_type = 'Pilotenschein',
price = '$10000',
requirements = 'Flugstunden nachweisen, Medizinische Untersuchung, Theorieprüfung, Praktische Prüfung',
description = 'Berechtigt zum Führen von Luftfahrzeugen',
processing_time = '4-8 Wochen',
valid_duration = '2 Jahre'
},
{
license_type = 'Motorradführerschein',
price = '$750',
requirements = 'Mindestalter 18 Jahre, Theorieprüfung bestehen, Praktische Prüfung bestehen',
description = 'Berechtigt zum Führen von Motorrädern',
processing_time = '1-2 Werktage',
valid_duration = 'Unbegrenzt'
},
{
license_type = 'Bootslizenz',
price = '$1500',
requirements = 'Mindestalter 16 Jahre, Theorieprüfung bestehen, Praktische Prüfung bestehen',
description = 'Berechtigt zum Führen von Wasserfahrzeugen',
processing_time = '3-5 Werktage',
valid_duration = '10 Jahre'
}
}
for _, license in pairs(defaultLicenses) do
MySQL.insert('INSERT INTO infopoint_license_info (license_type, price, requirements, description, processing_time, valid_duration, created_by) VALUES (?, ?, ?, ?, ?, ?, ?)', {
license.license_type,
license.price,
license.requirements,
license.description,
license.processing_time,
license.valid_duration,
'system'
})
end
end
end)
end)
-- Events abrufen
@ -89,21 +167,27 @@ end)
-- Lizenz Informationen abrufen
QBCore.Functions.CreateCallback('infopoint:getLicenseInfo', function(source, cb)
MySQL.query('SELECT * FROM infopoint_license_info WHERE active = 1 ORDER BY license_type ASC', {}, function(result)
cb(result)
end)
end)
-- Prüfen ob Spieler Lizenz-Informationen verwalten kann
QBCore.Functions.CreateCallback('infopoint:canManageLicenses', function(source, cb)
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return cb({}) end
if not Player then return cb(false) end
local job = Player.PlayerData.job.name
if job == 'police' then
-- Hier könntest du Lizenz-Informationen aus der Datenbank abrufen
local licenseInfo = {
{type = 'Führerschein', price = '$500', requirements = 'Theorieprüfung bestehen'},
{type = 'Waffenschein', price = '$2000', requirements = 'Saubere Akte, Prüfung'},
{type = 'Pilotenschein', price = '$10000', requirements = 'Flugstunden nachweisen'}
}
cb(licenseInfo)
else
cb({})
local canManage = false
for _, allowedJob in pairs(Config.JobPermissions.canManageLicenses) do
if job == allowedJob then
canManage = true
break
end
end
cb(canManage)
end)
-- Event erstellen
@ -206,3 +290,108 @@ RegisterNetEvent('infopoint:createJobOffer', function(jobData)
end
end)
end)
-- Lizenz-Information erstellen
RegisterNetEvent('infopoint:createLicenseInfo', function(licenseData)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local job = Player.PlayerData.job.name
local canManage = false
for _, allowedJob in pairs(Config.JobPermissions.canManageLicenses) do
if job == allowedJob then
canManage = true
break
end
end
if not canManage then
TriggerClientEvent('QBCore:Notify', src, 'Du hast keine Berechtigung Lizenz-Informationen zu verwalten!', 'error')
return
end
MySQL.insert('INSERT INTO infopoint_license_info (license_type, price, requirements, description, processing_time, valid_duration, created_by) VALUES (?, ?, ?, ?, ?, ?, ?)', {
licenseData.license_type,
licenseData.price,
licenseData.requirements,
licenseData.description,
licenseData.processing_time,
licenseData.valid_duration,
Player.PlayerData.citizenid
}, function(insertId)
if insertId then
TriggerClientEvent('QBCore:Notify', src, 'Lizenz-Information erfolgreich erstellt!', 'success')
end
end)
end)
-- Lizenz-Information bearbeiten
RegisterNetEvent('infopoint:updateLicenseInfo', function(licenseId, licenseData)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local job = Player.PlayerData.job.name
local canManage = false
for _, allowedJob in pairs(Config.JobPermissions.canManageLicenses) do
if job == allowedJob then
canManage = true
break
end
end
if not canManage then
TriggerClientEvent('QBCore:Notify', src, 'Du hast keine Berechtigung Lizenz-Informationen zu verwalten!', 'error')
return
end
MySQL.update('UPDATE infopoint_license_info SET license_type = ?, price = ?, requirements = ?, description = ?, processing_time = ?, valid_duration = ?, updated_by = ? WHERE id = ?', {
licenseData.license_type,
licenseData.price,
licenseData.requirements,
licenseData.description,
licenseData.processing_time,
licenseData.valid_duration,
Player.PlayerData.citizenid,
licenseId
}, function(affectedRows)
if affectedRows > 0 then
TriggerClientEvent('QBCore:Notify', src, 'Lizenz-Information erfolgreich aktualisiert!', 'success')
else
TriggerClientEvent('QBCore:Notify', src, 'Fehler beim Aktualisieren der Lizenz-Information!', 'error')
end
end)
end)
-- Lizenz-Information löschen
RegisterNetEvent('infopoint:deleteLicenseInfo', function(licenseId)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local job = Player.PlayerData.job.name
local canManage = false
for _, allowedJob in pairs(Config.JobPermissions.canManageLicenses) do
if job == allowedJob then
canManage = true
break
end
end
if not canManage then
TriggerClientEvent('QBCore:Notify', src, 'Du hast keine Berechtigung Lizenz-Informationen zu verwalten!', 'error')
return
end
MySQL.update('UPDATE infopoint_license_info SET active = 0 WHERE id = ?', {licenseId}, function(affectedRows)
if affectedRows > 0 then
TriggerClientEvent('QBCore:Notify', src, 'Lizenz-Information erfolgreich gelöscht!', 'success')
else
TriggerClientEvent('QBCore:Notify', src, 'Fehler beim Löschen der Lizenz-Information!', 'error')
end
end)
end)