Verlängerung
parent
c28d830a8c
commit
e00f680053
|
@ -175,6 +175,16 @@
|
|||
parentDiv.style.backgroundColor
|
||||
= '#70AD47';
|
||||
document.getElementById('placeholder$ausleihID').classList.add('extend');
|
||||
document.getElementById('placeholder_container$ausleihID').addEventListener('click', function(){
|
||||
if (!e) var e = window.event;
|
||||
e.cancelBubble = true;
|
||||
if (e.stopPropagation) e.stopPropagation();
|
||||
ID = this.id;
|
||||
var data = new URLSearchParams();
|
||||
data.append('ausleihID', ID);
|
||||
var url = 'http://141.19.142.11/verlaengerung.php?' + data.toString();
|
||||
location.href = url;
|
||||
});
|
||||
}
|
||||
// Ausgeliehen und nicht Verlängerbar
|
||||
else if (currentElement.innerHTML.trim().includes('Rückgabe') && $bookExtendable === 0){
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="device=device-width, initial-scaling=1"/>
|
||||
<link rel="Stylesheet" type="text/css" href="style.css"/>
|
||||
<link rel="Stylesheet" type="text/css" href="suchergebnisse.css"/>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<title>Candle Bibliothek | Verlängerung</title>
|
||||
<title>Candle Bibliothek | Verlängerung Meine Bücher</title>
|
||||
<link rel="icon" href="pictures/candle.png">
|
||||
<script src="burgerIcon.js"></script>
|
||||
<script src="notwendiges_laden.js" defer></script>
|
||||
|
@ -48,36 +49,159 @@
|
|||
</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="hauptcontainer" id="verlängerung">
|
||||
<div class="hauptcontainer"id="verlängerung">
|
||||
<h1 id="verlängerungH1">Buch verlängern</h1>
|
||||
<div id="verlängerungContent">
|
||||
<p id="möchten-sie">Möchten Sie das folgende Buch um 7 Tage verlängern?</p>
|
||||
|
||||
<div class="item" id="verlängerungItem">
|
||||
<img src="pictures/es.jpg" alt="Es" height="200">
|
||||
<div class="beschreibung">
|
||||
<h2>Es</h2>
|
||||
<h3>von Stephen King</h3>
|
||||
<div class="b2 green">Rückgabe am: 03.05.2023</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="searchResult_container">
|
||||
<?php
|
||||
$servername = "localhost";
|
||||
$username = "web_b-3";
|
||||
$password = "een7Ao6s";
|
||||
$dbname = "bibliothek_candle";
|
||||
|
||||
<div id="verlängerungButtonContainer">
|
||||
<a id = "verlängerungButton1" href="verlaengerungErfolgreich.html">Bestätigen</a>
|
||||
<a id = "verlängerungButton2" href="meinebuecher.php">Abbrechen</a>
|
||||
$connection =
|
||||
mysqli_connect($servername, $username, $password, $dbname);
|
||||
|
||||
if (!$connection) {
|
||||
die("Verbindung fehlgeschlagen: " . mysqli_connect_error());
|
||||
}
|
||||
|
||||
/* SQL-Befehl vorbereiten */
|
||||
$sql = $connection->prepare("SELECT ab.AusleihID, ab.BuchID, b.Titel, b.Bild, ab.Verlängerbar, DATE_FORMAT(ab.Anfangsdatum, '%d.%m.%Y') as Anfangsdatum, DATE_FORMAT(ab.Enddatum, '%d.%m.%Y') as Enddatum,
|
||||
GROUP_CONCAT(DISTINCT CONCAT(a.VorName, ' ', a.NachName)
|
||||
SEPARATOR ', ') AS 'Autor',
|
||||
IF(
|
||||
(SELECT ausgeliehenes_buch.Anfangsdatum FROM ausgeliehenes_buch WHERE ausgeliehenes_buch.AusleihID=ab.AusleihID) = Curdate(), 'Sofort Abholbereit',
|
||||
(
|
||||
IF(
|
||||
(SELECT ausgeliehenes_buch.Anfangsdatum FROM ausgeliehenes_buch WHERE ausgeliehenes_buch.AusleihID=ab.AusleihID) > Curdate(),
|
||||
CONCAT(
|
||||
'Abholbereit am: ', (
|
||||
SELECT DATE_FORMAT(
|
||||
ausgeliehenes_buch.Anfangsdatum , '%d.%m.%Y'
|
||||
) FROM ausgeliehenes_buch WHERE ausgeliehenes_buch.AusleihID=ab.AusleihID
|
||||
)
|
||||
)
|
||||
, CONCAT(
|
||||
'Rückgabe am: ', (
|
||||
SELECT DATE_FORMAT(
|
||||
ausgeliehenes_buch.Enddatum , '%d.%m.%Y'
|
||||
) FROM ausgeliehenes_buch WHERE ausgeliehenes_buch.AusleihID=ab.AusleihID
|
||||
)
|
||||
))
|
||||
)
|
||||
)
|
||||
AS 'Verfügbarkeit'
|
||||
FROM ausgeliehenes_buch AS ab
|
||||
INNER JOIN buch as b
|
||||
ON ab.BuchID = b.BuchID
|
||||
INNER JOIN `buch_verfasst_von_autor` AS bvva
|
||||
ON b.BuchID = bvva.BuchID
|
||||
INNER JOIN `autor` AS a ON bvva.AutorNr = a.AutorNr
|
||||
WHERE ab.AusleihID=?
|
||||
GROUP BY ab.AusleihID;;");
|
||||
|
||||
// Parameter binden
|
||||
$sql->bind_param("i", $ID);
|
||||
|
||||
// Übergebene ID des angeklickten Container speichern
|
||||
$containerID = $_GET['ausleihID'];
|
||||
|
||||
// Buch ID abtrennen
|
||||
$ID = str_replace('placeholder_container', '', $containerID);
|
||||
|
||||
|
||||
// SQL-Befehl ausführen
|
||||
$sql->execute();
|
||||
|
||||
// Ergebnis speichern
|
||||
$result = $sql->get_result();
|
||||
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
while($row = mysqli_fetch_assoc($result)) {
|
||||
$bookID = $row['BuchID'];
|
||||
$ausleihID = $row['AusleihID'];
|
||||
$bookCover = $row['Bild'];
|
||||
$bookTitle = $row['Titel'];
|
||||
$bookAuthor = $row['Autor'];
|
||||
$bookAvailability = $row['Verfügbarkeit'];
|
||||
$bookExtendable = $row['Verlängerbar'];
|
||||
$bookStartdate = $row['Anfangsdatum'];
|
||||
$bookEnddate = $row['Enddatum'];
|
||||
|
||||
$bookStartdatePlusSeven = $bookStartdate +7;
|
||||
|
||||
/* TODO: OnClick auslagern. */
|
||||
echo "<div id='book_container$bookID+$ausleihID' class='book_container'
|
||||
onclick='open_bookDetails(this.id)'>
|
||||
<div class='bookCover_container'>
|
||||
<img class='bookCover' src='book_covers/$bookCover'
|
||||
alt='Kein Bild vorhanden'>
|
||||
</div>
|
||||
<div class='bookDetails_container'>
|
||||
<h2 class='bookTitle'>$bookTitle</h2>
|
||||
<div class='bookDetails'>
|
||||
<p class='author'>von $bookAuthor</p>
|
||||
|
||||
</div>
|
||||
<div class='available_container'>
|
||||
<p id='available_$ausleihID' class='available'>
|
||||
$bookAvailability</p>
|
||||
</div>
|
||||
<div>
|
||||
<p id='bestellungsInfo$ausleihID'></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class='placeholder_container' id='placeholder_container$ausleihID'>
|
||||
<div class='placeholder' id='placeholder$ausleihID'></div>
|
||||
</div>
|
||||
<script type='text/javascript'
|
||||
language='JavaScript'>
|
||||
(function() {
|
||||
var currentElement = document.
|
||||
getElementById('available_$ausleihID');
|
||||
var parentDiv = currentElement.parentElement;
|
||||
// Ausgeliehen und Verlängerbar
|
||||
parentDiv.style.backgroundColor
|
||||
= '#70AD47';
|
||||
})();
|
||||
</script>
|
||||
</div>";
|
||||
}
|
||||
} else {
|
||||
echo "Keine Infos vorhanden.";
|
||||
echo $_POST['ausleihID'];
|
||||
}
|
||||
|
||||
if (!$result) {
|
||||
die("Ungültige SQL-Abfrage: " . mysqli_connect_error());
|
||||
}
|
||||
echo "
|
||||
<div id='verlängerungButtonContainer'>
|
||||
<a id = 'verlängerungButton1' href='verlaengerung_erfolgreich.php?ausleihID=$ID&buchID=$bookID'>Bestätigen</a>
|
||||
<a id = 'verlängerungButton2' href='meinebuecher.php'>Abbrechen</a>
|
||||
</div>";
|
||||
mysqli_close($connection);
|
||||
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--Link JS file-->
|
||||
<!--If it was small and got big, it calls the function only one time and doesn't do it all the time-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!--Link JS file-->
|
||||
<!--If it was small and got big, it calls the function only one time and doesn't do it all the time-->
|
||||
<script src="resize.js"></script>
|
||||
|
||||
<nav id="activeid" class="active"></nav>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="device=device-width, initial-scaling=1"/>
|
||||
<link rel="Stylesheet" type="text/css" href="style.css"/>
|
||||
<link rel="Stylesheet" type="text/css" href="suchergebnisse.css"/>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<title>Candle Bibliothek | Verlängerung Bestätigung</title>
|
||||
<link rel="icon" href="pictures/candle.png">
|
||||
|
@ -49,28 +50,172 @@
|
|||
</div>
|
||||
</header>
|
||||
|
||||
<div class="hauptcontainer" id="verlängerung">
|
||||
<h1 id="verlängerungH1">Buch erfolgreich verlängert</h1>
|
||||
<div id="verlängerungContent">
|
||||
<p id="möchten-sie">Das Buch wurde verlängert.<br>Neues Rückgabedatum: 10.05.2023</p>
|
||||
|
||||
<?php
|
||||
$ID = $_GET['ausleihID'];
|
||||
$BookID = $_GET['buchID'];
|
||||
$servername = "localhost";
|
||||
$username = "web_b-3";
|
||||
$password = "een7Ao6s";
|
||||
$dbname = "bibliothek_candle";
|
||||
|
||||
$connection =
|
||||
mysqli_connect($servername, $username, $password, $dbname);
|
||||
|
||||
if (!$connection) {
|
||||
die("Verbindung fehlgeschlagen: " . mysqli_connect_error());
|
||||
}
|
||||
$sql = $connection->prepare("
|
||||
UPDATE `ausgeliehenes_buch` SET `Enddatum` = DATE_ADD(Enddatum,INTERVAL 7 DAY) WHERE `ausgeliehenes_buch`.`AusleihID` = ?;
|
||||
");
|
||||
$sql->bind_param("i", $ID);
|
||||
|
||||
$sql->execute();
|
||||
$sql = $connection->prepare("SELECT ab.AusleihID, ab.BuchID, b.Titel, b.Bild, ab.Verlängerbar, DATE_FORMAT(ab.Anfangsdatum, '%d.%m.%Y') as Anfangsdatum, DATE_FORMAT(ab.Enddatum, '%d.%m.%Y') as Enddatum,
|
||||
GROUP_CONCAT(DISTINCT CONCAT(a.VorName, ' ', a.NachName)
|
||||
SEPARATOR ', ') AS 'Autor',
|
||||
IF(
|
||||
(SELECT ausgeliehenes_buch.Anfangsdatum FROM ausgeliehenes_buch WHERE ausgeliehenes_buch.AusleihID=ab.AusleihID) = Curdate(), 'Sofort Abholbereit',
|
||||
(
|
||||
IF(
|
||||
(SELECT ausgeliehenes_buch.Anfangsdatum FROM ausgeliehenes_buch WHERE ausgeliehenes_buch.AusleihID=ab.AusleihID) > Curdate(),
|
||||
CONCAT(
|
||||
'Abholbereit am: ', (
|
||||
SELECT DATE_FORMAT(
|
||||
ausgeliehenes_buch.Anfangsdatum , '%d.%m.%Y'
|
||||
) FROM ausgeliehenes_buch WHERE ausgeliehenes_buch.AusleihID=ab.AusleihID
|
||||
)
|
||||
)
|
||||
, CONCAT(
|
||||
'Rückgabe am: ', (
|
||||
SELECT DATE_FORMAT(
|
||||
ausgeliehenes_buch.Enddatum , '%d.%m.%Y'
|
||||
) FROM ausgeliehenes_buch WHERE ausgeliehenes_buch.AusleihID=ab.AusleihID
|
||||
)
|
||||
))
|
||||
)
|
||||
)
|
||||
AS 'Verfügbarkeit'
|
||||
FROM ausgeliehenes_buch AS ab
|
||||
INNER JOIN buch as b
|
||||
ON ab.BuchID = b.BuchID
|
||||
INNER JOIN `buch_verfasst_von_autor` AS bvva
|
||||
ON b.BuchID = bvva.BuchID
|
||||
INNER JOIN `autor` AS a ON bvva.AutorNr = a.AutorNr
|
||||
WHERE ab.AusleihID=?
|
||||
GROUP BY ab.AusleihID;;");
|
||||
|
||||
// Parameter binden
|
||||
$sql->bind_param("i", $ID);
|
||||
|
||||
// Übergebene ID des angeklickten Container speichern
|
||||
$containerID = $_GET['ausleihID'];
|
||||
|
||||
// Buch ID abtrennen
|
||||
$ID = str_replace('placeholder_container', '', $containerID);
|
||||
|
||||
|
||||
<div class="item" id="verlängerungItem">
|
||||
<img src="pictures/es.jpg" alt="Es" height="200">
|
||||
<div class="beschreibung">
|
||||
<h2>Es</h2>
|
||||
<h3>von Stephen King</h3>
|
||||
<div class="b2 green">Rückgabe am: 10.05.2023</div>
|
||||
</div>
|
||||
// SQL-Befehl ausführen
|
||||
$sql->execute();
|
||||
|
||||
// Ergebnis speichern
|
||||
$result = $sql->get_result();
|
||||
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
while($row = mysqli_fetch_assoc($result)) {
|
||||
$bookID = $row['BuchID'];
|
||||
$ausleihID = $row['AusleihID'];
|
||||
$bookCover = $row['Bild'];
|
||||
$bookTitle = $row['Titel'];
|
||||
$bookAuthor = $row['Autor'];
|
||||
$bookAvailability = $row['Verfügbarkeit'];
|
||||
$bookExtendable = $row['Verlängerbar'];
|
||||
$bookStartdate = $row['Anfangsdatum'];
|
||||
$bookEnddate = $row['Enddatum'];
|
||||
|
||||
$bookStartdatePlusSeven = $bookStartdate +7;
|
||||
|
||||
/* TODO: OnClick auslagern. */
|
||||
echo " <div class='hauptcontainer'id='verlängerung'>
|
||||
<h1 id='verlängerungH1'>Buch erfolgreich verlängert</h1>
|
||||
<div id='verlängerungContent'>
|
||||
<p id='möchten-sie'>Das Buch wurde verlängert.<br>Neues Rückgabedatum: $bookEnddate</p>
|
||||
<div id='searchResult_container'>
|
||||
<div id='book_container$bookID+$ausleihID' class='book_container'
|
||||
onclick='open_bookDetails(this.id)'>
|
||||
<div class='bookCover_container'>
|
||||
<img class='bookCover' src='book_covers/$bookCover'
|
||||
alt='Kein Bild vorhanden'>
|
||||
</div>
|
||||
<div class='bookDetails_container'>
|
||||
<h2 class='bookTitle'>$bookTitle</h2>
|
||||
<div class='bookDetails'>
|
||||
<p class='author'>von $bookAuthor</p>
|
||||
|
||||
<div id="verlängerungButtonContainer">
|
||||
<a id = "verlängerungErfolgreichButton1" href="meinebuecher.php">Zurück zu Meine Bücher</a>
|
||||
</div>
|
||||
<div class='available_container'>
|
||||
<p id='available_$ausleihID' class='available'>
|
||||
$bookAvailability</p>
|
||||
</div>
|
||||
<div>
|
||||
<p id='bestellungsInfo$ausleihID'></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class='placeholder_container' id='placeholder_container$ausleihID'>
|
||||
<div class='placeholder' id='placeholder$ausleihID'></div>
|
||||
</div>
|
||||
<script type='text/javascript'
|
||||
language='JavaScript'>
|
||||
(function() {
|
||||
var currentElement = document.
|
||||
getElementById('available_$ausleihID');
|
||||
var parentDiv = currentElement.parentElement;
|
||||
// Ausgeliehen und Verlängerbar
|
||||
parentDiv.style.backgroundColor
|
||||
= '#70AD47';
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
<div id='verlängerungButtonContainer'>
|
||||
<a id = 'verlängerungErfolgreichButton1' href='meinebuecher.php'>Zurück zu Meine Bücher</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>";
|
||||
}
|
||||
} else {
|
||||
echo "Keine Infos vorhanden.";
|
||||
echo $_POST['ausleihID'];
|
||||
}
|
||||
|
||||
</div>
|
||||
if (!$result) {
|
||||
die("Ungültige SQL-Abfrage: " . mysqli_connect_error());
|
||||
}
|
||||
?>
|
||||
|
||||
<!--<div class="hauptcontainer" id="verlängerung">-->
|
||||
<!-- <h1 id="verlängerungH1">Buch erfolgreich verlängert</h1>-->
|
||||
<!-- <div id="verlängerungContent">-->
|
||||
<!-- <p id="möchten-sie">Das Buch wurde verlängert.<br>Neues Rückgabedatum: 10.05.2023</p>-->
|
||||
<!---->
|
||||
<!---->
|
||||
<!-- <div class="item" id="verlängerungItem">-->
|
||||
<!-- <img src="pictures/es.jpg" alt="Es" height="200">-->
|
||||
<!-- <div class="beschreibung">-->
|
||||
<!-- <h2>Es</h2>-->
|
||||
<!-- <h3>von Stephen King</h3>-->
|
||||
<!-- <div class="b2 green">Rückgabe am: 10.05.2023</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!---->
|
||||
<!-- <div id="verlängerungButtonContainer">-->
|
||||
<!-- <a id = "verlängerungErfolgreichButton1" href="meinebuecher.php">Zurück zu Meine Bücher</a>-->
|
||||
<!-- </div>-->
|
||||
<!---->
|
||||
<!-- </div>-->
|
||||
<!---->
|
||||
<!--</div>-->
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue