-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_books.php
More file actions
177 lines (169 loc) · 7.17 KB
/
admin_books.php
File metadata and controls
177 lines (169 loc) · 7.17 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
<?php
include 'includes/dbcon.php';
?>
<?php
if (isset($_POST['submit'])) {
$book_id = $_POST['book-id'];
$book_edition = $_POST['book-edition'];
$book_year = $_POST['book-year'];
$book_title = $_POST['book-title'];
$book_authors = $_POST['book-authors'];
$book_publisher = $_POST['book-editor'];
$book_eudoxus_id = $_POST['book-eudoxus-id'];
$book_isbn = $_POST['book-isbn'];
$sql = "INSERT INTO book (id, title, authors, publisher, edition, year, eudoxus_id, isbn) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$book_id, $book_title, $book_authors, $book_publisher, $book_edition, $book_year, $book_eudoxus_id, $book_isbn]);
header('Location: ' . $_SERVER['PHP_SELF']);
}
?>
<?php
if (isset($_GET['book_id'])) {
$book_id = $_GET['book_id'];
$sql = "DELETE FROM book WHERE id = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$book_id]);
header('Location: ' . $_SERVER['PHP_SELF']);
}
?>
<?php
$sql = "SELECT * FROM book";
$stmt = $pdo->prepare($sql);
$stmt->execute();
$number_of_books = $stmt->rowCount();
$books = $stmt->fetchAll();
?>
<?php include "includes/header.php"; ?>
<!-- Begin Page Content -->
<div class="container-fluid">
<div class="mb-3">
<h1 class="h3 mb-0 text-gray-800">Σύνοψη</h1>
</div>
<div class="row">
<div class="col-xl-3 col-md-6 mb-4">
<a role="button" href="<?php $_SERVER['PHP_SELF']; ?>" class="btn-outline-light card border-left-primary shadow py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Βιβλιογραφια</div>
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $number_of_books; ?></div>
</div>
<div class="col-auto">
<i class="fas fa-bookmark fa-3x text-gray-300"></i>
</div>
</div>
</div>
</a>
</div>
</div>
<div class="my-3">
<h1 class="h3 mb-0 text-gray-800">Βιβλιογραφία</h1>
</div>
<div class="shadow">
<div class="card-header py-3">
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#newBook" role="button" aria-expanded="false" aria-controls="newBook">
Εισαγωγή Συγγράμματος
</a>
</p>
<div class="collapse" id="newBook">
<div class="card card-body">
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST" id="new-book-form">
<div class="form-row error-message error-new-book">
<div class="alert alert-danger" role="alert">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4 required">
<label for="book-id" class="font-weight-bold text-gray-800 col-form-label">Κωδικός:</label>
<input type="text" class="form-control" name="book-id" id="book-id">
</div>
<div class="form-group col-md-8 required">
<label for="book-title" class="font-weight-bold text-gray-800 col-form-label">Τίτλος Συγγράμματος</label>
<input type="text" class="form-control" name="book-title" id="book-title">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="book-edition" class="font-weight-bold text-gray-800 col-form-label">Έκδοση:</label>
<input type="text" class="form-control" name="book-edition" id="book-edition">
</div>
<div class="form-group col-md-6">
<label for="book-year" class="font-weight-bold text-gray-800 col-form-label">Έτος Έκδοσης:</label>
<input type="text" class="form-control" name="book-year" id="book-year">
</div>
</div>
<div class="form-group">
<label for="book-authors" class="font-weight-bold text-gray-800 col-form-label">Συγγραφείς:</label>
<input type="text" class="form-control" name="book-authors" id="book-authors">
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="book-editor" class="font-weight-bold text-gray-800 col-form-label">Εκδότης:</label>
<input type="text" class="form-control" name="book-editor" id="book-editor">
</div>
<div class="form-group col-md-4">
<label for="book-eudoxus-id" class="font-weight-bold text-gray-800 col-form-label">Κωδικός στον Εύδοξο:</label>
<input type="text" class="form-control" name="book-eudoxus-id" id="book-eudoxus-id">
</div>
<div class="form-group col-md-4">
<label for="book-isbn" class="font-weight-bold text-gray-800 col-form-label">ISBN:</label>
<input type="text" class="form-control" name="book-isbn" id="book-isbn">
</div>
</div>
<div class="form-group">
<input type="submit" class="btn btn-success float-right" name="submit">
</div>
</form>
</div>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="adminCourseTable" class="table table-bordered table-hover editTable" style="width:100%">
<thead>
<tr>
<th>Κωδικός</th>
<th>Τίτλος</th>
<th>Συγγραφείς</th>
<th>Τροποποίση</th>
<th>Διαγραφή</th>
</tr>
</thead>
<tbody>
<!-- Εμφάνιση Λίστας -->
<?php
foreach ($books as $book) :
?>
<tr>
<td><a href=book.php?book_id=<?php echo $book['id']; ?> class="text-gray-600"><?php echo $book['id']; ?></a></td>
<td><?php echo $book['title']; ?></td>
<td><?php echo $book['authors']; ?></td>
<td class='editField'><a href="edit_book.php?book_id=<?php echo $book['id']; ?>"><i class="far fa-edit text-warning"></i></a></td>
<td class='editField'><a href="admin_books.php?book_id=<?php echo $book['id']; ?>" onclick="return confirm('Είσαι σίγουρος ότι θέλεις να διαγράψεις το συγκεκριμένο βιβλίο;');"><i class='fas fa-trash-alt delete-item'></i></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<?php include "includes/footer.php"; ?>
<script>
$(document).ready(function() {
$('#adminCourseTable').DataTable();
});
$('tbody tr td:not(:last-child, :nth-child(4))').click(function() {
var tr = $(this).closest('tr');
window.location = tr.find('a').attr('href');
});
$('tbody tr td:not(:last-child, :nth-child(4))').hover(function() {
var tr = $(this).closest('tr');
tr.toggleClass('hover');
console.log($(this));
});
</script>