86 lines
2.6 KiB
PHP
86 lines
2.6 KiB
PHP
<?php
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit();
|
|
}
|
|
|
|
// Conectar ao banco de dados
|
|
$mysqli = new mysqli("10.15.0.42", "root", "34641747", "valida");
|
|
|
|
if ($mysqli->connect_error) {
|
|
die("Connection failed: " . $mysqli->connect_error);
|
|
}
|
|
|
|
// Buscar histórico de documentos processados
|
|
$query = "SELECT pd.*, u.username FROM processed_documents pd
|
|
LEFT JOIN users u ON pd.user_id = u.id
|
|
ORDER BY pd.created_at DESC";
|
|
$result = $mysqli->query($query);
|
|
?>
|
|
|
|
<div class="container">
|
|
<h2>Histórico de Documentos Processados</h2>
|
|
|
|
<table class="data-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Data/Hora</th>
|
|
<th>Usuário</th>
|
|
<th>Documento Original</th>
|
|
<th>Documento Processado</th>
|
|
<th>Ações</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php while ($row = $result->fetch_assoc()): ?>
|
|
<tr>
|
|
<td><?php echo date('d/m/Y H:i:s', strtotime($row['created_at'])); ?></td>
|
|
<td><?php echo htmlspecialchars($row['username']); ?></td>
|
|
<td>
|
|
<a href="<?php echo htmlspecialchars($row['original_path']); ?>" target="_blank">
|
|
Ver Original
|
|
</a>
|
|
</td>
|
|
<td>
|
|
<a href="<?php echo htmlspecialchars($row['processed_path']); ?>" target="_blank">
|
|
Ver Processado
|
|
</a>
|
|
</td>
|
|
<td>
|
|
<button onclick="deleteDocument(<?php echo $row['id']; ?>)" class="delete-btn">
|
|
Excluir
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
<?php endwhile; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<script>
|
|
function deleteDocument(id) {
|
|
if (confirm('Tem certeza que deseja excluir este documento?')) {
|
|
fetch('delete_document.php', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({id: id})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
alert('Documento excluído com sucesso!');
|
|
location.reload();
|
|
} else {
|
|
alert('Erro ao excluir documento: ' + data.message);
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
alert('Erro ao excluir documento');
|
|
});
|
|
}
|
|
}
|
|
</script>
|