<div style="height:15px;">
	<input type="hidden" id="idhdrbc27_data_out" value="<?php echo $idhdrbc27; ?>" />
</div>
<div id="add_progress" align="center" style="display:none"><?php echo $loading_indicator; ?></div>
<div id="idmainbc27" > 
<div id="tabbc27_dtl" style="height:420px">
	<ul>
		<li><a id="idtabbc27hdr_dtl" href="#divtabbc27hdr_dtl">Header Dokumen</a></li>
		<li><a id="idtabbc27sa_dtl" href="#divtabbc27assy_dtl">Assy</a></li>
		<li><a id="idtabdocbc27_dtl" href="#divtabbc27doc_dtl">Dokumen</a></li>
	</ul>
	
	<div id="divtabbc27hdr_dtl" >
		<table id="tblbc27viewdtl_hdr"></table>
		<br />
		<table>
			<tr>
				<td>NO. DOK</td><td>:</td><td><?php echo $CAR; ?><td>
			</tr>
			<tr>
				<td>Nomor Pengajuan</td><td>:</td><td><?php echo $CAR; ?><td>
			</tr>
			<tr>
				<td>NO bc27</td><td>:</td><td><input type="text" id="txtnobc27" value="" maxlength=10/>-> File name:<?php  echo $filename; ?><td>
			</tr>
			<tr>
				<td>TGL bc27</td><td>:</td><td><input type="text" id="txtnotglbc27" value="" readonly="readonly"/><td>
			</tr>
			<tr>
				<td></td><td></td><td><button id="updatenobc27">UPDATE DATA</button><button id="btnupdetpemasukanbc27manual" >Update Pengeluaran Barang</button></td>
			</tr>
			<tr>
				<td></td><td></td><td></td>
			</tr>
			<tr>
				<td></td><td></td><td></td>
			</tr>
			<tr>
				<td></td><td></td><td><button id="print_hdr_bc27">Print BC27</button><button id="print_hdr_bc27_dtl">Print BC27 Detil</button>
				</td>
			</tr>
		</table>
		<br />
		<br />
		<table>
			<tr>
				<td>Tgl Pengeluaran</td><td>:</td><td><input type="text" id="txttglpemasukanbc27hdr" style="width:100px" value="<?php echo $doc_out_date; ?>"/>dd/mm/yyyy</td><td></td>
			</tr>
			<tr>
				<td>Tgl Pengeluaran Approved</td><td>:</td><td><input type="text" id="txttglpemasukanapprovedbc27hdr" style="width:100px"  value="<?php echo $approve_date; ?>"/>dd/mm/yyyy</td>
				<td></td>
			</tr>
			<tr>
				<td></td><td></td><td><button id="btnapprovedpemasukanbc27manual" style="color:red">Approved Pengeluaran Barang</button></td><td></td>
			</tr>
		</table>
		
		
	</div>
	<div id="divtabbc27assy_dtl" >
		<table id="tblbc27detilitems"></table> <div id="ptblbc27detilitems"></div>
	</div>

	<div id="divtabbc27doc_dtl" >
		<table id="tblbc27dok"></table> <div id="ptblbc27dok"></div>
	</div>
	
</div>

