<html>
<head>
<script type="text/javascript"  language="javascript">
	$(document).ready(function(){
		$("#sjdate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready(function(){
		$("#invdate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready(function(){
		$("#docdate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready(function(){
		$("#ajudate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready(function(){
		$("#npedate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	function openwindow()
	{
		window.open("popup/popup_custout.php?","mywindow","menubar=1,scrollbars=1,resizable=1,width=600,height=250");
	}
	function openwindow1()
	{
		window.open("popup/popup_barang.php?","mywindow","menubar=1,scrollbars=1,resizable=1,width=600,height=250");
	}
	function pilih(id)
	{
		var y  = document.getElementById("outh_purpid");		
		$.ajax({type: "POST",
			url: "transaksi/manual/load_purpose.php", 
			data: "docid="+id,
			success: function(result){			
			y.innerHTML="<option value='0'>PILIH</option>";
			arr_data = result.split("XX");
			if(id==7){ /*BC 2.5 */
				var option = document.createElement("option");
					option.text = arr_data[1];
					option.value = arr_data[0];
					y.add(option);					
			}else if(id==8){ /*BC 2.6.1 */
				var option = document.createElement("option");
					option.text = arr_data[1];
					option.value = arr_data[0];
					y.add(option);
				var option = document.createElement("option");
					option.text = arr_data[3];
					option.value = arr_data[2];
					y.add(option);						
			}else if(id==9){ /*BC 2.7 */
				var option = document.createElement("option");
					option.text = arr_data[1];
					option.value = arr_data[0];
					y.add(option);					
			}else if(id==10){ /*BC 3.0 */
				var option = document.createElement("option");
					option.text = arr_data[1];
					option.value = arr_data[0];
					y.add(option);
				var option = document.createElement("option");
					option.text = arr_data[3];
					option.value = arr_data[2];
					y.add(option);
				var option = document.createElement("option");
					option.text = arr_data[5];
					option.value = arr_data[4];
					y.add(option);					
			}else if(id==12){ /*BC 4.1 */
				var option = document.createElement("option");
					option.text = arr_data[1];
					option.value = arr_data[0];
					y.add(option);
				var option = document.createElement("option");
					option.text = arr_data[3];
					option.value = arr_data[2];
					y.add(option);						
			}else if(id==13){ /*OTHERS */
				var option = document.createElement("option");
					option.text = arr_data[1];
					option.value = arr_data[0];
					y.add(option);
				var option = document.createElement("option");
					option.text = arr_data[3];
					option.value = arr_data[2];
					y.add(option);						
			}
			
		}});
	}
	$(document).ready(function(){
		var out = {
			source: "transaksi/manual/json_prodout.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);
			},
			minLength: 1
		};
		$("#prodcode").autocomplete(out);		
	});	
	function currency_click(currency){
		if(currency=="IDR"){
			var nilai=1;
		}else{
			var nilai=0;		
		}
		$("#n_rate").val(nilai);
	 }
	 function save_click(){
		if(form.outh_sjno.value==""){
			alert("Silakan isi no surat jalan.");
			form.outh_sjno.focus();
			return false;
		}else if(form.cust_name.value==""){
			alert("Silakan isi nama penerima.");
			form.cust_name.focus();
			return false;
		}else if((form.outh_invno.value=="") ){
			alert("Silakan isi nomor invoice.");
			form.outh_invno.focus();
			return false;
		}else if((form.outh_docid.value=="BLANK") ){
			alert("Silakan pilih jenis dokumen.");
			form.outh_docid.focus();
			return false;
		}else if((form.tujuan.value=="BLANK") ){
			alert("Silakan pilih tujuan dokumen.");
			form.tujuan.focus();
			return false;
		}else if((form.outh_docno.value=="") ){
			alert("Silakan isi nomor dokumen.");
			form.outh_docno.focus();
			return false;
		}else if((form.no_aju.value=="") ){
			alert("Silakan isi nomor aju.");
			form.no_aju.focus();
			return false;
		}else if((form.po_no.value=="10") && (form.tqty.value==0) ){
			alert("Silakan isi detail barang.");
			form.tqty.focus();
			return false;
		}else if((form.outh_currency.value=="BLANK") ){
			alert("Silakan pilih valuta.");
			form.outh_currency.focus();
			return false;
		}else if((form.n_rate.value==0) ){
			alert("Kurs tidak boleh nol.");
			form.n_rate.focus();
			return false;
		}else{
			var a = confirm("Apakah anda yakin akan menyimpan data?");
			if (a == true){
				form.action ='?page=Proses-Pengeluaran-BC27&Act=SAVEM';
				form.method = 'post';
				form.submit();			
				return true;
			}
		}
	}
	function add_det_click(){
	    var qtystock = $("#prodstock").val();
		var qtytrf	 = $("#outdqty").val();
		var qtys     = eval(qtystock);
		var qtyt     = eval(qtytrf);
		if(form.prodid.value==""){
			alert("Silakan isi nama barang.");
			form.prodname.focus();
			return false;
		}else if((form.outdqty.value=="") ){
			alert("Silakan isi jumlah barang.");
			form.outdqty.focus();
			return false; 
		}else if((form.outdprice.value=="") ){
			alert("Silakan isi harga barang.");
			form.outdprice.focus();
			return false;
		}else if((form.outdamount.value=="") ){
			alert("Silakan nilai barang.");
			form.outdamount.focus();
			return false;
		}else if((form.outdweight.value=="") ){
			alert("Silakan isi berat barang.");
			form.outdweight.focus();
			return false;
		}else if(qtys < qtyt ){
			alert("Jumlah stock lebih kecil dari jumlah yang dikeluarkan.");
			form.trfdqty.focus();
			return false; 
		}else{
			form.action ='?page=Proses-Pengeluaran-BC27&Act_Det=ADD_DETM';
			form.method = 'post';
			form.submit();			
			return true;
		}
	}
	function delete_detail_click(id){
		form.action ='?page=Proses-Pengeluaran-BC27&Act_Det=DELETE_DETM&id_deth='+id;
		form.method = 'post';
		form.submit();			
		return true;
	}
	function close_click(){
		form.action ='?page=Proses-Pengeluaran-BC27&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");
	}
	function pono_click(po_no){
		form.action ='?page=Proses-Pengeluaran-BC27&Act=SEL_PO&po_no='+po_no
		form.method = 'post';
		form.submit();		
		return true;
	}
	function cal_click(){
		var c  = $("#outh_currency").val();
		var q  = $("#outdqty").val();
		var r  = $("#n_rate").val();
		var th  = $("#totalharga").val();
		var p  = eval(th)/eval(q);	
		if(c=="IDR"){
			var nidr  = eval(th);
			var nusd  = 0; 
		}else{
			var nidr  = eval(th)*eval(r); 
			var nusd  = eval(th);
		}
		$("#outdprice").val(p)
		$("#n_usd").val(nusd);
		$("#outdamount").val(nidr);
	}
</script>
</head>
<form action="#" 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">HEADER PENGELUARAN-BC 2.7</th>
	</tr>
	<tr>
	  <td width="15%">Ref# No. PO</td>
	  <td width="35%">: 
	  	<input type="hidden" name="inch_id" value="<?php echo $inch_id; ?>" size="50" />
		<?php if(empty($outh_id)){ ?>
		<select name="po_no" onChange="pono_click(this.value);">
		  <option value="10" selected="selected">PILIH</option> 
			<?php
			  $dataSql = mysql_query("SELECT po_no FROM purchase_order WHERE po_status=20 AND po_type='Sales' ORDER BY  po_no ASC");
			  while ($dataRow = mysql_fetch_array($dataSql)) {
				if ($dataRow['po_no']== $po_no) {
					$cek = " selected";
				} else { $cek=""; }
				echo "<option value='$dataRow[po_no]' $cek>$dataRow[po_no]</option>";
			  }
			  $sqlData ="";
			?>
		 </select>
		 <?php }else{ ?>
		 <input type="hidden" name="po_no" value="<?php echo $po_no; ?>" size="50" />
		 <select name="po_no" onChange="pono_click(this.value);" disabled="disabled">
		  <option value="10" selected="selected">PILIH</option> 
			<?php
			  $dataSql = mysql_query("SELECT po_no FROM purchase_order WHERE po_status=20 ORDER BY  po_no ASC");
			  while ($dataRow = mysql_fetch_array($dataSql)) {
				if ($dataRow['po_no']== $po_no) {
					$cek = " selected";
				} else { $cek=""; }
				echo "<option value='$dataRow[po_no]' $cek>$dataRow[po_no]</option>";
			  }
			  $sqlData ="";
			?>
		 </select>
		 <?php } ?>
	  </td>
	  <td width="15%">Valuta & Kurs</td>
	  <td width="35%">: <select name="outh_currency" id="outh_currency" onChange="currency_click(this.value);">
			  <option value="BLANK">PILIH</option> 
				<?php
				  $dataSql = mysql_query("SELECT currency FROM currency ORDER BY id ASC");
				  while ($dataRow = mysql_fetch_array($dataSql)) {
					if ($dataRow['currency']== $outd_currency) {
						$cek = " selected";
					} else { $cek=""; }
					echo "<option value='$dataRow[currency]' $cek>$dataRow[currency]</option>";
				  }
				  $sqlData =""; 
				?>
			 </select>&nbsp;
			 <input type="text" id="n_rate" name="n_rate" value="<?=$outd_price_rate;?>" size="10" style="text-align:right">
	  </td>
	</tr>
	<tr>
	  <td>No Surat Jalan</td>
	  <td>: <input type="hidden" name="outh_id" value="<?php echo $outh_id; ?>" size="50" />
	                    <!--<input type="text" name="outh_sjno" value="<?php echo $outh_sjno; ?>" size="20" readonly style="background-color:#CCFFFF " />-->
                        <input type="text" name="outh_sjno" value="<?php echo $outh_sjno; ?>" size="20"/>   
      </td>
	  <td>&nbsp;</td>
	  <td>&nbsp; <input type="hidden" name="outh_dono" value="<?php echo $outh_dono; ?>" size="20"></td>
	</tr>
	<tr>
		<td>Tanggal Surat Jalan</td>
		<td>: <input type="text" name="outh_sjdate" value="<?php if(empty($outh_sjdate)){$outh_sjdate=$date;} echo $outh_sjdate; ?>" size="12" id="sjdate" 
				  readonly="true" style="background-color:#CCFFFF " /> </td>
		<td>Jenis Dokumen</td>
		<td>: <select name="outh_docid" onChange="pilih(this.value);">
					<?php
					  $dataSql = mysql_query("SELECT id,doc_type FROM document_type WHERE doc_status=2 AND id=9 ORDER BY  id ASC");
					  while ($dataRow = mysql_fetch_array($dataSql)) {
						if ($dataRow['id']== $outh_docid) {
							$cek = " selected";
						} else { $cek=""; }
						echo "<option value='$dataRow[id]' $cek>$dataRow[doc_type]</option>";
					  }
					  $sqlData ="";
					?>
				 </select>
		</td>
	</tr>
	<tr>
		<td>Penerima</td>
		<td>: <input type="hidden" name="cust_id" value="<?php echo $cust_id; ?>" size="10" />
			  <input type="hidden" name="cust_npwp" value="<?php echo $cust_npwp; ?>" size="10" />
				 <input type="text" name="cust_name" value="<?php echo $cust_name; ?>" size="50" readonly style="background-color:#CCFFFF " />		
				 <a href="javascript: openwindow('');"><img src="images/popup.png" height="15" width="15" title="Tambah" border="0" />
			 </td>
		<td>Tujuan</td>
		<td>: 
			<select name="tujuan" id="tujuan">
			  <option value="BLANK">PILIH</option> 
				<?php
				  $dataSql = mysql_query("SELECT id, purp_desc FROM purpose WHERE purp_docid=9 ORDER BY id ASC");
				  while ($dataRow = mysql_fetch_array($dataSql)) {
					if ($dataRow['purp_desc']== $tujuan) {
						$cek = " selected";
					} else { $cek=""; }
					echo "<option value='$dataRow[purp_desc]' $cek>$dataRow[purp_desc]</option>";
				  }
				  $sqlData =""; 
				?>
			 </select> 
		</td>
	</tr>
	<tr>
		<td>No Invoice</td>
		<td>: <input type="text" name="outh_invno" value="<?=$outh_invno;?>"></td>
		<td>No Dokumen</td>
		<td>: <input type="text" name="outh_docno" size="6" maxlength="6" value="<?=$outh_docno;?>"></td>
	</tr>
	<tr>
		<td>Tanggal Invoice</td>
		<td>: <input type="text" name="outh_invdate" value="<?php if(empty($outh_invdate)){$outh_invdate=$date;} echo $outh_invdate; ?>" size="12" id="invdate" 
				  readonly="true" style="background-color:#CCFFFF " />
		</td>
		<td>Tanggal Dokumen</td>
		<td>: <input type="text" name="outh_docdate" value="<?php if(empty($outh_docdate)){$outh_docdate=$date;} echo $outh_docdate; ?>" size="12" id="docdate" 
				  readonly="true" style="background-color:#CCFFFF " /></td>
	</tr>
	<tr>
		<td>No Aju</td>
		<td>: <input type="text" name="no_aju" size="30" maxlength="30" value="<?=$no_aju;?>"></td>
		<td>Tanggal Aju</td>
		<td>: <input type="text" name="tgl_aju" value="<?php if(empty($tgl_aju)){$tgl_aju=$date;} echo $tgl_aju; ?>" size="12" id="ajudate" 
				  readonly="true" style="background-color:#CCFFFF " /></td>
	</tr>
	<tr>
		<td>Keterangan</td>
		<td colspan="3">: <textarea name="outh_keterangan" cols="100"><?php echo $outh_keterangan; ?></textarea></td>		
	</tr>
	<!--<tr>
		<td>No NPE</td>
		<td>: <input type="text" name="no_npe" size="6" maxlength="6" value="<?=$no_npe;?>"></td>
		<td>Tanggal NPE</td>
		<td>: <input type="text" name="tgl_npe" value="<?php if(empty($tgl_npe)){$tgl_npe=$date;} echo $tgl_npe; ?>" size="12" id="npedate" 
				  readonly="true" style="background-color:#CCFFFF " /></td>
	</tr>-->
	<!--<tr>
		<td>Tipe Dokumen</td>
		<td>: <select name="tipe_dokumen">
				<option value="BLANK">PILIH</option>
					<?php
					  $dataSql = mysql_query("SELECT id,doc_type FROM document_type WHERE doc_status=3 ORDER BY  id ASC");
					  while ($dataRow = mysql_fetch_array($dataSql)) {
						if ($dataRow['doc_type']== $tipe_dokumen) {
							$cek = " selected";
						} else { $cek=""; }
						echo "<option value='$dataRow[doc_type]' $cek>$dataRow[doc_type]</option>";
					  }
					  $sqlData ="";
					?>
				 </select></td>
		<td>Harga Maklon</td>
		<td>: <input type="text" name="harga_dokumen" size="20" maxlength="20" value="<?=$harga_dokumen;?>" style="text-align:right"></td>
	</tr>-->
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<th colspan="4">DETAIL PENGELUARAN-BC 2.7</th>
	</tr>
	<?php if(($po_no=='10') || empty($po_no)){  ?>
	<tr>
		<td colspan="4">
			<table width="100%">
				<tr>
					<td>Kode/Nama Barang</td>
					<td>Satuan</td>
					<td>Stok</td>
					<td>Jumlah</td>
					<td>Nilai</td>
					<td>Harga</td>
					<!--<td>Rate</td>-->
					<td>Nilai(Non IDR)</td>
					<td>Nilai(IDR)</td>
					<td>Berat</td>
					<td>No.Urut</td>
					<td>No.SC</td>
					<td>Action</td>
				</tr>
				<tr>
					<td><input type="hidden" name="prodid" id="prodid" style="width:300px;">
						<input type="text" name="prodcode" id="prodcode" style="width:235px; 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></td>
					<td><input type="text" name="prodstock" id="prodstock" style="width:50px; text-align:right; background-color:#CCFFFF" readonly></td>
					<td><input type="text" id="outdqty" name="outdqty" style="width:50px; text-align:right"></td>
					<td><input type="text" id="totalharga" name="totalharga" style="width:100px; text-align:right" onBlur="cal_click();"></td>
					<td><input type="text" id="outdprice" name="outdprice" style="width:100px; text-align:right"></td>
					<!--<td><input type="text" id="n_rate" name="n_rate" value="<?=$outd_price_rate;?>" style="width:70px; text-align:right"></td>-->
					<td><input type="text" id="n_usd" name="n_usd" style="width:100px; text-align:right"></td>
					<td><input type="text" id="outdamount" name="outdamount" style="width:100px; text-align:right;"></td>
					<td><input type="text" name="outdweight" style="width:100px; text-align:right ">&nbsp;Kg</td>
					<td align="center"><input type="text" name="outdnourut" style="width:30px; text-align:center "></td>
					<td><input type="text" name="outdscno" style="width:100px; text-align:left "></td>
					<td><input type="button" name="Add_Detail" value="Tambah" style="cursor:pointer" onClick="add_det_click();"></td>
				</tr>
			</table>
		</td>
	</tr>
	<?php } ?>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="4">
		  <?php if(empty($outh_id) && !empty($po_no) && $po_no != "10"){ ?>			
			<table width="100%">
				<tr>
					<td align="center">No.</td>
					<td align="center">Nama Barang</td>
					<td align="center">Unit</td>
					<td align="center">Qty PO</td>
					<!--<td align="center">Qty Delv</td>-->
					<td align="center">Qty Rmn</td>
					<td align="center">Qty Stock</td>
					<td align="center">Qty Input</td>
					<td align="center">Harga/Unit</td>
					<!--<td align="center">Total</td>-->
					<td align="center">Berat</td>
					<td align="center">NoUrut</td>
					<td align="center">NoSC</td>
				</tr>
				<?php
					$no=0; 
					$qd = mysql_query("SELECT a.*, b.prod_code,b.prod_name,b.prod_sat, b.prod_cat
									   FROM purchase_order_detail a
									   INNER JOIN product b ON b.id=a.pod_prodid
						   			   WHERE a.po_no='$po_no'");
					while($dt=mysql_fetch_object($qd)){	   
						$no++;
						#cek terima
						$cek = mysql_fetch_array(mysql_query("SELECT SUM(a.outd_qty) qty_rcv FROM outgoing_detail a INNER JOIN outgoing b ON b.id=a.outd_hid
						WHERE b.outh_status IN(15,20) AND a.outd_prodid='$dt->pod_prodid' AND b.po_no='$po_no'"));
						#stock
						$qstk = get_stock($start_date,$end_date,$bulan2,$tahun2,$dt->pod_prodid,$dt->prod_cat,$inv);
						#sisa qty
						$qty_rmn=$dt->pod_qty-$cek['qty_rcv'];
						if($qty_rmn >0){
					
				?> 
				  <tr>
					<td align="center"><?=$no;?></td>
					<td><?php echo "$dt->prod_code - $dt->prod_name";?></td>
					<td align="center"><?=$dt->prod_sat;?></td>
					<td align="center">
						<input type="hidden" name="prod_name2[<?=$dt->id;?>]" value="<?=$dt->prod_name;?>" size="15" style="text-align:right">
						<input type="hidden" name="pilih[<?=$dt->id;?>]" value="<?=$dt->id;?>" size="15" style="text-align:right">
						<input type="hidden" name="outd_prodid2[<?=$dt->id;?>]" value="<?=$dt->pod_prodid;?>" size="15" style="text-align:right">
						<input type="text" name="pod_qty[<?=$dt->id;?>]" value="<?=$dt->pod_qty;?>" size="8" style="text-align:center" readonly>
					</td>
					<!--<td align="center">
						<input type="text" name="outd_rcv[<?=$dt->id;?>]" value="<?=$cek['qty_rcv'];?>" size="8" style="text-align:center" readonly>
					</td>-->
					<td align="center">
						<input type="text" name="outd_rmn[<?=$dt->id;?>]" value="<?=$qty_rmn;?>" size="8" style="background-color:#CCFFFF;text-align:center" readonly>
					</td>
					<td align="center">
						<input type="text" name="outd_qstk[<?=$dt->id;?>]" value="<?=$qstk;?>" size="8" readonly="true" style="background-color:#CCFFFF;text-align:center;">
					</td>
					<td align="center">
						<input type="text" name="outd_qty2[<?=$dt->id;?>]" value="0" size="8" style="text-align:center">
					</td>
					<td align="center">
						<input type="text" name="pod_price[<?=$dt->id;?>]" value="<?=$dt->pod_price;?>" size="10" style="text-align:right">						
					</td>
					<!--<td align="center">
						<input type="text" name="outd_price2[<?=$dt->id;?>]" value="<?=$dt->pod_amount;?>" size="10" style="text-align:right">						
					</td>-->
					<td align="center">
						<input type="text" name="outd_weight2[<?=$dt->id;?>]" value="0" size="10" style="text-align:right">&nbsp;KG
					</td>
					<td align="center">
						<input type="text" name="no_urut2[<?=$dt->id;?>]" value="0" size="5" style="text-align:center">
					</td>
					<td align="center">
						<input type="text" name="outd_scno2[<?=$dt->id;?>]" size="10" style="text-align:left">
					</td>
				</tr>
					<?php } }?>				
			</table>
			<?php }else if(empty($outh_id) && ($po_no=='10' || empty($po_no))){  ?>			
			<table width="100%">
				<tr>
					<td align="center">No.</td>
					<td align="center">Nama Barang</td>
					<td align="center">Unit</td>
					<td align="center">Jumlah</td>
					<td align="center">Harga</td>
					<!--<td align="center">Rate</td>-->
					<td align="center">Nilai(Non IDR)</td>
					<td align="center">Nilai(IDR)</td>
					<td align="center">Berat</td>
					<td align="center">No.Urut</td>
					<td align="center">No.SC</td>
					<td align="center">Action</td>
				</tr>
				<?php
				    $no=0; $tqty=0; $tprice=0; $tweight=0; $tprice_usd=0;
					$qd = mysql_query("SELECT a.*,b.prod_code,b.prod_name,b.prod_sat
									   FROM outgoing_temp a
									   INNER JOIN product b ON b.id=a.outd_prodid
									   WHERE a.outd_inputby='$user_id' ORDER BY a.id ASC");
					while($dt=mysql_fetch_object($qd)){	   
				    $no++;
					$tqty     = $tqty + $dt->outd_qty; 
					$tprice   = $tprice + $dt->outd_price;
					$tweight  = $tweight + $dt->outd_weight;
					$tprice_usd = $tprice_usd + $dt->outd_price_usd;
				?> 
				  <tr>
					<td style="width:20px;" align="center"><?=$no;?></td>
					<td style="width:300px;"><?php echo "$dt->prod_code - $dt->prod_name";?></td>
					<td style="width:150px;" align="center"><?=$dt->prod_sat;?></td>
					<td style="width:150px;" align="right"><?=number_format($dt->outd_qty,2,'.',',');?></td>
					<td style="width:150px;" align="right"><?=number_format($dt->outd_price_satuan,2,'.',',');?>&nbsp;<?=$dt->outd_currency;?></td>
					<!--<td style="width:150px;" align="right"><?=number_format($dt->outd_price_rate,2,'.',',');?></td>-->
					<td style="width:150px;" align="right"><?=number_format($dt->outd_price_usd,2,'.',',');?></td>
					<td style="width:150px;" align="right"><?=number_format($dt->outd_price,2,'.',',');?>&nbsp;IDR</td>
					<td style="width:150px;" align="right"><?=number_format($dt->outd_weight,2,'.',',');?>&nbsp;<?=$dt->outd_wunit;?></td>
					<td style="width:50px;" align="center"><?=$dt->no_urut;?></td>
					<td style="width:150px;" align="center"><?=$dt->outd_scno;?></td>
					<td style="width:170px;" align="center">
						<img src="images/btn_delete.png" width="20" height="20"  border="0"  title="Hapus" style="cursor:pointer" onClick="delete_detail_click('<?=$dt->id;?>');"/>
					</td>
				</tr>
				<?php } ?>
				<tr>
					<td colspan="3" align="right">Total</td>
					<td align="right"><?=number_format($tqty,2,'.',',');?><input type="hidden" name="tqty" value="<?=$tqty;?>"></td>
					<td>&nbsp;</td>
					<td align="right"><?=number_format($tprice_usd,2,'.',',');?></td>
					<td align="right"><?=number_format($tprice,2,'.',',');?>&nbsp;IDR</td>
					<td align="right"><?=number_format($tweight,2,'.',',');?>&nbsp;Kg</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>
			</table>
			<?php }else if(!empty($outh_id)){ ?>
			<table width="100%">
				<tr>
					<td align="center">No.</td>
					<td align="center">Nama Barang</td>
					<td align="center">Stock</td>
					<td align="center">Jumlah</td>
					<td align="center">Harga</td>
					<!--<td align="center">Rate</td>-->
					<td align="center">Nilai(Non IDR)</td>
					<td align="center">Nilai(IDR)</td>
					<td align="center">Berat</td>
					<td align="center">No.Urut</td>
					<td align="center">No.SC</td>
					<td align="center">Action</td>
				</tr>
				<?php
				    $no=0; $tqty=0; $tprice=0; $tweight=0; $tprice_usd=0;
					$qd = mysql_query("SELECT a.*, b.prod_code,b.prod_name,b.prod_sat,b.prod_cat
									   FROM outgoing_detail a
									   INNER JOIN product b ON b.id=a.outd_prodid
						   			   WHERE a.outd_hid='$outh_id' ORDER BY a.id ASC");
					while($dt=mysql_fetch_object($qd)){	   
				    $no++;
					$tqty     = $tqty + $dt->outd_qty; 
					$tprice   = $tprice + $dt->outd_price;
					$tweight  = $tweight + $dt->outd_weight;
					$tprice_usd = $tprice_usd + $dt->outd_price_usd;
					#stock
					$qstk2 = get_stock($start_date,$end_date,$bulan2,$tahun2,$dt->outd_prodid,$dt->prod_cat,$inv);
				?> 
				  <tr>
					<td align="center"><?=$no;?><input type="hidden" name="id_det[<?=$dt->id;?>]" value="<?=$dt->id;?>"></td>
					<td><input type="text" value="<?php echo "$dt->prod_code - $dt->prod_name : $dt->prod_sat";?>" size="30" readonly></td>
					<td align="center"><input type="text" name="outd_qstk2[<?=$dt->id;?>]" value="<?=$qstk2;?>" size="10" style="text-align:right;background-color:#CCFFFF" readonly></td>
					<td align="right"><input type="text" name="outd_qty[<?=$dt->id;?>]" value="<?=$dt->outd_qty;?>" size="10" style="text-align:right"></td>
					<td align="right">
						<input type="text" name="outd_price_satuan[<?=$dt->id;?>]" value="<?=$dt->outd_price_satuan;?>" size="10" style="text-align:right">
						<input type="text" name="outd_currency[<?=$dt->id;?>]" value="<?=$dt->outd_currency;?>" size="5" style="text-align:center">
					</td>
					<!--<td align="right"><input type="text" name="outd_price_rate[<?=$dt->id;?>]" value="<?=$dt->outd_price_rate;?>" size="10" style="text-align:right"></td>-->
					<td align="right"><input type="text" name="outd_price_usd[<?=$dt->id;?>]" value="<?=$dt->outd_price_usd;?>" size="10" style="text-align:right">&nbsp;</td>
					<td align="right">
						<input type="text" name="outd_price[<?=$dt->id;?>]" value="<?=$dt->outd_price;?>" size="10" style="text-align:right">&nbsp;IDR
						<input type="hidden" name="outd_price_rate[<?=$dt->id;?>]" value="<?=$dt->outd_price_rate;?>" size="10" style="text-align:right" readonly>
						<input type="hidden" name="outd_prodid[<?=$dt->id;?>]" value="<?=$dt->outd_prodid;?>" size="10" style="text-align:right" readonly>
						<input type="hidden" name="outd_codename[<?=$dt->id;?>]" value="<?php echo "$dt->prod_code - $dt->prod_name : $dt->prod_sat";?>" size="10" style="text-align:right" readonly>
					</td>
					<td align="right"><input type="text" name="outd_weight[<?=$dt->id;?>]" value="<?=$dt->outd_weight;?>" size="10" style="text-align:right">&nbsp;<?=$dt->outd_wunit;?></td>
					<td align="right"><input type="text" name="no_urut[<?=$dt->id;?>]" value="<?=$dt->no_urut;?>" size="5" style="text-align:center"></td>
					<td align="right"><input type="text" name="outd_scno[<?=$dt->id;?>]" value="<?=$dt->outd_scno;?>" size="10" style="text-align:left"></td>
					<td align="center">
						<img src="images/btn_delete.png" width="20" height="20"  border="0"  title="Hapus" style="cursor:pointer" onClick="delete_detail_click('<?=$dt->id;?>');"/>
					</td>
				</tr>
				<?php } ?>
				<tr>
					<td colspan="3" align="right">Total</td>
					<td align="right"><?=number_format($tqty,2,'.',',');?><input type="hidden" name="tqty" value="<?=$tqty;?>"></td>
					<td>&nbsp;</td>
					<td align="right"><?=number_format($tprice_usd,2,'.',',');?></td>
					<td align="right"><?=number_format($tprice,2,'.',',');?>&nbsp;IDR</td>
					<td align="right"><?=number_format($tweight,2,'.',',');?>&nbsp;Kg</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>
			</table>
			<?php } ?>
		</td>
	</tr>
	<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>
</html>