  [% META title = 'Admin &raquo; User Groups' -%]

  [% PROCESS admin/user_nav.tt page = 'user_group' %]

    [% # PROCESS dumper.tt dump = errors %]

    [% user_groups_dfv_js %]

	<h2 align="center">Setup User Groups</h2>

    [% IF dfv_errors %]
        <p class="error">[% c.cfg('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 %]/admin/user_group/update"
        [% user_groups_onsubmit %] name="user_group" id="user_group">
		<div class="indent">
		<table>
			<tr>
				<td class="label">Group name:</td>
				<td class="content">
                    [% PROCESS site/ajax_input.tt field = 'group_name' %]
					[% error_group_name %]
				</td>
			</tr>
			<tr>
				<td class="label">Group label:</td>
				<td class="content">
                    [% PROCESS site/ajax_input.tt field = 'group_label' size = 30 %]
					[% error_group_label %]
 				</td>
			</tr>
			<tr>
				<td class="label">Description:</td>
				<td class="content">
                    [% PROCESS site/ajax_input.tt field = 'group_detail' size = 50 %]
					[% error_group_detail %]
				</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 groups.size %]
	<table>
        <tr>
            <th></th>
            <th>Group name</th>
            <th>Group label</th>
            <th>Description</th>
            <th>Active</th>
        </tr>

        [% FOREACH item IN groups %]
        <tr>
            <td>[% loop.count %]</td>
            <td>
                <input type="text" size="10" name="[% item.id %]" value="[% item.group_name %]"
                    [% site.html.disabled %] />
            </td>
            <td>
                <input type="text" size="30" name="[% item.id %]" value="[% item.group_label %]"
                    [% site.html.disabled %] />
            </td>
            <td>
                <input type="text" size="50" name="[% item.id %]" value="[% item.group_detail %]"
                    [% site.html.disabled %] />
            </td>
			<td>
				<select name="active" [% site.html.disabled %]>
				[% FOREACH option IN ['yes', 'no'] %]
					 <option value="[% option %]" [% 'selected' IF option == item.active %]>
						[% option %]
					</option>
				[% END %]
				</select>
			</td>
            <td align="center">
					<a href="[% app_url %]/admin/user_group/edit/[% item.id %]">Edit</a>
			</td>
         </tr>
        [% END %]
    </table>
    [% END %]
