<?php
include "header.php";
?>
<!-- Main Working Space Start -->
<div class="col-md-12 mt-4">
<div style="">
        <div class="card mt-2" style="">
        <div class="col-md-12 card-header ">
            <div class="row">
              <div class="col-md-3 ">
                <h4 class=""><b>Projection List</b></h4>
              </div>
              <div class="col-md-6">
                <nav style="--bs-breadcrumb-divider: url(&#34;data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='%236c757d'/%3E%3C/svg%3E&#34;);" aria-label="breadcrumb">
                    <ol class="breadcrumb mt-2">
                        <li class="breadcrumb-item"><a href="index.php">Projection</a></li>
                        <li class="breadcrumb-item active" aria-current="page">Projection List</li>
                    </ol>
                </nav>
              </div>
            </div>
        </div>
            <div class="card-body">
              <form action="" method="post">
              <div class="col-md-12">
                <div class="row">
                  <div class="col-md-4">
                    <label for="">From Date</label>
                    <input type="date" id="search1" name="from" class="form-control">
                  </div>
                  <div class="col-md-4">
                    <label for="">To Date</label>
                    <input type="date" id="search2" name="to" class="form-control">
                  </div>
                  <div class="col-md-4">
                  <label for="">Lead Status</label>
                    <select name="status" id="lead_status" class="form-select">
                      <option value="NULL">--Select--</option>
                      <option value="Contacted">Contacted</option>
                      <option value="Not Contacted">Not Contacted</option>
                      <!-- <option value="Projection">Projection</option> -->
                      <!-- <option value="Not Interested">Not Interested</option> -->
                      <!-- <option value="Converted">Converted</option> -->
                    </select>
                  </div>
                </div>
              </div>
              <div class="col-md-12 mt-4">
                <div class="row">
                  <div class="col-md-4">
                    <label for="">Team Manager</label>
                    <select name="manager" autocomplete="off" id="manager" class="form-select">
                    <option value="">--Select--</option>
                      <option value="AKILA">AKILA</option>
                    </select>
                  </div>
                  <div class="col-md-4">
                    <label for="">Team Leader</label>
                    <select name="leader"  autocomplete="off"  id="ddl1" onchange="configureDropDownLists(this, document.getElementById('ddl2'))"  class="form-select">
                        <option value="">--Select--</option>
                        <option value="BAKIYALAKSHMI">BAKIYALAKSHMI</option>    
                        <option value="VIJAYAKUMARI">VIJAYAKUMARI</option>    
                </select>
                  </div>
                  <div class="col-md-3">
                    <label for="">Tele Caller</label>
                    <select name="telecaller"  autocomplete="off"  id="ddl2" class="form-select">                    
                    </select>

                  </div>
                  <div class="col-md-1">
                    <button class="btn btn-warning btn-sm" name="btn" type="submit" style="margin-top: 20px;"><span class="material-symbols-outlined">search</span></button>
                  </div>
                </div>
              </div>
              </form>
            </div>
        </div>
        <div class="col-md-12">
            <div class="row">
            <div class="col-md-6">
            <div class="card my-4">
                <div class="row">
                    <div class="card-header">
                        <div class="row">
                            <div class="col-md-6">
                                <h5 class="ms-2"><b>Assigned Leads</b></h5>
                            </div>
                            <div class="col-md-6">
<?php 
include "dbconfig.php";
$link = opencon();
$sql1 = "SELECT COUNT(Name) as assigned FROM new_lead  WHERE Team_Manager!=''";
$sql1_exe = mysqli_query($link,$sql1);
while($fetch1_qr = mysqli_fetch_array($sql1_exe)){
?>
                                <span style="float: right;"><b><?php echo $fetch1_qr['assigned']; }?></b>&nbsp;&nbsp;&nbsp;&nbsp;</span>
                            </div>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="col-md-12">
                            <div class="row">
<?php 
$sql2 = "SELECT COUNT(Name) as pipeline FROM new_lead  WHERE Lead_Status='Pipeline'";
$sql2_exe = mysqli_query($link,$sql2);
while($fetch2_qr = mysqli_fetch_array($sql2_exe)){
?>
                                <div class="col-md-4"><center><span style="color: green;"><b><?php echo $fetch2_qr['pipeline']; }?></b></span></center><center><span>Pipeline</span></center></div>
<?php 
$sql3 = "SELECT COUNT(Name) as spipeline FROM new_lead  WHERE Lead_Status='Sure Pipeline'";
$sql3_exe = mysqli_query($link,$sql3);
while($fetch3_qr = mysqli_fetch_array($sql3_exe)){
?>
                                <div class="col-md-4"><center><span style="color: orange;"><b><?php echo $fetch3_qr['spipeline']; }?></b></span></center><center><span>Sure Pipeline</span></center></div>
<?php 
$sql4 = "SELECT COUNT(Name) as projection FROM new_lead  WHERE Lead_Status='Projected'";
$sql4_exe = mysqli_query($link,$sql4);
while($fetch4_qr = mysqli_fetch_array($sql4_exe)){
?>
                                <div class="col-md-4"><center><span style="color: blue;"><b><?php echo $fetch4_qr['projection']; }?></b></span></center><center><span>Projection</span></center></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card mt-4">
                <div class="row">
                    <div class="card-header">
                        <div class="row">
                            <div class="col-md-6">
                                <h5 class="ms-2"><b>Direct Visit Leads</b></h5>
                            </div>
                            <div class="col-md-6">
<?php
$sql5 = "SELECT COUNT(Name) AS visited FROM new_lead WHERE Lead_Source='direct Visit'";
$sql5_exe = mysqli_query($link,$sql5);
while($fetch5_qr = mysqli_fetch_array($sql5_exe)){
?>
                                <span style="float: right;"><b><?php echo $fetch5_qr['visited']; }?></b>&nbsp;&nbsp;&nbsp;&nbsp;</span>
                            </div>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="col-md-12">
                            <div class="row">
<?php
$sql5 = "SELECT COUNT(Name) AS pipeline FROM new_lead WHERE Lead_Source='direct Visit' AND Lead_Status='Pipeline'";
$sql5_exe = mysqli_query($link,$sql5);
while($fetch5_qr = mysqli_fetch_array($sql5_exe)){
?>
                                <div class="col-md-4"><center><span style="color: green;"><b><?php echo $fetch5_qr['pipeline']; }?></b></span></center><center><span>Pipeline</span></center></div>
<?php
$sql5 = "SELECT COUNT(Name) AS spipeline FROM new_lead WHERE Lead_Source='direct Visit' AND Lead_Status='Sure Pipeline'";
$sql5_exe = mysqli_query($link,$sql5);
while($fetch5_qr = mysqli_fetch_array($sql5_exe)){
?>     
                                <div class="col-md-4"><center><span style="color: orange;"><b><?php echo $fetch5_qr['spipeline']; }?></b></span></center><center><span>Sure Pipeline</span></center></div>
<?php
$sql5 = "SELECT COUNT(Name) AS projection FROM new_lead WHERE Lead_Source='direct Visit' AND Lead_Status='Projected'";
$sql5_exe = mysqli_query($link,$sql5);
while($fetch5_qr = mysqli_fetch_array($sql5_exe)){
?> 
                                <div class="col-md-4"><center><span style="color: blue;"><b><?php echo $fetch5_qr['projection']; }?> </b></span></center><center><span>Projection</span></center></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-12 ">
          <div class="row">
            <div class="col-md-4">
              <div class="card">
                <h5 class="card-header">Team Manager Wise Leads</h5>
                <div class="card-body">
                  <table class="table table-striped">
                    <thead>
                      <tr>
                        <th>Team Manager</th>
                        <th>Assg.</th>
                        <th>PL</th>
                        <th>SPL</th>
                        <th>Proj.</th>
                      </tr>
                    </thead>
                    <tbody>
<?php
// $sql6="SELECT DISTINCT(Team_Manager) FROM new_lead WHERE Team_Manager!=''";
// $sql6_exe = mysqli_query($link,$sql6);
// while($fetch6_qr = mysqli_fetch_array($sql6_exe)){
  // $manager = $fetch6_qr['Team_Manager'];
?>

                      <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                      </tr>
<?php
// }
?>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
            <div class="col-md-4">
              <div class="card">
                <h5 class="card-header">Team Leader Wise Leads</h5>
                <div class="card-body">
                  <table class="table table-striped">
                    <thead>
                      <tr>
                        <th>Team Manager</th>
                        <th>Assg.</th>
                        <th>PL</th>
                        <th>SPL</th>
                        <th>Proj.</th>
                      </tr>
                    </thead>
                    <tbody>
<!-- -->

                      <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
            <div class="col-md-4">
              <div class="card">
                <h5 class="card-header">TeleCaller Wise Leads</h5>
                <div class="card-body">
                  <table class="table table-striped">
                    <thead>
                      <tr>
                        <th>Team Manager</th>
                        <th>Assg.</th>
                        <th>PL</th>
                        <th>SPL</th>
                        <th>Proj.</th>
                      </tr>
                    </thead>
                    <tbody>


                      <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
            </div>
        </div>
      </div>   
<!-- </div> -->
          <!-- </div> -->
<!-- </div> -->
</div>
<!-- Main Working Space End -->
<!-- Live name Search Start -->
<script>
  $(document).ready(function(){
    $("#search").keyup(function(){
      var a1=$(this).val();
      $('table tbody tr').hide();
      var len =$('table tbody tr:not(.notfound) td:nth-child(3):contains("'+a1+'")').length;
      if(len>0){
        $('table tbody tr:not(.notfound) td:contains("'+a1+'")').each(function(){
          $(this).closest('tr').show();
        });
      }else{
        $('.notfound').show();
      }
      // alert("working");
    });
  });
</script>
    <!-- Live Search End -->
    <!-- Changing dropdown Start -->
    <script type="text/javascript">
    function configureDropDownLists(ddl1,ddl2) {
    var BAKIYALAKSHMI = ['PRADEEPRAJA', 'RAMAPRABA.G','YOKESH.M','SURUTHIKA'];
    var VIJAYAKUMARI = ['ANI JOLLA', 'MANIVEL.S','POONGODI M'];
    var bleads = ['select', 'NA'];
    // var names = ['John', 'David', 'Sarah'];

    switch (ddl1.value) {
        case 'BAKIYALAKSHMI':
            ddl2.options.length = 0;
            for (i = 0; i < BAKIYALAKSHMI.length; i++) {
                createOption(ddl2, BAKIYALAKSHMI[i], BAKIYALAKSHMI[i]);
            }
            break;
        case 'VIJAYAKUMARI':
            ddl2.options.length = 0; 
            for (i = 0; i < VIJAYAKUMARI.length; i++) {
            createOption(ddl2, VIJAYAKUMARI[i], VIJAYAKUMARI[i]);
            }
            break;
        case 'bleads':
            ddl2.options.length = 0; 
            for (i = 0; i < bleads.length; i++) {
            createOption(ddl2, bleads[i], bleads[i]);
            }
            break;
    }

}

    function createOption(ddl, text, value) {
        var opt = document.createElement('option');
        opt.value = value;
        opt.text = text;
        ddl.options.add(opt);
    }
</script>
    <!-- Changing dropdown END -->


<script>
  $(document).ready(function(){
    $("#lead_status").click(function(){
      var a1=$(this).val();
      $('table tbody tr').hide();
      var len =$('table tbody tr:not(.notfound) td:nth-child(6):contains("'+a1+'")').length;
      if(len>0){
        $('table tbody tr:not(.notfound) td:contains("'+a1+'")').each(function(){
          $(this).closest('tr').show();
        });
      }else{
        $('.notfound').show();
      }
      // alert("working");
    });
  });
</script>
<script>
  $(document).ready(function(){
    $("#manager").click(function(){
      var a1=$(this).val();
      $('table tbody tr').hide();
      var len =$('table tbody tr:not(.notfound) td:nth-child(7):contains("'+a1+'")').length;
      if(len>0){
        $('table tbody tr:not(.notfound) td:contains("'+a1+'")').each(function(){
          $(this).closest('tr').show();
        });
      }else{
        $('.notfound').show();
      }
      // alert("working");
    });
  });
</script>
<script>
  $(document).ready(function(){
    $("#ddl1").click(function(){
      var a1=$(this).val();
      $('table tbody tr').hide();
      var len =$('table tbody tr:not(.notfound) td:nth-child(8):contains("'+a1+'")').length;
      if(len>0){
        $('table tbody tr:not(.notfound) td:contains("'+a1+'")').each(function(){
          $(this).closest('tr').show();
        });
      }else{
        $('.notfound').show();
      }
      // alert("working");
    });
  });
</script>
<script>
  $(document).ready(function(){
    $("#ddl2").click(function(){
      var a1=$(this).val();
      $('table tbody tr').hide();
      var len =$('table tbody tr:not(.notfound) td:nth-child(9):contains("'+a1+'")').length;
      if(len>0){
        $('table tbody tr:not(.notfound) td:contains("'+a1+'")').each(function(){
          $(this).closest('tr').show();
        });
      }else{
        $('.notfound').show();
      }
      // alert("working");
    });
  });
</script>
<script>
  $(document).ready(function(){
    $("#search1").click(function(){
      var a1=$(this).val();
      $('table tbody tr').hide();
      var len =$('table tbody tr:not(.notfound) td:nth-child(2):contains("'+a1+'")').length;
      if(len>0){
        $('table tbody tr:not(.notfound) td:contains("'+a1+'")').each(function(){
          $(this).closest('tr').show();
        });
      }else{
        $('.notfound').show();
      }
      // alert("working");
    });
  });
</script>
        <!-- LIVE SEARCH END -->

<?php
include "footer.php";
?>