Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. SELECT DISTINCT
  2. personnel_employee.id AS 'EmployeeID',
  3. personnel_employee.emp_code AS 'CodeID',
  4. dept_name AS 'DepartmentName',
  5. personnel_employee.first_name AS 'Name',
  6. att_attshift.alias AS 'Schedule',
  7. IF((WEEK(iclock_transaction.punch_time, 2) - WEEK(iclock_transaction.punch_time - INTERVAL DAY(iclock_transaction.punch_time)-1 DAY, 2) + 1) % 2 = 0,
  8. SELECT att1.alias FROM att_timeinterval att1 WHERE att1.id = (SELECT time_interval_id FROM att_shiftdetail ats WHERE ats.day_index = (7 + DAYOFWEEK(iclock_transaction.punch_time) - 1) LIMIT 1) LIMIT 1,
  9. SELECT att2.alias FROM att_timeinterval att2 WHERE att2.id = (SELECT time_interval_id FROM att_shiftdetail ats2 WHERE ats2.day_index = (0 + DAYOFWEEK(iclock_transaction.punch_time) - 1) LIMIT 1) LIMIT 1) AS horario,
  10. CAST(att_timeinterval.in_time AS datetime) AS 'FixedEntrance',
  11. CAST(addtime((floor(duration / 60)*10000 + (duration % 60*100)), time(att_timeinterval.in_time)) AS datetime) AS 'FixedExit',
  12. CAST(iclock_transaction.punch_time AS date) AS 'CurrentDay',
  13. DATE_FORMAT(iclock_transaction.punch_time, '%H:%i:%s') AS 'Time1'
  14. FROM
  15. att_shiftdetail
  16. INNER JOIN
  17. att_attshift
  18. ON att_attshift.id = att_shiftdetail.shift_id
  19. INNER JOIN
  20. att_timeinterval
  21. ON att_timeinterval.id = att_shiftdetail.time_interval_id
  22. INNER JOIN
  23. att_attschedule
  24. ON att_attschedule.shift_id = att_attshift.id
  25. INNER JOIN
  26. personnel_employee
  27. ON att_attschedule.employee_id = personnel_employee.id
  28. INNER JOIN
  29. iclock_transaction
  30. ON personnel_employee.emp_code = iclock_transaction.emp_code
  31. INNER JOIN
  32. personnel_department
  33. ON personnel_employee.department_id = personnel_department.id
  34. WHERE
  35. personnel_employee.status <> 3
  36. AND CAST(iclock_transaction.punch_time AS date) BETWEEN '2018-05-11' AND '2018-05-28'
  37. AND personnel_department.id = '11'
  38. AND personnel_employee.emp_code = '101104'
  39. and dayname(iclock_transaction.punch_time) = elt(att_shiftdetail.day_index mod 7 + 1, 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
  40. and elt(att_shiftdetail.day_index mod 7 + 1, '0', '1', '2', '3', '4', '5', '6') = att_shiftdetail.day_index
  41. group by
  42. iclock_transaction.punch_time
  43. ORDER BY
  44. personnel_employee.emp_code,
  45. iclock_transaction.punch_time;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement