  [% META title = 'Admin &raquo; Error Codes' -%]

<!-- BEGIN admin/config/errorcodes/default.tt -->
	[% # PROCESS dumper.tt dump = c.config('msg') %]

	[% error_codes_dfv_js %]

	[% PROCESS admin/misc_nav.tt page = 'error-codes' %]

  <h2 align="center">Error Codes</h2>

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

	[% INCLUDE site/snippets/help.tt file = 'errorcode' %]
	
    <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/error-codes/update" [% error_codes_onsubmit %]
			name="error-code" id="error-code">
		<div class="indent">
			<table>
				<tr>
					<td class="label">Error code:</td>
					<td class="content">
						[% PROCESS site/ajax_input.tt field = 'code', id = 'error_code',
							size = 2 %]
						[% error_code %]
 					</td>
				</tr>
				<tr>
					<td class="label">Brief description:</td>
					<td class="content">
                    <input type="text" name="description" value="" size="40" />
						[% error_description %]
 					</td>
				</tr>
				<tr>
					<td class="label">Unique:</td>
					<td class="content">
						<select name="is_unique" [% site.html.onfocus %]>
						[% FOREACH option IN ['yes', 'no'] %]
						 <option value="[% option %]">[% option %]</option>
						[% END %]
						</select>
						[% error_is_unique %]
 					</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 error_codes.size # only empty if new db %]
	<div class="[% dfv_errors ? 'itemhidden' : 'visible' %]">
		<table>
			<tr>
				<th></th>
				<th>Code</th>
				<th>Description</th>
				<th>Unique</th>
				<th>Active</th>
				<th>On report</th>			
			</tr>

			[% FOREACH ec IN error_codes %][% # PROCESS dumper.tt dump = ec.description %]
			<tr>
				<td>[% loop.count %]</td>
				<td align="center"><strong>[% ec.code | upper %]</strong></td>
				<td>
					<input type="text" size="40" value="[% ec.description | html %]"
						[% site.html.disabled %] />
				</td>
				<td>
					<select name="is_unique" [% site.html.disabled %]>
					[% FOREACH option IN ['yes', 'no'] %]
						 <option value="[% option %]" [% 'selected' IF option == ec.is_unique %]>
							[% option %]
						</option>
					[% END %]
					</select>
				</td>
				<td>
					<select name="active" [% site.html.disabled %]>
					[% FOREACH option IN ['yes', 'no'] %]
						 <option value="[% option %]" [% 'selected' IF option == ec.active %]>
							[% option %]
						</option>
					[% END %]
					</select>
				</td>
				<td align="center">
					[% IF codes_map.item(ec.code) %]
						<img src="/images/tick.gif" />
						[ <a href="[% app_url %]/config/report-error-codes/edit/[% codes_map.item(ec.code) %]">
							view</a> ]
					[% ELSE %]
						<span class="error">X</span>
						[ <a href="[% app_url %]/config/report-error-codes">add</a> ]
					[% END %]
				</td>
				<td align="center">
					<a href="[% app_url %]/config/error-codes/edit/[% ec.id %]">Edit</a>
				</td>
			 </tr>
			[% END %]
		</table>
	</div>
	[% END %]
<!-- END admin/config/errorcodes/default.tt -->
