<div id="tabdocbc40_dtl" style="height:440px">
	<ul>
		<li><a id="idtabitemsbc40hdr_dtl" href="#divtabitemsbc40hdr_dtl">Header Dokumen</a></li>
		<li><a id="idtabitemsbc40_dtl" href="#divtabitemsbc40_dtl">Detil Barang</a></li>
		<li><a id="idtabdocumentsbc40_dtl" href="#divtabdocumentsbc40_dtl">Dokumen</a></li>
		<li><a id="idtabcontainernc23_dtl" href="#divtabcontainernc23_dtl">Peti Kemas</a></li>
	</ul>
	<div id="divtabitemsbc40hdr_dtl" >
		<button id="btnviewhdrbc40_dtl" >View Form</button>
		<button id="btnviewhdrbc40_excel_dtl" >Excel Form</button>
		<div style="height:10px"></div>
		<table id="tblbc40hdr_dtl"></table>
		<table>
			<tr>
				<td>No. Group Invoice</td><td>:</td><td><?php echo $gabinv; ?></td>
			</tr>
			<tr>
			  <td>Tgl. Group Invoice</td><td>:</td><td><?php echo $tglgabinv; ?></td>
			</tr>
            <tr>
				<td>Input No. Pengajuan</td><td>:</td><td><input id="txtbc40noaju" value="<?php echo $car; ?>" /></td>
			</tr>
			<tr>
				<td>Input tgl. Pengajuan</td><td>:</td><td><input id="txtbc40tglaju" value="<?php echo $DokTupTg; ?>" /> mm/dd/yyyy</td>
			</tr>
			<tr>
				<td>Input No. bc40 (Dari BC)</td><td>:</td><td><input id="txtbc40nobc40"  value="<?php echo $BC23No; ?>"/></td>
			</tr>
            <tr>
				<td>Input Tgl. bc40 (Dari BC)</td><td>:</td><td><input id="txtbc40tglbc40"   value="<?php echo $BC23Tg; ?>" /> mm/dd/yyyy</td>
			</tr>
			<tr>
				<td>Pasok Nama</td><td>:</td><td><input id="txtbc40pasoknama"  value="<?php echo $PasokNama; ?>" /></td>
			</tr>
			<tr>
				<td></td><td></td><td><br /><button id="btnupdatebc40noaju">Update Data bc40</button></td>
			</tr>	
		</table>
		<div style="position:absolute;left:380px;top:140px">
		<table>
			<tr>
				<td></td>
			</tr>
		</table>
		</div>
		
	</div>
	<div id="divtabitemsbc40_dtl" >
		<button id="btnviewitembc40_dtl" >View Form</button>
		<button id="btnviewpartitembc40_dtl" >Data Part</button>
		<div style="height:10px"></div>
		<table id="tblbc40detilitems"></table> <div id="ptblbc40detilitems"></div>
	</div>
	<div id="divtabdocumentsbc40_dtl" >
		<button id="btnviewdokbc40_dtl" >View Form</button>
		<button id="btnupdatedokbc40_dtl" >Update Dokumen</button>
		<button id="btnupdatedokbc40_cancel" >Cancel Dok PO</button>
		<div style="height:10px"></div>
		<table id="tblbc40dok"></table> <div id="ptblbc40dok"></div>
		
	</div>
	<div id="divtabcontainernc23_dtl" >
		<div style="height:10px"></div>
		<table id="tblbc40con"></table> <div id="ptblbc40con"></div>
	</div>
