<% content_for :head do %>
  <meta name="turbolinks-cache-control" content="no-cache">
<% end %>

<%= stylesheet_link_tag 'datatables' %>

<% if params[:preview_report_id] %>
  <%= hidden_field_tag :show_report_preview, nil, class: "file-preview-link", data: { preview_url: document_preview_report_path(params[:preview_report_id], report_type: params[:preview_type]) } %>
<% end %>

<div class="content-pane flexible reports-index">
  <%= render partial: 'reports/index_header' %>
  <div id="content-reports-index">
    <div class="row">
      <div class="col-md-12">
        <div class="reports-datatable">
          <table id="reports-table"
                 class="table"
                 data-source="<%= reports_datatable_path(format: :json) %>">
            <thead>
              <tr>
                <th id="select-all">
                  <div class="sci-checkbox-container">
                    <input name="select_all" type="checkbox" class="sci-checkbox">
                    <span class="sci-checkbox-label"></span>
                  </div>
                </th>
                <th id="project-name"><%= t('projects.reports.index.thead_project_name') %></th>
                <th id="report-name"><%= t('projects.reports.index.thead_name') %></th>
                <th id="report-pdf"><%= t('projects.reports.index.pdf') %></th>
                <th id="report-docx"><%= t('projects.reports.index.docx') %></th>
                <th id="report-created-by"><%= t('projects.reports.index.thead_created_by') %></th>
                <th id="report-last-modified-by"><%= t('projects.reports.index.thead_last_modified_by') %></th>
                <th id="report-created-at"><%= t('projects.reports.index.thead_created_at') %></th>
                <th id="report-updated-at"><%= t('projects.reports.index.thead_updated_at') %></th>
              </tr>
            </thead>
            <tbody></tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- Save report modal -->
<div class="modal" id="delete-reports-modal" tabindex="-1" role="dialog" aria-labelledby="delete-reports-modal-label">
  <%= bootstrap_form_tag url: reports_destroy_path, method: :post, id: "delete-reports-form" do |f| %>
    <input type="hidden" name="report_ids" id="report-ids">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="delete-reports-modal-label"><%=t "projects.reports.index.modal_delete.head_title" %></h4>
        </div>
        <div class="modal-body">
          <%=t "projects.reports.index.modal_delete.message" %>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.cancel" %></button>
          <%= f.button t("projects.reports.index.modal_delete.delete"), class: "btn btn-danger", id: "confirm-delete-reports-btn", name: nil %>
        </div>
      </div>
    </div>
  <% end %>
</div>

<%= render partial: 'reports/modals/regenerate' %>

<%= javascript_include_tag 'reports/save_pdf_to_inventory' %>
<%= javascript_include_tag 'reports/reports_datatable' %>
<%= javascript_pack_tag 'pdfjs/pdf_js' %>
<%= stylesheet_pack_tag 'pdfjs/pdf_js_styles' %>
