forked from Simnation/Main
ed
This commit is contained in:
parent
db8f07a192
commit
4078440633
2 changed files with 426 additions and 44 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue