<div style="height:40px;">
	<button id="btngetbc25">Get Exp. BC 25</button>
	
</div>
<table id="tbl_bc25itemlist_dtl"></table> <div id="ptbl_bc25itemlist_dtl"></div>
<script type="text/javascript">
    
    $(document).ready(function(){
	
		$("#btngetbc25").button().click(function(){
			var id = jQuery("#tbl_bc25itemlist_dtl").jqGrid('getGridParam','selrow');
			
			if (id) { 
				var ret = jQuery("#tbl_bc25itemlist_dtl").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			if (ret.status!='SUKSES'){
				alert("Data tidak dapat diproses..!");
				return false;
			}
			
			
			var form_data = {
				id_upload_bc25:ret.id_upload_bc25,
				file_name:ret.file_name,
				file_path:ret.file_path
			};
			
			$("#dlgdatalistitem").dialog( "destroy" );
			$(".dlgdatalistitem_cl").remove();
			$("body").append('<div id="dlgdatalistitem" title="Warning" class="dlgdatalistitem_cl"><p>Apakah anda akan Memproses Data Menjadi BC 25 ?</p><br /></div>');
			$("#dlgdatalistitem").dialog({
				height: 200,
				width: 350,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'pasi_inventory/ct_expbc25/getbc25dataitemlist'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlgdatalistitem").dialog("close");
								$('#dlgdatalistitem').dialog("destroy"); 
								$(".dlgdatalistitem_cl").remove(); 
								$('#tbl_exp25').trigger('reloadGrid');
								//$('#tbl_bpbjadi').trigger('reloadGrid');
							} else { 
								alert(msg.sts+msg.desc);
								$("#dlgdatalistitem").dialog("close");
								$('#dlgdatalistitem').dialog("destroy"); 
								$(".dlgdatalistitem_cl").remove(); 		

							}
						}
					});
				},
				"CANCEL": function() {
						$( "#dlgdatalistitem" ).dialog( "close" );
						$(".dlgdatalistitem_cl").remove();

					}
				},
				close : function(){
					$('#dlgdatalistitem').dialog("destroy"); 
					$(".dlgdatalistitem_cl").remove(); 
					$("body").append('<div id="dlgdatalistitem" title="Warning" class="dlgdatalistitem_cl"><pApakah anda akan Memproses Data Menjadi BC 25?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		
			
		});
		
		var datePick = function (el) {
			$(el).datepicker({
				changeYear: true,
				changeMonth: true,
				showButtonPanel: true,
				onSelect: function () {
					
					if (this.id.substr(0, 3) === "gs_") {
                // in case of searching toolbar
					setTimeout(function(){
					jQuery("#tbl_bbitemlist_dtl").jqGrid()[0].triggerToolbar();
						}, 50);
					} else {
						// refresh the filter in case of
						// searching dialog
						$(this).trigger('change');
					}
				}    
			});
		};
		jQuery("#tbl_bc25itemlist_dtl").jqGrid({
			url:'<?php echo base_url().'pasi_inventory/ct_expbc25/data_bc25_itemlist'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:['ID','filename', 'date upload','status upload', 'tipe', 'create date'],
			colModel:[
				{name:'id_upload_bc25',index:'id_upload_bc25', width:60, hidden:true},
				{name:'file_name',index:'file_name', width:226},
				{name:'file_path',index:'file_path', width:166,hidden:true},
				{name:'status',index:'status', width:106},
				{name:'upload_by',index:'upload_by', width:106},
				{name:'upload_date',index:'upload_date', width:182, hidden:false,stype:"text",searchoptions:{dataInit:datePick, att:{title:'Select Date'}}},	
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptbl_bc25itemlist_dtl',
			sortname: 'id_upload_bc25',
			viewrecords: true,
			sortorder: "desc",
			width: 670,
			height:200,
			jsonReader: { repeatitems : false },
			caption:"List of Files Upload",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},
			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_bc25itemlist_dtl").getDataIDs(); 
				var rowData = $("#tbl_bc25itemlist_dtl").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_bc25itemlist_dtl'));
				   
					switch (rowData[i].status) {
						
						case 'SUKSES':
						   trElement.css({"color":"green"});
						break;
						case 'DELETED':
						   trElement.css({"color":"red", "text-decoration": "line-through"});
						break;
						case 'PROCESSED':
						   trElement.css({"color":"blue"});
						break;
					}
				}
			},
		}); 
		
		jQuery("#tbl_bc25itemlist_dtl").jqGrid('navGrid','#ptbl_bc25itemlist_dtl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_bc25itemlist_dtl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
	});
</script>



	
	