<?php
session_start();
include_once ('conn/session.php');
require_once 'conn/controller.php';

if(!isset($_SESSION['acc_no'])){
    
header("Location: auth_login.php");
exit(); 
}


$reg_user = new USER();
$stmt = $reg_user->runQuery("SELECT * FROM account WHERE acc_no=:acc_no");
$stmt->execute(array(":acc_no" => $_SESSION['acc_no']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);

$email = $row['email'];
 

?>


 <?php include 'auth_header.php'; ?>
 
 <!---begin of Mobile View Here   only from Digital Forest Team-->
 
     
   
   
  				
  <script>
    $(document).ready(function() {
      $('#mybutton').hide().delay(5000).fadeIn(2200);
});
    </script> 

 <style>
input[type=text2] {
  width: 60%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
} 

input[type=text], select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
}

input[type=number], date{
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
}


input[type=submit] {
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

input[type=submit]:hover {
  background-color: #45a049;
}

.container {
  border-radius: 5px;
  background-color: ;
  padding: 20px;
}
</style>
						
<style>


.card-block {
  height: 220px;
  background: #6236FF;
  border-radius: 10px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.09);
  color: #fff;
  position: relative;
}

.card-block .card-main {
  background-image: linear-gradient(-180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.23) 100%);
  position: absolute;
  border-radius: 10px;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  display: flex;
  align-items: flex-end;
  padding: 20px 24px;
}

.card-block .card-button {
  position: absolute;
  right: 10px;
  top: 10px;
}

.card-block .card-button > .btn {
  background: transparent !important;
  color: #fff !important;
}

.card-block span.label {
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.5;
  line-height: 1em;
  margin-bottom: 5px;
  text-transform: uppercase;
  display: block;
  font-weight: 500;
}

.card-block .in .card-number {
  font-size: 17px;
  letter-spacing: 3px;
  font-weight: 500;
}

.card-block .in .card-expiry {
  font-size: 14px;
  font-weight: 500;
  margin-right: 20px;
}

.card-block .in .card-ccv {
  font-weight: 500;
  font-size: 14px;
}

.card-block .bottom {
  display: flex;
  align-items: center;
  margin-top: 20px;
}

.card-block .balance {
  position: absolute;
  left: 24px;
  top: 24px;
}

.card-block .balance .title {
  font-weight: 700;
  color: #fff;
  margin-top: 7px;
  font-size: 24px;
}


