-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
264 lines (242 loc) · 10.6 KB
/
Copy pathdashboard.php
File metadata and controls
264 lines (242 loc) · 10.6 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php
session_start();
if(!isset($_SESSION['session_username'])){
header("location:index.php");
exit();
}
include('condli.php'); // Koneksi ke database
// Menampilkan data customer
$query = "SELECT * FROM customers";
$result = $conn->query($query);
$total_customers = $result->num_rows;
// Ambil data jumlah client untuk setiap paket
$packageQuery = "SELECT paket_mbps.nama, paket_mbps.harga, COUNT(customers.id_client) as total_clients
FROM customers
JOIN paket_mbps ON customers.id_paket = paket_mbps.id_paket
GROUP BY paket_mbps.id_paket";
$packageResult = $conn->query($packageQuery);
// Hitung pendapatan
$pendapatan = 0;
while ($package = $packageResult->fetch_assoc()) {
$pendapatan += $package['total_clients'] * $package['harga'];
}
// Mengambil data jumlah customer per hari
$query = "SELECT DATE(tanggal_pemasangan) as day, COUNT(*) as total FROM customers GROUP BY DATE(tanggal_pemasangan)";
$stmt = $conn->prepare($query);
$stmt->execute();
$result = $stmt->get_result();
// Menyusun data untuk chart
$days = [];
$daily_customer_counts = [];
while ($row = $result->fetch_assoc()) {
$days[] = $row['day']; // Menyimpan tanggal (format YYYY-MM-DD)
$daily_customer_counts[] = $row['total']; // Menyimpan jumlah pelanggan
}
$username = $_SESSION['session_username'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DLI-billing Dashboard</title>
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<!-- Custom Styles -->
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light shadow-sm">
<div class="container-fluid d-flex align-items-center">
<!-- Hamburger button -->
<button class="btn btn-outline-primary me-3" id="hamburgerToggle">
<i class="fas fa-bars"></i>
</button>
<a class="navbar-brand" href="dashboard.php"><i class="fas fa-billing"></i> DLI-billing</a>
<!-- Right Section -->
<div class="ms-auto d-flex align-items-center">
<!-- Notifications -->
<div class="dropdown me-3">
<button class="btn btn-outline-secondary position-relative" id="notifDropdown" data-bs-toggle="dropdown">
<i class="fas fa-bell"></i>
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
3
</span>
</button>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="notifDropdown">
<li><a class="dropdown-item" href="#">New invoice created</a></li>
<li><a class="dropdown-item" href="#">Customer feedback received</a></li>
<li><a class="dropdown-item" href="#">Payment overdue alert</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item text-center" href="#">View all notifications</a></li>
</ul>
</div>
<!-- Name -->
<div class="name me-3">
<h5><?php echo htmlspecialchars($username); ?></h5>
</div>
<!-- Profile -->
<div class="dropdown">
<a class="d-flex align-items-center text-decoration-none" href="#" id="profileDropdown" data-bs-toggle="dropdown">
<img src="assets/images/dli.png" alt="Profile" class="rounded-circle me-2" width="40" height="40">
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="profileDropdown">
<li><a class="dropdown-item" href="profile.php"><i class="fas fa-user-circle me-2"></i> My Profile</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item text-danger" href="logout.php"><i class="fas fa-sign-out-alt me-2"></i> Logout</a></li>
</ul>
</div>
</div>
</div>
</nav>
<!-- Sidebar -->
<div class="d-flex">
<nav class="sidebar bg-light p-3" id="sidebarMenu">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href=""><i class="fas fa-home"></i> Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link " href="paket.php"><i class="fa-solid fa-computer"></i> Paket Kecepatan</a>
</li>
<li class="nav-item">
<a class="nav-link" href="costumer.php"><i class="fas fa-users"></i> Customer</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-receipt"></i> Invoices</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-toggle" href="#" id="whatsappDropdown" data-bs-toggle="collapse" aria-expanded="false">
<i class="fab fa-whatsapp"></i> WhatsApp API
</a>
<ul class="collapse list-unstyled" id="whatsappSubMenu">
<li>
<a class="nav-link ms-3 submenu-link" href="setup.php"><i class="fas fa-cogs"></i> Setup</a>
</li>
<li>
<a class="nav-link ms-3 submenu-link" href="logs.php"><i class="fas fa-file-alt"></i> Logs</a>
</li>
</ul>
</ul>
</nav>
</div>
<!-- Main Content -->
<div class="content p-4">
<h3 class="mb-3">Dashboard</h3>
<div class="row mt-4">
<div class="col-md-4">
<div class="card text-center shadow-sm">
<div class="card-body">
<i class="fas fa-wallet fa-2x text-primary mb-3"></i>
<h5>Total Paid</h5>
<h3>234</h3>
<p class="text-danger">⬇ 5%</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-center shadow-sm">
<div class="card-body">
<i class="fas fa-wallet fa-2x text-danger mb-3"></i>
<h5>Total Unpaid</h5>
<h3>234</h3>
<p class="text-danger">⬇ 5%</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-center shadow-sm">
<div class="card-body">
<i class="fas fa-user-check fa-2x text-success mb-3"></i>
<h5>Total Customers</h5>
<h3><?php echo $total_customers; ?></h3>
<p class="text-primary">Open</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-center shadow-sm">
<div class="card-body">
<i class="fas fa-dollar-sign fa-2x text-warning mb-3"></i>
<h5>Pendapatan</h5>
<h3>Rp <?= number_format($pendapatan, 0, ',', '.') ?></h3>
<p class="text-success">New</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-center shadow-sm">
<div class="card-body">
<i class="fab fa-whatsapp fa-2x text-success mb-3"></i>
<h5>WhatsApp API</h5>
<h3>status</h3>
<p class="text-success">Online</p>
</div>
</div>
</div>
</div>
<!-- Chart Section -->
<div class="mt-5">
<h4>Pertambahan Costumer</h4>
<canvas id="customerChart" height="150"></canvas>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<!-- Custom JS -->
<script src="js/script.js"></script>
<script>
var ctx = document.getElementById('customerChart').getContext('2d');
var customerChart = new Chart(ctx, {
type: 'line',
data: {
labels: <?php echo json_encode($days); ?>, // Tampilkan tanggal
datasets: [{
label: 'Jumlah Customer',
data: <?php echo json_encode($daily_customer_counts); ?>, // Jumlah customer per hari
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
tension: 0.1
}]
},
options: {
responsive: true,
plugins: {
legend: {
display: true,
position: 'top'
},
tooltip: {
mode: 'index',
intersect: false
}
},
scales: {
x: {
title: {
display: true,
text: 'Tanggal'
}
},
y: {
title: {
display: true,
text: 'Jumlah Pelanggan'
},
beginAtZero: true
}
}
}
});
</script>
<footer class="text-center mt-5">
<p>© 2025 DLI-billing. All rights reserved.</p>
</footer>
</body>
</html>