<?php $msg = empty($msg)? get_session_msg($this): $msg; $this->session = \Config\Services::session(); ?>
<!DOCTYPE html>
<html>

<head>
	<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
	<meta content="utf-8" http-equiv="encoding">
    <meta name="description" content="The Teacher Management Information System (TMIS) is a simple user-friendly approach to supporting a harmonized and timely access to teacher information and streamlining the delivery of government services to members of the teaching profession in Uganda.">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="shortcut icon" href="<?php echo base_url();?>/favicon.ico" type="image/x-icon">
	<link rel="icon" href="<?php echo base_url();?>/favicon.ico" type="image/x-icon">

	<title><?php echo SITE_TITLE;?>: My Settings</title>

	<!-- Stylesheets -->
	<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.css" />
	<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.mobile.css" media="(max-width:790px)" />
	<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.tablet.css" media="(min-width:791px) and (max-width: 900px)" />
	<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.desktop.css" media="(min-width:901px)" />
	<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.list.css" />
	<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.menu.css" />
	<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.shadowbox.css" />
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-uWxY/CJNBR+1zjPWmfnSnVxwRheevXITnMqoEIeG1LJrdI0GlVs/9cVSyPYXdcSF" crossorigin="anonymous">
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
	<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/updated.css" />

	<!-- Javascript -->
	
	<?php echo minify_js('profile-user_data', array('jquery-2.1.1.min.js', 'jquery.form.js', 'tmis.js', 'tmis.callout.js', 'tmis.fileform.js', 'tmis.menu.js', 'tmis.responsive.js', 'tmis.shadowbox.js'));?>
	<!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-JM8P0P17Z6"></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', 'G-JM8P0P17Z6');
		var logout_timer = 0;

		function set_logout_interval() {
			// the interval 'timer' is set as soon as the page loads
			logout_timer = setInterval("auto_logout()", 600000);
			// the figure '600000' above indicates how many milliseconds (10 Minutes) the timer be set to.

		}

		function reset_logout_interval() {
			//After events on a page like click,scroll,page load, keystroke
			if (logout_timer != 0) {
				clearInterval(logout_timer);
				logout_timer = 0;
				// second step: implement the timer again
				logout_timer = setInterval("auto_logout()", 600000);
				// completed the reset of the timer
			}
		}

		function auto_logout() {
			// this function will redirect the user to the logout script
			window.location.href = "<?php echo base_url();?>/Account/logout";
		}
	</script>

	<style>
		/* Any element that is not writable */
		:read-only {}

		/* ... so you might want to scope it */
		input:read-only,
		textarea:read-only,
		[contenteditable]:read-only {
			cursor: not-allowed;
		}
	</style>
</head>