<input type="hidden" id="hdnid_bc_out_hdr" value="<?php echo  $id_bc_out_hdr; ?>" />
<input type="hidden" id="idhdrbc27" value="<?php echo  $id_bc_out_hdr; ?>" />
<script type="text/javascript">
    
    $(document).ready(function(){
		$( "#tabbc27_dtl" ).tabs();
		var form_data = {
			id_bc_out_hdr:$("#hdnid_bc_out_hdr").val(),
			'q':'66',
			idhdrbc27:$("#idhdrbc27").val(),
		}
		
		var datesetopt = {
			showOn: "button",
			buttonImageOnly: true,
			buttonImage: "<?php echo base_url()."assets/images/icons/16x16/timespan.png"  ?>",
			buttonText: "Tanggalan",
			dateFormat: 'mm/dd/yy'
		};
		
		$("#txtnotglbc27").datepicker(datesetopt);
		$("#txttglpemasukanbc27hdr").datepicker(datesetopt);
		$("#txttglpemasukanapprovedbc27hdr").datepicker(datesetopt);
		
		$("#idbc27hdrdlg").hide();
		$("#idprintbc27_Dtldlg").hide();
		
		$("#view_mainbc27_1").button().click(function(){
			$("#idbc27hdrdlg").hide();
			$("#idmainbc27").fadeIn();
			
		
		});
		$("#view_mainbc27_2").button().click(function(){
			$("#idprintbc27_Dtldlg").hide();
			$("#idmainbc27").fadeIn();
			
		
		});
		
		$("#print_hdr_bc27").button().click(function(){
			$("#add_progress").show();
			$("#idbc27hdrdlg").fadeIn();
			$("#idmainbc27").fadeOut();
			var sdata = "?id_bc_out_hdr=" + $("#hdnid_bc_out_hdr").val() + "&test=" + "test";
			$("#framebc27hdr").attr("src", "<?php echo base_url().'exim/ct_bc27/print_bc27_hdr'; ?>"+sdata).load(function(){
			
				$("#add_progress").hide();
			
			});
		});
				
		$("#print_hdr_bc27_dtl").button().click(function(){
			$("#add_progress").show();
			$("#idprintbc27_Dtldlg").fadeIn();
			$("#idmainbc27").fadeOut();
			
			var sdata = "?id_bc_out_hdr=" + $("#hdnid_bc_out_hdr").val() + "&test=" + "test";
			$("#framebc27dtl").attr("src", "<?php echo base_url().'exim/ct_bc27/print_bc27_dtl'; ?>"+sdata).load(function(){
			
				$("#add_progress").hide();
			
			});
			
		
		
		});
		
		
		$("#updatenobc27").button().click(function(){
			
			var form_update_bc27={
				id_bc_out_hdr:$("#hdnid_bc_out_hdr").val(),
				nobc27:$("#txtnobc27").val(),
				tglbc27:$("#txtnotglbc27").val(),
			};	
			
			if ($("#hdnid_bc_out_hdr").val() == ''){
			
				alert('PILIH SALAH SATU');
				return
			}
			
			if ($("#txtnobc27").val() == ''){
			
				alert('PILIH ISIKAN DENGAN BENAR');
				return
			}
			if ($("#txtnotglbc27").val() == ''){
			
				alert('PILIH ISIKAN DENGAN BENAR');
				return
			}
			
	
			
			$("#dlgbc27dtl_hdr_update").dialog( "destroy" );
			$(".dlgbc27dtl_hdr_updatecl").remove();
			$(".dlgbc27dtl_hdr_updatecl").html('');
			$("body").append('<div id="dlgbc27dtl_hdr_update" title="Warning" class="dlgbc27dtl_hdr_updatecl"><p>Apakah anda akan melakukan Update bc27 ini?!?</p><br /> No BC27 = '+ $("#txtnobc27").val() +'</div>');
			$("#dlgbc27dtl_hdr_update").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc27/update_bc27_sa_hdr'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_update_bc27,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlgbc27dtl_hdr_update").dialog("close");
								$('#dlgbc27dtl_hdr_update').dialog("destroy"); 
								$(".dlgbc27dtl_hdr_updatecl").remove(); 
								$('#tblbc27dok').trigger('reloadGrid');
								$('#tblbc27hdr').trigger('reloadGrid');
								$('#tblbc27viewdtl_hdr').trigger('reloadGrid');
								
								
																
							} else { 
								alert(msg.sts+' '+msg.desc); 
								$("#dlgbc27dtl_hdr_update").dialog("close");
								$('#dlgbc27dtl_hdr_update').dialog("destroy"); 
								$(".dlgbc27dtl_hdr_updatecl").remove(); 

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

					}
				},
				close : function(){
					$('#dlgbc27dtl_hdr_update').dialog("destroy"); 
					$(".dlgbc27dtl_hdr_updatecl").remove(); 
					$("body").append('<div id="dlgbc27dtl_hdr_update" title="Warning" class="dlgbc27dtl_hdr_updatecl"><p>Apakah anda akan memproses file ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
			
			
		
		
		});
		
		jQuery("#tblbc27viewdtl_hdr").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc27/loaddata'; ?>',
			mtype : "post",
			postData:form_data,
			datatype: "json",
			colNames:[
				'id_bc_out_hdr'
			  ,'filename'
			  ,'gabinvoice'
			  ,'laodeddate'
			  ,'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'
			  ,'jnkemas'
			  
			  
			],
			colModel:[
				{name:'id_bc_out_hdr',index:'id_bc_out_hdr', width:120, hidden:true},
				{name:'filename',index:'filename', width:220, hidden:true},
				{name:'gabinvoice',index:'gabinvoice', width:200, hidden:true},
				{name:'laodeddate',index:'laodeddate', width:70, hidden:true},
				{name:'CAR',index:'CAR', width:120, 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:false},
				{name:'TGINV',index:'TGINV', width:60, hidden:false},
				{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},
				{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},
				{name:'BRUTO',index:'BRUTO', width:120, hidden:true},
				{name:'NETTO',index:'NETTO', width:120, hidden:true},
				{name:'JMBRG',index:'JMBRG', width:120, hidden:true},
				{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:true},
				{name:'TGDAFT',index:'TGDAFT', width:120, hidden:true},
				{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:true},
				{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:'jnkemas',index:'jnkemas', width:120, hidden:true},
				
				
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptbl_getbc27',
			sortname: 'id_bc_out_hdr',
			viewrecords: true,
			sortorder: "desc",
			width: 800,
			height:40,
			jsonReader: { repeatitems : false },
			caption:"List of BC27 Header",
			rownumbers: false,
			shrinkToFit: false,
			multiselect: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#tbl_getbc27").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#tbl_getbc27").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#tbl_getbc27").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
				gridComplete: function(){
					var rowIDs = jQuery("#tbl_getbc27").getDataIDs(); 
					var rowData = $("#tbl_getbc27").getRowData();
				
					for (var i = 0; i < rowData.length; i++) 
					{
					   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_getbc27'));
					   
						switch (rowData[i].STATUS) {
							case '00':
							   trElement.css({"color":"blue"});
							break;
							case '01':
							   trElement.css({"color":"red"});
							break;
							
						}
					}
				},
			onSelectRow: function(id){
				var grididpr = jQuery("#tblbc27viewdtl_hdr").jqGrid('getGridParam','selrow');
				 if(grididpr){
					 var stret = jQuery("#tblbc27viewdtl_hdr").jqGrid('getRowData',grididpr);
					

					if ($.trim(stret.NODAFT) != ''){
						$("#txtnobc27").attr('readonly', true);
					 
					 } else { $("#txtnobc27").attr('readonly', false); } 
						$("#txtnobc27").val(stret.NODAFT);
					    $("#txtnotglbc27").val(stret.TGDAFT);
				  
				 }
			}
		}); 
			
                        
		// jQuery("#tblbc27viewdtl_hdr").jqGrid('navGrid','#ptblbc27viewdtl_hdr',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		// jQuery("#tblbc27viewdtl_hdr").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
		jQuery("#tblbc27detilitems").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc27/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: '#ptblbc27detilitems',
		sortname: 'id_bc_out_dtl',
		viewrecords: true,
		sortorder: "asc",
		width: 800,
		height:240,
		jsonReader: { repeatitems : false },
		caption:"List of bc27 Detil",
		rownumbers: true,
		shrinkToFit: false,
			afterInsertRow: function(rowid, aData){
			/*switch (aData.statusdok) {
				case 'DATA SENT':
					jQuery("#tblbc27detilitems").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
				break;
				case '2':
					jQuery("#tblbc27detilitems").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
				break;
				case '1':
					jQuery("#tblbc27detilitems").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
				break;
				
			} */
			},
			gridComplete: function(){
			 /*
				var rowIDs = jQuery("#tblbc27detilitems").getDataIDs(); 
				var rowData = $("#tblbc27detilitems").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tblbc27detilitems'));
				   
					switch (rowData[i].STATUS) {
						case '00':
						   trElement.css({"color":"blue"});
						break;
						
					}
				}
				 */
			},
		}); 
		jQuery("#tblbc27detilitems").jqGrid('navGrid','#ptblbc27detilitems',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tblbc27detilitems").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		
		jQuery("#tblbc27dok").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc27/loaddatadok'; ?>',
			mtype : "post",
			postData:{'q':'1', idhdrbc27:$("#idhdrbc27").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:true},
				{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: '#ptblbc27dok',
			sortname: 'id_bc_out_dok',
			viewrecords: true,
			sortorder: "asc",
			width: 800,
			height:240,
			jsonReader: { repeatitems : false },
			caption:"Dokumen",
			//rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			}	
		
		});
		
		jQuery("#tblbc27dok").jqGrid('navGrid','#ptblbc27dok',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		
		$("#btnupdetpemasukanbc27manual").button().click(function(){
			if( $.trim($("#txtnobc27").val()) =='' || $.trim($("#txtnotglbc27").val()) == '' 
				){
				alert('Data Belum Lengkap');
				return false;
			
			}
			
			var id = jQuery("#tblbc27viewdtl_hdr").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc27viewdtl_hdr").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			
			if (ret.NODAFT == ''){
				alert('nodaft belum ada');
			    return false;
			}
			
			var form_data = {
				
				id_bc_out:ret.id_bc_out_hdr,typedok:'BC27',statusdok:ret.statusdok
				
			};
			
			
					
			$("#update_pemasukan_bc27").dialog( "destroy" );
			$(".update_pemasukan_bc27cl").remove();
			$(".update_pemasukan_bc27cl").html('');
			$("body").append('<div id="update_pemasukan_bc27" title="Warning" class="update_pemasukan_bc27cl"><p>Apakah anda akan Memproses Data ini Menjadi Data Pengeluaran bc27?</p><br />Harap Periksa Baik2 karena perubahan hanya satu kali dan data menjadi APPROVED di inventory!!!!!</div>');
			$("#update_pemasukan_bc27").dialog({
				height: 200,
				width: 350,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url :"<?php echo base_url().'exim/ct_bc27/prosesdatatofg'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#update_pemasukan_bc27").dialog("close");
								$('#update_pemasukan_bc27').dialog("destroy"); 
								$(".update_pemasukan_bc27cl").remove(); 
								$(".update_pemasukan_bc27cl").html('');

								$('#tblbc27hdr').trigger('reloadGrid');
								$('#tblbc27hdr_dtl').trigger('reloadGrid');
								$("#idhdrbc27_data_out").val(msg.id_data_out_hdr);
							} else { 
								alert(msg.sts+msg.desc);
								$("#update_pemasukan_bc27").dialog("close");
								$('#update_pemasukan_bc27').dialog("destroy"); 
								$(".update_pemasukan_bc27cl").remove(); 		

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

					}
				},
				close : function(){
					$('#update_pemasukan_bc27').dialog("destroy"); 
					$(".update_pemasukan_bc27cl").remove(); 
					$("body").append('<div id="update_pemasukan_bc27" title="Warning" class="update_pemasukan_bc27cl"><p>Apakah anda akan Memproses Data ini Menjadi Data Pengeluaran bc27?</p><br />Harap Periksa Baik2 karena perubahan hanya satu kali dan data menjadi APPROVED di inventory!!!!!</div></div>');     
					$(".update_pemasukan_bc27cl").html('');
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
			
		
		});
		
		$("#btnapprovedpemasukanbc27manual").button().click(function(){ 
			if(($.trim($("#txtnobc27").val()) =='' && $.trim($("#txtnobc27").val()) =='-') || $.trim($("#txtnotglbc27").val()) == '' 
				|| $.trim($("#txttglpemasukanbc27hdr").val()) == '' || $.trim($("#txttglpemasukanapprovedbc27hdr").val()) == ''  ){
				alert('Data Belum Lengkap');
				return false;
			
			}
			
			var id = jQuery("#tblbc27viewdtl_hdr").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc27viewdtl_hdr").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data ={
				id_bc_out:$("#idhdrbc27_data_out").val(),
				typedok:'BC27',
				tglfg_out:$("#txttglpemasukanbc27hdr").val(),
				tglfg_out_apporved:$("#txttglpemasukanapprovedbc27hdr").val(),
			};		
			
			if ($("#idhdrbc27_data_out").val()==''){
						
				alert("Data Belum Di Proses Pengeluaran");
				return false;
			}
			
						
			$("#dlg_prosesdatatofg_bc27_approved").dialog( "destroy" );
			$(".dlg_prosesdatatofg_bc27_approvedcl").remove();
			$(".dlg_prosesdatatofg_bc27_approvedcl").html('');
			$("body").append('<div id="dlg_prosesdatatofg_bc27_approved" title="Warning" class="dlg_prosesdatatofg_bc27_approvedcl"><p>Apakah anda akan memproses APPROVED data ini?!?</p><br /> Type Doc BC = '+ form_data.typedok +'</div>');
			$("#dlg_prosesdatatofg_bc27_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_bc27_approved").dialog("close");
								$('#dlg_prosesdatatofg_bc27_approved').dialog("destroy"); 
								$(".dlg_prosesdatatofg_bc27_approvedcl").remove(); 
								/* jQuery("#tblfgout_hdr").trigger('reloadGrid'); */
							} else { 
								alert(msg.sts+' '+msg.desc); 
								$("#dlg_prosesdatatofg_bc27_approved").dialog("close");
								$('#dlg_prosesdatatofg_bc27_approved').dialog("destroy"); 
								$(".dlg_prosesdatatofg_bc27_approvedcl").remove(); 

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

					}
				},
				close : function(){
					$('#dlg_prosesdatatofg_bc27_approved').dialog("destroy"); 
					$(".dlg_prosesdatatofg_bc27_approvedcl").remove(); 
					$("body").append('<div id="dlg_prosesdatatofg_bc27_approved" title="Warning" class="dlg_prosesdatatofg_bc27_approvedcl"><p>Apakah anda akan memproses file ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
		
		});
	
		
	});
		  	
</script>
</div>
<div id="idbc27hdrdlg">
	<button id="view_mainbc27_1">Back</button>
	<hr >
	<iframe id="framebc27hdr" src="" frameborder="0" width="100%" height="370">
	</iframe>
	
</div>
<div id="idprintbc27_Dtldlg">
	<button id="view_mainbc27_2">Back</button>
	<hr >
	<iframe id="framebc27dtl" src="" frameborder="0" width="100%" height="370">
	</iframe>
	
</div>



<!--<div id="instruksi_pemeriksaandlg" title="Print Instruksi Pemeriksaan" class="instruksi_pemeriksaandlg_cl"></div> -->



	
	