[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
Backup
/
14082024
/
Data
/
htdocs
/
htdocs
/
simpeg
/
administrator
/
[
Home
]
File: absensi.php
<?php require_once("../lib/konek.php"); require_once("../lib/konfigurasi_semua.php"); require_once("../lib/cur.php"); require_once("../lib/function_tanggal.php"); $ip = getenv("REMOTE_ADDR"); $sql = "select ip_id from ip_register where ip_address = '".$ip."'"; // echo $sql; $rs = mysql_query($sql); $cekIp = mysql_fetch_array($rs); if(!$cekIp) { echo "<script>window.alert('IP anda tidak terdaftar dalam program kami.');</script>"; // echo "<script>window.parent.document.location.href='../index.php?hal=administrator/tolak.php';</script>"; } $ar_wkt = explode(":",$wkt); $detik_wkt = ($ar_wkt[0]*60*60)+($ar_wkt[1]*60)+$ar_wkt[2]; $sql = "select akses_id from hrd_hak_akses a left join hrd_form b on a.id_form=b.form_id left join hrd_user_login c on a.id_lj = c.id_lj where b.form_nama='absensi' and c.user_id = ".$_SESSION["hrd-id"]; $rs = mysql_query($sql); $prevO = mysql_fetch_array($rs); if(!$prevO) header("location:tolak.php"); $sql = "select * from hrd_user_login a left join hrd_pgw b on a.id_pgw = b.pgw_id left join hrd_jabatan_pegawai c on b.id_jab_pgw = c.jab_pgw_id where user_id = ".$_SESSION["hrd-id"]; $rs = mysql_query($sql); $dataPgw=mysql_fetch_array($rs); // echo "AA".$_POST["btnCek"]; if(isset($_POST["btnCek"])) { $sql = "select count(absen_id) as jml from hrd_absen where id_user = ".$_SESSION["hrd-id"]." and absen_tgl = '".$skr."'"; $rs = mysql_query($sql); $statCek = mysql_fetch_array($rs); if($statCek["jml"]==0) { $act = "in"; $_POST["act"] = $act; }else{ $sql = "select absen_id from hrd_absen where absen_cout is null and id_user = ".$_SESSION["hrd-id"]." and absen_tgl = '".$skr."' order by absen_cin desc"; $rs = mysql_query($sql); $statCek2 = mysql_fetch_array($rs); if($statCek2["absen_id"]) { $act = "out"; $_POST["act"] = $act; }else{ $act = "in"; $_POST["act"] = $act; } } } // echo "<script>window.alert('".$_POST["act"]."');</script>"; if($_POST["act"] == "in") { $sql = "select * from hrd_absen where absen_tgl = '".$skr."' and id_user = ".$_SESSION["hrd-id"]; $rs = mysql_query($sql); $cekAbsen = mysql_fetch_array($rs); // echo $sql; if($cekAbsen) { $sql = "select max(absen_id) as id from hrd_absen"; $Qrs = mysql_query($sql); $id = mysql_fetch_array($Qrs); $absenId = $id["id"]+1; $sql = "insert into hrd_absen (absen_id,absen_tgl,id_user,absen_cin) values(".$absenId.",'".$skr."',".$_SESSION["hrd-id"].",'".$wkt."')"; $rs = mysql_query($sql); }else{ $hitung_kmrn = strtotime($skr)-(86400*1); $kmrn = date("Y-m-d",$hitung_kmrn); $sql = "select * from hrd_absen where absen_tgl = '".$kmrn."' and id_user = ".$_SESSION["hrd-id"]; $rs = mysql_query($sql); $cekAbsenKemarin = mysql_fetch_array($rs); if(!$cekAbsenKemarin) { echo "<script>window.alert('Anda kemarin belum absen / tidak masuk');</script>"; }else{ $sql = "select * from hrd_absen where absen_tgl = '".$kmrn."' and id_user = ".$_SESSION["hrd-id"]." order by absen_cout desc"; $rs = mysql_query($sql); $cekAbsenKemarinCout = mysql_fetch_array($rs); if(!$cekAbsenKemarinCout["absen_cout"]) { echo "<script>window.alert('Anda kemarin belum cek out');</script>"; } } $ar_cin = explode(":",$dataPgw["pgw_cin"]); $detik_cin = ($ar_cin[0]*60*60)+($ar_cin[1]*60)+$ar_cin[2]; if($detik_wkt>$detik_cin) { echo "<script>window.alert('Anda telat hari ini');</script>"; $ket_telat = "y"; }else{ $ket_telat = "n"; } $sql = "select max(absen_id) as id from hrd_absen"; $Qrs = mysql_query($sql); $id = mysql_fetch_array($Qrs); $absenId = $id["id"]+1; $sql = "insert into hrd_absen (absen_id,absen_tgl,id_user,absen_cin,absen_telat) values(".$absenId.",'".$skr."',".$_SESSION["hrd-id"].",'".$wkt."','".$ket_telat."')"; $rs = mysql_query($sql); } }elseif($_POST["act"] == "out"){ if($_POST["absen_ket"]) { $sql = "select absen_id from hrd_absen where absen_cout is null and id_user = ".$_SESSION["hrd-id"]." and absen_tgl = '".$skr."'"; $rs = mysql_query($sql); $statCek = mysql_fetch_array($rs); $sql = "update hrd_absen set absen_tgl = '".$skr."',id_user = ".$_SESSION["hrd-id"].",absen_cout = '".$wkt."', absen_ket = '".$_POST["absen_ket"]."' where absen_id = ".$statCek["absen_id"].""; $rs = mysql_query($sql); }else{ echo "<script>window.alert('Keterangan harus diisi terlebih dahulu');</script>"; } } $sql = "select count(absen_id) as jml from hrd_absen where id_user = ".$_SESSION["hrd-id"]." and absen_tgl = '".$skr."'"; $rs = mysql_query($sql); $statCek = mysql_fetch_array($rs); if($statCek["jml"]==0) { $act = "in"; $_POST["act"] = $act; }else{ $sql = "select absen_id from hrd_absen where absen_cout is null and id_user = ".$_SESSION["hrd-id"]." and absen_tgl = '".$skr."' order by absen_cin desc"; $rs = mysql_query($sql); $statCek2 = mysql_fetch_array($rs); if($statCek2["absen_id"]) { $act = "out"; $_POST["act"] = $act; }else{ $act = "in"; $_POST["act"] = $act; } } $absen = 0; //config bln $bln_array = explode("-",$skr); $tgl_now = $bln_array[2]; if(!$_POST["bulan"]) { $bln = $bln_array[1]; $_POST["bulan"] = $bln_array[1]; }else{ $bln = $_POST["bulan"]; } if(!$_POST["tahun"]) { $thn = $bln_array[0]; $_POST["tahun"] = $bln_array[0]; }else{ $thn = $_POST["tahun"]; } if($bln == "01") $jml_bln = "31"; if($bln == "02") { if(($bln_array[0]%4) == 0) { $jml_bln = "29"; }else{ $jml_bln = "28"; } } if($bln == "03") $jml_bln = "31"; if($bln == "04") $jml_bln = "30"; if($bln == "05") $jml_bln = "31"; if($bln == "06") $jml_bln = "30"; if($bln == "07") $jml_bln = "31"; if($bln == "08") $jml_bln = "31"; if($bln == "09") $jml_bln = "30"; if($bln == "10") $jml_bln = "31"; if($bln == "11") $jml_bln = "30"; if($bln == "12") $jml_bln = "31"; //end //kuota jam perbulan $totalBln = 0; $date_array = explode("-",$skr); $sql = "select * from hrd_absen where absen_tgl between '".$date_array[0]."-".$date_array[1]."-01' and '".$date_array[0]."-".$date_array[1]."-".$jml_bln."' and id_user = ".$_SESSION["hrd-id"]." and absen_cin is not null and absen_cout is not null"; $rs = mysql_query($sql); while($dataAbsensi=mysql_fetch_array($rs)) { $total = (strtotime($dataAbsensi["absen_cout"])-strtotime($dataAbsensi["absen_cin"])); $totalBln = $totalBln+$total; } $total_menit = round($totalBln/60); $total_jam = 0; if($total_menit>60) { $total_jam = round($totalBln/3600); $tJam = ($totalBln/3600)+0.5; if($tJam<=($total_jam+0.5)) { $total_jam = $total_jam-1; } $total_menit = round(($totalBln-($total_jam*3600))/60); } //end //kuota perhari $sql = "select * from hrd_absen where absen_tgl = '".$skr."' and id_user = ".$_SESSION["hrd-id"]." and absen_cin is not null and absen_cout is not null"; $rs = mysql_query($sql); while($dataAbsensi=mysql_fetch_array($rs)) { $total_hr_ini = (strtotime($dataAbsensi["absen_cout"])-strtotime($dataAbsensi["absen_cin"])); $totalBln_hr_ini = $totalBln_hr_ini+$total_hr_ini; } $total_menit_hr_ini = round($totalBln_hr_ini/60); $total_jam_hr_ini = 0; if($total_menit_hr_ini>60) { $total_jam_hr_ini = round($totalBln_hr_ini/3600); $tJam_hr_ini = ($totalBln_hr_ini/3600)+0.5; if($tJam_hr_ini<=($total_jam_hr_ini+0.5)) { $total_jam_hr_ini = $total_jam_hr_ini-1; } $total_menit_hr_ini = round(($totalBln_hr_ini-($total_jam_hr_ini*3600))/60); } //end //telat $totalBln = 0; $date_array = explode("-",$skr); $sql = "select count(absen_id) as jml_tlt from hrd_absen where absen_tgl between '".$date_array[0]."-".$date_array[1]."-01' and '".$date_array[0]."-".$date_array[1]."-".$jml_bln."' and id_user = ".$_SESSION["hrd-id"]." and absen_telat = 'y'"; $rs = mysql_query($sql); $dataTelat=mysql_fetch_array($rs); $telat_bln = $dataTelat["jml_tlt"]; //end //kehadiran for($start=0, $end=$tgl_now; $start<$end; $start++) { if(($start+1) < 10) $dt = "0".($start+1); else $dt = ($start+1); $tgl = $thn."-".$bln."-".$dt; $hari = GetDayName($tgl); if($hari!="Minggu") { $sql = "select distinct absen_id, absen_tgl from hrd_absen where id_user = ".$_SESSION["hrd-id"]." and absen_tgl = '".$tgl."'"; $rs = mysql_query($sql); $cekAbsen = mysql_fetch_array($rs); if($cekAbsen) { $hadir = $hadir+1; $jmlHrGj = $jmlHrGj+1; }else{ $hadir = $hadir+0; $absen = $absen+1; } }else{ $jmlHrGj = $jmlHrGj+1; } } //end //konfigurasi tabel utama $tbHeader[0] = "Tanggal"; $tbHeaderWidth[0] = "150"; $tbContent[0] = "absen_tgl"; $tbContentAlign[0] = "center"; $tbHeader[1] = "Cek In"; $tbHeaderWidth[1] = "150"; $tbContent[1] = "absen_cin"; $tbContentAlign[1] = "center"; $tbHeader[2] = "Cek Out"; $tbHeaderWidth[2] = "150"; $tbContent[2] = "absen_cout"; $tbContentAlign[2] = "center"; $tbHeader[3] = "Keterangan"; $tbHeaderWidth[3] = "550"; $tbContent[3] = "absen_ket"; $tbContentAlign[3] = "left"; //query ke tabel form $sql = "select * from hrd_absen where absen_tgl = '".$skr."' and id_user = ".$_SESSION["hrd-id"]; if($_POST["order_by"]) { $sql .= " order by ".$_POST["order_by"]." ".$_POST["sort"]; }else{ $sql .= " order by absen_tgl"; } $QdataForm = mysql_query($sql); $dir_img = "../img"; ?> <html> <head> <title><?php echo $header;?></title> </head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="../lib/lib-style.css"> <script language="JavaScript" type="text/javascript" src="../lib/ew.js"></script> <style> body { margin: 0px; } </style> <body> <form name="frmEdit" method="POST" action="absensi.php"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td colspan="2" align="left" valign="middle" bgcolor="#000000" height="28"> <font face="Verdana, Arial, Helvetica, sans-serif" size="4" color="white"> <?php echo $header;?></font> </td> </tr> <tr> <td colspan="2" align="left" bgcolor="#DEDBE7" height="20"> <?php include("menu_atas.php"); ?> </td> </tr> <tr> <td colspan="2"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr background="<?php echo $dir_img;?>/background.jpg" valign="middle" height="50"> <td width="10%" align="center"> <img src="<?php echo $dir_img;?>/smi.png" width="64"> </td> <td height="50" width="*"> <?php echo $defFont;?> <b>Nama Karyawan</b> : <?php echo $dataPgw["pgw_nama"];?><br> <b>Jabatan</b> : <?php echo $dataPgw["jab_pgw_nama"];?><br> </font> </td> </tr> </table> </td> </tr> <tr> <td width="40%" valign="top"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr valign="top"> <td colspan="2"> <table border="0" width="90%" align="center"> <tr> <td> <fieldset> <legend><b><?php echo $defFont;?>Detail</font></b></legend> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="50%"><?php echo $defFont;?><b>Jam Masuk / Pulang</b></td> <td width="2%"><?php echo $defFont;?>:</td> <td width="48%"><?php echo $defFont;?><?php echo $dataPgw["pgw_cin"];?> / <?php echo $dataPgw["pgw_cout"];?></td> <tr> <tr> <td><?php echo $defFont;?><b>Jumlah Jam Kerja hari ini</b></td> <td><?php echo $defFont;?>:</td> <td><?php echo $defFont;?><?php echo $total_jam_hr_ini;?> jam, <?php echo $total_menit_hr_ini;?> menit</td> <tr> <tr> <td><?php echo $defFont;?><b>Jumlah Jam Kerja bulan ini</b></td> <td><?php echo $defFont;?>:</td> <td><?php echo $defFont;?><?php echo $total_jam;?> jam, <?php echo $total_menit;?> menit</td> <tr> </table> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="50%"><?php echo $defFont;?><b>Jumlah Telat bulan ini</b></td> <td width="2%"><?php echo $defFont;?>:</td> <td width="48%"><?php echo $defFont;?><?php echo $telat_bln;?> kali</td> <tr> <tr> <td><?php echo $defFont;?><b>Hadir / Absen</b></td> <td><?php echo $defFont;?>:</td> <td><?php echo $defFont;?><?php echo $hadir;?> / <?php echo $absen;?> </td> <tr> <tr> <td><?php echo $defFont;?><b>Klik Untuk Absen</b></td> <td><?php echo $defFont;?>:</td> <td><?php echo $defFont;?> <input type="submit" name="btnCek" value="Cek <?php if($act=="in") {?>In<?php }else{ ?>Out<?php } ?> Now"> </td> <tr> </table> </fieldset> </td> </tr> </table> </td> </tr> <tr valign="middle"> <td colspan="2"> </td> </tr> </table> </td> <td valign="top"> <fieldset> <legend><b><?php echo $defFont;?>Data Absen</font></b></legend> <table border="0" cellspacing="1" cellpadding="1" width="100%"> <?php if($act=="out") {?> <tr> <td colspan="2"> <?php echo $defFont;?><font color="black">Keterangan : <br> <textarea name="absen_ket" cols="80" rows="5" class="inputField"><?php echo nl2br($_POST["absen_ket"]);?></textarea> </td> </tr> <?php } ?> <tr background="<?php echo $dir_img;?>/bg_tr.png"> <?php for($start=0, $end=count($tbHeader); $start<$end; $start++) {?> <td width="<?php echo $tbHeaderWidth[$start];?>" align="center"> <?php echo $defFont;?><b><?php echo $tbHeader[$start];?></b><?php echo $tFont;?> </td> <?php } ?> </tr> <?php while($dataForm=mysql_fetch_array($QdataForm)) {?> <tr bgcolor="#FFFFFF" onmouseover="this.style.backgroundColor='#00FFFF'" onmouseout="this.style.backgroundColor='#FFFFFF'"> <td valign="top" align="<?php echo $tbContentAlign[0];?>"> <?php echo $defFont;?><?php echo format_date_long($dataForm[$tbContent[0]]);?> <?php echo $tFont;?> </td> <?php for($start=1, $end=count($tbHeader); $start<$end; $start++) {?> <td valign="top" align="<?php echo $tbContentAlign[$start];?>"> <?php echo $defFont;?><?php echo nl2br($dataForm[$tbContent[$start]]);?> <?php echo $tFont;?> </td> <?php } ?> </tr> <?php } ?> </table> </fieldset> </td> </tr> </table> <i><?php echo $hint;?></i> </form> </body> </html>