Advertisement
AlbertusMII

vrekapabsen isAllApproved

Nov 28th, 2023
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.12 KB | None | 0 0
  1. /****** Object:  View [dbo].[vrekapabsen]    Script Date: 28/11/2023 14:50:03 ******/
  2. SET ANSI_NULLS ON
  3. GO
  4.  
  5. SET QUOTED_IDENTIFIER ON
  6. GO
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. ALTER VIEW [dbo].[vrekapabsen]
  19. AS
  20. SELECT        EmployeeID, tipe, tgl, TimeIn, timeout, note, color
  21. FROM            (SELECT DISTINCT
  22.                                                     ao.EmployeeID, 'Absen' AS tipe, CONVERT(datetime, ao.Date, 105) AS tgl, ISNULL(ao.TimeIn, ao.Date) AS TimeIn, ISNULL(ao.TimeOut, ao.Date) AS timeout, 'In:' + ISNULL(LEFT(CONVERT(varchar,
  23.                                                     ao.TimeIn, 108), 5), '-') + '  Out:' + ISNULL(LEFT(CONVERT(varchar, ao.TimeOut, 108), 5), '-') + '  Late:' + ISNULL(LEFT(CONVERT(varchar, ao.LateTimeDouble, 108), 5), '00:00:00') + ' - Absen' AS note,
  24.                                                     'limegreen' AS color
  25.                           FROM            dbo.AttendanceOverview AS ao LEFT OUTER JOIN
  26.                                                     dbo.Attendance AS a ON ao.AttendanceOverviewID = a.AttendanceOverviewID
  27.                           WHERE        (a.isAllApproved = 1)
  28.                           UNION ALL
  29.                           SELECT DISTINCT
  30.                                                    ao.EmployeeID, 'Pengajuan' AS tipe, CONVERT(datetime, ao.Date, 105) AS tgl, ISNULL(ao.TimeIn, ao.Date) AS Expr1, ISNULL(ao.TimeOut, ISNULL(ao.TimeIn, ao.Date)) AS timeout,
  31.                                                    'In:' + ISNULL(LEFT(CONVERT(varchar, ao.TimeIn, 108), 5), '-') + '  Out:' + ISNULL(LEFT(CONVERT(varchar, ao.TimeOut, 108), 5), '-') + '  Late:' + ISNULL(LEFT(CONVERT(varchar, ao.LateTimeDouble,
  32.                                                    108), 5), '00:00:00') + ' - Pengajuan' AS note, 'orangered' AS color
  33.                           FROM            dbo.AttendanceOverview AS ao LEFT OUTER JOIN
  34.                                                    dbo.Attendance AS a ON ao.AttendanceOverviewID = a.AttendanceOverviewID
  35.                           WHERE        (ISNULL(a.isAllApproved, 0) = 0) AND (ao.TimeIn IS NULL) AND (ao.TimeOut IS NULL)
  36.                           UNION ALL
  37.                           SELECT        d.EmployeeID, 'Day Off' AS tipe, ISNULL(v.tgl, d.Date) AS Expr3, ISNULL(v.tgl, d.Date) AS Expr1, ISNULL(v.tgl, d.Date) AS Expr2, d.Note + ' - Day Off' AS Expr4, 'MediumOrchid' AS color
  38.                           FROM            dbo.DayOff AS d LEFT OUTER JOIN
  39.                                                    dbo.vwp AS v ON d.EmployeeID = v.employeeid AND CONVERT(date, v.tgl, 105) BETWEEN CONVERT(date, d.Date, 105) AND DATEADD(day, d.HowManyDays - 1, CONVERT(date, d.Date, 105)) AND
  40.                                                    v.tipe = 'Reguler'
  41.                           WHERE        (d.isAllApproved = 1)
  42.                           UNION ALL
  43.                           SELECT        EmployeeID, 'Overtime' AS tipe, DateStart, DateStart AS Expr1, DateEnd, Note + ' - Lembur' AS Expr2, 'deepskyblue' AS color
  44.                           FROM            dbo.Overtime
  45.                           WHERE        (isAllApproved = 1)) AS a_1
  46. GO
  47.  
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement