{extends "base.tpl.html"}
{block "title"}#{$issue_id} - {$extra_title}{/block}

{block "content"}
{if $note == ''}
<br />
<table width="100%" align="center">
  <tr>
    <td align="center">
      &nbsp;<span>{t}The specified note does not exist.{/t} <br />
      {t}It could have been converted to an email.{/t}
      <br /><br />
      &nbsp;<a href="javascript:self.close();">{t}Close{/t}</a></span>
    </td>
  </tr>
</table>
{else}

<script type="text/javascript">
<!--
function reply(id, issue_id)
{
    window.location.href = 'post_note.php?cat=reply&id=' + id + '&issue_id=' + issue_id;
}
function replyAsEmail(id, issue_id)
{
    window.location.href = 'send.php?cat=reply_to_note&note_id=' + id + '&issue_id=' + issue_id;
}
function openRawHeaders()
{

    var features = 'width=740,height=580,top=60,left=60,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,status=no';
    var headersWin = window.open('view_headers.php?cat=note&id={$smarty.get.id|intval}', '_headers', features);
    headersWin.focus();

}
function viewNote(id)
{
    window.location.href = 'view_note.php?id=' + id;
}
//-->
</script>

<form method="post" action="popup.php">
<table align="center" class="bordered internal">
        <tr class="title">
          <th colspan="2">
            {t}View Note Details{/t}
            {if $issue_id}
              {t escape=no
                1=$issue_id
                2="{$core.rel_url}view.php?id={$issue_id}"
              }(Associated with Issue <a href="%2">#%1</a>){/t}
            {/if}
          </th>
        </tr>
        {if $next != "" || $previous != ""}
        <tr class="buttons">
            <td colspan="2">
              {if $previous != ""}
              <input type="button" value="&lt;&lt; {t}Previous Note{/t}" onClick="viewNote({$previous});">
              {/if}
              <div class="right">
              {if $next != ""}
              <input type="button" value="{t}Next Note{/t} &gt;&gt;" onClick="viewNote({$next});">
              {/if}
              </div>
            </td>
        </tr>
        {/if}
        <tr>
          <th width="120">
            {t}Posted Date{/t}:
          </th>
          <td>
            {$note.not_created_date|timeago}
          </td>
        </tr>
        <tr>
          <th width="120">
            {t}From{/t}:
          </th>
          <td>
            {$note.not_from|escape:"html"}
          </td>
        </tr>
        {if $recipients|@count > 0}
        <tr>
          <th width="120">
            {t}Recipients{/t}:
          </th>
          <td>
            {strip}
            {section name="i" loop=$recipients}
              {if not $smarty.section.i.first}, {/if}
              {$recipients[i]|escape:"html"}
            {/section}
            {/strip}
          </td>
        </tr>
        {/if}
        <tr>
          <th width="120">
            {t}Title{/t}:
          </th>
          <td>
            {$note.not_title|default:"<Empty Title>"|escape:"html"}
          </td>
        </tr>
        {if $note.attachments|default:'' != ''}
        <tr>
          <th width="120">
            {t}Attachments{/t}:
          </th>
          <td>
            {section name="i" loop=$note.attachments}
              <i class="fa fa-paperclip" aria-hidden="true"></i>
              <a title="{t}download file{/t}" href="get_attachment.php?cat=blocked_email&note_id={$note.not_id}&filename={$note.attachments[i].filename}{if $note.attachments[i].cid}&cid={$note.attachments[i].cid|escape:"html"}{/if}">{$note.attachments[i].filename}</a><br />
            {/section}
          </td>
        </tr>
        {/if}
        <tr>
          <td colspan="2">
              {t}Message{/t}:
              <span class="small_default_white">(<a class="white_link" href="javascript:void(null);" onClick="Eventum.displayFixedWidth($('#email_message'))">{t}display in fixed width font{/t}</a>)</span>
              <div class="right">
                  {if $note.has_blocked_message}
                  <a class="white_link" href="javascript:void(null);" onClick="openRawHeaders();">{t}Blocked Message Raw Headers{/t}</a>
                  {/if}
              </div>
          </td>
        </tr>
        <tr>
          <td colspan="2" id="email_message">
            {$note.not_note|textFormat:$issue_id}
          </td>
        </tr>
        <tr class="buttons">
          <td colspan="2">
            <input type="button" value="{t}Reply{/t}" onClick="reply({$smarty.get.id|intval}, {$issue_id});">&nbsp;&nbsp;
            <input type="button" value="{t}Reply as Email{/t}" onClick="replyAsEmail({$smarty.get.id|intval}, {$issue_id});">&nbsp;&nbsp;
            <input type="button" value="{t}Close{/t}" onClick="window.close();">
          </td>
        </tr>
        {if $next != "" || $previous != ""}
        <tr class="buttons">
            <td colspan="2">
              {if $previous != ""}
              <input type="button" value="&lt;&lt; {t}Previous Note{/t}" onClick="viewNote({$previous});">
              {/if}
              <div class="right">
              {if $next != ""}
              <input type="button" value="{t}Next Note{/t} &gt;&gt;" onClick="viewNote({$next});">
              {/if}
              </div>
            </td>
        </tr>
        {/if}
      </table>
</form>

{/if}
{/block}
