<div style="height:30px;">
	<button id="btnfgin_uploaded_proses" >Proses Data</button>
</div>
   <table id="tbluploadfgin_uploaded"></table> <div id="ptbluploadfgin_uploaded"></div>   
<script type="text/javascript">
    
    $(document).ready(function(){
		$("#btnfgin_uploaded_proses").button().click(function(){
			var id = jQuery("#tbluploadfgin_uploaded").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbluploadfgin_uploaded").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
		
			if (ret.status_upload != 'SUKSES'){
			
				alert("Data Tidak Dapat di Proses");
				return false;
			}
			
			$("#dlg_uploadedfgin").dialog( "destroy" );
			$(".dlg_uploadedfgincl").remove();
			$("body").append('<div id="dlg_uploadedfgin" title="Warning" class="dlg_uploadedfgincl"><p>Apakah anda akan memproses file ini?!?</p><br /> file = '+ ret.filename +'</div>');
			$("#dlg_uploadedfgin").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'inventory/ct_fg/get_fg_load_data'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_uploadedfgin").dialog("close");
								$('#dlg_uploadedfgin').dialog("destroy"); 
								$(".dlg_uploadedfgincl").remove(); 
								$('#tbluploadfgin_uploaded').trigger('reloadGrid');
							} else { 
								alert(msg.sts+' '+msg.desc); 
								$("#dlg_uploadedfgin").dialog("close");
								$('#dlg_uploadedfgin').dialog("destroy"); 
								$(".dlg_uploadedfgincl").remove(); 

							}
						}
					});
				},
					"CANCEL": function() {
						$( "#dlg_uploadedfgin" ).dialog( "close" );

					}
				},
				close : function(){
					$('#dlg_uploadedfgin').dialog("destroy"); 
					$(".dlg_uploadedfgincl").remove(); 
					$("body").append('<div id="dlg_uploadedfgin" title="Warning" class="dlg_uploadedfgincl"><p>Apakah anda akan memproses file ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
			
		
		});
		
		jQuery("#tbluploadfgin_uploaded").jqGrid({
			url:'<?php echo base_url().'inventory/ct_fg/data_uploadfgin'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:['ID','filename', 'date upload','status upload', 'tipe','filepath' ,'create date', 'create by'],
			colModel:[
				{name:'id_fgin_upload',index:'id_fgin_upload', width:60, hidden:true},
				{name:'filename',index:'filename', width:160},
				{name:'date_upload',index:'date_upload', width:166,stype:"text",searchoptions:{}},
				{name:'status_upload',index:'status_upload', width:106},
				{name:'tipe',index:'tipe', width:106},
				{name:'filepath',index:'filepath', width:60, hidden:true},
				{name:'create_date',index:'create_date', width:166, hidden:false,stype:"text",searchoptions:{}},
				{name:'create_by',index:'create_by', width:106, hidden:false},
			
				],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptbluploadfgin_uploaded',
			sortname: 'id_fgin_upload',
			viewrecords: true,
			sortorder: "desc",
			width: 730,
			height:250,
			jsonReader: { repeatitems : false },
			caption:"List of Files Uploaded",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbluploadfgin_uploaded").getDataIDs(); 
				var rowData = $("#tbluploadfgin_uploaded").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbluploadfgin_uploaded'));
				   
					switch (rowData[i].status_upload) {
						
						case 'cancel':
						   trElement.css({"color":"green"});
						break;
						case 'Deleted':
						   trElement.css({"color":"red", "text-decoration": "line-through"});
						break;
						case 'DATA PROCESSED':
						   trElement.css({"color":"blue"});
						break;
						
						
					}
				}
			},
		}); 
		
		jQuery("#tbluploadfgin_uploaded").jqGrid('navGrid','#ptbluploadfgin_uploaded',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbluploadfgin_uploaded").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		
		
	});
		  	
</script>



	
	