<?php
require('header.php');
include "dbconfig.php";
$link =opencon();
$team_manager_session=$_SESSION['team_manager'];

?>

<div class="breadcome-area mg-b-30 small-dn">
                <div class="container-fluid">
                    <div class="row">

                                                
                        <div class="col-lg-12">
                            <div class="breadcome-list shadow-reset">
                                <div class="row">
                             <div class="col-lg-12">
                                 <!--<h4 style="text-align: center;font-size: 26px;background-color: antiquewhite;height: 36px;margin-top: -20px;">Search</h4>-->
                                  </div>
                               </div>
                                
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- Breadcome End-->
          
         
            <!-- stockprice, feed area end-->
            <div class="admin-dashone-data-table-area mg-b-15">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="sparkline8-list shadow-reset">
                                <div class="sparkline8-hd">
                                    <div class="main-sparkline8-hd">
                                        <h1>Lead List</h1>
                                        <div class="sparkline8-outline-icon">
                                            <span class="sparkline8-collapse-link"><i class="fa fa-chevron-up"></i></span>
                                            <span><i class="fa fa-wrench"></i></span>
                                            <span class="sparkline8-collapse-close"><i class="fa fa-times"></i></span>
                                        </div>
                                    </div>
                                </div>
                       <?php


$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'hrdant7r_market';
$DATABASE_PASS = 'gAw=6Y79}FDN';
$DATABASE_NAME = 'hrdant7r_market';
// Try and connect using the info above.
$conn = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);

if(isset($_POST['savewillpay']))
{
        
        
       

		$filenos=$_POST['fileno'];
		
		$date=date("Y-m-d");
		
		$count=count($_POST['fileno']);
		for($i=0;$i<$count;$i++)
		{
		   $fileno=$filenos[$i];
		
		$v1 = $fileno;
        $v2 = $_POST['willpay'];
       $v3 = $_POST['assign_date'];
        
			 
$sql="UPDATE final_leads_education SET assigned_to='$v2',assigned_date='$v3' WHERE id='$v1' and status=''";


 mysqli_query($conn,$sql);

if($i==($count-1))
{
    echo "<script>alert('Assigned success')</script>";
}



		}
	


}
if(isset($_POST['lead_update']))
{
        
        
       
       $client_status =$_POST['client_status'];
$call_status =$_POST['call_status'];
$lead_status =$_POST['lead_status'];
$status_date=date("Y-m-d");

		$filenos=$_POST['fileno'];
		
		$date=date("Y-m-d");
		
		$count=count($_POST['fileno']);
		for($i=0;$i<$count;$i++)
		{
		   $fileno=$filenos[$i];
		
		$v1 = $fileno;

$sql="UPDATE `final_leads_education` SET `client_status`='$client_status',call_status='$call_status',status='$lead_status',status_date='$status_date',remarks='$remarks' WHERE `id`='$v1'";


 mysqli_query($conn,$sql);

if($i==($count-1))
{

    echo "<script>alert('Updated success')</script>";
}



		}
	


}
?>             
                                
                                
                             <?php
                             
                             
                             
