<!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>Plot EMI Payment | 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">

</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">
			 <?php 
 $member_user_id=$_REQUEST['member_user_id'];
 $booking_random_no=$_REQUEST['booking_random_no'];
 $str="Select * from tbl_plot_registry_booking where booking_random_no='$booking_random_no'";
 $res=mysqli_query($connection,$str);
 $row=mysqli_fetch_array($res);
 
 
 
 ?>
				<!-- Page Header -->
				<div class="page-header">
					<div class="row">
						<div class="col">
							<h5 class="page-title text-white">Plot EMI Payment <small></small></h5>
    					
						</div>
					
					</div>
				</div>
				
					<form action="Apk/PlotEmiPayment" method="post" id="frmreg">
                	<div class="row">
						<div class="col-sm-12">
							<div class="card">
								<div class="card-header">
									<h6 class="card-title"><span style="color:#FF0033">Plot Code :  <?php echo $row['plot_code']; ?></span> </h6>
								<span style="color:red">	<?php echo $_REQUEST['msg']; ?></span>
								
								<?php 
                  $date=date("Y-m-d");
                  $qry="Select * from tbl_plot_emi_payment where member_user_id='$member_user_id' and booking_random_no='$booking_random_no' and entry_date='$date'";
                  $ress=mysqli_query($connection,$qry);
                  if(mysqli_num_rows($ress)>0)
                  {
                      $rows=mysqli_fetch_array($ress);
                      $plot_code=$rows['plot_code'];
                      $payment_amt=$rows['payment_amt'];
                      ?>
                      <span style="color:red"> All Ready Have A Payment Rs.<?php echo $payment_amt; ?> Today</span>
                      <?php
                  }
                  ?>
								</div>
								<div class="card-body">

									<div class="table-responsive">
										<div class="card filter-card">
						<div class="card-body pb-0">
							<div class="row filter-row">
							    <div class="col-sm-6 col-md-4">
									<div class="form-group">
										<label>Payment Date</label>
										<input type="date" name="payment_date" id="payment_date" value="<?php echo date("Y-m-d"); ?>" class="form-control">
										</div>
											<input type="hidden" name="emi_reference_no" id="emi_reference_no" required class="form-control" value="<?php echo str_shuffle("0123654789"); ?>">
								</div>
							   
								
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Customer Id</label>
								 <input type="text" class="form-control" id="member_user_id"  maxlength="10" minlength="10" style="text-transform:uppercase;background-color:#FFFFFF" placeholder="" name="member_user_id" value="<?php echo $row['member_user_id']; ?>" required >
									</div>
								</div>
									<div class="col-sm-6 col-md-5">
									<div class="form-group">
										<label>Customer Name</label>
									 <input type="text" class="form-control" id="member_name" placeholder="Customer Name" name="member_name" style="background-color:#FFFFFF"   readonly="true"  required value="<?php echo $row['member_name']; ?>">
									</div>
								</div>
									<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Sponsor Id</label>
									   <input type="text" class="form-control" id="sponcer_id" value="<?php echo $row['sponcer_id']; ?>" placeholder="Sponcer Id" name="sponcer_id" readonly="true" style="background-color:#FFFFFF"  required>
									</div>
								</div>
							
									<div class="col-sm-6 col-md-5">
									<div class="form-group">
										<label>Sponsor Name</label>
									 <input type="text" class="form-control" id="sponcer_name" value="<?php echo $row['sponcer_name']; ?>" placeholder="Sponcer Name" name="sponcer_name" readonly="true" style="background-color:#FFFFFF" required>
									</div>
								</div>
							
							
								<div class="col-sm-6 col-md-2">
									<div class="form-group">
										<label>Plot Code</label>
								<input type="text" class="form-control" name="plot_code" id="plot_code" value="<?php echo $row['plot_code']; ?>" readonly="true" style="background-color:#FFFFFF">
								<input type="hidden" class="form-control" name="plot_id" id="plot_id" value="<?php echo $row['plot_id']; ?>" readonly="true" style="background-color:#FFFFFF">
									</div>
								</div>
								<div class="col-sm-6 col-md-2">
									<div class="form-group">
										<label>Business($)</label>
								<input type="text" class="form-control" name="businessper" id="businessper" value="<?php echo $row['businessper']; ?>"  style="background-color:#FFFFFF" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode &amp;&amp; event.keyCode<58 &amp;&amp; event.shiftKey==false) || (95<event.keyCode &amp;&amp; event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 &amp;&amp; event.keyCode<40) || (event.keyCode==46) )" readonly="true">
							
									</div>
								</div>
									<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Plot Booking Id</label>
									 <input type="text" class="form-control" name="booking_random_no" id="booking_random_no" value="<?php echo $row['booking_random_no']; ?>" readonly="true" style="background-color:#FFFFFF">
									</div>
								</div>
								 <div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Total Amount</label>
								<input type="text" class="form-control" id="net_amount" value="<?php echo $row['net_amount']; ?>" name="net_amount"  style="background-color:#FFFFFF; text-align:right;" required onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode &amp;&amp; event.keyCode<58 &amp;&amp; event.shiftKey==false) || (95<event.keyCode &amp;&amp; event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 &amp;&amp; event.keyCode<40) || (event.keyCode==46) )" readonly="true">
									</div>
								</div>
								
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Previous Paid</label>
								<input type="text" class="form-control" id="prev_paid" value="<?php echo $row['paid_amount']; ?>" name="prev_paid" readonly="true" style="background-color:#FFFFFF; text-align:right;" required onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode &amp;&amp; event.keyCode<58 &amp;&amp; event.shiftKey==false) || (95<event.keyCode &amp;&amp; event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 &amp;&amp; event.keyCode<40) || (event.keyCode==46) )">
									</div>
								
								</div>
									<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Net Amount</label>
										 <input type="text" class="form-control" id="balance_amt" value="<?php echo $row['balance_amt']; ?>" name="balance_amt" readonly="true" style="background-color:#FFFFFF; text-align:right;" required>
									</div>
								</div>
								
									<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Paid Amount</label>
									<input type="text" class="form-control" id="paid_amount" value="" name="paid_amount"  style="background-color:#FFFFFF; text-align:right;" maxlength="10" required onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode &amp;&amp; event.keyCode<58 &amp;&amp; event.shiftKey==false) || (95<event.keyCode &amp;&amp; event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 &amp;&amp; event.keyCode<40) || (event.keyCode==46) )" >
									</div>
								</div>
								
									<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Next Due Amt.</label>
										 <input type="text" class="form-control" id="next_due" value="<?php echo $row['balance_amt']; ?>" name="next_due" readonly="true" style="background-color:#FFFFFF; text-align:right;" required>
									</div>
								</div>
								
									<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Payment Mode</label>
									 <select name="payment_mode" id="payment_mode" class="form-control" required>
								 <option value="">Payment Mode </option>
								 <option value="SETTLEMENT">SETTLEMENT </option>
								 <option value="CASH">CASH</option>
								 <option value="CHEQUE">CHEQUE</option>
								 <option value="NEFT/RTGS">NEFT/RTGS</option>
								 </select>
									</div>
								</div>
									<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Bank Name</label>
									 <input type="text" class="form-control" id="bank_name" value="" placeholder="Bank Name" name="bank_name" style="background-color:#FFFFFF;text-transform: uppercase;"  maxlength="100"  >
									</div>
								</div>
									<div class="col-sm-6 col-md-6">
									<div class="form-group">
										<label>Cheque/NEFT/RTGS</label>
									  <input type="text" class="form-control" id="cheque_no" value="" placeholder="Cheque/NEFT/RTGS" name="cheque_no" style="background-color:#FFFFFF" maxlength="25">
									</div>
								</div>
									<div class="col-sm-6 col-md-6">
									<div class="form-group">
										<label>Remark If Any</label>
									  <input type="text" class="form-control" id="remark" value="" placeholder="Remark" name="remark" style="background-color:#FFFFFF" maxlength="250">
									</div>
								</div>
							</div>	
							<div class="row filter-row">
								<div class="col-sm-4 col-md-3">
									<div class="form-group">
							      
										<button class="btn btn-primary btn-rounded" id="btnsubmit" type="button" onClick="SubmitForm()" style="width:150px;padding-top:10px">Submit</button>
									
									</div>
								
								</div>
							    

							</div>
						</div>
					</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				    </form>
	<!-- 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 -->
	<script src="assets/js/admin.js"></script>
	<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>

