<?php include('inc/header.php'); 
if(isset($_POST['pofile_submit']))
{
	
	$userObj->first_name=sanitize($_POST['first_name']);
	$userObj->last_name=sanitize($_POST['last_name']);
	$userObj->email=sanitize($_POST['email']);
	$userObj->phone=sanitize($_POST['phone']);
	$userObj->date_updated=date('Y-m-d H:i:s');

$file_exts = array("jpg", "bmp", "jpeg", "gif", "png");
$upload_exts = end(explode(".", $_FILES["profile_pic"]["name"]));

if ((($_FILES["profile_pic"]["type"] == "image/gif")

|| ($_FILES["profile_pic"]["type"] == "image/jpeg")

|| ($_FILES["profile_pic"]["type"] == "image/png")

|| ($_FILES["profile_pic"]["type"] == "image/pjpeg"))

&& ($_FILES["profile_pic"]["size"] < 600000)

&& in_array($upload_exts, $file_exts))
{
if ($_FILES["profile_pic"]["error"] > 0)
{
echo "Return Code: " . $_FILES["profile_pic"]["error"] . "<br>";
}
else
{
// Enter your path to <span id="IL_AD5" class="IL_AD">upload file</span> here
$filename=time().$_FILES["profile_pic"]["name"];
if (file_exists("admin_users/".$filename))
{

}
else
{

if($user_check==-1)
{	
move_uploaded_file($_FILES["profile_pic"]["tmp_name"],"admin_users/".$filename);
$userphotoObj->user_type='Admin';
$userphotoObj->path=sanitize("admin_users/".$filename);
$userphotoObj->userid=$userid;
$userphotoObj->insert();
}
else
{
move_uploaded_file($_FILES["profile_pic"]["tmp_name"],"admin_users/".$filename);
$userphotoObj->id=$user_check;
$userphotoObj->user_type='Admin';
$userphotoObj->path=sanitize("admin_users/".$filename);
$userphotoObj->userid=$userid;
$userphotoObj->update($user_check);
}
}

}

}
else
{
$file_err=1;

}
	$userObj->update($userid);
	$msg=1;
}
?>
			<!-- mobile navigation -->
			<nav id="mobile_navigation"></nav>
			
			<section id="breadcrumbs">
				<div class="container">
					<ul>
						<li><a href="#">Web School</a></li>
						<li><a href="#">Settings</a></li>
						<li><span>My Profile</span></li>						
					</ul>
				</div>
			</section>
			<section class="container clearfix main_section">
				<div id="main_content_outer" class="clearfix">
					<div id="main_content">
						<div class="alert alert-info"><strong> My Profile </strong></div>
						<!-- main content -->
                        <!--Message-->
						<?php if($msg==1){ ?>
                        <div class="success">Yeah ! Profile has been updated successfully</div>
                        <?php } ?>
                         <!--Message-->
						<div class="row">
							<div class="col-sm-12">
								<div class="user_heading">
									<div class="row">
										<div class="col-sm-2 hidden-xs">
                                        
											<img src="<?php echo SITE_URL; if($userphotoObj->path==''){ ?>img/user_avatar_lg.png<?php } else {?><?php echo $userphotoObj->path;  } ?>" alt="" class="img-thumbnail user_avatar">
										</div>
										<div class="col-sm-10">
											<div class="user_heading_info">
												<div class="user_actions pull-right" title="Edit Profile">
													<a href="#" class="edit_form"  data-placement="top auto" ><span class="icon-edit"></span></a>
													<!--<a href="#" class="remove_user" data-toggle="tooltip" data-placement="top auto" title="Remove User"><span class="icon-remove"></span></a>-->
												</div>
												<h1>Name : <?php echo $userObj->first_name.' '.$userObj->last_name; ?></h1>
												<h2>Username : <?php echo $userObj->username; ?></h2>
											</div>
										</div>
									</div>
								</div>
								<div class="user_content">
									<div class="row">
										<div class="col-sm-10 col-sm-offset-2">
											<form name="my_profile" id="my_profile" class="form-horizontal user_form" action="#" method="POST" enctype="multipart/form-data">
												<h3 class="heading_a">General</h3>
												<div class="form-group">
													<label class="col-sm-2 control-label">Username</label>
													<div class="col-sm-10 editable">
														<p class="form-control-static"><?php echo $userObj->username; ?></p>
														<div class="hidden_control">
														<input type="text" class="form-control" value="<?php echo $userObj->username; ?>"  readonly >	
														</div>
													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-2 control-label">First Name</label>
													<div class="col-sm-10 editable">
														<p class="form-control-static"><?php echo $userObj->first_name; ?></p>
														<div class="hidden_control">
															<input type="text" class="form-control" value="<?php echo $userObj->first_name; ?>" name="first_name" id="first_name" data-required="true">
														</div>
													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-2 control-label">Last Name</label>
													<div class="col-sm-10 editable">
														<p class="form-control-static"><?php echo $userObj->last_name; ?></p>
														<div class="hidden_control">
															<input type="text" class="form-control" value="<?php echo $userObj->last_name; ?>" name="last_name" id="last_name" data-required="true" >
														</div>
													</div>
												</div>
												<h3 class="heading_a">Contact info</h3>
												<div class="form-group">
													<label class="col-sm-2 control-label">Email</label>
													<div class="col-sm-10 editable">
														<p class="form-control-static"><?php echo $userObj->email; ?></p>
														<div class="hidden_control">
															<input type="text" class="form-control" value="<?php echo $userObj->email; ?>" name="email" id="email" data-required="true" data-type="email">
														</div>
													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-2 control-label">Phone</label>
													<div class="col-sm-10 editable">
														<p class="form-control-static"><?php echo $userObj->phone; ?></p>
														<div class="hidden_control">
															<input type="text" class="form-control" value="<?php echo $userObj->phone; ?>" name="phone" id="phone" data-required="true" data-type="phone">
														</div>
													</div>
												</div>
												
													<div class="form-group">
													<label class="col-sm-2 control-label">Upload Photo</label>
													<div class="col-sm-10 editable">
														<p class="form-control-static">
                                                        <img src="<?php echo $userphotoObj->path; ?>" alt=""  width="300" height="300" class="img-thumbnail user_avatar"></p>
														<div class="hidden_control">
															<input type="file"  name="profile_pic" id="profile_pic">
														</div>
													</div>
												</div>
												
												
												
												<div class="form_submit clearfix" style="display:none">
													<div class="row">
														<div class="col-sm-10 col-sm-offset-2">
															<button type="submit" class="btn btn-success" name="pofile_submit" id="pofile_submit">Save</button>
														</div>
													</div>
												</div>
											</form>
										</div>
									</div>
								</div>
							</div>
						</div>

					</div>
				</div>
			</section>
			<div id="footer_space"></div>
		</div>
	<?php include('inc/footer.php'); ?>