2021-06-17 01:23:32 +02:00
|
|
|
<?php
|
|
|
|
require("common.php");
|
2022-02-04 11:35:08 +01:00
|
|
|
//require("isbnImage.php");
|
2021-06-17 01:23:32 +02:00
|
|
|
function main($pdo, $pageN)
|
|
|
|
{
|
|
|
|
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<title>Biblioteca | <?php echo $GLOBALS["place"]; ?></title>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
|
|
|
|
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-blue-grey.css">
|
|
|
|
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans'>
|
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
|
|
<style>
|
|
|
|
html,
|
|
|
|
body,
|
|
|
|
h1,
|
|
|
|
h2,
|
|
|
|
h3,
|
|
|
|
h4,
|
|
|
|
h5 {
|
|
|
|
font-family: "Open Sans", sans-serif
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<body class="w3-theme-l5">
|
|
|
|
|
|
|
|
<!-- Navbar -->
|
|
|
|
<div class="w3-top">
|
|
|
|
<div class="w3-bar w3-theme-d2 w3-left-align w3-large">
|
|
|
|
<a href="./" class="w3-bar-item w3-button w3-padding-large w3-theme-d4"><i class="fa fa-book w3-margin-right"></i>Biblioteca | <?php echo $GLOBALS["place"]; ?></a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Page Container -->
|
|
|
|
<div class="w3-container w3-content" style="max-width:1400px;margin-top:80px">
|
|
|
|
<!-- The Grid -->
|
|
|
|
<div class="w3-row">
|
|
|
|
<!-- Left Column -->
|
|
|
|
<div class="w3-content">
|
|
|
|
<!-- Profile -->
|
|
|
|
<div class="w3-card w3-round w3-white">
|
|
|
|
<div class="w3-container">
|
|
|
|
<h3 class="w3-center">Biblioteca online</h3>
|
|
|
|
<h4 class="w3-center"><?php echo $GLOBALS["place"]; ?></h4>
|
|
|
|
<center><img style="width:45vw" src="bookshelf.svg" /></center>
|
|
|
|
<hr>
|
|
|
|
<h4 class="w3-center">Interrogazione completata</h4>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<br>
|
|
|
|
|
|
|
|
<!-- Accordion -->
|
|
|
|
<div class="w3-card w3-round">
|
|
|
|
<div class="w3-white">
|
|
|
|
|
2022-02-04 11:35:08 +01:00
|
|
|
<button onclick="myFunction('Demo1')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-list fa-fw w3-margin-right"></i>Risultati dell'interrogazione</button>
|
2021-06-17 01:23:32 +02:00
|
|
|
<div id="Demo1" class="w3-hide w3-container">
|
|
|
|
<?php
|
|
|
|
$arrayQ = [];
|
2021-11-09 22:19:17 +01:00
|
|
|
$mainQuery = "SELECT id,Titolo,Autore,ISBN FROM Libri WHERE ";
|
2022-02-04 11:35:08 +01:00
|
|
|
$lQuery = " SELECT DISTINCT upper(SUBSTR(Titolo,1,1)) AS letter FROM Libri ORDER BY letter";
|
2021-11-09 22:19:17 +01:00
|
|
|
$query = "";
|
2021-06-17 01:23:32 +02:00
|
|
|
$flag = false;
|
|
|
|
if (!empty($_POST["Titolo"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= " trim(lower(Titolo)) LIKE ('%' || trim(lower(:Titolo)) || '%')";
|
2021-06-17 01:23:32 +02:00
|
|
|
$arrayQ[":Titolo"] = $_POST["Titolo"];
|
|
|
|
}
|
2021-11-08 18:32:06 +01:00
|
|
|
if (!empty($_POST["Letter"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= " trim(lower(Titolo)) LIKE ( trim(lower(:Letter)) || '%')";
|
2021-11-08 18:32:06 +01:00
|
|
|
$arrayQ[":Letter"] = $_POST["Letter"];
|
|
|
|
}
|
2021-06-17 01:23:32 +02:00
|
|
|
if (!empty($_POST["Autore"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= " trim(lower(Autore)) LIKE ('%' || trim(lower(:Autore)) || '%')";
|
2021-06-17 01:23:32 +02:00
|
|
|
$arrayQ[":Autore"] = $_POST["Autore"];
|
|
|
|
}
|
|
|
|
if (!empty($_POST["Editore"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= " trim(lower(Editore)) LIKE ('%' || trim(lower(:Editore)) || '%')";
|
2021-06-17 01:23:32 +02:00
|
|
|
$arrayQ[":Editore"] = $_POST["Editore"];
|
|
|
|
}
|
|
|
|
if (!empty($_POST["Genere"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= " trim(lower(Genere)) LIKE ('%' || trim(lower(:Genere)) || '%')";
|
2021-06-17 01:23:32 +02:00
|
|
|
$arrayQ[":Genere"] = $_POST["Genere"];
|
|
|
|
}
|
|
|
|
if (!empty($_POST["ISBN"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= " trim(lower(ISBN)) LIKE ('%' || trim(lower(:ISBN)) || '%')";
|
2021-06-17 01:23:32 +02:00
|
|
|
$arrayQ[":ISBN"] = $_POST["ISBN"];
|
|
|
|
}
|
|
|
|
if (!empty($_POST["Inventario"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= " trim(lower(Inventario)) LIKE ('%' || trim(lower(:Inventario)) || '%')";
|
2021-06-17 01:23:32 +02:00
|
|
|
$arrayQ[":Inventario"] = $_POST["Inventario"];
|
|
|
|
}
|
|
|
|
if (!empty($_POST["Serie"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= " trim(lower(Serie)) LIKE ('%' || trim(lower(:Serie)) || '%')";
|
2021-06-17 01:23:32 +02:00
|
|
|
$arrayQ[":Serie"] = $_POST["Serie"];
|
|
|
|
}
|
|
|
|
if (!empty($_POST["Lingua"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= "trim(lower(Lingua)) LIKE ('%' || trim(lower(:Lingua)) || '%')";
|
2021-06-17 01:23:32 +02:00
|
|
|
$arrayQ[":Lingua"] = $_POST["Lingua"];
|
|
|
|
}
|
|
|
|
if (!empty($_POST["Argomento"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
2021-11-08 23:52:07 +01:00
|
|
|
$query .= " trim(lower(Argomento)) LIKE ('%' || trim(lower(:Argomento)) || '%')";
|
2021-06-17 01:23:32 +02:00
|
|
|
$arrayQ[":Argomento"] = $_POST["Argomento"];
|
|
|
|
}
|
|
|
|
if ($_POST["Prestito"] == "P") {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
|
|
|
$query .= " Prestito='P'";
|
|
|
|
} elseif ($_POST["Prestito"] == "NP") {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
|
|
|
$query .= " Prestito!='P'";
|
|
|
|
}
|
|
|
|
if (!empty($_POST["NPag"])) {
|
|
|
|
if (!$flag) {
|
|
|
|
$flag = true;
|
|
|
|
} else {
|
|
|
|
$query .= " AND ";
|
|
|
|
}
|
|
|
|
$query .= " NPag =:NPag";
|
|
|
|
$arrayQ[":NPag"] = $_POST["NPag"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$flag) $query .= " 1=1";
|
|
|
|
$query .= " ORDER BY Titolo ASC";
|
2022-02-04 11:35:08 +01:00
|
|
|
$newPage = $mainQuery.$query." LIMIT 10 OFFSET ".(($pageN+1)*10);
|
2021-06-17 01:23:32 +02:00
|
|
|
$query .= " LIMIT " . (10) . " OFFSET " . ($pageN * 10);
|
2021-11-09 22:19:17 +01:00
|
|
|
$mainQuery .= $query;
|
|
|
|
$stmt = $pdo->prepare($lQuery);
|
|
|
|
$stmt->execute();
|
2022-02-04 11:35:08 +01:00
|
|
|
$np = $pdo->prepare($newPage);
|
|
|
|
$np->execute($arrayQ);
|
|
|
|
$hasNewPage = count($np->fetchAll()) > 0;
|
2021-11-09 22:19:17 +01:00
|
|
|
?>
|
|
|
|
<div class="resultD w3-panel w3-card">
|
|
|
|
|
|
|
|
<?php
|
|
|
|
$test = $_POST;
|
|
|
|
unset($test["Letter"]);
|
|
|
|
unset($test["page"]);
|
|
|
|
unset($test["first"]);
|
|
|
|
$test["Numero di Pagine"] = $test["NPag"];
|
|
|
|
unset($test["NPag"]);
|
|
|
|
|
|
|
|
if(count($test)){
|
|
|
|
?>
|
|
|
|
<p>Parametri di ricerca</p>
|
|
|
|
<table class="w3-table w3-bordered">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<?php
|
|
|
|
foreach(array_keys($test) as $key){
|
|
|
|
if(!strlen($test[$key])) continue;
|
|
|
|
echo "<th>".htmlentities($key)."</th>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<?php
|
|
|
|
foreach(array_values($test) as $val){
|
|
|
|
if(!strlen($val)) continue;
|
|
|
|
echo "<td>".htmlentities($val)."</td>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<br /><br />
|
|
|
|
<form method="POST" action="results.php">
|
|
|
|
<button class="w3-btn w3-left w3-orange"><i class="fa fa-book fa-fw w3-margin-right"></i>Sfoglia senza restrizioni</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div class="resultD w3-panel w3-card">
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<form method="POST" style="display:inline;">
|
|
|
|
<input type="hidden" name="Letter" value="" />
|
|
|
|
<button class="w3-btn w3-red">×</button>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
while ($data = $stmt->fetch()) {
|
|
|
|
$letter = $data["letter"];
|
|
|
|
?>
|
|
|
|
<form method="POST" style="display:inline;">
|
|
|
|
<?php
|
|
|
|
$p = $_POST["page"];
|
|
|
|
unset($_POST["page"]);
|
|
|
|
foreach ($_POST as $key => $val) {
|
|
|
|
?><input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val); ?>" /><?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<input type="hidden" name="Letter" value="<?php echo htmlentities($letter); ?>" />
|
|
|
|
<button class="w3-btn w3-blue-grey"><?php echo htmlentities($letter); ?></button>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
$_POST["page"] = $p;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
$stmt = $pdo->prepare($mainQuery);
|
2021-06-17 01:23:32 +02:00
|
|
|
$stmt->execute($arrayQ);
|
|
|
|
$i = 0;
|
|
|
|
while ($data = $stmt->fetch()) {
|
|
|
|
$ak = array_keys($data);
|
|
|
|
for ($i = 0; $i < count($ak); $i++) {
|
|
|
|
$data[$ak[$i]] = iconv('iso-8859-1', 'UTF-8//IGNORE', $data[$ak[$i]]);
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<div class="resultD w3-panel w3-card">
|
2022-02-04 11:35:08 +01:00
|
|
|
<!-- <img src="<?php
|
|
|
|
//echo isbnImage($data["ISBN"]);
|
|
|
|
?>books.png" style="width:10vw;" /> --->
|
2021-06-17 01:23:32 +02:00
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>Titolo</th>
|
|
|
|
<td><?php echo htmlentities($data["Titolo"]); ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Autore</th>
|
|
|
|
<td><?php echo htmlentities($data["Autore"]); ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>ISBN</th>
|
2022-02-04 11:35:08 +01:00
|
|
|
<td><?php echo htmlentities(strlen(trim($data["ISBN"]))?$data["ISBN"]:"-"); ?></td>
|
2021-06-17 01:23:32 +02:00
|
|
|
</tr>
|
|
|
|
</table>
|
2022-02-04 11:35:08 +01:00
|
|
|
<form action="bookDetail.php" method="GET" target="_blank">
|
2021-06-17 01:23:32 +02:00
|
|
|
<input name="id" type="hidden" value="<?php echo $data["id"]; ?>" />
|
|
|
|
<button class="w3-btn w3-right w3-blue-grey"><i class="fa fa-arrow-circle-right fa-fw w3-margin-right"></i>Vedi</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
if ($i == 0) {
|
|
|
|
echo '<h4 class="w3-center">Nessun risultato</h4>';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<div class="w3-row">
|
|
|
|
<?php
|
|
|
|
$p = (int)$_POST["page"];
|
|
|
|
unset($_POST["page"]);
|
|
|
|
if ($p != 0) {
|
|
|
|
?>
|
|
|
|
<div class="w3-third">
|
|
|
|
<form method="POST">
|
|
|
|
<?php
|
|
|
|
|
|
|
|
foreach ($_POST as $key => $val) {
|
|
|
|
?><input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val); ?>" /><?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<input type="hidden" name="page" value="<?php echo $p - 1; ?>">
|
|
|
|
<button class="w3-btn w3-left w3-blue-grey"> <i class="fa fa-arrow-left fa-fw w3-margin-right "></i>Pagina precedente</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
|
|
|
|
} else {
|
|
|
|
?><div class="w3-third"></div><?php
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
<div class="w3-third">
|
|
|
|
<?php if ($i != 0) { ?> <h4 class="w3-center">Pagina <?php echo $pageN + 1; ?></h4> <?php } ?>
|
|
|
|
</div>
|
|
|
|
<div class="w3-third">
|
|
|
|
<?php
|
2022-02-04 11:35:08 +01:00
|
|
|
if ($i != 0 && $hasNewPage) {
|
2021-06-17 01:23:32 +02:00
|
|
|
?>
|
|
|
|
<form method="POST">
|
|
|
|
<?php
|
|
|
|
foreach ($_POST as $key => $val) {
|
|
|
|
?><input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val); ?>" /><?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<input type="hidden" name="page" value="<?php echo $p + 1; ?>">
|
|
|
|
<button class="w3-btn w3-right w3-blue-grey"> Pagina successiva<i class="fa fa-arrow-right fa-fw w3-margin-left"></i></button>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<br>
|
|
|
|
|
|
|
|
<!-- Interests -->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- End Left Column -->
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- End Grid -->
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- End Page Container -->
|
|
|
|
</div>
|
|
|
|
<br>
|
|
|
|
|
|
|
|
<!-- Footer -->
|
|
|
|
<footer class="w3-container w3-theme-d3 w3-padding-16">
|
|
|
|
<h5>Mattia Mascarello, MIT License, 2021</h5>
|
|
|
|
</footer>
|
|
|
|
|
|
|
|
<footer class="w3-container w3-theme-d5">
|
2022-02-06 17:36:58 +01:00
|
|
|
<p>Repo <a href="<?php echo $GLOBALS["repoUrl"]; ?>" target="_blank">github</a> | <a href="open.php"> Scarica i dati</a></p>
|
2021-06-17 01:23:32 +02:00
|
|
|
</footer>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
// Accordion
|
|
|
|
function myFunction(id) {
|
|
|
|
var x = document.getElementById(id);
|
|
|
|
if (x.className.indexOf("w3-show") == -1) {
|
|
|
|
x.className += " w3-show";
|
|
|
|
x.previousElementSibling.className += " w3-theme-d1";
|
|
|
|
} else {
|
|
|
|
x.className = x.className.replace("w3-show", "");
|
|
|
|
x.previousElementSibling.className =
|
|
|
|
x.previousElementSibling.className.replace(" w3-theme-d1", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used to toggle the menu on smaller screens when clicking on the menu button
|
|
|
|
function openNav() {
|
|
|
|
var x = document.getElementById("navDemo");
|
|
|
|
if (x.className.indexOf("w3-show") == -1) {
|
|
|
|
x.className += " w3-show";
|
|
|
|
} else {
|
|
|
|
x.className = x.className.replace(" w3-show", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
myFunction('Demo1')
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2021-11-09 22:19:53 +01:00
|
|
|
$dbh = new PDO('sqlite:db');
|
2021-06-17 01:23:32 +02:00
|
|
|
main($dbh, $_POST["page"] ?: 0);
|
|
|
|
?>
|