<!---- 
    Author 	: Ladur
    Tanggal : 12-08-2014	
    Revisi 	: Fahri
-->

<div class="easyui-layout" data-options="fit:true,border:false">
	<!-- Top view-->

    <div id="form-header" data-options="region:'north',border:false" >
        <div id="form-header-wrapper">
            <?php 
				if($list->TransStatus ==3 || $list->TransStatus ==2 || $list->TransStatus ==4 || $list->TransStatus ==5){ 
					$txt_date = "disabled";
					$txt_vendor = "disabled";
					$txt_desc = "disabled"; 
					$btn_delete = "disabled";
					$suspen_disible = "disabled"; 
				} 
				else { 
					$txt_date = "";
					$txt_vendor = "";
					$txt_desc = ""; 
					$btn_delete = "";
					$suspen_disible = ""; 
				} 
			?>
            <table cellpadding="0" cellspacing="0" width="100%" height="100%" border="0">
            <tr>
                <td align="left">
                    <a href="#" class="easyui-linkbutton" iconCls="icon-journal" plain="true" onclick="parent.tab_edit('Print Journal Voucher', '<?php echo"activities/journal_voucher"; ?>', 'icon-print', 'to_journal', $('#txt_voucher_no').val())">Journal</a>
                	<input type="checkbox" name="chk_suspended" id="chk_suspended" onClick="suspend(1)" <?php echo $suspen_disible; ?> <?php if($list->TransStatus == 3){ echo"checked disabled"; } else { echo"enabled"; } ?> />
                    Pembatalan Transaksi	
                </td>
                <td height="25" align="right" valign="middle">
                    <span class="form-title" style="margin-left:7px;">
                        <?=$menu_label?>
                    </span>
                </td>
            </tr>
            </table>		     	
        </div>			
    </div>
    <!-- End of top view -->
    
    <div id="form-body" data-options="region:'center',border:false">
    <?php if($list->TransStatus == 2){ ?>
        <div class="blanket"></div>
        <div class="finished-box"><b>Finished</b></div>
    <?php }else if($list->TransStatus == 3){ ?>
    	 <div class="blanket"></div>
         <div class="suspend-box"><b>Suspended</b></div>
	<?php
	}
	?>
        <div id="form-wrapper" class="easyui-panel" style="width:1180%;height:526px;padding:5px;" fit="true">
        	<form id="fm_journal_voucher" name="fm_journal_voucher" method="post">
			    <input type="hidden" id="detail_jv" name="detail_jv" />
            	<input type="hidden" id="sub_type" name="sub_type" />
                
                 <input type="hidden" id="txt_currency" name="txt_currency" value="0"/>
                 <input type="hidden" id="txt_hidden_debit" name="txt_hidden_debit" />
                 <input type="hidden" id="txt_hidden_rate" name="txt_hidden_rate" />
                
                <!-- Form Header -->
                <table width="100%" height="141" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="50%" valign="top">
                    	<table width="100%" cellpadding="0" cellspacing="1" style="margin-top:4px;">
                        <tr height="20">
                        	<td width="120"><b>Voucher No.</b></td>
                            <td width="10"><b>:</b></td>
                            <td>
                            	<input name="txt_voucher_no" id="txt_voucher_no" value="<?php echo $list->JVchNumber?>" type="text" class="easyui-validatebox" style="width:302px;height:18px" required readonly />
                            </td>
                        </tr>
                        <tr height="20">
                        	<td><b>Voucher Date</b></td>
                            <td><b>:</b></td>
                            <td>
                            	<input name="txt_voucher_date" id="txt_voucher_date" value="<?php echo $list->JVchDate; ?>" type="text" class="easyui-datebox validBackward" style="width:180px;" required editable="false" <?php echo $txt_date;?> readonly/>
                            </td>
                        </tr>
                        
                        
                        <tr height="20">
                        	<td valign="top" style="padding-top:4px;"><b>Description</b></td>
                            <td valign="top" style="padding-top:4px;"><b>:</b></td>
                            <td>
                            	<textarea class="textbox" <?php echo $txt_desc;?> style="width:302px;resize:none;white-space:normal;" name="txa_description" id="txa_description" rows="4" <?=($list->AppLevel1Status==1 || $list->AppLevel1Status==2)?'disabled':''?>><?php echo $list->JVchDesc; ?></textarea>
                            </td>
                        </tr>
                        </table>
                    </td>
                    <td width="50%" valign="top">&nbsp;</td>
                </tr>
                </table>
                <!-- End of form header -->
                
                <!-- Datagrid -->
                <table id="dtg_journal_voucher" class="easyui-edatagrid" toolbar="#tb_dtg_journal_voucher"
					idField="id" url="<?php echo base_url(); ?><?php echo'activities/journal_voucher'; ?>/get_detail_jvoucher/<?php echo $list->JVchNumber; ?>"
					rownumbers="true" fitColumns="true" singleSelect="true" style="height:355px;">
					<thead>
							
						    <th align="left" valign="middle" data-options="field:'AccountName',width:400,align:'left'">Account Name</th>
                            														
							<th field="Debit" formatter="formatRp" width="120" editor="{type:'Debit',options:{precision:2,decimalSeparator:',',groupSeparator:'.'}}" data-options="align:'right',halign:'center'">Debit</th>
							<th field="Credit" formatter="formatRp" width="170" editor="{type:'Credit',options:{precision:2,decimalSeparator:',',groupSeparator:'.'}}" data-options="align:'right',halign:'center'">Credit</th>
							<th field="Rate" width="170" editor="{type:'Rate'}" data-options="align:'right',halign:'center'">Exchange Rate</th>
                            <th field="TotRateDebet" width="120" hidden="true" editor="{type:'numberbox'}" data-options="align:'right',halign:'center'">Total Debet</th>
                            <th field="TotRateCredit" width="120" hidden="true" editor="{type:'numberbox'}" data-options="align:'right',halign:'center'">Total Credit</th>
                            
                            <th align="center" valign="middle" data-options="field:'Vendor',width:200,align:'left'">Vendor Name</th>
                            <th align="center" valign="middle" data-options="field:'Customer',width:200,align:'left'" >Customer Name</th>
                            
                            <th align="center" valign="middle" data-options="field:'VendorCode',width:200,align:'left'"  hidden="true">Vendor COde</th>
                            <th align="center" valign="middle" data-options="field:'CustomerCode',width:200,align:'left'"  hidden="true">Customer Code</th>
                            
                            <th align="center" valign="middle" hidden="true" data-options="field:'AccountNumber',width:400,align:'left'" editor="{type:'AccountNumber'}">Account Code</th>
                            <th align="center" valign="middle" hidden="true" data-options="field:'AccountSubTypeID',width:400,align:'left'" editor="{type:'AccountSubTypeID'}">Account Sub Type ID</th>
                            
                            <th align="center" valign="middle" data-options="field:'Memo',width:400,align:'left',editor:'text'">Memo</th>
							<th align="left" valign="middle" hidden="true" data-options="field:'id',width:20,align:'left'" editor="{type:'id'}">id</th>
					  		<th hidden="true" align="center" valign="middle" data-options="field:'CurrencyCode',width:400,align:'left'" editor="{type:'CurrencyCode'}">Currency Code</th>
                      </tr>
					</thead>
				</table>
                
                <!-- Dialog Button -->
				<div id="tb_dtg_journal_voucher">
					<!--<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addRow()">New</a>-->
					<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="delete_row();" <?php echo $btn_delete;?>>Delete</a>
					<!--<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="javascript:$('#dtg_journal_voucher').edatagrid('cancelRow')">Cancel</a>-->
				</div>
                <!-- End of Dialog Button -->
                <!-- End of Datagrid -->
                
                
        	</form>
		</div>
	</div>
    
    <div id="form-footer" data-options="region:'south',border:false">
    	<table width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td>&nbsp;</td>
                <td align="right">
                     <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-help" onclick="" plain="true">Help</a>
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button app-button" iconCls="icon-ok" id="app_dir" 
					 <?php 
					 	if(date('Y-m-d') < date('Y-m-d', strtotime($list->JVchDate)) || $list->AppLevel2Status == 1){
							echo "disabled";
						} 
						else if(($list->TransStatus == 3) || ($list->TransStatus == 2)){
							echo "disabled";
						}
						else if($this->session->userdata('jobtitle_status') == 0 && empty($AppLevel2Status)){
							echo "enabled";
						}
						else{ echo "disabled";}
					 ?>
                     onclick="app_dir()"> App. Dir</a>
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button app-button" iconCls="icon-ok" id="app_mgr" 
					 <?php 
					 	if(date('Y-m-d') < date('Y-m-d', strtotime($list->JVchDate)) || $list->AppLevel1Status == 1){
							echo "disabled";
						} 
						else if(($list->TransStatus == 3) || ($list->TransStatus == 2)){
							echo "disabled";
						}
						else if($this->session->userdata('jobtitle_status') == 1 && empty($AppLevel1Status)){
							echo "enabled";
						}
						else{ echo "disabled";}
					 ?>

                     onclick="app_mgr()"> App. Mgr</a>
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="saveData();" 
					 <?php 
					 	if($list->TransStatus ==3 || $list->TransStatus ==2 || $list->TransStatus ==4 || $list->TransStatus ==5){ 
							echo "disabled"; 
						} 
						else{ 
							echo"enabled"; 
						} 
					 ?>>Save</a> 								
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-print" onclick="">Preview & Print</a>   
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-cancel" onclick="">Cancel</a>	
                     </td>
             </tr>
         </table>
		</div>
