ed
This commit is contained in:
parent
2fe7be05aa
commit
12740ce5d5
2 changed files with 246 additions and 57 deletions
|
@ -45,7 +45,7 @@ function OpenCreateBillMenu()
|
|||
if cooldown then
|
||||
lib.notify({
|
||||
title = 'Billing System',
|
||||
description = 'Please wait before using the billing system again',
|
||||
description = 'Bitte warte, bevor du das Abrechnungssystem erneut verwendest',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
|
@ -56,7 +56,7 @@ function OpenCreateBillMenu()
|
|||
if #players == 0 then
|
||||
lib.notify({
|
||||
title = 'Billing System',
|
||||
description = 'No players nearby to bill',
|
||||
description = 'Keine Spieler in der Nähe zum Abrechnen',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
|
@ -69,7 +69,7 @@ function OpenCreateBillMenu()
|
|||
-- Add default bank account
|
||||
table.insert(accountOptions, {
|
||||
value = 'personal',
|
||||
label = 'Personal Bank Account'
|
||||
label = 'Persönliches Bankkonto'
|
||||
})
|
||||
|
||||
-- Add other accounts
|
||||
|
@ -97,7 +97,7 @@ function OpenCreateBillMenu()
|
|||
-- Register and show the player selection menu
|
||||
lib.registerContext({
|
||||
id = 'nearby_players_menu',
|
||||
title = 'Select Player to Bill',
|
||||
title = 'Spieler zum Abrechnen auswählen',
|
||||
menu = 'main_billing_menu', -- Add back button to main menu
|
||||
options = playerOptions
|
||||
})
|
||||
|
@ -107,11 +107,11 @@ end
|
|||
|
||||
-- Function to show the billing form after selecting a player
|
||||
function ShowBillingForm(selectedPlayer, accountOptions)
|
||||
local input = lib.inputDialog('Create Bill for ' .. selectedPlayer.name, {
|
||||
local input = lib.inputDialog('Rechnung erstellen für ' .. selectedPlayer.name, {
|
||||
{
|
||||
type = 'number',
|
||||
label = 'Amount ($)',
|
||||
description = 'Enter the bill amount',
|
||||
label = 'Betrag ($)',
|
||||
description = 'Gib den Rechnungsbetrag ein',
|
||||
icon = 'dollar-sign',
|
||||
required = true,
|
||||
min = 1,
|
||||
|
@ -119,14 +119,14 @@ function ShowBillingForm(selectedPlayer, accountOptions)
|
|||
},
|
||||
{
|
||||
type = 'input',
|
||||
label = 'Reason',
|
||||
description = 'Enter the reason for the bill',
|
||||
placeholder = 'Services provided...',
|
||||
label = 'Grund',
|
||||
description = 'Gib den Grund für die Rechnung ein',
|
||||
placeholder = 'Erbrachte Dienstleistungen...',
|
||||
required = true
|
||||
},
|
||||
{
|
||||
type = 'select',
|
||||
label = 'Receiving Account',
|
||||
label = 'Empfangskonto',
|
||||
options = accountOptions,
|
||||
required = true
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ function ShowBillingForm(selectedPlayer, accountOptions)
|
|||
if success then
|
||||
lib.notify({
|
||||
title = 'Billing System',
|
||||
description = 'Bill sent successfully to ' .. selectedPlayer.name,
|
||||
description = 'Rechnung erfolgreich an ' .. selectedPlayer.name .. ' gesendet',
|
||||
type = 'success'
|
||||
})
|
||||
|
||||
|
@ -163,7 +163,7 @@ function ShowBillingForm(selectedPlayer, accountOptions)
|
|||
else
|
||||
lib.notify({
|
||||
title = 'Billing System',
|
||||
description = 'Failed to send bill',
|
||||
description = 'Fehler beim Senden der Rechnung',
|
||||
type = 'error'
|
||||
})
|
||||
end
|
||||
|
@ -176,7 +176,7 @@ function ViewBills()
|
|||
if not bills or #bills == 0 then
|
||||
lib.notify({
|
||||
title = 'Billing System',
|
||||
description = 'You have no unpaid bills',
|
||||
description = 'Du hast keine unbezahlten Rechnungen',
|
||||
type = 'info'
|
||||
})
|
||||
|
||||
|
@ -190,38 +190,52 @@ function ViewBills()
|
|||
local billOptions = {}
|
||||
for _, bill in ipairs(bills) do
|
||||
local timestamp = os.date('%Y-%m-%d %H:%M', bill.date)
|
||||
|
||||
-- Check if bill is declined in our custom table
|
||||
local billData = lib.callback.await('billing:server:getBillStatus', false, bill.id)
|
||||
local isDeclined = billData and billData.declined == 1
|
||||
|
||||
local status = 'Unbezahlt'
|
||||
if bill.isPaid then
|
||||
status = 'Bezahlt'
|
||||
elseif isDeclined then
|
||||
status = 'Abgelehnt'
|
||||
end
|
||||
|
||||
table.insert(billOptions, {
|
||||
title = bill.description,
|
||||
description = ('Amount: $%s | Date: %s'):format(bill.amount, timestamp),
|
||||
description = ('Betrag: $%s | Datum: %s'):format(bill.amount, timestamp),
|
||||
icon = 'file-invoice',
|
||||
metadata = {
|
||||
{label = 'Bill ID', value = bill.id},
|
||||
{label = 'Type', value = bill.type},
|
||||
{label = 'Status', value = bill.isPaid and 'Paid' or 'Unpaid'}
|
||||
{label = 'Rechnungs-ID', value = bill.id},
|
||||
{label = 'Typ', value = bill.type},
|
||||
{label = 'Status', value = status}
|
||||
},
|
||||
onSelect = function()
|
||||
local confirm = lib.alertDialog({
|
||||
header = 'Pay Bill',
|
||||
content = ('Do you want to pay $%s for %s?'):format(bill.amount, bill.description),
|
||||
centered = true,
|
||||
cancel = true
|
||||
})
|
||||
|
||||
if confirm == 'confirm' then
|
||||
local success = lib.callback.await('ps-banking:server:payBill', false, bill.id)
|
||||
if success then
|
||||
lib.notify({
|
||||
title = 'Billing System',
|
||||
description = 'Bill paid successfully',
|
||||
type = 'success'
|
||||
})
|
||||
ViewBills() -- Refresh the list
|
||||
else
|
||||
lib.notify({
|
||||
title = 'Billing System',
|
||||
description = 'Failed to pay bill. Insufficient funds.',
|
||||
type = 'error'
|
||||
})
|
||||
if not bill.isPaid and not isDeclined then
|
||||
local confirm = lib.alertDialog({
|
||||
header = 'Rechnung bezahlen',
|
||||
content = ('Möchtest du $%s für %s bezahlen?'):format(bill.amount, bill.description),
|
||||
centered = true,
|
||||
cancel = true
|
||||
})
|
||||
|
||||
if confirm == 'confirm' then
|
||||
local success = lib.callback.await('ps-banking:server:payBill', false, bill.id)
|
||||
if success then
|
||||
lib.notify({
|
||||
title = 'Billing System',
|
||||
description = 'Rechnung erfolgreich bezahlt',
|
||||
type = 'success'
|
||||
})
|
||||
ViewBills() -- Refresh the list
|
||||
else
|
||||
lib.notify({
|
||||
title = 'Billing System',
|
||||
description = 'Fehler beim Bezahlen der Rechnung. Unzureichendes Guthaben.',
|
||||
type = 'error'
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -230,7 +244,7 @@ function ViewBills()
|
|||
|
||||
lib.registerContext({
|
||||
id = 'billing_menu',
|
||||
title = 'Your Bills',
|
||||
title = 'Deine Rechnungen',
|
||||
menu = 'main_billing_menu', -- Add back button to main menu
|
||||
options = billOptions
|
||||
})
|
||||
|
@ -290,3 +304,98 @@ function PlayBillingAnimation()
|
|||
ClearPedTasks(playerPed)
|
||||
DeleteEntity(prop)
|
||||
end
|
||||
|
||||
-- Event to show payment prompt when receiving a bill
|
||||
RegisterNetEvent('billing:client:showPaymentPrompt', function(data)
|
||||
-- Play a notification sound
|
||||
PlaySound(-1, "Event_Start_Text", "GTAO_FM_Events_Soundset", 0, 0, 1)
|
||||
|
||||
-- Create the payment prompt
|
||||
lib.registerContext({
|
||||
id = 'bill_payment_prompt',
|
||||
title = 'Neue Rechnung erhalten',
|
||||
options = {
|
||||
{
|
||||
title = 'Rechnung Details',
|
||||
description = 'Von: ' .. data.sender,
|
||||
metadata = {
|
||||
{label = 'Betrag', value = '$' .. data.amount},
|
||||
{label = 'Grund', value = data.reason},
|
||||
}
|
||||
},
|
||||
{
|
||||
title = 'Bezahlen',
|
||||
description = 'Rechnung sofort bezahlen',
|
||||
icon = 'money-bill',
|
||||
onSelect = function()
|
||||
local success = lib.callback.await('billing:server:handleBillResponse', false, {
|
||||
action = 'pay',
|
||||
billId = data.billId
|
||||
})
|
||||
|
||||
if success then
|
||||
lib.notify({
|
||||
title = 'Rechnung bezahlt',
|
||||
description = 'Du hast die Rechnung erfolgreich bezahlt',
|
||||
type = 'success'
|
||||
})
|
||||
else
|
||||
lib.notify({
|
||||
title = 'Zahlung fehlgeschlagen',
|
||||
description = 'Du hast nicht genug Geld auf deinem Konto',
|
||||
type = 'error'
|
||||
})
|
||||
end
|
||||
end
|
||||
},
|
||||
{
|
||||
title = 'Ablehnen',
|
||||
description = 'Rechnung ablehnen',
|
||||
icon = 'times-circle',
|
||||
onSelect = function()
|
||||
local confirm = lib.alertDialog({
|
||||
header = 'Rechnung ablehnen',
|
||||
content = 'Bist du sicher, dass du diese Rechnung ablehnen möchtest?',
|
||||
centered = true,
|
||||
cancel = true
|
||||
})
|
||||
|
||||
if confirm == 'confirm' then
|
||||
local success = lib.callback.await('billing:server:handleBillResponse', false, {
|
||||
action = 'decline',
|
||||
billId = data.billId
|
||||
})
|
||||
|
||||
if success then
|
||||
lib.notify({
|
||||
title = 'Rechnung abgelehnt',
|
||||
description = 'Du hast die Rechnung abgelehnt',
|
||||
type = 'info'
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
},
|
||||
{
|
||||
title = 'Später bezahlen',
|
||||
description = 'Rechnung für später speichern',
|
||||
icon = 'clock',
|
||||
onSelect = function()
|
||||
lib.callback.await('billing:server:handleBillResponse', false, {
|
||||
action = 'later',
|
||||
billId = data.billId
|
||||
})
|
||||
|
||||
lib.notify({
|
||||
title = 'Rechnung gespeichert',
|
||||
description = 'Die Rechnung wurde für später gespeichert',
|
||||
type = 'info'
|
||||
})
|
||||
end
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
-- Show the payment prompt
|
||||
lib.showContext('bill_payment_prompt')
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue