<?php 
session_start();
require '../config/database.php';
require 'model/model.php';
global $conn;

if (isset($_SESSION['admin_id'])) {
    $name = $_SESSION['name'];
} else {
    echo "<script>window.location='index.php'</script>";
    exit;
}

$result = '';
/*if(isset($_REQUEST['submit'])){
	$stats = '';
	$stats = get_stats($_REQUEST['postcode']);
	$stats2 = get_stats_fleet_size($_REQUEST['postcode']);
	$stats3 = get_stats_fleet_size_no_web_phone($_REQUEST['postcode']);
	$stats4 = get_stats_fleet_size_no_phone($_REQUEST['postcode']);
	$stats5 = get_stats_fleet_size_no_web($_REQUEST['postcode']);
	$stats6 = get_stats_phone_no($_REQUEST['postcode']);
}else{
	$stats = '';
	$stats = get_stats();
	$stats2 = get_stats_fleet_size();
	$stats3 = get_stats_fleet_size_no_web_phone();
	$stats4 = get_stats_fleet_size_no_phone();
	$stats5 = get_stats_fleet_size_no_web();
	$stats6 = get_stats_phone_no();
}*/

include('layout/header.php');
include('layout/left_sidebar.php');

?>
<!-- Title -->
<div class="row heading-bg">
	<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
		<h5 class="txt-dark">Stats</h5>
	</div>
