<div id="container_bc40_exim" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="bc40_exim_bar" >  
	<!--<button id="btngetdatahibbc40" style="color:#FF0000;">Get Data non HIB</button> -->
	<button id="btngetdata_hibbc40" style="color:#FF0000;">Get Data HIB</button>
	<button id="btngetdata_coo_bc40" style="color:#FF0000;">COO</button>
	<button id="btnbc40send2ceisa" >Ceisa</button>
	<button id="btnbc40viewdtl" >View/Update Data</button>
	<button id="btnbc40approvedata" >Approve/Move Data</button>
	<button id="btngetdatapobc40">Get Data PO</button>
	<button id="btnbc40search" >Search</button>
	<button id="btnbc40matchedceisa" >Matching Ceisa</button>
</div>
<table id="tblbc40hdr"></table> <div id="ptblbc40hdr"></div>
</div>
<script type="text/javascript">
    
    $(document).ready(function(){
		$(window).bind('resize', function() {  
			setTimeout(function(){
				setGridHight($("#tblbc40hdr"),$("#container_bc40_exim"),$("#bc40_exim_bar")); 
			},10); 
		});
		$("#btngetdatapobc40").button().click(function(){
			var form_data = {
				parmeter:'parameter'
			};
			
			$("#frmbc40_invoicepodlg").load('<?php echo base_url().'exim/ct_bc40/view_bc40_getdatapo'; ?>', form_data, function() {
				$("#frmbc40_invoicepodlg").dialog({
					modal:true,
					width : 900,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc40_invoicepodlg').dialog("destroy"); 
					    $(".frmbc40_invoicepodlg_cl").remove(); 
					    $("body").append('<div id="frmbc40_invoicepodlg" title="INVOICE DATA PO" class="frmbc40_invoicepodlg_cl"></div>'); 
						$('#tblbc40hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		
		
		});
		
		$("#btnbc40search").button().click(function(){
			$("#searchbc40_dlg").load('<?php echo base_url().'exim/ct_bc40/view_bc40_search'; ?>',  {parmeter:'parameter'}, function() {
				$("#searchbc40_dlg").dialog({
					modal:true,
					width : 600,
					height : 120,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#searchbc40_dlg').dialog("destroy"); 
					    $(".searchbc40_dlg_cl").remove(); 
					    $("body").append('<div id="searchbc40_dlg" title="PENCARIAN PERIODE TANGGAL DAFTAR" class="searchbc40_dlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});	
		
		});
		
		$("#btngetdatahibbc40").button().click(function(){
			$("#frmbc40invnonhibdlg").load('<?php echo base_url().'exim/ct_bc40/view_bc40_nonhib'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmbc40invnonhibdlg").dialog({
					modal:true,
					width : 1000,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc40invnonhibdlg').dialog("destroy"); 
					    $(".frmbc40invnonhibdlg_cl").remove(); 
					    $("body").append('<div id="frmbc40invnonhibdlg" title="INVOICE DATA NON HIB" class="frmbc40invnonhibdlg_cl"></div>'); 
						$('#tblbc40hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});
		
		$("#btngetdata_hibbc40").button().click(function(){
			$("#frmbc40invhibdlg").load('<?php echo base_url().'exim/ct_bc40/view_bc40_hib'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmbc40invhibdlg").dialog({
					modal:true,
					width : 1000,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc40invhibdlg').dialog("destroy"); 
					    $(".frmbc40invhibdlg_cl").remove(); 
					    $("body").append('<div id="frmbc40invhibdlg" title="INVOICE DATA HIB" class="frmbc40invhibdlg_cl"></div>'); 
						$('#tblbc40hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});
		
		$("#btnbc40approvedata").button().click(function(){
		
			var id = jQuery("#tblbc40hdr").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc40hdr").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};

			if (ret.statusdok == 'DATA BARU'){  
				alert("Update Dahulu No Pengajuan dan Nomor BC nya");
				return false; };

					
			$("#frmbc40movedlg").load('<?php echo base_url().'exim/ct_bc40/view_bc40_move'; ?>',  {parmeter:'parameter', idhdrbc23:ret.id_bc_in_hdr, inv_hdr_idbc23:ret.nobl, 'noinv':ret.nobl, nobc23:ret.BC23No}, function() {
			
				$("#frmbc40movedlg").dialog({
					modal:true,
					width : 980,
					height : 490,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc40movedlg').dialog("destroy"); 
					    $(".frmbc40movedlg_cl").remove(); 
					    $("body").append('<div id="frmbc40movedlg" title="MOVE DATA" class="frmbc40movedlg_cl"></div>'); 
						$('#tblbc40hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		
		
		});
		
		$("#btnbc40viewdtl").button().click(function(){
			var id = jQuery("#tblbc40hdr").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc40hdr").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			var form_data={
				parmeter:'parameter', 
				idhdrbc40:ret.id_bc_in_hdr, 
				inv_hdr_idbc40:ret.inv_hdr_id, 
				'noinv':ret.noinv, 
				car:ret.CAR,
				gabinv:ret.nobl,
				tglgabinv:ret.tglbl,
				DokTupTg:ret.DokTupTg,
				BC23No:ret.BC23No,
				BC23Tg:ret.BC23Tg,
				PasokNama:ret.PasokNama
				
				
				};
			$("#frmbc40viewdtldlg").load('<?php echo base_url().'exim/ct_bc40/view_bc40_dtl'; ?>', form_data , function() {
			
				$("#frmbc40viewdtldlg").dialog({
					modal:true,
					width : 1000,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc40viewdtldlg').dialog("destroy"); 
					    $(".frmbc40viewdtldlg_cl").remove(); 
					    $("body").append('<div id="frmbc40viewdtldlg" title="DETAIL DOCUMENTS" class="frmbc40viewdtldlg_cl"></div>'); 
						$('#tblbc40hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});		
		
		
		});
		
		jQuery("#tblbc40hdr").jqGrid({
			url:'<?php echo base_url().'exim/ct_bc40/loaddata'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:['ID','No Group Inv.','Tgl Group Inv.', '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 Modul' ,'Snrf' ,'Lengkap','PosSubSub','NoKontrak','TgKontrak' ,'HargaRp','TmpPeriksaFisik'
			,'AlmtPeriksaFisik','TgPeriksaFisik','WkPeriksaFisik','typedok', 'Status Data', 'inv_hdr_id','create_date','create_by','update_date' ,'update_by'],
			colModel:[
				{name:'id_bc_in_hdr',index:'id_bc_in_hdr', width:60, hidden:true},
				{name:'nobl',index:'nobl', width:120},
				{name:'tglbl',index:'tglbl', width:95,stype:"text",stype:"text",searchoptions:{sopt:['eq','cn','gt','lt'],dataInit:function(el){$(el).datepicker({changeYear: true,showButtonPanel: true,changeMonth: true,dateFormat:'dd/mm/yy'});} }},
				{name:'noinv',index:'noinv', width:70, hidden:true},
				{name:'tglinv',index:'tglinv', width:95,stype:"text",stype:"text",searchoptions:{sopt:['eq','cn','gt','lt'],dataInit:function(el){$(el).datepicker({changeYear: true,showButtonPanel: true,changeMonth: true,dateFormat:'dd/mm/yy'});} }, 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:224},
				{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', hidden:true},
				{name:'NilInv',index:'NilInv', width:106, align:'right', formatter:'number'},
				{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:82, hidden:false, align:'right'},
				{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:90, hidden:false},
				{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:'typedok',index:'typedok', width:200, hidden:true},
				{name:'statusdok',index:'statusdok', width:180, hidden:false},
				{name:'inv_hdr_id',index:'inv_hdr_id', width:200, hidden:true},
				{name:'create_date',index:'create_date', width:55, hidden:false},
				{name:'create_by',index:'create_by', width:55, hidden:false},
				{name:'update_date',index:'update_date', width:200, hidden:true},
				{name:'update_by',index:'update_by', width:200, hidden:true},
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc40hdr',
			sortname: 'id_bc_in_hdr',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:300,
			jsonReader: { repeatitems : false },
			caption:"List of bc40 Header",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#tblbc40hdr").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#tblbc40hdr").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#tblbc40hdr").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
			gridComplete: function(){
				var rowIDs = jQuery("#tblbc40hdr").getDataIDs(); 
				var rowData = $("#tblbc40hdr").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tblbc40hdr'));
				   
					switch (rowData[i].statusdok) {
						case 'DATA PROCESSED':
						   trElement.css({"color":"green"});
						break;
						
						case 'SENT TO INVENTORY CANCELED':
						   trElement.css({"color":"green"});
						break;
						
						case 'DATA SENT TO INVENTORY':
						   trElement.css({"color":"purple"});
						break;
						case 'DATA PROCESSED INVENTORY':
						   trElement.css({"color":"blue"});
						break;
						case 'APPROVED INVENTORY':
						   trElement.css({"color":"red"});
						break;
					}
				}
			},
		}); 
			
                        
		jQuery("#tblbc40hdr").jqGrid('navGrid','#ptblbc40hdr',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tblbc40hdr").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
			setTimeout(function(){
				setGridHight($("#tblbc40hdr"),$("#container_bc40_exim"),$("#bc40_exim_bar")); 
			},10); 
			
		$("#btngetdata_coo_bc40").button().click(function(){
			$("#frmbc40cooinvdlg").load('<?php echo base_url().'exim/ct_inv_draft/view_coo_inv_bc40'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmbc40cooinvdlg").dialog({
					modal:true,
					width : 1070,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc40cooinvdlg').dialog("destroy"); 
					    $(".frmbc40cooinvdlg_cl").remove(); 
					    $("body").append('<div id="frmbc40cooinvdlg" title="INVOICE COO DATA" class="frmbc40cooinvdlg_cl"></div>'); 
						$('#tblbc40hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
			
		});	

		$("#btnbc40send2ceisa").button().click(function(){
			var id = jQuery("#tblbc40hdr").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc40hdr").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};
				
			var form_data = {
				id_bc40_hdr_ceisa:ret.id_bc_in_hdr
			};
			
			$("#frmbc40_bc40_ceisadlg").load('<?php echo base_url().'exim/ct_bc40/view_coo_bc40_ceisa'; ?>', form_data, function() {
				$("#frmbc40_bc40_ceisadlg").dialog({
					modal:true,
					width : 550,
					height : 430,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc40_bc40_ceisadlg').dialog("destroy"); 
					    $(".frmbc40_bc40_ceisadlg_cl").remove(); 
					    $("body").append('<div id="frmbc40_bc40_ceisadlg" title="bc40 CEISA" class="frmbc40_bc40_ceisadlg_cl"></div>'); 
						$('#tblbc40hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});	
			
		});	
		
		$("#btnbc40matchedceisa").button().click(function(){
			$("#frmbc40matcheddata_ceisadlg").load('<?php echo base_url().'exim/ct_bc40/view_bc40_matching_ceisa'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmbc40matcheddata_ceisadlg").dialog({
					modal:true,
					width : 840,
					height : 520,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmbc40matcheddata_ceisadlg').dialog("destroy"); 
					    $(".frmbc40matcheddata_ceisadlg_cl").remove(); 
					    $("body").append('<div id="frmbc40matcheddata_ceisadlg" title="MATCHING DATA CEISA" class="frmbc40matcheddata_ceisadlg_cl"></div>'); 
						$('#tblbc40hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
			
		});

	});
		  	
</script>
<div id="frmbc40invnonhibdlg" title="INVOICE DATA NON HIB" class="frmbc40invnonhibdlg_cl"></div>
<div id="frmbc40viewdtldlg" title="DETAIL DOCUMENTS" class="frmbc40viewdtldlg_cl"></div> 
<div id="frmbc40movedlg" title="MOVE DATA" class="frmbc40movedlg_cl"></div>
<div id="frmbc40_invoicepodlg" title="INVOICE DATA PO" class="frmbc40_invoicepodlg_cl"></div>
<div id="frmbc40invhibdlg" title="INVOICE DATA HIB" class="frmbc40invhibdlg_cl"></div>
<div id="searchbc40_dlg" title="PENCARIAN PERIODE TANGGAL DAFTAR" class="searchbc40_dlg_cl"></div>
<div id="frmbc40cooinvdlg" title="INVOICE COO DATA" class="frmbc40cooinvdlg_cl"></div>
<div id="frmbc40_bc40_ceisadlg" title="bc40 CEISA" class="frmbc40_bc40_ceisadlg_cl"></div>
<div id="frmbc40matcheddata_ceisadlg" title="MATCHING DATA CEISA" class="frmbc40matcheddata_ceisadlg_cl"></div>




	
	