 <?php
/**
 * user_input_view.php - Admin edit user popup page
 *
 * @author $Author: dtong $
 * @version $Id: user_input_view.php,v 1.15 2011/06/06 14:17:19 dtong Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
*/

$href = base_url();
$refresh	= base_url().$page.'/refresh/'.$selectlistitem.'/'.$filter;
$page = base_url().$page;
$imgreq  = 'req.gif';
$img_req = "<img src=". osa_imagepath() .
	"$imgreq  title='Required field' alt='Required field' border='0' />";

$mode = CMS_ADMIN_UPDATE;
if ($action==CMS_ACTION_ADD) {
 	$id                 = "";
 	$firstname          = "";
 	$lastname           = "";
 	$middlename         = "";
 	$displayname        = "";
 	$sis_teacher_number = "";
 	$username 	        = "";
 	$password 	        = "";
 	$email 	            = "";
 	$title 	            = "";
 	$enabled	        = CMS_DB_BOOLEAN_TRUE;
 	$auth_id	        = CMS_AUTH_ID_LOCAL;
 	$selected_aut = $auth_id;
 	//$mode='insert';
 	$mode = CMS_ADMIN_INSERT;
}
elseif ($action==CMS_ACTION_EDIT) {
	$action = base_url().'admin/user/login/'.$username;
}
else {
 	return;
}
$mode = $page.'/'.$mode;

?>

<form method="POST" action="<?php echo $action?>" name="user_form" id="user_form" autocomplete="off">
<input type="hidden" id="id" name="id" size="30" value="<?php   echo $id; ?>" />
<input type="hidden" id="password" name="password" size="30" value="" />
<center>
<div class="user_title"><?php echo $selected_display; ?></div>
<div id='dhtmlwin_user' class="user_table">

<div id="div_username">
	<table class="user_table_edit"   >
	  		<tr >
			<td class="field_req" ><?php echo lang('admin_user_col_username'); ?><?php echo $img_req; ?></td>
			<td class="user_text_left" >
			<?php
				//The config cms_admin_username_not_change was added mainly for the demos.
				//So, people can not change the demo admin id.
				if ( $id != CMS_ADMIN_USER_DB_ID || !$this->config->item('cms_admin_username_not_change') ) {
			?>
			<input type="text" id="username" name="username" size="30" value="<?php echo $username; ?>" />
			<?php } else {
				echo $username;
			} ?>
			</tr>
	</table>
</div>

<div id="div_password" style="<?php echo $showhide ; ?>">
	<table class="user_table_edit"   >
	  	<tr >
		<td class="field_req" ><?php echo lang('admin_user_col_password'); ?><?php echo $img_req; ?></td>
		<td class="user_text_left" >
		<div id="show_selectd"  ><input type="password" id="showpass" name="showpass" size="30" value="<?php echo $password?>" /></div>
		</tr>
	</table>
</div>

<div id="firstname">
	<table class="user_table_edit"   >
	 	<tr >
		<td class="field_req" ><?php echo lang('admin_user_col_firstname'); ?><?php echo $img_req; ?></td>
		<td class="user_text_left" ><input type="text" id="firstname" name="firstname" size="30" value="<?php   echo $firstname; ?>" />
		</td>
	</table>
</div>

<div id="lastname">
	<table class="user_table_edit"   >
	 	<tr >
		<td class="field_req" ><?php echo lang('admin_user_col_lastname'); ?><?php echo $img_req; ?></td>
		<td class="user_text_left" ><input type="text" id="lastname" name="lastname" size="30" value="<?php   echo $lastname; ?>" />
	</tr>
	</table>
</div>

<div id="middlename">
	<table class="user_table_edit"   >
		<tr >
		<td class="user_edit_left" ><?php echo lang('admin_user_col_middlename'); ?></td>
		<td class="user_text_left" ><input type="text" id="middlename" name="middlename" size="30" value="<?php   echo $middlename; ?>" />
		</tr>
	</table>
</div>

<div id="displayname">
	<table class="user_table_edit"   >
		<tr >
		<td class="user_edit_left" ><?php echo lang('admin_user_col_displayname'); ?></td>
		<td class="user_text_left" ><input type="text" id="displayname" name="displayname" size="30" value="<?php   echo $displayname; ?>" />
		</tr>
	</table>
</div>

