Merge remote-tracking branch 'origin/master'
commit
b1c578452c
|
@ -50,8 +50,9 @@
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$ID = $_GET['ausleihID'];
|
|
||||||
$BookID = $_GET['buchID'];
|
$BookID = $_GET['buchID'];
|
||||||
|
|
||||||
$servername = "localhost";
|
$servername = "localhost";
|
||||||
$username = "web_b-3";
|
$username = "web_b-3";
|
||||||
$password = "een7Ao6s";
|
$password = "een7Ao6s";
|
||||||
|
@ -63,11 +64,79 @@ $connection =
|
||||||
if (!$connection) {
|
if (!$connection) {
|
||||||
die("Verbindung fehlgeschlagen: " . mysqli_connect_error());
|
die("Verbindung fehlgeschlagen: " . mysqli_connect_error());
|
||||||
}
|
}
|
||||||
$sql = $connection->prepare("
|
|
||||||
DELETE FROM `ausgeliehenes_buch` WHERE `ausgeliehenes_buch`.`AusleihID` = ?;
|
$sqlDelete = $connection->prepare("
|
||||||
UPDATE `buch` SET `Anzahl` = Anzahl+1 WHERE `buch`.`BuchID` = ? ;
|
DELETE FROM `ausgeliehenes_buch` WHERE `ausgeliehenes_buch`.`AusleihID` = ?;");
|
||||||
");
|
$sqlDelete->bind_param("i", $ID);
|
||||||
$sql->bind_param("ii", $ID, $BookID);
|
$ID = $_GET['ausleihID'];
|
||||||
|
// SQL-Befehl ausführen
|
||||||
|
$sqlDelete->execute();
|
||||||
|
|
||||||
|
$sqlGetQuantity = $connection->prepare(
|
||||||
|
"SELECT Anzahl, MaxAnzahl FROM `buch` WHERE BuchID = ?;");
|
||||||
|
$sqlGetQuantity->bind_param("i", $BookID);
|
||||||
|
$sqlGetQuantity->execute();
|
||||||
|
// Ergebnis speichern
|
||||||
|
$resultGetQuantity = $sqlGetQuantity->get_result();
|
||||||
|
if (mysqli_num_rows($resultGetQuantity) > 0) {
|
||||||
|
while($rowGetQuantity = mysqli_fetch_assoc($resultGetQuantity)) {
|
||||||
|
$bookQuantity = $rowGetQuantity['Anzahl'];
|
||||||
|
$bookMaxQuantity = $rowGetQuantity['MaxAnzahl'];
|
||||||
|
$bookTempQuantity = $bookQuantity + 1;
|
||||||
|
$bookTempQuantityNew = $bookMaxQuantity - $bookTempQuantity;
|
||||||
|
|
||||||
|
$sqlGetBorrowedQuantity = $connection->prepare(
|
||||||
|
"SELECT COUNT(*) AS Ausgeliehen
|
||||||
|
FROM `ausgeliehenes_buch` WHERE BuchID = ?;"
|
||||||
|
);
|
||||||
|
$sqlGetBorrowedQuantity->bind_param("i", $BookID);
|
||||||
|
$sqlGetBorrowedQuantity->execute();
|
||||||
|
// Ergebnis speichern
|
||||||
|
$resultGetBorrowedQuantity = $sqlGetBorrowedQuantity->get_result();
|
||||||
|
if (mysqli_num_rows($resultGetBorrowedQuantity) > 0) {
|
||||||
|
while($rowGetBorrowedQuantity = mysqli_fetch_assoc($resultGetBorrowedQuantity)) {
|
||||||
|
$bookBorrowedQuantity = $rowGetBorrowedQuantity['Ausgeliehen'];
|
||||||
|
|
||||||
|
if ($bookBorrowedQuantity == $bookTempQuantityNew) {
|
||||||
|
$sqlUpdateBook = $connection->prepare(
|
||||||
|
"UPDATE buch SET Anzahl = Anzahl+1
|
||||||
|
WHERE buch.BuchID = ? ;"
|
||||||
|
);
|
||||||
|
$sqlUpdateBook->bind_param("i", $BookID);
|
||||||
|
$sqlUpdateBook->execute();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sqlGetBorrowedID = $connection->prepare(
|
||||||
|
"SELECT AusleihID
|
||||||
|
FROM `ausgeliehenes_buch`
|
||||||
|
WHERE BuchID = ?
|
||||||
|
AND Reserviert=1
|
||||||
|
ORDER BY Enddatum
|
||||||
|
DESC LIMIT 1;"
|
||||||
|
);
|
||||||
|
$sqlGetBorrowedID->bind_param("i", $BookID);
|
||||||
|
$sqlGetBorrowedID->execute();
|
||||||
|
// Ergebnis speichern
|
||||||
|
$resultGetBorrowedID = $sqlGetBorrowedID->get_result();
|
||||||
|
if (mysqli_num_rows($resultGetBorrowedID) > 0) {
|
||||||
|
while($rowGetBorrowedID = mysqli_fetch_assoc($resultGetBorrowedID)) {
|
||||||
|
$bookBorrowedID = $rowGetBorrowedID['AusleihID'];
|
||||||
|
$sqlUpdateBookID = $connection->prepare(
|
||||||
|
"UPDATE `ausgeliehenes_buch`
|
||||||
|
SET `Verlängerbar` = '1',
|
||||||
|
`Reserviert` = '0'
|
||||||
|
WHERE `ausgeliehenes_buch`.`AusleihID` = ?;"
|
||||||
|
);
|
||||||
|
$sqlUpdateBookID->bind_param("i", $bookBorrowedID);
|
||||||
|
$sqlUpdateBookID->execute();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue