<!-- BEGIN [% template.name %] -->
  [% META title = 'Resources &raquo; Messages' -%]

    [% # PROCESS dumper.tt dump = users %]
    [% # PROCESS dumper.tt dump = dfv_errors %]

  [% INCLUDE site/messages.tt %]

  [% user_message_dfv_js %]

  [% IF dfv_errors %]
    <p class="error">[% c.config('msg').dfv_errors %]</p>
  [% END %]

  <h4>
    New message:
    [% div_name = 'new-message'; INCLUDE site/snippets/toggleview.tt %]
  </h4>

  [% class = recipient || dfv_errors ? 'visible' : 'itemhidden' %]
  <div id="[% div_name %]" class="[% class %]">
    <form method="post" action="[% app_url %]/resources/new_message"
        [% user_message_onsubmit %] name="usermessage" id="usermessage">
      <table class="indent">
        <tr>
          <td class="label">
            [% IF recipient; 'User'; ELSE; 'Location/User'; END %]:
          </td>
          <td>
          [% IF recipient %]
            <input type="hidden" name="user_id" value="[% recipient.id %]" />
            <input type="text" size="25" [% site.html.readonly %]
              value="[% recipient.first_name | ucfirst %] [% recipient.last_name |
              ucfirst %]" />
          [% ELSE; PROCESS user/user_select.tt; END %]
          </td>
        </tr>

        <tr>
          <td class="label" style="vertical-align: top">Message:</td>
          <td>
            <textarea name="message" rows="5" cols="80">[% IF request; '[Ref: ';
              c.cfg('settings').lab_number_prefix; request.request_number; '/';
              request.year - 2000; '] '; END %]</textarea>
            [% error_message %]
          </td>
        </tr>

        <tr class="borderless">
          <td colspan="2" align="right">
            <input type="submit" value="Send >>" />
          </td>
        </tr>
      </table>
    </form>
  </div>
<!-- END [% template.name %] -->