</div>
<div class="row">
	<div class="col-md-12">
		<div class="panel panel-default card-view">
			<div class="panel-wrapper collapse in">
				<div class="panel-body">
					<div class="form-wrap">
						<form method="post" action="">
							<div class="row">
								<div class="col-sm-4">
									<div class="form-group">
										<input type="text" name="postcode" id="postcode" placeholder="Post Code" class="form-control" value="" required>
									</div>
								</div>
								<div class="col-sm-4">
									<div class="form-group">
										<button type="button" class="btn btn-primary serach-by-postcode" name="submit">Submit</button>
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
		<div class="panel panel-default card-view pa-0">
			<div class="panel-wrapper collapse in">
				<div class="panel-body pa-0">
					<div class="sm-data-box">
						<div class="container-fluid">
							<div class="row">
								<div class="col-xs-6 text-center pl-0 pr-0 data-wrap-left" style="width: 70%;">
									<span class="txt-dark block counter"><span class="total_count"></span></span>
									<span class="weight-500 uppercase-font block font-13">All Records</span>
								</div>
								<div class="col-xs-6 text-center  pl-0 pr-0 data-wrap-right" style="width: 30%;">
									<i class="icon-grid data-right-rep-icon txt-light-grey"></i>
								</div>
							</div>	
							<div class="panel-wrapper collapse in loading-img-div2"></div>
							<div class="panel-wrapper collapse in loading-div2">
								<div class="panel-body">
									<div>
										<span class="pull-left inline-block capitalize-font txt-dark">
											1 – 9 vehicles
										</span>
										<span class="label label-warning pull-right total_1_9"></span>
										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											10 – 19 vehicles
										</span>
										<span class="label label-danger pull-right total_10_19"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											20 – 39 vehicles
										</span>
										<span class="label label-success pull-right total_20_39"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											40 – 99 vehicles
										</span>
										<span class="label label-primary pull-right total_40_99"></span>
										<div class="clearfix"></div>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											100+ vehicles
										</span>
										<span class="label label-primary pull-right total_100"></span>
										<div class="clearfix"></div>
									</div>
								</div>	
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
		<div class="panel panel-default card-view pa-0">
			<div class="panel-wrapper collapse in">
				<div class="panel-body pa-0">
					<div class="sm-data-box">
						<div class="container-fluid">
							<div class="row">
								<div class="col-xs-6 text-center pl-0 pr-0 data-wrap-left" style="width: 70%;">
									<span class="txt-dark block counter no_phone_no_website_count"><span class="counter-anim"></span></span>
									<span class="weight-500 uppercase-font block font-13">No Website & Phone</span>
								</div>
								<div class="col-xs-6 text-center  pl-0 pr-0 data-wrap-right" style="width: 30%;">
									<i class="icon-grid data-right-rep-icon txt-light-grey"></i>
								</div>
							</div>
							<div class="panel-wrapper collapse in loading-img-div3"></div>
							<div class="panel-wrapper collapse in loading-div3">
								<div class="panel-body">
									<div>
										<span class="pull-left inline-block capitalize-font txt-dark">
											1 – 9 vehicles
										</span>
										<span class="label label-warning pull-right total2_1_9"></span>
										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											10 – 19 vehicles
										</span>
										<span class="label label-danger pull-right total2_10_19"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											20 – 39 vehicles
										</span>
										<span class="label label-success pull-right total2_20_39"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											40 – 99 vehicles
										</span>
										<span class="label label-primary pull-right total2_40_99"></span>
										<div class="clearfix"></div>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											100+ vehicles
										</span>
										<span class="label label-primary pull-right total2_100"></span>
										<div class="clearfix"></div>
									</div>
								</div>	
							</div>	
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
		<div class="panel panel-default card-view pa-0">
			<div class="panel-wrapper collapse in">
				<div class="panel-body pa-0">
					<div class="sm-data-box">
						<div class="container-fluid">
							<div class="row">
								<div class="col-xs-6 text-center pl-0 pr-0 data-wrap-left" style="width: 70%;">
									<span class="txt-dark block counter"><span class="no_phone_yes_website_count"></span></span>
									<span class="weight-500 uppercase-font block font-13">No Phone But Website is there</span>
								</div>
								<div class="col-xs-6 text-center  pl-0 pr-0 data-wrap-right" style="width: 30%;">
									<i class="icon-grid data-right-rep-icon txt-light-grey"></i>
								</div>
							</div>	
							<div class="panel-wrapper collapse in loading-img-div4"></div>
							<div class="panel-wrapper collapse in loading-div4">
								<div class="panel-body">
									<div>
										<span class="pull-left inline-block capitalize-font txt-dark">
											1 – 9 vehicles
										</span>
										<span class="label label-warning pull-right total3_1_9"></span>
										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											10 – 19 vehicles
										</span>
										<span class="label label-danger pull-right total3_10_19"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											20 – 39 vehicles
										</span>
										<span class="label label-success pull-right total3_20_39"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											40 – 99 vehicles
										</span>
										<span class="label label-primary pull-right total3_40_99">></span>
										<div class="clearfix"></div>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											100+ vehicles
										</span>
										<span class="label label-primary pull-right total3_100"></span>
										<div class="clearfix"></div>
									</div>
								</div>	
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
		<div class="panel panel-default card-view pa-0">
			<div class="panel-wrapper collapse in">
				<div class="panel-body pa-0">
					<div class="sm-data-box">
						<div class="container-fluid">
							<div class="row">
								<div class="col-xs-6 text-center pl-0 pr-0 data-wrap-left" style="width: 70%;">
									<span class="txt-dark block counter"><span class="yes_phone_no_website_count"></span></span>
									<span class="weight-500 uppercase-font block font-13">No Website But Phone is there </span>
								</div>
								<div class="col-xs-6 text-center  pl-0 pr-0 data-wrap-right" style="width: 30%;">
									<i class="icon-grid data-right-rep-icon txt-light-grey"></i>
								</div>
							</div>	
							<div class="panel-wrapper collapse in loading-img-div5"></div>
							<div class="panel-wrapper collapse in loading-div5">
								<div class="panel-body">
									<div>
										<span class="pull-left inline-block capitalize-font txt-dark">
											1 – 9 vehicles
										</span>
										<span class="label label-warning pull-right total4_1_9"></span>
										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											10 – 19 vehicles
										</span>
										<span class="label label-danger pull-right total4_10_19"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											20 – 39 vehicles
										</span>
										<span class="label label-success pull-right total4_20_39"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											40 – 99 vehicles
										</span>
										<span class="label label-primary pull-right total4_40_99"></span>
										<div class="clearfix"></div>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											100+ vehicles
										</span>
										<span class="label label-primary pull-right total4_100"></span>
										<div class="clearfix"></div>
									</div>
								</div>	
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
		<div class="panel panel-default card-view pa-0">
			<div class="panel-wrapper collapse in">
				<div class="panel-body pa-0">
					<div class="sm-data-box">
						<div class="container-fluid">
							<div class="row">
								<div class="col-xs-6 text-center pl-0 pr-0 data-wrap-left" style="width: 70%;">
									<span class="txt-dark block counter"><span class="yes_phone_result"></span></span>
									<span class="weight-500 uppercase-font block font-13">Phone with or without Website </span>
								</div>
								<div class="col-xs-6 text-center  pl-0 pr-0 data-wrap-right" style="width: 30%;">
									<i class="icon-grid data-right-rep-icon txt-light-grey"></i>
								</div>
							</div>	
							<div class="panel-wrapper collapse in loading-img-div6"></div>
							<div class="panel-wrapper collapse in loading-div6">
								<div class="panel-body">
									<div>
										<span class="pull-left inline-block capitalize-font txt-dark">
											1 – 9 vehicles
										</span>
										<span class="label label-warning pull-right total5_1_9"></span>
										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											10 – 19 vehicles
										</span>
										<span class="label label-danger pull-right total5_10_19"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											20 – 39 vehicles
										</span>
										<span class="label label-success pull-right total5_20_39"></span>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											40 – 99 vehicles
										</span>
										<span class="label label-primary pull-right total5_40_99"></span>
										<div class="clearfix"></div>

										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10">
										<span class="pull-left inline-block capitalize-font txt-dark">
											100+ vehicles
										</span>
										<span class="label label-primary pull-right total5_100"></span>
										<div class="clearfix"></div>
									</div>
								</div>	
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- /Row -->

<?php include('layout/footer.php');?>

