-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcliente.php
More file actions
517 lines (442 loc) · 16.2 KB
/
cliente.php
File metadata and controls
517 lines (442 loc) · 16.2 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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
session_start(); // Mover session_start() para o topo
// Verificar se o token foi fornecido
$token = $_GET["token"] ?? "";
$isAdmin = isset($_GET["admin"]) && $_GET["admin"] == "1";
if (empty($token)) {
die("<h1>Acesso Negado</h1><p>Token de acesso não fornecido ou inválido.</p>");
}
// Incluir funções de cliente e autenticação
require_once dirname(__FILE__) . "/funcoes_cliente.php";
require_once dirname(__FILE__) . "/auth_cliente.php";
require_once dirname(__FILE__) . "/auth_admin.php";
// Obter dados do cliente pelo token
$cliente = obterClientePorToken($token);
if (!$cliente) {
die("<h1>Acesso Negado</h1><p>Token de acesso inválido ou expirado.</p>");
}
// Verificar se o cliente está ativo
if ($cliente["status"] !== "ativo") {
die("<h1>Acesso Suspenso</h1><p>Sua conta está temporariamente suspensa. Entre em contato com o suporte.</p>");
}
// Verificar autenticação
if ($isAdmin) {
// Se é acesso de admin, verificar se está logado como super admin
if (!verificarSuperAdmin()) {
// Redirecionar para login de admin com parâmetros para retornar
$returnUrl = urlencode($_SERVER["REQUEST_URI"]);
header("Location: admin_login.php?return=" . $returnUrl);
exit();
}
} else {
// Para clientes normais, não precisamos de autenticação adicional
// O token já foi validado acima
// Definir dados da sessão para o cliente
$_SESSION["cliente_token"] = $token;
$_SESSION["cliente_autenticado"] = true;
$_SESSION["tempo_login"] = time();
}
// Verificar e resetar contador mensal se necessário
$mesAtual = date("Y-m");
if ($cliente["ultimo_mes_atualizacao"] !== $mesAtual) {
atualizarCliente($cliente["email"], [
"eventos_criados_mes_atual" => 0,
"ultimo_mes_atualizacao" => $mesAtual
]);
$cliente["eventos_criados_mes_atual"] = 0;
$cliente["ultimo_mes_atualizacao"] = $mesAtual;
}
// Calcular eventos restantes
$eventosRestantes = $cliente["limite_eventos_mensal"] - $cliente["eventos_criados_mes_atual"];
$podecriarEvento = $eventosRestantes > 0;
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Criar Evento - Sistema de Eventos</title>
<link rel="stylesheet" href="styles.css">
<style>
body {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
min-height: 100vh;
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px 30px;
border-radius: 15px;
margin-bottom: 30px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.card {
background: white;
border-radius: 15px;
padding: 30px;
margin-bottom: 30px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
}
.cliente-info {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
border-radius: 15px;
margin-bottom: 30px;
text-align: center;
box-shadow: 0 15px 35px rgba(102, 126, 234, 0.3);
}
.cliente-email {
font-size: 24px;
font-weight: bold;
margin-bottom: 15px;
}
.limite-info {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 20px;
margin-top: 20px;
}
.limite-item {
background: rgba(255, 255, 255, 0.15);
padding: 20px;
border-radius: 12px;
text-align: center;
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.limite-item:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}
.limite-numero {
font-size: 32px;
font-weight: bold;
display: block;
margin-bottom: 8px;
}
.limite-label {
font-size: 14px;
opacity: 0.9;
}
.progresso-bar {
background: rgba(255, 255, 255, 0.2);
height: 10px;
border-radius: 5px;
margin-top: 20px;
overflow: hidden;
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}
.progresso-fill {
background: linear-gradient(90deg, #4CAF50, #45a049);
height: 100%;
transition: width 0.3s ease;
border-radius: 5px;
}
.progresso-fill.warning {
background: linear-gradient(90deg, #FF9800, #f57c00);
}
.progresso-fill.danger {
background: linear-gradient(90deg, #f44336, #d32f2f);
}
.alerta {
padding: 20px;
border-radius: 12px;
margin-bottom: 25px;
text-align: center;
border: none;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.alerta.sucesso {
background: linear-gradient(135deg, #d4edda, #c3e6cb);
color: #155724;
}
.alerta.aviso {
background: linear-gradient(135deg, #fff3cd, #ffeaa7);
color: #856404;
}
.alerta.erro {
background: linear-gradient(135deg, #f8d7da, #f5c6cb);
color: #721c24;
}
.form-disabled {
opacity: 0.6;
pointer-events: none;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 600;
font-size: 14px;
}
.form-row {
display: flex;
flex-wrap: wrap;
gap: 20px;
margin-bottom: 20px;
}
.form-row .form-group {
flex: 1;
min-width: 200px;
margin-bottom: 0;
}
.form-row .form-group.col-4 {
flex-basis: calc(33.333% - 13.333px);
}
.form-row .form-group.col-6 {
flex-basis: calc(50% - 10px);
}
@media (max-width: 768px) {
.form-row .form-group.col-4,
.form-row .form-group.col-6 {
flex-basis: 100%;
}
}
.form-group input, .form-group textarea, .form-group select {
width: 100%;
padding: 15px;
border: 2px solid #e1e5e9;
border-radius: 10px;
font-size: 16px;
transition: all 0.3s ease;
box-sizing: border-box;
background: #f8f9fa;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
outline: none;
border-color: #667eea;
background: white;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 15px 30px;
border-radius: 10px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
width: 100%;
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}
.btn-primary:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}
.btn-primary:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.eventos-criados {
margin-top: 30px;
}
.eventos-criados h2 {
color: #333;
margin-bottom: 20px;
font-size: 24px;
}
.evento-item {
background: white;
border: none;
border-radius: 12px;
padding: 20px;
margin-bottom: 15px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
transition: all 0.3s ease;
}
.evento-item:hover {
transform: translateY(-3px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}
.evento-info h4 {
margin: 0 0 8px 0;
color: #333;
font-size: 18px;
}
.evento-info p {
margin: 0;
color: #666;
font-size: 14px;
line-height: 1.5;
}
.evento-data {
color: #667eea;
font-weight: bold;
font-size: 16px;
padding: 8px 16px;
background: rgba(102, 126, 234, 0.1);
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
}
.evento-data:hover {
background: rgba(102, 126, 234, 0.2);
transform: scale(1.05);
}
.evento-item.selected {
border: 2px solid #667eea;
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
}
.nav-buttons {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 15px;
}
.nav-btn {
display: flex;
align-items: center;
padding: 20px;
background: white;
border: 2px solid #e1e5e9;
border-radius: 12px;
text-decoration: none;
color: #333;
transition: all 0.3s ease;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.nav-btn:hover {
transform: translateY(-3px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
border-color: #667eea;
}
.nav-btn.admin-btn:hover {
border-color: #667eea;
background: linear-gradient(135deg, #f8f9ff, #e8ebff);
}
.nav-btn.checklist-btn:hover {
border-color: #4CAF50;
background: linear-gradient(135deg, #f1f8e9, #e8f5e8);
}
.nav-btn.entrada-btn:hover {
border-color: #FF9800;
background: linear-gradient(135deg, #fff8e1, #ffecb3);
}
.nav-btn.relatorio-btn:hover {
border-color: #2196F3;
background: linear-gradient(135deg, #e3f2fd, #bbdefb);
}
.nav-btn.index-btn:hover {
border-color: #9C27B0;
background: linear-gradient(135deg, #f3e5f5, #e1bee7);
}
.nav-icon {
font-size: 24px;
margin-right: 15px;
min-width: 40px;
text-align: center;
}
.nav-content strong {
display: block;
font-size: 16px;
margin-bottom: 4px;
}
.nav-content small {
color: #666;
font-size: 12px;
}
@media (max-width: 768px) {
.container {
padding: 15px;
}
.card {
padding: 20px;
}
.cliente-info {
padding: 20px;
}
.limite-info {
grid-template-columns: 1fr;
}
.evento-item {
flex-direction: column;
align-items: flex-start;
gap: 15px;
}
.evento-data {
align-self: flex-end;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<div style="display: flex; justify-content: space-between; align-items: center;">
<h1>🎉 Criar Novo Evento</h1>
<a href="logout_cliente.php?token=<?php echo urlencode($token); ?>"
style="background: rgba(255,255,255,0.2); color: white; padding: 8px 16px; border-radius: 5px; text-decoration: none; font-size: 14px;">
🚪 Sair
</a>
</div>
</header>
<!-- Informações do Cliente -->
<div class="card cliente-info">
<div class="cliente-email">Bem-vindo, <?php echo htmlspecialchars($cliente["email"]); ?>!</div>
<p>Aqui você pode criar e gerenciar seus eventos</p>
<div class="limite-info">
<div class="limite-item">
<span class="limite-numero"><?php echo $cliente["limite_eventos_mensal"]; ?></span>
<div class="limite-label">Limite Mensal</div>
</div>
<div class="limite-item">
<span class="limite-numero"><?php echo $cliente["eventos_criados_mes_atual"]; ?></span>
<div class="limite-label">Eventos Criados</div>
</div>
<div class="limite-item">
<span class="limite-numero"><?php echo $eventosRestantes; ?></span>
<div class="limite-label">Eventos Restantes</div>
</div>
</div>
<?php
$progressoPercentual = $cliente["limite_eventos_mensal"] > 0 ?
($cliente["eventos_criados_mes_atual"] / $cliente["limite_eventos_mensal"]) * 100 : 0;
$progressoClass = '';
if ($progressoPercentual >= 90) $progressoClass = 'danger';
elseif ($progressoPercentual >= 70) $progressoClass = 'warning';
?>
<div class="progresso-bar">
<div class="progresso-fill <?php echo $progressoClass; ?>"
style="width: <?php echo min($progressoPercentual, 100); ?>%"></div>
</div>
</div>
<!-- Alertas -->
<?php if (!$podecriarEvento): ?>
<div class="alerta erro">
<strong>Limite Atingido!</strong><br>
Você já utilizou todos os seus eventos disponíveis para este mês (<?php echo $cliente['eventos_criados_mes_atual']; ?>/<?php echo $cliente['limite_eventos_mensal']; ?>).
<br>Seu limite será renovado no próximo mês.
</div>
<?php elseif ($eventosRestantes <= 2): ?>
<div class="alerta aviso">
<strong>Atenção!</strong><br>
Você tem apenas <?php echo $eventosRestantes; ?> evento(s) restante(s) para este mês.
</div>
<?php endif; ?>
<!-- Formulário de Criação de Evento -->
<div class="card <?php echo !$podecriarEvento ? 'form-disabled' : ''; ?>">
<h2>📝 Criar Novo Evento</h2>
<form id="eventoForm" <?php echo !$podecriarEvento ? 'disabled' : ''; ?>>
<input type="hidden"
(Content truncated due to size limit. Use line ranges to read in chunks)