
<div id="container_pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2_bar" >
	<table>
		<tr>
			<td>LIST SA    </td>
			<td style="padding-left:20px">
				<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_sa_view_mon">View Monitoring</button>  
				<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_sa_print_mon">Print xlsx</button>  
				<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_sa_print_mon1">Print xls</button>  
			</td>
		</tr> 
	</table> 
</div>
<table id="pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2"></table> <div id="ppasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2"></div>
</div> 

<script type="text/javascript">
 	
    $(document).ready(function(){ 
	
	
		var ceisa_bc_out<?php echo $bc_prefix;  ?>_cust_code='<?php echo $cust_code;  ?>';
		$(window).bind('resize', function() {  
			setTimeout(function(){
	 			setGridHight($("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2"),$("#container_pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2"),$("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2_bar")); 
			},10); 
		});  
		
	$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_sa_view_mon").button(); 
	$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_sa_print_mon").button();  
	$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_sa_print_mon1").button();  
		
    jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_sa_view_mon").click(function(){  
	var mark_id = jQuery('#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2').jqGrid('getGridParam','selrow');   
			if(!mark_id){ alert("Select SA ");} 
			else {
				var ret = jQuery("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").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,inv_file: ret.r2})
				 .dialog({
					modal:true,
					width : 970,
					height : 555,
						title :'MONITORING SUAI',
						buttons: {
							"CLOSE": function(){
								$dialog.dialog("close");  
							} 
						},
						close : function(){
							$dialog.dialog('destroy').remove();
							$('##pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2').trigger('reloadGrid');
						},
						open: function(){
							$("body").unblock(); 
						}
					});
			}
	}); 
	
	
    jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_sa_print_mon").click(function(){  
		 
					 	var selRowIds;
							 selRowIds =  $("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").jqGrid('getGridParam','selarrrow'); 
							if (selRowIds.length ==0){
								 alert("Harus memiliki minimal 1 SA, pilih SA");
								 exit;
							 } 
							reportPrintMon('xlsx');
							
							//action
				 
	}); 
	
	jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_sa_print_mon1").click(function(){  
		 
					 	var selRowIds;
							 selRowIds =  $("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").jqGrid('getGridParam','selarrrow'); 
							if (selRowIds.length ==0){
								 alert("Harus memiliki minimal 1 SA, pilih SA");
								 exit;
							 } 
							reportPrintMon('xls');
							
							//action
				 
	}); 
	
	
		function reportPrintMon(format){
		var mark_id = jQuery('#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2').jqGrid('getGridParam','selrow'); 
		var ret = jQuery("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").jqGrid('getRowData',mark_id);   
		var sa_id = ret.rID;   
		var inv_file = ret.r2;   
 	 
		
		var dialog = jQuery('<div />')
					 .html('<div class="ui-layout-content ui-widget-content-panel">\
									<p >Are u want to print report?</p>\
								   </div>\
									<div class="pane-footer ui-state-default"></div>\
									<form hidden id="frmPrintReportBarangJadiMerge" method="POST" action="<?php echo base_url().'pasi_ceisa_master/CT_pasi_sa_suai_item/printReport'; ?>"/>');  
		dialog.dialog({
				modal:true,
				width : 350,
				height : 150,
				title :'Report Monitoring',
				buttons: { 
					"CLOSE": function(){
						dialog.dialog("close");  
					},
					"PRINT": function() { 
					
					$("#frmPrintReportBarangJadiMerge").append($("<input>").attr({"value":sa_id , "name":'sa_id'})); 
					$("#frmPrintReportBarangJadiMerge").append($("<input>").attr({"value":inv_file , "name":'inv_file'})); 
					$("#frmPrintReportBarangJadiMerge").append($("<input>").attr({"value":format , "name":'format'})); 
					$("#frmPrintReportBarangJadiMerge").append($("<input>").attr({"value":$("#cb_datadok_bj").val() , "name":'source'})); 
 					$("#frmPrintReportBarangJadiMerge").submit();  
					
					dialog.dialog("close");  
					}
				},
				close : function(){
					dialog.dialog('destroy').remove(); 
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	
	} 
		
		
		jQuery("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").jqGrid({
			url:'<?php echo base_url().'pasi_ceisa_master/ct_pasi_sa/loaddata'; ?>',
			datatype: "json",
			mtype : "post",
			postData:{	id_header:'<?php echo $id_header;  ?>'
						,cust_code:'<?php echo $cust_code;  ?>'
						,bc_prefix:'<?php echo $bc_prefix;  ?>'
						,mode :'0'
						},
	 		colNames:[
					'dt_sa_sa_id','SA','CUST CODE','Invoice\'S','Item\'S','dt_sa_file_data_id'
			  		]
			,colModel:[
					{name:'rID',index:'rID', width:80, hidden:true, align :'right'}
					,{name:'r1',index:'r1', width:220, hidden:false, align :'right'}
					,{name:'r2',index:'r2', width:80, hidden:false, align :'right'}
					,{name:'r3',index:'r3', width:70, hidden:false, align :'right'}
					,{name:'r4',index:'r4', width:55, hidden:false, align :'right'}
					,{name:'r5',index:'r5', width:65, hidden:true, align :'right'}  
					],
		//	rowNum:-1,
			multiselect: true, 
			rowNum:100,
		 	rowList:[10,20,30,50,100,200],
	 		pager: '#ppasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2',
			sortname: 'r1',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height: 100,
			//width: 950,
			//height:300,
			jsonReader: { repeatitems : false }, 
			rownumbers: true,
			loadonce: false,
			shrinkToFit: false, 
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
			gridComplete: function(){
				var rowIDs = jQuery("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").getDataIDs(); 
				var rowData = $("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2'));
				   
					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_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").jqGrid('navGrid','#ppasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		 
	
	setTimeout(function(){
	 		setGridHight($("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2"),$("#container_pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2"),$("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list2_bar")); 
	},100); 
	});
		  	
</script>

	
	