
<% @ledgers = ["", ""] %> 
<% @ledgers << WkLedger.order(:name).pluck(:name, :id) %> 
<%  ledgerhash = Hash[*@ledgers.flatten].invert %>
<div class="splitcontent">
<div class="splitcontentleft">
<fieldset>
	<legend><%= l(:label_purchasing) %></legend>
	<p>
			<%= check_box_tag('settings[supplier_invoice_auto_post_gl]', 1, @settings['supplier_invoice_auto_post_gl'].to_i == 1) %> <label><%= l(:label_auto_post_gl) %></label>
	</p>
	
	<p><label><%= l(:label_credit_with_ledger)  %></label>
	    <%= select_tag 'settings[supplier_invoice_cr_ledger]', options_for_select(ledgerhash.invert, :selected => @settings['supplier_invoice_cr_ledger']) %></p>
	
	<p><label><%= l(:label_debit_with_ledger)  %></label>
	    <%= select_tag 'settings[supplier_invoice_db_ledger]', options_for_select(ledgerhash.invert, :selected => @settings['supplier_invoice_db_ledger']) %></p>
	
	<p><label><%= l(:label_txn_payment_with_credit_with_ledger)  %></label>
	    <%= select_tag 'settings[supplier_payment_cr_ledger]', options_for_select(ledgerhash.invert, :selected => @settings['supplier_payment_cr_ledger']) %></p>
	
	<p><label><%= l(:label_txn_payment_with_debit_with_ledger)  %></label>
	    <%= select_tag 'settings[supplier_payment_db_ledger]', options_for_select(ledgerhash.invert, :selected => @settings['supplier_payment_db_ledger']) %></p>
	
	<p>
		  <label><%= l(:label_quote_number_prefix) %></label><%= text_field_tag 'settings[wktime_quote_no_prefix]', @settings['wktime_quote_no_prefix'], :size => 13 %> 
	</p>
	
	<p>
		  <label><%= l(:label_po_number_prefix) %></label><%= text_field_tag 'settings[wktime_po_no_prefix]', @settings['wktime_po_no_prefix'], :size => 13 %> 
	</p>
	
	<p>
		  <label><%= l(:label_si_number_prefix) %></label><%= text_field_tag 'settings[wktime_si_no_prefix]', @settings['wktime_si_no_prefix'], :size => 13 %> 
	</p>
	
	<p>	
		  <%= check_box_tag('settings[label_create_supplier_invoice_without_purchase_order]', 1, @settings['label_create_supplier_invoice_without_purchase_order'].to_i == 1)%> <label><%= l(:label_create_supplier_invoice_without_purchase_order) %> </label>
	</p>
	
</fieldset>
</div>

<div class="splitcontentright">
<fieldset>
	<fieldset>
		<legend><%= l(:label_quote_components) %></legend>
		<p>
		<%
			invComps = []
			if(@settings['wktime_quote_components'].blank?)
				invComps = ''
			else
				@settings['wktime_quote_components'].each do |element|
				  listboxArr = element.split('|')
				  invCompName = listboxArr[0].blank? ? "" : listboxArr[0]
				  invCompVal = listboxArr[1].blank? ? "" : listboxArr[1]
				  optionText = invCompName + ' : ' + invCompVal
				  invComps << [optionText,element]
				end
			end
		%>
			<label><%= l(:label_quote_components) %></label>
				<%=  select_tag('settings[wktime_quote_components]',
					options_for_select(invComps, :selected => 'settings[wktime_quote_components]'), :multiple=> true, :style => "min-width:140px; height:100px;")%>	

			</p>			
			<p>
				<%= link_to l(:button_add), "javascript:showInvCompDialog('Add', 'settings_wktime_quote_components');", :class => "button"%>  |
				<%= link_to l(:button_edit), "javascript:showInvCompDialog('Edit', 'settings_wktime_quote_components');", :class => "button"%>  |
				<%= link_to l(:button_delete), "javascript:removeSelectedValue('settings_wktime_quote_components');", :class => "button" %>
			</p>
		
		
	</fieldset>
	<fieldset>
		<legend><%= l(:label_po_components) %></legend>
		<p>
		<%
			invComps = []
			if(@settings['wktime_po_components'].blank?)
				invComps = ''
			else
				@settings['wktime_po_components'].each do |element|
				  listboxArr = element.split('|')
				  invCompName = listboxArr[0].blank? ? "" : listboxArr[0]
				  invCompVal = listboxArr[1].blank? ? "" : listboxArr[1]
				  optionText = invCompName + ' : ' + invCompVal
				  invComps << [optionText,element]
				end
			end
		%>
			<label><%= l(:label_po_components) %></label>
				<%=  select_tag('settings[wktime_po_components]',
					options_for_select(invComps, :selected => 'settings[wktime_po_components]'), :multiple=> true, :style => "min-width:140px; height:100px;")%>	

			</p>			
			<p>
				<%= link_to l(:button_add), "javascript:showInvCompDialog('Add', 'settings_wktime_po_components');", :class => "button"%>  |
				<%= link_to l(:button_edit), "javascript:showInvCompDialog('Edit', 'settings_wktime_po_components');", :class => "button"%>  |
				<%= link_to l(:button_delete), "javascript:removeSelectedValue('settings_wktime_po_components');", :class => "button" %>
			</p>
		
		
	</fieldset>
	<fieldset>
		<legend><%= l(:label_si_components) %></legend>
		<p>
		<%
			invComps = []
			if(@settings['wktime_si_components'].blank?)
				invComps = ''
			else
				@settings['wktime_si_components'].each do |element|
				  listboxArr = element.split('|')
				  invCompName = listboxArr[0].blank? ? "" : listboxArr[0]
				  invCompVal = listboxArr[1].blank? ? "" : listboxArr[1]
				  optionText = invCompName + ' : ' + invCompVal
				  invComps << [optionText,element]
				end
			end
		%>
			<label><%= l(:label_si_components) %></label>
				<%=  select_tag('settings[wktime_si_components]',
					options_for_select(invComps, :selected => 'settings[wktime_si_components]'), :multiple=> true, :style => "min-width:140px; height:100px;")%>	

			</p>			
			<p>
				<%= link_to l(:button_add), "javascript:showInvCompDialog('Add', 'settings_wktime_si_components');", :class => "button"%>  |
				<%= link_to l(:button_edit), "javascript:showInvCompDialog('Edit', 'settings_wktime_si_components');", :class => "button"%>  |
				<%= link_to l(:button_delete), "javascript:removeSelectedValue('settings_wktime_si_components');", :class => "button" %>
			</p>
		
		
	</fieldset>	
</fieldset>
</div>
</div>