<?php
include"initialize_page.php";

?>
<!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">

	<title>Users</title>

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

	<!-- datatables Styling  -->
    <link rel="stylesheet" href="assets/css/plugins/datatables/jquery.dataTables.css" />
    
    <!-- Fonts  -->
    <link href='http://fonts.googleapis.com/css?family=Raleway:400,500,600,700,300' rel='stylesheet' type='text/css'>
    
    <!-- Base Styling  -->
    <link rel="stylesheet" href="assets/css/app/app.v1.css" />

</head>
<body>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript">
		
	function approveLoan(id,userid,totalamount)
	 {
		    //alert(totalamount);
			var r = confirm("Are you sure to Approve Loan??");
			if(r==true)
			{
			$.post("controller.php", {id:id,userid:userid,totalamount:totalamount, q:"approve_loan"} , function(data)
			{
				//alert(data);
			window.location.href='<?php   echo website_settingdata('x_weburl');   ?>admin/loan.php';  
			});
			}
		
	}

  </script>
	<?php include"xleftmenu.php"; ?>
    
    <section class="content">
    	
         <?php  include"xheader.php";  ?>
        <!-- Header Ends -->
        
        
        <div class="warrper container-fluid">
        	
            <div class="page-header"><h1>Loans Requests<?php //echo time();  ?></h1>
           <a class="btn btn-primary" href="<?php   echo website_settingdata('x_weburl');?>admin/add_loan_type.php" style="float: right; margin-bottom: 1em;">Add Loans Type</a>
            
            </div>
       
            
        </div>
<!-- Warper Ends Here (working area) -->

     <div class="panel panel-default">
                  
           
                   
                    <div class="row">
                    <div class="col-md-12">
                    <div class="panel-body">
                   
<table class="table table-striped table-bordered" id="basic-datatable" width="100%">
        <thead>
            <tr>
                <th>Sr.</th>
                <th>Name</th>
                <th>Required Amount</th>
				 <th>Approve</th>
                <th>View</th>
                
            </tr>
        </thead>
        <tbody>
                            
             <?php
				$sr=1;		  
			    $data_q=mysqli_query($con,"SELECT * FROM x_loanreq WHERE x_status = 'N' ORDER by x_id DESC");
				while($data_array=mysqli_fetch_array($data_q))
			    {
				$user_id = $data_array['x_userid'];
				$req_amount = $data_array['x_reqamount'];
				$req_amount = number_format($req_amount,2);
				$total_amount = $data_array['x_totalpay'];
				$main_currency = main_account_currency($user_id);
				
			?>
                <tr class="odd gradeX">
				
                <td><?php echo $sr; ?></td>
                <td><?php echo  user_bankuser($user_id,"x_fname");?> <?php echo  user_bankuser($user_id,"x_lname");?>    </td>              
                <td><?php echo $main_currency ?><?php echo $req_amount;?></td> 
				
                <td><button class="btn btn-danger" onClick="approveLoan(<?php echo $data_array['x_id'];  ?>,<?php echo $data_array['x_userid'];?>,<?php echo $total_amount;?>)">Approve</button></td>
				
               <td><a href="<?php   echo website_settingdata('x_weburl');   ?>admin/view_loan_requirement.php?id=<?php echo $data_array['x_id'];  ?>&ss=<?php  echo md5(rand(00000,99999));?>"><button class="btn btn-primary">View</button></a></td>
			   
			  
                                 
                </tr>
			<?php
            
            $sr++;
            }
            ?>  
</tbody>
</table>

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


<footer class="container-fluid footer">
Copyright &copy; <?php    echo date('Y');  ?>
</footer>


</section>
<!-- Content Block Ends Here (right box)-->



<!-- JQuery v1.9.1 -->
			<script src="assets/js/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
            
            <!-- Bootstrap -->
            <script src="assets/js/bootstrap/bootstrap.min.js"></script>
            
            <!-- NanoScroll -->
            <script src="assets/js/plugins/nicescroll/jquery.nicescroll.min.js"></script>
            
            
            <!-- Data Table -->
            <script src="assets/js/plugins/datatables/jquery.dataTables.js"></script>
            <script src="assets/js/plugins/datatables/DT_bootstrap.js"></script>
            <script src="assets/js/plugins/datatables/jquery.dataTables-conf.js"></script>
            
            
            <!-- Custom JQuery -->
            <script src="assets/js/app/custom.js" type="text/javascript"></script>
            
            
            
            <script>
            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
            
            ga('create', 'UA-56821827-1', 'auto');
            ga('send', 'pageview');
            
            </script>
</body>
</html>
