  [% META title = 'Admin &raquo; Edit Referral Source' -%]
<!-- BEGIN admin/config/referralsources/edit.tt -->
  [% # PROCESS dumper.tt dump = data %]

  [% # PROCESS admin/system_nav.tt page = 'trials' %]

  [% referral_sources_dfv_js %]

	[% PROCESS admin/referral_nav.tt page = 'referral-sources' %]
	
  <h2 align="center">Edit Referral Source Details</h2>

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

    <form method="post" action="[% app_url %]/config/referral-sources/update/[% data.id %]" [% referral_sources_onsubmit %]
        name="referral-source" id="referral-source">

    <table>
        <tr>
			<td class="label">Org. Code:</td>
			<td class="content">
                <input type="text" name="organisation_code" size="6"
					value="[% data.organisation_code | html %]" />
				[% error_organisation_code %]
			</td>
		</tr>
		<tr>
			<td class="label">Display Name:</td>
			<td class="content">
				<input type="text" name="display_name" size="80" value="[% data.display_name | html %]" />
				[% error_display_name %]
			</td>
		</tr>
		<tr>
			<td class="label">Parent Org. Code:</td>
			<td class="content">
				<select name="parent_organisation_id">
					<option value="">&nbsp;</option>
					[% FOREACH type IN [ 'hospital', 'practice' ] %]
					<optgroup label="[% type | upper %]">
						[% FOREACH entry IN parent_organisations %] 
                            [% NEXT UNLESS
                                entry.referral_type.description.match(type) %]
							<option value="[% entry.id %]"
							[% 'selected' IF entry.id == data.parent_organisation_id %]>
								[% entry.parent_code %] :: [% entry.description | html %]
							</option>
                        [% END %]
                    </optgroup>
                    [% END %]
				</select>
				[% error_parent_organisation_id %]
			</td>
        </tr>
		<tr>
			<td class="label">Location Type:</td>
			<td class="content">
				<select name="referral_type">
				[% FOREACH option IN ['hospital', 'practice'] %]
                     <option value="[% option %]" [% 'selected' IF option == data.referral_type.description %]>
                        [% option %]
                    </option>
			    [% END %]
				</select>
				[% error_referral_type %]
			</td>
        </tr>

        <tr>
            <td class="label">Active:</td>
			<td>
				<select name="is_active">
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option == source.is_active %]>
						[% option %]
					</option>
				[% END %]
				</select>
                [% error_is_active %]
			</td>
        </tr>
        
        <tr class="borderless">
            <td colspan="2" align="right">[% site.html.submit %]</td>
        </tr>
    </table>

    </form>

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


