forked from Simnation/Main
ed
This commit is contained in:
parent
a3269e304b
commit
f8715d76de
2 changed files with 35 additions and 3 deletions
|
@ -239,6 +239,7 @@ end
|
||||||
|
|
||||||
-- Function to view received bills
|
-- Function to view received bills
|
||||||
function ViewBills()
|
function ViewBills()
|
||||||
|
-- Get all bills from ps-banking
|
||||||
local bills = lib.callback.await('ps-banking:server:getBills', false)
|
local bills = lib.callback.await('ps-banking:server:getBills', false)
|
||||||
|
|
||||||
if not bills or #bills == 0 then
|
if not bills or #bills == 0 then
|
||||||
|
@ -255,13 +256,24 @@ function ViewBills()
|
||||||
return
|
return
|
||||||
end
|
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 = {}
|
local billOptions = {}
|
||||||
for _, bill in ipairs(bills) do
|
for _, bill in ipairs(bills) do
|
||||||
local timestamp = os.date('%Y-%m-%d %H:%M', bill.date)
|
local timestamp = os.date('%Y-%m-%d %H:%M', bill.date)
|
||||||
|
|
||||||
-- Check if bill is declined in our custom table
|
-- Check if bill is declined in our custom table
|
||||||
local billData = lib.callback.await('billing:server:getBillStatus', false, bill.id)
|
local billStatus = statusMap[bill.id]
|
||||||
local isDeclined = billData and billData.declined == 1
|
local isDeclined = billStatus and billStatus.declined == 1
|
||||||
|
|
||||||
local status = 'Unbezahlt'
|
local status = 'Unbezahlt'
|
||||||
if bill.isPaid then
|
if bill.isPaid then
|
||||||
|
|
|
@ -65,6 +65,24 @@ lib.callback.register('billing:server:getBillStatus', function(source, billId)
|
||||||
return nil
|
return nil
|
||||||
end)
|
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
|
-- Add a new callback for handling bill responses
|
||||||
lib.callback.register('billing:server:handleBillResponse', function(source, data)
|
lib.callback.register('billing:server:handleBillResponse', function(source, data)
|
||||||
local src = source
|
local src = source
|
||||||
|
@ -117,7 +135,9 @@ lib.callback.register('billing:server:handleBillResponse', function(source, data
|
||||||
|
|
||||||
return true
|
return true
|
||||||
elseif data.action == 'later' then
|
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
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue