Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[crud_tst-timeline_getItems]
- @filters CRUDFilterParameter READONLY,
- @sort sql_variant,
- @direction nvarchar(8),
- @page int,
- @pageSize int,
- @username nvarchar(32)
- AS
- BEGIN
- declare @result TABLE (id nvarchar(64), title nvarchar(max), link nvarchar(256), date nvarchar(64), [text] nvarchar(max), icon nvarchar(64), iconBackgroundClass nvarchar(64), isRight bit, dateOrder datetime)
- declare @langID int
- select @langID = try_cast(Value as int) from @filters where [Key] = 'langID'
- declare @filterTitle nvarchar(64)
- select @filterTitle = Value from @filters where [Key] = 'title'
- declare @filterDate datetime
- select @filterDate = try_convert(date, Value, 104) from @filters where [Key] = 'date'
- insert into @result
- select 'cust_'+cast(id as nvarchar) as id,
- '<sup class="text-success font-weight-bold mr-1">new</sup>'+name title,
- '' as link,
- convert(nvarchar,created,120) as date,
- fio as text,
- 'fas fa-user-tie' as icon,
- case when isnull(vip,0)=0 then 'primary' else 'danger' end as iconBackgroundClass,
- 0 isRight,
- created as dateOrder
- from tst_customers
- where (isnull(@filterTitle,'')='' or name like '%'+@filterTitle+'%' or fio like '%'+@filterTitle+'%')
- --and (isnull(@filterDate,'01-01-1900')='01-01-1900' or convert(nvarchar,created,104) = convert(nvarchar,@filterDate,104))
- union
- select 'order_'+cast(id as nvarchar) as id,
- cast(isnull(price,0) as nvarchar)+' '+iif(@langID=1, 'USD', 'руб.')+' <sup class="text-secondary font-weight-bold ml-1">'+(select name from tst_products where id = productID)+', '+cast(isnull(cnt,0) as nvarchar)+' '+iif(@langID=1, 'cnt', 'шт.')+'</sup>' title,
- '' as link,
- convert(nvarchar,created,120) as date,
- (select isnull(name,'--')+', '+isnull(fio,'--')+':' from tst_customers where id = customerID)+'<br>'+isnull(note,'--') as text,
- 'fas fa-box' as icon,
- 'success' as iconBackgroundClass,
- 1 isRight,
- created as dateOrder
- from tst_orders
- where (isnull(@filterTitle,'')='' or (select name from tst_customers where id = customerID) like '%'+@filterTitle+'%' or (select fio from tst_customers where id = customerID) like '%'+@filterTitle+'%')
- --and (isnull(@filterDate,'01-01-1900')='01-01-1900' or convert(nvarchar,created,104) = convert(nvarchar,@filterDate,104))
- -- 1 SELECT - сами данные
- select * from @result
- order by dateOrder
- OFFSET @PageSize * (@Page - 1) ROWS
- FETCH NEXT @PageSize ROWS ONLY;
- -- 2 SELECT - кол-во в таблице
- select count(*) from @result
- -- 3 SELECT Дополнительные настройки таблицы
- Select 'timeline' ViewType, 1 InstantFilter, iif(@langID=1, 'Timeline of customer activity', 'Временная линия активности заказчиков') Title
- /*Select '' Title,
- '' ToolbarAdditional,
- '' GroupOperationsToolbar,
- '' FastCreateLinkText, '' FastCreateDialogHeader, '' FastCreateDialogPlaceholder,
- 0 HideTitleCount,
- 0 DisableCellTitle,
- '10px' FontSize,
- '{filterCode}' FilterMakeup,
- 1 InstantFilter,
- */
- --'gantt' ViewType,
- -- GanttScale, GanttNavigate, GanttItemForm, GanttItemFormTitle
- -- KanbanItemForm, KanbanItemFormTitle
- -- 4 SELECT Данные для подвала страницы или данные для Ганта/Канбана (если установлен ViewType в 3 SELECT)
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement