-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
172 lines (166 loc) · 5.51 KB
/
dashboard.php
File metadata and controls
172 lines (166 loc) · 5.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$mysqli = new mysqli("localhost", "root", "root", "back_office");
include './connect.php';
include './request.php';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="El idrissi Chafik">
<title>Back Office</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
</head>
<body>
<!-- Container -->
<div class="container-fluid">
<div class="row">
<!-- SideBar -->
<nav id="sidebar" class="col-md-3 col-lg-2 col-sm-12 d-md-block bg-light sidebar border">
<div class="sidebar-sticky pt-3 mb-3">
<ul class="nav flex-column">
<li class="nav-item mx-auto" id="sidebar-dashboard">
<a class="nav-link" href="./dashboard.php">
<i class="fas fa-home"></i> Dashboard
</a>
</li>
<li class="nav-item mx-auto" id="sidebar-companies">
<a class="nav-link" href="./companies.php">
<i class="fas fa-users"></i> Companies
</a>
</li>
</ul>
</div>
</nav>
<!-- SideBar End -->
<!-- Dashboard -->
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
<div class="row">
<h2 class="mx-auto mt-4">Dashboard</h2>
</div>
<div class="row">
<div id="chart-pie" class="mt-4 mb-4 col-md-6 col-lg-6 col-sm-6 col-xs-12">
<canvas id="canvas-pie" data-pie="<?php echo action('employee_per_age')?>" height="200"></canvas>
</div>
<div id="chart-bar" class="mt-4 mb-4 col-md-6 col-lg-6 col-sm-6 col-xs-12">
<canvas id="canvas-bar" data-bar="<?php echo str_replace('"', "'", action('employee_per_companies'));?>" height="200"></canvas>
</div>
<table id='table-employee-per-department' class="mt-4 mb-4 col-md-12 col-lg-12 col-sm-12 col-xs-12 table table-striped table-sm text-center">
<thead>
<th colspan="4">Employees per department</th>
<tr>
<th>Dept.</th>
<th>First Name</th>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<?php
$result = action('employee_per_department');
while($obj = $result->fetch_object()) {
echo "
<tr id='employee-per-department'>
<td id='employee-$obj->id-department'> $obj->department </td>
<td id='employee-$obj->id-first-name'>$obj->first_name</td>
<td id='employee-$obj->id-name'> $obj->name </td>
<td id='employee-$obj->id-age'> $obj->age </td>
</tr>";
}
?>
</tbody>
</table>
</div>
</main>
</div>
</div>
<!-- Container End -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.0.0-alpha/Chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/feather-icons/4.9.0/feather.min.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script>
/* ChartJS Pie (BreakDown Of Employees) */
const pie_data = [{
data: JSON.parse(document.getElementById('canvas-pie').dataset.pie),
backgroundColor: [
"rgb(255, 99, 132)",
"rgb(54, 162, 235)",
"rgb(255, 205, 86)",
"rgb(86,255,142)",
"rgb(210,86,255)"
]
}];
const pie_options = {
tooltips: {
enabled: true,
},
title: {
display: true,
text: "Breakdown of employees (by age)"
},
};
const pie_ctx = document.getElementById("canvas-pie");
let pie_myChart = new Chart(pie_ctx, {
type: 'doughnut',
data: {
labels: ["<20", "20-30", "30-40", "40-50", "50>"],
datasets: pie_data
},
options: pie_options
});
/* ChartJS Bar (Number of Employees per Company) */
bar_data_full = JSON.parse((document.getElementById('canvas-bar').dataset.bar).replace(/\'/g, '"'));
bar_data_array = new Array();
bar_labels_array = new Array();
Object.keys(bar_data_full).forEach(key => {
bar_data_array.push(bar_data_full[key].count);
bar_labels_array.push(bar_data_full[key].name)
});
const bar_data = [{
data: bar_data_array,
backgroundColor: "rgb(54, 162, 235)"
}];
const bar_options = {
responsive: true,
legend: {
display: false
},
tooltips: {
enabled: true,
},
title: {
display: true,
text: "Number of Employees per Company"
},
hover: {
mode: 'label'
},
scales: {
yAxes: [{
ticks: {
stepSize: 1,
}
}]
}
};
const bar_ctx = document.getElementById("canvas-bar");
let bar_myChart = new Chart(bar_ctx, {
type: 'bar',
data: {
labels: bar_labels_array,
datasets: bar_data
},
options: bar_options
});
</script>
</html>