<?php 
include('include/connection.php'); 

session_start();
$uID=$_SESSION['uID'];
if(empty($uID))
	{
		header("location: index.php");
	}


$query="SELECT * FROM client_tbl";
$result=mysqli_query($link,$query);

$query="SELECT * FROM device_tbl";
$result=mysqli_query($link,$query);


$query9 = "SELECT MONTH(installDate) AS MONTH , SUM(cost) as Amount 
FROM fleet_view 
GROUP BY MONTH(installDate)";

$result9 = mysqli_query($link,$query9);
if (!$result9) { die("Query Failed."); }
while($row9 = mysqli_fetch_array($result9)) {

	$dataPoints9[] = [
		'label' => $row9[0],
		'y' => $row9[1]
	];

 }
// fleet company 
$query10 = "SELECT companyName, SUM(COST) as TOTAL  
FROM fleet_view 
GROUP BY companyName";

$result10 = mysqli_query($link,$query10);
if (!$result10) { die("Query Failed."); }

while($row10 = mysqli_fetch_array($result10)) {

	$dataPoints10[] = [
		'label' => $row10[0],
		'y' => $row10[1]
	];
 }

?> 

<!DOCTYPE html>
<html lang="en">
<head>
  <title>ACCOUNTANT | INTERNAL DATA </title>
    <meta http-equiv="Content-Type" content="text/html; charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="bootstrap-5.0.2-dist/css/bootstrap.min.css" rel="stylesheet">
	<link type="text/css" href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<link type="text/css" href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">
	<!-- <link type="text/css" href="css/theme.css" rel="stylesheet"> -->
	<link type="text/css" href="images/icons/css/font-awesome.css" rel="stylesheet">
	<link type="text/css" href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' rel='stylesheet'>
	<link href="assets/css/dashboard.css" rel="stylesheet">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
    <!-- <script src="search1.js" type="text/javascript"></script>
    <script src="search.js" type="text/javascript"></script>  -->

    <script>
		window.onload = function() {
    // Fleet amount
		var chart9 = new CanvasJS.Chart("chartContainer9", {
		animationEnabled: true,
		exportEnabled: true,
		theme: "light2",
		title: {
			text: " Fleet Amount Per Month " 
		},
		subtitles: [{
			text: ""
		}],
		data: [{
			type: "spline",
			yValueFormatString: "###",
			indexLabel: "{y}",
			dataPoints: <?php echo json_encode($dataPoints9, JSON_NUMERIC_CHECK); ?>
		}]
		});
		 // fleet company
		var chart10 = new CanvasJS.Chart("chartContainer10", {
		animationEnabled: true,
		exportEnabled: true,
		theme: "light2",
		title: {
			text: " Fleet Amount Per Company" 
		},
		subtitles: [{
			text: ""
		}],
		data: [{
			type: "column",
			yValueFormatString: "###",
			indexLabel: "{y}",
			dataPoints: <?php echo json_encode($dataPoints10, JSON_NUMERIC_CHECK); ?>
		}]
		});
        chart9.render();
        chart10.render();
    }
        </script>
</head>
<body>
<div class="container"> 
	<div class="row">
        <div class="col-sm-12">
            <center>
                <div class="alert alert-success" role="alert">
                    <h2><span class="badge badge-secondary">ACCOUNTANT </span></h2>
                        DASHBOARD
                </div>
            
                <a href="accountant_view_hosting.php"><button type="submit" class="btn btn-info " ><b> HOSTING RECORDS</b></button> </a>
                <a href="accountant_view_fleet.php"> <button type="submit" class="btn btn-info"><b> FLEET RECORDS </b></button></a>
                  <a href="accountant_view_summary.php"> <button type="submit" class="btn btn-info"><b> FLEET SUMMARY </b></button></a>
                <a href="logout.php"> <button class="btn btn-info approve" type="button">LOG OUT</button></a>
            </center>
        </div><br><br>

                      <div class="row" style="padding-top: 20px; padding-bottom: 20px">
                        
						<div class="col-sm-12" >
                            <div id="chartContainer9" style="height: 370px; width: 100%;"></div>
                            <div><hr style="height:2px;border-width:0;color:gray;background-color:gray"></div>
                        </div>
                        <div class="col-sm-12" >
				            <div id="chartContainer10" style="height: 370px; width: 100%;"></div>
				            <div><hr style="height:2px;border-width:0;color:gray;background-color:gray"></div>
			            </div>
							</div>

	</div>

</div>


    <script src="scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
	<script src="scripts/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
	<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<script src="scripts/flot/jquery.flot.js" type="text/javascript"></script>
	<script src="scripts/datatables/jquery.dataTables.js"></script>
    
    <script src="canvasjs.min.js"></script>
    <!--<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>-->
</div>

</body>
</html>



