qs-dispatch
For billing integration, set your Config in qs-dispatch to
Config.Billing = 'bcs_companymanager'
Client side
qs-dispatch/client/custom/billing/bcs_companymanager.lua
if Config.Billing ~= "bcs_companymanager" then
return
end
function CreateBill(amount, text)
local from = {
label = 'Police',
job = 'police',
identifier = 'police',
}
TriggerServerEvent('CompanyManager:server:CreateBill', GetPlayerServerId(PlayerId()), tonumber(amount), text, nil, from)
end
Server side
qs-dispatch/server/custom/billing/bcs_companymanager.lua
if Config.Billing ~= "bcs_companymanager" then
return
end
function getBills(a, cb, data)
MySQL.Async.fetchAll(
"SELECT * FROM billings WHERE identifier = @identifier AND company = @company",
{ ["@identifier"] = data.identifier, ['@company'] = GetJobName(a) },
function(result)
if result then
local bills = {}
for key, value in pairs(result) do
local day, month, year = value.deadline:match("(%d+)/(%d+)/(%d+)")
table.insert(
bills,
{
["author_name"] = value["biller"] or 'Not defined', -- value["row_name of author name in your SQL"]
["timestamp"] = year..'-'..month..'-'..day, -- value["row_name of timestamp in your SQL"]
["status"] = value["status"] or 'unpayed', -- value["row_name of status in your SQL"]
["item"] = value["description"] or 'Not defined', -- value["row_name of item/text in your SQL"]
}
)
end
DebugPrint(bills)
cb(bills)
else
cb(false)
end
end
)
end
RegisterServerCallback("qs-dispatch:server:getBills", getBills)
function CreateBill(target, text, amount)
local from = {
label = 'Police',
job = 'police',
identifier = 'police',
}
TriggerEvent('bill:createBill', target, tonumber(amount), text, from, source)
end