<?php
include 'includes/config.php';
session_start();
if (strlen($_SESSION['id']==0)) {
  header('location:logout.php');
  } else{
	
?>
<?php

$sqls = "SELECT * FROM users WHERE sid ='".$_GET['sid']."'";
$results = mysqli_query($con, $sqls);
$row = mysqli_fetch_array($results);
$message = ''; 

  if (isset($_POST['edit'])) {
     $loandate = $_POST['loandate'];
    $rrate = $_POST['rrate'];
    $tinstallment = $_POST['tinstallment'];
    $rints = $_POST['rints'];
   
    $sancamount = $_POST['sancamount'];
    $recamount = $_POST['recamount'];
    $balamount = $_POST['balamount'];
   
   
             $sql = "UPDATE `users` SET `loandate`='$loandate',`rrate`='$rrate',`tinstallment`='$tinstallment',`rints`='$rints',`sancamount`='$sancamount',`recamount`='$recamount',`balamount`='$balamount'  WHERE sid ='".$_GET['sid']."'";
           
 
     $result = mysqli_query($con, $sql);

     if ($result) {
      echo "<script>alert('Success Edit');
      window.location='loans.php'</script>";
    }else{
      echo "Error In Upload";
     // if want time add it date("Y/m/d"."h:i:sa")
    }


}

?>


<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
<meta name="robots" content="noindex">
<meta name="googlebot" content="noindex">
  <link rel="stylesheet" href="css/bootstrap.css" crossorigin="anonymous">
    <title>Edit Loans </title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/heroic-features.css" rel="stylesheet">
    <!-- <link href="css/datatables.css" rel="stylesheet"> -->
    
  <link href="css/datatables/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />
        
        <link href="css/datatables/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" />
        <link href="css/datatables/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" />
        <link href="css/datatables/select.bootstrap4.min.css" rel="stylesheet" type="text/css" />




    <!-- <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css"/> -->

    <style type="">
        .navbar-inverse{
            background-color: #0b0454!important;
        }
        a{
            color: #fdc010!important;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-inverse bg-success navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                 <a class="navbar-brand" href="welcome.php"><i class="glyphicon glyphicon-home"></i> Home</a>
            </div>
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li>
                        <a href="profile.php"><i class="glyphicon glyphicon-user"></i> <?php echo $_SESSION['sname'];?></a>
                    </li>
                    <li>
                      <a href="employee-details.php"><i class="glyphicon glyphicon-folder-open"></i> Employee Data</a>
                    </li>
                    <li>
                      <a href="nps.php"><i class="glyphicon glyphicon-globe"></i> NPS</a>
                    </li>
                    <li>
                      <a href="salary-income.php"><i class="glyphicon glyphicon-screenshot"></i> Salary/Income tax </a>
                    </li>
                    <li>
                      <a href="loans.php"><i class="glyphicon glyphicon-screenshot"></i> Loans/Advance </a>
                    </li>
                    <li>
                        <a href="logout.php"><i class="glyphicon glyphicon-log-out"></i> Logout</a>
                    </li>
                  
                </ul>
            </div>
        </div>
    </nav>
    <div id="divToPrint">
    <div class="container">
        <div class="row">
          <div class="col-md-12">
            <h2 class="h2 text-center">Update Loan/advance details</h2>
          </div>
         
          <div class="col-md-8 col-md-offset-2">
           <form action="" method="POST" enctype="multipart/form-data">
             <div class="form-group">
               <label>Loan Month</label>
               <input type="text" name="loandate" value="<?php echo $row['loandate']; ?>" class="form-control" required="">
               <small>DD/MM/YYYY enter in this format</small>
             </div>

             <div class="form-group">
               <label>Recovery Rate</label>
               <input type="text" name="rrate" value="<?php echo $row['rrate']; ?>" class="form-control" required="">
             </div>

             <div class="form-group">
               <label>Total Installments</label>
               <input type="text" name="tinstallment" value="<?php echo $row['tinstallment']; ?>" class="form-control" required="">
             </div>

             <div class="form-group">
               <label>Recovered Installment</label>
               <input type="text" name="rints" value="<?php echo $row['rints']; ?>" class="form-control" required="">
             </div>

             <div class="form-group">
               <label>Sanc Amount</label>
               <input type="text" name="sancamount" value="<?php echo $row['sancamount']; ?>" class="form-control" required="">
             </div>

             

             <div class="form-group">
               <label>Recovered Amount</label>
                <input type="text" name="recamount" value="<?php echo $row['recamount']; ?>" class="form-control" required="">
             </div>
             <div class="form-group">
               <label>Balance amount</label>
                <input type="text" name="balamount" value="<?php echo $row['balamount']; ?>" class="form-control" required="">
             </div>
             
             <div class="form-group text-center">
               <input type="reset" class="btn btn-info" value="Reset" name="">
               <input type="submit" class="btn btn-primary" value="Submit" name="edit">
             </div>
           </form>
          </div>  
        </div>
    </div>
 
   </div> 

       

   <div id="foot">
     <script src="js/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>

 
<!-- <script type="text/javascript" src="js/datatables.js"></script> -->
<!-- Datatable plugin js -->
        <script src="js/datatables/jquery.dataTables.min.js"></script>
        <script src="js/datatables/dataTables.bootstrap4.min.js"></script>

        <script src="js/datatables/dataTables.responsive.min.js"></script>
        <script src="js/datatables/responsive.bootstrap4.min.js"></script>

        <script src="js/datatables/dataTables.buttons.min.js"></script>
        <script src="js/datatables/buttons.bootstrap4.min.js"></script>

        <script src="js/jszip/jszip.min.js"></script>
        <script src="js/pdfmake/pdfmake.min.js"></script>
        <script src="js/pdfmake/vfs_fonts.js"></script>

        <script src="js/datatables/buttons.html5.min.js"></script>
        <script src="js/datatables/buttons.print.min.js"></script>

        <script src="js/datatables/dataTables.keyTable.min.js"></script>
        <script src="js/datatables/dataTables.select.min.js"></script>

        <!-- Datatables init -->
        <script src="js/datatables/datatables.init.js"></script>

<script type="text/javascript">
  $(document).ready(function() {
    $('#datatables').DataTable();
} );
</script>
   </div>
   
</body>

</html>
<?php } ?>