<!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>Edit Plot Booking Details | 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 
 $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">Edit Plot Booking Details <small></small></h5>
    					    <span class="text-warning"><?php echo $_REQUEST['msg']; ?></span>
						</div>
					
					</div>
				</div>
				
					<form action="Apk/EditPlotBooking" method="post" id="frmreg">
                	<div class="row">
						<div class="col-sm-12">
							<div class="card">

								<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-3">
									<div class="form-group">
										<label>Customer Id</label>
								 <input type="text" class="form-control" id="member_user_id" readonly 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-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>Plot Code</label>
								<input type="text" class="form-control" name="plot_code" id="plot_code" value="<?php echo $row['plot_code']; ?>" 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) )">
							
									</div>
								</div>
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Plot Size</label>
								<input type="text" class="form-control" id="plot_size" value="<?php echo $row['plot_size']; ?>" name="plot_size"  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) )" onkeyup="CalPlotAmt();">
									</div>
								</div>
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Plot Rate</label>
								<input type="text" class="form-control" id="plot_rate" value="<?php echo $row['plot_rate']; ?>" name="plot_rate"  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) )" onkeyup="CalPlotAmt();">
									</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="total_amount" value="<?php echo $row['total_amount']; ?>" name="total_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) )" onkeyup="calNextDue()">
									</div>
								</div>
								
								
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Discount Amt</label>
								<input type="text" class="form-control" id="discount_amt" value="<?php echo $row['discount_amt']; ?>" name="discount_amt" 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) )" onkeyup="calNextDue()">
									</div>
								
								</div>
									<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Net Amt</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) )">
									</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="<?php echo $row['paid_amount']; ?>" 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) )" onkeyup="calNextDue();">
									</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="balance_amt" value="<?php echo $row['balance_amt']; ?>" name="balance_amt" readonly="true" style="background-color:#FFFFFF; text-align:right;" required>
									</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>

function CalPlotAmt()
{
    var plotSize=0;var plotRate=0;
    var psize=$.trim($("#plot_size").val());
    var pRate=$.trim($("#plot_rate").val());
    if(psize.length>0)
    {
        plotSize=psize;
    }
    if(pRate.length>0)
    {
        plotRate=pRate;
    }
    var plotAmt=parseFloat(plotSize)*parseFloat(plotRate);
    $("#total_amount").val(plotAmt);
    calNextDue();
}

function calNextDue()
{
    var totalAmt=0;var DiscAmt=0;var PaidAmt=0;var balanceAmt=0;
    var total_amount=$.trim($("#total_amount").val());
    var discount_amt=$.trim($("#discount_amt").val());
    var paid_amount=$.trim($("#paid_amount").val());
    if(total_amount.length>0) { totalAmt=total_amount; }
    if(discount_amt.length>0) { DiscAmt=discount_amt; }
    if(paid_amount.length>0) { PaidAmt=paid_amount; }
    var netAmt=parseFloat(totalAmt)-parseFloat(DiscAmt);
    var balanceAmt=parseFloat(netAmt)-parseFloat(paid_amount);
    $("#net_amount").val(netAmt);
    $("#balance_amt").val(balanceAmt);
}

function SubmitForm()
{
    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 booking_random_no=$.trim($("#booking_random_no").val());
	var businessper=$.trim($("#businessper").val());
	var plot_size=$.trim($("#plot_size").val());
	var plot_rate=$.trim($("#plot_rate").val());
	var plot_code=$.trim($("#plot_code").val());
	var total_amount=$.trim($("#total_amount").val());
	var discount_amt=$.trim($("#discount_amt").val());
	var net_amount=$.trim($("#net_amount").val());
	var paid_amount=$.trim($("#paid_amount").val());
	var balance_amt=$.trim($("#balance_amt").val());
     if(member_user_id.length!=10)
	{
    	swal("Please Fill Customer Id....");
        return;
	}
	else if(member_name.length==0)
	{
		swal("Please Fill Customer Id....");
	    return;
	}
	else if(sponcer_id.length==0)
	{
    	swal("Please Fill Customer Id....");
	    return;
	}
	else if(plot_size.length==0)
	{
    	swal("Please Fill Plot Size");
		return;
	}
	else if(parseInt(plot_size)==0)
	{
	    swal("Please Fill Plot Size");
		return;
	}
		else if(plot_rate.length==0)
	{
    	swal("Please Fill Plot Rate");
		return;
	}
	else if(parseInt(plot_rate)==0)
	{
	    swal("Please Fill Plot Rate");
		return;
	}
	else if(businessper.length==0)
	{
	    swal("Please Fill Business Percentage");
		return;
	}
	else if(parseInt(businessper)==0)
	{
	    swal("Please Fill Business Percentage");
		return;
	}
    else if(total_amount.length==0)
	{
	    swal("Please Fill Plot Total Amount");
		return;
	}
	else if(parseInt(total_amount)==0)
	{
	    swal("Please Fill Plot Total Amount");
		return;
	} 
	else if(discount_amt.length==0)
	{
	    swal("Please Fill Discount Amount");
		return;
	}
	else if(net_amount.length==0)
	{
	    swal("Please Fill Plot Net Amount");
		return;
	}
	else if(parseInt(net_amount)==0)
	{
	    swal("Please Fill Plot Net Amount");
		return;
	} 
	else if(paid_amount.length==0)
	{
	    swal("Please Fill Total Paid Amount");
		return;
	}

	else if(balance_amt.length==0)
	{
	    swal("Please Fill Next Balance Amount");
		return;
	}
	else if(parseInt(balance_amt)==0)
	{
	    swal("Please Fill Next Balance Amount");
		return;
	} 
	else
	{
		$("#btnsubmit").attr("disabled", true);
		$("#frmreg").submit();
	}
}

</script>
</body>

</html>
