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

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

if (isset($_GET['id'])) {
    $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>Follow Up</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>
   $(document).ready(function() {

            $("#BtnSubmit").click(function() {
                $("#BtnSubmit").html("Saving...");

                var code = $("#code").val();
                var comments = $("#comments").val();
                var status = $("#status").val();
                var next_date=$("#next_date").val();
                $.ajax({
                    type: 'post',
                    url: 'followup-action.php',
                    data: {
                        'code': code,
                        'comments': comments,
                        'status': status,
                        'next_date':next_date,
                    },

                    success: function(data) {
                        alert(data);
                        $("#BtnSubmit").html("Save");
                        location.reload();
                      
                    }

                });



            });


        });
    </script>
</head>


<style>
    
    
/* CSS */
.button-33 {
  background-color: #c2fbd7;
  border-radius: 100px;
  box-shadow: rgba(44, 187, 99, .2) 0 -25px 18px -14px inset,rgba(44, 187, 99, .15) 0 1px 2px,rgba(44, 187, 99, .15) 0 2px 4px,rgba(44, 187, 99, .15) 0 4px 8px,rgba(44, 187, 99, .15) 0 8px 16px,rgba(44, 187, 99, .15) 0 16px 32px;
  color: green;
  cursor: pointer;
  display: inline-block;
  font-family: CerebriSans-Regular,-apple-system,system-ui,Roboto,sans-serif;
  padding: 7px 20px;
  text-align: center;
  text-decoration: none;
  transition: all 250ms;
  border: 0;
  font-size: 16px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.button-33:hover {
  box-shadow: rgba(44,187,99,.35) 0 -25px 18px -14px inset,rgba(44,187,99,.25) 0 1px 2px,rgba(44,187,99,.25) 0 2px 4px,rgba(44,187,99,.25) 0 4px 8px,rgba(44,187,99,.25) 0 8px 16px,rgba(44,187,99,.25) 0 16px 32px;
  transform: scale(1.05) rotate(-1deg);
}
    
   
</style>

<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>Follow Up</h1>
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a href="index.html">Home</a></li>
          <li class="breadcrumb-item">Follow Up</li>
        </ol>
      </nav>
    </div><!-- End Page Title -->


 <a href="leads-list.php">
                            <button type="button" class="btn btn-sm btn-success mt-2 py-2"><i class="bi bi-arrow-left me-1"></i>Leads List</button>
                        </a>
<br> <br>

    <section class="section dashboard">
      <div class="row">

        <!-- Left side columns -->
        <div class="col-lg-12">
          <div class="row">

            
            
            
             <!-- Sales Card -->
         
                
                <div class="card">
            <div class="card-body">
                
        <br>
                 <input type="hidden" id="code" name="code" value="<?php echo $id; ?>">
               
                <div class="col-12">
                  <label for="Comments" class="form-label">Comments</label>
                  <textarea type="text" class="form-control" name="comments" id="comments"></textarea> 
                </div>
               <div class="col-md-12">
                  <label for="Status" class="form-label">Status</label>
                  <select id="status" name="status" class="form-select">
                    <option value="Follow Up">Follow Up</option>
                    <option value="Not Intrested">Not Intrested</option>
                    <option value="Admission Confirmed">Admission Confirmed</option>
                    <option value="Contact Later">Contact Later</option>
                  </select>
                </div>
                  <div class="col-12">
                  <label for="next_date" class="form-label">Next Follow Up Date</label>
                  <input type="date" class="form-control" name="next_date" id="next_date" > 
                </div>
             <br>
                 <button type="button" id="BtnSubmit" name="BtnSubmit" class="btn btn-success">Save</button>
                 <a href="leads-list.php"><button type="button" class="btn btn-primary">Cancel</button></a>
             

       

            </div>
          </div>
                
                
              <div class="card info-card revenue-card">
       


        <div class="card-body">
              <h5 class="card-title">Lead <span>| Activities</span></h5>

              <div class="activity">
                                   <?php
                                        require "conn.php";
                                
                                        $sl = 1;
                                        $sql1 = "select * from tbl_follow_up where lead_id='$id' order by id desc";

                                        $rs1 = mysqli_query($conn, $sql1);
                                        while ($row1 = mysqli_fetch_assoc($rs1)) 
                                        {
                                        ?>
                                    <div class="activity-item d-flex">
                                      <div class="activite-label"><?php echo $sl.') '.$row1['date']; ?></div>
                                      <i class="bi bi-circle-fill activity-badge text-success align-self-start"></i>
                                      <div class="activity-content">
                                    <?php echo $row1['comments']; ?>
                                      </div>
                                    </div><!-- End activity item-->
                <?php
                $sl++;
                                        }
                                        
                                        ?>

               

              </div>

            </div>
        
        
        
        

              </div>
            


<div class="col-xxl-2 col-md-1">
            </div><!-- End Revenue Card -->
            


          </div>
        </div>

      </div>
    </section>
    <br><br><br>

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

  <!-- End Footer -->


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


</html>