<div id="container_pasi_bpbj_invoice" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="pasi_bpbj_invoice_bar" > DATA INVOICE
	</div>
<table id="pasi_bpbj_invoice_tbl"></table> <div id="ppasi_bpbj_invoice_tbl"></div>
</div> 

<script type="text/javascript">
    
    $(document).ready(function(){
		$(window).bind('resize', function() {  
			setTimeout(function(){
				setGridHight($("#pasi_bpbj_invoice_tbl"),$("#container_pasi_bpbj_invoice"),$("#pasi_bpbj_invoice_bar")); 
			},10); 
		}); 
		 
	$("#pasi_bpbj_invoice").button(); 
	$("#pasi_bpbj_invoice_barang").button(); 
	  

	jQuery("#pasi_bpbj_invoice_tbl").jqGrid({
			url:'<?php echo base_url().'pasi_ceisa_master/ct_pasi_sa_invoice/loaddata'; ?>',
			mtype : "post",
			postData:{'sa_id':'<?php echo $sa_id;  ?>'},
			datatype: "json",
			colNames:[
			'dt_sa_invoice_sa_invoice_id','dt_sa_invoice_sa_id','SA','No','Date','ETD Port'
			,'Cust Code','Order No','Item\'s','Date','By'
			,'Date','By'
			]
			,colModel:[
			{name:'rID',index:'rID', width:80, hidden:true, align :'right'}
			,{name:'r1',index:'r1', width:80, hidden:true, align :'right'}
			,{name:'r2',index:'r2', width:200, hidden:false, align :'left'}
			,{name:'r3',index:'r3', width:100, hidden:false, align :'left'}
			,{name:'r4',index:'r4', width:80, hidden:false, align :'center', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#pasi_dt_file")[0].triggerToolbar();},changeMonth: true,changeYear: true,dateFormat:'dd/mm/yy', showButtonPanel: true, beforeShow: function(input) {  setTimeout(function() { var buttonPane = $(input).datepicker("widget").find( ".ui-datepicker-buttonpane" );   var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');   btn.unbind("click").bind("click", function () {   $.datepicker._clearDate( input );   });   btn.appendTo( buttonPane );  }, 1 );  }  });}}}
			,{name:'r5',index:'r5', width:80, hidden:false, align :'center', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#pasi_dt_file")[0].triggerToolbar();},changeMonth: true,changeYear: true,dateFormat:'dd/mm/yy', showButtonPanel: true, beforeShow: function(input) {  setTimeout(function() { var buttonPane = $(input).datepicker("widget").find( ".ui-datepicker-buttonpane" );   var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');   btn.unbind("click").bind("click", function () {   $.datepicker._clearDate( input );   });   btn.appendTo( buttonPane );  }, 1 );  }  });}}}

			,{name:'r6',index:'r6', width:80, hidden:false, align :'left'}
			,{name:'r7',index:'r7', width:80, hidden:false, align :'left'}
			,{name:'r8',index:'r8', width:80, hidden:false, align :'right'}
			,{name:'r9',index:'r9', width:125, hidden:false, align :'center', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#pasi_dt_file")[0].triggerToolbar();},changeMonth: true,changeYear: true,dateFormat:'dd/mm/yy', showButtonPanel: true, beforeShow: function(input) {  setTimeout(function() { var buttonPane = $(input).datepicker("widget").find( ".ui-datepicker-buttonpane" );   var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');   btn.unbind("click").bind("click", function () {   $.datepicker._clearDate( input );   });   btn.appendTo( buttonPane );  }, 1 );  }  });}}}
			,{name:'r10',index:'r10', width:80, hidden:false, align :'left'}

			,{name:'r11',index:'r11', width:125, hidden:false, align :'center', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#pasi_dt_file")[0].triggerToolbar();},changeMonth: true,changeYear: true,dateFormat:'dd/mm/yy', showButtonPanel: true, beforeShow: function(input) {  setTimeout(function() { var buttonPane = $(input).datepicker("widget").find( ".ui-datepicker-buttonpane" );   var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');   btn.unbind("click").bind("click", function () {   $.datepicker._clearDate( input );   });   btn.appendTo( buttonPane );  }, 1 );  }  });}}}
			,{name:'r12',index:'r12', width:80, hidden:false, align :'left'}

			],
						rowNum:10,
			rowList:[10,20,30],
			pager: '#ppasi_bpbj_invoice_tbl',
			sortname: 'r1',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height: 100,
			//width: 950,
			//height:300,
			jsonReader: { repeatitems : false }, 
			rownumbers: true,
			loadonce: false,
			shrinkToFit: false,
			multiselect: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#pasi_bpbj_invoice_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#pasi_bpbj_invoice_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#pasi_bpbj_invoice_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
			gridComplete: function(){
				var rowIDs = jQuery("#pasi_bpbj_invoice_tbl").getDataIDs(); 
				var rowData = $("#pasi_bpbj_invoice_tbl").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#pasi_bpbj_invoice_tbl'));
				   
					switch (rowData[i].status_2) {
						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("#pasi_bpbj_invoice_tbl").jqGrid('navGrid','#ppasi_bpbj_invoice_tbl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#pasi_bpbj_invoice_tbl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		jQuery("#pasi_bpbj_invoice_tbl").jqGrid('setGroupHeaders', 
            { useColSpanStyle: true, groupHeaders:[ 
			{startColumnName: 'r3', numberOfColumns:  2, titleText: '<em><center>Invoice</center></em>'},
			{startColumnName: 'r9', numberOfColumns: 2, titleText: '<em><center>Log Create</center></em>'},
			{startColumnName: 'r11', numberOfColumns: 2, titleText: '<em><center>Log Modify</center></em>'}
		] });	 
	
		
	setTimeout(function(){
			setGridHight($("#pasi_bpbj_invoice_tbl"),$("#container_pasi_bpbj_invoice"),$("#pasi_bpbj_invoice_bar")); 
		},100); 
	});
		  	
</script>

	
	