<%
 componentHash = Hash.new
 total=0
 gross=0
 net=0
 key = params[:user_id] + "_" + params[:salary_date]
 firstName = @payrollEntries[key][:firstname] + ' ' + @payrollEntries[key][:lastname]
 salaryDate = @payrollEntries[key][:salDate]
 componentHash = @payrollDetails
%>
<div>
<h2><b><%=l(:label_salary_detail) %></b></h2>

<div>
<table>
	<tr>
		<td><b><%=l(:field_user)%></b></td>
		<td><%=h firstName %></td>
	</tr>
	<tr>
		<td><b><%=l(:label_salarydate)%></b></td>
		<td><%=h salaryDate %></td>
	</tr>
</table>
</div>
 <fieldset style="width: 94%;margin:1px 34px 0px 1px;background-color:#F6F6F6;float:right"><legend><b><%=l(:label_basic)%></b></legend>
	<table width="100px">
	<% componentHash[:b].each do |entry| %>
			<tr>
				<td><b><%=h entry[0]  %></b></td>
				<td><%=h entry[2]%><%=h "%.2f" % entry[1] %></td>
			</tr>
			<%gross=entry[1] %>
		<%end%>
	</table>
</fieldset>
	&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp

 <fieldset class="box tabular" style="display: inline-block; vertical-align: top; width:45%;"><legend><b><%=l(:label_allowances)%></b></legend>
	<table style="width:100%;border-collapse: collapse;" >
	<% total=0 %>
	<% componentHash[:a].each do |entry| %>
			<tr>
				<td style="border: 1px solid black;border-style: outset;border-collapse: collapse;background-color:white;"><b><%=h entry[0]  %></b></td>
				<td style="border: 1px solid black;border-collapse: collapse;border-style: inset;text-align:right;background-color:white;"><%=h entry[2]%> <%=h "%.2f" % entry[1] %></td>
			</tr>
			<% total=total+entry[1] %>

		<%end%>
		<%gross=gross+total%>
		<tr>
			<td style="border: 1px solid black;border-collapse: collapse;border-style: outset;background-color:white;"><b><%=l(:label_total) %></b></td>
			<td style="border: 1px solid black;border-collapse: collapse;border-style: inset;text-align:right;background-color:white;"><%=h  componentHash[:b][0][2] if componentHash[:b].present? %> <%=h "%.2f" % total %></td>
		</tr>
	</table>
</fieldset>
	&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp


  <fieldset class="box tabular" style="display: inline-block; vertical-align: top; width:45%; "><legend><b><%=l(:label_deduction)%></b></legend>
	<table style="width:100%;border-collapse: collapse;">
		<% total=0 %>
		<% componentHash[:d].each do |entry| %>
			<tr>
				<td style="border: 1px solid black;border-collapse: collapse;border-style: outset;background-color:white;"><b><%=h entry[0]  %></b></td>
				<td style="border: 1px solid black;border-collapse: collapse;border-style: inset;text-align:right;background-color:white;"><%=h entry[2]%> <%=h "%.2f" % entry[1] %></td>
			</tr>
			<% total=total+entry[1] %>
		<%end%>
		<%net=gross-total%>
			<tr>
				<td style="border: 1px solid black;border-collapse: collapse;border-style: outset;background-color:white;"><b><%=l(:label_total) %></b></td>
				<td style="border: 1px solid black;border-collapse: collapse;border-style: inset;text-align:right;background-color:white;"><%= componentHash[:b][0][2] if componentHash[:b].present? %> <%=h "%.2f" % total %></td>
			</tr>
	</table>
 </fieldset><br>
<% if componentHash[:r].present? %>
	<fieldset class="box tabular" style="display: inline-block; vertical-align: top; width:45%; "><legend><b><%=l(:label_reimbursements)%></b></legend>
		<table style="width:100%;border-collapse: collapse;">
			<% componentHash[:r].each do |entry| %>
				<tr>
					<td style="border: 1px solid black;border-collapse: collapse;border-style: outset;background-color:white;"><b><%=h entry[0]  %></b></td>
					<td style="border: 1px solid black;border-collapse: collapse;border-style: inset;text-align:right;background-color:white;"><%=h entry[2]%> <%=h "%.2f" % entry[1] %></td>
				</tr>
			<%end%>
		</table>
	</fieldset>
<% end %> <br>
	<div style="padding-right:50px;">
		<table width="15%" align="right" style="border-collapse: collapse;border: 0px solid black;">
			<tr>
				<td style="float:left; "><b><%=l(:label_gross) %></b></td>
				<td style="text-align:right; border-left: solid 0px black;"><%=h  componentHash[:b][0][2] if componentHash[:b].present? %> <%=h "%.2f" % gross%> </td>
			</tr>
			<tr>
				<td style="float:left;"><b><%=l(:label_net)%></b>
				<td style="text-align:right; border-left: solid 0px black;"><%=h  componentHash[:b][0][2] if componentHash[:b].present? %> <%=h "%.2f" % net%></td>
			</tr>
		</table>
	</div>

</div>
<% if !to_boolean(params[:isPreview]) && validateERPPermission('A_PAYRL') %>
	<div style="padding-top: 10px">
		<%= button_to l(:label_delete_payroll), { controller: "wkpayroll", action: "destroy", user_id: params[:user_id], salary_date: params[:salary_date] , tab: "payroll"}, method: :delete, data: { confirm: l(:text_are_you_sure) }%>
	</div>
<% end %>