<? $this->load->view( $this->aSystemVar['template_viewer_root'] . 'admin/_header') ?>
	<div class="bigCaption">Users</div>

	<div class="filter">
		<?= form_open('admin/user_list/', array( 'id' => 'filter_user_form') ) ?>
			<div>
			<select name="Status">
				<option value=""<?= empty($User_list['Status']) ? ' selected="selected" ' : '' ?>>all</option>
				<option value="active"<?= $User_list['Status'] == 'active' ? ' selected="selected" ' : '' ?>>active</option>
				<option value="inactive"<?= $User_list['Status'] == 'inactive' ? ' selected="selected" ' : '' ?>>inactive</option>
				<option value="unconfirmed"<?= $User_list['Status'] == 'unconfirmed' ? ' selected="selected" ' : '' ?>>unconfirmed</option>
			</select>
			<select name="FUserGroup">
				<option value="0" <?=(0==$User_list['UserGroup']?' selected="selected" ':'')?>>all</option>
				<? foreach ($User_group as $aItem): ?>
					<option value="<?=$aItem['Id']?>" <?=($aItem['Id']==$User_list['UserGroup']?' selected="selected" ':'')?>><?=$aItem['GroupName']?></option>
				<? endforeach; ?>
			</select>			
			<input type="text" name="User" id="NameFilter" value=" name" class="text" style="color:#888888;font-style:italic;" onfocus="this.value='';" />
			<input type="text" name="Email" id="EmailFilter" value=" email" class="text" style="color:#888888;font-style:italic;" onfocus="this.value='';" />

			<input type="submit" value="filter" class="submit" onClick="javascript: var nf=document.getElementById('NameFilter'); if(' name'==nf.value){nf.value='';} var ef=document.getElementById('EmailFilter'); if(' email'==ef.value){ef.value='';}" />
			</div>
		<?= form_close(); ?>
	</div>

	<?= form_open('admin/user_list/' . $User_list['Status'], array( 'id' => 'approve_user_form') ) ?>
		<input type="hidden" id="useraction" name="useraction" value="" />
		<input type="hidden" id="uservalue" name="uservalue" value="" />
		<table cellpadding="0" cellspacing="1" width="100%" class="contentList">
			<tr class="head">
				<td class="id">id</td>
				<td class="checkbox"><input type="checkbox" disabled="disabled" /></td>
				<td>image</td>
				<td class="title">NickName</td>
				<td class="desc">description</td>
				<td class="keywords">email</td>
				<td class="status">status</td>
				<td>posts</td>
				<td>messages</td>
				<td colspan="4" class="action">actions</td>
				<td>group</td>
			</tr>
			<? $i=0; ?>
			<? foreach( $User_list['UserList'] as $aUser ): ?>
					<?
				if( ($i%2) == 0 )
				{
					$sClassName = 'odd';
				}
				else
				{
					$sClassName = 'even';
				}
			?>

			<tr class="<?= $sClassName ?>">
					<td class="id"><?= $aUser['Id'] ?></td>
					<td class="checkbox"><input type="checkbox" name="UserId[]" value="<?= $aUser['Id'] ?>" id="u<?= $aUser['Id'] ?>" class="checkbox" /></td>
					<td><img src="<?= $aUser['PicUrl'] ?>" alt="" /></td>
					<td class="title"><?= $aUser['Name'] ?></td>
					<td class="desc"><?= $aUser['Description'] ?></td>
					<td class="email"><?= $aUser['Email']	 ?></td>
					<td class="status textCenter"><?= $aUser['Status'] ?></td>
					<td class="textCenter">
					<?
						if( empty($aUser['PostNum']) )
							echo $aUser['PostNum'];
						else
							echo anchor('admin/post_list/0/0/' . $aUser['Id'], $aUser['PostNum'] );
					?>
					</td>
					<td class="textCenter">
					<?
						if( empty($aUser['MailInboxNum']) )
							echo $aUser['MailInboxNum'];
						else
							echo anchor( 'mailbox/inbox/' . $aUser['Id'], $aUser['MailInboxNum'] );

					?>
					</td>
					<td class="view textCenter"><?= anchor('user/profile/' . $aUser['Name'], 'view' ) ?></td>
					<td class="edit textCenter"><?= anchor('user/profile_edit/' . $aUser['Name'], 'edit') ?></td>
						<? if( $aUser['Status'] == 'inactive' ): ?>
							<td class="textCenter activate">
								<a href="#" onclick="javascript: document.getElementById('action').value='active'; document.getElementById('u<?= $aUser['Id'] ?>').checked = true; document.getElementById('approve_user_form').submit(); return false;">activate</a>
							</td>
						<? elseif( $aUser['Status'] == 'unconfirmed' ): ?>
							<td class="textCenter view">
								<a href="#" onclick="javascript: document.getElementById('useraction').value='active'; document.getElementById('u<?= $aUser['Id'] ?>').checked = true; document.getElementById('approve_user_form').submit(); return false;">activate</a><br />
								<a href="#" onclick="javascript: document.getElementById('useraction').value='inactive'; document.getElementById('u<?= $aUser['Id'] ?>').checked = true; document.getElementById('approve_user_form').submit(); return false;">deactivate</a>
							</td>
						<? else: ?>
							<td class="textCenter deactivate">
								<a href="#" onclick="javascript: document.getElementById('useraction').value='inactive'; document.getElementById('u<?= $aUser['Id'] ?>').checked = true; document.getElementById('approve_user_form').submit(); return false;">deactivate</a>
							</td>
						<? endif; ?>
					<td class="delete textCenter"><a href="#" onclick="javascript: document.getElementById('useraction').value='deleted'; document.getElementById('u<?= $aUser['Id'] ?>').checked = true; document.getElementById('approve_user_form').submit(); return false;">delete</a></td>
					<td class="delete textCenter">
						<select name="usergroup" 
							onchange="javascript: $('useraction').value='changegroup'; $('uservalue').value=this.value; $('u<?=$aUser['Id']?>').checked = true; $('approve_user_form').submit(); return false;">
							<? foreach ($User_group as $aItem): ?>
								<option value="<?=$aItem['Id']?>" <?=($aItem['Id']==$aUser['UserGroup']?' selected="selected" ':'')?>><?=$aItem['GroupName']?></option>
							<? endforeach; ?>
						</select>
					</td>
				</tr>
				<? $i++;?>
			<? endforeach; ?>
		</table>
	<?= form_close(); ?>
<? $this->load->view( $this->aSystemVar['template_viewer_root'] . 'admin/_footer') ?>