<div style="height:40px;">
	<button id="btninv_coo_bc23viewdata">View Data</button>
	<button id="btninv_coo_bc23addbl">Add BL (Group Inv)</button>
	<button id="btninv_coo_bc23prosesbc">PROSES BC23</button>
</div>
<table id="tbl_data_coo_inv_bc23"></table> <div id="ptbl_data_coo_inv_bc23"></div>  
<div id="div_cek_invcoo_detil_null" style="color:red"><?php echo $test_null_inv; ?></div>
<script type="text/javascript">
    
    $(document).ready(function(){
		jQuery("#tbl_data_coo_inv_bc23").jqGrid({
			url:'<?php echo base_url().'exim/ct_upload_coo/tbl_coo_data'; ?>',
			mtype : "post",
			postData:{'SUPNEG':'LN'},
			datatype: "json",
			colNames:['ID','Vendor','No Invoice', 'Tgl Invoice','Item Count','SUPNEG','status','No BL/Srt Jln','Tgl BL/Srt Jln', 'tipe','No Aju','No BC','Tgl BC', 'create date', 'create by'],
			colModel:[
				{name:'id_coo_data',index:'id_coo_data', width:60, hidden:true},
				{name:'vendor',index:'vendor', width:120},
				{name:'no_invoice',index:'no_invoice', width:160},
				{name:'tgl_invoice',index:'tgl_invoice', width:166},
				{name:'item_count',index:'item_count', width:99},
				{name:'supplier_country',index:'supplier_country', width:50},
				{name:'status_inv',index:'status_inv', width:106},
				{name:'nobl',index:'nobl', width:106},
				{name:'tgbl',index:'tgbl', width:106},
				{name:'type_bc',index:'type_bc', width:106},
				{name:'car',index:'car', width:106},
				{name:'nobc',index:'nobc', width:106},
				{name:'tglbc',index:'tglbc', width:106},
				{name:'upload_date',index:'upload_date', width:166, hidden:false},
				{name:'upload_by',index:'upload_by', width:106, hidden:false},
			
				],
			rowNum:20,
			rowList:[20,50100],
			pager: '#ptbl_data_coo_inv_bc23',
			sortname: 'tgl_invoice',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:280,
			jsonReader: { repeatitems : false },
			caption:"DATA COO",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_data_coo_inv_bc23").getDataIDs(); 
				var rowData = $("#tbl_data_coo_inv_bc23").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_data_coo_inv_bc23'));
					
					if($.trim(rowData[i].nobl) != ''){  trElement.css({"color":"blue"}); }
					
				}
			},
		}); 
		
		jQuery("#tbl_data_coo_inv_bc23").jqGrid('navGrid','#ptbl_data_coo_inv_bc23',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_data_coo_inv_bc23").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
		$("#btninv_coo_bc23viewdata").button().click(function(){
			var id = jQuery("#tbl_data_coo_inv_bc23").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_data_coo_inv_bc23").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data={
				id_coo_data: function(){ return ret.id_coo_data; }
			};
			$("#frmview_coo_inv_bc23_dtl_dlg").load('<?php echo base_url().'exim/ct_inv_draft/view_coo_inv_bc23_dtl'; ?>',  form_data, function() {
				$("#frmview_coo_inv_bc23_dtl_dlg").dialog({
					modal:true,
					width : 1070,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmview_coo_inv_bc23_dtl_dlg').dialog("destroy"); 
					    $(".frmview_coo_inv_bc23_dtl_dlg_cl").remove(); 
					    $("body").append('<div id="frmview_coo_inv_bc23_dtl_dlg" title="INVOICE COO DATA DTL" class="frmview_coo_inv_bc23_dtl_dlg_cl"></div>'); 
						//$('#tblbc23hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
			
		});
		
		$("#btninv_coo_bc23addbl").button().click(function(){
			$("#frmview_coo_groupbl_bc23_dtl_dlg").load('<?php echo base_url().'exim/ct_inv_draft/view_coo_groupbl_bc23'; ?>',  {parameter:'parameter'}, function() {
				$("#frmview_coo_groupbl_bc23_dtl_dlg").dialog({
					modal:true,
					width : 1070,
					height : 530,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmview_coo_groupbl_bc23_dtl_dlg').dialog("destroy"); 
					    $(".frmview_coo_groupbl_bc23_dtl_dlg_cl").remove(); 
					    $("body").append('<div id="frmview_coo_groupbl_bc23_dtl_dlg" title="INVOICE COO GROUP" class="frmview_coo_groupbl_bc23_dtl_dlg_cl"></div>'); 
						//$('#tblbc23hdr').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
			
			
		});
		
		$("#btninv_coo_bc23prosesbc").button().click(function(){
			var id = jQuery("#tbl_data_coo_inv_bc23").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_data_coo_inv_bc23").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};
			if (ret.nobl == ''){
				alert("Silahkan bikin BL terlebih dahulu");
				return false;
			}	
			var form_data = {nobl:ret.nobl, tgbl:ret.tgbl};
			
			$("#bc23_insertproses_coo_dlg").load('<?php echo base_url().'exim/ct_inv_draft/view_coo_bc23_prosesinsertinv'; ?>', form_data , function() {
				$("#bc23_insertproses_coo_dlg").dialog({
					modal:true,
					width : 500,
					height : 500,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#bc23_insertproses_coo_dlg').dialog("destroy"); 
					    $(".bc23_insertproses_coo_dlg_cl").remove(); 
					    $("body").append('<div id="bc23_insertproses_coo_dlg" title="PROSES DATA" class="bc23_insertproses_coo_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});

	});
		  	
</script>
<div id="frmview_coo_inv_bc23_dtl_dlg" title="INVOICE COO DATA DTL" class="frmview_coo_inv_bc23_dtl_dlg_cl"></div>
<div id="frmview_coo_groupbl_bc23_dtl_dlg" title="INVOICE COO GROUP" class="frmview_coo_groupbl_bc23_dtl_dlg_cl"></div>
<div id="bc23_insertproses_coo_dlg" title="PROSES DATA" class="bc23_insertproses_coo_dlg_cl"></div>
	
	