</div>

<div id="dialog-account" class="easyui-dialog" style="width:655px; left:150px; top:50px; background-color:#F8F8F8; height:400px; padding: 0 0px 0 0px" closed="true" data-options="modal:true, iconCls:'icon-save'" buttons="#dialog-buttons-account-payment">
    <form id="form_account" method="post" novalidate>
        <table width="100%" align="left" border="0">
        <tr>
            <td align="left" valign="middle">
                <input type="text" style="width:150px;height:20px" name="txt_account_number" id="txt_account_number" class="easyui-validatebox" placeholder="Account Number" onkeyup="search_account_popup()" />
            </td>
            <td colspan="2" align="left" valign="middle">
                <input type="text" style="width:476px;height:20px" name="txt_account_name" id="txt_account_name" class="easyui-validatebox" placeholder="Account Name" onkeyup="search_account_popup()" />
            </td>
		</tr>
        <tr>
            <td colspan="3">
                <table id="tt_choose_account_journal" class="easyui-datagrid" 
                    url="<?php echo base_url(); ?>activities/journal_voucher/get_akun" 
                    singleSelect="true" 
                    style="width:635px;height:290px"
                >
                    <thead>
                    <tr>
                        <th field="AccountNumber" width="150" sortable="true">Account Number</th>
                        <th field="AccountName" width="460" sortable="true">Name</th>
                        <th field="AccountSubTypeID" width="460" sortable="true" hidden="true">AccountSubType ID</th>
                        <th field="CurrencyCode" width="460" sortable="true" hidden="true">Currency Code</th>
                    </tr>
                    </thead>
                </table>
            </td>
        </tr>
        </table>
    </form>