</div>	
<input type="hidden" id="idhdrbc40" value="<?php echo $idhdrbc40; ?>" />
<input type="hidden" id="inv_hdr_idbc40" value="<?php echo $inv_hdr_idbc40; ?>" />
<input type="hidden" id="bc40noinv" value="<?php echo $noinv; ?>" />
<input type="hidden" id="hdnbc40dtl_car" value="<?php echo $car; ?>" />
<script type="text/javascript">
    $(document).ready(function(){
		$( "#tabdocbc40_dtl" ).tabs();
		
		$( "#btnviewdokbc40_dtl" ).button();
		$( "#btnupdatedokbc40_dtl" ).button();
		
		var datesetopt = {
			showOn: "button",
			buttonImageOnly: true,
			buttonImage: "<?php echo base_url()."assets/images/icons/16x16/timespan.png"  ?>",
			buttonText: "Tanggalan",
			dateFormat: 'mm/dd/yy'
		};
		
		$("#txtbc40tglaju").datepicker(datesetopt);
		$("#txtbc40tglbc40").datepicker(datesetopt);
		
		$( "#btnupdatebc40noaju" ).button().click(function(){
			
			
			var form_data ={
				idhdrbc40:$("#idhdrbc40").val(),
				bc40noaju:$("#txtbc40noaju").val(),
				bc40tglaju:$("#txtbc40tglaju").val(),
				bc40nobc40:$("#txtbc40nobc40").val(),
				bc40tglbc40:$("#txtbc40tglbc40").val(),
				PasokNama:$("#txtbc40pasoknama").val()
			};		
			
			$("#updatenoaju_bc40_dlg").dialog( "destroy" );
			$(".updatenoaju_bc40_dlgcl").remove();
			$(".updatenoaju_bc40_dlgcl").html('');
			$("body").append('<div id="updatenoaju_bc40_dlg" title="Warning" class="updatenoaju_bc40_dlgcl"><p>Apakah anda akan data ini?!?</p><br /> No Doc dari BC = '+ $("#txtbc40nobc40").val() +'</div>');
			$("#updatenoaju_bc40_dlg").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc40/updatenoaju_bc40'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#updatenoaju_bc40_dlg").dialog("close");
								$('#updatenoaju_bc40_dlg').dialog("destroy"); 
								$(".updatenoaju_bc40_dlgcl").remove(); 
								jQuery("#tblbc40hdr_dtl").trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+' '+msg.desc); 
								jQuery("#tblbc40hdr_dtl").trigger('reloadGrid');
								$("#updatenoaju_bc40_dlg").dialog("close");
								$('#updatenoaju_bc40_dlg').dialog("destroy"); 
								$(".updatenoaju_bc40_dlgcl").remove(); 
								
							}
						}
					});
				},
					"CANCEL": function() {
						$( "#updatenoaju_bc40_dlg" ).dialog( "close" );

					}
				},
				close : function(){
					$('#updatenoaju_bc40_dlg').dialog("destroy"); 
					$(".updatenoaju_bc40_dlgcl").remove(); 
					$("body").append('<div id="updatenoaju_bc40_dlg" title="Warning" class="updatenoaju_bc40_dlgcl"><p>Apakah anda akan memproses file ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
		
		});
		
		$( "#btnviewitembc40_dtl" ).button().click(function(){
			$("#frmformdtlbc40_dlg").load('<?php echo base_url().'exim/ct_bc40_view_dtl/viewformbc40dtl'; ?>',  {parmeter:'parameter', id_inv_hdr:$("#inv_hdr_idbc40").val()}, function() {
				$("#frmformdtlbc40_dlg").dialog({
					modal:true,
					width : 1000,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmformdtlbc40_dlg').dialog("destroy"); 
					    $(".frmformdtlbc40_dlg_cl").remove(); 
					    $("body").append('<div id="frmformdtlbc40_dlg" title="FORM DETAIL" class="frmformdtlbc40_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		
		});
		
		function xxx1111(){
		
			$("#frmformhdrbc400_dlg").load('<?php echo base_url().'exim/ct_bc40/view_bc40_hdr_form_print'; ?>', {'xxxx':'xxxxx'} , function() {
				$("#frmformhdrbc400_dlg").dialog({
					modal:true,
					width : 980,
					height : 550,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						},
						/* "SAVE PDF":function() {  
							//$("#iddivformheaderbc40").printElement();
							 //window.open('<?php echo base_url().'exim/ct_bc40/view_bc40_hdr_print'; ?>'+'?test=testxx', 'window name', 'window settings');
							 //$("#framelappenerimaanbrgperdokumen").attr("src", "<?php echo base_url().'exim/ct_bc40/view_bc40_hdr_print'; ?>"+'?test=testxx');
							
						}  */
                    },
						
                    
					close : function(){
						$('#frmformhdrbc400_dlg').dialog("destroy"); 
					    $(".frmformhdrbc400_dlg_cl").remove(); 
					    $("body").append('<div id="frmformhdrbc400_dlg" title="FORM HEADER" class="frmformhdrbc400_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		};
		
		$( "#btnviewhdrbc40_dtl" ).button().click(function(){
			
			var id = jQuery("#tblbc40hdr_dtl").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc40hdr_dtl").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};
			
			var form_data={
				id_inv_hdr:ret.id_bc_in_hdr,
				BC23No:ret.BC23No
			
			};
			
			
			$("#frmformhdrbc40_dlg").load('<?php echo base_url().'exim/ct_bc40/view_bc40_hdr_form_old'; ?>', form_data , function() {
				$("#frmformhdrbc40_dlg").dialog({
					modal:true,
					width : 980,
					height : 550,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						},
						"SAVE PDF":function() {  
							//$("#iddivformheaderbc40").printElement();
							 window.open('<?php echo base_url().'exim/ct_bc40/view_bc40_hdr_print'; ?>'+'?test=testxx', 'window name', 'window settings');
							 //$("#framelappenerimaanbrgperdokumen").attr("src", "<?php echo base_url().'exim/ct_bc40/view_bc40_hdr_print'; ?>"+'?test=testxx');
							 //xxx1111();
						} 
                    },
						
                    
					close : function(){
						$('#frmformhdrbc40_dlg').dialog("destroy"); 
					    $(".frmformhdrbc40_dlg_cl").remove(); 
					    $("body").append('<div id="frmformhdrbc40_dlg" title="FORM HEADER" class="frmformhdrbc40_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});
		
		$( "#btnviewpartitembc40_dtl" ).button().click(function(){
						
			$("#frminvdtlbc40_dlg").load('<?php echo base_url().'exim/ct_bc23_view_dtl/loaddatapartnumberbc23'; ?>',{parmeter:'parameter', id_inv_hdr:$("#inv_hdr_idbc").val(), 'noinv':$("#bc23noinv").val(), idhdrbc23:$("#idhdrbc40").val()}, function() {
				$("#frminvdtlbc40_dlg").dialog({
					modal:true,
					width : 1000,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frminvdtlbc40_dlg').dialog("destroy"); 
					    $(".frminvdtlbc40_dlg_cl").remove(); 
					    $("body").append('<div id="frminvdtlbc40_dlg" title="INVOICE PART NUMBER" class="frminvdtlbc40_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});	
			
		});
		
		jQuery("#tblbc40detilitems").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc40/loaddata_bc40_dtl'; ?>',
			mtype : "post",
			postData:{'q':'1', idhdrbc40:$("#idhdrbc40").val()},
			datatype: "json",
			colNames:['ID', 'id_hdr', 'CAR','Serial', 'JnsBarangDtl', 'TujuanKirimDtl', 'NoHs', 'SeriTrp', 'BrgUrai'
					,'Merk','Tipe','SpfLain','KdBrg','Penggunaan','KemasJn','KemasJm','KdFasDtl','BrgAsal','DNilInv','KdSat','JmlSat','NettoDtl'
					,'SatBmJm','SatCukJm','DtlOk','create_date','create_by','update_date','update_by'
					],
			colModel:[
				{name:'id_bc_in_dtl',index:'id_bc_in_dtl', width:30, hidden:true},
				{name:'id_bc_in_hdr',index:'id_bc_in_hdr', width:30, hidden:true},
				{name:'CAR',index:'CAR', width:30, hidden:true},
				{name:'Serial',index:'Serial', width:30, hidden:false},
				{name:'JnsBarangDtl',index:'JnsBarangDtl', width:30, hidden:true},
				{name:'TujuanKirimDtl',index:'TujuanKirimDtl', width:30, hidden:true},
				{name:'NoHs',index:'NoHs', width:94, hidden:false},
				{name:'SeriTrp',index:'SeriTrp', width:30, hidden:true},
				{name:'BrgUrai',index:'BrgUrai', width:149, hidden:false},
				{name:'Merk',index:'Merk', width:30, hidden:true},
				{name:'Tipe',index:'Tipe', width:30, hidden:true},
				{name:'SpfLain',index:'SpfLain', width:30, hidden:true},
				{name:'KdBrg',index:'KdBrg', width:89, hidden:false},
				{name:'Penggunaan',index:'Penggunaan', width:30, hidden:true},
				{name:'KemasJn',index:'KemasJn', width:30, hidden:true},
				{name:'KemasJm',index:'KemasJm', width:30, hidden:true},
				{name:'KdFasDtl',index:'KdFasDtl', width:30, hidden:true},
				{name:'BrgAsal',index:'BrgAsal', width:30, hidden:true},
				{name:'DNilInv',index:'DNilInv', width:129, hidden:false, align:'right', formatter:'number'},
				{name:'KdSat',index:'KdSat', width:60, hidden:false},
				{name:'JmlSat',index:'JmlSat', width:91, hidden:false, align:'right', formatter:'number'},
				{name:'NettoDtl',index:'NettoDtl', width:30, hidden:true},
				{name:'SatBmJm',index:'SatBmJm', width:30, hidden:true},
				{name:'SatCukJm',index:'SatCukJm', width:30, hidden:true},
				{name:'DtlOk',index:'DtlOk', width:30, hidden:true},
				{name:'create_date',index:'create_date', width:30, hidden:true},
				{name:'create_by',index:'create_by', width:30, hidden:true},
				{name:'update_date',index:'update_date', width:30, hidden:true},
				{name:'update_by',index:'update_by', width:30, hidden:true},
				
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc40detilitems',
			sortname: 'id_bc_in_dtl',
			viewrecords: true,
			sortorder: "asc",
			width: 950,
			height:290,
			jsonReader: { repeatitems : false },
			caption:"Detil Barang",
			//rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			}	
		
		});
		
		jQuery("#tblbc40detilitems").jqGrid('navGrid','#ptblbc40detilitems',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		
		jQuery("#tblbc40hdr_dtl").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc40/loaddataheader'; ?>',
			mtype : "post",
			postData:{'q':'1',idhdrbc40:$("#idhdrbc40").val()},
			datatype: "json",
			colNames:['ID', 'No Inv','Tgl Inv','CAR' ,'KdKpbc' ,'Tujuan' ,'JnsBarang' ,'TujuanKirim' ,'PasokNama','PasokAlmt','PasokNeg' ,'UsahaId'
			,'UsahaNpwp' ,'KdTPB'  ,'Registrasi','UsahaNama','UsahaAlmt' ,'UsahaStatus' ,'ApiKd','ApiNo' ,'PpjkId','PpjkNpwp','PpjkNama' ,'PpjkAlmt'
			,'PpjkNo' ,'PpjkTg','IndId' ,'IndNpwp','IndNama','IndAlmt' ,'Moda' ,'AngkutNama' ,'AngkutNo','AngkutFl' ,'PelBkr','PelMuat' ,'PelTransit'
			,'bc40No' ,'bc40Tg','KdKpbcBongkar','KdKpbcAwas','DokTupKd' ,'DokTupNo','DokTupTg','PosNo' ,'PosSub' ,'TmpTbn' ,'KdVal','Ndpbm','NilInv'
			,'Freight' ,'BTambahan','Diskon','KdAss' ,'Asuransi' ,'KdHrg','Fob' ,'Cif','Bruto' ,'Netto','JmCont','JmBrg','TglTtd','KotaTtd','Namattd'
			,'ContakPerson' ,'NoPhone','NoFax','Email','Status' ,'Snrf' ,'Lengkap','PosSubSub','NoKontrak','TgKontrak' ,'HargaRp','TmpPeriksaFisik'
			,'AlmtPeriksaFisik','TgPeriksaFisik','WkPeriksaFisik','create_date','create_by','update_date' ,'update_by','typedok', 'status dok', 'inv_hdr_id'],
			colModel:[
				{name:'id_bc_in_hdr',index:'id_bc_in_hdr', width:60, hidden:true},
				{name:'noinv',index:'noinv', width:70, hidden:true},
				{name:'tglinv',index:'tglinv', width:95, hidden:true},
				{name:'CAR',index:'CAR', width:200},
				{name:'KdKpbc',index:'KdKpbc', width:67},
				{name:'Tujuan',index:'Tujuan', width:200, hidden:true},
				{name:'JnsBarang',index:'JnsBarang', width:200, hidden:true},
				{name:'TujuanKirim',index:'TujuanKirim', width:200, hidden:true}, 
				{name:'PasokNama',index:'PasokNama', width:124},
				{name:'PasokAlmt',index:'PasokAlmt', width:200, hidden:true},
				{name:'PasokNeg',index:'PasokNeg', width:200, hidden:true},
				{name:'UsahaId',index:'UsahaId', width:200, hidden:true},
				{name:'UsahaNpwp',index:'UsahaNpwp', width:200, hidden:true},
				{name:'KdTPB',index:'KdTPB', width:200, hidden:true},
				{name:'Registrasi',index:'Registrasi', width:200, hidden:true},
				{name:'UsahaNama',index:'UsahaNama', width:200, hidden:true},
				{name:'UsahaAlmt',index:'UsahaAlmt', width:200, hidden:true},
				{name:'UsahaStatus',index:'UsahaStatus', width:200, hidden:true},
				{name:'ApiKd',index:'ApiKd', width:200, hidden:true},
				{name:'ApiNo',index:'ApiNo', width:200, hidden:true},
				{name:'PpjkId',index:'PpjkId', width:200, hidden:true},
				{name:'PpjkNpwp',index:'PpjkNpwp', width:200, hidden:true},
				{name:'PpjkNama',index:'PpjkNama', width:200, hidden:true},
				{name:'PpjkAlmt',index:'PpjkAlmt', width:200, hidden:true},
				{name:'PpjkNo',index:'PpjkNo', width:200, hidden:true},
				{name:'PpjkTg',index:'PpjkTg', width:200, hidden:true},
				{name:'IndId',index:'IndId', width:200, hidden:true},
				{name:'IndNpwp',index:'IndNpwp', width:200, hidden:true},
				{name:'IndNama',index:'IndNama', width:200, hidden:true},
				{name:'IndAlmt',index:'IndAlmt', width:200, hidden:true},
				{name:'Moda',index:'Moda', width:200, hidden:true},
				{name:'AngkutNama',index:'AngkutNama', width:200, hidden:true},
				{name:'AngkutNo',index:'AngkutNo', width:200, hidden:true},
				{name:'AngkutFl',index:'AngkutFl', width:200, hidden:true},
				{name:'PelBkr',index:'PelBkr', width:200, hidden:true},
				{name:'PelMuat',index:'PelMuat', width:200, hidden:true},
				{name:'PelTransit',index:'PelTransit', width:200, hidden:true},
				{name:'BC23No',index:'BC23No', width:114},
				{name:'BC23Tg',index:'BC23Tg', width:95},
				{name:'KdKpbcBongkar',index:'KdKpbcBongkar', width:200, hidden:true},
				{name:'KdKpbcAwas',index:'KdKpbcAwas', width:200, hidden:true},
				{name:'DokTupKd',index:'DokTupKd', width:200, hidden:true},
				{name:'DokTupNo',index:'DokTupNo', width:200, hidden:true},
				{name:'DokTupTg',index:'DokTupTg', width:200, hidden:true},
				{name:'PosNo',index:'PosNo', width:200, hidden:true},
				{name:'PosSub',index:'PosSub', width:200, hidden:true},
				{name:'TmpTbn',index:'TmpTbn', width:200, hidden:true},
				{name:'KdVal',index:'KdVal', width:42, hidden:true},
				{name:'Ndpbm',index:'Ndpbm', width:93, align:'right'},
				{name:'NilInv',index:'NilInv', width:86, align:'right'},
				{name:'Freight',index:'Freight', width:200, hidden:true},
				{name:'BTambahan',index:'BTambahan', width:200, hidden:true},
				{name:'Diskon',index:'Diskon', width:200, hidden:true},
				{name:'KdAss',index:'KdAss', width:200, hidden:true},
				{name:'Asuransi',index:'Asuransi', width:200, hidden:true},
				{name:'KdHrg',index:'KdHrg', width:200, hidden:true},
				{name:'Fob',index:'Fob', width:200, hidden:true},
				{name:'Cif',index:'Cif', width:200, hidden:true},
				{name:'Bruto',index:'Bruto', width:200, hidden:true},
				{name:'Netto',index:'Netto', width:200, hidden:true},
				{name:'JmCont',index:'JmCont', width:200, hidden:true},
				{name:'JmBrg',index:'JmBrg', width:200, hidden:true},
				{name:'TglTtd',index:'TglTtd', width:200, hidden:true},
				{name:'KotaTtd',index:'KotaTtd', width:200, hidden:true},
				{name:'Namattd',index:'Namattd', width:200, hidden:true},
				{name:'ContakPerson',index:'ContakPerson', width:200, hidden:true},
				{name:'NoPhone',index:'NoPhone', width:200, hidden:true},
				{name:'NoFax',index:'NoFax', width:200, hidden:true},
				{name:'Email',index:'Email', width:200, hidden:true},
				{name:'Status',index:'Status', width:49, hidden:true},
				{name:'Snrf',index:'Snrf', width:200, hidden:true},
				{name:'Lengkap',index:'Lengkap', width:200, hidden:true},
				{name:'PosSubSub',index:'PosSubSub', width:200, hidden:true},
				{name:'NoKontrak',index:'NoKontrak', width:200, hidden:true},
				{name:'TgKontrak',index:'TgKontrak', width:200, hidden:true},
				{name:'HargaRp',index:'HargaRp', width:200, hidden:true},
				{name:'TmpPeriksaFisik',index:'TmpPeriksaFisik', width:200, hidden:true},
				{name:'AlmtPeriksaFisik',index:'AlmtPeriksaFisik', width:200, hidden:true},
				{name:'TgPeriksaFisik',index:'TgPeriksaFisik', width:200, hidden:true},
				{name:'WkPeriksaFisik',index:'WkPeriksaFisik', width:200, hidden:true},
				{name:'create_date',index:'create_date', width:200, hidden:true},
				{name:'create_by',index:'create_by', width:200, hidden:true},
				{name:'update_date',index:'update_date', width:200, hidden:true},
				{name:'update_by',index:'update_by', width:200, hidden:true},
				{name:'typedok',index:'typedok', width:200, hidden:true},
				{name:'statusdok',index:'statusdok', width:200, hidden:true},
				{name:'inv_hdr_id',index:'inv_hdr_id', width:200, hidden:true},
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc40hdr_dtl',
			sortname: 'id_bc_in_hdr',
			viewrecords: true,
			sortorder: "desc",
			width: 900,
			height:16,
			jsonReader: { repeatitems : false },
			caption:"List of bc40 Header",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			}
		}); 
		                
		jQuery("#tblbc40hdr_dtl").jqGrid('navGrid','#ptblbc40hdr_dtl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		
		jQuery("#tblbc40dok").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc40/loaddatadok'; ?>',
			mtype : "post",
			postData:{'q':'1', idhdrbc40:$("#idhdrbc40").val()},
			datatype: "json",
			colNames:['ID', 'id_hdr', 'CAR','Dok Kd', 'Uraian', 'Dok No', 'Dok Tg'
					],
			colModel:[
				{name:'id_bc_in_dok',index:'id_bc_in_dok', width:30, hidden:true},
				{name:'id_bc_in_hdr',index:'id_bc_in_hdr', width:30, hidden:true},
				{name:'CAR',index:'CAR', width:171, hidden:false},
				{name:'DokKd',index:'DokKd', width:77, hidden:false},
				{name:'uraian',index:'uraian', width:183, hidden:false},
				{name:'DokNo',index:'DokNo', width:160, hidden:false},
				{name:'DokTg',index:'DokTg', width:104, hidden:false}				
				
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc40dok',
			sortname: 'id_bc_in_dok',
			viewrecords: true,
			sortorder: "asc",
			width: 950,
			height:290,
			jsonReader: { repeatitems : false },
			caption:"Dokumen",
			//rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			}	
		
		});
		
		jQuery("#tblbc40dok").jqGrid('navGrid','#ptblbc40dok',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		
		jQuery("#tblbc40con").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc40/loaddatacon'; ?>',
			mtype : "post",
			postData:{'q':'1', idhdrbc40:$("#idhdrbc40").val()},
			datatype: "json",
			colNames:['ID', 'id_hdr', 'CAR','ContNo', 'ContUkur', 'ContTipe'
					],
			colModel:[
				{name:'id_bc_in_con',index:'id_bc_in_con', width:30, hidden:true},
				{name:'id_bc_in_hdr',index:'id_bc_in_hdr', width:30, hidden:true},
				{name:'CAR',index:'CAR', width:171, hidden:false},
				{name:'ContNo',index:'ContNo', width:77, hidden:false},
				{name:'ContUkur',index:'ContUkur', width:183, hidden:false},
				{name:'ContTipe',index:'ContTipe', width:160, hidden:false},
				
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc40con',
			sortname: 'id_bc_in_con',
			viewrecords: true,
			sortorder: "asc",
			width: 950,
			height:290,
			jsonReader: { repeatitems : false },
			caption:"Container",
			//rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			}	
		
		});
		
		jQuery("#tblbc40con").jqGrid('navGrid','#ptblbc40con',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		
		
		$("#btnviewhdrbc40_excel_dtl").button().click(function(){
			var id = jQuery("#tblbc40hdr_dtl").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc40hdr_dtl").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};
			
			//event.preventDefault();
			document.location.href = '<?php echo base_url().'exim/ct_bc40/savetoexcelbc40'; ?>'+'?id_bc_in_hdr='+ret.id_bc_in_hdr	
		
		});
		
		$("#btnupdatedokbc40_cancel").button().click(function(){
		
			var id = jQuery("#tblbc40hdr_dtl").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc40hdr_dtl").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				$("#tabdocbc40_dtl").tabs("select", 0);
				return false;
			};	
			
			if (ret.statusdok != 'DATA BARU'){
			
				alert("Data Sudah Diproses, Tidak Dapat Dilanjutkan");
				return false;
			}
			
			var form_data={
				idhdrbc40:ret.id_bc_in_hdr,
				typedok:'BC40',
				bc_in_from_in:'INVMS'
			
			};
			
			$("#dlg_cancelpo_bc40").dialog( "destroy" );
			$(".dlg_cancelpo_bc40cl").remove();
			$(".dlg_cancelpo_bc40cl").html('');
			$("body").append('<div id="dlg_cancelpo_bc40" title="Warning" class="dlg_cancelpo_bc40cl"><p>Apakah anda akan memproses peng-cancel-an data ini?!?</p><br /> Pasok Nama = '+ ret.PasokNama + ' dll (Lihat No Dokumennya)<br /><b>Pikirkanlah baik2</b></div>');
			$("#dlg_cancelpo_bc40").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
										
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc40/cancelnocar'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_cancelpo_bc40").dialog("close");
								$('#dlg_cancelpo_bc40').dialog("destroy"); 
								$(".dlg_cancelpo_bc40cl").remove(); 
								/* jQuery("#tblfgout_hdr").trigger('reloadGrid'); */
								jQuery("#tblbc40detilitems").trigger('reloadGrid');
								jQuery("#tblbc40hdr_dtl").trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+' '+msg.desc); 
								$("#dlg_cancelpo_bc40").dialog("close");
								$('#dlg_cancelpo_bc40').dialog("destroy"); 
								$(".dlg_cancelpo_bc40cl").remove(); 

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

					}
				},
				close : function(){
					$('#dlg_cancelpo_bc40').dialog("destroy"); 
					$(".dlg_cancelpo_bc40cl").remove(); 
					$("body").append('<div id="dlg_cancelpo_bc40" title="Warning" class="dlg_cancelpo_bc40cl"><p>Apakah anda akan peng-cancel-an data ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
			
			
		});
		
	});
</script>
<div id="frminvdtlbc40_dlg" title="INVOICE PART NUMBER" class="frminvdtlbc40_dlg_cl"></div>
<div id="frmformdtlbc40_dlg" title="FORM DETAIL" class="frmformdtlbc40_dlg_cl"></div>
<div id="frmformhdrbc40_dlg" title="FORM HEADER" class="frmformhdrbc40_dlg_cl"></div>
<div id="cekmoduldetil_dlg" title="DATA MODUL DETAIL" class="cekmoduldetil_dlg_cl"></div>
<div id="frmformhdrbc400_dlg" title="FORM HEADER" class="frmformhdrbc400_dlg_cl"></div>

