<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 tampil_ft(ID){
		var kode = ID;	
		
		$.ajax({
			type	: "POST",
			url		: "kasir/penjualan/cari_kode.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_kode").val(kode);
				$("#txt_tanggal").val(data.tanggal);
				$("#txt_kodesl").val(data.kodesl);
				$("#txt_kodepl").val(data.kodepl);
				$("#txt_namapl").val(data.namapl);
				$("#txt_jenisby").val(data.jenisby);
				$("#txt_jeniskt").val(data.jeniskt);
				$("#txt_nokartu").val(data.nokartu);
				$("#txt_charge").val(data.charge);
				$("#txt_total").val(data.total);
				$("#txt_potong").val(data.potong);
				$("#txt_bayar").val(data.bayar);
				$("#txt_kembali").val(data.kembali);
				$("#txt_posting").val('P');
				$("#cetak_fkt").focus();
				$("#tampil_data").hide();
				$("#data_detail").show();
				$("#data_detail").load('kasir/penjualan/tampil_data_ft.php?kode='+kode);				
				format_total();
				format_bayar();
				format_kembali();
				format_potong();
			}
		});
	}
	
	function format_total(){
		var angka = $("#txt_total").val();
		var jhuruf= angka.length;		
				
		$.ajax({
			type	: "POST",
			url		: "kasir/penjualan/format_rupiah.php",
			data	: "angka="+angka+
					"&jhuruf="+jhuruf,
			dataType: "json",
			success	: function(data){				
				$("#txt_ctotal").val(data.huruf);
				var ctotal=$("#txt_ctotal").val();				
			}
		});
	}
	
	function format_bayar(){
		var angka = $("#txt_bayar").val();
		var jhuruf= angka.length;
				
		$.ajax({
			type	: "POST",
			url		: "kasir_gsr/penjualan/format_rupiah.php",
			data	: "angka="+angka+
					"&jhuruf="+jhuruf,
			dataType: "json",
			success	: function(data){
				$("#txt_cbayar").val(data.huruf);
			}
		});
	}
	
	function format_kembali(){
		var angka = $("#txt_kembali").val();
		var jhuruf= angka.length;
		
		$.ajax({
			type	: "POST",
			url		: "kasir/penjualan/format_rupiah.php",
			data	: "angka="+angka+
					"&jhuruf="+jhuruf,
			dataType: "json",
			success	: function(data){				
				$("#txt_ckembali").val(data.huruf);
			}
		});
	}
	
	function format_potong(){
		var angka = $("#txt_potong").val();
		var jhuruf= angka.length;
		
		$.ajax({
			type	: "POST",
			url		: "kasir/penjualan/format_rupiah.php",
			data	: "angka="+angka+
					"&jhuruf="+jhuruf,
			dataType: "json",
			success	: function(data){				
				$("#txt_cpotong").val(data.huruf);
			}
		});
	}
</script>

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

$tanggal = $_GET['tanggal'];
$user    = $_GET['user'];

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>No.Faktur</th>
			<th>Tanggal</th>
			<th>Kasir</th>
			<th>Pelanggan</th>
			<th>Total Item</th>
			<th>Total Unit</th>
			<th>Total Harga</th>
			<th>View</th>
		</tr>";		
		$query = mysql_query("SELECT kode_pj,tanggal,nama_pl,count(kode_st) as totitem,sum(jml_unit) as totunit,sum(jumlah) as tjumlah,user FROM faktur_pj
			WHERE tanggal='$tanggal' AND user='$user' AND posting='P' AND batal='' GROUP BY kode_pj");
		$no=1;
		while($r=mysql_fetch_array($query)){
			
			echo "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r[kode_pj]</td>
				<td align='center'>".jin_date_str($r['tanggal'])."</td>
				<td>$r[nama_pl]</td>
				<td>$r[user]</td>
				<td align='center'>$r[totitem]</td>
				<td align='right'>$r[totunit]</td>
				<td align='right'>".number_format($r['tjumlah'])."</td>
				<td align='center'>
			    	<a href='javascript:void(0)' onClick=\"tampil_ft('$r[kode_pj]')\">
				    	<img src='images/view.png' border='0' id='edit' title='Lihat faktur' width='12' height='12' >
				    </a>
			    </td>
			</tr>";
			$no++;
		}
	echo "</table>";
?>