<%= title l(:label_ledger) %>
<%= render partial: "wkgltransaction/render_accounting_tabs" %>

<% wkaccounting_helper = Object.new.extend(WkaccountingHelper) %>
<% ledgerType = wkaccounting_helper.getLedgerTypeHash
 ledgerType = {'' =>  ""}.merge(ledgerType) %>
<%= form_tag({:controller => controller_name, :action => 'index'}, :method => :get, :id => 'query_form') do %>
	<%= hidden_field_tag "searchlist", "#{controller_name}" %>
	<%=h hidden_field_tag('tab', controller_name) %>
	<%	ledger_type =session[:wkledger].try(:[], :ledger_type) %>
	<%	ledgername =session[:wkledger].try(:[], :name) %>
	<fieldset>
		<% if validateERPPermission("A_ACC_PRVLG") %>
			<div style="float:right">
				<%= link_to l(:label_new_ledger), url_for(:controller => controller_name, :action => 'edit'), :class => 'icon icon-add' %>
			</div>
		<% end %>
		<table>
			<tr>
				<th><label><%= l(:field_name) %></label></th>
				<td><%= text_field_tag 'name', ledgername, :size => 30 %></td>
				<th><label style="padding-left: 10px;"><%= l(:field_type) %></label></th>
				<td><%=h select_tag("ledger_type", options_for_select(ledgerType.invert, :selected => ledger_type ), :style => "width:160px; ") %></td>
				<td><%= submit_tag l(:button_apply), :class => "small", :name => nil %></td>
				<td><%= link_to l(:button_clear), {:tab => controller_name, clear: true}, :class => 'icon icon-reload' %></td>
			</tr>
		</table>
	</fieldset>
<% end %>

<div class="total-hours">
	<p><%= l(:label_total) %>: &nbsp;<%= @ledgers[0].currency unless @ledgers[0].blank? || @ledgers[0].blank?%> <%= html_hours("%.2f" % @totalAmt) %></p>
</div>

<% if @ledgers.present? %>
	<%= render :partial => 'wkledger/ledger_list'%>
	<% other_formats_links do |f| %>
  	<%= f.link_to_with_query_parameters 'CSV', {} %>
	<% end %>
<% else %>
	<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>