<?php  include "header.php";

$session = $_SESSION['spm_gold'];
$id = $session['id'];

    $statement = $pdo->prepare("SELECT * FROM tbl_users where id = ?");
    $statement->execute(array($id));
    $emp_data = $statement->fetchAll(PDO::FETCH_ASSOC);
    $totalData = $statement->rowCount();
    
    $error_message='';
    
    
    
    
    if(isset($_POST['form3'])) {
        
        
	    $valid = 1;
	    
	    
    	if( empty($_POST['password']) || empty($_POST['re_password']) ) {
            $valid = 0;
            $error_message .= "Password can not be empty<br>";
        }
        
        
        if( !empty($_POST['password']) && !empty($_POST['re_password']) ) {
        	if($_POST['password'] != $_POST['re_password']) {
    	    	$valid = 0;
    	        $error_message .= "Passwords do not match<br>";	
        	}        
        }
        
        
    if($valid == 1) {
    	$pass="";
    
    	    $session['password'] = $_POST['password'];
    	    $pass = $session['password'];
    	
    	// Updating the Database
		$statement = $pdo->prepare("UPDATE tbl_users SET password=? WHERE id=?");
		$statement->execute(array($pass,$session['id']));
    	$message = 'User Password is Updated Successfully.';
    }
    
    
   
   
    
}
?>


<div class="content-wrapper" style="background:white;">
    
    
    
    
    
    
    <br>
        <div class="col-lg-12 alerts">
            <div id="custom-alerts" style="display:none;">
                <div class="alert alert-dismissable">
                    <div class="custom-msg"></div>
                </div>
            </div>
            <?php if ($error_message)  { ?>
            <div class="alert alert-danger alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-ban"></i> Error</h4>
                <?= $error_message; ?>
            </div>
            <?php $error=0;} if ($warning) { ?>
            <div class="alert alert-warning alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-warning"></i> Warning</h4>
                <?= $warning; ?>
            </div>
            <?php  $warning=0;} if ($message) { ?>
            <div class="alert alert-success alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4>    <i class="icon fa fa-check"></i> Success</h4>
                <?= $message; ?>
            </div>
            <?php $message=0; } ?>
        </div>
        <div class="clearfix"></div>


<section class="content-header">
            <h1><b>Update Profile Details</b></h1>
            <ol class="breadcrumb">
                <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
                <li class="active">Update Profile</li>            
            </ol>
</section>


</br>

<?php foreach($emp_data as $data){ ?>

<section class="content">
    <div class="row">
		<div class="col-md-12">
				
				<div class="nav-tabs-custom">
					<ul class="nav nav-tabs">
						<li class="active"><a href="#tab_1" data-toggle="tab">Personal Details</a></li>
						<li><a href="#tab_3" data-toggle="tab">Update Password</a></li>
						<li><a href="#tab_4" data-toggle="tab">Account Details</a></li>
					</ul>
					
					
					
					<div class="tab-content">
					    
					    
					    
          				<div class="tab-pane active" id="tab_1">
							 <div class="row">
							     
							     
							     
		                      <!--<div class="col-md-2">
		                          <center><h5 class="box-title"><b><i class="fa fa-user"></i> Profile </b></h5></center>
		                          <?php //if($data['photo']==""){
		                              //echo '<img src="upload/default-photo.png" style="width:150px;">';
		                          //}else { ?>
		                          <img src="<?//=$data['photo']?>" style="width:150px;">
		                          <?php //} ?>
		                      </div>-->
		                      
		                      
		                      
		                      <div class="col-md-6">    
		                      <center><h5 class="box-title"><b><i class="fa fa-user"></i> Personal Information </b></h5></center>
                                    Name : <b><?=$data['name']?></b><br>
                                    Employee Code : <b><?=$data['emp_code']?></b><br>
                                    Mobile No : <b><?=$data['mobile']?></b><br>
                              </div>
                              
                              
                              
		                      <div class="col-md-6">
		                          <center><h5 class="box-title"><b><i class="fa fa-user"></i> Account Login Details </b></h5></center>
		                          User Type : <b>***</b><br>
		                          Role : <b>***</b><br>
		                          Email Id : <b><?=$data['email']?></b><br>
		                          Password : <b>*****</b><br>
		                      </div>
							</div>
							
							
							
							
							
							
          				</div>
          				
          				
          				
          				
          				
          				
          				
          				
          				<div class="tab-pane" id="tab_3">
							<form class="form-horizontal" action="" method="post">
							<div class="box box-info">
								<div class="box-body">
									<div class="form-group">
										<label for="" class="col-sm-2 control-label">Password </label>
										<div class="col-sm-4">
											<input type="password" class="form-control" name="password">
										</div>
									</div>
									<div class="form-group">
										<label for="" class="col-sm-2 control-label">Retype Password </label>
										<div class="col-sm-4">
											<input type="password" class="form-control" name="re_password">
										</div>
									</div>
							        <div class="form-group">
										<label for="" class="col-sm-2 control-label"></label>
										<div class="col-sm-6">
											<button type="submit" class="btn btn-success pull-left" name="form3">Update Password</button>
										</div>
									</div>
								</div>
							</div>
							</form>

          				</div>
          				
          				
          				
          				
          				<div class="tab-pane" id="tab_4">
							 <div class="row">
							        <center><h5 class="box-title"><b><i class="fa fa-user"></i> Bank Details - Information </b></h5></center><br>
							  <div class="col-md-4"></div>
		                      <div class="col-md-2">    
		                            Account Holder Name : <br>
		                            Account Number : <br>
                                    Bank Name : <br>
                                    Branch Name : <br>
                                    Bank Code : <br>
		                      </div>
		                      <div class="col-md-2">    
                                    <b><?=$data['name']?></b><br>
                                    <b><?=$data['account_number']?></b><br>
                                    <b><?=$data['bankname']?></b><br>
                                    <b><?=$data['branch']?></b><br>
                                    <b><?=$data['bankcode']?></b><br>
		                      </div>
		                      <div class="col-md-4"></div>
							</div>
							
							
							
							
							
							
          				</div>
          			</div>
				</div>			

		</div>
	</div>
</section>
<?php } ?>

<?php include "footer.php";?>