<?php
include("conn.php");
if(isset($_GET['id']))
{
      $id = base64_decode($_GET['id']);
    $sql="select * from tbl_customer where id='$id'";
    $smt=mysqli_query($conn,$sql);

    // print_r($sql);
    // die();
    $Lead=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>Update 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="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
    
    $(document).ready(function() {

    var url = "post-action.php";
    // 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]

        $("#btnUpdate").val("Submitting...");
        $("#btnUpdate").prop('disabled', true);
        setInterval(function() { $("#btnUpdate").prop('disabled', false); }, 5000);
        $.ajax({
            type: "POST",
            url: url,
            data: form.serialize(), // serializes form input
            success: function(data) {

                console.log(data);


                if ( data == "Record Updated")
                {
                    window.location = "leads-list.php";
                } else {
                    $("#msg").html(data);
                    $("#msg").slideDown("slow");
                    $("#msg").slideUp(3000);

                }
            }
        });

    });
    });



     $(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>Update Leads </h1>
            <nav>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
                    <li class="breadcrumb-item">Update Lead </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">Update Lead : <?php  if(isset($_GET['id'])) echo $Lead['name'];  ?></h5>
                                
                                  <form id="f1" action="update-lead-action.php" class="row g-3 needs-validation" novalidate="" method="post">
                                     
                                       <input type="hidden" name="id" id="id" value="<?php if (isset($_GET['id'])) echo $Lead['id']; ?>" />
                                      <div class="col-md-12">
                                          <label for="validationCustom01" class="form-label"><b> Course</b></label> 
                                          <select class="form-select" id="services" name="services">
                                         <option selected="selected" value="<?php if (isset($_GET['id'])) echo $Lead['services']; ?>"><?php if (isset($_GET['id'])) echo $Lead['services'];  ?></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-6">
                                        <label for="validationCustom01" class="form-label"><b> Name</b></label>
                                        <input value="<?php if (isset($_GET['id'])) echo $Lead['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 $Lead['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-6">
                                      
                                         <label for="yourDesignation" class="form-label"><b> Last Education</b></label>
                                         <select class="form-select" id="education" name="education">
                                         <option selected="selected" value="<?php if (isset($_GET['id'])) echo $Lead['education']; ?>"><?php if (isset($_GET['id'])) echo $Lead['education'];  ?></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 $Lead['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="<?php if (isset($_GET['id'])) echo $Lead['passing_year']; ?>"><?php if (isset($_GET['id'])) echo $Lead['passing_year'];  ?></option>
                                          <option>First Year (1st)</option>
                                          <option>Second Year (2nd)</option>
                                          <option>Third Year (3rd)</option>
                                          <option>Fourth Year (4th)</option>
                                          <option>Pass Out</option>
                                          
                                          
                                        </select>
                                        
                                         
                                         
                                  </div>
                                  <div class="col-md-6" >
                                       <label for="yourDesignation" class="form-label"><b>Email</b></label>
                                     <input value="<?php if (isset($_GET['id'])) echo $Lead['email']; ?>" type="email" class="form-control" id="email" name="email" required="" placeholder="Enter Your email">

                                  </div>
                                
                                    <div class="col-md-6">
                                      
                                      
                                       <label for="yourDesignation" class="form-label"><b>state</b></label>
                                        <input value="<?php if (isset($_GET['id'])) echo $Lead['state_id']; ?>" type="text" class="form-control" id="state_id" name="state_id" required="" placeholder="Enter Your State">

                                        <!--<select class="form-select" id="state_id" name="state_id">-->
                                        <!-- <option selected="selected" value="<?php if (isset($_GET['id'])) echo $Lead['state_id']; ?>"><?php if (isset($_GET['id'])) echo $Lead['state_id'];  ?></option>-->
                                      
                                    
                                        <!--        include("./conn.php");-->
                                        <!--        $sql = "select * from state order by state_title asc";-->
                                        <!--        $smt = mysqli_query($conn, $sql);-->
                                        <!--        while ($rs = mysqli_fetch_assoc($smt)) -->
                                        <!--        {-->
                                        <!--            echo '<option value="'.$rs['id'].' ">'.$rs['state_title'].'</option>';-->
                                        <!--        }-->
                                        <!--        ?>-->

                                          
                                          
                                        <!--</select>-->
                                        
                                         
                                         
                                  </div>
                                    <div class="col-md-6">
                                      
                                      
                                       <label for="yourDesignation" class="form-label"><b>District</b></label>
                                        <input value="<?php if (isset($_GET['id'])) echo $Lead['district_id']; ?>" type="text" class="form-control" id="district_id" name="district_id" required="" placeholder="Enter Your District">
                                        <!--<select class="form-select" id="district_id" name="district_id">-->
                                        <!-- <option selected="selected" value="<?php if (isset($_GET['id'])) echo $Lead['district_id']; ?>"><?php if (isset($_GET['id'])) echo $Lead['district_id'];  ?></option>-->
                                             
                                          
                                          
                                        <!--</select>-->
                                        
                                         
                                         
                                  </div>
                                
                                   <div class="col-md-12">
                                      
                                      
                                       <label for="yourDesignation" class="form-label"><b>Address</b></label>
                                    <textarea  type="text" class="form-control" id="address" name="address" required=""><?php if (isset($_GET['id'])) echo $Lead['address']; ?></textarea>
                                        <div class="invalid-feedback">
                                            Please provide a address.
                                        </div>
                                        
                                         
                                         
                                  </div>
                                
                                  <div class="col-md-12">
                                        <label for="validationCustom01" class="form-label"><b>Remarks</b></label>
                                        <textarea type="text" rows="2" class="form-control" id="remarks" name="remarks" required=""> <?php if (isset($_GET['id'])) echo $Lead['remarks']; ?></textarea>
                                       
                                        <div class="invalid-feedback">
                                            Please provide require.
                                        </div>
                                  </div>
                                    <div class="col-md-6">
                                        <label for="validationCustom01" class="form-label"><b>Lead source</b></label>
                                         <select class="form-select" id="lead_source" name="lead_source">
                                         <option selected="selected" value="<?php if (isset($_GET['id'])) echo $Lead['lead_source']; ?>"><?php if (isset($_GET['id'])) echo $Lead['lead_source'];  ?></option>
                                         <option  value="Facebook Advertisement">Facebook Advertisement</option>  
                                         <option value="Instagram ad">Instagram ad</option>
                                         <option value="Youtube Ad">Youtube Ad</option>
                                         <option value="Referred from Friends">Referred from Friends</option>
                                          
                                          
                                        </select>
                                        <div class="invalid-feedback">
                                            Please provide require.
                                        </div>
                                  </div>
                                    <div class="col-md-6">
                                        <label for="validationCustom01" class="form-label"><b>Priority</b></label>
                                         <select class="form-select" id="priority" name="priority">
                                         <option selected="selected" value="<?php if (isset($_GET['id'])) echo $Lead['priority']; ?>"><?php if (isset($_GET['id'])) echo $Lead['priority'];  ?></option>
                                          <option value="High">High</option>   
                                          <option value="Medium">Medium</option>
                                          <option value="Low">Low</option>
                                          
                                        </select>
                                        <div class="invalid-feedback">
                                            Please provide require.
                                        </div>
                                  </div>
                                  
                                  <div class="col-md-12" >
                                       <button class="btn btn-lg btn-primary btn-sm" type="submit" id="btnUpdate">Update</button>
                                            <a href="leads-list.php"><button class="btn btn-sm btn-danger btn-lg" type="button">Cancel</button></a>
                                  </div>
                                </form>
                             </div>
                        </div>
                    </div>

                </div>
            </div>

        </section>







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




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


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

</body>

</html>    