-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBooks.php
85 lines (80 loc) · 3.22 KB
/
Books.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
<html>
<head>
<title>Книги</title>
<?php require_once "back/connect.php";?>
<?php require_once "Classes/Book.php";?>
<style>
dialog {
background: rgba(255, 255, 255, 0.7);
width: 300px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
border-radius: 5px;
}
#books tr > *:nth-child(1) {
display: none;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="js/ajax.js"></script>
<script src="js/book/script.js"></script>
</head>
<body>
<input type="button" onclick="document.location='index.php'" value="Назад">
<div>
<?php $stmt = $pdo->query('SELECT * FROM book');?>
<?php $stmt->setFetchMode( PDO::FETCH_CLASS, 'book');?>
<table id="books" style="border-style: solid">
<thead>
<th>ID</th>
<th>Название</th>
<th>Автор</th>
<th>Издательство</th>
<th>Год</th>
<th>ISBN</th>
<th>Количество экземпляров</th>
<th>Экземпляров в наличии</th>
</thead>
<tbody>
<?php while($row = $stmt->fetch()) {?>
<tr>
<td><?php echo $row->getIdbook()?></td>
<td><?php echo $row->getName()?></td>
<td><?php echo $row->getAuthor()?></td>
<td><?php echo $row->getPublishingHouse()?></td>
<td><?php echo $row->getYearOfPublishing()?></td>
<td><?php echo $row->getISBN()?></td>
<td><?php echo $row->getCount()?></td>
<td><?php echo $row->getCurrentCount()?></td>
<td><a id='editbtnBook' data-id = <?php echo $row->getIdbook() ?> href='javascript:void(0)'>Редактировать</a></td>
<td><a class='delbtn' data-id=<?php echo $row->getIdbook() ?> href='javascript:void(0)'>Удалить</a></td>
</tr>
<?php } ?>
</tbody>
</table>
<div>
<input type="button" id="openDialog" value="Добавить">
<input type="button" id="updateBooks" onclick="updateBooks()" value="Обновить">
</div>`
</div>
<dialog>
<?php require_once "bookForm.php" ?>
<p>
<input type="submit" id="bookSubmit" value="Ок" form="book">
<input type="button" id="closeDialog" value="Отмена">
</p>
</dialog>
<script>
var dlg = document.querySelector('dialog');
document.querySelector('#openDialog').onclick = function() {
dlg.show();
}
document.querySelector('#closeDialog').onclick = function() {
$('form input[type="text"] , form input[type="number"').val('');
$('#book').prop('title', '');
dlg.close();
//window.location.reload(1);
}
</script>
</body>
</html>