Newer
Older
dmpopidor / app / views / public_pages / plan_export.pdf.erb
<!DOCTYPE html>
<html>
  <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <title>
          <%= @plan.title %>
      </title>
      <style>
          html { font-family: <%= @formatting[:font_face].tr('"', '') -%>; font-size: <%= @formatting[:font_size] -%>pt; }
          h1 { font-size: <%= @formatting[:font_size] + 2 -%>pt; font-face:bold; padding: 0;}
          h2 { font-size: <%= @formatting[:font_size] + 1 -%>pt; font-face:bold; padding: 0; margin: 1em 0 0 0;}
          h3 { font-size: <%= @formatting[:font_size] + 0 -%>pt; font-face:bold; padding: 0; margin: 1em 0 0 0;}
          h2 + div.question > h3 { margin: 0; }
          table, tr, td, th, tbody, thead, tfoot { page-break-inside: avoid !important; }
          table { border-collapse: collapse; }
          th, td { border: 1px solid black !important; padding: 2px; }
          p { margin: 0.25em 0; }
      </style>
  </head>
  <body>
    <div style="text-align:center;">
      <h1><%= @plan.title %></h1>
      <p><em><%= _("A Data Management Plan created using ") + Rails.configuration.branding[:application][:name] + "." %></em></p>
    </div>
    </br>
    <p><%= _("Creator(s): ") + @creator_text %></p>    <br>
    <p><%= _("Affiliation: ") + @affiliation %></p>    <br>
    <% if @funder.present? %>
      <p><%= _("Funder: ") + @funder %></p>   <br>
    <% else %>
      <p><%= _("Template: ") + @template + @customizer %></p> <br>
    <% end %>
    <% if @plan.grant_number.present? %>
      <p><%= _("Grant Number: ") + @plan.grant_number %></p> <br>
    <% end %>
    <% if @plan.description.present? %>
      <p><%= _("Description: ") + @plan.description %></p> <br>
    <% end %>
    <p><%= _("Last Updated: ") + @plan.updated_at.to_date.to_s %></p> <br>

		<p><%= _("Copyright information: The above plan creator(s) have agreed that others may use as much of the text of this plan as they would like in their own plans, and customise it as necessary. You do not need to credit the creator(s) as the source of the language used, but using any of the plan's text does not imply that the creator(s) endorse, or have any relationship to, your project or proposal") %></p>
    <% @phases.each do |phase| %>
      <div style="page-break-before:always;"></div> <!-- Page break before each phase -->
      <h1><%= phase.title %></h1>
      <% Section.where(phase_id: phase.id, id: @a_s_ids).order(:number).each do |section| %>
        <h2><%= section.title %></h2>
        <% Question.where(section_id: section, id: @a_q_ids).order(:number).each do |question| %>
          <div class="question">
            <h3><%= raw question.text %></h3>
            <% answer = @plan.answer(question.id, false) %>
            <% if answer.nil? %>
              <p><%= _('Question not answered.') -%></p>
            <% else %>
              <% q_format = question.question_format %>
              <% if q_format.option_based? %>
                <ul>
                <% answer.question_options.each do |option| %>
                  <li><%= option.text %></li>
                <% end %>
                </ul>
                <!-- Validates if this question has comments-->
                <% if question.option_comment_display == true %>
                  <% if !answer.text.nil? %>
                    <%= raw answer.text.gsub(/<tr>(\s|<td>|<\/td>|&nbsp;)*(<\/tr>|<tr>)/,"") %>
                  <% end %>
                <% end %>
              <% else %>
                <!-- display an answer for questions type 'text area' and 'text field'-->
                <% if !answer.text.nil?  %>
                  <%= raw answer.text.gsub(/<tr>(\s|<td>|<\/td>|&nbsp;)*(<\/tr>|<tr>)/,"") %>
                <% end %>
              <% end %>
            <% end %>
          </div>
        <% end %>
      <% end %>
    <% end %>
  </body>
</html>