-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsultar-registros.php
157 lines (139 loc) · 6.57 KB
/
consultar-registros.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
<?php
// Define o local e nome do arquivo
$target_file = "./db/csv/Lista.csv";
// Verifica se o arquivo já existe
if (file_exists($target_file)) {
$dados = array_map('str_getcsv', file($target_file));
array_walk($dados, function(&$a) use ($dados) {
$a = array_combine($dados[0], $a);
});
array_shift($dados);
} else {
echo "<script>alert('Não existe nenhum registro!');window.location.href='index.php';</script>";
}
/*
$dados = array_map('str_getcsv', file($arquivo));
array_walk($dados, function(&$a) use ($dados) {
$a = array_combine($dados[0], $a);
});
array_shift($dados);*/
if (isset($_POST['download-qr']))
{
$caminho = './svg/auto/';
$zip = new ZipArchive();
$nomeZip = 'QrCode.zip';
if ($zip->open($nomeZip, ZipArchive::CREATE) !== TRUE) {
exit("Não foi possível criar o arquivo zip");
}
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($caminho));
foreach ($iterator as $key=>$value) {
if (!$value->isDir()) {
$caminhoArquivo = $value->getRealPath();
$nomeArquivo = $value->getBasename();
$zip->addFile($caminhoArquivo, $nomeArquivo);
}
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=' . $nomeZip);
header('Content-Length: ' . filesize($nomeZip));
readfile($nomeZip);
unlink($nomeZip); // Exclui o arquivo zip após o download
}
if (isset($_POST['apagar-registros']))
{
$csv_dir = './db/csv/';
$manual_dir = './svg/manual/';
$auto_dir = './svg/auto/';
// Excluindo arquivos dentro do diretório ./db/csv/
if ($handle = opendir($csv_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
unlink($csv_dir . $file);
}
}
closedir($handle);
}
// Excluindo arquivos dentro do diretório ./svg/manual/
if ($handle = opendir($manual_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
unlink($manual_dir . $file);
}
}
closedir($handle);
}
// Excluindo arquivos dentro do diretório ./svg/auto/
if ($handle = opendir($auto_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
unlink($auto_dir . $file);
}
}
closedir($handle);
//header('Location: qr-auto.php');
}
echo "<script>alert('Registros excluidos com sucesso!');window.location.href='index.php';</script>";
}
?>
<!DOCTYPE html>
<html lang="pt">
<head>
<title>QR Code</title>
<meta charset="UTF-8" >
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/js/bootstrap.min.js"></script>
<?php include("cabecalho.php") ?>
<head>
<body>
<div class="container py-5">
<div class="row justify-content-center">
<div class="col-md-18">
<div class="card border-0 shadow">
<div class="card-body p-4">
<h2 class="mb-4 text-center">QR Codes gerados</h2>
<form action="consultar-registros.php" method="post">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Nome</th>
<th scope="col">Cargo</th>
<th scope="col">Departamento</th>
<th scope="col">E-mail</th>
<th scope="col">Celular</th>
<th scope="col">Ramal</th>
</tr>
</thead>
<tbody>
<?php foreach ($dados as $dado) { ?>
<tr>
<td><?php echo $dado['DisplayName']; ?></td>
<td><?php echo $dado['Title']; ?></td>
<td><?php echo $dado['Department']; ?></td>
<td><?php echo $dado['Mail']; ?></td>
<td><?php echo $dado['Mobile']; ?></td>
<td><?php echo $dado['TelephoneNumber']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="d-flex justify-content-center">
<button type="submit" style="margin-left: 10px;" name="download-qr" class="btn btn-success shadow"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-download" viewBox="0 0 16 16"><path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"></path><path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"></path></svg>
DOWNLOAD
</button> <br>
<button type="submit" style="margin-left: 10px;" name="apagar-registros" class="btn btn-danger shadow"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-trash3" viewBox="0 0 16 16"><path d="M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.506a.58.58 0 0 0-.01 0H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1h-.995a.59.59 0 0 0-.01 0H11Zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5h9.916Zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47ZM8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5Z"></path></svg>
APAGAR REGISTROS
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>