Advertisement
hecrus

Untitled

Apr 1st, 2021
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. insert into @result select tasks.id, isnull((select surname + ' ' + firstname from ssk_managers where id = tasks.managerID),'-') as manager, isnull((select shortname + '<br><a href="viewprofile?itemID='+username+'">'+inn+'</a>' from ctr_contragents where id = tasks.contragentID),'-') as createdBy, isnull((select shortname + ' ' + username + ' ' + inn from ctr_contragents where id = tasks.contragentID),'-') as ordCreatedBy, isnull((select name from ssk_managerTasks where id = tasks.taskID),'-') as task, case when itemCode = 'request' and completed is null then (select '<a href="request?itemID='+cast(instanceID as nvarchar)+'" class="bdg badge badge-pill badge-primary text-center">'+code+'</a>' from ssk_requests where id = itemID)--(select '<a href="order?itemID=moderation_'+cast(id as nvarchar)+'" class="bdg badge badge-pill badge-primary text-center">'+code+'</a>' from ssk_requests where id = cast(itemID as int)) when itemCode = 'profile' then isnull((select shortname + '<br><a href="viewprofile?itemID='+username+'">'+inn+'</a>' from ctr_contragents where id = tasks.contragentID),'-') when itemCode = 'offer' /*and completed is null*/ then (select '<a href="offer?itemID='+cast(instanceID as nvarchar)+'_get" class="bdg badge badge-pill badge-success text-center">'+code+'</a>' from ssk_offers where id = cast(itemID as int)) else '-' end as object, isnull(convert(nvarchar, tasks.created, 104) + '<br>' + LEFT(convert(nvarchar, tasks.created,108),8),'-') as created, tasks.created as ordCreated, isnull(convert(nvarchar, dateadd(hour,(select timeNorm from ssk_managerTasks where id = tasks.taskID),tasks.created), 104) + '<br>' + LEFT(convert(nvarchar, dateadd(hour,(select timeNorm from ssk_managerTasks where id = taskID),tasks.created),108),8),'-') as endTask, dateadd(hour,(select timeNorm from ssk_managerTasks where id = tasks.taskID),tasks.created) as ordEndTask, isnull(convert(nvarchar, tasks.completed, 104) + '<br>' + LEFT(convert(nvarchar, tasks.completed,108),8),'-') as timeTask, tasks.completed as ordTimeTask, isnull(LEFT(convert(nvarchar, dateadd(hour,(select timeNorm from ssk_managerTasks where id = tasks.taskID),'2000-01-01 00:00:00.000'),108),8),'-') as timeNorm, (select timeNorm from ssk_managerTasks where id = tasks.taskID) as ordTimeNorm, isnull(iif(datediff(hour,created,completed) > (select timeNorm from ssk_managerTasks where id = taskID), '<div class="text-danger">'+ cast(datediff(hour,tasks.created,tasks.completed) as nvarchar) + RIGHT(LEFT(convert(nvarchar, tasks.completed - tasks.created,108),8),6) +'</div>', LEFT(convert(nvarchar, tasks.completed - tasks.created,108),8)),'-') as timePassed, tasks.completed - tasks.created ordTimePassed, --case when tasks.isComplete is null then 'Не выполнено' -- when tasks.isComplete = 0 then 'Отклонено' -- when tasks.isComplete = 1 then 'Выполнено' --end as result, isnull(tasks.isComplete,'Не выполнена') as result, case when tasks.inTime is null then '-' when tasks.inTime = 0 then '<div class="text-danger">Просрочено</div>' when tasks.inTime = 1 then '<div class="text-success">В срок</div>' end as inTime, '<a href="#" class="as-form-modal" data-code="notes" data-itemID="'+try_cast(tasks.id as nvarchar)+'_comment_ssk_managerTaskLogs" data-big="0" data-title="Редактировать заметки" data-btnText="Сохранить">'+isnull(nullif(left(tasks.comment,35)+'...','...'),'<span class="text-danger">Добавить</span>')+'</a>' as comment, '{"placement": "left", "placeholder":"Комментарий...", "clear": true, "escape": false, "inputclass":"" }' editable_comment, 1 hide_start, case isComplete when 'Выполнена' then '#abf5a4' when 'Отложена' then '#edf5a4' when 'Отклонена' then '#f5a4a4' end as color from ssk_managerTaskLogs tasks where (isnull(@filterCreatedBy,'') = '' or (select shortname from ctr_contragents where id = tasks.contragentID) like '%'+@filterCreatedBy+'%' or (select inn from ctr_contragents where id = tasks.contragentID) like '%'+@filterCreatedBy+'%' ) and (isnull(@filterManager,0) = 0 or tasks.managerID = @filterManager) and (isnull(@filterResult,'') = '' or isnull(cast(tasks.isComplete as nvarchar),'Не выполнена') = @filterResult)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement