<%= stylesheet_link_tag 'wk-time', :plugin => "redmine_wktime" %>
<% opportunityHelper = Object.new.extend(WkopportunityHelper) %>
<%  salestagehash = opportunityHelper.getSaleStageHash %>
<div class="autoscroll">
<table class="list time-entries">
  <thead>
      <% if action_name == 'index' %>
         <tr>
				<%= sort_header_tag('opportunity_name', :caption => l(:field_name), class: "lbl-txt-align") %>
				<%= sort_header_tag('parent_type', :caption => l(:label_relates_to), class: "lbl-txt-align") %>
				<%= sort_header_tag('sales_stage', :caption => l(:label_txn_sales_stage), class: "lbl-txt-align") %>
				<%= sort_header_tag('amount', :caption => l(:field_amount), class: "lbl-txt-align") %>
				<%= sort_header_tag('close_date', :caption => l(:label_expected_date_to_close_project), class: "lbl-txt-align") %>
				<%= sort_header_tag('assigned_user_id', :caption => l(:field_assigned_to), class: "lbl-txt-align") %>
				<%= sort_header_tag('updated_at', :caption => l(:label_modified).capitalize, class: "lbl-txt-align") %>
				<th></th>
         </tr>
      <% else %>
         <tr>
				<th class="lbl-txt-align"><%= l(:field_name) %></th>
				<th class="lbl-txt-align"><%= l(:label_relates_to) %></th>
				<th class="lbl-txt-align"><%=  l(:label_txn_sales_stage) %></th>
				<th class="lbl-txt-align"><%=  l(:field_amount) %></th>
				<th class="lbl-txt-align"><%=  l(:label_expected_date_to_close_project) %></th>
				<th class="lbl-txt-align"><%=  l(:field_assigned_to) %></th>
				<th class="lbl-txt-align"><%= l(:label_modified).capitalize %></th>
				<th></th>
         </tr>
	  <% end %>
  </thead>
   <tbody>
	<% opportunities.each do |entry| %>
		<tr>
		    <td class="lbl-txt-align"><%=h entry.name  %></td>
		<!--	<td class="lbl-txt-align"><%#=h entry.parent.name unless entry.parent.blank? %></td> -->
			<td class="lbl-txt-align"><%=h relatedHash[entry.parent_type] %></td>
			<td class="lbl-txt-align"><%=h opportunityHelper.get_sales_stage(entry).blank? ? "" : salestagehash[opportunityHelper.get_sales_stage(entry)] %></td>
			<td class="lbl-txt-align"><%=h entry.currency + " "  %><%=h html_hours("%.2f" % entry.amount) %></td>
			<td class="lbl-txt-align"><%=h entry.close_date.localtime.strftime("%Y-%m-%d") %></td>
			<td class="lbl-txt-align"><%=h entry.assigned_user.name(:firstname_lastname)  unless entry.assigned_user.blank? %></td>
			<td class="lbl-txt-align"><%=h entry.updated_at.localtime.strftime("%Y-%m-%d") %></td>
			<td class="lbl-txt-align"><%= link_to image_tag('edit.png'), {:controller => 'wkopportunity', :action => 'edit', :opp_id => entry.id, :tab => 'wkopportunity', id: entry.id}, :title => l(:button_edit) %>
							<%= link_to image_tag('delete.png'), {:controller => 'wkopportunity', :action => 'destroy', :opp_id => entry.id, :tab => 'wkopportunity', id: entry.id},  :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
		</tr>
	<% end %>
   </tbody>
</table>
</div>