if($_SESSION['team_manager']=='Admin' && isset($_GET['assign']))
{
    ?>
    
    
     <div class="sparkline12-graph">
                                    <div class="basic-login-form-ad">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <div class="all-form-element-inner">
                                      
                                                        <div class="form-group-inner">
                                                            <div class="row">
                                                                <div class="col-lg-3">
                                                                    <label class="login2 pull-right pull-right-pro">Assigned To</label>
                                                                </div>
                                                                <div class="col-lg-4">
                                                                    
                                                  <select type="text" class="form-control" name="staffname" id="convert_telecaller" onchange="setvalue(this.value,'savewillpayvalue')">
                                                                          <option value="" >Select </option>
                                                                        <option value="ROSHNI MOHAMED NAZEER">ROSHNI MOHAMED NAZEER</option>
                                                                        <option value="RAJESWARI SHANTHAKUMAR">RAJESWARI SHANTHAKUMAR</option>
                                                                        
                                                                    </select>                    
                                                                    
                                                                   
                                                                </div>
                                                            </div>
                                                        </div>
                                                          <div class="form-group-inner">
                                                            <div class="row">
                                                                <div class="col-lg-3">
                                                                    <label class="login2 pull-right pull-right-pro">Assigned Date</label>
                                                                </div>
                                                                <div class="col-lg-4">
                                                                    
                                                  <input type="date" class="form-control" name="assign_date" id="assign_date" onchange="setvalue(this.value,'savewillpayvalue1')">
                                                                          
                                                                    
                                                                   
                                                                </div>
                                                            </div>
                                                        </div>
                                                                                                              
														
                                                        <div class="form-group-inner">
                                                            <div class="login-btn-inner">
                                                                <div class="row">
                                                                    <div class="col-lg-3"></div>
                                                                    <div class="col-lg-9">
                                                                        <div class="login-horizental cancel-wp pull-left">
                                        <button class="btn btn-sm btn-primary login-submit-cs"  onclick="trigfunction('savewillpay')">Assign</button>
                                        
                                       
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                             
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
    
    
    <?php
}
?>

<div class="sparkline12-graph">
                                    <div class="basic-login-form-ad">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <div class="all-form-element-inner">
                                      
                                                        <div class="form-group-inner">
                                                            <div class="row">
                                                                <div class="col-lg-3">
                                                                    <label class="login2 pull-right pull-right-pro"> Connected / Not Connected</label>
                                                                </div>
                                                                <div class="col-lg-4">
                                                                    
                                                 <select name='call_status' class='form-control call_status<?=$count1;?> ' onchange="setvalue(this.value,'call_status')" style='width: 167px;'>
                         <?php
                         if($row["call_status"]!='')
                         {
                         ?>
                         
                         <option value="<?=$row["call_status"];?>"><?=$row["call_status"];?></option>
                         
                         <?php
                         }
                         ?>
 
<option value="Not connected">Not connected</option>
<option value="Connected">Connected</option>




</select>               
                                                                    
                                                                   
                                                                </div>
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group-inner">
                                                            <div class="row">
                                                                <div class="col-lg-3">
                                                                    <label class="login2 pull-right pull-right-pro">Interested / Not Interested</label>
                                                                </div>
                                                                <div class="col-lg-4">
                                              <select name='lead_status' class='form-control query_status<?=$count1;?> ' style='width: 167px;' onchange="setvalue(this.value,'client_status')">
                         <?php
                         if($row["client_status"]!='')
                         {
                         ?>
                         
                         <option value="<?=$row["client_status"];?>"><?=$row["client_status"];?></option>
                         
                         <?php
                         }
                         ?>

<option value="">Select</option>

<option value="Interested">Interested</option>


<option value="Not Interested">Not Interested</option>

</select>          
                   </div>
                                                            </div>
                                                        </div>
                  
                  
                  <div class="form-group-inner">
                                                            <div class="row">
                                                                <div class="col-lg-3">
                                                                    <label class="login2 pull-right pull-right-pro">Lead Status</label>
                                                                </div>
                                                                <div class="col-lg-4">
                   <select name='query_status' class='form-control lead_status<?=$count1;?> ' style='width: 167px;' onchange="setvalue(this.value,'lead_status')">
                         <?php
                         if($row["status"]!='')
                         {
                         ?>
                         
                         <option value="<?=$row["status"];?>"><?=$row["status"];?></option>
                         
                         <?php
                         }
                         ?>

<option value="">Select</option>
<option value="ELIGIBILITY COMPLETED">ELIGIBILITY COMPLETED</option>            
<option value="ADMISSION COMPLETED">ADMISSION COMPLETED</option>
<option value="SURE PIPELINE">SURE PIPELINE</option>
<option value="UNDER PROJECTION">UNDER PROJECTION</option>
<option value="HIGH FEES">HIGH FEES</option>
<option value="COURSE NOT AVAILABLE">COURSE NOT AVAILABLE</option>
<option value="UNIVERSITY NOT AVAILABLE">UNIVERSITY NOT AVAILABLE</option>
<option value="STUDENT NOT ELIGIBLE">STUDENT NOT ELIGIBLE</option>

</select>  

 </div>
                                                            </div>
                                                        </div>
                                                       
                                                                                                              
														
                                                        <div class="form-group-inner">
                                                            <div class="login-btn-inner">
                                                                <div class="row">
                                                                    <div class="col-lg-3"></div>
                                                                    <div class="col-lg-9">
                                                                        <div class="login-horizental cancel-wp pull-left">
                                        <button class="btn btn-sm btn-primary login-submit-cs"  onclick="trigfunction('lead_update')">Update</button>
                                        
                                       
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                             
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
    
  <form method="post">
                                <div class="sparkline13-graph">
                                    <div class="datatable-dashv1-list custom-datatable-overright">
                                        <?php if($_SESSION['roll']=='1'){ ?>  
                                        <div id="toolbar">
                                            <select class="form-control">
                                                <option value="">Export Basic</option>
                                                <option value="all">Export All</option>
                                                <option value="selected">Export Selected</option>
                                            </select>
                                        </div>
                                       <?php } ?>  
                                        
<table id="table" data-toggle="table" data-pagination="true"  data-search="true"  <?php if($_SESSION['roll']=='1'){ ?>data-show-columns="true" data-show-pagination-switch="true" data-show-refresh="true" data-key-events="true" data-show-toggle="false" data-resizable="true" data-cookie="true" data-cookie-id-table="saveId" data-show-export="true" data-click-to-select="true" data-toolbar="#toolbar"  <?php } ?>>
                                            <thead>
                                                <tr>
                                                      <th><input type='checkbox' id='checkAll' style="margin-top: 2px" onclick="checkall(this)">CHECK ALL</th>
                                                       
                                                       
                                                    <th>S.No</th>
                                                   
                                               <th>Status</th>
                                                <th>Student Name</th>
                                                   <th>Mobile Number</th>

                                                <th>Alternate Number</th>
                                                <th>Email</th>
                                                <th>Location</th>
                                                <th>Qualification</th>
                                                <th>Applied Course</th>
                                                <th>Date of Birth</th>
                                             
                                               <th>Assigned To</th>
                                               <th>Assigned Date</th>

                                      
                                       <th>Status Updated Date</th>
                                   
                                            
                                                </tr>
                                            </thead>
                                            <tbody>
                                               <?php

$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'hrdant7r_market';
$DATABASE_PASS = 'gAw=6Y79}FDN';
$DATABASE_NAME = 'hrdant7r_market';
// Try and connect using the info above.
$conn = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}




if(isset($_GET['session']))
{
    $session=$_GET['session'];


$sql107=explode("[]",$_SESSION[$session]);

// print_r($sql107);
$count=count($sql107);

$prabuinc=0;
$i=0;
$count1=1;
while($prabuinc < $count)
{
    $sql1=$sql107[$prabuinc];
    

 $result = $conn->query($sql1);
if ($result->num_rows > 0) {

while($row = $result->fetch_assoc()) {
    
    
$fileno=$row["fileno"];
$mainid=$row["id"];
echo "<tr>


<td>
<input type='checkbox' class='check-input' name='fileno[]' value='".$row["id"]."'>

</td>

<td>".$count1."</td>";
?>

<td>
    
    <select name='call_status' class='form-control call_status<?=$count1;?> ' style='width: 167px;'>
                         <?php
                         if($row["call_status"]!='')
                         {
                         ?>
                         
                         <option value="<?=$row["call_status"];?>"><?=$row["call_status"];?></option>
                         
                         <?php
                         }
                         ?>
 
<option value="Not connected">Not connected</option>
<option value="Connected">Connected</option>




</select>
<br>
    
    <select name='lead_status' class='form-control query_status<?=$count1;?> ' style='width: 167px;' onchange="statuschange(this,<?=$count1;?>)">
                         <?php
                         if($row["client_status"]!='')
                         {
                         ?>
                         
                         <option value="<?=$row["client_status"];?>"><?=$row["client_status"];?></option>
                         
                         <?php
                         }
                         ?>

<option value="">Select</option>

<option value="Interested">Interested</option>


<option value="Not Interested">Not Interested</option>

</select>
<br>
  <select name='query_status' class='form-control lead_status<?=$count1;?> ' style='width: 167px;'>
                         <?php
                         if($row["status"]!='')
                         {
                         ?>
                         
                         <option value="<?=$row["status"];?>"><?=$row["status"];?></option>
                         
                         <?php
                         }
                         ?>

<option value="">Select</option>
<option value="ELIGIBILITY COMPLETED">ELIGIBILITY COMPLETED</option>            
<option value="ADMISSION COMPLETED">ADMISSION COMPLETED</option>
<option value="SURE PIPELINE">SURE PIPELINE</option>
<option value="UNDER PROJECTION">UNDER PROJECTION</option>
<option value="HIGH FEES">HIGH FEES</option>
<option value="COURSE NOT AVAILABLE">COURSE NOT AVAILABLE</option>
<option value="UNIVERSITY NOT AVAILABLE">UNIVERSITY NOT AVAILABLE</option>
<option value="STUDENT NOT ELIGIBLE">STUDENT NOT ELIGIBLE</option>

</select>
<br>
<textarea class='form-control remarks<?=$count1;?> '><?=$row["remarks"];?></textarea>

<button type="button" id='basicSuccessAnimation' class='btn btn-success query_statusubmit$i'  onclick=submitapproval_call1('<?=$mainid;?>',this,<?=$count1;?>)  style='margin-top: 10%;'>submit</button>
</td>

<?php
echo "<td>".$row["student_name"]."</td>
<td>".$row["mobilenumber"]."</td>
<td>".$row["alternate_number"]."</td>
<td>".$row["email"]."</td>
<td>".$row["location"]."</td>
<td>".$row["qualification"]."</td>
<td>".$row["course_applied"]."</td>
<td>".$row["dob"]."</td>
<td>".$row["assigned_to"]."</td>
<td>".$row["assigned_date"]."</td>";
$count1++;



echo "<td>".$row["status_date"]."</td>



</tr>";
}

}
$prabuinc++;
}


}

?>
                                            </tbody>
                                        </table>
                                        <?php //echo $links; ?>
                                    </div>
                                </div>
                                
                                 <input type="text" name="willpay" id="savewillpayvalue"    style='display:none'>
                                 <input type="date" name="assign_date" id="savewillpayvalue1"    style='display:none'>
                                <button type="submit" name="savewillpay" id="savewillpay"  style='display:none'>submit</button>
                                
                                
                                 <input type="text" name="call_status" id="call_status" value="Not Connected"   style='display:none'>
                                 <input type="text" name="client_status" id="client_status"    style='display:none'>
                                 <input type="text" name="lead_status" id="lead_status"    style='display:none'>
                                <button type="submit" name="lead_update" id="lead_update"  style='display:none'>submit</button>
                                
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <script>
                
 function submitapproval_call1(id,x,y)
  {
      
    
      
      var call_status=document.getElementsByClassName("call_status"+y)[0].value;
      var lead_status=document.getElementsByClassName("lead_status"+y)[0].value;
      var stu_calls=document.getElementsByClassName("query_status"+y)[0].value;
    var remarks=document.getElementsByClassName("remarks"+y)[0].value;
    
     if(call_status!='')
     {
           x.innerHTML="Please Wait...";
         var data2 = new FormData();
        
        data2.append("client_status",stu_calls);
        data2.append("call_status",call_status);
        data2.append("lead_status",lead_status);
        data2.append("remarks",remarks);
       

        data2.append("lead_id",id);
        
    const xhttp = new XMLHttpRequest();
    xhttp.onload = function() {
        
      alert(this.responseText);
        x.innerHTML = "Submit";
        
            }
   
  xhttp.open("POST", "lead_status_update.php");
  xhttp.send(data2);
  
  
     }
     else
     {
         alert("Fields Are Required");
     }
     

 
   
   
  }
  
            </script>
<?php
require('footer.php');
?>