<?php
require_once('config/config.php');
require_once('foo/functions.php');
session_start();

dbconnect();

$sql = "SELECT * FROM `".USERS_TABLE_NAME."` WHERE user_name='{$_SESSION['user_login']}'";
$stmt = $pdo->query($sql);
$row = $stmt->fetch(PDO::FETCH_ASSOC);

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="img/favicon.png">
    <title><?php echo WEB_TITLE ?></title>

    <!-- Bootstrap CSS -->    
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- bootstrap theme -->
    <link href="css/bootstrap-theme.css" rel="stylesheet">
    <!--external css-->
    <!-- font icon -->
    <link href="css/elegant-icons-style.css" rel="stylesheet" />
    <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
	<!-- date picker -->
    <link rel="stylesheet" type="text/css" href="assets/bootstrap-datepicker/css/datepicker.css" />
    <!-- Custom styles -->
    <link href="css/style.css" rel="stylesheet">
    <link href="css/style-responsive.css" rel="stylesheet" />
	<link rel="stylesheet" href="css/intlTelInput.css">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
</head>

  <body class="login-body">

    <div class="container">
	
	<!--header start-->
      <header class="header white-bg">

            <!--logo start-->
			<a href="<?php echo HOME_URL ?>">
			<img src="img/logo.png" alt="<?php echo WEB_NAME ?>" />
			</a>
            <!--logo end-->
			
			<!-- notificatoin dropdown start-->
                <ul class="nav pull-right top-menu">
			
			<div class="top-nav notification-row">
			
			<!-- user login dropdown start-->
                    <li class="dropdown">
                        <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                            <span class="profile-ava">
                                <img width="29" height="29" alt="<?php echo $row['first_name']; ?> <?php echo $row['last_name']; ?>" src="users/<?php echo user_photo(preg_replace('/\s/', '', $_SESSION['user_login'])); ?>">                            </span>
                            <span class="username"><?php echo $row['first_name']; ?> <?php echo $row['last_name']; ?></span>
                            <b class="caret"></b>                        </a>
                        <ul class="dropdown-menu extended logout">
                            <div class="log-arrow-up"></div>
							<li class="eborder-top">
								<a href="signout.php"><i class="icon-key"></i> Sign Out</a>
							</li>
                        </ul>
                  </li>
                    <!-- user login dropdown end -->
                </ul>
                <!-- notificatoin dropdown end-->
			
			</div>

            
      </header>      
      <!--header end-->

      <form class="form-validate app-form" id="spl-form" action="splashed.php" method="post" enctype="multipart/form-data">
      
        <div class="login-wrap">
            <h2 class="app-form-heading">Welcome <?php echo $row['first_name']; ?> <?php echo $row['last_name']; ?>, </h2>
			
			<!-- Error Message -->
			<?php if (!empty($_GET['error'])): ?>
			<div class="alert fade in alert-danger">
				<button data-dismiss="alert" class="close close-sm" type="button">
				<i class="icon-remove"></i>
				</button>
				<?php echo $_GET['error']?>
			</div>
			<?php endif ?>
			
			<!-- Success Message -->
			<?php if (!empty($_GET['msg'])): ?>
			<div class="alert fade in alert-success">
				<button data-dismiss="alert" class="close close-sm" type="button">
				<i class="icon-remove"></i>
				</button>
				<?php echo $_GET['msg']?>
			</div>
			<?php endif ?>

			<p>let's help you secure your account, please take time to update your settings.</p>
			<hr>
			<h2>Security Settings</h2>
            <div class="input-group col-sm-6">
              <input type="password" id="pass" name="pass" class="form-control" placeholder="Enter New Password" autofocus required>
            </div>
            <div class="input-group col-sm-6">
                <input type="password" id="pass2" name="pass2" class="form-control" placeholder="Confirm your Password" required>
            </div>
			<div class="input-group col-sm-6">
              <input type="password" id="pin" name="pin" class="form-control" placeholder="Enter New PIN" required>
            </div>
            <div class="input-group col-sm-6">
                <input type="password" id="pin2" name="pin2" class="form-control" placeholder="Confirm your PIN" required>
            </div>
			<div class="input-group col-sm-12">
                <input type="text" id="secq" name="secq" class="form-control" placeholder="Enter a security question" required>
            </div>
			<div class="input-group col-sm-12">
                <input type="password" id="seca" name="seca" class="form-control" placeholder="Enter your answer" required>
            </div>
			
			<?php 
			dbconnect();
			$sql = "SELECT * FROM `".USERS_TABLE_NAME."` WHERE user_acc='{$_SESSION['user_acc']}'";
			$stmt = $pdo->query($sql);
			$row = $stmt->fetch(PDO::FETCH_ASSOC);
			if (empty($row['user_photo'])) { echo '
			<h2>Passport Photo</h2>
			<div class="input-group col-sm-12">
              <input type="file" id="photo" name="photo" class="form-control" accept="image/*" placeholder="Passport Photo" required>
            </div>
			';}else{ echo '';} 
			?>
			
			<div class="input-group col-sm-12">
              <button class="btn btn-primary btn-lg" name="submit" id="submit" type="submit">Update</button>
            </div>
        </div>
      </form>

    </div>
	
	<!-- javascripts -->
    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <!-- nice scroll -->
    <script src="js/jquery.scrollTo.min.js"></script>
    <script src="js/jquery.nicescroll.js" type="text/javascript"></script>
    <!-- jquery validate js -->
    <script type="text/javascript" src="js/jquery.validate.min.js"></script>
	
	<!-- jquery ui -->
    <script src="js/jquery-ui-1.9.2.custom.min.js"></script>
	
	<!--custom checkbox & radio-->
    <script type="text/javascript" src="js/ga.js"></script>
    <!--custom switch-->
    <script src="js/bootstrap-switch.js"></script>
    <!--custom tagsinput-->
    <script src="js/jquery.tagsinput.js"></script>
    
    <!-- colorpicker -->
    <script type="text/javascript" src="assets/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
	
	<!-- bootstrap-datepicker -->
    <script type="text/javascript" src="assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="assets/bootstrap-daterangepicker/date.js"></script>
    <script type="text/javascript" src="assets/bootstrap-daterangepicker/daterangepicker.js"></script>
	<script src="js/intlTelInput.js"></script>
	<script>
      $("#phone").intlTelInput({
        utilsScript: "js/utils.js"
      });
    </script>

    <!-- custom form validation script for this page-->
    <script src="js/form-validation-script.js"></script>
	<!-- custom form component script for this page-->
    <script src="js/form-component.js"></script>
    <!--custome script for all page-->
    <script src="js/scripts.js"></script>


  </body>
</html>