</div>

<!-- Dialog Button -->
<div id="dialog-buttons-account-payment">
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="choose_account_journal();">OK</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="modal_close('dialog-account')">Cancel</a>
</div>

<div id="dialog-type-journal" class="easyui-dialog" style="width:655px; left:150px; top:50px; background-color:#F8F8F8; height:400px; padding: 0 0px 0 0px" closed="true" data-options="modal:true, iconCls:'icon-save'" buttons="#dialog-buttons-account-payment">
    <table width="100%" align="left" border="0">
    <tr>
        <td colspan="3">
            <table id="tt_choose_type_journal" class="easyui-datagrid" 
                url="<?php echo base_url(); ?>activities/journal_voucher/get_type_journal" 
                singleSelect="true" 
                style="width:635px;height:290px"
            >
                <thead>
                <tr>
                    <th field="TypeID" width="150" sortable="true">Type ID</th>
                    <th field="TypeName" width="460" sortable="true">Name</th>
                </tr>
                </thead>
            </table>
        </td>
    </tr>
    </table>
</div>

<!-- Dialog Button -->
<div id="dialog-buttons-account-payment">
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="choose_type_journal();">OK</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="modal_close('dialog-type-journal')">Cancel</a>
</div>


<script type="text/javascript">
function app_dir(){
	$('#dtg_journal_voucher').edatagrid('saveRow');
	var rows = $('#dtg_journal_voucher').edatagrid('getRows');
	var jum = rows.length;
	var items = JSON.stringify(rows);
	$("#detail_jv").val(items);
	
	custom_data('<?php echo"activities/journal_voucher"; ?>/approval1','#fm_journal_voucher');
}

