  [% META title = 'Admin &raquo; Specimens' -%]
<!-- BEGIN admin/config/specimens/default.tt -->

	[% # PROCESS dumper.tt dump = specimen_lab_test_map %]
    [% # PROCESS dumper.tt dump = specimen_sample_types %]
    [% # PROCESS dumper.tt dump = sample_types %]
    
  [% PROCESS admin/misc_nav.tt page = 'specimens' %]

  [% specimens_dfv_js %]

  <h2 align="center">Specimens</h2>

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

    <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="post" action="[% app_url %]/config/specimens/update" [% specimens_onsubmit %]
        name="lab_test" id="lab_test">
		<div class="indent">
			<table>
				<tr>
					<td class="label">Sample code:</td>
					<td class="content">
                        [% PROCESS site/ajax_input.tt field = 'sample_code' %]
						[% error_sample_code %]
					</td>
				</tr>
				<tr>
					<td class="label">Description:</td>
					<td class="content">
						<input type="text" name="description" id="description" value=""  size="20" />
						[% error_description %]
 					</td>
				</tr>
                <tr>
                    <td class="label" style="vertical-align: top">
                        Sample type(s):
                    </td>
                    <td class="content">
                        [% FOREACH type IN sample_types; # PROCESS dumper.tt dump = type %]
                        <div>
                            <input type="checkbox" name="sample_type_id" value="[% type.id %]" />
                            [% type.specimen_type %]
                        </div>                    
                        [% END %]
                        <div>[% # for samples like SER where no lab tests required: %]
                            <input type="checkbox" name="sample_type_id" value="0" />
                            not required
                        </div>                    
                        [% error_sample_type_id %]
                    </td>
                </tr>
				<tr>
					<td class="label">Active:</td>
					<td class="content">
						<select name="active" [% site.html.onfocus %]>
						[% FOREACH option IN ['yes', 'no'] %]
						 <option value="[% option %]">[% option %]</option>
						[% END %]
						</select>
						[% error_active %]
 					</td>
				</tr>
            </table>

			<p class="indent">[% site.html.submit %]</p>
		</div>
		</form>
	</div>

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

	[% IF specimens.size # only empty if new db %]
	<div class="[% dfv_errors ? 'itemhidden' : 'visible' %]">
        [% PROCESS site/page_count.tt %]

		<table>
			<tr>
				<th></th>
				<th>Sample Code</th>
				<th>Description</th>
                <th colspan="3">
                    <div>Sample type</div>
                    <div style="text-align: center">
                        <span title="liquid samples (PB, BMA, etc)"
                            class="acronym">L</span> |
                        <span title="biopsy - unfixed (LU, GU, etc)"
                            class="acronym">BU</span> |
                        <span title="biopsy - fixed (LF, GF, etc)"
                            class="acronym">BF</span>
                    </div>
                </th>
				<th>Tests</th>
				<th>Active</th>
			</tr>

			[% FOREACH s IN specimens %]
			<tr>
				<td>
                    [% IF cgi_pager; cgi_pager.first_pos_displayed + loop.count - 1; ELSE; loop.count; END %]
                </td>
				<td>
					<input type="text" size="15" name="sample_code" value="[% s.sample_code | html %]"
						[% site.html.disabled %] />
				</td>
				<td>
					<input type="text" size="45" name="description" value="[% s.description | html %]"
                        [% site.html.disabled %] />
				</td>

                [% FOREACH type IN sample_types %]
                <td align="center">
                    [% IF specimen_sample_types.item(s.id).item(type.id) %]
                        <img src='/images/tick.gif' />
                    [% ELSE %]
                        <span class="red">X</span>
                    [% END %]
                </td>
                [% END %]
                
				<td align="center">
					[% IF specimen_lab_test_map.item(s.id);
						title = specimen_lab_test_map.item(s.id).lab_test_names.join(', ');
					%]					
						<span class="acronym" title="[% title %]">Yes</span>
					[% END %]
				</td>
				<td>
					<select name="active" [% site.html.disabled %]>
					[% FOREACH option IN ['yes', 'no'] %]
						 <option value="[% option %]" [% 'selected' IF option == s.active %]>
							[% option %]
						</option>
					[% END %]
					</select>
				</td>
				<td align="center">
					<a href="[% app_url %]/config/specimens/edit/[% s.id %]">Edit</a>
				</td>
			 </tr>
			[% END %]

		</table>
	</div>
	[% END %]

    [% PROCESS site/cgi_pager.tt %]
<!-- BEGIN admin/config/specimens/default.tt -->