  [% META title = 'Admin &raquo; Edit Diagnostic Category' -%]
<!-- BEGIN [% template.name %] -->

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

  [% diagnostic_categories_dfv_js %]

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

  <h2>Edit Diagnostic Category</h2>

    [% IF dfv_errors %]
    <dl>
        <dt class="error">[% c.cfg('msg').dfv_errors %]</dt>
        [% IF error_description %]
            <dd>Description [% error_description %]</dd>[% END %]
    </dl>
    [% END %]

    <form method="post" action="[% app_url %]/config/diagnostic-categories/update/[% data.id %]"
        [% diagnostic_categories_onsubmit %] name="diagnostic-category" id="diagnostic-category">

    <table class="indent">
        <tr>
            <th [% IF error_description %]class="error"[% END %]>Description</th>
			<th [% IF error_category_type %]class="error"[% END %]>Type</th>
			<th [% IF error_active %]class="error"[% END %]>Active</th>
        </tr>

        <tr>
            <td>
                <input type="text" name="description" size="40"
                    value="[% data.description | html %]" />
             </td>
			<td>
				<select name="category_type">
				[% FOREACH option IN ['main', 'sub'] %]
                     <option value="[% option %]" [% 'selected' IF option == data.category_type %]>
                        [% option %]
                    </option>
			    [% END %]
				</select>
			</td>
			<td>
				<select name="active">
				[% FOREACH option IN ['yes', 'no'] %]
                     <option value="[% option %]" [% 'selected' IF option == data.active %]>
                        [% option %]
                    </option>
			    [% END %]
				</select>
			</td>
             <td>
                [% site.html.submit %]
            </td>
        </tr>
    </table>

    </form>

    <p class="indent">[% site.html.back_button %]</p>
	
  <h2>Configure [% data.description | html %] Diagnostic Category</h2>

	<p class="bold indent">ICDO3 members: [% icdo3.keys.sort.join(', ') %]</p>
	
    <form method="post" action="[% app_url %]/config/diagnostic-categories/configure/[% data.id %]">

    <table class="indent">
        <tr>
            <th>
				<a href="[% app_url %]/config/diagnostic-categories/edit/[%
					data.id %]?sort_by=name">Diagnosis</a>
			</th>
            <th>
				<a href="[% app_url %]/config/diagnostic-categories/edit/[%
					data.id %]?sort_by=icdo3">ICDO3</a>
			</th>
			<td class="borderless"></td>
        </tr>

		[% FOREACH entry IN diagnoses; NEXT UNLESS entry.icdo3;
			class = icdo3.item(entry.icdo3) ?
				entry.active.match('yes') ? 'bold' : 'grey'
				: 'normal';
		%]
			
			<tr class="[% class %]">
				<td>[% entry.name | html %]</td>
				<td>[% entry.icdo3 %]</td>
				<td>
					<input type="checkbox" name="icdo3" value="[% entry.icdo3 %]"
						[% 'checked' IF icdo3.item(entry.icdo3) %] />
				</td>
			</tr>
		[% END %]
	</table>
	
	<p class="indent">[% site.html.submit %]</p>
<!-- END [% template.name %] -->