function app_mgr(){
	var total_debit = 0;
	var total_credit = 0;
	
	$('#dtg_journal_voucher').edatagrid('saveRow');
	var rows = $('#dtg_journal_voucher').edatagrid('getRows');
	var jum = rows.length;
	var items = JSON.stringify(rows);
	$("#detail_jv").val(items);
	
	for(var i=0; i<rows.length; i++){
		if(rows[i].Debit == ''){ rows[i].TotRateDebet = 0; }
			total_debit += parseInt(rows[i].TotRateDebet);
		if(rows[i].Credit == ''){ rows[i].TotRateCredit = 0; }
			total_credit += parseInt(rows[i].TotRateCredit);
	}
	if(total_debit != total_credit){
		$.messager.alert('Unseccessfull','Account Tidak Balance','error');
		return false;
	} else {
		custom_data('<?php echo"activities/journal_voucher"; ?>/approval2','#fm_journal_voucher');
	}
}

function delete_row(){
        var item = $('#dtg_journal_voucher').datagrid('getData').total;

        if(item <= 1){
            $.messager.alert('Warning','Anda tidak dapat menghapus list item, minimum list item adalah satu (1)','error')
        }
        else {
            remove_row();
        }            
    }
    
function remove_row(){
	var url             = base_url + 'activities/journal_voucher/delete';

	var selectedrow     = $('#dtg_journal_voucher').datagrid('getSelected');
	var row_index       = $('#dtg_journal_voucher').datagrid('getRowIndex', selectedrow);
	
	var id  = selectedrow.id;

	$.messager.confirm('Confirmation :', 'Anda yakin, Anda ingin menghapus item "' + selectedrow.AccountName + '"',  
		function(r){
			if (r){
				$('#dtg_journal_voucher').datagrid('deleteRow', row_index);
				
				$.post(url, {id:id}, function(result){
					if (result.status == true){
						$.messager.alert('Success',result.message,'info',function(){
//                                location.reload();						                    
						});				
					} 
					else {
						$.messager.alert('Failed',result.message,'error',function(){
							location.reload();						                    
						});				
					}
				},'json');
			}
		}
);        
}

function addRow(){
	$('#dtg_journal_voucher').edatagrid('addRow');
	var rows = $('#dtg_journal_voucher').edatagrid('getRows');
	var jumr = rows.length;
	var new_db = 0;
	var new_cd = 0;
	var tot_new_db = 0;
	var tot_new_cd = 0;
	 
	for(var i=1; i<rows.length; i++){
	   
		var db =  parseInt(rows[i-1].Debet);
		var cd =  parseInt(rows[i-1].Credit);
		
		new_db += db;
		new_cd += cd;
		tot_new_db = new_db - new_cd;
		tot_new_dc = new_cd - new_db;
		
		if(jumr > 2){
			if(tot_new_db < 0){
			   $('.Credit').val(0);
			} else {
				$('.Credit').val(0);
			}
			
			if(tot_new_dc < 0){
			   $('.Debit').val(0);
			} else {
				$('.Debit').val(0);
			}	
		} 
		else {
			if(isNaN(db)){
			   $('.Credit').val(0);
			} else {
				$('.Credit').val(0);
			}
			
			if(isNaN(cd)){
			   $('.Debit').val(0);
			} else {
				$('.Debit').val(0);
			}	
		}
		//alert(db);
		$('#dtg_journal_voucher').edatagrid('saveRow');
		
		//new_db++;
	}
	
}

function open_account_journal(){ 
   modal_open('Account List','dialog-account');
}

function open_type_journal(){ 
   modal_open('Type Journal','dialog-type-journal');
}


function search_account_popup(){
	$('#tt_choose_account_journal').datagrid('load',{
		AccountNo 	: $('#txt_account_number').val(),
		AccountName : $('#txt_account_name').val()
	});
}