$(document).ready(function(){

	$("#paid_amount").keyup(function()
	{ // Keyup function for check the user action in input
		 var paid_amount=$.trim($("#paid_amount").val());
		 if(paid_amount.length==0)
		 {
		 $("#total_amount").val(0);
		 $("#total_amount").select();
		 }
		cal_balance();
	});


function cal_balance()
{
	var total_amount=$.trim($("#balance_amt").val());
	var paid_amount=$.trim($("#paid_amount").val());
	var Balacne=0;
	if(parseInt(total_amount)>0)
 	{
 	total_amount=parseInt(total_amount);
 	}
	if(parseInt(paid_amount)>0)
 	{
 	discount_amount=parseInt(paid_amount);
 	}
	next_due=total_amount-discount_amount;
	if(next_due<0)
	{
		alert("Extra Amount Not Allowed");
		$("#paid_amount").select();
	}
	else
	{
		$("#next_due").val(next_due);
	}
}

});


function SubmitForm()
{
	
	var payment_date=$.trim($("#payment_date").val());
	var member_user_id=$.trim($("#member_user_id").val());
	var member_name=$.trim($("#member_name").val());
	var sponcer_id=$.trim($("#sponcer_id").val());
	var sponcer_name=$.trim($("#sponcer_name").val());
	var paid_amount=$.trim($("#paid_amount").val());
	var next_due=$.trim($("#next_due").val());
	if(payment_date.length==0)
	{
		//alert("fsadfs");
		swal("Please Select EMI Payment Date....");
	    return;
	}
	else if(member_user_id.length!=10)
	{
		//alert("fsadfs");
		swal("Please Fill Customer Id....");
        return;
	}
	else if(member_name.length==0)
	{
		//alert("fsadfs");
		swal("Please Fill Customer Id....");
	    return;
	}
	else if(sponcer_id.length==0)
	{
		//alert("fsadfs");
		swal("Please Fill Customer Id....");
	    return;
	}
	else if(paid_amount.length==0)
	{
		//alert("fsadfs");
		swal("Please Fill EMI Paid Amount....");
		return;
	}
	else if(parseInt(paid_amount)<0)
	{
		//alert("fsadfs");
		swal("Please Fill EMI Paid Amount....");
		return;
	}
	else if(parseInt(next_due)<0)
	{
		//alert("fsadfs");
		swal("Extra Amount Not Allowed ...");
		return;
	}
	else
	{
		$("#btnsubmit").attr("disabled", true);
		$("#frmreg").submit();
	}
}

</script>
</body>

</html>