<div id="sis_teacher_number">
	<table class="user_table_edit"   >
		<tr >
		<td class="user_edit_left" ><?php echo lang('admin_user_col_teacher_number'); ?></td>
		<td class="user_text_left" ><input type="text" id="sis_teacher_number" name="sis_teacher_number" size="30" value="<?php   echo $sis_teacher_number; ?>" />
		</tr>
	</table>
</div>

<div id="email">
	<table class="user_table_edit"   >
		<tr >
		<td class="field_req" ><?php echo lang('admin_user_col_email'); ?><?php echo $img_req; ?></td>
		<td class="user_text_left" ><input type="text" id="email" name="email" size="30" value="<?php   echo $email; ?>" />
		</tr>
	</table>
</div>

<div id="title">
	<table class="user_table_edit"   >
		<tr >
		<td class="user_edit_left" ><?php echo lang('admin_user_col_title'); ?></td>
		<td class="user_text_left" ><input type="text" id="title" name="title" size="30" value="<?php   echo $title; ?>" />
		</tr>
	</table>
</div>

<div id="department">
	<table class="user_table_edit"   >
		<tr >
		<td class="user_edit_left" ><?php echo lang('admin_user_col_department'); ?></td>
		<td class="user_text_left" >
 		<?php
	    	echo form_dropdown("department_id", $department, $selected_dep, "size=1");
		?>
		</td>
		</tr>
	</table>
</div>

<div id="access">
	<table class="user_table_edit"   >
		<tr >
	    <td class="field_req" ><?php echo lang('admin_user_col_access'); ?><?php echo $img_req; ?></td>
		<td class="user_text_left" >

 		<?php
	 		if ($cms_admin_username != $username){
	 			echo form_dropdown("accessid", $access, $selected_acc, "size=1");
	 		}
	 		else{
 		?>
 			<input type="text" id="accessname" name="accessname" size="30" value="<?php   echo $access[$selected_acc]; ?>"  readonly="readonly"/>
 			<input type="hidden" id="accessid" name="accessid" size="30" value="<?php   echo $selected_acc; ?>"  />
 		<?php
 			}

		?>
		</td>
	</tr>
	</table>
</div>

<div id="auth">
	<table class="user_table_edit"   >
		<tr >
	    <td class="field_req" ><?php echo lang('admin_user_col_auth'); ?><?php echo $img_req; ?></td>
		<td class="user_text_left" >
		<?php
			if ($cms_admin_username != $username){
				echo form_dropdown("auth_id", $auth, $selected_aut, "size=1 " . " onChange='javascript:showhidediv(this,\"div_password\")'");
			}
			else{
		?>
 			<input type="text" id="authname" name="authname" size="30" value="<?php   echo $auth[$selected_aut]; ?>"  readonly="readonly"/>
 			<input type="hidden" id="auth_id" name="auth_id" size="30" value="<?php   echo $selected_aut; ?>"  />
 		<?php
			}

		?>
		</td>
	   </tr>
	</table>
</div>

<div id="Enabled">
	<table class="user_table_edit"   >
		<tr >
		<td class="user_edit_left" ><?php echo lang('admin_user_col_enabled'); ?></td>
		<td class="user_text_left" >
		<?php
			$checked="";
			if ($enabled == '1') {
				$checked='checked';
			}
		?>
		<input type="checkbox"  name="enabled" <?php  echo $checked; ?>  />
	</tr>
	</table>
</div>

</div>
<span class="admin_req"  style="color:red"><?php echo lang('admin_red'); ?></span>
<span class="admin_req" ><?php echo lang('admin_req'); ?></span>
</center>

<div class="reswin_buttons">
	<span id="div_loginas" style="<?php echo $showhideloginas ; ?>">
	<input type="submit" value="<?php echo lang('admin_user_btn_loginas'); ?>" <?php osa_btn()?> />
	</span>
	<span style="margin-left:30px">&nbsp;</span>
	<input type="button" value="<?php echo lang('admin_btn_cancel'); ?>" name="cancel" <?php osa_btn()?>
	onClick="cancelDhtml('user_input');return false;" />

	<span style="margin-left:30px">&nbsp;</span>

	<input type="button" value="<?php echo lang('admin_btn_save'); ?>" name="save" <?php osa_btn()?>
		onClick="submitUser('<?php echo $mode; ?>','user_form','<?php echo $refresh; ?>','page_content','user_input' );return false;" />
</div>

<br />
</form>