Implemented only show menu if bills available, closes #25

This commit is contained in:
ElPumpo
2020-02-05 11:16:02 +01:00
parent 19a54ee750
commit 146328ddea
9 changed files with 37 additions and 25 deletions
+25 -21
View File
@@ -10,29 +10,33 @@ end)
function ShowBillsMenu()
ESX.TriggerServerCallback('esx_billing:getBills', function(bills)
ESX.UI.Menu.CloseAll()
local elements = {}
if #bills > 0 then
ESX.UI.Menu.CloseAll()
local elements = {}
for k,v in ipairs(bills) do
table.insert(elements, {
label = ('%s - <span style="color:red;">%s</span>'):format(v.label, _U('invoices_item', ESX.Math.GroupDigits(v.amount))),
billId = v.id
})
for k,v in ipairs(bills) do
table.insert(elements, {
label = ('%s - <span style="color:red;">%s</span>'):format(v.label, _U('invoices_item', ESX.Math.GroupDigits(v.amount))),
billId = v.id
})
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'billing', {
title = _U('invoices'),
align = 'bottom-right',
elements = elements
}, function(data, menu)
menu.close()
ESX.TriggerServerCallback('esx_billing:payBill', function()
ShowBillsMenu()
end, data.current.billId)
end, function(data, menu)
menu.close()
end)
else
ESX.ShowNotification(_U('no_invoices'))
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'billing', {
title = _U('invoices'),
align = 'bottom-right',
elements = elements
}, function(data, menu)
menu.close()
ESX.TriggerServerCallback('esx_billing:payBill', function()
ShowBillsMenu()
end, data.current.billId)
end, function(data, menu)
menu.close()
end)
end)
end