  [% META title = 'Admin &raquo; Clinical Trials' -%]

	[% # PROCESS dumper.tt dump = c.config('msg') %]

  [% PROCESS admin/misc_nav.tt page = 'trials' %]

  [% trials_dfv_js %]

  <h2 align="center">Clinical Trials</h2>

    [% IF dfv_errors %]
        <p class="error">[% c.config('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 %]">
		<form method="post" action="[% app_url %]/config/trials/update" [% trials_onsubmit %]
			name="clinical_trial" id="clinical_trial">
		<div class="indent">
			<table>
				<tr>
					<td class="label">Trial name:</td>
					<td class="content">
						[% PROCESS site/ajax_input.tt field = 'trial_name' size = 40 %]
						[% error_trial_name %]
 					</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 trials.size # only empty if new db %]
	<div class="[% dfv_errors ? 'itemhidden' : 'visible' %]">
		<table>
			<tr>
				<th></th>
				<th>Trial Name</th>
				<th>Active</th>
			</tr>

			[% FOREACH t IN trials %]
			<tr>
				<td>[% loop.count %]</td>
				<td>
					<input type="text" size="40" name="trial_name" value="[% t.trial_name | html %]"
						[% site.html.disabled %] />
				</td>
				<td>
					<select name="active" [% site.html.disabled %]>
					[% FOREACH option IN ['yes', 'no'] %]
						 <option value="[% option %]" [% 'selected' IF option == t.active %]>
							[% option %]
						</option>
					[% END %]
					</select>
				</td>
				<td align="center">
					<a href="[% app_url %]/config/trials/edit/[% t.id %]">Edit</a>
				</td>
			 </tr>
			[% END %]

		</table>
	</div>
	[% END %]