<%= stylesheet_link_tag 'wk-time', :plugin => "redmine_wktime" %>
<% show_on_map = session[controller_name].try(:[], :show_on_map) %>
<div class="autoscroll">

	<table class="list time-entries" style="width:<%= !show_on_map ? "100%" : "35%" %>; float:left;">
		<thead>
			<tr>
				<%= sort_header_tag('name', :caption => l(:field_name), class: "lbl-txt-align", style:(show_on_map ? "width:30%" : "")) %>
				<%= sort_header_tag('type', :caption => l(:field_type), class: "lbl-txt-align", style:(show_on_map ? "width:30%" : "")) %>
				<% if !show_on_map %>
					<th class="lbl-txt-align"><%= l(:label_account_address1)   %></th>
				<% end %>
				<%= sort_header_tag('city', :caption => l(:label_city), class: "lbl-txt-align", style:(show_on_map ? "width:15%" : "")) %>
				<%= sort_header_tag('state', :caption => l(:label_state), class: "lbl-txt-align", style:(show_on_map ? "width:15%" : "")) %>
				<% if !show_on_map %>
					<th class="lbl-txt-align"><%= l(:field_is_default)   %></th>
					<th class="lbl-txt-align"><%= l(:label_main_location)   %></th>
				<% end %>
				<th  style='<%= show_on_map ? "width:10%" : "" %>'></th>
			</tr>
		</thead>
		<tbody>
		<% @locationObj.each do |entry| %>
			<tr>
				<td class="lbl-txt-align"><%=h entry.name  %></td>
				<td class="lbl-txt-align"><%=h entry.location_type.name unless entry.location_type.blank?  %></td>
				<% if !show_on_map %>
					<td class="lbl-txt-align"><%=h entry.address.blank? ? nil : entry.address.address1  %></td>
				<% end %>
				<td class="lbl-txt-align"><%=h entry.address.blank? ? nil : entry.address.city  %></td>
				<td class="lbl-txt-align"><%=h entry.address.blank? ? nil : entry.address.state  %></td>
				<% if !show_on_map %>
					<td class="lbl-txt-align"><%=h  checked_image entry.is_default?  %></td>
					<td class="lbl-txt-align"><%=h  checked_image entry.is_main?  %></td>
				<% end %>
				<td class="lbl-txt-align"><%= link_to image_tag('edit.png'), {:controller => controller_name, :action => 'edit', :location_id => entry.id, id: entry.id, :tab => 'wklocation'}, :title => l(:button_edit) %>
								<%= link_to image_tag('delete.png'), {:controller => controller_name, :action => 'destroy', :location_id => entry.id, id: entry.id, :tab => 'wklocation'},  :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
			</tr>
		<% end %>
		</tbody>
	</table>

	<% if show_on_map %>
		<%= render partial: "wkgeolocation/show_on_map", locals: { entries: @locationObj, model: "address", height: '94%', width: '64%'} %>
	<% end %>
</div>