<?php
error_reporting(0);
?>
<!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>Add New Project | 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">
		<link rel="stylesheet" href="assets/css/select2.min.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">
				
					<div class="row">
						<div class="col-sm-12">
							<div class="card">
								<div class="card-header">
									<h6 class="card-title">Add New Plot</h6>
									<span><?php echo $_REQUEST['msg']; ?></span>
								</div>
								<div class="card-body">

									<div class="table-responsive">
										<div class="card filter-card">
						<div class="card-body pb-0">
						    <form name="frm" id="frm" method="post" action="Apk/AddNewPlot">
							<div class="row filter-row">
								<div class="col-sm-6 col-md-4">
									<div class="form-group">
										<label>Select Project</label>
									    <select name="project_name" id="project_name" class="form-control"   required>
									        <option value="">Select Project</option>
									        <?php 
									        $str="Select * from tbl_prject_master";
									        $res=mysqli_query($connection,$str);
									        while($row=mysqli_fetch_array($res))
									        {
									            ?>
									            <option value="<?php echo $row['project_id']; ?>"><?php echo $row['project_name']; ?></option>
									            <?php
									        }
									        ?>
									    </select>
									</div>
								</div>
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Sector Name</label>
										<input class="form-control" type="text" name="sector_code" id="sector_code" value="" maxlength="30">
									
									</div>
								</div>
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Plot Code</label>
										<input class="form-control" type="text" name="plot_code" id="plot_code" value="" maxlength="2">
									
									</div>
								</div>
							
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Start From</label>
										<input class="form-control" type="text" name="starting_no" id="starting_no" value="1" maxLength="4" 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>Total Plots</label>
									<input type="text" name="total_plots" id="total_plots" required class="form-control" 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) )" maxLength="4">
									
									</div>
								</div>
							    <div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Width</label>
									<input type="text" name="plot_width" id="plot_width" required class="form-control"  maxLength="10">
									
									</div>
								</div>
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Length</label>
									<input type="text" name="plot_Length" id="plot_Length" required class="form-control" maxLength="10">
									
									</div>
								</div>
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Plot Area Sq/Ft</label>
									<input type="text" name="plot_area" id="plot_area" required class="form-control" readonly 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) )" maxLength="10" style="background-color:#fff">
									
									</div>
								</div>
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Plot Rate</label>
									<input type="text" name="plot_rate" id="plot_rate" required class="form-control"  maxLength="8" 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>Total Amount</label>
									<input type="text" name="plotAmt" id="plotAmt" required class="form-control"  maxLength="15" readonly style="background-color:#fff">
									
									</div>
								</div>
								<div class="col-sm-6 col-md-3">
								<div class="form-group">
								     <button type="button" class="btn btn-primary" id="btnedit" onClick="SavePlot()">&nbsp;&nbsp;&nbsp;Submit &nbsp;&nbsp;<i class="ft-thumbs-up position-right"></i></button>
								</div></div>
								<div class="col-sm-6 col-md-6">
								<div class="form-group">
								    <span id="lblmsg"></span>
								</div></div>
							</div>	
							</form>
						
						</div>
					</div>
									</div>
								</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 -->
	<script src="assets/js/admin.js"></script>
