CREATE PROCEDURE [dbo].[tree_tst-catalog_getItems]
@parameters DictionaryParameter READONLY,
@username nvarchar(128 )='',
@itemID nvarchar(128)=''
as
begin
declare @langID int
select @langID = try_cast(Value as int) from @parameters where [Key] = 'langID'
-- SELECT 1
select 1 Result, '' Msg,
1 CanRename, 1 CanAdd, 1 canDelete,
'' PlusIcon, '' MinusIcon, 0 ShowIcon, 1 ShowTags,
'0' ParentIDRootValue,
'' EmptyIcon,
'' NodeIcon
-- SELECT 2
select c.id Id,
c.name as title,
isnull(c.parentID, 0) ParentID,
c.ord Ord,
'' Icon, -- fa fa-cube
'form' [Type], -- // form, redirect, refreshContainer
'' Value,
--'refreshContainer' [Type],
--'body' Value,
0 Expanded,
0 Selected,
'fa fa-stop' selectedIcon,
'#555' color,
'#eee' backColor,
'#' href,
1 selectable,
case when (select count(*) from tst_categoryProducts where categoryID = c.id) > 0
then ''+cast((select count(*) from tst_categoryProducts where categoryID = c.id) as nvarchar) + ' '+iif(@langID=1, 'cnt', 'тов.')+''
else ''+cast((select count(*) from tst_categoryProducts where categoryID = c.id) as nvarchar) + ' '+iif(@langID=1, 'cnt', 'тов.')+''
end + '|' +
case when (select count(*) from tst_categories c1 where c1.parentID = c.id) > 3
then '+'+cast((select count(*) from tst_categories c1 where c1.parentID = c.id)-3 as nvarchar)+'...'
else '' end + '|' +
isnull(STUFF((SELECT top 3 '|' + CAST(name as nvarchar(64)) as [text()]
FROM tst_categories c1 WHERE c1.parentID = c.id ORDER BY c1.ord
FOR XML PATH(''), TYPE).value('.', 'VARCHAR(MAX)'), 1, 1, ''), '') AS info
from tst_categories c
end