Advertisement
vitareinforce

approach tidak dobel v2 vitra

Feb 19th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. $pernah_masuk = 0;
  2. $pernah_istirahat_mulai = 0;
  3. $pernah_istirahat_selesai = 0;
  4. $pernah_pulang = 0;
  5.  
  6. $tanggal_terdeteksi = null;
  7. $tanggal_terakhir = null;
  8.  
  9. // // cek data presensi sebelumnya
  10. $oldpresensi = Presensi::where([
  11. ['status', '=', 'Rutin'],
  12. ['slotjam', '=', $slotjam],
  13. ['karyawan_id', '=', $id_karyawan],
  14. ['tanggal_dan_waktu_tap', '=', $tanggal_waktu_tap]
  15. ])->get();
  16. if(count($oldpresensi) > 0) {
  17. for($op = 0; $op < count($oldpresensi); $op++) {
  18. $oldpresensi[$op]->update($presensi);
  19. $data_terinput = $data_terinput + 0;
  20. }
  21. } else {
  22. $tanggal_terdeteksi = date('Y-m-d', strtotime($tanggal_waktu_tap));
  23. // cek jam masuk
  24. if((($slotjam == 'Masuk') || ($slotjam == 'Terlambat Masuk')) && ($pernah_masuk == 0)) {
  25. Presensi::create($presensi);
  26. $data_terinput = $data_terinput + 1;
  27. if(($tanggal_terdeteksi == $tanggal_terakhir) || ($tanggal_terakhir == null)) {
  28. $pernah_masuk = 1;
  29. }
  30. }
  31. // cek jam istirahat mulai
  32. if($slotjam == 'Istirahat Mulai' && $pernah_istirahat_mulai == 0) {
  33. Presensi::create($presensi);
  34. $data_terinput = $data_terinput + 1;
  35. if(($tanggal_terdeteksi == $tanggal_terakhir) || ($tanggal_terakhir == null)) {
  36. $pernah_istirahat_mulai = 1;
  37. }
  38. }
  39. // cek jam istirahat selesai
  40. if($slotjam == 'Istirahat Selesai' && $pernah_istirahat_selesai == 0) {
  41. Presensi::create($presensi);
  42. $data_terinput = $data_terinput + 1;
  43. if(($tanggal_terdeteksi == $tanggal_terakhir) || ($tanggal_terakhir == null)) {
  44. $pernah_istirahat_selesai = 1;
  45. }
  46. }
  47. // cek jam pulang
  48. if($slotjam == 'Pulang' && $pernah_pulang == 0) {
  49. Presensi::create($presensi);
  50. $data_terinput = $data_terinput + 1;
  51. if(($tanggal_terdeteksi == $tanggal_terakhir) || ($tanggal_terakhir == null)) {
  52. $pernah_pulang = 1;
  53. }
  54. }
  55. $tanggal_terakhir = date('Y-m-d', strtotime($tanggal_waktu_tap));
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement