<script type="text/javascript">
$(document).ready(function() {		
    $(function() {
        $("#theList.detail tr:even").addClass("stripe1");
        $("#theList.detail tr:odd").addClass("stripe2");n

        $("#theList.detail tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});

	function pilih(ID){
		var kode = ID;
		
		$.ajax({
			type	: "POST",
			url		: "modul/gaji/cari_nik.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#t_nik2").val(data.nik);
				$("#form_cari_nik").dialog('close');
				tampil_data();
			}
		});
	}
	
	function tampil_data(){
		var bulan = $("#t_bulan").val();
		var tahun = $("#t_tahun").val();
		var nik1  = $("#t_nik1").val();
		var nik2  = $("#t_nik2").val();
				
		$("#tampil_data").show();
		$("#tampil_data").load('modul/gaji/tampil_data.php?bulan='+bulan+'&tahun='+tahun+'&nik1='+nik1+'&nik2='+nik2);
	}
</script>

<?php
include '../../inc/inc.koneksi.php';

$bulan= $_GET[bulan];
$tahun= $_GET[tahun];

echo "<table id='theList' class='detail' width='100%'>
		<tr>			
			<th>NIK</th>
			<th>Nama Karyawan</th>
			<th>Jabatan</th>
			<th>Sakit</th>
			<th>Ijin</th>
			<th>Alpa</th>
			<th>Total Gaji</th>
			<th>Total Potongan</th>
			<th>Gaji Bersih</th>
			<th>Pilih</th>
		</tr>";
		
		$sql = "SELECT * FROM gaji WHERE bulan='$bulan' AND tahun='$tahun' ORDER BY kode_gj";
				
		$query = mysql_query($sql);
		$jml_data = mysql_num_rows($query);
		$no=0;		
		$t_totgaji= 0;				
		$t_totpot = 0;		
		$t_gaber  = 0;
		
		while($r_data=mysql_fetch_array($query)){
			$totpot = $r_data[pot_absen]+$r_data[um_gaji]+$r_data[angsuran]+$r_data[pot_bpjs]+$r_data[pot_pph21]+$r_data[jumlah_pl];
			
			echo "<tr>					
					<td>$r_data[nik]</td>
					<td>$r_data[nama]</td>
					<td>$r_data[jabatan]</td>
					<td align='center'>$r_data[sakit]</td>
					<td align='center'>$r_data[ijin]</td>
					<td align='center'>$r_data[alpa]</td>					
					<td align='right'>".number_format($r_data[tot_gaji],0)."</td>
					<td align='right'>".number_format($totpot,0)."</td>
					<td align='right'>".number_format($r_data[gaber],0)."</td>
					<td align='center'><a href='javascript:void(0)' onClick=\"pilih('$r_data[kode_gj]')\">
						<img src='icon/download.gif' border='0' id='edit' title='Pilih NIK' width='12' height='12' ></a>
					</td>
				</tr>";
			$no++;
			$t_totgaji=$t_totgaji+$r_data[tot_gaji];
			$t_totpot =$t_totpot+$totpot;
			$t_gaber  =$t_gaber+$r_data[gaber];
		}
		echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>			
			<td align='right'>Total</td>			
			<td align='right'>".number_format($t_totgaji,0)."</td>
			<td align='right'>".number_format($t_totpot,0)."</td>
			<td align='right'>".number_format($t_gaber,0)."</td>
		</tr>
		</table>";
		
	echo "<table width='100%'>
		<tr>
			<td>Jumlah Data : $no</td>
		</tr>
		</table>";
?>