<?php include("includes/header.php"); ?>
<?php include("includes/auto_out.php"); ?>
<!DOCTYPE html>
<html>
<head>
  <title>Request Loans | <?php echo $sitename; ?></title>
  
     <!----------------------------------------------------------------------->
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
     <script src="bootstrap/js/jquery.min.js"></script>
     <script src="bootstrap/js/bootstrap.min.js"></script>
     <!----------------------------------------------------------------------->
     <link rel="icon" href="images/fav-icon.ico" type="image/x-icon" />
    <!-- <link rel="shortcut icon" href="images/fav-icon.ico" type="image/x-icon" />
     <!----------------------------------------------------------------------->
     <!-------------------Constumized CSS--------------------------->
     <link rel="stylesheet" type="text/css" href="css/style.cs">

     <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
     <style>
        body{
          background-color: #f5f5f5;
        }
      .icons-links{
        text-decoration: none;
        color: #555;
        font-size: 16px;
        font-weight: bolder;
      }
      .icons-links:hover{
        color:#0c2074;
        text-decoration: none;
      }
     </style>
     
</head>
<body>
  <?php  include("includes/dashboard_nav.php"); ?>
    <br>
  <div class="container-fluid">
    

        <div class="row">
      <div class="col-sm-2">
        <?php include("includes/sidebar.php"); ?>
          <?php include("includes/side.php"); ?>
      </div>
      <div class="col-sm-10">
               <div class="row">

                   <!------------------LEFT ROW ---------------------------->
                   <div class="col-sm-5">
                       
                      
                     
                       <!------------------------------------------------------>

                       <div class="row">
                         <div class="col-sm-12">
                            <div class="panel panel-default">
                             <div class="panel-body">
                               <h4 style=""><img src="images/2746100.png" width="28">  REQUEST INSTANT LOAN</h4>
                               <hr>

                               <div class="row">

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


                                  <?php
                                    if(isset($_POST["loanbtn"])){

                                      //GET ALL VAIRABLES
                                      $my_account = $_POST["my_account"];
                                      $annual_income = $_POST["annual_income"];
                                      $loan_type = $_POST["loan_type"];
                                      $loan_duration = $_POST["loan_duration"];
                                      $loan_amount = $_POST["loan_amount"];
                                      $confirm_password = $_POST["confirm_password"];
                                      $loan_status = "PENDING";
                                      $loan_date = date("M d, Y");

                                      //Check if password is correct with db pass
                                      if($b_password == $confirm_password){

                                        //INSERT INTO Db
                                        $query = mysqli_query($conn, "INSERT INTO loans VALUES('', '$u_dbid', '$my_account', '$annual_income', '$loan_type', '$loan_duration', '$loan_amount', '$loan_status', '$loan_date')");
                                        echo "<div class='alert alert-success'><i class='glyphicon glyphicon-ok'></i> Your loan application has been sent.</div>";

                                        echo "<script>window.location.assign('loans.php');</script>";

                                      }else{
                                        echo "<div class='alert alert-danger'><i class='glyphicon glyphicon-warning-sign'></i> Unable to confirm password.</div>";
                                      }

                                    }
                                  ?>



                                   <form action="" method="POST">
                                     <div class="form-group">
                                      <label>My Account:</label>
                                       <select class="form-control input-lg" name="my_account" style="border-radius: 0px;">
                                         <option><?php echo $account_number; ?> - <?php echo ucfirst($firstname)."&nbsp;".ucfirst($middlename)."&nbsp;".ucfirst($lastname) ?></option>
                                       </select>

                                       <br>

                                       <label>Annual Income:</label>
                                       <select class="form-control input-lg" name="annual_income" style="border-radius: 0px;">
                                         <option>$50,000 - $150,000</option>
                                         <option>$150,000 - $500,000</option>
                                         <option>$500,000 - $1,000,000</option>
                                         <option>$1,000,000+</option>
                                       </select>

                                       <br>

                                       <label>Loan Type:</label>
                                       <select class="form-control input-lg" name="loan_type" style="border-radius: 0px;">
                                         <option>Car Loan</option>
                                         <option>Home Loan</option>
                                         <option>Business Loan</option>
                                         <option>Others</option>
                                       </select>

                                       <br>

                                       <label>Loan Duration:</label>
                                       <select class="form-control input-lg" name="loan_duration" style="border-radius: 0px;">
                                         <option>6 Months - 1 Year</option>
                                         <option>1 - 2 years</option>
                                         <option>2 - 5 years</option>
                                         <option>5 years above</option>
                                       </select>

                                       <br>

                                       <label>Loan Amount ($):</label>
                                       <input type="number" class="form-control input-lg" name="loan_amount" style="border-radius: 0px;" placeholder="USD" autocomplete="none" required/>

                                       <br>

                                       <label>Confirm Password:</label>
                                       <input type="password" class="form-control input-lg" name="confirm_password" style="border-radius: 0px;" placeholder="********" autocomplete="none" required/>

                                       <br>

                                       <button type="submit" name="loanbtn" class="btn btn-primary" style="border-radius: 0px;">Apply</button>
                                     </div>
                                   </form>
                                </div>


                                 
                               </div>

                               <br>
                               
                             </div>
                           </div>
                         </div>
                       </div>
                       <!------------------------------------------------------>
                       
                   </div>
                   <!-----------------/LEFT ROW ---------------------------->

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

                   <!------------------RIGHT ROW --------------------------->
                   <div class="col-sm-4">

                  
                    
                   </div>
                   <!-----------------/RIGHT ROW --------------------------->
               </div>
      </div>
    </div>
  </div>
</body>
</html>