ed
This commit is contained in:
parent
fb02bf36f5
commit
7b2d064f63
34 changed files with 250 additions and 56 deletions
|
@ -169,6 +169,74 @@ function ShowBillingForm(selectedPlayer, accountOptions)
|
|||
end
|
||||
end
|
||||
|
||||
-- Function to show payment account selection
|
||||
function ShowPaymentAccountSelection(billId, amount, description)
|
||||
-- Get player's accounts for payment
|
||||
local accounts = lib.callback.await('ps-banking:server:getAccounts', false) or {}
|
||||
local accountOptions = {}
|
||||
|
||||
-- Add default bank account
|
||||
table.insert(accountOptions, {
|
||||
value = 'personal',
|
||||
label = 'Persönliches Bankkonto',
|
||||
description = 'Bezahlen mit deinem Hauptkonto'
|
||||
})
|
||||
|
||||
-- Add other accounts
|
||||
for _, account in ipairs(accounts) do
|
||||
table.insert(accountOptions, {
|
||||
value = account.id,
|
||||
label = account.holder .. ' - ' .. account.cardNumber,
|
||||
description = 'Kontostand: $' .. account.balance
|
||||
})
|
||||
end
|
||||
|
||||
-- Register and show the account selection menu
|
||||
lib.registerContext({
|
||||
id = 'payment_account_menu',
|
||||
title = 'Wähle Zahlungskonto',
|
||||
menu = 'billing_menu', -- Add back button to bills menu
|
||||
options = accountOptions,
|
||||
onExit = function()
|
||||
ViewBills() -- Return to bills menu
|
||||
end,
|
||||
onSelect = function(selected)
|
||||
local accountId = selected.value
|
||||
|
||||
local confirm = lib.alertDialog({
|
||||
header = 'Rechnung bezahlen',
|
||||
content = ('Möchtest du $%s für %s von diesem Konto bezahlen?'):format(amount, description),
|
||||
centered = true,
|
||||
cancel = true
|
||||
})
|
||||
|
||||
if confirm == 'confirm' then
|
||||
local success = lib.callback.await('billing:server:payBillFromAccount', false, {
|
||||
billId = billId,
|
||||
accountId = accountId
|
||||
})
|
||||
|
||||
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
|
||||
})
|
||||
|
||||
lib.showContext('payment_account_menu')
|
||||
end
|
||||
|
||||
-- Function to view received bills
|
||||
function ViewBills()
|
||||
local bills = lib.callback.await('ps-banking:server:getBills', false)
|
||||
|
@ -213,30 +281,8 @@ function ViewBills()
|
|||
},
|
||||
onSelect = function()
|
||||
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
|
||||
-- Show account selection for payment
|
||||
ShowPaymentAccountSelection(bill.id, bill.amount, bill.description)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -310,6 +356,68 @@ RegisterNetEvent('billing:client:showPaymentPrompt', function(data)
|
|||
-- Play a notification sound
|
||||
PlaySound(-1, "Event_Start_Text", "GTAO_FM_Events_Soundset", 0, 0, 1)
|
||||
|
||||
-- Get player's accounts for payment
|
||||
local accounts = lib.callback.await('ps-banking:server:getAccounts', false) or {}
|
||||
local accountOptions = {}
|
||||
|
||||
-- Add default bank account
|
||||
table.insert(accountOptions, {
|
||||
title = 'Persönliches Bankkonto',
|
||||
description = 'Bezahlen mit deinem Hauptkonto',
|
||||
icon = 'credit-card',
|
||||
onSelect = function()
|
||||
local success = lib.callback.await('billing:server:handleBillResponse', false, {
|
||||
action = 'pay',
|
||||
billId = data.billId,
|
||||
accountId = 'personal'
|
||||
})
|
||||
|
||||
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
|
||||
})
|
||||
|
||||
-- Add other accounts
|
||||
for _, account in ipairs(accounts) do
|
||||
table.insert(accountOptions, {
|
||||
title = account.holder .. ' - ' .. account.cardNumber,
|
||||
description = 'Kontostand: $' .. account.balance,
|
||||
icon = 'university',
|
||||
onSelect = function()
|
||||
local success = lib.callback.await('billing:server:handleBillResponse', false, {
|
||||
action = 'pay',
|
||||
billId = data.billId,
|
||||
accountId = account.id
|
||||
})
|
||||
|
||||
if success then
|
||||
lib.notify({
|
||||
title = 'Rechnung bezahlt',
|
||||
description = 'Du hast die Rechnung erfolgreich bezahlt',
|
||||
type = 'success'
|
||||
})
|
||||
else
|
||||
lib.notify({
|
||||
title = 'Zahlung fehlgeschlagen',
|
||||
description = 'Nicht genug Geld auf diesem Konto',
|
||||
type = 'error'
|
||||
})
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
-- Create the payment prompt
|
||||
lib.registerContext({
|
||||
id = 'bill_payment_prompt',
|
||||
|
@ -325,28 +433,9 @@ RegisterNetEvent('billing:client:showPaymentPrompt', function(data)
|
|||
},
|
||||
{
|
||||
title = 'Bezahlen',
|
||||
description = 'Rechnung sofort bezahlen',
|
||||
description = 'Wähle ein Konto zum 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
|
||||
menu = 'payment_account_selection'
|
||||
},
|
||||
{
|
||||
title = 'Ablehnen',
|
||||
|
@ -396,6 +485,14 @@ RegisterNetEvent('billing:client:showPaymentPrompt', function(data)
|
|||
}
|
||||
})
|
||||
|
||||
-- Register the account selection submenu
|
||||
lib.registerContext({
|
||||
id = 'payment_account_selection',
|
||||
title = 'Wähle Zahlungskonto',
|
||||
menu = 'bill_payment_prompt',
|
||||
options = accountOptions
|
||||
})
|
||||
|
||||
-- Show the payment prompt
|
||||
lib.showContext('bill_payment_prompt')
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue