<?php include("auth.php");
session_start();
?>
<!DOCTYPE html>
<html lang="en">

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

    <title>Leads List</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/2.1.1/jquery.min.js"></script>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

     <script>
      $(document).ready(function() {
     $('#exampleModal').on('shown.bs.modal', function () {
  $('#myInput').trigger('focus')
});


 $("#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();
                      
                    }

                });
 });
 

 
 

});
function getId(clicked)
{
//   alert(clicked) ;
    $('#code').val(clicked);
};
 


       
    </script>
   
   
<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: 13px;
  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>
</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>Leads</h1>
           
           
        </div><!-- End Page Title -->

        <section class="section">
            <a href="leads.php">
                <button type="button" class="btn btn-primary"><i class="bi bi-plus me-1"></i> Add New Lead</button>
            </a><br><br>
            
<!-- Button trigger modal -->
<!--<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">-->
<!--  Launch demo modal-->
<!--</button>-->

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h3 class="modal-title" id="exampleModalLabel">Follow Up</h3>
        <!--<button type="button" class="close" data-dismiss="modal" aria-label="Close">-->
        <!--  <span aria-hidden="true"></span>-->
        <!--</button>-->
      </div>
      <div class="modal-body">
          <input type="hidden" id="code" name="code" value="">
           <div class="col-sm-12">
                  <label for="Comments" class="form-label">Comments</label>
                  <textarea type="text" class="form-control" name="comments" id="comments"></textarea> 
                </div>
               <div class="col-sm-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-sm-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>
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" id="BtnSubmit" name="BtnSubmit">Save</button>
      </div>
    </div>
  </div>
</div>



            <section class="section">
                <div class="row">
                    <div class="col-lg-12">

                        <div class="card" style="overflow:scroll;">
                            <div class="card-body" id="records">
                                <h5 class="card-title">Leads</h5>
                                <!-- Table with stripped rows -->
                             <table id="example" class="table table-striped dt-responsive nowrap" style="width:100%">

                                    <thead>
                                        <tr>
                                            <!--<th>Sl NO.</th>-->
                                            <th>Name</th>
                                            <th>Mobile</th>
                                            <th>Intrested In</th>
                                             <th>Education</th>
                                            <th>Institute</th>
                                            <th>Year</th>
                                            <th>Address</th>
                                            <th>Email</th>
                                             <th>Status</th>
                                             <th>Remarks</th>
                                            <th>Contact</th>
                                             <th>Update</th>
                                           
                                            
                                        </tr>
                                    </thead>
                                    
                                
                                    <tbody>
                                        <?php
                                        require "conn.php";
                                        $v_code = $_SESSION['v_code'];
                                        $sl = 1;
                                        $sql = "select * from tbl_customer where v_code='$v_code' and deleted_at is NULL";
                                        //   $sql = "select distinct tbl_customer.id, tbl_customer.name, tbl_customer.mobile, tbl_customer.intrested_in, tbl_customer.remarks, tbl_follow_up.status, tbl_follow_up.next_date  from tbl_customer left join tbl_follow_up on tbl_customer.id = tbl_follow_up.lead_id  where tbl_customer.v_code='$v_code' and tbl_customer.deleted_at is NULL order by tbl_customer.id desc";
                                        $rs = mysqli_query($conn, $sql);
                                        while ($row = mysqli_fetch_assoc($rs)) {
                                            echo "<tr>";
                                            // echo '<td>'. $sl .'</td>';
                                            echo '<td>'. $row['name'] .' ('.$row['education'].') - '.$row['passing_year'].'<br> Ph- '.$row['mobile'].'<br>'.$row['status'].'</td>';
                                            echo '<td>' . $row['mobile'] . '</td>';
                                            echo '<td>' . $row['intrested_in'] . '</td>';
                                            echo '<td>' . $row['education'] . '</td>'; 
                                            echo '<td>' . $row['institute_name'] . '</td>';
                                            echo '<td>' . $row['passing_year'] . '</td>'; 
                                            echo '<td>' . $row['address'] . '</td>'; 
                                            echo '<td>' . $row['email'] . '</td>'; 
                                            echo '<td>' . $row['status'] . '</td>'; 
                                            echo '<td>' . $row['remarks'] . '</td>'; 
                                            echo '<td> 
                                            <a href="tel:'. $row['mobile'] . '"><button class="button-33" role="button" style=" background-color:black; color:white;"><i class="bi bi-telephone-fill"></i> </button></a>
                                            <a href="https://wa.me/' ."91".$row['mobile'] . '?text=Hii"><button class="button-33" role="button" style="background-color:#48ca50; color:white;"><i class="bi bi-whatsapp"></i> </button></a> 
                                            <a href="sms:'. $row['mobile'] . '?&body=Hii"><button class="button-33" role="button" style="background-color:#2091eb; color:white;" ><i class="bi bi-envelope-fill"></i> </button></a>
                                             <button class="button-33" id="'. $row['id'] .'" onclick="getId(this.id)"  style="background-color:#FFD203; color:black" data-toggle="modal" data-target="#exampleModal">Follow Up</button>
                                              </td>';

                                            echo '<td><a href="update-leads.php?id='.base64_encode($row['id']).'" class="btn " style="background-color:#428bca; color:white;"><i class="bi bi-pencil"></i></a></td>';
                                            //  <button id=' . $row['id'] . ' class="btn btn-danger delete"><i class="bi bi-trash"></i></button>
                                            echo "</tr>";
                                            $sl++;
                                        }
                                        ?>

                                    </tbody>
                                </table>
                                
                                
    <!--follow Up-->
    
   
                                
                                
                            </div>
                        </div>
                    </div>
                </div>

            </section>
            </section>

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

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


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

<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.4/js/dataTables.bootstrap5.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.4.1/js/dataTables.responsive.min.js" ></script>

<script>
  $(document).ready(function() {
      $('#example').DataTable();
  } );
    </script>
    
  


</body>

</html>