  [% META title = 'Admin &raquo; Report Error Codes' -%]
  
<!-- BEGIN admin/config/reporterrorcodes/default.tt -->
	[% # PROCESS dumper.tt dump = codes_map %]

    [% error_codes_dfv_js %]

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

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

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

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

    <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/report-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">
						<select name="code">
							<option value="">-- select one --</option>
							[% FOREACH ec IN error_codes %]
								[% NEXT UNLESS ec.active.match('yes') %]
								[% NEXT IF codes_map.item(ec.code) # skip if used %]
								<option value="[% ec.code %]">
									[% ec.code | upper %]
									[% ec.description | html %]
								</option>
							[% END %]
						</select>
						[% IF error_code %]
							[% error_code %]
						[% ELSE %]
							[ <a href="[% app_url %]/config/error-codes">new</a> ]
						[% END %]
 					</td>
				</tr>
				<tr>
					<td class="label">Expanded description:</td>
					<td class="content">
                    <input type="text" name="description" value="" size="70" />
						[% error_description %]
 					</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 report_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>Active</th>
			</tr>

			[% FOREACH ec IN report_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="70" value="[% ec.description | html %]"
						[% site.html.disabled %] />
				</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">
					<a href="[% app_url %]/config/report-error-codes/edit/[% ec.id %]">Edit</a>
				</td>
			 </tr>
			[% END %]
		</table>
	</div>
	[% END %]
<!-- END admin/config/reporterrorcodes/default.tt -->
