  [% META title = 'Admin &raquo; Anatomical Sites' -%]
<!-- BEGIN [% template.name %] -->

  [% # PROCESS dumper.tt dump = c.stash.errs %]
  [% # PROCESS dumper.tt dump = data %]

	[% anatomical_sites_dfv_js %]

	[% # PROCESS admin/request_nav.tt page = 'diagnostic-categories' %]

	<h2 align="center">Anatomical Sites</h2>

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

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

    <p class="title">
		[% div_name = 'new'; INCLUDE site/snippets/toggleview.tt %]
		Add new entry
	</p>

	<div class="[% dfv_errors ? 'visible' : 'itemhidden' %]" id="[% div_name %]">

        <form method="get" action="[% app_url %]/config/anatomical-sites/update"
            name="new_sites" id="new_sites" [% anatomical_sites_onsubmit %]>
            <div class="indent">
                <table>
                    <tr>
                        <td class="label">Description:</td>
                        <td>
						[% PROCESS site/ajax_input.tt field = 'site_name',
							id = 'site_name' size = 50; max_length = 50 %]
                            [% error_site_name %]
                        </td>
                    </tr>
                   <tr>
                        <td class="label">Snomed:</td>
                        <td class="content">
                            <input type="text" name="snomed" size="6"
                                value="[% c.query.param('snomed') %]" />
                            [% error_snomed %]
                        </td>
                    </tr>

                    <tr>
                        <td class="borderless" colspan="2" align="center">[% site.html.submit %]</td>
                    </tr>
                </table>
            </div>
        </form>
    </div>

	<p class="spacer">&nbsp;</p>

	[% IF data.size # only empty if new db %]
	<div class="[% dfv_errors ? 'itemhidden' : 'visible' %]">
		<table>
			<tr>
				<th></th>
				<th>Description</th>
				<th>Snomed</th>
				<td class="borderless"></td>
			</tr>

			[% FOREACH entry IN data %]
			<tr>
				<td>
                    [% loop.count %]
                </td>
				<td>
					<input type="text" size="40" name="description"
                            value="[% entry.site_name | html %]"
						[% site.html.disabled %] />
				</td>
				<td>
					<input type="text" size="6" name="snomed"
                            value="[% entry.snomed | html %]"
						[% site.html.disabled %] />
				</td>

				<td align="center">
					<a href="[% app_url %]/config/anatomical-sites/edit/[% entry.id %]">Edit</a>
				</td>
			 </tr>
			[% END %]

		</table>
	</div>
	[% END %]
<!-- END [% template.name %] -->
