<% title "#{current_user.org.name} Plans" %>
<div class="row org-admin">
  <div class="col-md-12">    
    <h1><%= _('%{org_name} Plans') % { org_name: current_user.org.name } %></h1>
  </div>
</div>

<div class="row org-admin">
  <div class="col-md-12">
    <% if @feedback_plans.length > 0 %>
      <h2><%= _('Notifications') %></h2>
      <div class="panel panel-default">
        <div class="panel-body notifications">
          <table class="table">
            <thead>
              <th scope="col"><%= _('Plan') %></th>
              <th scope="col"><%= d_('dmpopidor', 'Template') %></th>
              <th scope="col"><%= _('Requestor') %></th>
              <th scope="col"><%= _('Type') %></th>
              <th scope="col"><%= _('Actions') %></th>
            </thead>
            <tbody>
              <% @feedback_plans.each do |notice| %>
                <!-- Using the plan owner as the requestor even though it could have been issued by a co-owner -->
                <!-- TODO: correct this behavior once the notification table is in place -->
                <tr>
                  <td><%= link_to notice.name, plan_path(notice) %></td>
                  <td><%= notice.template.title %></td>
                  <td><%= notice.owner ? notice.owner.name(false) : "" %></td>
                  <td><%= _('Feedback requested') %></td>
                  <td><%= link_to _('Complete'), feedback_complete_org_admin_plan_path(notice), 'data-toggle': 'tooltip', title: _('Notify the plan owner that I have finished providing feedback') %></td>
                </tr>
              <% end %>
            </tbody>
          </table>
        </div>
      </div>
    <% end %>
    <% if @plans.length > 0 %>
      <%= paginable_renderise(
        partial: '/paginable/plans/org_admin',
        controller: 'paginable/plans',
        action: 'org_admin',
        scope: @plans,
        query_params: { sort_field: 'plans.updated_at', sort_direction: 'desc' }) %>
    <% end %>
  </div>
</div>
