<?php include("includes/header.php"); ?>
<?php include("includes/auto_out.php"); ?>
<!DOCTYPE html>
<html>
<head>
  <title>Edit User Details | <?php echo $sitename;  ?> HQ</title>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">

   <!--CSS-->
  <link rel="stylesheet" href="style.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">

    <!-- Bootstrap Core CSS -->
      <link href="css/bootstrap.min.css" rel="stylesheet">

     <!-- Font Awesome -->
    <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">

      <!-- Custom CSS -->
      <link href="css/blog-home.css" rel="stylesheet">

      <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
      <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
      <!--[if lt IE 9]-->
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
          <script src="js/jquery.js"></script>
          <script src="js/bootstrap.js"></script>





          <!----MODAL-------------------->
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>



</head>

<body>
  <?php  include("includes/dashboard_navbar.php"); ?>
  <!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here-->
  <style>
    body{
      background-color: #f5f5f5;
    }
    .destop-siderbar{
      background-color: #131e2a;
      height: 100%;
      width:240px;
      box-shadow: 0 0 4px 0 rgba(0,0,0,.50), 0 2px 4px 0 rgba(0,0,0,.50);
      position: fixed;
      margin-left:-20px;
      padding:50px 25px;
    }
    .destop-siderbar li{
       padding: 30px 20px;
       list-style: none;
    }
    .destop-siderbar li a{
      color: #fff;
      font-size: 17px;
      padding:10px 0px;
    }
    .destop-siderbar li a i{
      color:rgb(45, 156, 219);
      font-weight: lighter;
    }
    .destop-siderbar .active {
      background-color:#123962;
      box-shadow: 0 0 4px 0 rgba(0,0,0,.50), 0 2px 4px 0 rgba(0,0,0,.50);
      
    }
    .destop-siderbar .active a{
      color:#fff;
    }
    .destop-siderbar .active a:hover{
      color:#fff;
    }
    .destop-siderbar li a:hover{
      color: #a5bdd9;
      text-decoration: none;
    }
    .panel{
      border-radius: 0px;
      border-color: transparent;
    }
    .input-danger{
       border:1px solid darkred;
       color:darkred;
     }
     .input-danger::placeholder{
       opacity: 0.6;
       color:darkred;
     }
  </style>

  <div class="container-fluid">
    <div class="row">
      <!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here-->
      <div class="col-sm-2 hidden-xs" style="height: 100%;">
             <?php include("includes/desktop_side.php"); ?>
      </div>
      <!--/////////////////////// DESTOP Side bar starts here--><!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here-->
      <div class="col-sm-10">
        <br><br><br><br>

        <!----------------------------------------------------------------------------------->

        <div class="row">
          <div class="col-sm-12">
            <div class="row">


              <div class="col-sm-12">
                 <div class="panel panel-default">
                  <div class="panel-body">
                       <span style="font-size: 16px; font-weight: bold;"><img src="images/users.png" width="50px">&nbsp;&nbsp; EDIT USER</span>
                       <hr>

                       <?php
                          if(isset($_GET["user_id"])){
                            $user_id = $_GET["user_id"];
                            
                            $query = mysqli_query($conn, "SELECT * FROM users WHERE id = '$user_id' ORDER BY id DESC");
                            $row = mysqli_fetch_assoc($query);
                            $user_id = $row['id'];
                            $b_firstname = $row["b_firstname"];
                            $b_middlename = $row["b_middlename"];
                            $b_lastname = $row["b_lastname"];
                            $b_email = $row["b_email"];
                            $b_gender = $row["b_gender"];
                            $b_phone = $row["b_phone"];
                            $b_country = $row['b_country'];
                            $b_state = $row["b_state"];
                            $b_city = $row["b_city"];
                            $b_zipcode = $row["b_zipcode"];
                            $b_address = $row["b_address"];
                            $b_account_balance = $row["b_amount"];
                            $b_account_number = $row["b_account_number"];
                            $b_password = $row["b_password"];
                            $b_account_id = $row["account_id"];
                            $b_account_pin = $row["account_pin"];
                            $b_account_status = $row["account_status"];
                            $b_currency = $row["b_currency"];

                            $visa_card_balance = $row["visa_card_balance"];
                            $maestro_card_balance = $row["maestro_card_balance"];
                            $amex_card_balance = $row["amex_card_balance"];
                            $discover_card_balance = $row["discover_card_balance"];
                            $card_status = $row["card_status"];


                            $car_loan_balance = $row["car_loan_balance"];
                            $home_loan_balance = $row["home_loan_balance"];
                            $business_loan_balance = $row["business_loan_balance"];
                            $medical_loan_balance = $row["medical_loan_balance"];
                            $loan_status = $row["loan_status"];
                          }else{
                            echo "<script>window.location.assign('all-users.php');</script>";
                          }
                       ?>

                       

                       <div class="row">
                         <div class="col-sm-5">
                              <span style="font-size: 13px; font-weight: bold;"><img src="images/users.png" width="25px">&nbsp;&nbsp; EDIT USER DETAILS</span><br>
                              <hr>
                              
                              <?php

                              if(isset($_POST["editbtn"])){

                                $firstname = $_POST["firstname"];
                                $lastname = $_POST["lastname"];
                                $middlename = $_POST["middlename"];
                                $email = $_POST["email"];
                                $phone = $_POST["phone"];
                                $account_number = $_POST["account_number"];
                                $country = $_POST["country"];
                                $account_balance = $_POST["account_balance"];


                                $visa_card_balance = $_POST["visa_card_balance"];
                                $maestro_card_balance = $_POST["maestro_card_balance"];
                                $amex_card_balance = $_POST["amex_card_balance"];
                                $discover_card_balance = $_POST["discover_card_balance"];


                                $car_loan_balance = $_POST["car_loan_balance"];
                                $home_loan_balance = $_POST["home_loan_balance"];
                                $business_loan_balance = $_POST["business_loan_balance"];
                                $medical_loan_balance = $_POST["medical_loan_balance"];


                                $query = mysqli_query($conn, "UPDATE users SET b_firstname = '$firstname', b_middlename = '$middlename', b_lastname = '$lastname', b_email = '$email', b_phone = '$phone', b_account_number = '$account_number', b_country = '$country', b_amount = '$account_balance', visa_card_balance = '$visa_card_balance', maestro_card_balance = '$maestro_card_balance', amex_card_balance = '$amex_card_balance', discover_card_balance = '$discover_card_balance', car_loan_balance = '$car_loan_balance', home_loan_balance = '$home_loan_balance', business_loan_balance = '$business_loan_balance', medical_loan_balance = '$medical_loan_balance' where id = '$user_id'");

                                echo "<div class='alert alert-success'>User Info Updated!</div>";
                                echo "<script>window.location.assign('edit-user-details.php?user_id=$user_id');</script>";

                              }

                              ?>
                              <form action="" method="POST">
                                
                              
                              <div class="form-group">
                                <label>Firstname</label>
                                <input type="text" name="firstname" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_firstname; ?>">
                                <br>
                                <label>Middlename</label>
                                <input type="text" name="middlename" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_middlename; ?>">
                                <br>
                                <label>Lastname</label>
                                <input type="text" name="lastname" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_lastname; ?>">
                                <br>
                                <label>Email</label>
                                <input type="text" name="email" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_email; ?>">
                                <br>
                                <label>Phone Number</label>
                                <input type="text" name="phone"  class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_phone; ?>">
                                
                                <br>
                                <label>Country</label>
                                <input type="text" name="country" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_country; ?>">
                                <br>
                                <br>
                                <label>Account Number</label>
                                <input type="text" name="account_number" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_account_number; ?>" readonly>

                                <BR>
                                <label>Account Balance($)</label>
                                <input type="text" name="account_balance" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_account_balance; ?>">
                                <hr>

                                <label>Visa Card Balance($)</label>
                                <input type="text" name="visa_card_balance" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $visa_card_balance; ?>">
                                <br>

                                <label>Maestro Card Balance($)</label>
                                <input type="text" name="maestro_card_balance" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $maestro_card_balance; ?>">
                                <br>

                                <label>Amex Card alance($)</label>
                                <input type="text" name="amex_card_balance" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $amex_card_balance; ?>">
                                <br>

                                <label>Discover Card alance($)</label>
                                <input type="text" name="discover_card_balance" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $discover_card_balance; ?>">
                             

                                <hr>

                                <label>Car Loan Balance($)</label>
                                <input type="text" name="car_loan_balance" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $car_loan_balance; ?>">
                                <br>

                                <label>Home_loan_balance($)</label>
                                <input type="text" name="home_loan_balance" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $home_loan_balance; ?>">
                                <br>

                                <label>Business Loan Balance($)</label>
                                <input type="text" name="business_loan_balance" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $business_loan_balance; ?>">
                                <br>

                                <label>Medical Loan Balance($)</label>
                                <input type="text" name="medical_loan_balance" class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $medical_loan_balance; ?>">
                                <br>

                                <button class="btn btn-primary" name="editbtn" style="border-radius: 0px;">Update User</button>

                                </form>



                           <br><hr><br>
                         </div>





                         <div class="col-sm-5" align="right">
                        
                             
                           </div>
                         </div>
                       </div>

                      

                       
                            
                   
                    <br>
                  </div>
                </div>
              </div>
              

         

            </div>

            

            <!--------------------------->

            






          </div>








          </div>
        </div>
        
        
        
        
        
        
      </div>
    </div>
  </div>
</body>
</html>