  [% META title = 'Admin &raquo; Diagnostic Categories' -%]
<!-- BEGIN [% template.name %] -->
  
  [% # PROCESS dumper.tt dump = c.stash.errs %]

	[% diagnostic_category_dfv_js %]

	[% PROCESS admin/request_nav.tt page = 'diagnostic-categories' %]
	
	<h2 align="center">Diagnostic Categories</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/diagnostic-categories/update"
            name="new_categories" id="new_categories" [% diagnostic_category_onsubmit %]>
            <div class="indent">
                <table>
                    <tr>
                        <td class="label">Description:</td>
                        <td>
						[% # PROCESS site/ajax_input.tt field = 'description', id = 'diagnostic_category' %]
                            <input type="text" name="description" size="40"
                                value="[% c.query.param('description') %]" />
                            [% error_description %]
                        </td>
                    </tr>
                   <tr>
                        <td class="label">Type:</td>
                        <td class="content">
                            <select name="category_type" [% site.html.onfocus %]>
                            [% FOREACH option IN ['main', 'sub'] %]
                                <option value="[% option %]">[% option %]</option>
                            [% END %]
                            </select>
                            [% error_category_type %]
                        </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>
                    
                    <tr>
                        <td class="borderless" colspan="2" align="center">[% site.html.submit %]</td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
    
	<p class="spacer">&nbsp;</p>

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

			[% FOREACH entry IN categories %]
			<tr>
				<td>
                    [% loop.count %]
                </td>
				<td>
					<input type="text" size="40" name="description"
                            value="[% entry.description | html %]"
						[% site.html.disabled %] />
				</td>
				<td>
					<select name="category_type" [% site.html.disabled %]>
					[% FOREACH option IN ['main', 'sub'] %]
						 <option value="[% option %]" [% 'selected' IF option == entry.category_type %]>
							[% option %]
						</option>
					[% END %]
					</select>
				</td>
				<td>
					<select name="active" [% site.html.disabled %]>
					[% FOREACH option IN ['yes', 'no'] %]
						 <option value="[% option %]" [% 'selected' IF option == entry.active %]>
							[% option %]
						</option>
					[% END %]
					</select>
				</td>
				<td align="center">
					<a href="[% app_url %]/config/diagnostic-categories/edit/[% entry.id %]">Configure</a>
				</td>
			 </tr>
			[% END %]

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