<?php include("auth.php");

require("conn.php");
$action = "Add";
$id = null;

if (isset($_GET['action']))
{
    $action = base64_decode($_GET['action']);
    $id = base64_decode($_GET['id']);

    $sql = "select * from tbl_customer where id='$id'";
    $smt = mysqli_query($conn, $sql);
    $row = mysqli_fetch_assoc($smt);
}

?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">

    <title>Create Leads </title>
    <meta content="" name="description">
    <meta content="" name="keywords">
    <link href="assets/img/favicon.png" rel="icon">
    <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
    <?php include("templates/inc.php"); ?>

    <!--<script src="scripts/customer.js" type="text/javascript" language="javascript"></script>-->
    
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
   
   <script>
   
   
   
   $(document).ready(function(){
    //Upload event_url 

   
// jQuery ajax form submit example, runs when form is submitted
$("#f1").submit(function(e) {
    e.preventDefault(); // prevent actual form submit
    var form = $(this);
    var url = form.attr('action'); //get submit url [replace url here if desired]  
    
    $("#btnAdd").val("Submitting...");
    $("#btnAdd").prop('disabled', true);
    setInterval(function () {$("#btnAdd").prop('disabled', false);}, 3000);

    
        $.ajax({
            type: "POST",
            url: url,
            data: form.serialize(), // serializes form input
            success: function(data){

                console.log(data);
                $("#btnAdd").val("Submit");
                
                $("#msg").html(data); 
                $("#msg").slideDown("slow");
                $("#msg").slideUp(5000,function(){ 
                if(data=="Your are Registered.")
                   window.location="leads-list.php";
                 });
				    
                   
                
                
            }
        });
    
});




	
});
    
 
  
    //Upload image_url 

            $(document).on('change', '#file_url', function () {
                var name = document.getElementById("file_url").files[0].name;
                var form_data = new FormData();
                var ext = name.split('.').pop().toLowerCase();
                if (jQuery.inArray(ext, ['pdf', 'jpeg', 'jpg', 'png']) == -1) {
                    alert("Invalid Image File");
                }
                var oFReader = new FileReader();
                oFReader.readAsDataURL(document.getElementById("file_url").files[0]);
                var f = document.getElementById("file_url").files[0];
                var fsize = f.size || f.fileSize;
                if (fsize > 2000000) {
                    alert("Image File Size is very big");
                } else {
                    form_data.append("file_url", document.getElementById('file_url').files[
                        0]);

                    $.ajax({

                        url: "upload.php",
                        method: "POST",
                        data: form_data,
                        contentType: false,
                        cache: false,
                        processData: false,
                        beforeSend: function () {
                            $('#uploaded_file_url').html(
                                "<label class='text-success'>Uploading...</label>");
                        },
                        success: function (data) {
                            $('#uploaded_file_url').html(data);
                        }
                    });
                }
            });



  
  
  
  $(function () {
  $("#state_id").change(function(){
	 
   var id=$("#state_id").val();
   
	
		$.ajax({
			 type:'post',
			 url: 'get-districts.php',
			 data: {'id':id},
			 success: function(data)
			 {	 
			    
				 $("#district_id").html(data); 
				
			  }
		 });
       });
       
  });

  </script>

</head>

