<div id="container_pasi_uploadbc25_set" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="pasi_uploadbc25_set_bar" >    
		<button id="btnuploadbc25" >Sync File</button> <button id="btndeletefilebc25" >Delete Sync</button>
	</div>
	<table id="tbluploadbc25"></table> <div id="ptbluploadbc25"></div>
 </div>

 <script type="text/javascript">
    $(document).ready(function(){
		$(window).bind('resize', function() {  
			setTimeout(function(){
				setGridHight($("#tbluploadbc25"),$("#container_pasi_uploadbc25_set"),$("#pasi_uploadbc25_set_bar")); 
			},10); 
		});
	
		$("#btnuploadbc25").button().click(function(){
			
			$("#frmuploadbc25dialog").load('<?php echo base_url().'pasi_uploadmd/ct_uploadbc25/view_uploadbc25dialog'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmuploadbc25dialog").dialog({
					modal:true,
					width : 530,
					height : 330,
					buttons: {
						"Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
					},
					close : function(){
						$('#frmuploadbc25dialog').dialog("destroy"); 
						$(".frmuploadbc25dialog_cl").remove(); 
						$("body").append('<div id="frmuploadbc25dialog" title="SYNC FILE BC 25" class="frmuploadbc25dialog_cl"></div>'); 
						
						jQuery("#tbluploadbc25").trigger('reloadGrid');

					},
					open: function(){
						$("body").unblock();	
					}
				});
			});		
		});
		
		$("#btndeletefilebc25").button().click(function(){	
			var id = jQuery("#tbluploadbc25").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbluploadbc25").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			var form_data = {
				id_upload_bc25:ret.id_upload_bc25,
				file_name:ret.file_name
			};
			
			$("#dlgdeletefilebc25").dialog( "destroy" );
			$(".dlgdeletefilebc25cl").remove();
			$("body").append('<div id="dlgdeletefilebc25" title="Warning" class="dlgdeletefilebc25cl"><p>Are you sure want to delete this file ?</p><br /> file = '+ ret.file_name +'</div>');
			$("#dlgdeletefilebc25").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'pasi_uploadmd/ct_uploadbc25/deletefilebc25'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.status == '00'){
								alert(msg.desc);
								$("#dlgdeletefilebc25").dialog("close");
								$('#dlgdeletefilebc25').dialog("destroy"); 
								$(".dlgdeletefilebc25cl").remove(); 
								$('#tbluploadbc25').trigger('reloadGrid');
							} else { 
								alert(msg.status +' '+ msg.desc); 
								$("#dlgdeletefilebc25").dialog("close");
								$('#dlgdeletefilebc25').dialog("destroy"); 
								$(".dlgdeletefilebc25cl").remove(); 

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

					}
				},
				close : function(){
					$('#dlgdeletefilebc25').dialog("destroy"); 
					$(".dlgdeletefilebc25cl").remove(); 
					$("body").append('<div id="dlgdeletefilebc25" title="Warning" class="dlgdeletefilebc25cl"><p>Are you sure want to delete this file ?</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("#tbluploadbc25").jqGrid()[0].triggerToolbar();
						}, 50);
					} else {
						// refresh the filter in case of
						// searching dialog
						$(this).trigger('change');
					}
				}    
			});
		};
		
		jQuery("#tbluploadbc25").jqGrid({
			url:'<?php echo base_url().'pasi_uploadmd/ct_uploadbc25/loaddatabc25'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:['ID','File Names', 'Upload Date','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:166, hidden:false,stype:"text",searchoptions:{dataInit:datePick, att:{title:'Select Date'}}},
			
				],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptbluploadbc25',
			sortname: 'id_upload_bc25',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:100,
			jsonReader: { repeatitems : false },
			caption:"List of Sync Files",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbluploadbc25").getDataIDs(); 
				var rowData = $("#tbluploadbc25").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbluploadbc25'));
				   
					switch (rowData[i].status) {
						
						case 'SUKSES':
						   trElement.css({"color":"green"});
						break;
						case 'DELETED':
						   trElement.css({"color":"red", "text-decoration": "line-through"});
						break;
					}
				}
			},
		}); 
		
		jQuery("#tbluploadbc25").jqGrid('navGrid','#ptbluploadbc25',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbluploadbc25").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		setTimeout(function(){
			setGridHight($("#tbluploadbc25"),$("#container_pasi_uploadbc25_set"),$("#pasi_uploadbc25_set_bar")); 
		},100); 
	
	});
   </script>
   <div id="frmuploadbc25dialog" title="SYNC BC 25 FILE" class="frmuploadbc25dialog_cl"></div>
 	
	