<div style="height:30px;">
	<button id="btnbc23nonhibexecdata">Get Loader Data</button>
	<button id="btnbc23nonhibviewdata">View Data</button>
	<button id="btnbc23nonhibsummarydata">View Summary</button>
	<button id="btnbc23nonhibaddbldata">Add AWB/BL</button>
	<button id="btnbc23nonhibprosesdata">Prosses Data</button>
</div>
<table id="tblbc23hdrnonhib_draft"></table> <div id="ptblbc23hdrnonhib_draft"></div>
<div id="div_idbc23_nonhib" style="color:red"><b><?php echo $test ?></b></div>
<script type="text/javascript">
    
    $(document).ready(function(){
		$("#btnbc23nonhibexecdata").button().click(function(){
			
			$.ajax({
				url : "<?php echo base_url().'exim/ct_inv_draft/execdatanonhibbc23'; ?>",
				type : 'POST',
				dataType: 'json',
				data : {test:'aaa'},
				success: function(msg){
					if (msg.sts == '00'){
						
						alert(msg.desc);
						$('#tblbc23hdrnonhib_draft').trigger('reloadGrid');
						
					} else { alert(msg.sts+msg.desc);  }
				}
			});
		
		
		});
		
		$("#btnbc23nonhibaddbldata").button().click(function(){
			
						
			$("#bc23_nonhibaddbldata_dlg").load('<?php echo base_url().'exim/ct_inv_draft/view_bc23_nonhibaddbldata'; ?>',  {parmeter:'parameter'}, function() {
				$("#bc23_nonhibaddbldata_dlg").dialog({
					modal:true,
					width : 900,
					height : 550,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#bc23_nonhibaddbldata_dlg').dialog("destroy"); 
					    $(".bc23_nonhibaddbldata_dlg_cl").remove(); 
					    $("body").append('<div id="bc23_nonhibaddbldata_dlg" title="ADD DATA BL/AWB" class="bc23_nonhibaddbldata_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
			
		
		});
		
		$("#btnbc23nonhibviewdata").button().click(function(){
			var id = jQuery("#tblbc23hdrnonhib_draft").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc23hdrnonhib_draft").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			$("#frminvdtlnonhib_dlg").load('<?php echo base_url().'exim/ct_inv_draft/view_bc23_nonhibdtl'; ?>',  {parmeter:'parameter', id_datanonhibbc23:ret.id_nonhib_hdr}, function() {
				$("#frminvdtlnonhib_dlg").dialog({
					modal:true,
					width : 797,
					height : 506,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frminvdtlnonhib_dlg').dialog("destroy"); 
					    $(".frminvdtlnonhib_dlg_cl").remove(); 
					    $("body").append('<div id="frminvdtlnonhib_dlg" title="INVOICE NON HIB DATA DETAIL" class="frminvdtlnonhib_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});	
		
		
		});
		
		$("#btnbc23nonhibsummarydata").button().click(function(){
		
			var id = jQuery("#tblbc23hdrnonhib_draft").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc23hdrnonhib_draft").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data={parmeter:'parameter', id_datanonhibbc23:ret.id_nonhib_hdr};
			
			$("#frminvdtlnonhibsummary_dlg").load('<?php echo base_url().'exim/ct_inv_draft/view_bc23_nonhib_summary'; ?>',  form_data, function() {
				$("#frminvdtlnonhibsummary_dlg").dialog({
					modal:true,
					width : 797,
					height : 506,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frminvdtlnonhibsummary_dlg').dialog("destroy"); 
					    $(".frminvdtlnonhibsummary_dlg_cl").remove(); 
					    $("body").append('<div id="frminvdtlnonhibsummary_dlg" title="INVOICE NON HIB DATA SUMMARY" class="frminvdtlnonhibsummary_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});	
		});
		
		$("#btnbc23nonhibprosesdata").button().click(function(){
			var id = jQuery("#tblbc23hdrnonhib_draft").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tblbc23hdrnonhib_draft").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			/* var form_data={
				id:ret.id_nonhib_hdr, 
				noinv:ret.noinv,
				tglinv:ret.tglinv,
				
				}; */
			
			var form_data = {nobl:ret.nobl, tgbl:ret.tgbl};
			
			$("#bc23_insertproses_noonhib_dlg").load('<?php echo base_url().'exim/ct_inv_draft/view_bc23_nonhibprosesinsertinv'; ?>', form_data , function() {
				$("#bc23_insertproses_noonhib_dlg").dialog({
					modal:true,
					width : 500,
					height : 500,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#bc23_insertproses_noonhib_dlg').dialog("destroy"); 
					    $(".bc23_insertproses_noonhib_dlg_cl").remove(); 
					    $("body").append('<div id="bc23_insertproses_noonhib_dlg" title="PROSES DATA" class="bc23_insertproses_noonhib_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
			
		
		});
		
		function myformatter ( cellvalue, options, rowObject )
		{
			if (cellvalue == "new")
				 return '<font color="red">' + cellvalue + '</font>';//or use classes
			else
				 return '<font color="blue">' + cellvalue + '</font>';//or use classes
		}
		
		jQuery("#tblbc23hdrnonhib_draft").jqGrid({
			url:'<?php echo base_url().'exim/ct_inv_draft/loaddata_bc23_nonhib'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:['ID', 'No. Invoice', 'Date. Inv','No BL/AWB','TGL BL/AWB','itemcount','Vendor','From File', 'Total Item', 'Date Exec', 'status'],
			colModel:[
				{name:'id_nonhib_hdr',index:'id_nonhib_hdr', width:60, hidden:true},
				{name:'noinv',index:'noinv', width:89, hidden:false},
				{name:'tglinv',index:'tglinv', width:89, hidden:false,searchoptions:{sopt:['eq','cn','gt','lt'],dataInit:function(el){$(el).datepicker({changeYear: true,showButtonPanel: true,changeMonth: true, dateFormat:'yy-mm-dd'});} }},
				{name:'nobl',index:'nobl', width:85, hidden:false},
				{name:'tgbl',index:'tgbl', width:75, hidden:false},
				{name:'itemcount',index:'itemcount', width:60, align:'right', hidden:false},
				{name:'vendor',index:'vendor', width:90, align:'center', hidden:false},
				{name:'from_file_name',index:'from_file_name', width:388, hidden:true},
				{name:'totalitemfile',index:'totalitemfile', width:86, align:'right', hidden:false},
				{name:'exec_date',index:'exec_date', width:106, hidden:false},
				{name:'status',index:'status', width:75, hidden:false, hidden:false, formatter:myformatter,stype:"select",editoptions:{value:"New:New;DATA PROCESSED:Not New;2:All"}},
				
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblbc23hdrnonhib_draft',
			sortname: 'id_nonhib_hdr',
			viewrecords: true,
			sortorder: "asc",
			width: 970,
			height:250,
			jsonReader: { repeatitems : false },
			caption:"INVOICE DATA NON HIB",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},
			gridComplete: function(){
				var rowIDs = jQuery("#tblbc23hdrnonhib_draft").getDataIDs(); 
				var rowData = $("#tblbc23hdrnonhib_draft").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tblbc23hdrnonhib_draft'));
					
					if(rowData[i].nobl == '-' || rowData[i].nobl == ""){  trElement.css({"color":"black"}); } 
					else if(rowData[i].nobl != '-'){ trElement.css({"color":"blue"}); }
					
				};
				
			},
		}); 
			
                        
		jQuery("#tblbc23hdrnonhib_draft").jqGrid('navGrid','#ptblbc23hdrnonhib_draft',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tblbc23hdrnonhib_draft").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});

	});
		  	
</script>

<div id="frminvdtlnonhib_dlg" title="INVOICE NON HIB DATA DETAIL" class="frminvdtlnonhib_dlg_cl"></div>
<div id="frminvdtlnonhibsummary_dlg" title="INVOICE NON HIB DATA SUMMARY" class="frminvdtlnonhibsummary_dlg_cl"></div>
<div id="bc23_nonhibaddbldata_dlg" title="ADD DATA BL/AWB" class="bc23_nonhibaddbldata_dlg_cl"></div>
<div id="bc23_insertproses_noonhib_dlg" title="PROSES DATA" class="bc23_insertproses_noonhib_dlg_cl"></div>



	
	