<?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>Follow Ups</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>
        $(document).ready(function() {

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

                var v_code = $("#v_code").val();
                var date = $("#date").val();
                var comments = $("#comments").val();
                var status = $("#status").val();
                
         
              
                $.ajax({
                    type: 'post',
                    url: 'followuoup-action.php',
                    data: {

                        'v_code': v_code,
                        'date': date,
                        'comments': comments,
                        'status': status,
                    },


                    success: function(data) {
                        alert(data);
                        $("#BtnSubmit").html("Save");
                        window.location.href = 'leads-list.php';

                      
                    }

                });



            });


        });
        
        
//         $(document).ready( function() {
//   $('#example').dataTable( {
//     "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
//       if ( aData[4] == "Follow Up" )
//       {
//         $('td', nRow).css('background-color', '#59FD1A' );
//       }
//       else if ( aData[4] == "Contact Later" )
//       {
//         $('td', nRow).css('background-color', '	#59FD1A');
//       }
//       else if ( aData[4] == "Admission Confirmed" )
//       {
//         $('td', nRow).css('background-color', '#59FD1A');
//       }
//       else
//       {
//         $('td', nRow).css('background-color', '#FF3434');
//       }
//     }
//   } );
// } );
        
        
    </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>Follow Ups</h1>
           
           
        </div><!-- End Page Title -->

     
          


            <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">Today's Follow Ups</h5>
                                <!-- Table with stripped rows -->
                             <table id="example" class="table table-striped dt-responsive nowrap" style="width:100%">

                                    <thead>
                                        <tr>
                                            <!--<th>Next Date</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>Comments</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 order by id asc";
                                          $sql = "select distinct tbl_customer.id, tbl_customer.name, tbl_customer.mobile, tbl_customer.intrested_in,tbl_customer.education,tbl_customer.institute_name,tbl_customer.passing_year,tbl_customer.address,tbl_customer.email,tbl_customer.remarks, tbl_follow_up.status, tbl_follow_up.next_date,tbl_follow_up.comments  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 and tbl_follow_up.next_date=CURDATE() and tbl_follow_up.next_date=(SELECT MAX(next_date) FROM tbl_follow_up where tbl_customer.id = tbl_follow_up.lead_id)  order by tbl_customer.id desc";
                                        $rs = mysqli_query($conn, $sql);
                                        while ($row = mysqli_fetch_assoc($rs)) {
                                            echo "<tr>";
                                            
                                            // echo '<td>'. $row['next_date'] .'</td>';
                                             echo '<td>'. $row['name'] .'(Follow up on-'. $row['next_date'] .')</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['comments'] . '</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>
                                            
                                            <a href="activity.php?id=' . base64_encode($row['id']) . '"><button class="button-33" role="button" style="background-color:#FFD203; color:black">Follow Up</button></a>

                                            </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>
                            </div>
                        </div>
                    </div>
                </div>

            </section>
            
             <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">7 days Follow Ups</h5>
                                <!-- Table with stripped rows -->
                             <table id="example1" class="table table-striped dt-responsive nowrap" style="width:100%">

                                    <thead>
                                        <tr>
                                            <!--<th>Next Date</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>Comments</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 order by id asc";
                                          $sql = "select distinct tbl_customer.id, tbl_customer.name, tbl_customer.mobile, tbl_customer.intrested_in,tbl_customer.education,tbl_customer.institute_name,tbl_customer.passing_year,tbl_customer.address,tbl_customer.email,tbl_customer.remarks, tbl_follow_up.status, tbl_follow_up.next_date,tbl_follow_up.comments  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 and tbl_follow_up.next_date BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 7 DAY) and tbl_follow_up.next_date=(SELECT MAX(next_date) FROM tbl_follow_up where tbl_customer.id = tbl_follow_up.lead_id)  order by tbl_customer.id desc";
                                        $rs = mysqli_query($conn, $sql);
                                        while ($row = mysqli_fetch_assoc($rs)) {
                                            echo "<tr>";
                                            
                                            // echo '<td>'. $row['next_date'] .'</td>';
                                            echo '<td>'. $row['name'] .'(Follow up on- '. $row['next_date'] .')</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['comments'] . '</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>
                                            
                                            <a href="activity.php?id=' . base64_encode($row['id']) . '"><button class="button-33" role="button" style="background-color:#FFD203; color:black">Follow Up</button></a>

                                            </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>
                            </div>
                        </div>
                    </div>
                </div>

            </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();
      $('#example1').DataTable();
  } );
  </script>

</body>

</html>