Advertisement
Guest User

sqz_duty - Boss Menu edit

a guest
May 1st, 2022
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.34 KB | None | 0 0
  1. function OpenBossMenu(society, close, options)
  2.     options = options or {}
  3.     local elements = {
  4.         {label = 'Show Duty Time of employees', value = 'dutyTime'}
  5.     }
  6.  
  7.     ESX.TriggerServerCallback('esx_society:isBoss', function(isBoss)
  8.         if isBoss then
  9.             local defaultOptions = {
  10.                 withdraw = true,
  11.                 deposit = true,
  12.                 wash = true,
  13.                 employees = true,
  14.                 grades = true
  15.             }
  16.  
  17.             for k,v in pairs(defaultOptions) do
  18.                 if options[k] == nil then
  19.                     options[k] = v
  20.                 end
  21.             end
  22.  
  23.             if options.withdraw then
  24.                 table.insert(elements, {label = _U('withdraw_society_money'), value = 'withdraw_society_money'})
  25.             end
  26.  
  27.             if options.deposit then
  28.                 table.insert(elements, {label = _U('deposit_society_money'), value = 'deposit_money'})
  29.             end
  30.  
  31.             if options.wash then
  32.                 table.insert(elements, {label = _U('wash_money'), value = 'wash_money'})
  33.             end
  34.  
  35.             if options.employees then
  36.                 table.insert(elements, {label = _U('employee_management'), value = 'manage_employees'})
  37.             end
  38.  
  39.             if options.grades then
  40.                 table.insert(elements, {label = _U('salary_management'), value = 'manage_grades'})
  41.             end
  42.  
  43.             ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'boss_actions_' .. society, {
  44.                 title    = _U('boss_menu'),
  45.                 align    = 'top-left',
  46.                 elements = elements
  47.             }, function(data, menu)
  48.                 if data.current.value == 'withdraw_society_money' then
  49.                     ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'withdraw_society_money_amount_' .. society, {
  50.                         title = _U('withdraw_amount')
  51.                     }, function(data2, menu2)
  52.                         local amount = tonumber(data2.value)
  53.  
  54.                         if amount == nil then
  55.                             ESX.ShowNotification(_U('invalid_amount'))
  56.                         else
  57.                             menu2.close()
  58.                             TriggerServerEvent('esx_society:withdrawMoney', society, amount)
  59.                         end
  60.                     end, function(data2, menu2)
  61.                         menu2.close()
  62.                     end)
  63.                 elseif data.current.value == 'deposit_money' then
  64.                     ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'deposit_money_amount_' .. society, {
  65.                         title = _U('deposit_amount')
  66.                     }, function(data2, menu2)
  67.                         local amount = tonumber(data2.value)
  68.  
  69.                         if amount == nil then
  70.                             ESX.ShowNotification(_U('invalid_amount'))
  71.                         else
  72.                             menu2.close()
  73.                             TriggerServerEvent('esx_society:depositMoney', society, amount)
  74.                         end
  75.                     end, function(data2, menu2)
  76.                         menu2.close()
  77.                     end)
  78.                 elseif data.current.value == 'wash_money' then
  79.                     ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'wash_money_amount_' .. society, {
  80.                         title = _U('wash_money_amount')
  81.                     }, function(data2, menu2)
  82.                         local amount = tonumber(data2.value)
  83.  
  84.                         if amount == nil then
  85.                             ESX.ShowNotification(_U('invalid_amount'))
  86.                         else
  87.                             menu2.close()
  88.                             TriggerServerEvent('esx_society:washMoney', society, amount)
  89.                         end
  90.                     end, function(data2, menu2)
  91.                         menu2.close()
  92.                     end)
  93.                 elseif data.current.value == 'manage_employees' then
  94.                     OpenManageEmployeesMenu(society)
  95.                 elseif data.current.value == 'manage_grades' then
  96.                     OpenManageGradesMenu(society)
  97.                 elseif data.current.value == 'dutyTime' then
  98.                     TriggerServerEvent('sqz_duty:GetEmployes', ESX.PlayerData.job.name)
  99.                 end
  100.             end, function(data, menu)
  101.                 if close then
  102.                     close(data, menu)
  103.                 end
  104.             end)
  105.         end
  106.     end, society)
  107. end
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement