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

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

	function batal(ID){
		var pilih = confirm('Batalkan perubahan status barang kode = '+ID+ '?');
		
		if (pilih==true) {
			var kode  = ID;
			var kodetk= $("#txt_kodetk").val();
			$.ajax({
				type	: "POST",
				url		: "spv/ubahstatus/cari_kode.php",
				data	: "kode="+kode+
						"&kodetk="+kodetk,
				dataType: "json",
				success	: function(data){
					$("#txt_kode").val(kode);
					$("#txt_tanggal").val(data.tgl);					
					$("#txt_kodest").val(data.kodest);
					$("#txt_namast").val(data.namast);
					$("#txt_jmlunit").val(data.jmlunit);
					$("#txt_satuan").val(data.satuan);
					$("#txt_jumlahasl").val(data.jumlahasl);
					$("#txt_selisih").val(data.selisih);
					$("#pencarian").hide();
					$("#tampil_data").hide();
					$("#info_psb").show();
					$("#tampil_detail").show();
					$("#tampil_detail").load('spv/ubahstatus/tampil_data_batal.php?kode='+kode+'&kodetk='+kodetk);
				}
			});
		}
	}
</script>

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

$tglawal  = $_GET[tgl_awal];
$tglakhir = $_GET[tgl_akhir];
$kodetk   = $_GET[kodetk];

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode PSB</th>
			<th>Tanggal</th>
			<th>Kode Barang</th>
			<th>Nama Barang</th>
			<th>Jml.Unit</th>
			<th>Satuan</th>
			<th>Total Item</th>
			<th>Total Hasil</th>
			<th>Aksi</th>
		</tr>";

		$sql = mysql_query("SELECT kode_ps,tanggal,kode_st,nama_st,jml_unit,satuan,count(no_urut) AS totitem,sum(jml_unit1) as totunit FROM jurpsb WHERE kode_tk='$kodetk' AND tanggal BETWEEN '$tglawal' AND '$tglakhir' AND batal='' GROUP BY kode_ps");
		$no=1;
		while($r_data=mysql_fetch_array($sql)){
			
			echo "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r_data[kode_ps]</td>
				<td align='center'>".jin_date_str($r_data[tanggal])."</td>
				<td>$r_data[kode_st]</td>
				<td>$r_data[nama_st]</td>
				<td align='center'>$r_data[jml_unit]</td>
				<td>$r_data[satuan]</td>
				<td align='center'>$r_data[totitem]</td>
				<td align='center'>$r_data[totunit]</td>
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"batal('$r_data[kode_ps]')\">
						<img src='icon/thumb_down.png' border='0' id='edit' title='Batal' width='12' height='12' >
					</a>
				</td>
			</tr>";
			$no++;
		}
	echo "</table>";
	
echo "</div>";
?>