<%
  projects ||= []
  hidden ||= false
  show_archived ||= false
  uniq_prefix ||= 'easy_trial_expiration_'
%>
<div id="project_selection" class="<%= hidden ? 'hidden' : '' %>">
<table style="border:1px solid #cbc8cd;" class="list entities projects easy-trial-expiration__table projects" data-url="<%= easy_trial_expiration_projects_path(show_archived ? {archived: 1} : {}) %>">
  <tbody>
    <% Project.each_with_easy_level(projects) do |project, level| %>
      <% classes = ''%>
      <% classes << "idnt idnt-#{level}" if level > 0 %>
      <% classes << " #{uniq_prefix}parentproject_#{project.parent_id}" if project.child? -%>
      <tr class="easy-trial-expiration__row <%= classes %>" data-level="<%= level %>">
        <% has_expander = !project.leaf? && (show_archived ? project.descendants.find { |d| d.status == Project::STATUS_ARCHIVED } : project.descendants.find { |d| d.status != Project::STATUS_ARCHIVED } ) %>
        <td class="name <%= 'has-expander' if has_expander %>">
          <div class="row-control">
            <% if has_expander %>
              <%= project_parent_plus_button(project.id, uniq_prefix) %>
            <% else %>
              <span class="expander-placeholder"></span>
            <% end -%>
          </div>
          <%= project.name %>
        </td>
        <td>
          <%=
            if show_archived
              if project.archived?
                check_box_tag('active[project_ids][]', project.id, false, id: nil, 'data-parent_id' => project.parent_id)
              else
                content_tag(:i, '', title: l('easy_trial_expiration.label_project_is_active'), class: 'icon icon-checked')
              end
            else
              check_box_tag('active[project_ids][]', project.id, false, id: nil, 'data-parent_id' => project.parent_id)
            end
          %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
</div>
