<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
	<title>EMI Payment Summary | Admin Panel</title>

	<!-- Favicons -->
<link rel="shortcut icon" type="image/x-icon" href="../UserProfile/images/logo/logo.png">

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

	<!-- Fontawesome CSS -->
	<link rel="stylesheet" href="assets/plugins/fontawesome/css/fontawesome.min.css">
	<link rel="stylesheet" href="assets/plugins/fontawesome/css/all.min.css">
	 
	<!-- Animate CSS -->
	<link rel="stylesheet" href="assets/css/animate.min.css">

	<!-- Main CSS -->
	<link rel="stylesheet" href="assets/css/admin.css">
		<!-- Datatables CSS -->
	<link rel="stylesheet" href="assets/plugins/datatables/datatables.min.css">
 <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css"> 
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.6/css/buttons.dataTables.min.css">
  <style>
input[type=search]
{
    display: block;
    width: 100%;
    padding: .50rem 1rem;
    font-size: 1rem;
    line-height: 1.25;
    color: #4E5154;
    background-color:#FFF;
    background-clip: padding-box;
    border: 1px solid #BABFC7;
    border-radius: .25rem;
}
input[type=button]
{
 
    background-color:#140dec;

}
</style>
</head>

<body>
	<div class="main-wrapper">
	
		<!-- Header -->
	<?php include 'include/header.php'; ?>
		<!-- /Header -->
		
		<!-- Sidebar -->
		<?php include 'include/leftmenu.php'; ?>
		<!-- /Sidebar -->
		
		<div class="page-wrapper">
			<div class="content container-fluid">
			
				<!-- Page Header -->
				<div class="page-header">
					<div class="row">
						<div class="col">
							<h5 class="page-title text-white">EMI Payment Summary</h5>
						</div>

					</div>
				</div>
			        <div class="row">
						<div class="col-sm-12">
							<div class="card">
							
								<div class="card-body">
								    <form name="frm" id="frm" method="post" action="#">
								    <div class="row">
								<div class="col-sm-6 col-md-4">
									<div class="form-group">
										<label>From Date</label>
									<input type="date" name="from_date" id="from_date" class="form-control" requires>
									</div>
								</div>
									<div class="col-sm-6 col-md-4">
									<div class="form-group">
										<label>To Date</label>
									<input type="date" name="to_date" id="to_date" class="form-control" required>
									</div>
								</div>
									<div class="col-sm-4 col-md-3">
									<div class="form-group">
							      
										<button class="btn btn-primary btn-rounded" id="btnsubmit" type="submit" onClick="SubmitForm()" style="width:150px;margin-top:30px">Submit</button>
									
									</div>
								
								</div>
							    </div>
							    </div>
							    </form>
							 </div>
							</div>
					    </div>
					
                	<div class="row">
 						<div class="col-sm-12">
							<div class="card">
							 <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') 
					{
					$fdt=$_POST['from_date'];
					$tdt=$_POST['to_date'];
					$from_date=date("Y-m-d",strtotime($fdt));
					$to_date=date("Y-m-d",strtotime($tdt));
					 $hdr="EMI Payment Report From ".date("d-M-Y",strtotime($fdt)). " To ".date("d-M-Y",strtotime($tdt));
					
					 ?>
								<div class="card-body">
                                 <div class="col-sm-12">
                    <h6><?php echo $hdr; ?></h6>
                    </div>
                                    <hr>
									<div class="table-responsive">
										<table class="table table-stripped" id="example">
											<thead>
												<tr style="background-color: #140dec;color:#FFF">
												   	<th></th>
                    							 <th>#</th>
                    							 <th>EMI Payment Date</th>
                    							  <th>Customer Details</th>
                    							  <th>Plot Code</th>
                    							  <th>Paid Amt.</th>
                    							  <th>Comm. Amt</th>
                    							  <th>Comm.(%)</th>
									  
												</tr>
											</thead>
											<tbody>
											    <?php 
											    $cnt=1;
                							  $total_paid_amt=0;$total_comm_amt=0;
                							   	$str="Select * FROM tbl_plot_emi_payment where  emi_date between '$from_date' and '$to_date' and closingstatus=1 order by emi_payment_id desc";
                							  $result=mysqli_query($connection,$str);
                								while($row=mysqli_fetch_array($result))
                								{  
                								$total_paid_amt=$total_paid_amt+$row['payment_amt'];
                								$total_comm_amt=$total_comm_amt+$row['total_comm_amt'];
							  
											    ?>
												<tr>
								<td>
									<div class="btn-group">
										<button type="button" class="btn btn-primary">Action</button>
										<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
											<span class="sr-only">Toggle Dropdown</span>
										</button>
										<div class="dropdown-menu">
									 <a href="EmiCommissionSummary?emi_reference_no=<?php echo $row['emi_reference_no'];  ?>&booking_random_no=<?php echo $row['booking_random_no'];  ?>"  target="_blank"  class="dropdown-item"><i class="ft-external-link"></i>Show Commission</a>
										<a href="PrintReceipt?emi_reference_no=<?php echo $row['emi_reference_no'];  ?>&booking_random_no=<?php echo $row['booking_random_no'];  ?>&customer_id=<?php echo $row['member_user_id'];  ?>&paid_amount=<?php echo $row['payment_amt'];  ?>"  class="dropdown-item" target="_blank" ><i class="ft-external-link"></i>Print Receipt</a>
										</div></div>
							    </td>
								<td><?php echo $cnt++; ?></td>
								<td><?php echo date("d-M-Y",strtotime($row['emi_date'])); ?></td>
								<td><?php echo $row['member_name']; ?></br>(<?php echo $row['member_user_id']; ?>)</td>
								<td><?php echo $row['plot_code']; ?></td>
								<td><?php echo $row['payment_amt']; ?></td>
								<td><?php echo $row['total_comm_amt']; ?></td>
								<td><?php echo round($row['comm_per'],2); ?></td>
												</tr>
												<?php } ?>
											</tbody>
										</table>
									</div>
								
								</div>
									<?php }  ?>
							</div>
						</div>
						
					</div>
			</div>
		</div> 
	</div>

	<!-- jQuery -->
	<script src="assets/js/jquery-3.5.0.min.js"></script>

	<!-- Bootstrap Core JS -->
	<script src="assets/js/popper.min.js"></script>
	<script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>

	<!-- Slimscroll JS -->
	<script src="assets/plugins/slimscroll/jquery.slimscroll.min.js"></script>
		<script src="assets/plugins/datatables/jquery.dataTables.min.js"></script>
	<script src="assets/plugins/datatables/datatables.min.js"></script> 

	<!-- Custom JS -->
	<!-- Custom JS -->
	<script src="assets/js/admin.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.js" type="text/javascript"></script>
  <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" type="text/javascript"></script> 
  <script src="https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js" type="text/javascript"></script>
  <script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.flash.min.js" type="text/javascript"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js" type="text/javascript"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js" type="text/javascript"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js" type="text/javascript"></script>
  <script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.html5.min.js" type="text/javascript"></script>
  <script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.print.min.js" type="text/javascript"></script>
 <script>
$(document).ready(function() {
    $('#example').DataTable( {
        dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ]
    } );
} );
</script>

</body>

</html>