
    <form method="post" action="[% app_url %]/admin/user/update_user_details/[% selected_user.id %]"
        [% user_details_onsubmit %] name="user_update" id="user_update">

	<table>
		<tr>
			<th colspan="2">[% selected_user ? 'User details' : 'New user' %]</th>
		</tr>

        <tr>
			<td align="right">Username:</td>
			<td>
                <input type="text" name="username" value="[% selected_user.username %]" id="username"
                    [%- IF c.cfg('use_cgi_ajax') -%]
                        onChange="do_ajax(['username'], ['bad_username']); return true;"
                    [%- END -%] [% site.html.on_focus %] size="12" />
                <span class="ajax_error"><em id="bad_username"></em></span>
                [% error_username %]
            </td>
		</tr>

        <tr>
			<td align="right">First name:</td>
			<td><input type="text" name="first_name" value="[% selected_user.first_name %]"
                id="user_fname" size="12" [% site.html.on_focus %] />
                [% UNLESS error_first_name.match('already exists'); # fname + lname constraint
                    error_first_name; END %]
            </td>
		</tr>

        <tr>
			<td align="right">Last name:</td>
			<td><input type="text" name="last_name" value="[% selected_user.last_name %]"
                id="user_lname" size="12" [% site.html.on_focus %] />
                [% error_last_name %]
            </td>
		</tr>

        <tr>
			<td align="right">Password:</td>
			<td><input type="text" name="password" value="[% selected_user.password %]"
                size="35" id="user_pwd" [% site.html.on_focus %] />
                [% error_password %]
            </td>
		</tr>

        <tr>
			<td align="right">Location:</td>
			<td>
				<!--
                <input type="text" name="location" value="$profile.location" size="12" [% on_focus %] />
                -->
				<select name="user_location_id" id="user_location" [% site.html.on_focus %]>
					<option value="">&nbsp;</option>
					[% FOREACH location IN locations %]
					<option [% 'selected' IF location.id == selected_user.user_location_id %]
                        value="[% location.id %]">[% location.location_name %]</option>
					[% END %]
				</select>
                [% IF error_user_location_id %]
                    [% error_user_location_id %]
                [% ELSE %]
                  [ <a href="[% app_url %]/admin/user_location">new</a> ]
                [% END %]
            </td>
		</tr>

        <tr>
			<td align="right">Designation:</td>
			<td>
                <input type="text" name="designation" value="[% selected_user.designation %]"
                    id="user_role" size="20" [% site.html.on_focus %] />
                [% error_designation %]
            </td>
		</tr>

        <tr>
			<td align="right">E-mail:</td>
            <td><input type="text" name="email" size="35" value="[% selected_user.email %]"
                id="user_email" [% site.html.on_focus %] />
                [% error_email %]
            </td>
		</tr>

        <tr>
			<td align="right">Group:</td>
			<td>
				<select name="group_id" id="user_group" [% site.html.on_focus %]>
					<option value="">&nbsp;</option>
					[% FOREACH group IN groups %]
					<option [% 'selected' IF group.id == selected_user.group_id %]
                        value="[% group.id %]">[% group.group_label %]</option>
					[% END %]
				</select>
                [% IF error_group_id %]
                    [% error_group_id %]
                [% ELSE %]
                    [ <a href="[% app_url %]/admin/user_group">new</a> ]
                [% END %]
            </td>
		</tr>

        <tr>
			<td align="right">Active:</td>
			<td>
                [% FOREACH option IN ['yes' 'no'] %]
                <input type="radio" name="active" [% 'checked' IF selected_user.active == option %]
                    value="[% option %]" />[% option %]
                [% END %]
                [% error_active %]
            </td>
        </tr>

        <tr>
            <td colspan="2" align="center" style="border: none">
            <input type="submit" name=".submit" value="Insert/Update User" class="button" />
            [% site.html.reset %]
            </td>
        </tr>
	</table>

    </form>