<script type="text/javascript">
$(document).ready(function() {

	$(document).on("click", ".serach-by-postcode", function() {
		if($("#postcode").val() != '' && $("#postcode").val().length >= 2){
			get_stats_data($("#postcode").val());
		}
		
	});
	get_stats_data();
	function get_stats_data(postcode = ''){

		$(".loading-div1").hide();
	    $(".loading-img-div1").html("<div style='padding: 100px;text-align: center;'><img src='../img/loading.gif' width='50'/>");
	    $.ajax({
	        url : "ajax/get-states.php",
	        data : { action:'main-total', postcode:postcode },
	        dataType: 'json',
	    }).done(function (data) { 
	    	$(".loading-img-div1").html("");
	    	$(".loading-img-div1").show();
	    	$(".loading-div1").show();

	    	$(".total_count").html(data.total_count);
	    	$(".no_phone_no_website_count").html(data.no_phone_no_website_count);
	    	$(".no_phone_yes_website_count").html(data.no_phone_yes_website_count);
	    	$(".yes_phone_no_website_count").html(data.yes_phone_no_website_count);
	    	$(".yes_phone_result").html(data.yes_phone_result);


	    	$.ajax({
		        url : "ajax/get-states.php",
		        data : { action:'get_stats_fleet_size', postcode:postcode },
		        dataType: 'json',
		    }).done(function (data) { 
		    	$(".loading-img-div2").html("");
		    	$(".loading-img-div2").show();
		    	$(".loading-div2").show();

		    	$(".total_1_9").html(data.total_1_9);
		    	$(".total_10_19").html(data.total_10_19);
		    	$(".total_20_39").html(data.total_20_39);
		    	$(".total_40_99").html(data.total_40_99);
		    	$(".total_100").html(data.total_100);

		    	$.ajax({
			        url : "ajax/get-states.php",
			        data : { action:'get_stats_fleet_size_no_web_phone', postcode:postcode },
			        dataType: 'json',
			    }).done(function (data) {
			    	$(".loading-img-div3").html("");
			    	$(".loading-img-div3").show();
			    	$(".loading-div3").show();

			    	$(".total2_1_9").html(data.total_1_9);
			    	$(".total2_10_19").html(data.total_10_19);
			    	$(".total2_20_39").html(data.total_20_39);
			    	$(".total2_40_99").html(data.total_40_99);
			    	$(".total2_100").html(data.total_100);

			    	$.ajax({
				        url : "ajax/get-states.php",
				        data : { action:'get_stats_fleet_size_no_phone', postcode:postcode },
				        dataType: 'json',
				    }).done(function (data) {
				    	$(".loading-img-div4").html("");
				    	$(".loading-img-div4").show();
				    	$(".loading-div4").show();

				    	$(".total3_1_9").html(data.total_1_9);
				    	$(".total3_10_19").html(data.total_10_19);
				    	$(".total3_20_39").html(data.total_20_39);
				    	$(".total3_40_99").html(data.total_40_99);
				    	$(".total3_100").html(data.total_100);

				    	$.ajax({
					        url : "ajax/get-states.php",
					        data : { action:'get_stats_fleet_size_no_web', postcode:postcode },
					        dataType: 'json',
					    }).done(function (data) {
					    	$(".loading-img-div5").html("");
					    	$(".loading-img-div5").show();
					    	$(".loading-div5").show();

					    	$(".total4_1_9").html(data.total_1_9);
					    	$(".total4_10_19").html(data.total_10_19);
					    	$(".total4_20_39").html(data.total_20_39);
					    	$(".total4_40_99").html(data.total_40_99);
					    	$(".total4_100").html(data.total_100);

					    	$.ajax({
						        url : "ajax/get-states.php",
						        data : { action:'get_stats_phone_no', postcode:postcode },
						        dataType: 'json',
						    }).done(function (data) { 
						    	$(".loading-img-div6").html("");
						    	$(".loading-img-div6").show();
						    	$(".loading-div6").show();

						    	$(".total5_1_9").html(data.total_1_9);
						    	$(".total5_10_19").html(data.total_10_19);
						    	$(".total5_20_39").html(data.total_20_39);
						    	$(".total5_40_99").html(data.total_40_99);
						    	$(".total5_100").html(data.total_100);
						    });
					    });
				    });
			    });
		    });
	    });

	    $(".loading-div2").hide();
	    $(".loading-img-div2").html("<div style='padding: 100px;text-align: center;'><img src='../img/loading.gif' width='50'/>");
	    

	    $(".loading-div3").hide();
	    $(".loading-img-div3").html("<div style='padding: 100px;text-align: center;'><img src='../img/loading.gif' width='50'/>");
	    

	    $(".loading-div4").hide();
	    $(".loading-img-div4").html("<div style='padding: 100px;text-align: center;'><img src='../img/loading.gif' width='50'/>");
	    

	    $(".loading-div5").hide();
	    $(".loading-img-div5").html("<div style='padding: 100px;text-align: center;'><img src='../img/loading.gif' width='50'/>");
	    

	    $(".loading-div6").hide();
	    $(".loading-img-div6").html("<div style='padding: 100px;text-align: center;'><img src='../img/loading.gif' width='50'/>");
	    
	}
	
});
</script>