function saveData(){
	var total_debit = 0;
	var total_credit = 0;
	
	$('#dtg_journal_voucher').edatagrid('saveRow');
	var rows = $('#dtg_journal_voucher').edatagrid('getRows');
	var jum = rows.length;
	var items = JSON.stringify(rows);
	$("#detail_jv").val(items);
	
	for(var i=0; i<rows.length; i++){
		if(rows[i].Debit == ''){ rows[i].TotRateDebet = 0; }
			total_debit += parseInt(rows[i].TotRateDebet);
		if(rows[i].Credit == ''){ rows[i].TotRateCredit = 0; }
			total_credit += parseInt(rows[i].TotRateCredit);
	}
	
	if(total_debit != total_credit){
		$.messager.alert('Unseccessfull','Account Tidak Balance','error');
		return false;
	} else {
		//$("#fm_journal_voucher").submit();
		edit_data('<?php echo"$menu_link"; ?>', '#fm_journal_voucher','1');
	}
}

$.extend($.fn.datagrid.defaults.editors, {
	Debit: {
		init: function(container, options){
			var input = $('<input type="text" class="Debit" />').appendTo(container);
			return input.validatebox(options);
		},
		destroy: function(target){
			$(target).remove();
		},
		getValue: function(target){
			 return $(target).val();
		},
		setValue: function(target, value){
			  $(target).val(value);
		},
		resize: function(target, width){
			   $(target)._outerWidth(width);
		}
	},
	Credit: {
		init: function(container, options){
			var input = $('<input type="text" class="Credit" />').appendTo(container);
			return input.validatebox(options);
		},
		destroy: function(target){
			$(target).remove();
		},
		getValue: function(target){
			 return $(target).val();
		},
		setValue: function(target, value){
			  $(target).val(value);
		},
		resize: function(target, width){
			   $(target)._outerWidth(width);
		}
	},
	Rate: {
		init: function(container, options){
			var input = $('<input type="text" class="Rate" />').appendTo(container);
			return input.validatebox(options);
		},
		destroy: function(target){
			$(target).remove();
		},
		getValue: function(target){
			 return $(target).val();
		},
		setValue: function(target, value){
			  $(target).val(value);
		},
		resize: function(target, width){
			   $(target)._outerWidth(width);
		}
	},
	AccountName: {
		init: function(container, options){
			var input = $('<input type="text" class="AccountName" onClick="open_account_journal()" style="height:18px;" readonly/>').appendTo(container);
			return input.validatebox(options);
		},
		destroy: function(target){
			$(target).remove();
		},
		getValue: function(target){
			 return $(target).val();
		},
		setValue: function(target, value){
			  $(target).val(value);
		},
		resize: function(target, width){
			   $(target)._outerWidth(width);
		}
	},
	AccountNumber: {
		init: function(container, options){
			var input = $('<input type="text" class="AccountNumber" style="height:18px;"/>').appendTo(container);
			return input.validatebox(options);
		},
		destroy: function(target){
			$(target).remove();
		},
		getValue: function(target){
			 return $(target).val();
		},
		setValue: function(target, value){
			  $(target).val(value);
		},
		resize: function(target, width){
			   $(target)._outerWidth(width);
		}
	},
	AccountSubTypeID: {
		init: function(container, options){
			var input = $('<input type="text" class="AccountSubTypeID" style="height:18px;"/>').appendTo(container);
			return input.validatebox(options);
		},
		destroy: function(target){
			$(target).remove();
		},
		getValue: function(target){
			 return $(target).val();
		},
		setValue: function(target, value){
			  $(target).val(value);
		},
		resize: function(target, width){
			   $(target)._outerWidth(width);
		}
	},
	CurrencyCode: {
		init: function(container, options){
			var input = $('<input type="text" class="CurrencyCode" style="height:18px;" />').appendTo(container);
			return input.validatebox(options);
		},
		destroy: function(target){
			$(target).remove();
		},
		getValue: function(target){
			 return $(target).val();
		},
		setValue: function(target, value){
			  $(target).val(value);
		},
		resize: function(target, width){
			   $(target)._outerWidth(width);
		}
	},
});
	
