<html>
<head>
<script type="text/javascript">
	$(document).ready(function(){
		$("#docdate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready(function(){
		var out = {
			source: "transaksi/manual/json_dokumen.php",					
			select: function(event, ui){
				$("#prodcode").val(ui.item.prod_code); 
				$("#prodid").val(ui.item.prod_id); 
				$("#prodsat").val(ui.item.prod_sat); 
				$("#prodstock").val(ui.item.prod_stock);
				$("#prodprice").val(ui.item.prod_price);
				$("#prodcurr").val(ui.item.prod_curr);
				$("#prodnett").val(ui.item.prod_nett);
				$("#prodgross").val(ui.item.prod_gross);
				$("#prodbox").val(ui.item.prod_box);
				$("#prodpallet").val(ui.item.prod_pallet);
			},
			minLength: 1
		};
		$("#prodcode").autocomplete(out);		
	});	
	$(document).ready(function(){
		var cust = {
			source: "transaksi/manual/json_customer.php",					
			select: function(event, ui){
				$("#doch_custid").val(ui.item.cust_id); 
				$("#nm_penerima").val(ui.item.cust_name); 
				$("#doch_attn").val(ui.item.cust_attn); 
			},
			minLength: 1
		};
		$("#nm_penerima").autocomplete(cust);		
	});	
	function format_number(bilangan){
		var	number_string = bilangan.toString(),
		split	= number_string.split('.'),
		sisa 	= split[0].length % 2,
		rupiah 	= split[0].substr(0, sisa),
		ribuan 	= split[0].substr(sisa).match(/\d{1,3}/gi);
			
		if (ribuan) {
			separator = sisa ? ',' : '';
			rupiah += separator + ribuan.join(',');
		}
		rupiah = split[1] != undefined ? rupiah + '.' + split[1] : rupiah;
		return rupiah;
	} 
	function ppncheck_click(){
		var check	 = document.getElementById("doch_ppncheck"); 
		var stotal	 = $("#doch_subtotal").val();		
		if (check.checked == true){
			var ppn = eval(stotal)*0.1;
		} else {
			var ppn = 0;
		}
		var gtotal = eval(stotal) + eval(ppn);
		$("#doch_ppn").val(ppn);
		$("#doch_ppnd").val(format_number(ppn));
		$("#doch_grandtotal").val(gtotal);
		$("#doch_grandtotald").val(format_number(gtotal));
	}
	function price_click(){
		var qty		 = $("#docd_qty").val();
		var price	 = $("#prodprice").val();
		var nett	 = $("#prodnett").val();
		var gross	 = $("#prodgross").val();
		var box	 	 = $("#prodbox").val();
		var pallet	 = $("#prodpallet").val();
		var total 	 = (eval(qty)*eval(price)).toFixed(2);
		var tbox 	 = Math.ceil((eval(qty)/eval(box)).toFixed(1));
		var tnett 	 = (eval(qty)*eval(nett)).toFixed(2);
		var tgross 	 = (eval(qty)*eval(gross)).toFixed(2);
		var tpallet	 = Math.ceil((eval(tbox)/eval(pallet)).toFixed(1));
		$("#docd_total").val(total);	
		$("#docd_weight").val(tnett);
		$("#docd_gross").val(tgross);
		$("#docd_box").val(tbox);
		$("#docd_pallet").val(tpallet);	
	 }
	 function add_click(doch_id){
	 	if(form.prodid.value==""){
			alert("Silakan isi kode barang.");
			form.prodcode.focus();
			return false;
		}else if(form.docd_buyerpo.value==""){
			alert("Silakan isi buyer PO.");
			form.docd_buyerpo.focus();
			return false;
		}else if(form.docd_qty.value==""){
			alert("Silakan isi qty.");
			form.docd_qty.focus();
			return false;
		}else if(form.docd_price.value==""){
			alert("Silakan isi harga.");
			form.docd_price.focus();
			return false;
		}else if(form.docd_currency.value==0){
			alert("Silakan isi currency.");
			form.docd_currency.focus();
			return false;
		}/*else if(form.docd_weight.value==""){
			alert("Silakan isi netto.");
			form.docd_weight.focus();
			return false;
		}else if(form.docd_gross.value==""){
			alert("Silakan isi gross.");
			form.docd_gross.focus();
			return false;
		}else if(form.docd_box.value==""){
			alert("Silakan isi box.");
			form.docd_box.focus();
			return false;
		}else if(form.docd_pallet.value==""){
			alert("Silakan isi jumlah pallet.");
			form.docd_pallet.focus();
			return false;
		}*/else{
			form.action ='?page=Proses-Dokumen&Act=ADD&doch_id='+doch_id;
			form.method = 'post';
			form.submit();			
			return true;
		}	
 	 }
	 function delete_click(docd_id,doch_id){
	 		form.action ='?page=Proses-Dokumen&Act=DEL&docd_id='+docd_id+'&doch_id='+doch_id;
			form.method = 'post';
			form.submit();			
			return true;
	 }
	 function save_click(){
		if(form.doch_idtypeout.value==0){
			alert("Silakan isi jenis pengeluaran.");
			form.doch_idtypeout.focus();
			return false;
		}else if(form.nm_penerima.value==""){
			alert("Silakan isi nama penerima.");
			form.nm_penerima.focus();
			return false;
		}else if((form.doch_invno.value=="") ){
			alert("Silakan isi nomor invoice.");
			form.doch_invno.focus();
			return false;
		}else if((form.doch_dono.value=="") ){
			alert("Silakan isi nomor DO.");
			form.doch_dono.focus();
			return false;
		}else if((form.doch_doctype.value==0) ){
			alert("Silakan pilih jenis dokumen.");
			form.doch_doctype.focus();
			return false;
		}else if((form.doch_docno.value=="") ){
			alert("Silakan isi nomor dokumen.");
			form.doch_docno.focus();
			return false;
		}else if((form.doch_attn.value=="") ){
			alert("Silakan isi Up/Att.");
			form.doch_attn.focus();
			return false;
		}else if((form.doch_desc.value=="") ){
			alert("Silakan isi catatan.");
			form.doch_desc.focus();
			return false;
		}else if((form.doch_subtotal.value==0) ){
			alert("Silakan isi detail barang.");
			form.doch_subtotal.focus();
			return false;
		}else if((form.doch_idpayment.value==0) ){
			alert("Silakan isi tipe payment.");
			form.doch_idpayment.focus();
			return false;
		}else if((form.doch_idttd.value==0) ){
			alert("Silakan isi ttd.");
			form.doch_idttd.focus();
			return false;
		}else if((form.doch_idjabatan.value==0) ){
			alert("Silakan isi jabatan.");
			form.doch_idjabatan.focus();
			return false;
		}else if((form.doch_status.value==0) ){
			alert("Silakan pilih status.");
			form.doch_status.focus();
			return false;
		}else{
			var a = confirm("Apakah anda yakin akan menyimpan data?");
			if (a == true){
				form.action ='?page=Proses-Dokumen&Act=SAVE';
				form.method = 'post';
				form.submit();			
				return true;
			}
		}
	}	
	function close_click(){
		/*window.close();*/
		form.action ='?page=Proses-Dokumen&Act=CLOSE';
		form.method = 'post';
		form.submit();			
		return true;
	}
	function popup_item(){
		window.open("popup/popup_item.php?","mywindow","menubar=1,scrollbars=1,resizable=1,width=650,height=250");
	}
</script>
</head>
<body>
<form action="?page=Proses-Dokumen" method="post" name="form" target="_self" enctype="multipart/form-data">
<table width="100%" cellpadding="2" cellspacing="1" class="table-list" style="margin-top:0px;">
	<tr>
	  <th colspan="4" align="left">HEADER PLAN PENGELUARAN</th>
	</tr>
	<tr>
	  <td width="15%">Jenis Pengeluaran</td>
	  <td width="35%">: 
	  	<input type="hidden" name="doch_id" value="<?php echo $doch_id; ?>" size="50" />
		<select name="doch_idtypeout">
		  <option value="0" selected="selected">PILIH</option> 
			<?php
			  $dataSql = mysql_query("SELECT id,out_type FROM outgoing_type WHERE out_status=10 ORDER BY  id ASC");
			  while ($dataRow = mysql_fetch_array($dataSql)) {
				if ($dataRow['id']== $doch_idtypeout) {
					$cek = " selected";
				} else { $cek=""; }
				echo "<option value='$dataRow[id]' $cek>$dataRow[out_type]</option>";
			  }
			  $sqlData ="";
			?>
		 </select>
	  </td>
	  <td width="15%">Up/Pic/Attn</td>
	  <td width="35%">: <input type="text" id="doch_attn" name="doch_attn" value="<?php echo $doch_attn; ?>" size="25"></td>
	</tr>
	<tr>
		<td>No. Registrasi</td>
		<td>: <input type="text" name="doch_regno" value="<?php echo $doch_regno; ?>" size="15" readonly="true" style="background-color:#CCFFFF " /> </td>
		<td>Jenis Dokumen</td>
		<td>: <select name="doch_doctype">
				  <option value="0" selected="selected">PILIH</option> 
					<?php
					  $dataSql = mysql_query("SELECT doc_type FROM document_type WHERE doc_status=2 ORDER BY  id ASC");
					  while ($dataRow = mysql_fetch_array($dataSql)) {
						if ($dataRow['doc_type']== $doch_doctype) {
							$cek = " selected";
						} else { $cek=""; }
						echo "<option value='$dataRow[doc_type]' $cek>$dataRow[doc_type]</option>";
					  }
					  $sqlData ="";
					?>
			 </select>
		</td>
	</tr>
	<tr>
		<td>No DO</td>
		<td>: <input type="text" name="doch_dono" value="<?php echo $doch_dono; ?>" size="25" /></td>
		<td>No Dokumen</td>
		<td>: <input type="text" name="doch_docno" value="<?php echo $doch_docno; ?>" size="6" /></td>
	</tr>
	<tr>
		<td>Penerima Barang</td>
		<td>: 
			<input type="hidden" name="doch_custid" id="doch_custid" value="<?=$doch_custid;?>" size="50" />
			<input type="text" name="nm_penerima" id="nm_penerima" value="<?=$nm_penerima;?>" size="50" style="background-color:#CCFFFF" />
		</td>
		<td>Tanggal Dokumen</td>
		<td>: <input type="text" name="doch_docdate" value="<?php if(empty($doch_docdate)){$doch_docdate=$date;} echo $doch_docdate; ?>" size="12" id="docdate" 
				  readonly="true" style="background-color:#CCFFFF " /></td>
	</tr>
	<tr>
		<td>No. Invoice</td>
		<td>: <input type="text" name="doch_invno" value="<?php echo $doch_invno; ?>" size="25" /></td>
		<td>Status</td>
		<td>: <select name="doch_status">
			  <?php if($doch_status==10){ ?>
			  	<option value="0">PILIH</option>
				<option value="10" selected="selected">Barang Jadi</option>
				<option value="20">Non Barang Jadi</option>
			  <?php }elseif($doch_status==20){ ?>
			  	<option value="0">PILIH</option>
				<option value="10">Barang Jadi</option>
				<option value="20" selected="selected">Non Barang Jadi</option>
			  <?php }else{ ?>
			  	<option value="0" selected="selected">PILIH</option>
				<option value="10">Barang Jadi</option>
				<option value="20">Non Barang Jadi</option>
			  <?php } ?>
			  </select>
		</td>
	</tr>
	<tr>
		<td>Catatan</td>
		<td colspan="3">: <textarea name="doch_desc" class="textarea-field" cols="100"><?php echo $doch_desc; ?></textarea></td>
	</tr>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<th colspan="4" align="left">DETAIL DATA BARANG</th>
	</tr>
	<tr>
		<td colspan="4">
			<table width="100%">
				<tr>
					<td align="center">Kode Barang</td>								
					<td align="center">Satuan</td>
					<td align="center">BuyerPO</td>
					<td align="center">Qty</td>
					<td align="center">Harga</td>	
					<td align="center">Curr</td>				
					<td align="center">Total</td>					
					<td align="center">Nett</td>
					<td align="center">Gross</td>
					<td align="center">Box</td>
					<td align="center">Pallet</td>
					<td align="center">Action</td>
				</tr>
				<tr>
					<td>
						<input type="hidden" name="prodid" id="prodid" style="width:300px;">
						<input type="hidden" name="prodnett" id="prodnett" style="width:300px;">
						<input type="hidden" name="prodgross" id="prodgross" style="width:300px;">
						<input type="hidden" name="prodbox" id="prodbox" style="width:300px;">
						<input type="hidden" name="prodpallet" id="prodpallet" style="width:300px;">
						<input type="text" name="prodcode" id="prodcode" style="width:140px; background-color:#CCFFFF" >
						<img src="images/popup.png" height="15" width="15" title="Popup Item Master" style="cursor:pointer" border="0" onClick="popup_item();" />
					</td>
					<td>
						<input type="text" name="prodsat" id="prodsat" style="width:50px; text-align:left; background-color:#CCFFFF" readonly="true">
						<input type="hidden" name="prodstock" id="prodstock" style="width:50px; text-align:right; background-color:#CCFFFF" readonly="true">
					</td>
					<td><input type="text" name="docd_buyerpo" id="docd_buyerpo" size="15"></td>
					<td><input type="text" name="docd_qty" id="docd_qty" size="5" style="text-align:right" onBlur="price_click()"></td>
					<td><input type="text" name="docd_price" id="prodprice" size="10" style="text-align:right"  onBlur="price_click()"></td>
					<td>
						<!--<input type="text" name="docd_currency" id="prodcurr" size="5" style="text-align:center">-->
						<select name="docd_currency" id="prodcurr">
							<option value="0" selected>PILIH</option>
							<?php
							  $dataSql = mysql_query("SELECT currency FROM currency ORDER BY id ASC");
							  while ($dataRow = mysql_fetch_array($dataSql)) {
								echo "<option value='$dataRow[currency]' $cek>$dataRow[currency]</option>";
							  }
							  $sqlData =""; 
							?>
						 </select>
					</td>
					<td><input type="text" name="docd_total" id="docd_total" size="10" style="text-align:right"></td>
					<td><input type="text" name="docd_weight" id="docd_weight" size="6" value="0" style="text-align:right"></td>
					<td><input type="text" name="docd_gross" id="docd_gross" size="6" value="0" style="text-align:right"></td>
					<td><input type="text" name="docd_box" id="docd_box" size="6" value="0" style="text-align:right"></td>
					<td>
						<input type="text" name="docd_upallet" id="docd_upallet" size="10" value="120X100X14" style="text-align:center">
						<input type="text" name="docd_pallet" id="docd_pallet" size="3" value="0" style="text-align:right">
					</td>
					<td><input type="button" name="Add" value="Add" onClick="add_click('<?=$doch_id;?>');"></td>
				</tr>
			</table>
		</td>
	</tr>	
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<?php if(!empty($doch_id)){ ?>		
	<tr>
		<td colspan="4">
			<table width="100%">
				<tr>
					<td align="center">No.</td>
					<td align="center">Nama Barang</td>
					<td align="center">Kode</td>
					<td align="center">Satuan</td>
					<td align="center">Buyer PO</td>
					<td align="center">Harga</td>
					<td align="center">Qty</td>
					<td align="center">Total</td>
					<td align="center">Curr</td>
					<td align="center">Nett</td>
					<td align="center">Gross</td>
					<td align="center">Box</td>
					<td align="center">Pallet</td>
					<td align="center">Act</td>
				</tr>
				<?php
				    $no=0; $tqty=0; $ptotal=0; $tnet=0; $tgros=0;
					$qd = mysql_query("SELECT a.*,b.prod_code, b.prod_name, b.prod_sat
									   FROM document_detail a
									   INNER JOIN product b ON b.id=a.docd_prodid
						   			   WHERE a.docd_hid='$doch_id'");
					while($dt=mysql_fetch_object($qd)){	   
				    $no++;					
					$tnet    = $tnet + $dt->docd_weight;
					$tgros   = $tgros + $dt->docd_gross;
					$tqty    = $tqty + $dt->docd_qty;
					$pprice  = $dt->docd_qty * $dt->docd_price;
					$ptotal  = $ptotal + $pprice;					
				?> 
				  <tr>
					<td align="center"><?=$no;?>.</td>
					<td><?=$dt->prod_name;?></td>
					<td align="left"><?=$dt->prod_code;?></td>
					<td align="center"><?=$dt->prod_sat;?></td>
					<td align="center"><?=$dt->docd_buyerpo;?></td>
					<td align="right"><?=number_format($dt->docd_price,2,'.',',');?></td>
					<td align="right"><?=number_format($dt->docd_qty,2,'.',',');?></td>
					<td align="right"><?=number_format($pprice,2,'.',',');?></td>
					<td align="center"><?=$dt->docd_currency;?></td>
					<td align="right"><?=number_format($dt->docd_weight,2,'.',',');?></td>
					<td align="right"><?=number_format($dt->docd_gross,2,'.',',');?></td>
					<td align="right"><?=$dt->docd_box;?></td>
					<td align="center">(<?=$dt->docd_upallet;?>)X<?=$dt->docd_pallet;?></td>
					<td align="center">
						<img src="images/btn_delete.png" height="20" width="20" title="Hapus" border="0" style="cursor:pointer" 
						onclick="delete_click('<?=$dt->id;?>','<?=$doch_id;?>');" />
					</td>
				</tr>
				<?php } 
					$ppn    = $ptotal * 0.1; 
					$gtotal = $ptotal + $ppn; 
				?>
				<tr>
					<td colspan="7" align="right">Sub Total</td>
					<td align="right"><?=number_format($ptotal,2,'.',',');?>
						<input type="hidden" name="doch_subtotal" id="doch_subtotal" value="<?=$ptotal;?>" size="15" style="text-align:right">
					</td>
					<td>&nbsp;</td>
					<td align="right"><?=number_format($tnet,2,'.',',');?></td>
					<td align="right"><?=number_format($tgros,2,'.',',');?></td>
					<td colspan="3" align="right">Total qty : <?=number_format($tqty,2,'.',',');?></td>
				</tr>
				<tr>
					<td colspan="2" align="right">Payment : </td>
					<td colspan="4" align="left">
						<select name="doch_idpayment" id="doch_idpayment">
							<option value="0" selected="selected">PILIH</option> 
							<?php
							  $dataSql = mysql_query("SELECT id, pay_type FROM payment_type WHERE pay_status=10 ORDER BY  id ASC");
							  while ($dataRow = mysql_fetch_array($dataSql)) {
								if ($dataRow['id']== $doch_idpayment) {
									$cek = " selected";
								} else { $cek=""; }
								echo "<option value='$dataRow[id]' $cek>$dataRow[pay_type]</option>";
							  }
							  $sqlData ="";
							?>
						 </select>
					</td>
					<td align="right">Discount</td>
					<td align="right">
						<input type="text" name="doch_discount" id="doch_discount" value="<?=$doch_discount;?>" size="15" style="text-align:right">
					</td>
					<td colspan="6">&nbsp;</td>
				</tr>
				<tr>
					<td colspan="7" align="right">PPN <input type="checkbox" name="doch_ppncheck" id="doch_ppncheck" checked="checked" onClick="ppncheck_click();"></td>
					<td align="right">
						<input type="hidden" name="doch_ppn" id="doch_ppn" value="<?=$ppn;?>" readonly="true" size="15" style="text-align:right">
						<input type="text" name="doch_ppnd" id="doch_ppnd" value="<?=number_format($ppn,2,'.',',');?>" readonly="true" size="15" style="text-align:right">
					</td>
					<td colspan="6" align="right">
						Ttd : 
						<select name="doch_idttd" id="doch_idttd">
							<option value="0" selected="selected">PILIH</option> 
							<?php
							  $dataSql = mysql_query("SELECT id, ttd_name FROM tandatangan WHERE ttd_status=10 ORDER BY  id ASC");
							  while ($dataRow = mysql_fetch_array($dataSql)) {
								if ($dataRow['id']== $doch_idttd) {
									$cek = " selected";
								} else { $cek=""; }
								echo "<option value='$dataRow[id]' $cek>$dataRow[ttd_name]</option>";
							  }
							  $sqlData ="";
							?>
						 </select>
					</td>
				</tr>
				<tr>
					<td colspan="7" align="right">Grand Total</td>
					<td align="right">
						<input type="hidden" name="doch_grandtotal" id="doch_grandtotal" value="<?=$gtotal;?>" readonly="true" size="15" style="text-align:right">
						<input type="text" name="doch_grandtotald" id="doch_grandtotald" value="<?=number_format($gtotal,2,'.',',');?>" readonly="true" size="15" style="text-align:right">
					</td>
					<td colspan="6" align="right">
						Jabatan :
						<select name="doch_idjabatan" id="doch_idjabatan">
							<option value="0" selected="selected">PILIH</option> 
							<?php
							  $dataSql = mysql_query("SELECT id, jab_name FROM jabatan WHERE jab_status=10 ORDER BY  id ASC");
							  while ($dataRow = mysql_fetch_array($dataSql)) {
								if ($dataRow['id']== $doch_idjabatan) {
									$cek = " selected";
								} else { $cek=""; }
								echo "<option value='$dataRow[id]' $cek>$dataRow[jab_name]</option>";
							  }
							  $sqlData ="";
							?>
						 </select>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php }else{ ?>
	<tr>
		<td colspan="4">
			<table width="100%">
				<tr>
					<td align="center">No.</td>
					<td align="center">Nama Barang</td>
					<td align="center">Kode</td>
					<td align="center">Satuan</td>
					<td align="center">Buyer PO</td>
					<td align="center">Harga</td>
					<td align="center">Qty</td>
					<td align="center">Total</td>
					<td align="center">Curr</td>
					<td align="center">Nett</td>
					<td align="center">Gross</td>
					<td align="center">Box</td>
					<td align="center">Pallet</td>
					<td align="center">Act</td>
				</tr>
				<?php
				    $no=0; $tqty=0; $ptotal=0; $tnet=0; $tgros=0;
					$qd = mysql_query("SELECT a.*,b.prod_code, b.prod_name, b.prod_sat
									   FROM document_temp a
									   INNER JOIN product b ON b.id=a.docd_prodid
						   			   WHERE a.docd_userid='$user_id'");
					while($dt=mysql_fetch_object($qd)){	   
				    $no++;					
					$tnet    = $tnet + $dt->docd_weight;
					$tgros   = $tgros + $dt->docd_gross;
					$tqty    = $tqty + $dt->docd_qty;
					$pprice  = $dt->docd_qty * $dt->docd_price;
					$ptotal  = $ptotal + $pprice;					
				?> 
				  <tr>
					<td align="center"><?=$no;?>.</td>
					<td><?=$dt->prod_name;?></td>
					<td align="left"><?=$dt->prod_code;?></td>
					<td align="center"><?=$dt->prod_sat;?></td>
					<td align="center"><?=$dt->docd_buyerpo;?></td>
					<td align="right"><?=number_format($dt->docd_price,2,'.',',');?></td>
					<td align="right"><?=number_format($dt->docd_qty,2,'.',',');?></td>
					<td align="right"><?=number_format($pprice,2,'.',',');?></td>
					<td align="center"><?=$dt->docd_currency;?></td>
					<td align="right"><?=number_format($dt->docd_weight,2,'.',',');?></td>
					<td align="right"><?=number_format($dt->docd_gross,2,'.',',');?></td>
					<td align="right"><?=$dt->docd_box;?></td>
					<td align="center">(<?=$dt->docd_upallet;?>)X<?=$dt->docd_pallet;?></td>
					<td align="center">
						<img src="images/btn_delete.png" height="20" width="20" title="Hapus" border="0" style="cursor:pointer" 
						onclick="delete_click('<?=$dt->id;?>','<?=$doch_id;?>');" />
					</td>
				</tr>
				<?php } 
					$ppn    = $ptotal * 0.1; 
					$gtotal = $ptotal + $ppn; 
				?>
				<tr>
					<td colspan="7" align="right">Sub Total</td>
					<td align="right"><?=number_format($ptotal,2,'.',',');?>
						<input type="hidden" name="doch_subtotal" id="doch_subtotal" value="<?=$ptotal;?>" size="15" style="text-align:right">
					</td>
					<td>&nbsp;</td>
					<td align="right"><?=number_format($tnet,2,'.',',');?></td>
					<td align="right"><?=number_format($tgros,2,'.',',');?></td>
					<td colspan="3" align="right">Total qty : <?=number_format($tqty,2,'.',',');?></td>
				</tr>
				<tr>
					<td colspan="2" align="right">Payment : </td>
					<td colspan="4" align="left">
						<select name="doch_idpayment" id="doch_idpayment">
							<option value="0" selected="selected">PILIH</option> 
							<?php
							  $dataSql = mysql_query("SELECT id, pay_type FROM payment_type WHERE pay_status=10 ORDER BY  id ASC");
							  while ($dataRow = mysql_fetch_array($dataSql)) {
								if ($dataRow['id']== $doch_idpayment) {
									$cek = " selected";
								} else { $cek=""; }
								echo "<option value='$dataRow[id]' $cek>$dataRow[pay_type]</option>";
							  }
							  $sqlData ="";
							?>
						 </select>
					</td>
					<td align="right">Discount</td>
					<td align="right">
						<input type="text" name="doch_discount" id="doch_discount" value="<?=$doch_discount;?>" size="15" style="text-align:right">
					</td>
					<td colspan="6">&nbsp;</td>
				</tr>
				<tr>
					<td colspan="7" align="right">PPN <input type="checkbox" name="doch_ppncheck" id="doch_ppncheck" checked="checked" onClick="ppncheck_click();"></td>
					<td align="right">
						<input type="hidden" name="doch_ppn" id="doch_ppn" value="<?=$ppn;?>" readonly="true" size="15" style="text-align:right">
						<input type="text" name="doch_ppnd" id="doch_ppnd" value="<?=number_format($ppn,2,'.',',');?>" readonly="true" size="15" style="text-align:right">
					</td>
					<td colspan="6" align="right">
						Ttd : 
						<select name="doch_idttd" id="doch_idttd">
							<option value="0" selected="selected">PILIH</option> 
							<?php
							  $dataSql = mysql_query("SELECT id, ttd_name FROM tandatangan WHERE ttd_status=10 ORDER BY  id ASC");
							  while ($dataRow = mysql_fetch_array($dataSql)) {
								if ($dataRow['id']== $doch_idttd) {
									$cek = " selected";
								} else { $cek=""; }
								echo "<option value='$dataRow[id]' $cek>$dataRow[ttd_name]</option>";
							  }
							  $sqlData ="";
							?>
						 </select>
					</td>
				</tr>
				<tr>
					<td colspan="7" align="right">Grand Total</td>
					<td align="right">
						<input type="hidden" name="doch_grandtotal" id="doch_grandtotal" value="<?=$gtotal;?>" readonly="true" size="15" style="text-align:right">
						<input type="text" name="doch_grandtotald" id="doch_grandtotald" value="<?=number_format($gtotal,2,'.',',');?>" readonly="true" size="15" style="text-align:right">
					</td>
					<td colspan="6" align="right">
						Jabatan :
						<select name="doch_idjabatan" id="doch_idjabatan">
							<option value="0" selected="selected">PILIH</option> 
							<?php
							  $dataSql = mysql_query("SELECT id, jab_name FROM jabatan WHERE jab_status=10 ORDER BY  id ASC");
							  while ($dataRow = mysql_fetch_array($dataSql)) {
								if ($dataRow['id']== $doch_idjabatan) {
									$cek = " selected";
								} else { $cek=""; }
								echo "<option value='$dataRow[id]' $cek>$dataRow[jab_name]</option>";
							  }
							  $sqlData ="";
							?>
						 </select>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php } ?>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="4" align="center">
			<input type="button" name="btnSave" value="SIMPAN" style="cursor:pointer;" onClick="save_click();">
			<input type="button" value="BATAL" name="batal" style="cursor:pointer"  onClick="close_click();" />
		</td>
    </tr>
</table>
</form>
</body>
</html> 