<?php
include("common/connection.php");
login_check();
?>
<!doctype html>
<html class="no-js" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Current Leads | Buurtzorg</title>
    <script>
	function delete_lead(per) 
	{
	  var response = confirm("Are You Sure to Delete Lead!");
	  if (response == true) 
	  {
		$.ajax({
		url:"ajax_delete_lead.php",
		type:"POST",
		data:{'per':per},
		success:function(data)
		{
 			//alert('Lead '+data+' Deleted Successfully');
		}
		});
	  } 
	  else 
	  {
		alert('Lead Not Deleted');
	  }
	}
	</script>
    <script>
	function update_callconnect(Status,Lead_Id)
	{
	 //alert(Status);
	 
	 $.ajax({
		url:"ajax_updatecall_lead.php",
		type:"POST",
		data:{'Status':Status,'Lead_Id':Lead_Id},
		success:function(data)
		{
		//alert(data)
			if(Status=='Call Connected')
			{
			
			  window.location.href='call_connected.php?Lid='+Lead_Id;
			}
			else
			{
			  window.location.href='current_leads.php';
			}
		}
		})
	}
	</script>
    <?php include("headerlink.php"); ?>
    <?php
		//---------user type check-------// 
	    $user_sql="select User_Type as type,Location from user_master where User_Name='".$_SESSION['user']."'";
		$user_query=mysqli_query($con,$user_sql);
		$user=mysqli_fetch_array($user_query);
		
		//---------all leads fetching by condition-------// 
		$all_leads_sql="select count(Lead_ID) as total_leads from lead_master where Active='Yes'";
		
		if($user['type']!='Super Admin' && $user['type']!='Co-Admin')
		{
		//$all_leads_sql.=" where Lead_Referred_To='".$_SESSION['user']."'";
		  $all_leads_sql.=" and Control_Location='".$user['Location']."'";
		}
		
		$all_leads_query=mysqli_query($con,$all_leads_sql);
		$all_leads=mysqli_fetch_array($all_leads_query);
		
		
		//---------fresh leads fetching by condition-------// 
		$fresh_leads_sql="select count(Lead_ID) as fresh_leads from lead_master where Status ='Yet to be Called' and Active='Yes'";
		
		if($user['type']!='Super Admin' && $user['type']!='Co-Admin')
		{
		//$fresh_leads_sql.=" and Lead_Referred_To='".$_SESSION['user']."'";
		   $fresh_leads_sql.=" and Control_Location='".$user['Location']."'";
		}
		
		$fresh_leads_query=mysqli_query($con,$fresh_leads_sql);
		$fresh_leads=mysqli_fetch_array($fresh_leads_query);
		
		//---------fresh leads fetching by condition-------// 
		$progress_leads_sql="select count(Lead_ID) as progress_leads from lead_master where Active='Yes' and (Status !='Yet to be Called' and Status !='')";
		
		if($user['type']!='Super Admin' && $user['type']!='Co-Admin')
		{
		//$progress_leads_sql.=" and Lead_Referred_To='".$_SESSION['user']."'";
		$progress_leads_sql.=" and Control_Location='".$user['Location']."'";
		}
		
		$progress_leads_query=mysqli_query($con,$progress_leads_sql);
		$progress_leads=mysqli_fetch_array($progress_leads_query);
		
		//---------today leads fetching by condition-------// 
		$today_leads_sql="select count(Lead_ID) as today_leads from communication_master where (Status !='Yet to be Called' and Status !='') and Date_Of_Communication LIKE'".date('Y-m-d')."%'";
		
		if($user['type']!='Super Admin' && $user['type']!='Co-Admin')
		{
		$today_leads_sql.=" and Communicator_ID='".$_SESSION['user']."'";
		}
		//echo $today_leads_sql;
		$today_leads_query=mysqli_query($con,$today_leads_sql);
		$today_leads=mysqli_fetch_array($today_leads_query);		
		?>
     	<link rel="stylesheet" href="css/data-table/bootstrap-table.css">
    	<link rel="stylesheet" href="css/data-table/bootstrap-editable.css">
        
        
        <style>
		table {overflow:inherit !important}
		table thead {overflow:inherit !important}
		table thead tr {overflow:inherit !important}
		
		table tbody {overflow:inherit !important}
		table tbody tr {overflow:inherit !important; }
		table tbody tr td {overflow:inherit !important}
		
		
		.fixed-table-body {overflow:inherit !important}
		.action_dropdown {padding:0 !important; min-width:460px !important;  left:-258px; background-color:rgba(0,0,0,0) !important;
		 box-shadow:none !important; border:none !important; margin-top:-70px}
										
		 .action_dropdown:after {
			  content:'';
			  width: 0;
			  height: 0;
			  border-left: 7px solid transparent;
			  border-right: 7px solid transparent;
			  border-top: 12px solid #337ab7;
			  margin-top:40px;
			  position:absolute;
			  top:-10px;
			  margin-left:-190px;
		}
		
		
		 .bgcolor_1 { background-color:#f2dede; color:#a94442 !important }
		 .bgcolor_2 { xbackground-color:white !important }
		 .bgcolor_3 { background-color:#dff0d8; color:#3c763d !important }
		 
		 
		 
		 
		 .main_txt{
		 float:left;
		 width:60%;
		 height:auto;
		 text-align:left;
		 font-size:15px;
		 color:#FFFFFF;
		 font-weight:600;
		 }
		 
		 .number_div{
		 float:left;
		 width:40%;
		 text-align:right;
		 color:#FFFFFF;
		 font-size:50px;
		 font-weight:600;
		 }
		 
		 .maindiv{
		 float:left;
		 width:100%;
		 height:90px;
		 padding:15px;
		 border-radius:5px;
		 }
		
		</style>
</head>

<body>
    <!--[if lt IE 8]>
		<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
	<![endif]-->
    <!-- Start Left menu area -->
    
    
    
    <?php include("left-menu.php"); ?>
    
    
    
    <!-- End Left menu area -->
    <!-- Start Welcome area -->
    <div class="all-content-wrapper">
        
        
       <?php include("header-menu.php"); ?> 
        
        
        <!-- Static Table Start -->
        <div class="static-table-area">
        
        <!--<div class="analytics-sparkle-area" style="margin-bottom:30px;">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
                        <div class="analytics-sparkle-line reso-mg-b-30">
                            <div class="analytics-content">
                                <h5>ALL LEADS</h5>
                                <h2><?php echo $all_leads['total_leads'];?></h2>
                               
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
                        <div class="analytics-sparkle-line reso-mg-b-30">
                            <div class="analytics-content">
                                <h5>FRESH LEADS</h5>
                                <h2><?php echo $fresh_leads['fresh_leads'];?></h2>
                               
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
                        <div class="analytics-sparkle-line reso-mg-b-30">
                            <div class="analytics-content">
                                <h5>IN-PROGRESS LEADS</h5>
                                <h2><?php echo $progress_leads['progress_leads'];?></h2>
                               
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
                        <div class="analytics-sparkle-line reso-mg-b-30">
                            <div class="analytics-content">
                                <h5>TODAY'S CALLS</h5>
                                <h2><?php echo $today_leads['today_leads'];?></h2>
                               
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>-->
        
        
        
            <div class="container-fluid">
                <div class="row">
                
                
                
                
                    
                    <div class="col-lg-12 col-md-6 col-sm-6 col-xs-12" >
                        <div class="sparkline9-list mt-b-30 res-mg-t-30 analysis-progrebar-ctn">
                        
                        <!--<div class="sparkline9-hd" style="margin-bottom:150px;">
                                <div class="main-sparkline9-hd">
                                    <h1>
                                    <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
                                    
                                    <div class="maindiv" style="background-color:#006a94;">
                                    <div class="main_txt" style="padding-top:22px;">ALL LEADS</div>
                                    <div class="number_div"><?php echo $all_leads['total_leads'];?></div>
                                    
                                    </div>
                                    
                        
                    </div>
                                    <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
                                    
                                    <div class="maindiv" style="background-color:#009aca;">
                                    <div class="main_txt" style="padding-top:22px;">FRESH LEADS</div>
                                    <div class="number_div"><?php echo $fresh_leads['fresh_leads'];?></div>
                                    
                                    </div>
                                    
                                    
                                    
                                    
                        
                    </div>
                                    <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
                                    
                           <div class="maindiv" style="background-color:#06acdc;">
                                    <div class="main_txt" style="padding-top:16px;">IN-PROGRESS LEADS</div>
                                    <div class="number_div"><?php echo $progress_leads['progress_leads'];?></div>
                                    
                                    </div>         
                                    
                                    
                        
                    </div>
                                    <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
                                    
                                    
                                    <div class="maindiv" style="background-color:#42c6dd;">
                                    <div class="main_txt" style="padding-top:22px;">TODAY'S CALLS</div>
                                    <div class="number_div"><?php echo $today_leads['today_leads'];?></div>
                                    
                                    </div>
                                    
                                    
                                    
                       
                    </div>
                    </h1>
                                </div>
                            </div>-->
                        
                        
                        
                            <div class="sparkline9-hd">
                                <div class="main-sparkline9-hd">
                                    <h1>Physio Invoice Report <!--<input class="btn btn-custon-rounded-three
                                    				btn-primary" type="button" value="ALL LEADS <?php echo $all_leads['total_leads'];?>" name="update_status" style="cursor:auto; margin-left:30px; font-weight:500;"></input>
                                                    
                                                    <input class="btn btn-custon-rounded-three
                                    				btn-primary" type="button" value="FRESH LEADS <?php echo $fresh_leads['fresh_leads'];?>" name="update_status" style="cursor:auto; margin-left:10px; font-weight:500;"></input>
                                                    
                                                     <input class="btn btn-custon-rounded-three
                                    				btn-primary" type="button" value="IN-PROGRESS LEADS <?php echo $progress_leads['progress_leads'];?>" name="update_status" style="cursor:auto; margin-left:10px; font-weight:500;"></input>
                                                    
                                                    <input class="btn btn-custon-rounded-three
                                    				btn-primary" type="button" value="TODAY'S CALLS <?php echo $today_leads['today_leads'];?>" name="update_status" style="cursor:auto; margin-left:10px; font-weight:500;"></input>
    </button>--></h1>
                                </div>
                            </div>
                            
                            
                            <div class="sparkline13-graph">
                                <div class="datatable-dashv1-list custom-datatable-overright">
                                    <div id="toolbar">
                                      
                                        
                                        
                                        
                                        <div class="form-group" style="width:600px;">
                                        <form action="#" method="post">
                                         <input name="From_Date" id="start" type="text" class="form-control" 
                                                      placeholder="From Date" style="margin-right:10px; width:100px; float:left;  margin-bottom:10px;" value="<?php echo $_REQUEST['From_Date'] ?>" autocomplete="off">
                                                      <input name="To_Date" id="finish" type="text" class="form-control" 
                                                      placeholder="To Date" style="width:100px; float:left;  margin-bottom:10px; margin-right:10px;" value="<?php echo $_REQUEST['To_Date'] ?>" autocomplete="off">
													  
													 
														 
														 
                                                      
                                                       <input type="submit" class="btn btn-custon-rounded-three
                                    				btn-primary" name="Lead_Search" value="Submit">
                                          </form>            
                                                   </div>
                                        
                                       
                                    </div>
                                    
                                    
 										

                                    <table id="table" data-toggle="table" data-pagination="true" data-search="true" data-show-columns="true" data-show-pagination-switch="true" data-show-refresh="false" 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" class="textcenter table-striped">
                                        <thead>
                                        
                                            <tr align="center">
                                                <!--<th data-field="state" data-checkbox="false"></th>-->
                                                <th  data-field="Lead ID" data-editable="false">Invoice_No.</th>
												<th  data-field="Creation Date" data-editable="false">Patient ID</th>
                                                <th data-field="Lead Name" data-editable="false"> Patient Name</th>
                                                <th data-field="Phone No" data-editable="false">Start Date</th>
                                               
                                                <th data-field="City Town" data-editable="false">End Date</th>
                                                <th data-field="Course Name" data-editable="false">No of Days</th>
												<th data-field="Course" data-editable="false">Rate/Day</th>
                                                
                                                
                                                <th data-field="Centre" data-editable="false">Total Amount</th> 
                                               
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
										
										$leads_table_sql="SELECT invoice_master.*, patient_agreement.Service_Type, patient_agreement.Patient_Name FROM invoice_master INNER JOIN patient_agreement ON invoice_master.Aggrement_Id=patient_agreement.SLN where patient_agreement.Service_Type = 6
";
										
										if($_REQUEST['From_Date']!='' && $_REQUEST['To_Date']!='')
										{
										    $leads_table_sql.=" and invoice_master.Start_Date>='".date('Y-m-d',strtotime($_REQUEST['From_Date']))."' and invoice_master.End_Date<='".date('Y-m-d',strtotime($_REQUEST['To_Date']))."'";
										
										}
										
										
										
										
										$leads_table_sql.=" order by invoice_master.SLN desc";
										echo $leads_table_sql;
									    $leads_table_query=mysqli_query($con,$leads_table_sql);
										$i=1;
										while($leads_datas=mysqli_fetch_array($leads_table_query))
										{
										 	//echo "select Service_Type from patient_agreement where SLN='".$leads_datas['Aggrement_Id']."'";
										 //	$check_nursing=mysqli_fetch_array($con,"select Service_Type from patient_agreement where SLN='".$leads_datas['Aggrement_Id']."'");
										 //	echo $check_nursing['Service_Type'];
										//	if($check_nursing['Service_Type']>6)
											
										//	{
										//	    echo $check_nursing['Service_Type'];
										 //   $patient=mysqli_fetch_array(mysqli_query($con,"select * from patient_master where Patient_Id='".$leads_datas['Patient_Id']."'"));									
										?>
                                        
                                            <tr style="background-color:xxred !important">
                                                
                                                <td ><?php echo $leads_datas['Invoice_No']; ?></td>
												<td ><?php echo $leads_datas['Patient_Id']; ?></td>
                                                <td><?php echo $leads_datas['Patient_Name']; ?></td>
                                                <td><?php echo date('d M, Y',strtotime($leads_datas['Start_Date'])); ?></td>
                                               
                                               <td><?php echo date('d M, Y',strtotime($leads_datas['End_Date'])); ?></td>
                                              
                                                
                                                <td><?php echo $leads_datas['Total_Days']; ?></td>
												<td><?php echo $leads_datas['Rate']; ?></td>
												<td><?php echo $leads_datas['Amount']; ?></td>
                                               
                                   
                                    
                               
                                            </tr>
                                          <?php
											}
										  //$i++;
										 // }
										  ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                
            </div>
        </div>
        <!-- Static Table End -->
        <div class="footer-copyright-area">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="footer-copy-right">
                            <p>Copyright © 2019. All rights reserved.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- jquery
		============================================ -->
    <script src="js/vendor/jquery-1.12.4.min.js"></script>
    <!-- bootstrap JS
		============================================ -->
    <script src="js/bootstrap.min.js"></script>
    <!-- wow JS
		============================================ -->
    <script src="js/wow.min.js"></script>
    <!-- price-slider JS
		============================================ -->
    <script src="js/jquery-price-slider.js"></script>
    <!-- meanmenu JS
		============================================ -->
    <script src="js/jquery.meanmenu.js"></script>
    <!-- owl.carousel JS
		============================================ -->
    <script src="js/owl.carousel.min.js"></script>
    <!-- sticky JS
		============================================ -->
    <script src="js/jquery.sticky.js"></script>
    <!-- scrollUp JS
		============================================ -->
    <script src="js/jquery.scrollUp.min.js"></script>
    
    
    
    <!-- datepicker JS
		============================================ -->
    <script src="js/datepicker/jquery-ui.min.js"></script>
    <script src="js/datepicker/datepicker-active.js"></script>
    
    
    
    <!-- data table JS
		============================================ -->
    <script src="js/data-table/bootstrap-table.js"></script>
    <script src="js/data-table/tableExport.js"></script>
    <script src="js/data-table/data-table-active.js"></script>
    <script src="js/data-table/bootstrap-table-editable.js"></script>
    <script src="js/data-table/bootstrap-editable.js"></script>
    <script src="js/data-table/bootstrap-table-resizable.js"></script>
    <script src="js/data-table/colResizable-1.5.source.js"></script>
    <script src="js/data-table/bootstrap-table-export.js"></script>
    
    
    
    <!-- mCustomScrollbar JS
		============================================ -->
    <script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
    <script src="js/scrollbar/mCustomScrollbar-active.js"></script>
    <!-- metisMenu JS
		============================================ -->
    <script src="js/metisMenu/metisMenu.min.js"></script>
    <script src="js/metisMenu/metisMenu-active.js"></script>
    <!-- peity JS
		============================================ -->
    <script src="js/peity/jquery.peity.min.js"></script>
    <script src="js/peity/peity-active.js"></script>
    <!-- sparkline JS
		============================================ -->
    <script src="js/sparkline/jquery.sparkline.min.js"></script>
    <script src="js/sparkline/sparkline-active.js"></script>
    <!-- tab JS
		============================================ -->
    <script src="js/tab.js"></script>
    <!-- plugins JS
		============================================ -->
    <script src="js/plugins.js"></script>
    <!-- main JS
		============================================ -->
    <script src="js/main.js"></script>
    <!-- tawk chat JS
		============================================ -->
        
         <script>
$(document).ready(function() {
   $("body").tooltip({ 
   	selector: '[data-toggle=tooltip]' 
	 });
});
 
</script>
<!------------------------Fancybox---------------------------------->
 
 <script type="text/javascript" src="lib/jquery.mousewheel.pack.js"></script>

<script type="text/javascript" src="source/jquery.fancybox.pack.js?v=2.1.5"></script>
	<link rel="stylesheet" type="text/css" href="source/jquery.fancybox.css" media="screen" />

<style type="text/css">
	.fancybox-custom .fancybox-skin {
		box-shadow: 0 0 50px #222;
	}
</style> 
<script>
$(document).ready(function() {
	$(".various").fancybox({
		maxWidth	: 380,
		maxHeight	: 410,
		fitToView	: true,
		width		: '100%',
		height		: '100%',
		autoSize	: false,
		closeClick	: false,
		openEffect	: 'none',
		closeEffect	: 'none',
		
		
		
		
	});
	
 
});

</script>
<!--    <script src="js/tawk-chat.js"></script>-->
</body>

</html>