function OpenGetStocksMenu()
ESX.TriggerServerCallback('esx_carteljob:getStockItems', function(items)
print(json.encode(items))
local elements = {}
for i=1, #items, 1 do
table.insert(elements, {label = 'x' .. items[i].count .. ' ' .. items[i].label, value = items[i].name})
end
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'stocks_menu',
{
title = _U('cartel_stock'),
elements = elements
},
function(data, menu)
local itemName = data.current.value
ESX.UI.Menu.Open(
'dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count',
{
title = _U('quantity')
},
function(data2, menu2)
local count = tonumber(data2.value)
if count == nil then
ESX.ShowNotification(_U('quantity_invalid'))
else
menu2.close()
menu.close()
OpenGetStocksMenu()
TriggerServerEvent('esx_carteljob:getStockItem', itemName, count)
end
end,
function(data2, menu2)
menu2.close()
end
)
end,
function(data, menu)
menu.close()
end
)
end)
end