  [% META title = 'Admin &raquo; Edit Email Contact' -%]

<!-- BEGIN admin/config/emailcontacts/edit.tt -->
  [% # PROCESS dumper.tt dump = errs %]

	[% PROCESS site/autosuggest.tt varname = 'hospital' %]

    [% email_contacts_dfv_js %]

	[% # PROCESS admin/misc_nav.tt page = 'error-codes' %]

	[% meta_data = c.get_meta_data('EmailContact') %]

  <h2 align="center">Edit Email Contact</h2>

	[% INCLUDE site/snippets/help.tt file = 'emailcontact' %]

    [% IF dfv_errors %]
    <dl>
        <dt class="error">[% c.cfg('msg').dfv_errors %]</dt>
        [% IF error_display_name %]
            <dd>Display name [% error_display_name %]</dd>[% END %]
        [% IF error_scope %]
            <dd>Scope [% error_scope %]</dd>[% END %]
        [% IF error_referral_source_id %]
            <dd>Referral source [% referral_source_id %]</dd>[% END %]
        [% IF error_type %]
            <dd>Type [% error_type %]</dd>[% END %]
        [% IF error_contact_address %]
            <dd>Email [% error_contact_address %]</dd>[% END %]
        [% IF error_active %]
            <dd>Active [% error_active %]</dd>[% END %]
    </dl>
    [% END %]

    <form method="post" action="[% app_url %]/config/email-contacts/update/[% data.id %]"
		[% email_contact_onsubmit %] name="email-contact" id="email-contact">

    <table>
      <tr>
        <th [% IF error_display_name %]class="error"[% END %]>Display name</th>
        <th [% IF error_scope %]class="error"[% END %]>Scope</th>
        <th [% IF error_referral_source_id %]class="error"[% END %]>Source</th>
      	<th [% IF error_type %]class="error"[% END %]>Type</th>
      	<th [% IF error_contact_address %]class="error"[% END %]>Email</th>
      	<th [% IF error_active %]class="error"[% END %]>Active</th>
      </tr>
      <tr>
        <td>
          <input type="text" name="display_name" value="[% data.display_name | html %]" />
        </td>
        <td>
      		<select name="scope">
      			<option value=""></option>
						[% FOREACH item IN meta_data.column('scope').check_in %]
              <option value="[% item %]" [% 'selected' IF item == data.scope %]>
                [% item %]</option>
            [% END %]
        </td>
        <td class="search_bar">
          <input style="width: 200px" type="text" id="location_name" name="_display_name"
            value="[% data.referral_source.display_name %]"/>
          <input type="hidden" id="source_id" name="referral_source_id" />
          <input type="hidden" name="_referral_source_id"
            value="[% data.referral_source_id %]" />
        </td>
        <td>
      		<select name="type">
      			<option value=""></option>
              [% FOREACH item IN meta_data.column('type').check_in %]
              <option value="[% item %]" [% 'selected' IF item == data.type %]>
                [% item %]</option>
            [% END %]
        </td>
        <td>
          <input type="text" name="contact_address" size="30"
              value="[% data.contact_address | html %]" />
        </td>
        <td>
          <select name="is_active">
          [% FOREACH option IN ['yes', 'no'] %]
            <option value="[% option %]" [% 'selected' IF option == data.is_active %]>
              [% option %]
            </option>
			    [% END %]
          </select>
        </td>
        <td>
         [% site.html.submit %]
        </td>
      </tr>
    </table>

    </form>

    <p>[% site.html.back_button %]</p>
<!-- END admin/config/emailcontacts/edit.tt -->
