<div style="height:40px;">
	<button id="btninsertkurs_whdtl">Insert Kurs</button> 
	<button id="btnupdatekurs_whdtl">Edit Kurs</button> 
</div>
<table id="tbl_headerkurs_whdtl"></table> <div id="ptbl_headerkurs_whdtl"></div>
<script type="text/javascript">
    
    $(document).ready(function(){
				
		$("#btnupdatekurs_whdtl").button().click(function(){
			var id = jQuery("#tbl_headerkurs_whdtl").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_headerkurs_whdtl").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data={
				id:ret.id,
				rate:ret.rate,
				currenciesid:ret.currenciesid,
				currenciescode:ret.currenciescode,
				headerid:ret.headerid
			};			
			
			$("#frmheaderkurs_whdtlupdate_dlg").load('<?php echo base_url().'settings/ct_kurs/view_detail_kurs_update'; ?>',  form_data, function() {
				$("#frmheaderkurs_whdtlupdate_dlg").dialog({
					modal:true,
					width : 350,
					height : 200,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmheaderkurs_whdtlupdate_dlg').dialog("destroy"); 
					    $(".frmheaderkurs_whdtlupdate_dlg_cl").remove(); 
					    $("body").append('<div id="frmheaderkurs_whdtlupdate_dlg" title="Kurs" class="frmheaderkurs_whdtlupdate_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});
		
		$("#btninsertkurs_whdtl").button().click(function(){
						
			$("#frmkurs_whdtlinsert_dlg").load('<?php echo base_url().'settings/ct_kurs/view_detail_kurs_insert/'.$id; ?>',  function() {
				$("#frmkurs_whdtlinsert_dlg").dialog({
					modal:true,
					width : 350,
					height : 200,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  	
						}
                    },
					close : function(){
						$('#frmkurs_whdtlinsert_dlg').dialog("destroy"); 
					    $(".frmkurs_whdtlinsert_dlg_cl").remove(); 
					    $("body").append('<div id="frmkurs_whdtlinsert_dlg" title="Kurs" class="frmkurs_whdtlinsert_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});
				
		jQuery("#tbl_headerkurs_whdtl").jqGrid({
			url:'<?php echo base_url().'settings/ct_kurs/loadDatadtl/'.$id; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			
			colNames:['id','headerid','currenciesid', 'Valuta','Rate','Create By','Create Date','Update By','Update Date'],	
			colModel:[
				{name:'id',index:'id', width:60, hidden:true},
				{name:'headerid',index:'headerid', width:60, hidden:true},
				{name:'currenciesid',index:'currenciesid', width:60, hidden:true},
				{name:'currenciescode',index:'currenciescode', width:100, hidden:false},
				{name:'rate',index:'rate', width:120, hidden:false},
				{name:'create_by',index:'create_by', width:150,hidden:false},
				{name:'create_date',index:'create_date', width:150,hidden:false},
				{name:'update_by',index:'update_by', width:150,hidden:false},
				{name:'update_date',index:'update_date', width:150,hidden:false},
				],
			rowNum:15,
			rowList:[15,25,35],
			pager: '#ptbl_headerkurs_whdtl',
			sortname: 'currenciescode',
			viewrecords: true,
			sortorder: "asc",
			width: 800,
			height:250,
			jsonReader: { repeatitems : false },
			caption:'<?php echo $no_skep ?> <?php echo $startdate ?> s/d <?php echo $enddate ?>',
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
						
			},			
			gridComplete: function(){
				
			},
		}); 
			
                        
		jQuery("#tbl_headerkurs_whdtl").jqGrid('navGrid','#ptbl_headerkurs_whdtl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_headerkurs_whdtl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		
}); 

		  	
</script>
<div id="frmkurs_whdtlinsert_dlg" title="Kurs" class="frmkurs_whdtlinsert_dlg_cl"></div>
<div id="frmheaderkurs_whdtlupdate_dlg" title="Kurs" class="frmheaderkurs_whdtlupdate_dlg_cl"></div>

	
	