Advertisement
AlbertusMII

vcalendarrekapabsensi isAllApproved

Nov 28th, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 4.75 KB | None | 0 0
  1. /****** Object:  View [dbo].[vcalendarrekapabsensi]    Script Date: 28/11/2023 14:32:53 ******/
  2. SET ANSI_NULLS ON
  3. GO
  4.  
  5. SET QUOTED_IDENTIFIER ON
  6. GO
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. ALTER VIEW [dbo].[vcalendarrekapabsensi]
  15. AS
  16. SELECT        EmployeeID, tipe, tgl, TimeIn, timeout, note, color, Late
  17. FROM            (SELECT DISTINCT
  18.                                                     ao.EmployeeID, 'H' AS tipe, CONVERT(datetime, ao.Date, 105) AS tgl, ISNULL(ao.TimeIn, ao.Date) AS TimeIn, ISNULL(ao.TimeOut, ao.Date) AS timeout, 'H In:' + ISNULL(LEFT(CONVERT(varchar,
  19.                                                     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') AS note,
  20.                                                     'limegreen' AS color, ISNULL(LEFT(CONVERT(varchar, ao.LateTimeDouble, 108), 5), '00:00:00') AS Late
  21.                           FROM            dbo.AttendanceOverview AS ao LEFT OUTER JOIN
  22.                                                     dbo.Attendance AS a ON ao.AttendanceOverviewID = a.AttendanceOverviewID
  23.                           WHERE        (a.isAllApproved = 1) and ao.TimeIn is not null and ao.TimeOut is not null
  24.                           UNION ALL
  25.                           SELECT        d.EmployeeID, 'S' AS tipe, ISNULL(v.tgl, d.Date) AS Expr3, ISNULL(v.tgl, d.Date) AS Expr1, ISNULL(v.tgl, d.Date) AS Expr2, 'S ' + d.Note AS Expr4, 'MediumOrchid' AS color, 0 AS Late
  26.                           FROM            dbo.DayOff AS d LEFT OUTER JOIN
  27.                                                    dbo.vwp AS v ON d.EmployeeID = v.employeeid
  28.                                                    --AND CONVERT(date, v.tgl, 105) BETWEEN CONVERT(date, d.Date, 105) AND DATEADD(day, d.HowManyDays - 1, CONVERT(date, d.Date, 105)) AND
  29.                                                    inner join DayOffDetail dd on d.DayOffID = dd.DayOffID and CONVERT(date, v.tgl, 105) = CONVERT(date, dd.Tgl, 105)
  30.                                                    and v.tipe = 'Reguler'
  31.                           WHERE        (d.isAllApproved = 1) AND (d.IsDisease = 1)
  32.                           UNION ALL
  33.                           SELECT        d.EmployeeID, 'C' AS tipe, ISNULL(v.tgl, d.Date) AS Expr3, ISNULL(v.tgl, d.Date) AS Expr1, ISNULL(v.tgl, d.Date) AS Expr2, 'C ' + d.Note AS Expr4, 'MediumOrchid' AS color, 0 AS Late
  34.                           FROM            dbo.DayOff AS d INNER JOIN
  35.                                                    dbo.Constanta AS C ON d.ConstantaID = C.ConstantaID LEFT OUTER JOIN
  36.                                                    dbo.vwp AS v ON d.EmployeeID = v.employeeid
  37.                                                    --AND CONVERT(date, v.tgl, 105) BETWEEN CONVERT(date, d.Date, 105) AND DATEADD(day, d.HowManyDays - 1, CONVERT(date, d.Date, 105)) AND
  38.                                                    inner join DayOffDetail dd on d.DayOffID = dd.DayOffID and CONVERT(date, v.tgl, 105) = CONVERT(date, dd.Tgl, 105)
  39.                                                    and v.tipe = 'Reguler'
  40.                           WHERE        (d.isAllApproved = 1) AND (C.Name LIKE '%Cuti%')
  41.                           UNION ALL
  42.                           SELECT        d.EmployeeID, 'I' AS tipe, ISNULL(v.tgl, d.Date) AS Expr3, ISNULL(v.tgl, d.Date) AS Expr1, ISNULL(v.tgl, d.Date) AS Expr2, 'I ' + d.Note AS Expr4, 'MediumOrchid' AS color, 0 AS Late
  43.                             FROM            dbo.DayOff AS d INNER JOIN
  44.                                                     dbo.Constanta AS C ON d.ConstantaID = C.ConstantaID LEFT OUTER JOIN
  45.                                                     dbo.vwp AS v ON d.EmployeeID = v.employeeid
  46.                                                     --AND CONVERT(date, v.tgl, 105) BETWEEN CONVERT(date, d.Date, 105) AND DATEADD(day, d.HowManyDays - 1, CONVERT(date, d.Date, 105))
  47.                                                     AND v.tipe = 'Reguler'
  48.                                             inner join DayOffDetail dd on d.DayOffID = dd.DayOffID and CONVERT(date, v.tgl, 105) = CONVERT(date, dd.Tgl, 105)
  49.                                            
  50.                             WHERE        (d.isAllApproved = 1) AND (isnull(d.IsDisease,0) = 0) AND (C.Name NOT LIKE '%Cuti%')
  51.                           UNION ALL
  52.                           SELECT DISTINCT
  53.                                                    employeeid, 'A' AS tipe, tgl, CONVERT(datetime, CONVERT(varchar, tgl, 105) + ' ' + CONVERT(varchar(8), masuk), 105) AS masuk, CONVERT(datetime, CONVERT(varchar,
  54.                                                    CASE WHEN masuk > keluar THEN dateadd(day, 1, tgl) ELSE tgl END, 105) + ' ' + CONVERT(varchar(8), keluar), 105) AS keluar, 'A In:' + ISNULL(LEFT(CONVERT(varchar, masuk, 108), 5), '-')
  55.                                                    + '  Out:' + ISNULL(LEFT(CONVERT(varchar, keluar, 108), 5), '-') AS note, 'slategrey' AS color, 0 AS Late
  56.                           FROM            dbo.vwp
  57.                           WHERE        (tipe = 'reguler') AND (tgl IS NOT NULL)) AS a_1
  58. GO
  59.  
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement