-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthorbooks.php
136 lines (111 loc) · 5.44 KB
/
authorbooks.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
<?php
session_start();
require_once './src/classes/Connection.php'; // Certifique-se de que o caminho está correto
require_once './src/classes/Book.php';
if (empty($_SESSION)) {
header("Location: ./login.php");
exit();
}
$connection = Connection::Connect();
// Aqui você pode acessar os dados da sessão
$userId = $_SESSION['user_id'] ?? '0';
$userName = $_SESSION['user_name'] ?? 'Visitante';
$userEmail = $_SESSION['user_email'] ?? 'Não definido';
$userAccess = $_SESSION['user_access'] ?? 'Simples';
$books = Book::getBooksByAuthorId($userId);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- MATERIAL ICONS GOOGLE -->
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" rel="stylesheet" />
<!-- LINK BOOTSTRAP CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- LINK CSS -->
<link rel="stylesheet" href="./src/css/global.css">
<title>Home</title>
</head>
<body class="bg">
<div class="container mt-3">
<div class="d-flex justify-content-center position-relative mx-2">
<a href="./index.php">
<span class=" material-symbols-outlined position-absolute start-0">
arrow_back
</span>
</a>
<div class="fs-5 fw-bold text-primary text-center w-100">Meus livros</div>
</div>
<div class="d-flex justify-content-center">
<div class="search-container my-3" style="width: 400px;">
<div type="submit" class="material-symbols-outlined search-icon">search</div>
<input class="input-search" type="text" name="searchAll" id="searchAll" placeholder="Pesquisar" autocomplete="off">
</div>
</div>
<div>
<!-- Tabela de livros -->
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th scope="col" style="width: 10%;">ID</th>
<th scope="col" style="width: 70%;">Título</th>
<th scope="col" style="width: 20%;">Ações</th>
</tr>
</thead>
<tbody id="bookTableBody">
<?php if (!empty($books)): ?>
<?php foreach ($books as $book): ?>
<tr>
<td><?php echo htmlspecialchars($book['id']); ?></td>
<td class="text-truncate" style="max-width: 0;">
<?php echo htmlspecialchars($book['title']); ?>
</td>
<td>
<div class="d-flex flex-column flex-md-row">
<a href="#" data-bs-toggle="modal" data-bs-target="#editBook-<?= $book['id'] ?>" class="btn btn-white btn-sm mb-1 mb-md-0 me-md-1 w-100">
<i class="fa-regular fa-pen-to-square"></i>
</a>
<a href="./src/backend/deletebook.php?book_id=<?= $book['id'] ?>" class="btn btn-default btn-sm w-100">
<i class="fa-regular fa-trash-can"></i>
</a>
</div>
</td>
</tr>
<?php
require "./src/widgets/modal/edit-book.php";
endforeach;
?>
<?php else: ?>
<tr>
<td colspan="3" class="text-center">Nenhum livro encontrado.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- LINK BOOTSTRAP JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
<script>
document.getElementById('searchAll').addEventListener('input', function() {
const searchValue = this.value.toLowerCase().trim();
const rows = document.querySelectorAll('#bookTableBody tr');
rows.forEach(row => {
const title = row.querySelector('td:nth-child(2)').textContent.toLowerCase().trim();
if (title.includes(searchValue)) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
});
</script>
</body>
</html>