<%
	require_relative './report_payroll'
	user_id = session[controller_name].try(:[], :user_id).blank? ? 0 : session[controller_name].try(:[], :user_id)
	from = session[controller_name].try(:[], :from)
	to = session[controller_name].try(:[], :to)
	group_id = session[controller_name].try(:[], :group_id).blank?  ? 0 : session[controller_name].try(:[], :group_id)
	projId = session[controller_name].try(:[], :project_id)

	helperObj = Object.new.extend(ReportPayroll)
	data = helperObj.calcReportData(user_id, group_id, projId, from, to)
%>
<%= stylesheet_link_tag 'application' , :media => "all" %>
<%= stylesheet_link_tag 'wk-time', :plugin => "redmine_wktime" %>

<style type="text/css">		
		.tbl-report{
			width : 2200px;
			table-layout: fixed; !important;
			word-wrap: break-word; !important;
			text-align: center; 
			margin-top:5px; margin-bottom:10px; padding-left: 10px; color:#333333;
			font-family:Verdana, sans-serif; font-size:12px; 
		}
 </style>
<div id="wages-rpt-dlg", style="overflow-x:auto;">
<div>
		<div style="float:left">
 <caption style="text-align:left"><b><%= l(:label_wk_form_r) %><br/><%= l(:label_register_wages) %><br/><%= l(:label_wages_rule) %></b></br>
 <b><%= l(:label_wk_name_address) %>:</b> <%= getMainLocation %>
 <%= getAddress %>
 <b><%= l(:label_wages_period) %>:</b> <%= data[:period] %>
  </caption> 
  </div>
		<div style="float:right">
			<table>
				<tr>
					<td>
						<% attachment = WkLocation.getMainLogo() %>
						<% if attachment.present? %>
							<%= image_tag(download_location_attachment_path(attachment, attachment.filename), class: 'filecontent image') %>
						<% end %>
					</td>
				</tr>
			</table>
		</div>
		</div>
		<div style="clear:both;"></div>
<table class="tbl-report" border="1" style="border-collapse:collapse;" cellspacing="0",frame="box">
<% count = 0 %>  
 <thead style="background-color:#e6e6e6;">
 <tr>
		<% data[:headerarr].each do |entry| %>	
		  <th><%= entry %> </th>
		<% end %>
 </tr>
 </thead>
 <tbody>
 <% data[:rowval].each do |key, value| %>
	<tr class="<%= cycle("odd", "even") %>">
		<% value.each do |k,v| %>
			<td> <%= v.to_s %> </td>
		<% end %>
	</tr>
 <% end %>
 <tr>
	<th colspan=<%=data[:usercol].length%>> <%= l(:label_total) %> </th>
		<% data[:headerarr].each_with_index do |entry, index| %>
			<% unless data[:usercol].length > index %>
				<th><%= data[:compTotalHash][entry] %> </th> 
			<% end %>
		<% end %>
 </tr>
 </tbody>
 </table>
 </div>