mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
update
This commit is contained in:
@@ -64,15 +64,19 @@ end
|
||||
|
||||
function OpenBossMenu(society, close, options)
|
||||
options = options or {}
|
||||
local elements = {}
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-user", title = TranslateCap('boss_menu')}
|
||||
}
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:isBoss', function(isBoss)
|
||||
if isBoss then
|
||||
local defaultOptions = {
|
||||
checkBal = true,
|
||||
withdraw = true,
|
||||
deposit = true,
|
||||
wash = true,
|
||||
employees = true,
|
||||
salary = true,
|
||||
grades = true
|
||||
}
|
||||
|
||||
@@ -82,266 +86,283 @@ function OpenBossMenu(society, close, options)
|
||||
end
|
||||
end
|
||||
|
||||
if options.checkBal then
|
||||
elements[#elements+1] = {icon = "fas fa-wallet", title = TranslateCap('check_society_balance'), value = "check_society_balance"}
|
||||
end
|
||||
if options.withdraw then
|
||||
table.insert(elements, {label = TranslateCap('withdraw_society_money'), value = 'withdraw_society_money'})
|
||||
elements[#elements+1] = {icon = "fas fa-wallet", title = TranslateCap('withdraw_society_money'), value = "withdraw_society_money"}
|
||||
end
|
||||
|
||||
if options.deposit then
|
||||
table.insert(elements, {label = TranslateCap('deposit_society_money'), value = 'deposit_money'})
|
||||
elements[#elements+1] = {icon = "fas fa-wallet", title = TranslateCap('deposit_society_money'), value = "deposit_money"}
|
||||
end
|
||||
|
||||
if options.wash then
|
||||
table.insert(elements, {label = TranslateCap('wash_money'), value = 'wash_money'})
|
||||
elements[#elements+1] = {icon = "fas fa-wallet", title = TranslateCap('wash_money'), value = "wash_money"}
|
||||
end
|
||||
|
||||
if options.employees then
|
||||
table.insert(elements, {label = TranslateCap('employee_management'), value = 'manage_employees'})
|
||||
elements[#elements+1] = {icon = "fas fa-users", title = TranslateCap('employee_management'), value = "manage_employees"}
|
||||
end
|
||||
if options.salary then
|
||||
elements[#elements+1] = {icon = "fas fa-wallet", title = TranslateCap('salary_management'), value = "manage_salary"}
|
||||
end
|
||||
|
||||
if options.grades then
|
||||
table.insert(elements, {label = TranslateCap('salary_management'), value = 'manage_grades'})
|
||||
elements[#elements+1] = {icon = "fas fa-scroll", title = TranslateCap('grade_management'), value = "manage_grades"}
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'boss_actions_' .. society, {
|
||||
title = TranslateCap('boss_menu'),
|
||||
align = 'top-left',
|
||||
elements = elements
|
||||
}, function(data, menu)
|
||||
if data.current.value == 'withdraw_society_money' then
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'withdraw_society_money_amount_' .. society, {
|
||||
title = TranslateCap('withdraw_amount')
|
||||
}, function(data2, menu2)
|
||||
local amount = tonumber(data2.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(TranslateCap('invalid_amount'))
|
||||
else
|
||||
menu2.close()
|
||||
TriggerServerEvent('esx_society:withdrawMoney', society, amount)
|
||||
end
|
||||
end, function(data2, menu2)
|
||||
menu2.close()
|
||||
end)
|
||||
elseif data.current.value == 'deposit_money' then
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'deposit_money_amount_' .. society, {
|
||||
title = TranslateCap('deposit_amount')
|
||||
}, function(data2, menu2)
|
||||
local amount = tonumber(data2.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(TranslateCap('invalid_amount'))
|
||||
else
|
||||
menu2.close()
|
||||
TriggerServerEvent('esx_society:depositMoney', society, amount)
|
||||
end
|
||||
end, function(data2, menu2)
|
||||
menu2.close()
|
||||
end)
|
||||
elseif data.current.value == 'wash_money' then
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'wash_money_amount_' .. society, {
|
||||
title = TranslateCap('wash_money_amount')
|
||||
}, function(data2, menu2)
|
||||
local amount = tonumber(data2.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(TranslateCap('invalid_amount'))
|
||||
else
|
||||
menu2.close()
|
||||
TriggerServerEvent('esx_society:washMoney', society, amount)
|
||||
end
|
||||
end, function(data2, menu2)
|
||||
menu2.close()
|
||||
end)
|
||||
elseif data.current.value == 'manage_employees' then
|
||||
ESX.OpenContext("right", elements, function(menu,element)
|
||||
if element.value == "check_society_balance" then
|
||||
TriggerServerEvent('esx_society:checkSocietyBalance', society)
|
||||
elseif element.value == "withdraw_society_money" then
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-wallet", title = TranslateCap('withdraw_amount'), description = "Withdraw money from the society account"},
|
||||
{icon = "fas fa-wallet", title = "Amount", input = true, inputType = "number", inputPlaceholder = "Amount to withdraw..", inputMin = 1, inputMax = 250000, name = "withdraw"},
|
||||
{icon = "fas fa-check", title = "Confirm", value = "confirm"}
|
||||
}
|
||||
ESX.RefreshContext(elements)
|
||||
elseif element.value == "confirm" then
|
||||
local amount = tonumber(menu.eles[2].inputValue)
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(TranslateCap('invalid_amount'))
|
||||
else
|
||||
TriggerServerEvent('esx_society:withdrawMoney', society, amount)
|
||||
ESX.CloseContext()
|
||||
end
|
||||
elseif element.value == "deposit_money" then
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-wallet", title = TranslateCap('deposit_amount'), description = "Deposit some money into the society account"},
|
||||
{icon = "fas fa-wallet", title = "Amount", input = true, inputType = "number", inputPlaceholder = "Amount to deposit..", inputMin = 1, inputMax = 250000, name = "deposit"},
|
||||
{icon = "fas fa-check", title = "Confirm", value = "confirm2"}
|
||||
}
|
||||
ESX.RefreshContext(elements)
|
||||
elseif element.value == "confirm2" then
|
||||
local amount = tonumber(menu.eles[2].inputValue)
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(TranslateCap('invalid_amount'))
|
||||
else
|
||||
TriggerServerEvent('esx_society:depositMoney', society, amount)
|
||||
ESX.CloseContext()
|
||||
end
|
||||
elseif element.value == "wash_money" then
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-wallet", title = TranslateCap('wash_money_amount'), description = "Deposit some money into the money wash"},
|
||||
{icon = "fas fa-wallet", title = "Amount", input = true, inputType = "number", inputPlaceholder = "Amount to wash..", inputMin = 1, inputMax = 250000, name = "wash"},
|
||||
{icon = "fas fa-check", title = "Confirm", value = "confirm3"}
|
||||
}
|
||||
ESX.RefreshContext(elements)
|
||||
elseif element.value == "confirm3" then
|
||||
local amount = tonumber(menu.eles[2].inputValue)
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(TranslateCap('invalid_amount'))
|
||||
else
|
||||
TriggerServerEvent('esx_society:washMoney', society, amount)
|
||||
ESX.CloseContext()
|
||||
end
|
||||
elseif element.value == "manage_employees" then
|
||||
OpenManageEmployeesMenu(society)
|
||||
elseif data.current.value == 'manage_grades' then
|
||||
elseif element.value == "manage_salary" then
|
||||
OpenManageSalaryMenu(society)
|
||||
elseif element.value == "manage_grades" then
|
||||
OpenManageGradesMenu(society)
|
||||
end
|
||||
end, function(data, menu)
|
||||
if close then
|
||||
close(data, menu)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end, society)
|
||||
end
|
||||
|
||||
function OpenManageEmployeesMenu(society)
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'manage_employees_' .. society, {
|
||||
title = TranslateCap('employee_management'),
|
||||
align = 'top-left',
|
||||
elements = {
|
||||
{label = TranslateCap('employee_list'), value = 'employee_list'},
|
||||
{label = TranslateCap('recruit'), value = 'recruit'}
|
||||
}}, function(data, menu)
|
||||
if data.current.value == 'employee_list' then
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-users", title = TranslateCap('employee_management')},
|
||||
{icon = "fas fa-users", title = TranslateCap('employee_list'), value = "employee_list"},
|
||||
{icon = "fas fa-users", title = TranslateCap('recruit'), value = "recruit"}
|
||||
}
|
||||
ESX.OpenContext("right", elements, function(menu,element)
|
||||
if element.value == "employee_list" then
|
||||
OpenEmployeeList(society)
|
||||
elseif data.current.value == 'recruit' then
|
||||
OpenRecruitMenu(society)
|
||||
elseif element.value == "recruit" then
|
||||
OpenRecruitMenu(society)
|
||||
end
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenEmployeeList(society)
|
||||
ESX.TriggerServerCallback('esx_society:getEmployees', function(employees)
|
||||
|
||||
local elements = {
|
||||
head = {TranslateCap('employee'), TranslateCap('grade'), TranslateCap('actions')},
|
||||
rows = {}
|
||||
{unselectable = true, icon = "fas fa-user", title = "Employees"}
|
||||
}
|
||||
|
||||
for i=1, #employees, 1 do
|
||||
local gradeLabel = (employees[i].job.grade_label == '' and employees[i].job.label or employees[i].job.grade_label)
|
||||
|
||||
table.insert(elements.rows, {
|
||||
data = employees[i],
|
||||
cols = {
|
||||
employees[i].name,
|
||||
gradeLabel,
|
||||
'{{' .. TranslateCap('promote') .. '|promote}} {{' .. TranslateCap('fire') .. '|fire}}'
|
||||
}
|
||||
})
|
||||
elements[#elements+1] = {icon = "fas fa-user", title = employees[i].name .. " | " ..gradeLabel, gradeLabel = gradeLabel, data = employees[i]}
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open('list', GetCurrentResourceName(), 'employee_list_' .. society, elements, function(data, menu)
|
||||
local employee = data.data
|
||||
elements[#elements+1] = {icon = "fas fa-arrow-left", title = "Return", value = "return"}
|
||||
|
||||
if data.value == 'promote' then
|
||||
menu.close()
|
||||
OpenPromoteMenu(society, employee)
|
||||
elseif data.value == 'fire' then
|
||||
ESX.ShowNotification(TranslateCap('you_have_fired', employee.name))
|
||||
ESX.OpenContext("right", elements, function(menu,element)
|
||||
if element.value == "return" then
|
||||
OpenManageEmployeesMenu(society)
|
||||
else
|
||||
local elements2 = {
|
||||
{unselectable = true, icon = "fas fa-user", title = element.title},
|
||||
{icon = "fas fa-user", title = "Promote", value = "promote"},
|
||||
{icon = "fas fa-user", title = "Fire", value = "fire"},
|
||||
{icon = "fas fa-arrow-left", title = "Return", value = "return"}
|
||||
}
|
||||
ESX.OpenContext("right", elements2, function(menu2,element2)
|
||||
local employee = element.data
|
||||
if element2.value == "promote" then
|
||||
ESX.CloseContext()
|
||||
OpenPromoteMenu(society, employee)
|
||||
elseif element2.value == "fire" then
|
||||
ESX.ShowNotification(TranslateCap('you_have_fired', employee.name))
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:setJob', function()
|
||||
OpenEmployeeList(society)
|
||||
end, employee.identifier, 'unemployed', 0, 'fire')
|
||||
ESX.TriggerServerCallback('esx_society:setJob', function()
|
||||
OpenEmployeeList(society)
|
||||
end, employee.identifier, 'unemployed', 0, 'fire')
|
||||
elseif element2.value == "return" then
|
||||
OpenEmployeeList(society)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
OpenManageEmployeesMenu(society)
|
||||
end)
|
||||
end, society)
|
||||
end
|
||||
|
||||
function OpenRecruitMenu(society)
|
||||
ESX.TriggerServerCallback('esx_society:getOnlinePlayers', function(players)
|
||||
local elements = {}
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-user", title = TranslateCap('recruiting')}
|
||||
}
|
||||
|
||||
for i=1, #players, 1 do
|
||||
if players[i].job.name ~= society then
|
||||
table.insert(elements, {
|
||||
label = players[i].name,
|
||||
value = players[i].source,
|
||||
name = players[i].name,
|
||||
identifier = players[i].identifier
|
||||
})
|
||||
elements[#elements+1] = {icon = "fas fa-user", title = players[i].name, value = players[i].source, name = players[i].name, identifier = players[i].identifier}
|
||||
end
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'recruit_' .. society, {
|
||||
title = TranslateCap('recruiting'),
|
||||
align = 'top-left',
|
||||
elements = elements
|
||||
}, function(data, menu)
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'recruit_confirm_' .. society, {
|
||||
title = TranslateCap('do_you_want_to_recruit', data.current.name),
|
||||
align = 'top-left',
|
||||
elements = {
|
||||
{label = TranslateCap('no'), value = 'no'},
|
||||
{label = TranslateCap('yes'), value = 'yes'}
|
||||
}}, function(data2, menu2)
|
||||
menu2.close()
|
||||
elements[#elements+1] = {icon = "fas fa-arrow-left", title = "Return", value = "return"}
|
||||
|
||||
if data2.current.value == 'yes' then
|
||||
ESX.ShowNotification(TranslateCap('you_have_hired', data.current.name))
|
||||
ESX.OpenContext("right", elements, function(menu,element)
|
||||
if element.value == "return" then
|
||||
OpenManageEmployeesMenu(society)
|
||||
else
|
||||
local elements2 = {
|
||||
{unselectable = true, icon = "fas fa-user", title = "Confirm"},
|
||||
{icon = "fas fa-times", title = TranslateCap('no'), value = "no"},
|
||||
{icon = "fas fa-check", title = TranslateCap('yes'), value = "yes"},
|
||||
}
|
||||
ESX.OpenContext("right", elements2, function(menu2,element2)
|
||||
if element2.value == "yes" then
|
||||
ESX.ShowNotification(TranslateCap('you_have_hired', element.name))
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:setJob', function()
|
||||
OpenRecruitMenu(society)
|
||||
end, data.current.identifier, society, 0, 'hire')
|
||||
end
|
||||
end, function(data2, menu2)
|
||||
menu2.close()
|
||||
end)
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
ESX.TriggerServerCallback('esx_society:setJob', function()
|
||||
OpenRecruitMenu(society)
|
||||
end, element.identifier, society, 0, 'hire')
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenPromoteMenu(society, employee)
|
||||
ESX.TriggerServerCallback('esx_society:getJob', function(job)
|
||||
local elements = {}
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-user", title = TranslateCap('promote_employee', employee.name)}
|
||||
}
|
||||
|
||||
for i=1, #job.grades, 1 do
|
||||
local gradeLabel = (job.grades[i].label == '' and job.label or job.grades[i].label)
|
||||
|
||||
table.insert(elements, {
|
||||
label = gradeLabel,
|
||||
value = job.grades[i].grade,
|
||||
selected = (employee.job.grade == job.grades[i].grade)
|
||||
})
|
||||
elements[#elements+1] = {icon = "fas fa-user", title = gradeLabel, value = job.grades[i].grade, selected = (employee.job.grade == job.grades[i].grade)}
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'promote_employee_' .. society, {
|
||||
title = TranslateCap('promote_employee', employee.name),
|
||||
align = 'top-left',
|
||||
elements = elements
|
||||
}, function(data, menu)
|
||||
menu.close()
|
||||
ESX.ShowNotification(TranslateCap('you_have_promoted', employee.name, data.current.label))
|
||||
elements[#elements+1] = {icon = "fas fa-arrow-left", title = "Return", value = "return"}
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:setJob', function()
|
||||
ESX.OpenContext("right", elements, function(menu,element)
|
||||
if element.value == "return" then
|
||||
OpenEmployeeList(society)
|
||||
end, employee.identifier, society, data.current.value, 'promote')
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
else
|
||||
ESX.ShowNotification(TranslateCap('you_have_promoted', employee.name, element.title))
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:setJob', function()
|
||||
OpenEmployeeList(society)
|
||||
end, employee.identifier, society, element.value, 'promote')
|
||||
end
|
||||
end, function(menu)
|
||||
OpenEmployeeList(society)
|
||||
end)
|
||||
end, society)
|
||||
end
|
||||
|
||||
function OpenManageGradesMenu(society)
|
||||
function OpenManageSalaryMenu(society)
|
||||
ESX.TriggerServerCallback('esx_society:getJob', function(job)
|
||||
local elements = {}
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-wallet", title = TranslateCap('salary_management')}
|
||||
}
|
||||
|
||||
for i=1, #job.grades, 1 do
|
||||
local gradeLabel = (job.grades[i].label == '' and job.label or job.grades[i].label)
|
||||
|
||||
table.insert(elements, {
|
||||
label = ('%s - <span style="color:green;">%s</span>'):format(gradeLabel, TranslateCap('money_generic', ESX.Math.GroupDigits(job.grades[i].salary))),
|
||||
elements[#elements+1] = {
|
||||
icon = "fas fa-wallet",
|
||||
title = ('%s - <span style="color:green;">%s</span>'):format(gradeLabel, TranslateCap('money_generic', ESX.Math.GroupDigits(job.grades[i].salary))),
|
||||
value = job.grades[i].grade
|
||||
})
|
||||
}
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'manage_grades_' .. society, {
|
||||
title = TranslateCap('salary_management'),
|
||||
align = 'top-left',
|
||||
elements = elements
|
||||
}, function(data, menu)
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'manage_grades_amount_' .. society, {
|
||||
title = TranslateCap('salary_amount')
|
||||
}, function(data2, menu2)
|
||||
ESX.OpenContext("right", elements, function(menu,element)
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-wallet", title = element.title, description = "Change a grade salary amount", value = element.value},
|
||||
{icon = "fas fa-wallet", title = "Amount", input = true, inputType = "number", inputPlaceholder = "Amount to change grade salary..", inputMin = 1, inputMax = Config.MaxSalary, name = "gradesalary"},
|
||||
{icon = "fas fa-check", title = "Confirm", value = "confirm"}
|
||||
}
|
||||
|
||||
local amount = tonumber(data2.value)
|
||||
ESX.RefreshContext(elements)
|
||||
if element.value == "confirm" then
|
||||
local amount = tonumber(menu.eles[2].inputValue)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(TranslateCap('invalid_amount'))
|
||||
elseif amount > Config.MaxSalary then
|
||||
ESX.ShowNotification(TranslateCap('invalid_amount_max'))
|
||||
else
|
||||
menu2.close()
|
||||
|
||||
ESX.CloseContext()
|
||||
ESX.TriggerServerCallback('esx_society:setJobSalary', function()
|
||||
OpenManageGradesMenu(society)
|
||||
end, society, data.current.value, amount)
|
||||
OpenManageSalaryMenu(society)
|
||||
end, society, menu.eles[1].value, amount)
|
||||
end
|
||||
end, function(data2, menu2)
|
||||
menu2.close()
|
||||
end)
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
end)
|
||||
end, society)
|
||||
end
|
||||
|
||||
function OpenManageGradesMenu(society)
|
||||
ESX.TriggerServerCallback('esx_society:getJob', function(job)
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-wallet", title = TranslateCap('grade_management')}
|
||||
}
|
||||
|
||||
for i=1, #job.grades, 1 do
|
||||
local gradeLabel = (job.grades[i].label == '' and job.label or job.grades[i].label)
|
||||
|
||||
elements[#elements+1] = {icon = "fas fa-wallet", title = ('%s'):format(gradeLabel), value = job.grades[i].grade}
|
||||
end
|
||||
|
||||
ESX.OpenContext("right", elements, function(menu,element)
|
||||
local elements = {
|
||||
{unselectable = true, icon = "fas fa-wallet", title = element.title, description = "Change a grade label", value = element.value},
|
||||
{icon = "fas fa-wallet", title = "Label", input = true, inputType = "text", inputPlaceholder = "Label to change job grade label..", name = "gradelabel"},
|
||||
{icon = "fas fa-check", title = "Confirm", value = "confirm"}
|
||||
}
|
||||
|
||||
ESX.RefreshContext(elements)
|
||||
if element.value == "confirm" then
|
||||
local label = tostring(menu.eles[2].inputValue)
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:setJobLabel', function()
|
||||
OpenManageGradesMenu(society)
|
||||
end, society, menu.eles[1].value, label)
|
||||
end
|
||||
end)
|
||||
end, society)
|
||||
end
|
||||
@@ -349,3 +370,5 @@ end
|
||||
AddEventHandler('esx_society:openBossMenu', function(society, close, options)
|
||||
OpenBossMenu(society, close, options)
|
||||
end)
|
||||
|
||||
if ESX.PlayerLoaded then RefreshBussHUD() end
|
||||
|
||||
Reference in New Issue
Block a user