1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-05 15:02:32 +02:00
parent a3269e304b
commit f8715d76de
2 changed files with 35 additions and 3 deletions

View file

@ -239,6 +239,7 @@ end
-- Function to view received bills
function ViewBills()
-- Get all bills from ps-banking
local bills = lib.callback.await('ps-banking:server:getBills', false)
if not bills or #bills == 0 then
@ -255,13 +256,24 @@ function ViewBills()
return
end
-- Get bill statuses from our custom table
local billStatuses = lib.callback.await('billing:server:getAllBillStatuses', false)
local statusMap = {}
-- Create a map of bill ID to status for quick lookup
if billStatuses then
for _, status in ipairs(billStatuses) do
statusMap[status.bill_id] = status
end
end
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 billStatus = statusMap[bill.id]
local isDeclined = billStatus and billStatus.declined == 1
local status = 'Unbezahlt'
if bill.isPaid then

View file

@ -65,6 +65,24 @@ lib.callback.register('billing:server:getBillStatus', function(source, billId)
return nil
end)
-- Add a callback to get all bill statuses for a player
lib.callback.register('billing:server:getAllBillStatuses', function(source)
local src = source
local player = QBCore.Functions.GetPlayer(src)
if not player then return nil end
local citizenId = player.PlayerData.citizenid
-- Get all bill statuses for this player
local result = MySQL.query.await('SELECT * FROM billing_accounts WHERE receiver_id = ?', {citizenId})
if result and #result > 0 then
return result
end
return {}
end)
-- Add a new callback for handling bill responses
lib.callback.register('billing:server:handleBillResponse', function(source, data)
local src = source
@ -117,7 +135,9 @@ lib.callback.register('billing:server:handleBillResponse', function(source, data
return true
elseif data.action == 'later' then
-- No action needed, bill remains in system
-- Simply close the prompt without any action
-- The bill will remain in the system as unpaid
-- No need to update anything in the database
return true
end