<script src="assets/js/select2.min.js"></script>
<script>
 $(document).ready(function()
 {
	$("#plot_width").keyup(function()
	{ // Keyup function for check the user action in input
		 var plot_width=$.trim($("#plot_width").val());
		 if(plot_width.length==0)
		 {
			$("#plot_width").val(0);
			$("#plot_width").select();
		 }
		 cal_size();
	});
	$("#plot_Length").keyup(function()
	{ // Keyup function for check the user action in input
		 var plot_Length=$.trim($("#plot_Length").val());
		 if(plot_Length.length==0)
		 {
		 $("#plot_Length").val(0);
		 $("#plot_Length").select();
		 }
		 cal_size();
	});

	$("#plot_rate").keyup(function()
	{ // Keyup function for check the user action in input

		 GetPlotAmt();
	});

function cal_size()
{
	var plot_width=$.trim($("#plot_width").val());
	var plot_Length=$.trim($("#plot_Length").val());
	var total_size=0;
	if(parseInt(plot_width)>0)
 	{
 	    plot_width=parseFloat(plot_width);
 	}
	if(parseInt(plot_Length)>0)
 	{
    	plot_Length=parseFloat(plot_Length);
 	}
	total_size=plot_width*plot_Length;
	$("#plot_area").val(total_size);
}

function GetPlotAmt()
{
   
    var plot_area=$.trim($("#plot_area").val());
	var plot_rate=$.trim($("#plot_rate").val());
	if(parseInt(plot_area)>0)
 	{
 	    plot_area=parseFloat(plot_area);
 	}
	if(parseInt(plot_rate)>0)
 	{
    	plot_rate=parseFloat(plot_rate);
 	}
	totalAmt=plot_area*plot_rate;
	$("#plotAmt").val(totalAmt);
}
		
});

function SavePlot()
{
	//
	var project_id=$.trim($("#project_name").val());
	var sector=$.trim($("#sector_code").val());
    var starting_no=$.trim($("#starting_no").val());
	var total_plots=$.trim($("#total_plots").val());
	var plot_width=$.trim($("#plot_width").val());
	var plot_Length=$.trim($("#plot_Length").val());
	var plot_area=$.trim($("#plot_area").val());
	var plot_rate=$.trim($("#plot_rate").val());
	var plotAmt=$.trim($("#plotAmt").val());
    if(project_id.length==0)
	{
		//alert("fsadfs");
		$("#lblmsg").html("Please Select Project....");
		$("#project").focus();$("#project").select();return;
	}
// 	else if(sector.length==0)
// 	{
// 		//alert("fsadfs");
// 		$("#lblmsg").html("Please Fill Sector....");
// 		$("#sector").focus();$("#sector").select();return;
// 	}
	else if(starting_no.length==0)
	{
		$("#starting_no").val("1");
	}
	else if(parseInt(starting_no)==0)
	{
		$("#starting_no").val(1);
	}
	else if(total_plots.length==0)
	{
		$("#lblmsg").html("Please Fille total Plots....");
		$("#total_plots").focus();$("#total_plots").select();return;
	}
	else if(parseInt(total_plots)==0)
	{
		$("#lblmsg").html("Please Fill total Plots....");
		$("#total_plots").focus();$("#total_plots").select();return;
	}
	else if(plot_width.length==0)
	{
		$("#lblmsg").html("Please Fill Plot Width....");
		$("#plot_width").focus();$("#plot_width").select();return;
	}
	else if(parseInt(plot_width)==0)
	{
		$("#lblmsg").html("Please Fill Plot Width....");
		$("#plot_width").focus();$("#plot_width").select();return;
	}
	else if(plot_Length.length==0)
	{
		$("#lblmsg").html("Please Fill Plot Length....");
		$("#plot_Length").focus();$("#plot_Length").select();return;
	}
	else if(parseInt(plot_Length)==0)
	{
		$("#lblmsg").html("Please Fill Plot Length....");
		$("#plot_Length").focus();$("#plot_Length").select();return;
	}
	else if(plot_area.length==0)
	{
		$("#lblmsg").html("Please Fill Plot Area....");
		$("#plot_Length").focus();$("#plot_area").select();return;
	}
	else if(parseInt(plot_area)==0)
	{
		$("#lblmsg").html("Please Fill Plot Length....");
		$("#plot_area").focus();$("#plot_area").select();return;
	}
	else if(plot_rate.length==0)
	{
		$("#lblmsg").html("Please Fill Plot Rate....");
		$("#plot_rate").focus();$("#plot_rate").select();return;
	}
	else if(parseInt(plot_rate)==0)
	{
		$("#lblmsg").html("Please Fill Plot Rate....");
		$("#plot_rate").focus();$("#plot_rate").select();return;
	}
	else
	{
		$("#btnedit").attr("disabled", true);
		$("#frm").submit();
	}
}
</script>
</body>


</html>