<?php
session_start();
include 'actions/dbconnection.php';

$sno = $_SESSION['sno'];

$sql = "SELECT * FROM leads where assign_by = '$sno' ORDER BY time DESC";
$result = $conn->query($sql);
$trows = mysqli_num_rows($result);

$sql1 = "SELECT * FROM leads where lead_status = 'Closed-Won' and assign_by = '$sno'";
$result1 = $conn->query($sql1);
$cleads = mysqli_num_rows($result1);

$sql4 = "SELECT * FROM leads where lead_status = 'Demo Scheduled' and assign_by = '$sno'";
$result4 = $conn->query($sql4);
$sleads = mysqli_num_rows($result4);

$sql5 = "SELECT * FROM leads where lead_status = 'Demo Done' and assign_by = '$sno'";
$result5 = $conn->query($sql5);
$dleads = mysqli_num_rows($result5);


?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="" />
    <meta name="keywords" content="" />
	<title>Wisibles</title>
    <link rel="icon" href="images/fav-icon.svg" type="image/svg" sizes="16x16">
    
    <link rel="stylesheet" href="css/main.min.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/color.css">
    <link rel="stylesheet" href="css/responsive.css">
	<link href="plugins/apex/apexcharts.css" rel="stylesheet" type="text/css">

</head>
<body>
<div class="page-loader" id="page-loader">
	 <div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>
	 <span>Loading...</span>
</div><!-- page loader -->
<div class="theme-layout">
	
	<?php include 'header.php'; ?>
	<div class="top-sub-bar">
		<div class="container-fluid">
			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-6">
					<div class="menu-btn">
						<i class="">
<svg id="menu-btn" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg></i>
					</div>
					<div class="page-title">
						<h4>Dashboard</h4>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-6">
					<ul class="breadcrumb">
						<li><a href="#" title="">Home</a></li>
						<li><a href="#" title="">Dashboard</a></li>
					</ul>
				</div>
			</div>
		</div>	
	</div><!-- top sub bar -->
	<?php include 'left_menu.php'; ?>
	

	<div class="container-fluid">
		<div class="row">
			<div class="col-lg-12">
				<div class="panel-content">
					<h4 class="main-title">Dashboard</h4>
					<div class="row merged20 mb-4">
						<div class="col-lg-3 col-md-4 col-sm-4">
							<div class="d-widget soft-red">
								<div class="d-widget-title">
									<h5>Total Leads</h5>
								</div>
								<div class="d-widget-content">
									<span class="realtime-ico pulse"></span>
									<h6>Check Now</h6>
									<h5><?php echo $trows; ?></h5>
									<i class="icofont-users-alt-3"></i>
								</div>
							</div>
						</div>
						<div class="col-lg-3 col-md-4 col-sm-4">
							<div class="d-widget soft-blue">
								<div class="d-widget-title">
									<h5>Close Leads</h5>
								</div>
								<div class="d-widget-content">
									<span class="realtime-ico pulse"></span>
									<h6>Check Now</h6>
									<h5><?php echo $cleads; ?></h5>
									<i class="icofont-optic"></i>
								</div>
							</div>
						</div>

						<div class="col-lg-3 col-md-4 col-sm-4">
							<div class="d-widget soft-green">
								<div class="d-widget-title">
									<h5>Demo Done</h5>
								</div>
								<div class="d-widget-content">
									<span class="realtime-ico pulse"></span>
									<h6>Check Now</h6>
									<h5><?php echo $dleads; ?></h5>
									<i class="icofont-computer"></i>
								</div>
							</div>
						</div>

						<div class="col-lg-3 col-md-4 col-sm-4">
							<div class="d-widget soft-blue">
								<div class="d-widget-title">
									<h5>Demo Scheduled</h5>
								</div>
								<div class="d-widget-content">
									<span class="realtime-ico pulse"></span>
									<h6>Check Now</h6>
									<h5><?php echo $sleads; ?></h5>
									<i class="icofont-computer"></i>
								</div>
							</div>
						</div>

						
					</div>
				
					<div class="row merged20 mb-4">
						<div class="col-lg-12">
							<div class="d-widget">
								<div class="d-widget-title">
									<h5>Recent Leads</h5>
								</div>
								<table class="table table-default all-events table-striped table-responsive-lg">
									<thead>
										<tr>
											<th>S NO</th>
											<th>School Name</th>
											<th>Name</th>
											<th>Mobile</th>
											
											<th>Email</th>
                                           
											
											
										</tr>
									</thead>
									<tbody>
											   <?php
		   
				$count=0;
					while($row = $result->fetch_assoc())
					{   
				$time = $row['time']; 
					$time = strtotime($time);
?>	
										<tr>
											<td><?php echo ++$count; ?></td>
											<td><?php echo $row['school_name']?></td>
											<td><?php echo $row['name']?></td>
											<td><?php echo $row['mobile']?></td>
											
											<td><a href="#" title=""><span class="__cf_email__" data-cfemail="<?php echo $row['email']?>"><?php echo $row['email']?></span></a></td>
                                           
											
											
										
										</tr>
										<?php  }	?>  
									</tbody>
								</table>	
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div><!-- main content -->
	
	<!-- side slide message & popup -->
</div>
	
	<script src="js/main.min.js"></script>
	<script src="js/vivus.min.js"></script>
	<script src="js/script.js"></script>
	
	<script src="plugins/apex/apexcharts.min.js"></script>
	<script src="js/graphs-scripts.js"></script>

	

</body>	

</html>