$(document).ready(function(){
	
	
	
	$('#dtg_journal_voucher').datagrid({
		onLoadSuccess:function(){
			dg_item = $('#dtg_journal_voucher').datagrid('getRows');
			
			$.each(dg_item, function( index, value ) {
				if(cek_data == 1){
					amount = parseInt(value.Debit) * parseInt(value.Rate);
					amount2 = parseInt(value.Credit) * parseInt(value.Rate);
					$(value.TotRateDebet).val(amount);
					$(value.TotRateCredit).val(amount2);
				}
				else{
					amount = parseInt(value.Debit) * parseInt(value.Rate);
					amount2 = parseInt(value.Credit) * parseInt(value.Rate);
					$(value.TotRateDebet).val(amount);
					$(value.TotRateCredit).val(amount2);
				}
            });
		},
		onBeginEdit:function(rowIndex){
			editors = $('#dtg_journal_voucher').datagrid('getEditors',rowIndex);
			debet		= $(editors[0].target);
			credit		= $(editors[1].target);
			rate		= $(editors[2].target);
			TotRateDebet	= $(editors[3].target);
			TotRateCredit	= $(editors[4].target);
			sub_type		= $(editors[6].target);
			currency		= $(editors[8].target);
			var cek_data = $('#cek_data').val();
			currency_code 	= $(currency).val();
			
			if(currency_code == 'IDR' || currency_code == ""){
				$('.Rate').prop('readonly', true);
				$('.Rate').val(1);
			}
			else if(currency_code != 'IDR' || currency_code != ""){
				$('.Rate').prop('readonly', false);
			}
			
			rate.numberbox({
				onChange:function(){
					debet_val 	= $(debet).val();
					credit_val 	= $(credit).val();
					sub_type 	= $(sub_type).val();
					rate_2 		= $(rate).val();
					rate_val 	= $(rate).numberbox('getValue');
					$('#app_dir').linkbutton('disable', true);
					$('#app_mgr').linkbutton('disable', true);
					
					if(cek_data == 1){
						amount = parseInt(debet_val) * parseInt(rate_val);
						amount2 = parseInt(credit_val) * parseInt(rate_val);
						$(TotRateDebet).val(amount);
						$(TotRateCredit).val(amount2);
					}
					else{
						amount = parseInt(debet_val) * parseInt(rate_val);
						amount2 = parseInt(credit_val) * parseInt(rate_val);
						$(TotRateDebet).val(amount);
						$(TotRateCredit).val(amount2);
					}
					
				}
			}),
			debet.numberbox({
				onChange:function(){
					debet_val 	= $(debet).val();
					credit_val 	= $(credit).val();
					sub_type 	= $(sub_type).val();
					rate_2 		= $(rate).val();
					rate_val 	= $(rate).numberbox('getValue');
					$('#app_dir').linkbutton('disable', true);
					$('#app_mgr').linkbutton('disable', true);
					
					if(cek_data == 1){
						amount = parseInt(debet_val) * parseInt(rate_val);
						amount2 = parseInt(credit_val) * parseInt(rate_val);
						$(TotRateDebet).val(amount);
						$(TotRateCredit).val(amount2);
					}
					else{
						amount = parseInt(debet_val) * parseInt(rate_val);
						amount2 = parseInt(credit_val) * parseInt(rate_val);
						$(TotRateDebet).val(amount);
						$(TotRateCredit).val(amount2);
					}
					
				}
			}),
			credit.numberbox({
				onChange:function(){
					debet_val 	= $(debet).val();
					credit_val 	= $(credit).val();
					sub_type 	= $(sub_type).val();
					rate_2 		= $(rate).val();
					rate_val 	= $(rate).numberbox('getValue');
					$('#app_dir').linkbutton('disable', true);
					$('#app_mgr').linkbutton('disable', true);
					
					if(cek_data == 1){
						amount = parseInt(debet_val) * parseInt(rate_val);
						amount2 = parseInt(credit_val) * parseInt(rate_val);
						$(TotRateDebet).val(amount);
						$(TotRateCredit).val(amount2);
					}
					else{
						amount = parseInt(debet_val) * parseInt(rate_val);
						amount2 = parseInt(credit_val) * parseInt(rate_val);
						$(TotRateDebet).val(amount);
						$(TotRateCredit).val(amount2);
					}
					
				}
			});
		}
	});
	
	$('#fm_journal_voucher').click(function(){
		$('#dtg_journal_voucher').edatagrid('saveRow');
	});
	
});

function suspend(type){
	suspend_data_new('F', type, '<?=$menu_link?>', $('#txt_voucher_no').val(), 'Journal Voucher');
}
</script>