<div id="container_bc41_exim" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="bc41_exim_bar" >  
		 <button id="btnbc41pre" style="color:#FF0000;">Get Data</button>
		 <button id="btnbc41viewdtl" >View Data / Update NO. BC</button>
		 <!-- <button id="btnbc41approvedata" >Approve/Move Data</button> -->


	 </div>
<table id="tblbc41hdr"></table> <div id="ptblbc41hdr"></div>
 </div>
<script type="text/javascript">
  
    $(document).ready(function(){
		$(window).bind('resize', function() {  
			setTimeout(function(){
				setGridHight($("#tblbc41hdr"),$("#container_bc41_exim"),$("#bc41_exim_bar")); 
			},10); 
		});
			
		$("#btnbc41viewdtl").button().click(function(){
			var id = jQuery("#tblbc41hdr").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc41hdr").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			var form_data={
				parmeter:'parameter',
				CAR:ret.CAR,
				id_bc_out_hdr:ret.id_bc_out_hdr
				
			};
			$("#frmbc41viewdtldlg").load('<?php echo base_url().'exim/ct_bc41/view_bc41_dtl'; ?>', form_data , function() {
			
				$("#frmbc41viewdtldlg").dialog({
					modal:true,
					width : 890,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc41viewdtldlg').dialog("destroy"); 
					    $(".frmbc41viewdtldlg_cl").remove(); 
					    $("body").append('<div id="frmbc41viewdtldlg" title="DETAIL DOCUMENTS" class="frmbc41viewdtldlg_cl"></div>'); 
						$('#tblbc41hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});		
			
		});
		
		
	/* 	$("#btnbc41approvedata").button().click(function(){
			var id = jQuery("#tblbc41hdr").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc41hdr").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};

			if (ret.statusdok == 'DATA BARU'){  
				alert("Kirim Dahulu Data Ke Modul bc41 Untuk Mendapat CAR(Send to modul)");
				return false; };

					
			$("#frmbc41movedlg").load('<?php echo base_url().'exim/ct_bc41_view_dtl/view_bc41_move'; ?>',  {parmeter:'parameter', idhdrbc41:ret.id_bc_in_hdr, inv_hdr_idbc41:ret.nobl, 'noinv':ret.nobl, nobc41:ret.bc41No}, function() {
			
				$("#frmbc41movedlg").dialog({
					modal:true,
					width : 980,
					height : 490,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc41movedlg').dialog("destroy"); 
					    $(".frmbc41movedlg_cl").remove(); 
					    $("body").append('<div id="frmbc41movedlg" title="MOVE DATA" class="frmbc41movedlg_cl"></div>'); 
						$('#tblbc41hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		
		}); */
		
		$("#btnbc41pre").button().click(function(){
			$("#frmbc41invdlg").load('<?php echo base_url().'exim/ct_bc41/view_bc41_getdata'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmbc41invdlg").dialog({
					modal:true,
					width : 831,
					height : 461,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc41invdlg').dialog("destroy"); 
					    $(".frmbc41invdlg_cl").remove(); 
					    $("body").append('<div id="frmbc41invdlg" title="LOAD SA DATA" class="frmbc41invdlg_cl"></div>'); 
						$('#tblbc41hdr').trigger('reloadGrid');
	
					},
					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("#tblbc41hdr").jqGrid()[0].triggerToolbar();
						}, 50);
					} else {
						
						$(this).trigger('change');
					}
				}    
			});
		};
		
		jQuery("#tblbc41hdr").jqGrid({
		url:'<?php echo base_url().'exim/ct_bc41/loaddata'; ?>',
		mtype : "post",
		postData:{'q':'1'},
		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:195, 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:210, 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: 6 }},
			{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:180, 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: '#ptblbc41hdr',
		sortname: 'id_bc_out_hdr',
		viewrecords: true,
		sortorder: "desc",
		width: '',
		height:290,
		jsonReader: { repeatitems : false },
		caption:"List of bc41 Header",
		rownumbers: true,
		shrinkToFit: false,
		multiselect: false,
		afterInsertRow: function(rowid, aData){
			/*switch (aData.statusdok) {
				case 'DATA SENT':
					jQuery("#tblbc41hdr").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
				break;
				case '2':
					jQuery("#tblbc41hdr").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
				break;
				case '1':
					jQuery("#tblbc41hdr").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
				break;
				
			} */
		},
		gridComplete: function(){
			var rowIDs = jQuery("#tblbc41hdr").getDataIDs(); 
			var rowData = $("#tblbc41hdr").getRowData();
		
			for (var i = 0; i < rowData.length; i++) 
			{
			   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tblbc41hdr'));
			   
				switch (rowData[i].statusdok) {
					case 'DATA BARU':
					   trElement.css({"color":"blue"});
					break;
					case 'DATA PROCESSED':
					   trElement.css({"color":"green"});
					break;
					
				}
			}
		},
	}); 
			
                        
	jQuery("#tblbc41hdr").jqGrid('navGrid','#ptblbc41hdr',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
	jQuery("#tblbc41hdr").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});

			setTimeout(function(){
				setGridHight($("#tblbc41hdr"),$("#container_bc41_exim"),$("#bc41_exim_bar")); 
			},10); 

		
	});
	
		  	
</script>
<div id="frmbc41invdlg" title="LOAD DATA SA" class="frmbc41invdlg_cl"></div>
<div id="frmbc41viewdtldlg" title="DETAIL DOCUMENTS" class="frmbc41viewdtldlg_cl"></div>
<div id="frmgetdatahdrbc41_dlg" title="GET DATA FROM MODUL" class="frmgetdatahdrbc41_dlg_cl"></div>
<div id="frmbc41movedlg" title="MOVE DATA" class="frmbc41movedlg_cl"></div>
<div id="frmbc41invnonhibdlg" title="INVOICE DATA NON HIB" class="frmbc41invnonhibdlg_cl"></div>

		
	