<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html metal:use-macro="container/page_macro/macros/master_page">

<script metal:fill-slot="js_slot" type="text/javascript" src="js/checkAll2"></script>

<span tal:omit-tag="" metal:fill-slot="breadcrumbs">
	&gt; <label tal:omit-tag="" i18n:translate="">user management</label>
</span>

<span tal:omit-tag="" metal:fill-slot="main_content_slot">
	<span tal:omit-tag="" tal:condition="python:user.has_role(('Manager','IVAAdmin',),context)">
		<table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#EEEEEE">
          <tr>
		  	<td><a href="manage_addIvaUsers" class="link2" i18n:translate="">Add users</a></td>
          	<td><a href="manage_affiliations" class="link2" i18n:translate="">Add affiliation</a></td>
          	<td><a href="manage_ivaUsers_csv" class="link2" i18n:translate="">Save as CSV</a></td>
			<td><a href="?managepending=" class="link2" i18n:translate="">Pending users</a></td>
          </tr>
		</table>
		
		<form method="post" action="">
			<table>
				<tr>
					<td i18n:translate="">Last name:</td>
					<td><input type="text" name="pnimi" value="" tal:attributes="value request/pnimi | default" /></td>
					<td><input type="submit" value="Search" name="findusers" i18n:attributes="value" /></td>
				</tr>
				<tr>
					<td i18n:translate="">First name:</td>
					<td><input type="text" name="enimi" value="" tal:attributes="value request/enimi | default" /></td>
				</tr>
				<tr>
					<td i18n:translate="">Affiliation:</td>
					<td tal:content="structure python:container.fle_users.erialadeKombo(request, kastinimi='organization',vaikimisiID=getattr(request, 'eriala','-1'))"></td>
				</tr>
			</table>
		</form>
		
		<br /><br />

		<span tal:omit-tag="" tal:condition="exists:request/findusers">
		<span tal:omit-tag="" tal:define="
    			enimi request/enimi | nothing;
    			pnimi request/pnimi | nothing;
    			org request/organization | string:;
				checkall request/checkall | nothing;
    			userList python:here.filtreeriKasutajad(request, here.fle_users.get_users(),enimi,pnimi,org=org);
    			">
					
    			<h2 i18n:translate="">search results</h2>
    		<form name="userResult" id="userResult" action="manage_ivaUsers_handler" method="post" >
    			<table border="0" cellpadding="0" cellspacing="0" width="100%">
					<thead>
						<tr>
						<th><input type="button" onclick="javascript:selectAll('unames','userResult')" value="All" i18n:attributes="value" name="findusers" /></th>
						<th i18n:translate="">First name</th>
						<th i18n:translate="">Last name</th>
						<th i18n:translate="">Username</th>
						<th tal:condition="org" i18n:translate="">Affiliation</th>
						<th i18n:translate="">n</th>
						<th i18n:translate="">Last access</th>
						<th i18n:translate="">Info</th>
						</tr>
					</thead>
				<tbody>
			<tr tal:repeat="juser userList">
				<td width="30" align="center"><input type="checkbox" name="unames" value="" tal:attributes="value juser/get_uname" /></td>
				<td tal:content="juser/get_first_name" />
				<td tal:content="juser/get_last_name" />
					<td tal:content="juser/get_uname" />
					<td tal:condition="org"><label tal:content="juser/get_organization" /></td>
					<td tal:content="python:len(juser.user_courses())" />
					<td tal:content="python:juser.global_last_active_time(request)" />
					<td><a href="" tal:attributes="href string:${juser/absolute_url}/user_courses_info" i18n:translate="">Info</a></td>
			</tr>
				</tbody>
				
		</table>
			<input type="submit" name="delete" i18n:attributes="value" value="Delete" />
			<input type="submit" name="permission" i18n:attributes="value" value="Permissions" />
			<input type="submit" name="archive" i18n:attributes="value" value="Archive" />
			<br />
			<span tal:condition="context/getAffiliations">
    			<label for="organization" i18n:translate="">Set affiliation for selected users:</label>
    			<span tal:replace="structure python:container.fle_users.erialadeKombo(request, kastinimi='organization',vaikimisiID=getattr(request, 'eriala','-1'))"></span>
    			<input type="submit" name="changeAff" i18n:attributes="value" value="Change affiliation" />
			</span>
	</form>
		
	</span>
	</span>
	
	<span tal:omit-tag="" tal:condition="exists:request/managepending">
		<h2 i18n:translate="">users waiting confirmation</h2>
		<form name="regUsersf" action="manage_registering_users" method="post">
			<table border="0">
				<thead>
					<tr>
					<th><input type="button" onclick="javascript:selectAll('suser:list','regUsersf')" value="Check all" name="findusers" i18n:attributes="value" /></th>
						<th i18n:translate="">req username</th>
						<th i18n:translate="">First name</th>
						<th i18n:translate="">Last name</th>
						<th i18n:translate="">preflang</th>
						<th i18n:translate="">email</th>
						<th i18n:translate="">message</th>
					</tr>
					</thead>
					<tbody>
					<tr tal:repeat="puser context/get_pending_users">
						<span tal:define="pdetails python:context.get_pending_details(puser)">
							<td><input type="checkbox" value="" tal:attributes="value puser" name="suser:list" /></td>
							<td><input type="text" value="" tal:attributes="value puser;name puser" name=""></td>
							<td tal:content="pdetails/fname"></td>
							<td tal:content="pdetails/lname"></td>
							<td tal:content="pdetails/preflang"></td>
							<td><a href="" tal:attributes="href string:mailto:${pdetails/email}" tal:content="pdetails/email"></a></td>
							<td tal:content="pdetails/optmess"></td>
						</span>
					</tr>
					<tr>
						<td colspan="5">
							<input type="submit" i18n:attributes="value" value="Accept" name="acceptB" />
							<input type="submit" i18n:attributes="value" value="Reject" name="rejectB" />
						</td>
					</tr>
					</tbody>
				</table>
			</form>
		</span>
		
	</span>
</span>
 
</html>
