<?php include("includes/header.php"); ?>
<?php include("includes/auto_out.php"); ?>
<!DOCTYPE html>
<html>
<head>
  <title>Edit Transaction | <?php echo $sitename;  ?></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>



</head>

<body>
  <?php  include("includes/dashboard_navbar.php"); ?>
  <!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here-->
 <!-- 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>

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

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

              <div class="col-sm-6">
                 <div class="panel panel-default">
                  <div class="panel-body">
                    <img src="images/1751805.png" width="35">&nbsp;&nbsp;<b>EDIT TRANSACTION</b>
                <br><hr><br>


                <?php
                     if(isset($_GET["loan_id"])){
                       $loan_id = $_GET["loan_id"];
                       //USE COLL ID TO FETCH DATA
                       $query = mysqli_query($conn, "SELECT * FROM loans WHERE id = '$loan_id'");
                       $row = mysqli_fetch_assoc($query);

                       $loan_id = $row['id'];
                       $my_account = $row["my_account"];
                       $annual_income = $row["annual_income"];
                       $loan_type = $row["loan_type"];
                       $loan_duration = $row['loan_duration'];
                       $loan_amount = $row['loan_amount'];
                       $loan_status = $row["loan_status"];
                       $loan_date = $row["loan_date"]; 

                     }else{
                       echo "<script>window.location.assign('all-loans.php');</script>";
                     }
                    ?>
                     <h3>Edit Transaction Status</h3><br>
                     <?php
                       if(isset($_POST["editloanbtn"])){

                        $loan_id = $_GET["loan_id"];
                        $loan_status = $_POST["loan_status"];

                         
                        //INSER DATA INTO DB
                        $query = mysqli_query($conn, "UPDATE loans SET loan_status = '$loan_status' WHERE id = '$loan_id'");
                        echo "<div class='alert alert-success'>Loan Edited Successfully!</div>";
                        echo "<script>window.location.assign('all-loans.php');</script>";


                       }
                     ?>

                     <form action="" method="POST">
                        <select name="loan_status" class="form-control input-lg" style="border-radius: 0px;">
                          <option>PENDING</option>
                          <option>APPROVED</option>
                          <option>DECLINED</option>
                        </select>
                        <br>
                        <div align="right"><button type="submit" name="editloanbtn" class="btn btn-primary" style="border-radius: 0px;"><i class="fa fa-edit"></i> Edit</button></div>
                       </form>



                       <hr>


                      

                     
                       



                     


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

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

            </div>

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







          </div>


          <div class="col-sm-4">
            
            </div>
          </div>
        </div>
        
        
        
        
        
        
      </div>
    </div>
  </div>
</body>
</html>