<body onload="set_logout_interval()" onmousemove="reset_logout_interval()" onclick="reset_logout_interval()" onkeypress="reset_logout_interval()" onscroll="reset_logout_interval()">
	<?php echo view("addons/secure_header", array('page'=>'my_settings'));?>
	<div class="container-fluid mx-auto mt-5 pt-5 px-0 app-area">
		<aside class="app-area-sidebar px-3 py-4 bg-primary d-none d-md-block">
			<nav id="menucontainer" class="nav flex-column">
				<?php echo view("addons/menu", array('clear_menu'=>'Y'));?>
			</nav>
		</aside>
		<main class="app-area-content px-3 bg-light">
			<?php echo !empty($msg)?"<div>".format_notice($this, $msg)."</div>": "";?>
			<section class="d-flex justify-content-between align-items-center app-area-content-intro">
				<h3>My Settings</h3>
				<div class="editcontent" title="Edit Profile">
					<i class="bi bi-pencil-square"></i>
				</div>
			</section>
			<section class="app-area-content-body mt-3 px-3 py-3 bg-white">
				<form id="user_data" method="post" autocomplete="off" enctype="multipart/form-data" action="<?php echo base_url();?>/Profile/user_data" class='simplevalidator row g-3'>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<span class="label text-start fw-bold d-block">Username</span>
						<span class="value d-block">
							<?php echo $this->session->get('profile_loginname'); ?>
						</span>
						<div <?php echo $this->session->get('__permission_group') == '4'? " width='98%'": "";?>>

							<?php

							if ($this->session->get('__permission_group') == 4) {

								echo "
									<table align='right' class='listtable' style='border: 1px solid #DDDDDD; text-align: right; width: 220px;'>
										<tr>
											<td>
												<div class='rightnote'>
													<a href='".base_url()."/Cron/update_query_cache' class='shadowbox closable'>refresh query cache</a>
												</div>
											</td>
										</tr>
										<tr>
											<td>
												<div class='rightnote'>
													<a href='".base_url()."/Cron/update_message_cache' class='shadowbox closable'>refresh message cache</a>
												</div>
											</td>
										</tr>
									</table>
								";
								
							}

							?>

						</div>
					</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<span class="label text-start fw-bold d-block">Current Role</span>
						<span class="value d-block">

							<?php echo $this->session->get('profile_userrole'); ?>
						
						</span>
					</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<span class="label top text-start fw-bold d-block">Current Password</span>
						<span>
							<div class="viewdiv value">*********</div>
							<div class="editdiv">
								<input type="password" id="currentpassword" name="currentpassword" title="Current Password" placeholder="Current Password" maxlength="100" class="textfield optional" value="" />
								<div class="editdiv smalltext">Enter the password only if you want to change it.</div>
							</div>
						</span>
					</div>
					<div class="col-md-6 m-0 nextdiv">
						<div class="editdiv border-bottom pb-2 mb-2">
							<span class="label editdiv text-start fw-bold d-block">New Password</span>
							<input type="password" id="newpassword" name="newpassword" title="New Password" placeholder="New Password" maxlength="100" class="textfield optional" value="" />
						</div>
					</div>
					<div class="col-md-6 m-0 nextdiv">
						<div class="editdiv">
							<input type="password" id="repeatpassword" name="repeatpassword" title="Repeat New Password" placeholder="Repeat New Password" maxlength="100" class="textfield optional" value="" />
						</div>
					</div>
					<div class="col-md-6 m-0 editdiv smalltext">Your new password should be at least 8 characters long with a letter and a number.</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<span class="label text-start fw-bold d-block">Surname <?php //echo $approved;?></span>
						<span>
							<div class="viewdiv value">
								<?php echo $this->session->get('profile_lastname');?>
							</div>
							<div class="editdiv">
								<input type="text" id="lastname" name="lastname" title="Surname" class="textfield" value="<?php echo $this->session->get('profile_lastname');?>" <?=(!empty($approved) && ($approved == 'Y')) ?'readonly' :'' ; ?> />
							</div>
						</span>
					</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<td class="label">Other Names:</td>
						<td>
							<div class="viewdiv value">
								<?php echo $this->session->get('profile_firstname');?>
							</div>
							<div class="editdiv">
								<input type="text" id="firstname" name="firstname" title="Other Names" <?=(!empty($approved) && ($approved == 'Y')) ?'readonly' :'' ; ?> class="textfield" value="<?php echo $this->session->get('profile_firstname'); ?>" />
							</div>
						</td>
					</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<td class="label">NIN:</td>
						<td>
							<div class="viewdiv value">
								<?php echo $this->session->get('profile_nin');?>
							</div>
							<div class="editdiv">
								<input type="text" id="nin" name="nin" minlength="14" maxlength="14" title="National Identification Number (NIN)" <?=(!empty($approved) && ($approved == 'Y')) ?'readonly' :'' ; ?> class="textfield" value="<?php echo $this->session->get('profile_nin');?>" />
							</div>
						</td>
					</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<td class="label top">Photo:</td>
						<td>
							<div class="viewdiv value">
								<?php echo $this->session->get('profile_photo')? "<img src='".base_url().'/assets/uploads/images/'.$this->session->get('profile_photo')."' style='max-height:80px;' border='0' />": 'None';?>
							</div>
							<div class="editdiv">
								<?php echo $this->session->get('profile_photo')? "<img src='".base_url().'/assets/uploads/images/'.$this->session->get('profile_photo')."' style='max-height:110px;' border='0' /><br>": '';?>
								<input type="text" id="photo" name="photo" title="Your Profile Photo" data-size='300' data-val='jpg,jpeg,gif,png,tiff' class="textfield filefield optional" <?php echo $this->session->get('profile_photo')? "placeholder='Select New Image'": '';?> value="" />
								<div class="editdiv smalltext">Allowed Formats: JPG, JPEG, GIF, PNG, TIFF &nbsp;&nbsp; Max Size: 300kB</div>
							</div>
						</td>
					</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<td class="label top">Signature on File</td>
						<td>
							<div class="viewdiv value">
								<?php
								
								echo $this->session->get('profile_signature')? "<img src='".base_url().'/assets/uploads/images/'.$this->session->get('profile_signature')."' style='max-height:80px;' border='0' />": 'None';
								
								?>
							</div>
							<div class="editdiv">
								<?php
								
								echo $this->session->get('profile_signature')? "<img src='".base_url().'/assets/uploads/images/'.$this->session->get('profile_signature')."' style='max-height:80px;' border='0' />": '';
								
								?>
								
								<input
									type="text"
									id="signature"
									name="signature"
									title="Your Signature on File"
									data-size='300'
									data-val='jpg,jpeg,gif,png,tiff'
									class="textfield filefield optional"

									<?php echo $this->session->get('profile_signature')? "placeholder='Select New Image'": ''; ?>

									value=""
								/>
								
								<div class="editdiv smalltext">Allowed Formats: JPG, JPEG, GIF, PNG, TIFF &nbsp;&nbsp; Max Size: 300kB</div>
							</div>
						</td>
					</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<td class="label">Telephone</td>
						<td>
							<div class="viewdiv value">
								<?php echo($this->session->get('profile_telephone')? $this->session->get('profile_telephone'): '&nbsp;');?>
							</div>
							<div class="editdiv"><input type="text" id="telephone"
									name="telephone" title="Telephone"
									placeholder="Optional" maxlength="16"
									class="textfield numbersonly optional"
									value="<?php echo($this->session->get('profile_telephone')? $this->session->get('profile_telephone'): '');?>" />
							</div>
						</td>
					</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<td class="label">Email Address</td>
						<td class="value">
							<?php echo $this->session->get('profile_emailaddress');?></td>
						<td class="value">&nbsp;</td>
					</div>
					<div class="col-md-6 m-0 border-bottom pb-2 mb-2">
						<td class="label">Address</td>
						<td>
							<div class="viewdiv value">
								<?php echo($this->session->get('contactaddress__addressline')? $this->session->get('contactaddress__addressline')." ".$this->session->get('contactaddress__county')." <br>".$this->session->get('contactaddress__district').($this->session->get('contactaddress__country')? ", ".$this->session->get('contactaddress__country'): ''): 'None');?>
							</div>
							<div class="editdiv"><input type="text" id="contactaddress"
									name="contactaddress" title="Contact Address"
									placeholder="" maxlength="16"
									class="textfield placefield optional"
									value="<?php echo($this->session->get('contactaddress__addressline')? $this->session->get('contactaddress__addressline'): '');?>" />
							</div>
						</td>
					</div>
					<div class="col-md-12 editdiv">
						<span class="editdiv d-block">
							<input type="submit" name="save" id="save" class="btn" value="SAVE" />
						</span>
					</div>
				</form>
			</section>
		</main>
	</div>
	<?php echo view("addons/secure_footer");?>
</body>

</html>