<input type="hidden" id="idhdrbc30" value="<?php echo $idhdrbc30; ?>" />
<input type="hidden" id="idhdrbc30_data_out" value="<?php echo $id_data_out_hdr; ?>" />
<div id="tabdocbc30_dtl" style="height:440px">
	<ul>
		<li><a id="idtabitemsbc30hdr_dtl" href="#divtabitemsbc30hdr_dtl">Header Dokumen</a></li>
		<li><a id="idtabitemsbc30_dtl" href="#divtabitemsbc30_dtl">Detil Barang</a></li>
		<li><a id="idtabdocumentsbc30_dtl" href="#divtabdocumentsbc30_dtl">Dokumen</a></li>
	
	</ul>
	<div id="divtabitemsbc30hdr_dtl" >
		<button id="btnviewhdrbc30_dtl" >View Form</button><span style="padding-left:20px" /><button id="btnviewhdrbc30_cekinv" >Cek NoInv</button>
		<div style="height:10px"></div>
		<table id="tblbc30hdr_dtl"></table> <!--<div id="ptblbc30hdr_dtl"></div> -->
		<br />
		<a style="color:red">Pilih datanya dahulu sebelum update:</a>
		<table>
			<tr>
			<td>Nomor Pengajuan</td><td>:</td><td><input id="txtcarbc30hdr" style="width:190px"></input></td>
			</tr>
			<tr>
				<td>Masukan Nomor Daftar</td><td>:</td><td><input type="text" id="txtnodaftarbc30hdr" style="width:100px" maxlength=6/></td>
			</tr>
			<tr>
				<td>Masukan Tanggal Daftar</td><td>:</td><td><input type="text" id="txttgldaftarbc30hdr" style="width:100px"/>mm/dd/yyyy</td>
			</tr>
			<tr>
				<td></td><td></td><td><button id="btnupdaprosesbc30manual" >Update</button> <span style="padding-left:20px" /><button id="btnupdetpemasukanbc30manual" >Update Pengeluaran Barang</button></td>
			</tr>
		</table>
		<br />
		
		<table>
			<tr>
				<td>Tgl Pengeluaran</td><td>:</td><td><input type="text" id="txttglpemasukanbc30hdr" style="width:100px"/>dd/mm/yyyy</td><td></td>
			</tr>
			<tr>
				<td>Tgl Pengeluaran Approved</td><td>:</td><td><input type="text" id="txttglpemasukanapprovedbc30hdr" style="width:100px"/>dd/mm/yyyy</td>
				<td></td>
			</tr>
			<tr>
				<td></td><td></td><td><button id="btnapprovedpemasukanbc30manual" style="color:red">Approved Pengeluaran Barang</button></td><td></td>
			</tr>
		</table>
	</div>
	<div id="divtabitemsbc30_dtl" >
		<button id="btnviewitembc30_dtl" >View Form</button>
		<div style="height:10px"></div>
		<table id="tblbc30detilitems"></table> <div id="ptblbc30detilitems"></div>
	</div>
	<div id="divtabdocumentsbc30_dtl" >
		<button id="btnviewdokbc30_dtl" >View Form</button>
		<div style="height:10px"></div>
		<table id="tblbc30dok"></table> <div id="ptblbc30dok"></div>
	</div>
	
</div>	



