<!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>Associate Registration | 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">
			
				<!-- Page Header -->
				<div class="page-header">
					<div class="row">
						<div class="col">
							<h5 class="page-title text-white">Associate Registration</h5>
    					
						</div>
					
					</div>
				</div>
				
					<form action="Apk/AssociateRegistration" method="post" id="frmreg">
                	<div class="row">
						<div class="col-sm-12">
							<div class="card">
								<div class="card-header">
									<h6 class="card-title">Personal Details </h6>
								</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-3">
									<div class="form-group">
										<label>Sponsor Id</label>
									<input type="text" class="form-control"  placeholder="" name="sponsor_id" id="sponsor_id"  maxLength="10" style="text-transform:uppercase;" onKeyup="get_sponsor();" onblur="get_sponsor();" maxLength="10"/>
									</div>
								</div>
									<div class="col-sm-6 col-md-6">
									<div class="form-group">
										<label>Sponsor Name</label>
										<input type="text" class="form-control" required="" readonly="" name="sponsor_name" id="sponsor_name"   placeholder=""  style="text-transform:uppercase;background-color:#fff" value="" >
									</div>
								</div>
							
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Select Position</label>
									 <select name="position" class="form-control" id="position" required onChange="get_promoter();" >
								 <option selected disabled value>Select Position</option>
                                        <option value="LEFT">LEFT</option>
                                        <option value="RIGHT">RIGHT</option>
                                 </select>
									</div>
								</div>
								<div class="col-sm-6 col-md-3">
									<div class="form-group">
										<label>Promoter Id</label>
									<input type="text" class="form-control" readonly=""   placeholder="" name="promoter_id" id="promoter_id"  maxLength="10" style="text-transform:uppercase;background-color:#fff"  />
									</div>
								</div>
									<div class="col-sm-6 col-md-5">
									<div class="form-group">
										<label>Promoter Name</label>
										<input type="text" class="form-control" required="" readonly="" name="promoter_name" id="promoter_name"   placeholder=""   value="" style="text-transform:uppercase;background-color:#fff">
									</div>
								</div>
									<div class="col-sm-6 col-md-4">
									<div class="form-group">
										<label>Associate Name</label>
											<input type="text" class="form-control"  placeholder="" name="member_name" id="member_name" value="" style="text-transform:uppercase;" onkeydown="return ((event.keyCode >= 65 && event.keyCode <= 90) || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 32)" maxLength="100"/>
									</div>
								</div>
								
									<div class="col-sm-6 col-md-4">
									<div class="form-group">
										<label>Contact No</label>
											<input type="text" class="form-control" placeholder="" name="contact" id="contact" 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"/>
									</div>
								</div>
								
									<div class="col-sm-6 col-md-4">
									<div class="form-group">
										<label>PAN No</label>
											<input type="text" class="form-control" placeholder="" name="pan_no" id="pan_no" maxLength="10" style="text-transform:uppercase;"  />
									</div>
								</div>
								
									<div class="col-sm-6 col-md-4">
									<div class="form-group">
										<label>Aadhar No</label>
											<input type="text" class="form-control" placeholder="" name="aadhar_no" id="aadhar_no" maxLength="12" 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>	
							<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 class="col-sm-6 col-md-6">
									<div class="form-group">
							      <span id="lblmsg" style="color:red; margin-left:10px"></span>
									</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 get_sponsor()
{ 
	 var sponcerid=$.trim($("#sponsor_id").val());
	 
	 if(sponcerid.length==10)
	 {
    //alert(sponcerid);
	 var dataString = 'member_user_id='+ sponcerid;
		$.ajax
		({
			type: "POST",
			url: "get_member.php",
			data: dataString,
			cache: false,
			success: function(data)
			{
			    console.log(data);
				$("#sponsor_name").val(data);
			} 
		});
	 }
	 else
	 {
	 $("#sponsor_name").val("");
	 }
}
function get_promoter()
{
	var sponcerid=$.trim($("#sponsor_id").val());
	 var position=$.trim($("#position").val());
	 if(position.length>3)
	 {
		 var dataString = 'sponcerid='+ sponcerid+'&position='+position;
		//alert(dataString);//
			$.ajax
			({
				type: "POST",
				url: "get_promoter.php",
				data: dataString,
				cache: false,
				success: function(data)
				{
					var ArrNames = data.split("%");
					$("#promoter_id").val(ArrNames[0]);
					$("#promoter_name").val(ArrNames[1]);
					 
				} 
			});
	 }
 }
function SubmitForm()
{
   
	var sponcerid=$.trim($("#sponsor_id").val());
	var sponsor_name=$.trim($("#sponsor_name").val());
	var position=$.trim($("#position").val());
	var promoter_id=$.trim($("#promoter_id").val());
	var promoter_name=$.trim($("#promoter_name").val());
	var member_name=$.trim($("#member_name").val());
	var contact=$.trim($("#contact").val());
	var pan_no=$.trim($("#pan_no").val());
	var aadhar_no=$.trim($("#aadhar_no").val());

	if(sponcerid.length!=10)
	{
		swal("!Please Fill Valid Sponsor Id");
		return;
	}
	else if(sponsor_name.length==0)
	{
        swal("!Please Fill Valid Sponsor Id");
		return;
	}

	else if(position.length==0)
	{
		 swal("!Please Fill Valid Position");
		return;
	}
	else if(promoter_id.length!=10)
	{
        swal("!Please Fill Valid Promoter Id");
		return;
	}
	else if(promoter_name.length==0)
	{
        swal("!Please Fill Promoter Name");
		return;
	}
	else if(contact.length!=10)
	{
        swal("!Please Fill Contact");
		return;
	}
	else if(pan_no.length!=10)
	{
        swal("!Please Fill Valid PAN No");
		return;
	}
	else if(aadhar_no.length!=12)
	{
        swal("!Please Fill Valid Aadhar No");
		return;
	}
	else
	{
		$("#btnsubmit").attr("disabled", true);
		$("#frmreg").submit();
	}
 }
</script>
</body>

</html>
