<div id="container_pasi_ceisa_master_sa_suai" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="pasi_ceisa_master_sa_suai_bar" >   
		<!-- <button type="button" id="pasi_ceisa_master_sa_suai_invoice">View Monitoring Invoce</button> !-->
		
		
		
	</div>
<table id="pasi_ceisa_master_sa_suai_tbl"></table> <div id="ppasi_ceisa_master_sa_suai_tbl"></div>
</div> 

<script type="text/javascript">
    
    $(document).ready(function(){
	
	$(window).bind('resize', function() {  
		setTimeout(function(){
			setGridHight($("#pasi_ceisa_master_sa_suai_tbl"),$("#container_pasi_ceisa_master_sa_suai"),$("#pasi_ceisa_master_sa_suai_bar")); 
		},10); 
	}); 
		 
	$("#pasi_ceisa_master_sa_suai_invoice").button(); 
	$("#pasi_ceisa_master_sa_suai_barang").button(); 
	$("#pasi_ceisa_master_sa_suai_validation").button();  

	 jQuery("#pasi_ceisa_master_sa_suai_invoice").click(function(){
			var mark_id = jQuery('#pasi_ceisa_master_sa_suai_tbl').jqGrid('getGridParam','selrow');   
			if(!mark_id){ alert("Select SA ");} 
			else {
				var ret = jQuery("#pasi_ceisa_master_sa_suai_tbl").jqGrid('getRowData',mark_id);    
				var $dialog = jQuery('<div \>')
				 .load('<?php echo base_url().'pasi_ceisa_master/ct_pasi_sa_suai_invoice'; ?>',{sa_id :ret.rID})
				 .dialog({
					modal:true,
					width : 970,
					height : 555,
						title :'LIST INVOICE',
						buttons: {
							"CLOSE": function(){
								$dialog.dialog("close");  
							} 
						},
						close : function(){
							$dialog.dialog('destroy').remove();
							$('#pasi_ceisa_master_sa_suai_tbl').trigger('reloadGrid');
						},
						open: function(){
							$("body").unblock(); 
						}
					});
			}
		});
		 
		jQuery("#pasi_ceisa_master_sa_suai_barang").click(function(){
			var mark_id = jQuery('#pasi_ceisa_master_sa_suai_tbl').jqGrid('getGridParam','selrow');   
			if(!mark_id){ alert("Select SA ");} 
			else {
				var ret = jQuery("#pasi_ceisa_master_sa_suai_tbl").jqGrid('getRowData',mark_id);    
				var $dialog = jQuery('<div \>')
				 .load('<?php echo base_url().'pasi_ceisa_master/ct_pasi_sa_suai_item'; ?>',{sa_id :ret.rID})
				 .dialog({
					modal:true,
					width : 970,
					height : 555,
						title :'LIST INVOICE',
						buttons: {
							"CLOSE": function(){
								$dialog.dialog("close");  
							} 
						},
						close : function(){
							$dialog.dialog('destroy').remove();
							$('#pasi_ceisa_master_sa_suai_tbl').trigger('reloadGrid');
						},
						open: function(){
							$("body").unblock(); 
						}
					});
			}
			 
		});
		 
		 
	jQuery("#pasi_ceisa_master_sa_suai_tbl").jqGrid({
			url:'<?php echo base_url().'pasi_ceisa_master/ct_pasi_sa_suai/loaddata'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:[
					'dt_sa_suai_sa_suai_id','SA Name','Cust Code','Invoice','Invoice','Item','dt_sa_suai_file_data_id'
					,'File','Used','Type','CAR','NO','DATE'
					,'Status','doc_type'
					]
			,colModel:[
					{name:'rID',index:'rID', width:80, hidden:true, align :'right'}
					,{name:'r1',index:'r1', width:250, hidden:false, align :'left'}
					,{name:'r2',index:'r2', width:80, hidden:false, align :'left'}
					,{name:'r22',index:'r22', width:380, hidden:false, align :'left'}
					,{name:'r3',index:'r3', width:60, hidden:false, align :'right'}
					,{name:'r4',index:'r4', width:60, hidden:false, align :'right'}
					,{name:'r5',index:'r5', width:80, hidden:true, align :'left'}

					,{name:'r6',index:'r6', width:180, hidden:true, align :'left'}
					,{name:'r7',index:'r7', width:40, hidden:true,editable: false, formatter:'checkbox',  align: "center",stype: "select", searchoptions: { value: "-100:All;1:Yes;0:No" }}
					,{name:'r12',index:'r12', width:50, hidden:true, align :'left'}
					,{name:'r8',index:'r8', width:180, hidden:true, align :'left'}
					,{name:'r9',index:'r9', width:80, hidden:true, align :'left'} 
					,{name:'r10',index:'r10', width:80, hidden:true, align :'left', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#table_name")[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:'r13',index:'r13', width:80, hidden:true, align :'left'} 
					,{name:'r11',index:'r11', width:80, hidden:true, align :'right'} 
	
					],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ppasi_ceisa_master_sa_suai_tbl',
			sortname: 'r1',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height: 100,
			//width: 950,
			//height:300,
			jsonReader: { repeatitems : false },
			caption:"Data File AJU SA SUAI",
			rownumbers: true,
			loadonce: false,
			shrinkToFit: false,
			multiselect: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#pasi_ceisa_master_sa_suai_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#pasi_ceisa_master_sa_suai_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#pasi_ceisa_master_sa_suai_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
			gridComplete: function(){
				var rowIDs = jQuery("#pasi_ceisa_master_sa_suai_tbl").getDataIDs(); 
				var rowData = $("#pasi_ceisa_master_sa_suai_tbl").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#pasi_ceisa_master_sa_suai_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_ceisa_master_sa_suai_tbl").jqGrid('setGroupHeaders', 
            { useColSpanStyle: true, groupHeaders:[
	 		{startColumnName: 'r3', numberOfColumns: 2, titleText: '<em><center>Total</center></em>'},
 			{startColumnName: 'r7', numberOfColumns: 6, titleText: '<em><center>Dokumen</center></em>'}, 
        ] });
			               
		jQuery("#pasi_ceisa_master_sa_suai_tbl").jqGrid('navGrid','#ppasi_ceisa_master_sa_suai_tbl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#pasi_ceisa_master_sa_suai_tbl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
	
	
		
	setTimeout(function(){
			setGridHight($("#pasi_ceisa_master_sa_suai_tbl"),$("#container_pasi_ceisa_master_sa_suai"),$("#pasi_ceisa_master_sa_suai_bar")); 
		},100); 
	});
		  	
</script>

	
	