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

    [% # PROCESS dumper.tt dump = users %]
    
  [% INCLUDE site/messages.tt %]

  <h4>
    New message:
    [% div_name = 'new_msg'; INCLUDE site/snippets/toggleview.tt %]
  </h4>
  
  [% class = recipient ? 'visible' : 'itemhidden' %]
  <div id="[% div_name %]" class="[% class %]">		
    <form method="post" action="[% app_url %]/resources/new_message">
      <table class="indent">
        <tr>
          <td class="label">User:</td>
          <td>
          [% IF recipient %]
            <input type="hidden" name="user_id" value="[% recipient.id %]" />
            <input type="text" size="15" [% site.html.readonly %]
              value="[% recipient.first_name | ucfirst %] [% recipient.last_name |
              ucfirst %]" />
          [% ELSE %]
            <select name="user_id">
            [% DEFAULT optgroup_name = '' %]
                <option value="">--select one--</option>
            [% WHILE (user = users.next); # iterator
                NEXT UNLESS user.active.match('yes');
                IF user.user_location.location_name != optgroup_name;
                    optgroup_name = user.user_location.location_name %]
                <optgroup label="[% optgroup_name %]">
                [% END %]
              <option value="[% user.id %]">
                [% user.last_name  | upper %],
                [% user.first_name | ucfirst %]
              </option>
            [% END %]
            </select>
          [% END %]
          </td>
        </tr>
  
        <tr>
          <td class="label" style="vertical-align: top">Message:</td>
          <td>
            <textarea name="message" rows="5" cols="80"></textarea> 
          </td>
        </tr>
        
        <tr class="borderless">
          <td colspan="2" align="right">
            <input type="submit" value="Send >>" />
          </td>
        </tr>
      </table>
    </form>
  </div>
<!-- END [% template.name %] -->