260 lines
No EOL
12 KiB
PHP
260 lines
No EOL
12 KiB
PHP
<!DOCTYPE html>
|
|
<html>
|
|
<?php
|
|
include "db/bootstrap.php";
|
|
include "db/functions.php";
|
|
|
|
session_start();
|
|
|
|
|
|
if(empty($_SESSION['csrf_token'])){
|
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
|
}
|
|
|
|
$books = getBooks($pdo);
|
|
$borrowers = getBorrowers($pdo);
|
|
$activeLoans = getActiveLoans($pdo);
|
|
$lateLoans = getLateLoans($pdo);
|
|
|
|
?>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<link rel="stylesheet" href="style.css">
|
|
<title>Bücherei Verwaltung</title>
|
|
</head>
|
|
<body>
|
|
<h1>Bücherei Verwaltung</h1>
|
|
<br>
|
|
<table>
|
|
<td>
|
|
<h2>Neues Buch hinzufügen</h2>
|
|
<form id="bookForm">
|
|
<label>Titel
|
|
<br>
|
|
<input type="text" name="title" required>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Autor
|
|
<br>
|
|
<input type="text" name="author" required>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Lernfeld
|
|
<br>
|
|
<input type="text" name="area" required>
|
|
</label>
|
|
<input type="hidden" name="submissionType" value="book">
|
|
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
|
<br>
|
|
<br>
|
|
<button type="submit">Buch hinzufügen</button>
|
|
</form>
|
|
</td>
|
|
<td>
|
|
<h2>Neue Exemplare hinzufügen</h2>
|
|
<form id="copyForm">
|
|
<label>Buch
|
|
<br>
|
|
<select name="book" required>
|
|
<option value="">Wähle ein Buch</option>
|
|
<?php foreach ($books as $book): ?>
|
|
<option value="<?= htmlspecialchars($book['bookID'])?>">
|
|
<?= htmlspecialchars($book['title'] . " by " . $book['author'])?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Anzahl
|
|
<br>
|
|
<input type="number" name="amount" value="1" required>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Zustand
|
|
<br>
|
|
<input type="text" name="condition" required>
|
|
</label>
|
|
<input type="hidden" name="submissionType" value="copy">
|
|
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
|
<br>
|
|
<br>
|
|
<button type="submit">Exemplare hinzufügen</button>
|
|
</form>
|
|
</td>
|
|
<td>
|
|
<h2>Ausleiher hinzufügen</h2>
|
|
<form id="borrowerForm">
|
|
<label>Vorname
|
|
<br>
|
|
<input type="name" name="firstname" required>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Nachname
|
|
<br>
|
|
<input type="name" name="lastname" required>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Klasse/Funktion
|
|
<br>
|
|
<input type="text" name="role" required>
|
|
</label>
|
|
<input type="hidden" name="submissionType" value="borrower">
|
|
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
|
<br>
|
|
<br>
|
|
<button type="submit">Ausleiher hinzufügen</button>
|
|
</form>
|
|
</td>
|
|
<td>
|
|
<h2>Buch verleihen</h2>
|
|
<form id="loanForm">
|
|
<label>Ausleiher
|
|
<br>
|
|
<select name="borrowerID" required>
|
|
<option value="">Wähle einen Ausleiher</option>
|
|
<?php foreach ($borrowers as $borrower): ?>
|
|
<option value="<?= htmlspecialchars($borrower['borrowerID'])?>">
|
|
<?= htmlspecialchars($borrower['lastName'] . ", " . $borrower['firstName'] . " (" . $borrower['role'] . ")")?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Buch
|
|
<br>
|
|
<select id="bookSelect" name="book" required>
|
|
<option value="">Wähle ein Buch</option>
|
|
<?php foreach ($books as $book): ?>
|
|
<option value="<?= htmlspecialchars($book['bookID'])?>">
|
|
<?= htmlspecialchars($book['title'] . " von " . $book['author'])?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Exemplar
|
|
<br>
|
|
<select id="copySelect" name="copyID">
|
|
<option value="">Bitte zuerst ein Buch wählen</option>
|
|
</select>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Ausleihdatum
|
|
<br>
|
|
<input type="date" name="borrowedDate" value="<?=date("Y-m-d");?>">
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Rückgabedatum
|
|
<br>
|
|
<input type="date" name="dueDate" value="<?=date_add(date_create(date('Y-m-d')), date_interval_create_from_date_string('14 days'))->format('Y-m-d');?>">
|
|
</label>
|
|
<input type="hidden" name="submissionType" value="loan">
|
|
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
|
<br>
|
|
<br>
|
|
<button type="submit">Buch verleihen</button>
|
|
</form>
|
|
</td>
|
|
<td>
|
|
<h2>Buch einsammeln</h2>
|
|
<form id="checkInForm">
|
|
<label>Ausleiher wählen
|
|
<br>
|
|
<select id="borrowerSelect">
|
|
<option value="">Wähle einen Ausleiher</option>
|
|
<?php foreach ($borrowers as $borrower): ?>
|
|
<option value="<?= htmlspecialchars($borrower['borrowerID'])?>">
|
|
<?= htmlspecialchars($borrower['firstName'] . " " . $borrower['lastName'])?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Wähle ein Exemplar
|
|
<br>
|
|
<select id="copyReturnSelect" name="copyID-loanID">
|
|
<option>Bitte zuerst einen Ausleiher wählen</option>
|
|
</select>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<label>Zurückgegeben am
|
|
<br>
|
|
<input type="date" name="returnedDate" value=<?= date("Y-m-d") ?>>
|
|
</label>
|
|
<br>
|
|
<br>
|
|
<button type="submit">Buch einsammeln</button>
|
|
<input type="hidden" name="submissionType" value="return">
|
|
<input type="hidden" name="csrf_token" value=<?= $_SESSION['csrf_token'] ?>>
|
|
</form>
|
|
</td>
|
|
<table>
|
|
<td>
|
|
<h2>Verliehene Bücher</h2>
|
|
<table>
|
|
<th>Vorname</th><th>Nachname</th><th>Klasse/Funktion</th><th>Buch</th><th>Exemplar</th><th>Ausleihdatum</th><th>Rückgabe fällig</th>
|
|
<?php foreach ($activeLoans as $loan): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($loan['firstName'])?></td>
|
|
<td><?= htmlspecialchars($loan['lastName'])?></td>
|
|
<td><?= htmlspecialchars($loan['borrowerRole'])?></td>
|
|
<td><?= htmlspecialchars($loan['bookTitle'])?></td>
|
|
<td>#<?= htmlspecialchars($loan['copyID'])?></td>
|
|
<td><?= date_create($loan['borrowedDate'])->format("d.m.Y")?></td>
|
|
<td><?= date_create($loan['dueDate'])->format("d.m.Y")?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
</td>
|
|
<td>
|
|
<h2>Versäumte Rückgaben</h2>
|
|
<table>
|
|
<th>Vorname</th><th>Nachname</th><th>Klasse/Funktion</th><th>Buch</th><th>Exemplar</th><th>Ausleihdatum</th><th>Rückgabe fällig</th>
|
|
<?php foreach ($lateLoans as $lateLoan): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($lateLoan['firstName'])?></td>
|
|
<td><?= htmlspecialchars($lateLoan['lastName'])?></td>
|
|
<td><?= htmlspecialchars($lateLoan['borrowerRole'])?></td>
|
|
<td><?= htmlspecialchars($lateLoan['bookTitle'])?></td>
|
|
<td>#<?= htmlspecialchars($lateLoan['copyID'])?></td>
|
|
<td><?= date_create($lateLoan['borrowedDate'])->format("d.m.Y")?></td>
|
|
<td><?= date_create($lateLoan['dueDate'])->format("d.m.Y")?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
</td>
|
|
</table>
|
|
<table>
|
|
<td>
|
|
<h2>Datenbank durchsuchen</h2>
|
|
<form id="sqlSelectInputForm">
|
|
<label>
|
|
SELECT <input style="width: 500px;" type="text" name="sqlSelectTextarea" placeholder="* FROM books WHERE bookID = 5" required></input>
|
|
</label>
|
|
<input type="hidden" name="submissionType" value="selectRequest">
|
|
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
|
<br>
|
|
<br>
|
|
<button type="submit">Abschicken</button>
|
|
</form>
|
|
</td>
|
|
</table>
|
|
</table>
|
|
<br>
|
|
<div id="result"></div>
|
|
|
|
<?php include "script.php" ?>
|
|
</body>
|
|
</html>
|