<%
if has_role?(:user, @project)
- action_plans = ActionPlan.find(:all, :conditions => ['status= ? AND project_id=?', ActionPlan::STATUS_OPEN, @project.id],
- :include => 'reviews', :order => 'dead_line ASC')
+ open_action_plans = ActionPlan.find(:all, :conditions => ['status= ? AND project_id=?', ActionPlan::STATUS_OPEN, @project.id],
+ :include => 'reviews', :order => 'dead_line ASC')
+ closed_action_plans = ActionPlan.find(:all, :conditions => ['status= ? AND project_id=?', ActionPlan::STATUS_CLOSED, @project.id],
+ :include => 'reviews', :order => 'dead_line ASC')
div_id = "action-plan-widget-#{widget.id.to_s}"
%>
<div class="line-block">
+ <% if has_role?(:admin, @project) %>
<div style="float:right">
<a href="<%= url_for :controller => 'action_plans', :action => 'index', :id => @project.id -%>">
<%= message('widgets.more') -%>
</a>
</div>
+ <% end %>
+
<h3><%= message('widget.action_plans.title') -%></h3>
</div>
-<% if action_plans.size ==0 %>
- <span class="empty_widget"><%= message('widget.action_plans.no_action_plan') -%></span>
-<% else %>
<div id="<%= div_id -%>">
+
+<% if open_action_plans.size ==0 %>
+ <span class="empty_widget"><%= message('widget.action_plans.no_action_plan') -%></span>
+<% else %>
<table class="width100 data actionPlans">
<thead>
<tr>
</thead>
<tbody>
<%
- action_plans.each do |plan|
+ open_action_plans.each do |plan|
%>
<tr class="<%= cycle 'even', 'odd', :name => (div_id) -%>">
<td class="thin nowrap"><%= h(plan.name) -%></td>
- <td class="thin nowrap <%= 'over-due' if plan.over_due? -%>" align="right" x="<%= plan.dead_line ? plan.dead_line.tv_sec : '' -%>"><%= plan.dead_line ? plan.dead_line.strftime("%d %b %Y") : ' ' -%></td>
+ <td class="thin nowrap <%= 'over-due' if plan.over_due? -%>" align="right"><%= plan.dead_line ? plan.dead_line.strftime("%d %b %Y") : ' ' -%></td>
+ <% if plan.progress[:total]==0 %>
+ <td class="noprogress thin nowrap"><%= message('action_plans.no_reviews_linked_to_action_plan') -%></td>
+ <% else %>
+ <td class="progress thin">
+ <%= render :partial => 'action_plans/progress', :locals => {:action_plan => plan} -%>
+ </td>
+ <% end %>
+ </tr>
+ <%
+ end
+ %>
+ </tbody>
+ </table>
+<% end %>
+
+<%
+ unless closed_action_plans.size ==0
+ table_id = "closed-action-plan-table-#{widget.id.to_s}"
+ link_id = "closed-action-plan-link-#{widget.id.to_s}"
+%>
+ <script type="text/javascript">
+ function displayClosedActionPlans() {
+ var table = $('<%= table_id -%>');
+ var link = $('<%= link_id -%>');
+ if (table.visible()) {
+ table.hide();
+ link.update("<%= message('widget.action_plans.show_closed_action_plans') -%>");
+ } else {
+ table.show();
+ link.update("<%= message('widget.action_plans.hide_closed_action_plans') -%>");
+ }
+ }
+ </script>
+ <div style="margin-top:10px; font-size:93%"><a href="#" onclick="displayClosedActionPlans();" id ="<%= link_id -%>"><%= message('widget.action_plans.show_closed_action_plans') -%></a></div>
+ <table class="width100 data actionPlans" style="display:none" id="<%= table_id -%>">
+ <thead>
+ <tr>
+ <th colspan="3"></th>
+ </tr>
+ </thead>
+ <tbody>
+ <%
+ closed_action_plans.each do |plan|
+ %>
+ <tr class="<%= cycle 'even', 'odd', :name => (div_id+'closed') -%>">
+ <td class="thin nowrap"><%= h(plan.name) -%></td>
+ <td class="thin nowrap" align="right"><%= plan.dead_line ? plan.dead_line.strftime("%d %b %Y") : ' ' -%></td>
<% if plan.progress[:total]==0 %>
<td class="noprogress thin nowrap"><%= message('action_plans.no_reviews_linked_to_action_plan') -%></td>
<% else %>
%>
</tbody>
</table>
-</div>
-
<% end %>
+
+</div>
<% end %>