<body>

    <!-- ======= Header ======= -->
    <?php
    include("templates/header.php");
    ?>

    <!-- End Header -->

    <!-- ======= Sidebar ======= -->
    <?php
    include("templates/sidebar.php");

    ?>
    <!-- End Sidebar-->

    <main id="main" class="main">

        <div class="pagetitle">
            <h1>Create Leads </h1>
            <nav>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
                    <li class="breadcrumb-item">Create Leads </li>

                </ol>
            </nav>
            <hr>
           
        </div><!-- End Page Title -->
                        <a href="leads-list.php">
                            <button type="button" class="btn btn-sm btn-primary mt-2 py-2"><i class="bi bi-arrow-left me-1"></i>Leads List</button>
                        </a>
       <br><br>
        <section class="section">
            <div class="row">
                <div class="col-lg-12">

                    <div class="card">
                      
                        <div class="card-body">
                            <div class="card-body">
                                <h5 class="card-title">Add New Leads</h5>

                                <!-- Custom Styled Validation -->
                                <form id="f1" action="leads-action.php" class="row g-3 needs-validation" novalidate="" method="post">
                                   
                                      
                                  <div class="col-md-2">
                                   <label for="validationDefault04" class="form-label"><b>Intrested In</b></label>
                                  </div>
                                  <div class="col-md-3">
                                      
                                      <input type="radio" id="intrested_in" name="intrested_in" value="Free Counselling"  checked="checked">  Free Counselling 
                                  </div>
                                      <div class="col-md-3">
                                      
                                      <input type="radio"id="intrested_in" name="intrested_in" value="Demo Class" > Demo Class
                                  </div>   
                                      
                                   

                                     <div class="col-md-6">
                                        <label for="validationCustom01" class="form-label"><b> Name</b></label>
                                        <input value="<?php if (isset($_GET['id'])) echo $row['name']; ?>" type="text" class="form-control" id="name" name="name" required="" placeholder="Enter Your name">
                                        <div class="invalid-feedback">
                                            Please provide a Name.
                                        </div>
                                    </div>
                                    
                                    <div class="col-md-6">
                                        <label for="validationCustom01" class="form-label"><b>Mobile Number</b></label>
                                        <input value="<?php if (isset($_GET['id'])) echo $row['mobile']; ?>" type="number" class="form-control" id="mobile" name="mobile" required="" placeholder="Enter Your Mobile Number">
                                        <div class="invalid-feedback">
                                            Please provide a mobile number.
                                        </div>
                                    </div>
                                  
                                     <div class="col-md-12">
                                      
                                      
                                       <label for="yourDesignation" class="form-label"><b>Select Course</b></label>
                                        <select class="form-select" id="course" name="course">
                                         <option selected="selected" value="0">Choose...</option>
                                          <option>Full Stack Developer Bootcamp(FSDB)</option>
                                          <option>App Developer Bootcamp(ADB)</option>
                                          <option>Data Analyst Bootcamp(ADB)</option>
                                          <option>Digital Marketing Bootcamp(ADB)</option>
                                        </select>
                                        
                                         
                                         
                                  </div>
                                    
                                    
                                    <div class="col-md-12">
                                      
                                         <label for="yourDesignation" class="form-label"><b>Select Last Education</b></label>
                                        <select class="form-select" id="education" name="education">
                                         <option selected="salacted" value="0">Choose...</option>
                                          <option>B-TECH</option>
                                          <option>M-TECH</option>
                                          <option>BCA</option>
                                          <option>MCA</option>
                                          <option>BSC IT/CS</option>
                                          <option>MSC IT/CS</option>
                                          <option>BBA</option>
                                          <option>MBA</option>
                                          <option>POLYTECHNIC</option>
                                          <option>BA</option>  
                                          <option>MA</option>  
                                          <option>BSC</option>  
                                          <option>MSC</option>  
                                          <option>BCOM</option>  
                                          <option>MCOM</option>  
                                          <option>INTERMEDIATE</option>
                                          <option>OTHERS</option>
                                        </select>
                                     
                                        
                                         
                                         
                                  </div>
                                    
                                    
                                  <div class="col-md-6">
                                      
                                        <label for="yourDesignation" class="form-label"><b>Colleges/Intitution Name</b></label>
                                      
                                <input value="<?php if (isset($_GET['id'])) echo $row['institute_name']; ?>" type="text" class="form-control" id="institute_name" name="institute_name" required="" placeholder="Enter Your College/Institute">
                                        
                                        
                                         
                                         
                                  </div>
                                  
                                  <div class="col-md-6">
                                      
                                      
                                       <label for="yourDesignation" class="form-label"><b>Select Year</b></label>
                                        <select class="form-select" id="passing_year" name="passing_year">
                                         <option selected="selected" value="0">Choose...</option>
                                          <option value="First Year (1st)">First Year (1st)</option>
                                          <option value="Second Year (2nd)">Second Year (2nd)</option>
                                          <option value="Third Year (3rd)">Third Year (3rd)</option>
                                          <option value="Fourth Year (4th)">Fourth Year (4th)</option>
                                          <option value="Pass Out">Pass Out</option>
                                          
                                          
                                        </select>
                                        
                                         
                                         
                                  </div>

                                 

                                  


                                    <div class="col-12 text-center">
                                        <!--<input type="hidden" name="v_code" id="v_code" value="<?php echo $vc; ?>" />-->
                                        
                                       <div class="alert alert-primary" role="alert" id="msg" style="display:none">
                                          
                                        </div>
                                    <button class="btn btn-primary  btn-lg" id="btnAdd" type="submit">Add</button>
                
                                        
                                                                            </div>
                                </form><!-- End Custom Styled Validation -->
                            </div>
                        </div>
                    </div>

                </div>
            </div>

        </section>







    </main><!-- End #main -->




    <!-- ======= Footer ======= -->
    <?php
    include("templates/footer.php");
    ?>
    <!-- End Footer -->


    <?php include("templates/vendors.php"); ?>

</body>

</html>