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

  [% PROCESS admin/lab_test_nav.tt page = 'lab_section' %]


    [% # PROCESS dumper.tt dump = lab_section_specimen_types %]
    [% # PROCESS dumper.tt dump = specimen_types %]

    [% lab_sections_dfv_js %]

	<h2 align="center">Lab Sections</h2>

    [% IF dfv_errors %]
        <p class="error">[% c.cfg('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 %]">

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

    <form method="post" action="[% app_url %]/admin/lab_section/update"
        [% lab_sections_onsubmit %] name="lab_section" id="lab_section">

		<div class="indent">
		<table>
			<tr>
				<td class="label">Description:</td>
				<td class="content">
                    [% PROCESS site/ajax_input.tt field = 'section_name' %]
					[% error_section_name %]
				</td>
			</tr>
			<tr>
				<td class="label">Results summary:</td>
				<td class="content">
					<select name="has_result_summary" [% site.html.onfocus %]>
					[% FOREACH option IN ['no', 'yes'] # default to no %]
					 <option value="[% option %]">[% option %]</option>
					[% END %]
					</select>
					[% error_has_result_summary %]
					</td>
			</tr>
			<tr>
				<td class="label">Section notes:</td>
				<td class="content">
					<select name="has_section_notes" [% site.html.onfocus %]>
					[% FOREACH option IN ['no', 'yes'] # default to no %]
					 <option value="[% option %]">[% option %]</option>
					[% END %]
					</select>
					[% error_has_section_notes %]
					</td>
			</tr>
			<tr>
				<td class="label">Sign out:</td>
				<td class="content">
					<select name="has_test_sign_out" [% site.html.onfocus %]>
					[% FOREACH option IN ['no', 'yes'] # default to no %]
					 <option value="[% option %]">[% option %]</option>
					[% END %]
					</select>
					[% error_has_test_sign_out %]
					</td>
			</tr>
			<tr>
				<td class="label">Results import:</td>
				<td class="content">
					<select name="has_results_import" [% site.html.onfocus %]>
					[% FOREACH option IN ['no', 'yes'] # default to no %]
					 <option value="[% option %]">[% option %]</option>
					[% END %]
					</select>
					[% error_has_results_import %]
					</td>
			</tr>
			<tr>
				<td class="label">Remote system:</td>
				<td class="content">
					<select name="has_foreign_id" [% site.html.onfocus %]>
					[% FOREACH option IN ['no', 'yes'] # default to no %]
					 <option value="[% option %]">[% option %]</option>
					[% END %]
					</select>
					[% error_has_foreign_id %]
				</td>
			</tr>
			<tr>
				<td class="label">Auto-expand:</td>
				<td class="content">
					<select name="auto_expand" [% site.html.onfocus %]>
					[% FOREACH option IN ['no', 'yes'] # default to no %]
					 <option value="[% option %]">[% option %]</option>
					[% END %]
					</select>
					[% error_auto_expand %]
				</td>
			</tr>
            [% IF c.cfg('settings').have_label_printer %]
			  <tr>
				<td class="label">Print labels:</td>
				<td class="content">
					<select name="has_labels" [% site.html.onfocus %]>
					[% FOREACH option IN ['no', 'yes'] # default to no %]
					 <option value="[% option %]">[% option %]</option>
					[% END %]
					</select>
					[% error_has_labels %]
				</td>
			  </tr>
            [% END %]
			<tr>
				<td class="label" style="vertical-align: top">
                    Default sample<br />types:
                </td>
				<td class="content">
                    [% FOREACH type IN specimen_types; # PROCESS dumper.tt dump = type %]
                    <div id="id">
                        <input type="checkbox" name="sample_type_id" value="[% type.id %]" />
                        [% type.specimen_type %]
                    </div>
                    [% END %]
                    [% error_sample_type_id %]
				</td>
			</tr>
			<tr>
				<td class="label">Active:</td>
				<td class="content">
					<select name="is_active" [% site.html.onfocus %]>
					[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]">[% option %]</option>
					[% END %]
					</select>
					[% error_is_active %]
					</td>
			</tr>
        </table>

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

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

    [% IF sections.size %]
	<table>
        <tr>
            <th></th>
            <th>Description</th>
            <th>
				<span title="section records individual test results"
				  class="acronym">Results</span>
			</th>
            <th>
				<span title="section has test-specific instructions"
				  class="acronym">Notes</span>
			</th>
            <th>
				<span title="section allows block completion of all outstanding test results"
				  class="acronym">Sign-out</span>
			</th>
            <th>
				<span title="section allows import of results via data file"
				  class="acronym">Import</span>
			</th>
            <th>
				<span title="section has remote system interface"
				  class="acronym">Remote</span>
			</th>
            <th>
				<span title="auto-expands panels to lab-tests"
				  class="acronym">Expand</span>
			</th>
            [% IF c.cfg('settings').have_label_printer %]
              <th>
				<span title="ability to print labels for section"
				  class="acronym">Labels</span>
			  </th>
            [% END %]
            <th colspan="[% specimen_types.size %]">
                <div id="id">
                    <span title="default specimen type(s) for section lab tests"
                        class="acronym">Specimen</span>
                </div>
				<div style="text-align: center">
                        [%
							specimen_list = [];
                            specimen_list.push(s.specimen_type)
								FOREACH s IN specimen_types;
							# INCLUDE dumper.tt dump = specimen_list;
                        %]
                        [% IF specimen_list.grep('liquid').size %]
                            <span title="liquid samples (PB, BMA, etc)"
                                class="acronym">L</span> |
                        [% END %]
                        [% IF specimen_list.grep('biopsy - unfixed').size %]
                            <span title="biopsy - unfixed (LU, GU, etc)"
                                class="acronym">BU</span> |
                        [% END %]
                        [% IF specimen_list.grep('biopsy - fixed').size %]
                            <span title="biopsy - fixed (LF, GF, etc)"
                                class="acronym">BF</span>
                        [% END %]
                        [% IF specimen_list.grep('generic').size %]
                            Generic
                        [% END %]
                </div>
			</th>
            <th>Active</th>
        </tr>

        [% FOREACH section IN sections; # INCLUDE dumper.tt dump = section.as_tree; %]
        <tr>
            <td>[% loop.count %]</td>
            <td>
                <input type="text" size="30" name="[% section.id %]"
                    value="[% section.section_name %]" [% site.html.disabled %] />
            </td>
			<td>
				<select name="has_result_summary" [% site.html.disabled %]>
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option ==
                            section.has_result_summary %]>
						[% option %]
					</option>
				[% END %]
				</select>
			</td>
			<td>
				<select name="has_section_notes" [% site.html.disabled %]>
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option ==
                            section.has_section_notes %]>
						[% option %]
					</option>
				[% END %]
				</select>
			</td>
			<td>
				<select name="has_test_sign_out" [% site.html.disabled %]>
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option ==
                            section.has_test_sign_out %]>
						[% option %]
					</option>
				[% END %]
				</select>
			</td>
			<td>
				<select name="has_results_import" [% site.html.disabled %]>
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option ==
                            section.has_results_import %]>
						[% option %]
					</option>
				[% END %]
				</select>
			</td>
			<td>
				<select name="has_foreign_id" [% site.html.disabled %]>
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option ==
                            section.has_foreign_id %]>
						[% option %]
					</option>
				[% END %]
				</select>
			</td>
			<td>
				<select name="auto_expand" [% site.html.disabled %]>
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option ==
                            section.auto_expand %]>
						[% option %]
					</option>
				[% END %]
				</select>
			</td>
            [% IF c.cfg('settings').have_label_printer %]
			  <td>
				<select name="has_labels" [% site.html.disabled %]>
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option ==
                            section.has_labels %]>
						[% option %]
					</option>
				[% END %]
				</select>
			  </td>
            [% END %]

            [% FOREACH type IN specimen_types %]
            <td align="center">
                [% IF lab_section_specimen_types.item(section.id).item(type.id) %]
                    <img src='/images/tick.gif' />
                [% ELSE %]
                    <span class="red">X</span>
                [% END %]
            </td>
            [% END %]

			<td>
				<select name="is_active" [% site.html.disabled %]>
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option ==
                            section.is_active %]>
						[% option %]
					</option>
				[% END %]
				</select>
			</td>

			<td align="center">
				<a href="[% app_url %]/admin/lab_section/edit/[% section.id %]">Edit</a>
			</td>
         </tr>
        [% END %]
    </table>
    [% END %]
<!-- END [% template.name %] -->
