[% PROCESS _header.tt js="plugins/${plugin_name}/reports-${fileversion}.js" %]
[% PROCESS _message.tt %]
[% USE date %]

[% PROCESS _infobox.tt %]

<form action="reports2.cgi" method="POST">
  <input type="submit" name="sub" value="sub" style="display:none"><!-- make enter submit the form -->
  <input type="hidden" name="action" value="email">
  <input type="hidden" name="send" value="1">
  <input type="hidden" name="report" value="[% r.nr %]">
  <input type="hidden" name="CSRFtoken" value="[% get_user_token(c) %]">
  <div class="grow flexcol gap-1 items-center">
    <h1 class="py-5">Send Report By Mail</h1>
    <div class="card w-[500px]">
      <div class="head gap-2">
        <a href="reports2.cgi" class="link hoverable rounded" title="Go back to report list"><i class="uil uil-angle-double-left text-2xl leading-6 mx-2"></i> </a>
        <h3 class="mightOverflowBlock">E-Mail: [% IF r.defined("var") && r.var.defined("name") %][% r.var.name | html %][% ELSE %][% r.name | html %][% END %]</h3>
      </div>
      <div class="body">
        <table class="w-full cellspacing">
          <tr>
            <th>Subject</th>
            <td><input type="text" name="subject" value="[% subject | html %]" class="w-full" required></td>
          </tr>
          <tr>
            <th>To</th>
            <td><input type="text" name="to" value="[% r.to | html %]" class="w-full" required></td>
          </tr>
          <tr>
            <th>Cc</th>
            <td><input type="text" name="cc" value="[% r.cc | html %]" class="w-full"></td>
          </tr>
          <tr>
            <th>Description</th>
            <td><textarea name="desc" wrap="hard" class="w-full h-20">[% IF r.defined("var") && r.var.defined("desc") %][% r.var.desc | html %][% ELSE %][% r.desc | html %][% END %]</textarea></td>
          </tr>
          <tr>
            <th>Attachments</th>
            <td>
              [% PROCESS _reports_icon.tt r=r %]
              <a href="reports2.cgi?report=[% r.nr %]&amp;refreshreport=0"><i class="[% icon %] text-sm"></i> [% attach %] ([% n = reduce_number(size, 'B', 1000); sprintf("%.1f %s", n.0, n.1) %])</a>
            </td>
          </tr>
          <tr>
            <td></td>
            <td>
              <button class="w-44 green self-center"><i class="uil uil-fast-mail"></i> Send E-Mail</button>
            </td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</form>


[% PROCESS _footer.tt %]