<script type="text/javascript">
    
    $(document).ready(function(){
		$( "#tabdocbc30_dtl" ).tabs();
		$("#btnviewhdrbc30_dtl").button().click(function(){
			alert("On Progress to view form");
		
		});
		$("#btnviewitembc30_dtl").button().click(function(){
			alert("On Progress to view form");
			
		});
		$("#btnviewdokbc30_dtl").button().click(function(){
			alert("On Progress to view form");
		
		});
		
		var datesetopt = {
			showOn: "button",
			buttonImageOnly: true,
			buttonImage: "<?php echo base_url()."assets/images/icons/16x16/timespan.png"  ?>",
			buttonText: "Tanggalan",
			dateFormat: 'mm/dd/yy'
		};
		
		$("#txttgldaftarbc30hdr").datepicker(datesetopt);
		$("#txttglpemasukanbc30hdr").datepicker(datesetopt);
		$("#txttglpemasukanapprovedbc30hdr").datepicker(datesetopt);
		$("#btnapprovedpemasukanbc30manual").button().click(function(){ 
			if( ($.trim($("#txtcarbc30hdr").val()) =='' && $.trim($("#txtcarbc30hdr").val()) =='-') || $.trim($("#txtnodaftarbc30hdr").val()) == '' || $.trim($("#txttgldaftarbc30hdr").val()) == '' || $.trim($("#txttglpemasukanbc30hdr").val())=='' || $.trim($("#txttglpemasukanapprovedbc30hdr").val())=='' ){
				alert('Data Belum Lengkap');
				return false;
			
			}
			
			var id = jQuery("#tblbc30hdr_dtl").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc30hdr_dtl").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data ={
				id_bc_out:$("#idhdrbc30_data_out").val(),
				typedok:ret.typedok,
				tglfg_out:$("#txttglpemasukanbc30hdr").val(),
				tglfg_out_apporved:$("#txttglpemasukanapprovedbc30hdr").val(),
			};		
			
			if ($("#idhdrbc30_data_out").val()==''){
						
				alert("Data Belum Di Proses Pemasukan");
				return false;
			}
			
			$("#dlg_prosesdatatofg_bc30_approved").dialog( "destroy" );
			$(".dlg_prosesdatatofg_bc30_approvedcl").remove();
			$(".dlg_prosesdatatofg_bc30_approvedcl").html('');
			$("body").append('<div id="dlg_prosesdatatofg_bc30_approved" title="Warning" class="dlg_prosesdatatofg_bc30_approvedcl"><p>Apakah anda akan memproses data ini?!?</p><br /> Type Doc BC = '+ ret.typedok +'</div>');
			$("#dlg_prosesdatatofg_bc30_approved").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
						if ($("#tglfg_out").val()=='' || $("#tglfg_out_apporved").val()==''){
			
							alert("Please Insert Date");
							return false;
						
						}
					
					$.ajax({
						url : "<?php echo base_url().'inventory/ct_fg/prosesdatatofg_approved'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_prosesdatatofg_bc30_approved").dialog("close");
								$('#dlg_prosesdatatofg_bc30_approved').dialog("destroy"); 
								$(".dlg_prosesdatatofg_bc30_approvedcl").remove(); 
								/* jQuery("#tblfgout_hdr").trigger('reloadGrid'); */
							} else { 
								alert(msg.sts+' '+msg.desc); 
								$("#dlg_prosesdatatofg_bc30_approved").dialog("close");
								$('#dlg_prosesdatatofg_bc30_approved').dialog("destroy"); 
								$(".dlg_prosesdatatofg_bc30_approvedcl").remove(); 

							}
						}
					});
				},
					"CANCEL": function() {
						$( "#dlg_prosesdatatofg_bc30_approved" ).dialog( "close" );

					}
				},
				close : function(){
					$('#dlg_prosesdatatofg_bc30_approved').dialog("destroy"); 
					$(".dlg_prosesdatatofg_bc30_approvedcl").remove(); 
					$("body").append('<div id="dlg_prosesdatatofg_bc30_approved" title="Warning" class="dlg_prosesdatatofg_bc30_approvedcl"><p>Apakah anda akan memproses file ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
		
		});
		
		$("#btnviewhdrbc30_cekinv").button().click(function(){ 
		
			var gridData = jQuery("#tblbc30dok").getRowData();
			var postData = JSON.stringify(gridData);
			var form_data={
				datadiff:postData
			};	
			
			$.ajax({
				url :"<?php echo base_url().'exim/ct_bc30/cek_inv_bc30'; ?>",
				type : 'POST',
				dataType: 'json',
				data : form_data,
				success: function(msg){
					if (msg.sts == '00'){
						alert(msg.desc);
					
					} else { 
						alert(msg.sts+msg.desc);

					}
				}
			});
			
		});
		
		$("#btnupdetpemasukanbc30manual").button().click(function(){
			if( ($.trim($("#txtcarbc30hdr").val()) =='' && $.trim($("#txtcarbc30hdr").val()) =='-') || $.trim($("#txtnodaftarbc30hdr").val()) == '' || $.trim($("#txttgldaftarbc30hdr").val()) == '' ){
				alert('Data Belum Lengkap');
				return false;
			
			}
			
			
			var id = jQuery("#tblbc30hdr_dtl").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc30hdr_dtl").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			if (ret.CAR == '-'){
				alert('car belum ada');
			    return false;
			}
			
			if (ret.nodaft == ''){
				alert('nodaft belum ada');
			    return false;
			}
			
			var form_data = {
				
				id_bc_out:ret.id_bc_out_hdr,typedok:ret.typedok,statusdok:ret.statusdok
				
			};
			
					
			$("#update_pemasukan_bc30").dialog( "destroy" );
			$(".update_pemasukan_bc30cl").remove();
			$(".update_pemasukan_bc30cl").html('');
			$("body").append('<div id="update_pemasukan_bc30" title="Warning" class="update_pemasukan_bc30cl"><p>Apakah anda akan Memproses Data ini Menjadi Data Pengeluaran bc30?</p><br />Harap Periksa Baik2 karena perubahan hanya satu kali dan data menjadi APPROVED di inventory!!!!!</div>');
			$("#update_pemasukan_bc30").dialog({
				height: 200,
				width: 350,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url :"<?php echo base_url().'exim/ct_bc30/prosesdatatofg'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#update_pemasukan_bc30").dialog("close");
								$('#update_pemasukan_bc30').dialog("destroy"); 
								$(".update_pemasukan_bc30cl").remove(); 
								$(".update_pemasukan_bc30cl").html('');
								$("#idhdrbc30_data_out").val(msg.id_bc_out);
								$('#tblbc30hdr').trigger('reloadGrid');
								$('#tblbc30hdr_dtl').trigger('reloadGrid');
							} else { 
								alert(msg.sts+msg.desc);
								$("#update_pemasukan_bc30").dialog("close");
								$('#update_pemasukan_bc30').dialog("destroy"); 
								$(".update_pemasukan_bc30cl").remove(); 		

							}
						}
					});
				},
				"CANCEL": function() {
						$( "#update_pemasukan_bc30" ).dialog( "close" );

					}
				},
				close : function(){
					$('#update_pemasukan_bc30').dialog("destroy"); 
					$(".update_pemasukan_bc30cl").remove(); 
					$("body").append('<div id="update_pemasukan_bc30" title="Warning" class="update_pemasukan_bc30cl"><p>Apakah anda akan Memproses Data ini Menjadi Data Pengeluaran bc30?</p><br />Harap Periksa Baik2 karena perubahan hanya satu kali dan data menjadi APPROVED di inventory!!!!!</div></div>');     
					$(".update_pemasukan_bc30cl").html('');
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
			
		
		});
		
		$("#btnupdaprosesbc30manual").button().click(function(){
			
			var id = jQuery("#tblbc30hdr_dtl").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc30hdr_dtl").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			if (ret.CAR != '-'){
				alert('car sudah ada');
			    return false;
			}
			
			
			
			var form_data = {
				
				id_bc_out_hdr:ret.id_bc_out_hdr,
				car:$("#txtcarbc30hdr").val(),
				nodaft:$("#txtnodaftarbc30hdr").val(),
				tgdaft:$("#txttgldaftarbc30hdr").val()
			};
						
			$("#update_car_bc30_manual").dialog( "destroy" );
			$(".update_car_bc30_manualcl").remove();
			$(".update_car_bc30_manualcl").html('');
			$("body").append('<div id="update_car_bc30_manual" title="Warning" class="update_car_bc30_manualcl"><p>Apakah anda akan Memproses Data ini Menjadi Data bc30?</p><br />Harap Periksa Baik2 karena perubahan hanya satu kali</div>');
			$("#update_car_bc30_manual").dialog({
				height: 200,
				width: 350,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url :"<?php echo base_url().'exim/ct_bc30/sendtomodulbc30manual'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#update_car_bc30_manual").dialog("close");
								$('#update_car_bc30_manual').dialog("destroy"); 
								$(".update_car_bc30_manualcl").remove(); 
								$(".update_car_bc30_manualcl").html('');
								$('#tblbc30hdr').trigger('reloadGrid');
								$('#tblbc30hdr_dtl').trigger('reloadGrid');
							} else { 
								alert(msg.sts+msg.desc);
								$("#update_car_bc30_manual").dialog("close");
								$('#update_car_bc30_manual').dialog("destroy"); 
								$(".update_car_bc30_manualcl").remove(); 		

							}
						}
					});
				},
				"CANCEL": function() {
						$( "#update_car_bc30_manual" ).dialog( "close" );

					}
				},
				close : function(){
					$('#update_car_bc30_manual').dialog("destroy"); 
					$(".update_car_bc30_manualcl").remove(); 
					$("body").append('<div id="update_car_bc30_manual" title="Warning" class="update_car_bc30_manualcl"><p>Apakah anda akan Memproses Data ini Menjadi Data bc30?</p></div>');     
					$(".update_car_bc30_manualcl").html('');
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
		
		});
		
		var datePick = function (el) {
			$(el).datepicker({
				changeYear: true,
				changeMonth: true,
				showButtonPanel: true,
				onSelect: function () {
					
					if (this.id.substr(0, 3) === "gs_") {
               
					setTimeout(function(){
					jQuery("#tblbc30hdr_dtl").jqGrid()[0].triggerToolbar();
						}, 50);
					} else {
						
						$(this).trigger('change');
					}
				}    
			});
		};
		
		jQuery("#tblbc30hdr_dtl").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc30/loaddata'; ?>',
			mtype : "post",
			postData:{'q':'66','idhdrbc30':$("#idhdrbc30").val()},
			datatype: "json",
			colNames:[
			   'id'
			  ,'CAR'
			  ,'JnEks'
			  ,'KatEks'
			  ,'JNPEB'
			  ,'JNEKSOld'
			  ,'JNLAIN'
			  ,'JNDAG'
			  ,'JNBYR'
			  ,'IDEKS'
			  ,'NPWPEKS'
			  ,'NamaEks'
			  ,'AlmtEks'
			  ,'NoSiup'
			  ,'TgSiup'
			  ,'JnPerus'
			  ,'NoTdp'
			  ,'TgTdp'
			  ,'Niper'
			  ,'StatusH'
			  ,'IdQq'
			  ,'NpwpQq'
			  ,'NamaQq'
			  ,'AlmtQq'
			  ,'NiperQq'
			  ,'NAMABELI'
			  ,'ALMTBELI'
			  ,'NEGBELI'
			  ,'IDPPJK'
			  ,'NPWPPPJK'
			  ,'NamaPpjk'
			  ,'AlmtPpjk'
			  ,'NoPpjk'
			  ,'TgPpjk'
			  ,'MODA'
			  ,'TGEKS'
			  ,'CARRIER'
			  ,'VOY'
			  ,'NOSHIPORD'
			  ,'TGSHIPORD'
			  ,'PELMUAT'
			  ,'PELBONGKAR'
			  ,'PELTRANSIT'
			  ,'NOINV'
			  ,'TGINV'
			  ,'NOLPSE'
			  ,'TGLPSE'
			  ,'PROPBRG'
			  ,'NEGTUJU'
			  ,'FLSIE'
			  ,'FLKARANT'
			  ,'FLSM'
			  ,'FLIZLAIN'
			  ,'DELIVERY'
			  ,'KdHrg'
			  ,'NilInv'
			  ,'KDVAL'
			  ,'FREIGHT'
			  ,'ASURANSI'
			  ,'KdAss'
			  ,'FOB'
			  ,'MERK'
			  ,'JMCONT'
			  ,'BRUTO'
			  ,'NETTO'
			  ,'JMBRG'
			  ,'JMBRGCTH'
			  ,'JMBRGGAB'
			  ,'JMBRGPJT'
			  ,'NODAFT'
			  ,'TGDAFT'
			  ,'KDKTR'
			  ,'KTRGATE'
			  ,'NILPE'
			  ,'KDBANK'
			  ,'LOKBANK'
			  ,'NOSSP'
			  ,'TGSSP'
			  ,'JNTPB'
			  ,'LOKTPB'
			  ,'KDLOKBRG'
			  ,'KDKTRMUAT'
			  ,'KDKTRPRIKS'
			  ,'TGSIAP'
			  ,'WKSIAP'
			  ,'ASALDATA'
			  ,'TPNAME'
			  ,'PEBOK'
			  ,'LENGKAP'
			  ,'JNPARTOF'
			  ,'BENDERA'
			  ,'TTDPEB'
			  ,'STATUS'
			  ,'SNRF'
			  ,'NOBCF'
			  ,'TGBCF'
			  ,'SERIBCF'
			  ,'NOMOREDI'
			  ,'KMDT'
			  ,'VOLUME'
			  ,'KDHANGGAR'
			  ,'KONS'
			  ,'JMLKMSPEB'
			  ,'PELMUATEKS'
			  ,'NILKURS'
			  ,'PNBP'
			  ,'NOBC11'
			  ,'TGBC11'
			  ,'POSBC11'
			  ,'SUBPOSBC11'
			  ,'create_date'
			  ,'create_by'
			  ,'update_date'
			  ,'update_by'
			  ,'typedok'
			  ,'statusdok'
			  ,'noinv1'
			  ,'tginv1'
			  ,'inv_hdr_id'
			  ,'bc_in_from_in'
			  ,'nopol'
			  
			  
			],
			colModel:[
				{name:'id_bc_out_hdr',index:'id_bc_out_hdr', width:120, hidden:true},
				{name:'CAR',index:'CAR', width:165, hidden:false},
				{name:'JnEks',index:'JnEks', width:120, hidden:true},
				{name:'KatEks',index:'KatEks', width:120, hidden:true},
				{name:'JNPEB',index:'JNPEB', width:120, hidden:true},
				{name:'JNEKSOld',index:'JNEKSOld', width:120, hidden:true},
				{name:'JNLAIN',index:'JNLAIN', width:120, hidden:true},
				{name:'JNDAG',index:'JNDAG', width:120, hidden:true},
				{name:'JNBYR',index:'JNBYR', width:120, hidden:true},
				{name:'IDEKS',index:'IDEKS', width:120, hidden:true},
				{name:'NPWPEKS',index:'NPWPEKS', width:120, hidden:true},
				{name:'NamaEks',index:'NamaEks', width:120, hidden:true},
				{name:'AlmtEks',index:'AlmtEks', width:120, hidden:true},
				{name:'NoSiup',index:'NoSiup', width:120, hidden:true},
				{name:'TgSiup',index:'TgSiup', width:120, hidden:true},
				{name:'JnPerus',index:'JnPerus', width:120, hidden:true},
				{name:'NoTdp',index:'NoTdp', width:120, hidden:true},
				{name:'TgTdp',index:'TgTdp', width:120, hidden:true},
				{name:'Niper',index:'Niper', width:120, hidden:true},
				{name:'StatusH',index:'StatusH', width:120, hidden:true},
				{name:'IdQq',index:'IdQq', width:120, hidden:true},
				{name:'NpwpQq',index:'NpwpQq', width:120, hidden:true},
				{name:'NamaQq',index:'NamaQq', width:120, hidden:true},
				{name:'AlmtQq',index:'AlmtQq', width:120, hidden:true},
				{name:'NiperQq',index:'NiperQq', width:120, hidden:true},
				{name:'NAMABELI',index:'NAMABELI', width:170, hidden:false},
				{name:'ALMTBELI',index:'ALMTBELI', width:120, hidden:true},
				{name:'NEGBELI',index:'NEGBELI', width:70, hidden:false},
				{name:'IDPPJK',index:'IDPPJK', width:120, hidden:true},
				{name:'NPWPPPJK',index:'NPWPPPJK', width:120, hidden:true},
				{name:'NamaPpjk',index:'NamaPpjk', width:120, hidden:true},
				{name:'AlmtPpjk',index:'AlmtPpjk', width:120, hidden:true},
				{name:'NoPpjk',index:'NoPpjk', width:120, hidden:true},
				{name:'TgPpjk',index:'TgPpjk', width:120, hidden:true},
				{name:'MODA',index:'MODA', width:120, hidden:true},
				{name:'TGEKS',index:'TGEKS', width:120, hidden:true},
				{name:'CARRIER',index:'CARRIER', width:120, hidden:true},
				{name:'VOY',index:'VOY', width:120, hidden:true},
				{name:'NOSHIPORD',index:'NOSHIPORD', width:120, hidden:true},
				{name:'TGSHIPORD',index:'TGSHIPORD', width:120, hidden:true},
				{name:'PELMUAT',index:'PELMUAT', width:120, hidden:true},
				{name:'PELBONGKAR',index:'PELBONGKAR', width:120, hidden:true},
				{name:'PELTRANSIT',index:'PELTRANSIT', width:120, hidden:true},
				{name:'NOINV',index:'NOINV', width:120, hidden:true},
				{name:'TGINV',index:'TGINV', width:60, hidden:true},
				{name:'NOLPSE',index:'NOLPSE', width:120, hidden:true},
				{name:'TGLPSE',index:'TGLPSE', width:120, hidden:true},
				{name:'PROPBRG',index:'PROPBRG', width:120, hidden:true},
				{name:'NEGTUJU',index:'NEGTUJU', width:120, hidden:true},
				{name:'FLSIE',index:'FLSIE', width:120, hidden:true},
				{name:'FLKARANT',index:'FLKARANT', width:120, hidden:true},
				{name:'FLSM',index:'FLSM', width:120, hidden:true},
				{name:'FLIZLAIN',index:'FLIZLAIN', width:120, hidden:true},
				{name:'DELIVERY',index:'DELIVERY', width:120, hidden:true},
				{name:'KdHrg',index:'KdHrg', width:120, hidden:true},
				{name:'NilInv',index:'NilInv', width:90, hidden:false, align:'right', formatter:'number',formatoptions: { decimalPlaces: 4 }},
				{name:'KDVAL',index:'KDVAL', width:50, hidden:false},
				{name:'FREIGHT',index:'FREIGHT', width:120, hidden:true},
				{name:'ASURANSI',index:'ASURANSI', width:120, hidden:true},
				{name:'KdAss',index:'KdAss', width:120, hidden:true},
				{name:'FOB',index:'FOB', width:120, hidden:true},
				{name:'MERK',index:'MERK', width:120, hidden:true},
				{name:'JMCONT',index:'JMCONT', width:60, hidden:false, align:'right'},
				{name:'BRUTO',index:'BRUTO', width:120, hidden:false, align:'right'},
				{name:'NETTO',index:'NETTO', width:120, hidden:false, align:'right'},
				{name:'JMBRG',index:'JMBRG', width:60, hidden:false, align:'right'},
				{name:'JMBRGCTH',index:'JMBRGCTH', width:120, hidden:true},
				{name:'JMBRGGAB',index:'JMBRGGAB', width:120, hidden:true},
				{name:'JMBRGPJT',index:'JMBRGPJT', width:120, hidden:true},
				{name:'NODAFT',index:'NODAFT', width:120, hidden:false},
				{name:'TGDAFT',index:'TGDAFT', width:120, hidden:false,stype:"text",searchoptions:{dataInit:datePick, att:{title:'Select Date'}}},
				{name:'KDKTR',index:'KDKTR', width:120, hidden:true},
				{name:'KTRGATE',index:'KTRGATE', width:120, hidden:true},
				{name:'NILPE',index:'NILPE', width:120, hidden:true},
				{name:'KDBANK',index:'KDBANK', width:120, hidden:true},
				{name:'LOKBANK',index:'LOKBANK', width:120, hidden:true},
				{name:'NOSSP',index:'NOSSP', width:120, hidden:true},
				{name:'TGSSP',index:'TGSSP', width:120, hidden:true},
				{name:'JNTPB',index:'JNTPB', width:120, hidden:true},
				{name:'LOKTPB',index:'LOKTPB', width:120, hidden:true},
				{name:'KDLOKBRG',index:'KDLOKBRG', width:120, hidden:true},
				{name:'KDKTRMUAT',index:'KDKTRMUAT', width:120, hidden:true},
				{name:'KDKTRPRIKS',index:'KDKTRPRIKS', width:120, hidden:true},
				{name:'TGSIAP',index:'TGSIAP', width:120, hidden:true},
				{name:'WKSIAP',index:'WKSIAP', width:120, hidden:true},
				{name:'ASALDATA',index:'ASALDATA', width:120, hidden:true},
				{name:'TPNAME',index:'TPNAME', width:120, hidden:true},
				{name:'PEBOK',index:'PEBOK', width:120, hidden:true},
				{name:'LENGKAP',index:'LENGKAP', width:120, hidden:true},
				{name:'JNPARTOF',index:'JNPARTOF', width:120, hidden:true},
				{name:'BENDERA',index:'BENDERA', width:120, hidden:true},
				{name:'TTDPEB',index:'TTDPEB', width:120, hidden:true},
				{name:'STATUS',index:'STATUS', width:120, hidden:false},
				{name:'SNRF',index:'SNRF', width:120, hidden:true},
				{name:'NOBCF',index:'NOBCF', width:120, hidden:true},
				{name:'TGBCF',index:'TGBCF', width:120, hidden:true},
				{name:'SERIBCF',index:'SERIBCF', width:120, hidden:true},
				{name:'NOMOREDI',index:'NOMOREDI', width:120, hidden:true},
				{name:'KMDT',index:'KMDT', width:120, hidden:true},
				{name:'VOLUME',index:'VOLUME', width:120, hidden:true},
				{name:'KDHANGGAR',index:'KDHANGGAR', width:120, hidden:true},
				{name:'KONS',index:'KONS', width:120, hidden:true},
				{name:'JMLKMSPEB',index:'JMLKMSPEB', width:120, hidden:true},
				{name:'PELMUATEKS',index:'PELMUATEKS', width:120, hidden:true},
				{name:'NILKURS',index:'NILKURS', width:120, hidden:true},
				{name:'PNBP',index:'PNBP', width:120, hidden:true},
				{name:'NOBC11',index:'NOBC11', width:120, hidden:true},
				{name:'TGBC11',index:'TGBC11', width:120, hidden:true},
				{name:'POSBC11',index:'POSBC11', width:120, hidden:true},
				{name:'SUBPOSBC11',index:'SUBPOSBC11', width:120, hidden:true},
				{name:'create_date',index:'create_date', width:120, hidden:true},
				{name:'create_by',index:'create_by', width:120, hidden:true},
				{name:'update_date',index:'update_date', width:120, hidden:true},
				{name:'update_by',index:'update_by', width:120, hidden:true},
				{name:'typedok',index:'typedok', width:120, hidden:true},
				{name:'statusdok',index:'statusdok', width:120, hidden:false},
				{name:'noinv1',index:'noinv1', width:120, hidden:true},
				{name:'tginv1',index:'tginv1', width:120, hidden:true},
				{name:'inv_hdr_id',index:'inv_hdr_id', width:120, hidden:true},
				{name:'bc_in_from_in',index:'bc_in_from_in', width:120, hidden:true},
				{name:'nopol',index:'nopol', width:120, hidden:true},
				
				
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc30hdr_dtl',
			sortname: 'id_bc_out_hdr',
			viewrecords: true,
			sortorder: "desc",
			width: 950,
			height:50,
			jsonReader: { repeatitems : false },
			caption:"List of BC30 Header",
			rownumbers: true,
			shrinkToFit: false,
			multiselect: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#tblbc30hdr_dtl").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#tblbc30hdr_dtl").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#tblbc30hdr_dtl").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
			gridComplete: function(){
				/*
				var rowIDs = jQuery("#tblbc30hdr_dtl").getDataIDs(); 
				var rowData = $("#tblbc30hdr_dtl").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tblbc30hdr_dtl'));
				    switch (rowData[i].STATUS) {
						case '00':
						   trElement.css({"color":"blue"});
						break;
						
					}
				} */
			},
			onSelectRow: function(id){
				var grididpr = jQuery("#tblbc30hdr_dtl").jqGrid('getGridParam','selrow');
				 if(grididpr){
					 var stret = jQuery("#tblbc30hdr_dtl").jqGrid('getRowData',grididpr);
					
					if (stret.CAR != '' && stret.CAR != '-'){
						$("#txtcarbc30hdr").attr('readonly', true);
					 
					 } else { $("#txtcarbc30hdr").attr('readonly', false); } 
					   $("#txtcarbc30hdr").val(stret.CAR);
					   $("#txtnodaftarbc30hdr").val(stret.NODAFT);
					   $("#txttgldaftarbc30hdr").val(stret.TGDAFT);
				  
				 }
			}
		}); 
		jQuery("#tblbc30hdr_dtl").jqGrid('navGrid','#ptblbc30hdr_dtl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
	    jQuery("#tblbc30hdr_dtl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});

		var form_data={
			'q':'66','idhdrbc30':$("#idhdrbc30").val()
		};
		
		jQuery("#tblbc30detilitems").jqGrid({
		url:'<?php echo base_url().'exim/ct_bc30/loaddatadetil'; ?>',
		mtype : "post",
		postData:form_data,
		datatype: "json",
		colNames:[
			'idpebdtl'
			  ,'idpebhdr'
			  ,'CAR'
			  ,'SERIBRG'
			  ,'HS'
			  ,'URBRG1'
			  ,'URBRG2'
			  ,'URBRG3'
			  ,'URBRG4'
			  ,'DMERK'
			  ,'SIZE'
			  ,'TYPE'
			  ,'KDBRG'
			  ,'KDIZIN'
			  ,'NOIZIN'
			  ,'TGIZIN'
			  ,'JMKOLI'
			  ,'JNKOLI'
			  ,'DNilInv'
			  ,'FOBPERBRG'
			  ,'FOBPERSAT'
			  ,'KDPE'
			  ,'TARIPPE'
			  ,'HPATOK'
			  ,'JMSATUAN'
			  ,'JNSATUAN'
			  ,'NETDET'
			  ,'JMSATPE'
			  ,'JNSATPE'
			  ,'KDVALPE'
			  ,'NILVALPE'
			  ,'PEPERBRG'
			  ,'DTLOK'
			  ,'NCV'
			  ,'DVolume'
			  ,'NegAsal'
			
		],

		colModel:[
			{name:'id_bc_out_dtl',index:'id_bc_out_dtl', width:120, hidden:true},
			{name:'id_bc_out_hdr',index:'id_bc_out_hdr', width:120, hidden:true},
			{name:'CAR',index:'CAR', width:120, hidden:true},
			{name:'SERIBRG',index:'SERIBRG', width:60, hidden:false},
			{name:'HS',index:'HS', width:120, hidden:false},
			{name:'URBRG1',index:'URBRG1', width:120, hidden:false},
			{name:'URBRG2',index:'URBRG2', width:256, hidden:false},
			{name:'URBRG3',index:'URBRG3', width:120, hidden:false},
			{name:'URBRG4',index:'URBRG4', width:120, hidden:false},
			{name:'DMERK',index:'DMERK', width:120, hidden:false},
			{name:'SIZE',index:'SIZE', width:80, hidden:false},
			{name:'TYPE',index:'TYPE', width:80, hidden:false},
			{name:'KDBRG',index:'KDBRG', width:92, hidden:false},
			{name:'KDIZIN',index:'KDIZIN', width:120, hidden:true},
			{name:'NOIZIN',index:'NOIZIN', width:120, hidden:true},
			{name:'TGIZIN',index:'TGIZIN', width:120, hidden:true},
			{name:'JMKOLI',index:'JMKOLI', width:85, hidden:false, align:'right'},
			{name:'JNKOLI',index:'JNKOLI', width:53, hidden:false},
			{name:'DNilInv',index:'DNilInv', width:80, hidden:false, align:'right'},
			{name:'FOBPERBRG',index:'FOBPERBRG', width:80, hidden:false, align:'right'},
			{name:'FOBPERSAT',index:'FOBPERSAT', width:120, hidden:true},
			{name:'KDPE',index:'KDPE', width:120, hidden:true},
			{name:'TARIPPE',index:'TARIPPE', width:120, hidden:true},
			{name:'HPATOK',index:'HPATOK', width:120, hidden:true},
			{name:'JMSATUAN',index:'JMSATUAN', width:80, hidden:false, align:'right'},
			{name:'JNSATUAN',index:'JNSATUAN', width:74, hidden:false},
			{name:'NETDET',index:'NETDET', width:120, hidden:false, align:'right'},
			{name:'JMSATPE',index:'JMSATPE', width:120, hidden:true},
			{name:'JNSATPE',index:'JNSATPE', width:120, hidden:true},
			{name:'KDVALPE',index:'KDVALPE', width:120, hidden:true},
			{name:'NILVALPE',index:'NILVALPE', width:120, hidden:true},
			{name:'PEPERBRG',index:'PEPERBRG', width:120, hidden:true},
			{name:'DTLOK',index:'DTLOK', width:120, hidden:true},
			{name:'NCV',index:'NCV', width:120, hidden:true},
			{name:'DVolume',index:'DVolume', width:120, hidden:true},
			{name:'NegAsal',index:'NegAsal', width:120, hidden:true},
		
		],
		
		rowNum:10,
		rowList:[10,20,30],
		pager: '#ptblbc30detilitems',
		sortname: 'id_bc_out_dtl',
		viewrecords: true,
		sortorder: "asc",
		width: 930,
		height:260,
		jsonReader: { repeatitems : false },
		caption:"List of BC30 Detil",
		rownumbers: true,
		shrinkToFit: false,
			afterInsertRow: function(rowid, aData){
			/*switch (aData.statusdok) {
				case 'DATA SENT':
					jQuery("#tblbc30detilitems").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
				break;
				case '2':
					jQuery("#tblbc30detilitems").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
				break;
				case '1':
					jQuery("#tblbc30detilitems").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
				break;
				
			} */
			},
			gridComplete: function(){
			 /*
				var rowIDs = jQuery("#tblbc30detilitems").getDataIDs(); 
				var rowData = $("#tblbc30detilitems").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tblbc30detilitems'));
				   
					switch (rowData[i].STATUS) {
						case '00':
						   trElement.css({"color":"blue"});
						break;
						
					}
				}
				 */
			},
		}); 
		jQuery("#tblbc30detilitems").jqGrid('navGrid','#ptblbc30detilitems',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tblbc30detilitems").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		
		jQuery("#tblbc30dok").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc30/loaddatadok'; ?>',
			mtype : "post",
			postData:{'q':'1', idhdrbc30:$("#idhdrbc30").val()},
			datatype: "json",
			colNames:['ID', 'id_hdr', 'CAR','Dok Kd', 'Uraian', 'Dok No', 'Dok Tg'
					],
			colModel:[
				{name:'id_bc_out_dok',index:'id_bc_out_dok', width:30, hidden:true},
				{name:'id_bc_out_hdr',index:'id_bc_out_hdr', width:30, hidden:true},
				{name:'CAR',index:'CAR', width:171, hidden:false},
				{name:'KdDok',index:'KdDok', width:77, hidden:false},
				{name:'uraian',index:'uraian', width:183, hidden:false},
				{name:'NoDok',index:'NoDok', width:160, hidden:false},
				{name:'TgDok',index:'DokTg', width:104, hidden:false}				
				
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc30dok',
			sortname: 'id_bc_out_dok',
			viewrecords: true,
			sortorder: "asc",
			width: 950,
			height:290,
			jsonReader: { repeatitems : false },
			caption:"Dokumen",
			//rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			}	
		
		});
		
		jQuery("#tblbc30dok").jqGrid('navGrid','#ptblbc30dok',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		
		
		
	});
		  	
</script>



	
	