</style>				
				





					
<br><br>
 
 
 <div class="container-fluid py-4">
 
  <div class="row">
        <div class="col-12">
          <div class="card my-4">
            <div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
              <div class="bg-gradient-primary shadow-primary border-radius-lg pt-4 pb-3">
                <h4 class="text-white text-capitalize ps-3"><img src="icon/ibft.png" height="40" width="40" > LOAN & FACILITY</h4> 
              </div>
            </div>
            <div class="card-body px-0 pb-2"> 
                
                
                
                
                      <div class="row">
        <div class="col-md-7 mt-4">
          <div class="card"> 
            <div class="card-body pt-4 p-3">
                <p style="color:darkgreen;">Use our fastest loan processing application for your house, cars and property payments across the globe</p>
          
            		    <div class="container"> 
       
                           
        
               
		    
            		    
            		   
                    <form class="cmxform"  autocomplete="off" method="POST" action="">  
                    
                    	     <?php
					                                if(isset($_POST['add_loan'])){
						   
						                            $conn = mysqli_connect($host, $username, $password, $database);
                                                    
                                                    // Check connection
                                                    
                                                    if (!$conn) {
                                                          die("Connection failed: " . mysqli_connect_error());
                                                    }
                                                     
                                                    echo ""; 
                                                    
                                                    $db_select = mysqli_select_db($con, $database);
						   
						                         
                                                    $name =$_REQUEST['name'];
						                            $acc_no =$_REQUEST['acc_no'];
						                            $email =$_REQUEST['email'];
						                            $loanamt =$_REQUEST['loanamt'];
						                            $inter =$_REQUEST['inter'];
						                            $dura =$_REQUEST['dura'];
                                                    $monthlypay =$_REQUEST['monthlypay'];
                                                    $purpose =$_REQUEST['purpose'];
                                                    $balance =$_REQUEST['balance'];
                                                    $status =$_REQUEST['status'];
                                                    $date =$_REQUEST['date'];            
                                            
    $stmt = $reg_user->runQuery("SELECT * FROM quick_loan WHERE loanamt=:loanamt");
    $stmt1 = $reg_user->runQuery("SELECT * FROM quick_loan WHERE dura=:dura"); 
    $stmt->execute(array(":loanamt" => $loanamt));
    $stmt1->execute(array(":dura" => $dura)); 
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $row1 = $stmt1->fetch(PDO::FETCH_ASSOC); 


    if ($stmt->rowCount() > 0 || $stmt1->rowCount() > 0 ) {
        $msg = "
		      <div class='alert alert-danger'>
				<button class='close' data-dismiss='alert'>&times;</button>
					<strong>Sorry!</strong> You Have Same Amount Pending Application, Contact Support
			  </div>
			                                                            <script type='text/javascript'>
                                                							<!--
                                                							function Redirect() {
                                                							window.location='quick_loan.php';
                                                							}
                                                							document.write ('');
                                                							setTimeout('Redirect()', 5000);
                                                							//-->
                                                							</script>
			  ";
    } else {        
        $sql = "INSERT INTO `quick_loan` (`id`, `name`, `acc_no`, `email`, `loanamt`, `inter`, `dura`, `monthlypay`, `purpose`, `balance`, `status`, `date`) 
        VALUES (NULL, '$name', '$acc_no', '$email', '$loanamt', '$inter', '$dura', '$monthlypay', '$purpose', '$balance', '$status', '$date')"; 
                                                      
                                                                            
          
                            						   $insert=mysqli_query($conn, $sql);
                            						   
                            						   if($insert){
                            						       
                            						       
                            							  	$msg = "
                                            					<div class='alert alert-success'> 
                                            					<center>	<strong style='color:black;'>Loan Application Was Successful, Please Wait for Approval
                                                                       </strong></center>
                                                                       
                                                                       	<script type='text/javascript'>
                                                							<!--
                                                							function Redirect() {
                                                							window.location='quick_loan.php';
                                                							}
                                                							document.write ('');
                                                							setTimeout('Redirect()', 3000);
                                                							//-->
                                                							</script>
                                            			  		</div>
                                            					";
                            							   
                            						   }else{
                            						       
                            						       echo '<h3>Loan Application Failed!</h3>';
                            						       
                            						       
                            						   }
                            					   
					                                }
					                                }
                            					?>
                    
                    
                    
                                             <?php if (isset($msg)) echo $msg; ?>
                                     
                                     
								     
                           
                             <label for="firstName1">Estimated Duration:</label>
                         <select  name="dura" required >
                                                            <option value="">Select Duration</option> 
                                                            <option value="0-6 months">0-6 months</option> 
                                                             <option value="7-12 months">7-12 months</option> 
                                                              <option value="24- 34 months">24-34 months</option> 
                                                               <option value="36 months">36 months</option>  
                                                       
                                            </select>    
                        
                            
                            
                               
                             <label for="lastName1">Required Amount:</label>
                             <input  type="text" name="loanamt" placeholder="e.g  USD50,000" required="">
                           
                             <label for="lastName1">Purpose of the Loan:</label>
                                 <textarea  name="purpose"
                                 placeholder="state the purpose of the loan" id="exampleFormControlTextarea1" rows="5" required=""></textarea>
                                          
                            
                            
                              <input class="custom-date form-control"  type="hidden" name="email" value="<?php echo $row['email']; ?>"> 
								      <input class="custom-date form-control"  type="hidden" name="name" value="<?php echo $row['fname']; ?> <?php echo $row['lname']; ?>"> 
								     <input class="custom-date form-control"  type="hidden" name="acc_no" value="<?php echo $row['acc_no']; ?>"> 
								       <input class="custom-date form-control"  type="hidden" name="inter" value="0.00%"> 
								    <input class="custom-date form-control"  type="hidden" name="monthlypay" value="USD0.00"> 
								    <input class="custom-date form-control"  type="hidden" name="status" value="PENDING"> 
                                    <input class="custom-date form-control"  type="hidden" name="balance" value="0.00">  
                                    <input class="custom-date form-control"  type="hidden" name="date" value="<?php echo date("h:i A d M Y"); ?>">   
                            
                            
                             
                         
                            
                            <input type="submit" name="add_loan" id="mybutton" class="btn bg-gradient-dark mb-0" value="SUBMIT APP  → ">  
                          </form>
                              
                          
        
            </div>
            </div>
          </div>
        </div>
        <div class="col-md-5 mt-4">
          <div class="card h-100 mb-4">
            <div class="card-header pb-0 px-3">
              <div class="row">
                <div class="col-md-6">
                  <h6 class="mb-0">My Loan Statitics</h6>
                </div>
                <div class="col-md-6 d-flex justify-content-start justify-content-md-end align-items-center">
                  <i class="material-icons me-2 text-lg">date_range</i>
                  <small><?php echo date("h:i A d M Y"); ?></small>
                </div>
              </div>
            </div>
            <div class="card-body pt-4 p-3"> 
                   
                   
	           
			   
<style>
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

th, td {
  text-align: left;
  padding: 5px;
}

tr:nth-child(even){background-color: }
</style>
 
                         <div style="overflow-x:auto; ">
			                <?php
								
			        $conn = mysqli_connect($host, $username, $password, $database);

		            $acc_no = $row['acc_no']; 
             	    $query=mysqli_query($conn,"SELECT * FROM `quick_loan` WHERE acc_no ='$acc_no' ");
     
            		
            		echo '<table  class="table">';
            		echo '<caption class=""><br>';
            		echo '<thead><tr><th>LOAN AMOUNT:</th><th>PURPOSE</th><th>DURATION</th><th>% RATE</th><th>M/PAY</th><th>BALANCE</th><th>STATUS</th><th>DATE</th><th>ACTION</th>
            		 
            		</tr></thead>';
            		
            		
            		while($active=mysqli_fetch_array($query)){
            			echo '
            			
            		  
            			<tbody><tr><td>'.$active['loanamt'].'</td><td>'.$active['purpose'].'</td>
            			<td>'.$active['dura'].'</td><td>'.$active['inter'].'</td><td>'.$active['monthlypay'].'</td><td>'.$active['balance'].'</td><td><strong style="color:green">'.$active['status'].'</strong></td>
            		<td>'.$active['date'].'</td>	<td class="filled-button dark"><strong ><a href="delete_loan.php?id='.$active['id'].'">DELETE</a></strong></td>
            			</tr></tbody>';
            		}
            		echo '</table>';
            		
            		      	 {
                                 						       
                     }
                         
            	  ?>
	</div>		   
			   
                   
                   
            </div>
          </div>
        </div>
      </div>
                
                
      
                          
		    
		    </div>
 
                 
              
              <br><br>
            </div>
          </div>
        </div><br><br>
      </div>
 
 
 
 </div>
 





















				
				
				
		 
		    
		    
		    
   
			   
	
       

 <?php include 'auth_footer.php'; ?>		
	 
 
    