-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
338 lines (307 loc) · 11.9 KB
/
index.php
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<?php
session_start();
require 'config.php'; // Ensure 'config.php' contains the correct DB credentials
// Ensure user is logged in
if (!isset($_SESSION['agent_email'])) {
header("Location: signin.php");
exit();
}
$agent_email = $_SESSION['agent_email'];
$agent_name = $_SESSION['agent_name'];
$code = $_SESSION['code'];
try {
// Create a PDO connection
$pdo = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Fetch the agent's payment link (agent_code)
$stmt = $pdo->prepare("SELECT agent_code FROM agents WHERE email = ?");
$stmt->execute([$agent_email]);
$payment_link = $stmt->fetchColumn();
$stmt = $pdo->prepare("SELECT balance FROM agents WHERE email = ?");
$stmt->execute([$agent_email]);
$balance = $stmt->fetchColumn();
// Fetch the total number of withdrawals for the agent
$stmt = $pdo->prepare("SELECT COUNT(*) AS total_withdrawals FROM agents_withdrawal WHERE agent_email = ?");
$stmt->execute([$agent_email]);
$total_withdrawals = $stmt->fetchColumn();
$stmt = $pdo->prepare("SELECT COUNT(*) AS clients FROM users WHERE agent = ?");
$stmt->execute([$code]);
$total_clients = $stmt->fetchColumn();
} catch (PDOException $e) {
die("Database error: " . $e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>S-MART Affiliate Dashboard| Dashboard</title>
<!-- Favicon -->
<link rel="shortcut icon" href="img/logo.png" type="image/x-icon" />
<!-- Custom styles -->
<link rel="stylesheet" href="./css/style.min.css" />
</head>
<style>
.sidebar-head {
display: flex !important;
flex-direction: row !important;
align-items: center !important;
justify-content: space-between !important;
width: 100% !important;
max-width: 100% !important;
/* flex-wrap: nowrap !important; */
}
.logo-wrapper {
display: flex !important;
align-items: center !important;
}
.logo-wrapper img {
max-width: 130px !important;
height: auto !important;
}
.sidebar-toggle {
display: flex !important;
align-items: center !important;
justify-content: center !important;
flex-shrink: 0 !important;
margin-left: 10px !important;
margin-top: 10px !important;
}
.sidebar-user-container {
display: flex;
align-items: center;
white-space: nowrap;
/* Prevents wrapping */
overflow: hidden;
/* Ensures overflow is hidden */
max-width: 200px;
/* Set a max width to control layout */
}
.sidebar-user-icon {
color: white;
flex-shrink: 0;
/* Prevents the icon from shrinking */
margin-right: 8px;
/* Adds some space between the icon and the name */
}
.sidebar-user-info {
flex-grow: 1;
/* Allows the name to take available space */
overflow: hidden;
text-overflow: ellipsis;
/* Adds '...' if the name is too long */
}
</style>
<body>
<div class="layer"></div>
<!-- ! Body -->
<a class="skip-link sr-only" href="#skip-target">Skip to content</a>
<div class="page-flex">
<!-- ! Sidebar -->
<aside class="sidebar">
<div class="sidebar-start">
<div class="sidebar-head">
<a href="/" class="logo-wrapper" title="Home">
<span class="sr-only">Home</span>
<img src="img/logo-white.png" width="100%" aria-hidden="true" alt="Logo" />
</a>
<button class="sidebar-toggle transparent-btn" title="Menu" type="button">
<span class="sr-only">Toggle menu</span>
<span class="icon menu-toggle" aria-hidden="true"></span>
</button>
</div>
<div class="sidebar-body">
<ul class="sidebar-body-menu">
<li>
<a class="active" href="index.php"><span class="icon home" aria-hidden="true"></span>Dashboard</a>
</li>
<li>
<a href="clients.php"><i data-feather="users" aria-hidden="true" class="icon"></i>
Clients</a>
</li>
<li>
<a class="show-cat-btn" href="##">
<i data-feather="arrow-down-circle" aria-hidden="true" class="icon"></i> Withdrawal
<span class="category__btn transparent-btn" title="Open list">
<span class="sr-only">Open list</span>
<span class="icon arrow-down" aria-hidden="true"></span>
</span>
</a>
<ul class="cat-sub-menu">
<li>
<a href="withdrawal-request.php" style="font-size: 12px">View Withdrawal Request</a>
</li>
<li>
<a href="request-withdrawal.php" style="font-size: 12px">Request For Withdrawal</a>
</li>
</ul>
</li>
<li>
<a class="show-cat-btn" href="##">
<i data-feather="users" aria-hidden="true" class="icon"></i>Community
<span class="category__btn transparent-btn" title="Open list">
<span class="sr-only">Open list</span>
<span class="icon arrow-down" aria-hidden="true"></span>
</span>
</a>
<ul class="cat-sub-menu">
<li>
<a href="https://chat.whatsapp.com/IDH0u43syKp5aZlmvzLCUW " target="_blank"
style="font-size: 12px">Join group</a>
</li>
</ul>
</li>
<li>
<a href="profile.php"><i data-feather="user" aria-hidden="true" class="icon"></i>
Profile</a>
</li>
<li>
<a href="logout.php"><i data-feather="log-out" aria-hidden="true" class="icon"></i></i>
Logout</a>
</li>
</ul>
</div>
</div>
<div class="sidebar-footer">
<a href="##" class="sidebar-user" style="padding: 10px;">
<!-- <span class="sidebar-user-img"> -->
<!-- </span> -->
<div class="sidebar-user-container">
<i data-feather="user" aria-hidden="true" class="sidebar-user-icon"></i>
<div class="sidebar-user-info">
<span class="sidebar-user__title">
<?php echo htmlspecialchars($agent_name); ?>
</span>
</div>
</div>
</a>
</div>
</aside>
<div class="main-wrapper">
<!-- ! Main nav -->
<nav class="main-nav--bg">
<div class="container main-nav">
<div class="main-nav-start"></div>
<div class="main-nav-end">
<button class="sidebar-toggle transparent-btn" title="Menu" type="button">
<span class="sr-only">Toggle menu</span>
<span class="icon menu-toggle--gray" aria-hidden="true"></span>
</button>
<button class="theme-switcher gray-circle-btn" type="button" title="Switch theme">
<span class="sr-only">Switch theme</span>
<i class="sun-icon" data-feather="sun" aria-hidden="true"></i>
<i class="moon-icon" data-feather="moon" aria-hidden="true"></i>
</button>
<div class="nav-user-wrapper">
<button href="##" class="nav-user-btn dropdown-btn" title="My profile" type="button">
<span class="sr-only">My profile</span>
<span class="nav-user-img">
<picture>
<source srcset="./img/avatar/avatar-illustrated-02.webp" type="image/webp" />
<img src="./img/avatar/avatar-illustrated-02.png" alt="User name" />
</picture>
</span>
</button>
<ul class="users-item-dropdown nav-user-dropdown dropdown">
<li>
<a href="profile.php">
<i data-feather="user" aria-hidden="true"></i>
<span>Profile</span>
</a>
</li>
<li>
<a class="danger" href="logout.php">
<i data-feather="log-out" aria-hidden="true"></i>
<span>Log out</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</nav>
<!-- ! Main -->
<main class="main users chart-page" id="skip-target">
<div class="container">
<h2 class="main-title">Dashboard</h2>
<div class="row stat-cards">
<div class="col-md-6 col-xl-4 mt-2">
<article class="stat-cards-item" onclick="window.location.href='request-withdrawal.php';"
style="cursor: pointer;">
<div class="stat-cards-icon warning">
<i data-feather="credit-card" aria-hidden="true"></i>
</div>
<div class="stat-cards-info">
<p class="stat-cards-info__num">₦ <span><?php echo $balance ?></span></p>
<p class="stat-cards-info__title">Total Balance</p>
</div>
</article>
</div>
<div class="col-md-6 col-xl-4 mt-2">
<article class="stat-cards-item" onclick="window.location.href='clients.php';" style="cursor: pointer;">
<div class="stat-cards-icon purple">
<i data-feather="users"></i>
</div>
<div class="stat-cards-info">
<p class="stat-cards-info__num"><?php echo $total_clients ?></p>
<p class="stat-cards-info__title">
Total Clients
</p>
</div>
</article>
</div>
<div class="col-md-6 col-xl-4 mt-2">
<article class="stat-cards-item ">
<div class="stat-cards-icon success">
<i data-feather="link" aria-hidden="true"></i>
</div>
<div class="stat-cards-info">
<p class="stat-cards-info__title">Copy referral link</p>
<div style="display: flex; align-items: center; gap: 10px;">
<input type="text" id="referralLink"
value="https://app.s-martpos.com/signup?authc=<?php echo strtolower(htmlspecialchars($payment_link ?? 'N/A')); ?>"
readonly
style="border: none; background: transparent; font-size: 14px; width: 100%; cursor: default;"
class="stat-cards-info__num">
<button onclick="copyReferralLink()"
style="padding: 5px 10px; font-size: 12px; background: #4CAF50; color: white; border: none; cursor: pointer;">Copy</button>
</div>
</div>
<script>
function copyReferralLink() {
var copyText = document.getElementById("referralLink");
copyText.select();
copyText.setSelectionRange(0, 99999); // For mobile devices
document.execCommand("copy");
// Show confirmation
alert("Referral link copied: " + copyText.value);
}
</script>
</article>
</div>
</div>
</div>
</main>
<!-- ! Footer -->
<footer class="footer">
<div class="container footer--flex">
<div class="footer-start">
<p>
2025 © S-MART Affiliate - Powered by
<a href="" target="_blank" rel="noopener noreferrer">Onatech NGC</a>
</p>
</div>
</div>
</footer>
</div>
</div>
<!-- Chart library -->
<script src="./plugins/chart.min.js"></script>
<!-- Icons library -->
<script src="plugins/feather.min.js"></script>
<!-- Custom scripts -->
<script src="js/script.js"></script>
</body>
</html>