Advertisement
vitareinforce

approach biar ga dobel vitra version

Feb 19th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 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;
  7. $tanggal_terakhir;
  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. dd('masuk for');
  19. $oldpresensi[$op]->update($presensi);
  20. $data_terinput = $data_terinput + 0;
  21. }
  22. } else {
  23. $tanggal_terdeteksi = date('Y-m-d', strtotime($tanggal_waktu_tap));
  24. // cek jam masuk
  25. if((($slotjam == 'Masuk') || ($slotjam == 'Terlambat Masuk')) && ($pernah_masuk == 0)) {
  26. Presensi::create($presensi);
  27. $data_terinput = $data_terinput + 1;
  28. if($tanggal_terdeteksi == $tanggal_terakhir) {
  29. $pernah_masuk = 1;
  30. }
  31. }
  32. // cek jam istirahat mulai
  33. if($slotjam == 'Istirahat Mulai' && $pernah_istirahat_mulai == 0) {
  34. dd('ismul');
  35. Presensi::create($presensi);
  36. $data_terinput = $data_terinput + 1;
  37. if($tanggal_terdeteksi == $tanggal_terakhir) {
  38. $pernah_istirahat_mulai = 1;
  39. }
  40. }
  41. // cek jam istirahat selesai
  42. if($slotjam == 'Istirahat Selesai' && $pernah_istirahat_selesai == 0) {
  43. dd('issel');
  44. Presensi::create($presensi);
  45. $data_terinput = $data_terinput + 1;
  46. if($tanggal_terdeteksi == $tanggal_terakhir) {
  47. $pernah_istirahat_selesai = 1;
  48. }
  49. }
  50. // cek jam pulang
  51. if($slotjam == 'Pulang' && $pernah_pulang == 0) {
  52. dd('pulang');
  53. Presensi::create($presensi);
  54. $data_terinput = $data_terinput + 1;
  55. if($tanggal_terdeteksi == $tanggal_terakhir) {
  56. $pernah_pulang = 1;
  57. }
  58. }
  59. $tanggal_terakhir = date('Y-m-d', strtotime($tanggal_waktu_tap));
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement