<?php

	include 'includes/common.php';
	include 'includes/admin_API_Config.php';
    include 'Header.php';
    include 'Navbar.php';
    include 'Sidebar.php';

	$obj = new API_Config;
	$data = array();
	$data['admin_user_id']     = $_SESSION['admin_user_id'];
	$data['admin_username']    = $_SESSION['admin_username'];
	$response = json_decode($obj->call_API("API_getUserProfile.php", $data));

	//var_dump($response);
	$profile = $response->profile_data[0];

	error_reporting(0);
	/*$_SESSION['admin_username'] = $resultData['username'];
	$_SESSION['admin_phone'] = $resultData['phone'];
	$_SESSION['admin_email_address'] = $resultData['email_address'];
	$_SESSION['admin_name'] = $resultData['firstname'] . " " . $resultData['lastname'];
	$_SESSION['admin_user_id'] = $resultData['id'];*/


?>

<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">

			<!-- BEGIN PAGE HEAD -->
			<div class="page-head">
				<!-- BEGIN PAGE TITLE -->
				<div class="page-title">
					<h1>User Account</h1>
				</div>
				<!-- END PAGE TITLE -->
			</div>
			<!-- END PAGE HEAD -->
			<!-- BEGIN PAGE BREADCRUMB -->
			<ul class="page-breadcrumb breadcrumb">
				<li>
					<a href="dashboard.php">Dashboard</a>
					<i class="fa fa-circle"></i>
				</li>
				<li>
					<a href="Profile.php">Profile</a>
				</li>
			</ul>
			<!-- END PAGE BREADCRUMB -->
			<!-- END PAGE HEADER-->

		<!-- BEGIN PAGE CONTENT-->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN PROFILE CONTENT -->
					<div class="profile-content">
						<div class="row">
							<div class="col-md-12">
								
								
								
								<div class="portlet light">
									<div class="portlet-title tabbable-line">
										<div class="caption caption-md">
											<i class="icon-globe theme-font hide"></i>
											<span class="caption-subject font-blue-madison bold uppercase">Profile Account</span>
										</div>
										<ul class="nav nav-tabs">
											<li class="active">
												<a href="#profile" id="tabProfile" data-toggle="tab" >Personal Info</a>
											</li>
											<li>
												<a href="#password" id="tabPassword" data-toggle="tab" >Change Password</a>
											</li>
										</ul>
									</div>
									<div class="portlet-body">
										<div class="tab-content">
											<!-- PERSONAL INFO TAB -->
        									<div class="tab-pane active" id="profile">
												<form role="form" id="frmUserProfile" name="frmUserProfile" action="#" method="post" enctype="multipart/form-data">
													<div class="form-group">
														<label class="control-label">First Name</label>
														<input type="text" class="form-control" id="firstName" name="firstName" value="<?php echo $profile->firstname;?>" readonly/>
													</div>
													<div class="form-group">
														<label class="control-label">Last Name</label>
														<input type="text" class="form-control" id="lastName" name="lastName" value="<?php echo $profile->lastname;?>" readonly/>
													</div>
													<div class="form-group">
														<label class="control-label">Mobile Number</label>
														<input type="text" class="form-control" id="phone" name="phone" value="<?php echo $profile->phone;?>" readonly/>
													</div>
													<div class="form-group">
														<label class="control-label">Email Address</label>
														<input type="text" class="form-control" id="emailID" name="emailID" value="<?php echo $profile->email;?>" readonly/>
													</div>
													<div class="form-group">
														<label class="control-label">Username</label>
														<input type="text" class="form-control" value="<?php echo $profile->username;?>" readonly/>
													</div>
													<p>&nbsp;</p>
													<div class="form-group">
														<button type="submit" class="btn default btn-lg blue" name="btnEditUserProfile" id="btnEditUserProfile">Edit</button>
														<input type="hidden" name="userID"   id="userID" class="form-control" <?php echo $_SESSION['admin_user_id'];?>/>
														<input type="hidden" name="userName" id="userName" class="form-control" <?php echo $_SESSION['admin_username'];?>/>
													</div>
												 </form>
											</div>
											<!-- END PERSONAL INFO TAB -->
											<!-- CHANGE PASSWORD TAB -->
											<div class="tab-pane" id="password">
												<form role="form" id="frmUserPassword" name="frmUserPassword" action="#" method="post" enctype="multipart/form-data">
													<div class="form-group">
														<label class="control-label">Current Password</label>
														<input type="password" class="form-control" id="currentPassword" name="currentPassword"/>
													</div>
													<div class="form-group">
														<label class="control-label">New Password</label>
														<input type="password" class="form-control" id="newPassword" name="newPassword"/>
													</div>
													<div class="form-group">
														<label class="control-label">Re-type New Password</label>
														<input type="password" class="form-control" id="confirmPassword" name="confirmPassword"/>
													</div>
													<p>&nbsp;</p>
													<div class="form-group">
														<button type="submit" class="btn default btn-lg blue" name="btnChangeUserPassword" id="btnChangeUserPassword">Save</button>
														<input type="hidden" name="userID"   id="userID" class="form-control" value="<?php echo $_SESSION['admin_user_id'];?>"/>
														<input type="hidden" name="userName" id="userName" class="form-control" value="<?php echo $_SESSION['admin_username'];?>"/>
													</div>
												 </form>
											</div>
											<!-- END CHANGE PASSWORD TAB -->
										</div>
									</div>
								 </div>


							</div>
						</div>
					</div>
					<!-- END PROFILE CONTENT -->
				</div>
			</div>
		<!-- END PAGE CONTENT-->
		
		
		</div>
	</div>
<!-- END CONTENT -->


<?php

    include 'Footer.php';

?>


<script type="text/javascript">

	   $(".cancel").click(function(){
			 location.reload();
	   });

	   $("#tabProfile").click(function(){
		   disableField();
		   $("#btnEditUserProfile").text("Edit");
	   });


	   $("#tabPassword").click(function(){
		   $("#btnEditUserProfile").text("Save");
	   });




	    function enableField()
		{
			$('#firstName').removeAttr("readonly");
		    $('#lastName').removeAttr("readonly");
			$('#phone').removeAttr("readonly");
			$('#emailID').removeAttr("readonly");
			
	    }


		function disableField()
		{
			
			$('#firstName').attr("readonly", "readonly");
			$('#lastName').attr("readonly", "readonly");
			$('#phone').attr("readonly", "readonly");
			$('#emailID').attr("readonly", "readonly");
		
		}

</script>

</body>
</html>