function kekurangan_keluar($batas_keluar, $jam_keluar) { $result = selisih_waktu($jam_keluar, $batas_keluar); return $result; }
function insert_new_presensi($nip, $tanggal, $jam, $src) { #echo $nip." - ".$tanggal." - ".$jam." - ".$src."<BR>"; if ($nip != "") { $TL[1] = 0; $TL[2] = 0; $TL[3] = 0; $TL[4] = 0; $PSW[1] = 0; $PSW[2] = 0; $PSW[3] = 0; $PSW[4] = 0; $m = substr($tanggal, 0, 7); $Pegawai = pegawai_id($nip); $u = substr($Pegawai->kode_bidang, 0, 2); $kode_jadwal_kerja = $Pegawai->jadwal_kerja; $oJadwalKerja = jadwal_kerja_id($kode_jadwal_kerja); cek_rekapitulasi($nip, $m, $u); if (mysql_num_rows($oJadwalKerja) != 0) { $oJadwalKerja2 = jadwal_kerja("date_from <= '" . $tanggal . "' AND date_until >= '" . $tanggal . "'"); $nJadwalKerja2 = mysql_num_rows($oJadwalKerja2); if ($nJadwalKerja2 == 0) { $JadwalKerja = mysql_fetch_array($oJadwalKerja); } else { $JadwalKerja = mysql_fetch_array($oJadwalKerja2); } $NamaHari = strtolower(nama_hari($tanggal)); $JamKerja = $JadwalKerja[$NamaHari]; $oPresensi = presensi($u, "nip = '" . $nip . "' AND tanggal = '" . $tanggal . "' AND jam = '" . $jam . "' AND (status = '0' OR status = '1' OR \r\n\t\t\t\tstatus = '9')"); $nPresensi = mysql_num_rows($oPresensi); if ($nPresensi == 0) { $oPresensi2 = presensi($u, "nip = '" . $nip . "' AND tanggal = '" . $tanggal . "' AND (status = '0' OR status = '1' OR status = '9')", "jam"); $nPresensi2 = mysql_num_rows($oPresensi2); if ($nPresensi2 == 0) { $oLibur = libur("tanggal = '" . $tanggal . "'"); $nLibur = mysql_num_rows($oLibur); $hari = strtolower(nama_hari($tanggal)); if ($nLibur == 0 and $hari != "sabtu" and $hari != "minggu") { $status = "1"; $kode_alasan = ""; $kekurangan = get_kekurangan($nip, $tanggal, $jam, $status, $kode_alasan); $hadir = 1; $TL = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "','" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t'" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $JamKerja . "','" . $src . "','10')\r\n\t\t\t\t\t\t\t"; #echo "10. ".$sql."<br>"; $query = mysql_query($sql); } else { $query = true; } } else { if ($nPresensi2 == 1) { $Presensi2 = mysql_fetch_array($oPresensi2); if ($Presensi2['jam'] == '00:00:00') { $oLibur = libur("tanggal = '" . $tanggal . "'"); $nLibur = mysql_num_rows($oLibur); $hari = strtolower(nama_hari($tanggal)); if ($nLibur == 0 and $hari != "sabtu" and $hari != "minggu") { $status = "1"; $kode_alasan = ""; $kekurangan = get_kekurangan($nip, $tanggal, $jam, $status, $kode_alasan); $hadir = 1; $TL = cek_1234($kekurangan); $sql = "DELETE FROM presensi_" . $u . " WHERE id = '" . $Presensi2['id'] . "'"; $query = mysql_query($sql); $sql = "\r\n\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "','" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t'" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $JamKerja . "','" . $src . "','11')\r\n\t\t\t\t\t\t\t\t"; #echo "11. ".$sql."<br>"; $query = mysql_query($sql); } else { $query = true; } } else { if ($jam < $Presensi2['jam']) { $oLibur = libur("tanggal = '" . $tanggal . "'"); $nLibur = mysql_num_rows($oLibur); $hari = strtolower(nama_hari($tanggal)); if ($nLibur == 0 and $hari != "sabtu" and $hari != "minggu") { $status = "1"; $kode_alasan = ""; $kekurangan = get_kekurangan($nip, $tanggal, $jam, $status, $kode_alasan); $hadir = 1; $TL = cek_1234($kekurangan); $TL[1] = cek_TL1($TL[1], $tanggal, $nip, $Presensi2['jam'], $kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,cek) \t\r\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "','" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $JamKerja . "','" . $src . "','12')\r\n\t\t\t\t\t\t\t\t\t"; #echo "12. ".$sql."<br>"; $query = mysql_query($sql); $status = "9"; $kode_alasan = ""; $kekurangan = get_kekurangan($nip, $tanggal, $Presensi2['jam'], $status, $kode_alasan); $hadir = 0; $TL[1] = 0; $TL[2] = 0; $TL[3] = 0; $TL[4] = 0; $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\tUPDATE presensi_" . $u . " \r\n\t\t\t\t\t\t\t\t\t\tSET \r\n\t\t\t\t\t\t\t\t\t\t\tstatus = '" . $status . "',\r\n\t\t\t\t\t\t\t\t\t\t\tkekurangan = '" . $kekurangan . "',\r\n\t\t\t\t\t\t\t\t\t\t\thadir = '" . $hadir . "',\r\n\t\t\t\t\t\t\t\t\t\t\tTL1 = '" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tTL2 = '" . $TL[2] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tTL3 = '" . $TL[3] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tTL4 = '" . $TL[4] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tPSW1 = '" . $PSW[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tPSW2 = '" . $PSW[2] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tPSW3 = '" . $PSW[3] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tPSW4 = '" . $PSW[4] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tcek = '13'\r\n\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $Presensi2['id'] . "'\r\n\t\t\t\t\t\t\t\t\t"; #echo "13. ".$sql."<br>"; $query = mysql_query($sql); } else { $query = true; } } else { $oLibur = libur("tanggal = '" . $tanggal . "'"); $nLibur = mysql_num_rows($oLibur); $hari = strtolower(nama_hari($tanggal)); if ($nLibur == 0 and $hari != "sabtu" and $hari != "minggu") { $TL[1] = cek_TL1($Presensi2['TL1'], $tanggal, $nip, $jam, $Presensi2['kekurangan']); } if ($TL[1] != $Presensi2['TL1']) { $sql = "UPDATE presensi_" . $u . " SET TL1 = '" . $TL[1] . "',cek = '14' WHERE id = '" . $Presensi2['id'] . "'"; #echo "14. ".$sql."<br>"; $query = mysql_query($sql); } $oLibur = libur("tanggal = '" . $tanggal . "'"); $nLibur = mysql_num_rows($oLibur); $hari = strtolower(nama_hari($tanggal)); if ($nLibur == 0 and $hari != "sabtu" and $hari != "minggu") { $status = "9"; $kode_alasan = ""; $kekurangan = get_kekurangan($nip, $tanggal, $jam, $status, $kode_alasan); $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,PSW1,PSW2,PSW3,PSW4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $PSW[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . $PSW[2] . "','" . $PSW[3] . "','" . $PSW[4] . "','" . $JamKerja . "','" . $src . "','15')\r\n\t\t\t\t\t\t\t\t\t"; #echo "15. ".$sql."<br>"; $query = mysql_query($sql); } else { $query = true; } } } } else { $oPresensi3 = presensi($u, "nip = '" . $nip . "' AND tanggal = '" . $tanggal . "' AND status = '1'"); $Presensi3 = mysql_fetch_array($oPresensi3); if ($jam < $Presensi3['jam']) { $oLibur = libur("tanggal = '" . $tanggal . "'"); $nLibur = mysql_num_rows($oLibur); $hari = strtolower(nama_hari($tanggal)); if ($nLibur == 0 and $hari != "sabtu" and $hari != "minggu") { $status = "1"; $kode_alasan = ""; $kekurangan = get_kekurangan($nip, $tanggal, $jam, $status, $kode_alasan); $hadir = 1; $TL = cek_1234($kekurangan); $oPresensi4 = presensi($u, "nip = '" . $nip . "' AND tanggal = '" . $tanggal . "' AND status = '9'"); $Presensi4 = mysql_fetch_array($oPresensi4); $TL[1] = cek_TL1($TL[1], $tanggal, $nip, $Presensi4['jam'], $kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "','" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t'" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $JamKerja . "','" . $src . "','16')\r\n\t\t\t\t\t\t\t\t"; #echo "16. ".$sql."<br>"; $query = mysql_query($sql); $sql = "DELETE FROM presensi_" . $u . " WHERE id = '" . $Presensi3['id'] . "'"; $query = mysql_query($sql); } else { $query = true; } } else { $oPresensi4 = presensi($u, "nip = '" . $nip . "' AND tanggal = '" . $tanggal . "' AND status = '9'"); $Presensi4 = mysql_fetch_array($oPresensi4); if ($jam > $Presensi4['jam']) { $oLibur = libur("tanggal = '" . $tanggal . "'"); $nLibur = mysql_num_rows($oLibur); $hari = strtolower(nama_hari($tanggal)); if ($nLibur == 0 and $hari != "sabtu" and $hari != "minggu") { $oPresensi5 = presensi($u, "nip = '" . $nip . "' AND tanggal = '" . $tanggal . "' AND status = '1'"); $Presensi5 = mysql_fetch_array($oPresensi5); $TL[1] = cek_TL1($Presensi5['TL1'], $tanggal, $nip, $jam, $Presensi5['kekurangan']); } if ($TL[1] != $Presensi5['TL1']) { $sql = "UPDATE presensi_" . $u . " SET TL1 = '" . $TL[1] . "',cek = '17' WHERE id = '" . $Presensi5['id'] . "'"; #echo "17. ".$sql."<br>"; $query = mysql_query($sql); } $oLibur = libur("tanggal = '" . $tanggal . "'"); $nLibur = mysql_num_rows($oLibur); $hari = strtolower(nama_hari($tanggal)); if ($nLibur == 0 and $hari != "sabtu" and $hari != "minggu") { $status = "9"; $kode_alasan = ""; $kekurangan = get_kekurangan($nip, $tanggal, $jam, $status, $kode_alasan); $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,PSW1,PSW2,PSW3,PSW4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $PSW[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . $PSW[2] . "','" . $PSW[3] . "','" . $PSW[4] . "','" . $JamKerja . "','" . $src . "','18')\r\n\t\t\t\t\t\t\t\t\t"; #echo "18. ".$sql."<br>"; $query = mysql_query($sql); $sql = "DELETE FROM presensi_" . $u . " WHERE id = '" . $Presensi4['id'] . "'"; $query = mysql_query($sql); } else { $query = true; } } else { $query = true; } } } } } else { $query = true; } } else { $kemarin = date("Y-m-d", strtotime($tanggal) - 1); $oJadwalShiftKemarin = jadwal_shift("nip = '" . $nip . "' AND tanggal = '" . $kemarin . "' AND jam_masuk > jam_keluar"); $nJadwalShiftKemarin = mysql_num_rows($oJadwalShiftKemarin); if ($nJadwalShiftKemarin != 0) { $JadwalShiftKemarin = mysql_fetch_array($oJadwalShiftKemarin); $oId[] = $JadwalShiftKemarin['id']; $oNip[] = $JadwalShiftKemarin['nip']; $oTanggal[] = $JadwalShiftKemarin['tanggal']; $oJamKerja[] = $JadwalShiftKemarin['jam_kerja']; $oJamMasuk[] = $JadwalShiftKemarin['jam_masuk']; $oJamKeluar[] = $JadwalShiftKemarin['jam_keluar']; $oCekMasuk[] = $JadwalShiftKemarin['cek_masuk']; $oCekKeluar[] = $JadwalShiftKemarin['cek_keluar']; $oCek[] = $JadwalShiftKemarin['cek']; } $oJadwalShift = jadwal_shift("nip = '" . $nip . "' AND tanggal = '" . $tanggal . "' AND jam_kerja != 'L'", "jam_masuk"); $nJadwalShift = mysql_num_rows($oJadwalShift); if ($nJadwalShift != 0) { while ($JadwalShift = mysql_fetch_array($oJadwalShift)) { $oId[] = $JadwalShift['id']; $oNip[] = $JadwalShift['nip']; $oTanggal[] = $JadwalShift['tanggal']; $oJamKerja[] = $JadwalShift['jam_kerja']; $oJamMasuk[] = $JadwalShift['jam_masuk']; $oJamKeluar[] = $JadwalShift['jam_keluar']; $oCekMasuk[] = $JadwalShift['cek_masuk']; $oCekKeluar[] = $JadwalShift['cek_keluar']; $oCek[] = $JadwalShift['cek']; } } $n = count(@$oId); if ($n > 0) { for ($k = 0; $k < $n; $k++) { #echo "<BR>"; if ($oCekMasuk[$k] == 0) { $oPresensi = presensi($u, "nip = '" . $nip . "' AND jam_kerja = '" . $oId[$k] . "'", "status"); $nPresensi = mysql_num_rows($oPresensi); if ($nPresensi == 0) { $status = "1"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $k == 0 and $tanggal > $oTanggal[$k]) { $hour = substr($jam, 0, 2); $hour += 24; $hour .= substr($jam, 2, 6); } else { $hour = $jam; } $kekurangan = selisih_waktu($oJamMasuk[$k], $hour); $hadir = 1; $TL = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "','" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t'" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $oId[$k] . "','" . $src . "','30')\r\n\t\t\t\t\t\t\t\t"; #echo "30. ".$sql."<br>"; $query = mysql_query($sql); $status = "9"; $kode_alasan = ""; $jam = "00:00:00"; $kekurangan = 450 - $kekurangan; $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,status,kekurangan,PSW1,PSW2,PSW3,PSW4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $status . "','" . $kekurangan . "','" . $PSW[1] . "','" . $PSW[2] . "',\r\n\t\t\t\t\t\t\t\t\t'" . $PSW[3] . "','" . $PSW[4] . "','" . $oId[$k] . "','" . $src . "','31')\r\n\t\t\t\t\t\t\t\t"; #echo "31. ".$sql."<br>"; $query = mysql_query($sql); $sql = "UPDATE jadwal_shift SET cek_masuk = '1',cek = '1' WHERE id = '" . $oId[$k] . "'"; $query = mysql_query($sql); $k = $n; } else { if ($nPresensi == 1) { $Presensi = mysql_fetch_array($oPresensi); if ($Presensi['jam'] == "00:00:00") { $status = "1"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $k == 0 and $tanggal > $oTanggal[$k]) { $hour = substr($jam, 0, 2); $hour += 24; $hour .= substr($jam, 2, 6); } else { $hour = $jam; } $kekurangan = selisih_waktu($oJamMasuk[$k], $hour); $hadir = 1; $TL = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "','" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $oId[$k] . "','" . $src . "','32')\r\n\t\t\t\t\t\t\t\t\t"; #echo "32. ".$sql."<br>"; $query = mysql_query($sql); $status = "9"; $kode_alasan = ""; $jam = "00:00:00"; $kekurangan = 450 - $kekurangan; $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,status,kekurangan,PSW1,PSW2,PSW3,PSW4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $status . "','" . $kekurangan . "','" . $PSW[1] . "','" . $PSW[2] . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . $PSW[3] . "','" . $PSW[4] . "','" . $oId[$k] . "','" . $src . "','33')\r\n\t\t\t\t\t\t\t\t\t"; #echo "33. ".$sql."<br>"; $query = mysql_query($sql); $sql = "DELETE FROM presensi_" . $u . " WHERE id = '" . $Presensi['id'] . "'"; $query = mysql_query($sql); $sql = "UPDATE jadwal_shift SET cek_masuk = '1',cek = '1' WHERE id = '" . $oId[$k] . "'"; $query = mysql_query($sql); $k = $n; } else { $query = true; $k = $n; } } else { $query = true; $k = $n; } } } else { if ($oCekKeluar[$k] == 0) { $oPresensi = presensi($u, "nip = '" . $nip . "' AND jam_kerja = '" . $oId[$k] . "'", "status"); $nPresensi = mysql_num_rows($oPresensi); if ($nPresensi == 1) { $Presensi = mysql_fetch_array($oPresensi); if ($Presensi['jam'] == "00:00:00") { $status = "1"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $k == 0 and $tanggal > $oTanggal[$k]) { $hour = substr($jam, 0, 2); $hour += 24; $hour .= substr($jam, 2, 6); } else { $hour = $jam; } $kekurangan = selisih_waktu($oJamMasuk[$k], $hour); $hadir = 1; $TL = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "','" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $oId[$k] . "','" . $src . "','34')\r\n\t\t\t\t\t\t\t\t\t"; #echo "34. ".$sql."<br>"; $query = mysql_query($sql); $status = "9"; $kode_alasan = ""; $jam = "00:00:00"; $kekurangan = 450 - $kekurangan; $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,status,kekurangan,PSW1,PSW2,PSW3,PSW4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $status . "','" . $kekurangan . "','" . $PSW[1] . "','" . $PSW[2] . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . $PSW[3] . "','" . $PSW[4] . "','" . $oId[$k] . "','" . $src . "','35')\r\n\t\t\t\t\t\t\t\t\t"; #echo "35. ".$sql."<br>"; $query = mysql_query($sql); $sql = "DELETE FROM presensi_" . $u . " WHERE id = '" . $Presensi['id'] . "'"; $query = mysql_query($sql); $sql = "UPDATE jadwal_shift SET cek_masuk = '1',cek = '1' WHERE id = '" . $oId[$k] . "'"; $query = mysql_query($sql); $k = $n; } else { if ($jam < $Presensi['jam'] and $tanggal == $Presensi['tanggal']) { $status = "1"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $k == 0 and $tanggal > $oTanggal[$k]) { $hour = substr($jam, 0, 2); $hour += 24; $hour .= substr($jam, 2, 6); } else { $hour = $jam; } $kekurangan = selisih_waktu($oJamMasuk[$k], $hour); $kekurangan_in = $kekurangan; $hadir = 1; $TL = cek_1234($kekurangan); /* if ($TL[1] == 1) { $batas_keluar = $oJamKeluar[$k]; $selisih = (60 * (substr($Presensi['jam'] ,0,2) - substr($batas_keluar,0,2))) + substr($Presensi['jam'],3,2) - substr($batas_keluar,3,2); if ($selisih >= $kekurangan) $TL[1] = 0; } */ $sql = "\r\n\t\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,cek) \t\r\n\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "','" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $oId[$k] . "','" . $src . "','36')\r\n\t\t\t\t\t\t\t\t\t\t"; #echo "36. ".$sql."<br>"; $query = mysql_query($sql); $status = "9"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $tanggal == $oTanggal[$k]) { $hour = substr($oJamKeluar[$k], 0, 2); $hour += 24; $hour .= substr($oJamKeluar[$k], 2, 6); } else { $hour = $oJamKeluar[$k]; } $kekurangan = selisih_waktu($Presensi['jam'], $hour); if ($kekurangan + $kekurangan_in > 450) { $kekurangan = 450 - $kekurangan_in; } $hadir = 0; $TL[1] = 0; $TL[2] = 0; $TL[3] = 0; $TL[4] = 0; $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\t\tUPDATE presensi_" . $u . " \r\n\t\t\t\t\t\t\t\t\t\t\tSET \r\n\t\t\t\t\t\t\t\t\t\t\t\tstatus = '" . $status . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tkekurangan = '" . $kekurangan . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\thadir = '" . $hadir . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tTL1 = '" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tTL2 = '" . $TL[2] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tTL3 = '" . $TL[3] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tTL4 = '" . $TL[4] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tPSW1 = '" . $PSW[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tPSW2 = '" . $PSW[2] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tPSW3 = '" . $PSW[3] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tPSW4 = '" . $PSW[4] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tcek = '37'\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $Presensi['id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t"; #echo "37. ".$sql."<br>"; $query = mysql_query($sql); $sql = "UPDATE jadwal_shift SET cek_keluar = '1',cek = '1' WHERE id = '" . $oId[$k] . "'"; $query = mysql_query($sql); $k = $n; } else { /* if ($Presensi['TL1'] == 1) { $batas_keluar = $oJamKeluar[$k]; $selisih = (60 * (substr($jam ,0,2) - substr($batas_keluar,0,2))) + substr($jam,3,2) - substr($batas_keluar,3,2); if ($selisih >= $Presensi['kekurangan']) $TL[1] = 0; else $TL[1] = $Presensi['TL1']; } if ($TL[1] != $Presensi['TL1']) { $sql = "UPDATE presensi_".$u." SET TL1 = '".$TL[1]."',cek = '38' WHERE id = '".$Presensi['id']."'"; #echo "38. ".$sql."<br>"; $query = mysql_query($sql); } */ $status = "9"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $tanggal == $oTanggal[$k]) { $hour = substr($oJamKeluar[$k], 0, 2); $hour += 24; $hour .= substr($oJamKeluar[$k], 2, 6); } else { $hour = $oJamKeluar[$k]; } $kekurangan = selisih_waktu($jam, $hour); if ($kekurangan + $Presensi['kekurangan'] > 450) { $kekurangan = 450 - $Presensi['kekurangan']; } $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,PSW1,PSW2,PSW3,PSW4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $PSW[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $PSW[2] . "','" . $PSW[3] . "','" . $PSW[4] . "','" . $oId[$k] . "','" . $src . "','39')\r\n\t\t\t\t\t\t\t\t\t\t"; #echo "39. ".$sql."<br>"; $query = mysql_query($sql); $sql = "UPDATE jadwal_shift SET cek_keluar = '1',cek = '1' WHERE id = '" . $oId[$k] . "'"; $query = mysql_query($sql); $k = $n; } } } else { $oPresensi2 = presensi($u, "nip = '" . $nip . "' AND jam_kerja = '" . $oId[$k] . "' AND status = '9'"); $nPresensi2 = mysql_num_rows($oPresensi2); if ($nPresensi2 != 0) { $Presensi2 = mysql_fetch_array($oPresensi2); if ($jam > $Presensi2['jam']) { $oPresensi3 = presensi($u, "nip = '" . $nip . "' AND jam_kerja = '" . $oId[$k] . "' AND status = '1'"); $Presensi3 = mysql_fetch_array($oPresensi3); if ($jam < $Presensi3['jam'] and $tanggal == $Presensi3['tanggal'] or $jam > $Presensi3['jam'] and $tanggal < $Presensi3['tanggal']) { $status = "1"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $k == 0 and $tanggal > $oTanggal[$k]) { $hour = substr($jam, 0, 2); $hour += 24; $hour .= substr($jam, 2, 6); } else { $hour = $jam; } $kekurangan = selisih_waktu($oJamMasuk[$k], $hour); $kekurangan_in = $kekurangan; $hadir = 1; $TL = cek_1234($kekurangan); /* if ($TL[1] == 1) { $batas_keluar = $oJamKeluar[$k]; $selisih = (60 * (substr($Presensi3['jam'] ,0,2) - substr($batas_keluar,0,2))) + substr($Presensi3['jam'],3,2) - substr($batas_keluar,3,2); if ($selisih >= $kekurangan) $TL[1] = 0; } */ $sql = "\r\n\t\t\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,\r\n\t\t\t\t\t\t\t\t\t\t\t\tcek) \r\n\t\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $TL[1] . "','" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $oId[$k] . "','" . $src . "','40')\r\n\t\t\t\t\t\t\t\t\t\t\t"; #echo "40. ".$sql."<br>"; $query = mysql_query($sql); $status = "9"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $tanggal > $oTanggal[$k]) { $hour = substr($oJamKeluar[$k], 0, 2); $hour += 24; $hour .= substr($oJamKeluar[$k], 2, 6); } else { $hour = $oJamKeluar[$k]; } $kekurangan = selisih_waktu($Presensi3['jam'], $hour); if ($kekurangan + $kekurangan_in > 450) { $kekurangan = 450 - $kekurangan_in; } $hadir = 0; $TL[1] = 0; $TL[2] = 0; $TL[3] = 0; $TL[4] = 0; $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\t\t\tUPDATE presensi_" . $u . " \r\n\t\t\t\t\t\t\t\t\t\t\t\tSET \r\n\t\t\t\t\t\t\t\t\t\t\t\t\tstatus = '" . $status . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tkekurangan = '" . $kekurangan . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\thadir = '" . $hadir . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tTL1 = '" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tTL2 = '" . $TL[2] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tTL3 = '" . $TL[3] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tTL4 = '" . $TL[4] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tPSW1 = '" . $PSW[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tPSW2 = '" . $PSW[2] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tPSW3 = '" . $PSW[3] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tPSW4 = '" . $PSW[4] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tcek = '41'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $Presensi3['id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t"; #echo "41. ".$sql."<br>"; $query = mysql_query($sql); $sql = "DELETE FROM presensi_" . $u . " WHERE id = '" . $Presensi2['id'] . "'"; $query = mysql_query($sql); $sql = "UPDATE jadwal_shift SET cek_keluar = '1',cek = '1' WHERE id = '" . $oId[$k] . "'"; $query = mysql_query($sql); $k = $n; } else { $oPresensi4 = presensi($u, "nip = '" . $nip . "' AND jam_kerja = '" . $oId[$k] . "' AND status = '1'"); $Presensi4 = mysql_fetch_array($oPresensi4); /* if ($Presensi4['TL1'] == 1) { $batas_keluar = $oJamKeluar[$k]; $selisih = (60 * (substr($jam ,0,2) - substr($batas_keluar,0,2))) + substr($jam,3,2) - substr($batas_keluar,3,2); if ($selisih >= $Presensi4['kekurangan']) $TL[1] = 0; else $TL[1] = $Presensi4['TL1']; } if ($TL[1] != $Presensi4['TL1']) { $sql = "UPDATE presensi_".$u." SET TL1 = '".$TL[1]."',cek = '42' WHERE id = '".$Presensi4['id']."'"; #echo "42. ".$sql."<br>"; $query = mysql_query($sql); } */ $status = "9"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $tanggal == $oTanggal[$k]) { $hour = substr($oJamKeluar[$k], 0, 2); $hour += 24; $hour .= substr($oJamKeluar[$k], 2, 6); } else { $hour = $oJamKeluar[$k]; } $kekurangan = selisih_waktu($jam, $hour); if ($kekurangan + $Presensi4['kekurangan'] > 450) { $kekurangan = 450 - $Presensi4['kekurangan']; } $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,PSW1,PSW2,PSW3,PSW4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $PSW[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $PSW[2] . "','" . $PSW[3] . "','" . $PSW[4] . "','" . $oId[$k] . "','" . $src . "','43')\r\n\t\t\t\t\t\t\t\t\t\t\t"; #echo "43. ".$sql."<br>"; $query = mysql_query($sql); $sql = "DELETE FROM presensi_" . $u . " WHERE id = '" . $Presensi2['id'] . "'"; $query = mysql_query($sql); $sql = "UPDATE jadwal_shift SET cek_keluar = '1',cek = '1' WHERE id = '" . $oId[$k] . "'"; $query = mysql_query($sql); $k = $n; } } else { $query = true; $k = $n; } } else { $query = true; $k = $n; } } } else { $oPresensi = presensi($u, "nip = '" . $nip . "' AND jam_kerja = '" . $oId[$k] . "' AND status = '1'"); $Presensi = mysql_fetch_array($oPresensi); if ($jam < $Presensi['jam'] and $tanggal == $Presensi['tanggal']) { $status = "1"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $k == 0 and $tanggal > $oTanggal[$k]) { $hour = substr($jam, 0, 2); $hour += 24; $hour .= substr($jam, 2, 6); } else { $hour = $jam; } $kekurangan = selisih_waktu($oJamMasuk[$k], $hour); $hadir = 1; $TL = cek_1234($kekurangan); $oPresensi2 = presensi($u, "nip = '" . $nip . "' AND jam_kerja = '" . $oId[$k] . "' AND status = '9'"); $Presensi2 = mysql_fetch_array($oPresensi2); /* if ($TL[1] == 1) { $batas_keluar = $oJamKeluar[$k]; $selisih = (60 * (substr($Presensi2['jam'] ,0,2) - substr($batas_keluar,0,2))) + substr($Presensi2['jam'],3,2) - substr($batas_keluar,3,2); if ($selisih >= $kekurangan) $TL[1] = 0; } */ $sql = "\r\n\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,hadir,TL1,TL2,TL3,TL4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $hadir . "','" . $TL[1] . "',\r\n\t\t\t\t\t\t\t\t\t'" . $TL[2] . "','" . $TL[3] . "','" . $TL[4] . "','" . $oId[$k] . "','" . $src . "','44')\r\n\t\t\t\t\t\t\t\t"; #echo "44. ".$sql."<br>"; $query = mysql_query($sql); $sql = "DELETE FROM presensi_" . $u . " WHERE id = '" . $Presensi['id'] . "'"; $query = mysql_query($sql); } else { $oPresensi2 = presensi($u, "nip = '" . $nip . "' AND jam_kerja = '" . $oId[$k] . "' AND status = '9'"); $Presensi2 = mysql_fetch_array($oPresensi2); if ($jam > $Presensi2['jam'] and $tanggal == $Presensi2['tanggal'] or $tanggal > $Presensi2['tanggal']) { $oPresensi3 = presensi($u, "nip = '" . $nip . "' AND jam_kerja = '" . $oId[$k] . "' AND status = '1'"); $Presensi3 = mysql_fetch_array($oPresensi3); /* if ($Presensi3['TL1'] == 1) { $batas_keluar = $oJamKeluar[$k]; $selisih = (60 * (substr($jam ,0,2) - substr($batas_keluar,0,2))) + substr($jam,3,2) - substr($batas_keluar,3,2); if ($selisih >= $Presensi3['kekurangan']) $TL[1] = 0; else $TL[1] = $Presensi3['TL1']; } if ($TL[1] != $Presensi3['TL1']) { $sql = "UPDATE presensi_".$u." SET TL1 = '".$TL[1]."',cek = '45' WHERE id = '".$Presensi3['id']."'"; #echo "45. ".$sql."<br>"; $query = mysql_query($sql); } */ $status = "9"; $kode_alasan = ""; if ($oJamMasuk[$k] > $oJamKeluar[$k] and $tanggal == $oTanggal[$k]) { $hour = substr($oJamKeluar[$k], 0, 2); $hour += 24; $hour .= substr($oJamKeluar[$k], 2, 6); } else { $hour = $oJamKeluar[$k]; } $kekurangan = selisih_waktu($jam, $hour); if ($kekurangan + $Presensi3['kekurangan'] > 450) { $kekurangan = 450 - $Presensi3['kekurangan']; } $PSW = cek_1234($kekurangan); $sql = "\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO presensi_" . $u . " (nip,tanggal,jam,status,kekurangan,PSW1,PSW2,PSW3,PSW4,jam_kerja,src,cek) \r\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $nip . "','" . $tanggal . "','" . $jam . "','" . $status . "','" . $kekurangan . "','" . $PSW[1] . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . $PSW[2] . "','" . $PSW[3] . "','" . $PSW[4] . "','" . $oId[$k] . "','" . $src . "','46')\r\n\t\t\t\t\t\t\t\t\t"; #echo "46. ".$sql."<br>"; $query = mysql_query($sql); $sql = "DELETE FROM presensi_" . $u . " WHERE id = '" . $Presensi2['id'] . "'"; $query = mysql_query($sql); } else { $query = true; $k = $n; } } } } } } else { $query = true; } } } else { $query = true; } if (@$query) { $result = true; } else { $result = false; } return $result; }