Add Container Feature

This commit is contained in:
Katharina 2019-02-22 20:47:26 +01:00 committed by /jedi/
parent 33ec4480d6
commit fef7701152
3 changed files with 32 additions and 27 deletions

View file

@ -33,12 +33,12 @@ switch($_GET["action"]) {
}
break;
case "add_found":
if (hasval($_POST["was"]) && hasval($_POST["wann"]) && hasval($_POST["wo"])) {
if (hasval($_POST["was"]) && hasval($_POST["wann"]) && hasval($_POST["wo"])&& hasval($_POST["container"])) {
/* Prepared statement, stage 1: prepare */
if (!($stmt = $mysqli->prepare("INSERT INTO found_items(was, wann, wo) VALUES (?, ?, ?)"))) {
if (!($stmt = $mysqli->prepare("INSERT INTO found_items(was, wann, wo, container) VALUES (?, ?, ?, ?)"))) {
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$stmt->bind_param("sss", $_POST["was"], $_POST["wann"], $_POST["wo"])) {
if (!$stmt->bind_param("ssss", $_POST["was"], $_POST["wann"], $_POST["wo"], $_POST["container"])) {
$errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}
if (!$stmt->execute()) {
@ -103,13 +103,13 @@ switch($_GET["action"]) {
}
break;
case "edit_found_item":
if(hasval($_POST["id"]) && hasval($_POST["was"])) {
if(hasval($_POST["id"]) && hasval($_POST["was"])&& hasval($_POST["container"])) {
/* Prepared statement, stage 1: prepare */
$was=$_POST["was"];
if (!($stmt = $mysqli->prepare("UPDATE found_items SET was=?, wo=?, wann=? WHERE id = ?"))) {
if (!($stmt = $mysqli->prepare("UPDATE found_items SET was=?, wo=?, wann=?, container=? WHERE id = ?"))) {
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$stmt->bind_param("sssi", $_POST["was"] , $_POST["wo"], $_POST["wann"], $_POST["id"])) {
if (!$stmt->bind_param("ssssi", $_POST["was"] , $_POST["wo"], $_POST["wann"], $_POST["container"], $_POST["id"])) {
$errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}
if (!$stmt->execute()) {
@ -148,12 +148,12 @@ switch($_GET["action"]) {
}
break;
case "add_found_item":
if (hasval($_POST["was"])) {
if (hasval($_POST["was"])&& hasval($_POST["container"])) {
/* Prepared statement, stage 1: prepare */
if (!($stmt = $mysqli->prepare("INSERT INTO found_items(was) VALUES (?)"))) {
if (!($stmt = $mysqli->prepare("INSERT INTO found_items(was, container) VALUES (?, ?)"))) {
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$stmt->bind_param("s", $_POST["was"])) {
if (!$stmt->bind_param("ss", $_POST["was"], $_POST["container"])) {
$errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}
if (!$stmt->execute()) {
@ -196,6 +196,7 @@ switch($_GET["action"]) {
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kiste</th>
<th>foto</th>
<th></th>
</tr>
@ -206,6 +207,7 @@ switch($_GET["action"]) {
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kiste</th>
<th>foto</th>
<th></th>
</tr>
@ -219,12 +221,13 @@ switch($_GET["action"]) {
<td><?php echo $item["was"]; ?></td>
<td><?php echo $item["wann"]; ?></td>
<td><?php echo $item["wo"]; ?></td>
<td><?php echo $item["container"]; ?></td>
<td><img style="height: 48px;" src="/upload/<?php echo $item["hash"]; ?>"></td>
<td>
<div class="btn-group" role="group">
<button type="button" class="btn btn-outline-secondary"><i class="fas fa-fw fa-check-circle"></i></button>
<!--<a href="/found_item_edit/<?php echo $item["id"]; ?>/" type="button" class="btn btn-outline-secondary"><i class="fas fa-fw fa-edit"></i></a>-->
<button type="button" class="btn btn-outline-secondary" data-toggle="modal" data-target="#exampleModal" onclick="fill_edit_form(<?php echo $item["id"]; ?>,'<?php echo $item["was"]; ?>','<?php echo $item["wann"]; ?>','<?php echo $item["wo"]; ?>','<?php echo $item["hash"]; ?>')">
<button type="button" class="btn btn-outline-secondary" data-toggle="modal" data-target="#exampleModal" onclick="fill_edit_form(<?php echo $item["id"]; ?>,'<?php echo $item["was"]; ?>','<?php echo $item["wann"]; ?>','<?php echo $item["wo"]; ?>','<?php echo $item["hash"]; ?>', '<?php echo $item["container"]?>')">
<i class="fas fa-fw fa-edit"></i>
</button>
<button type="button" class="btn btn-outline-danger" onclick="delete_item(<?php echo $item["id"]; ?>)"><i class="fas fa-fw fa-trash-alt"></i></button>

View file

@ -14,7 +14,7 @@ function auth(){
function get_founditems($onlyUnmatched = false){
global $mysqli;
if ($onlyUnmatched) {
$res = $mysqli->query("SELECT distinct found_items.*, files.hash FROM (SELECT files.* from files ORDER BY files.id DESC LIMIT 100000) as files, found_items LEFT JOIN matches ON found_items.id = matches.f_id WHERE found_items.del = 0 AND files.item_id = found_items.id AND matches.f_id IS NULL GROUP BY files.item_id ORDER BY found_items.id DESC");
$res = $mysqli->query("SELECT found_items.*, files.hash FROM (SELECT files.* from files ORDER BY files.id DESC LIMIT 100000) as files, found_items LEFT JOIN matches ON found_items.id = matches.f_id WHERE found_items.del = 0 AND files.item_id = found_items.id AND matches.f_id IS NULL GROUP BY files.item_id ORDER BY found_items.id DESC");
} else {
$res = $mysqli->query("SELECT found_items.*, files.hash FROM (SELECT files.* from files ORDER BY files.id DESC LIMIT 100000) as files, found_items WHERE files.item_id = found_items.id AND found_items.del = 0 GROUP BY files.item_id ORDER BY found_items.id ASC");
}

View file

@ -10,6 +10,9 @@
#img-upload{
width: 100%;
}
#img-zoom{
width: 100%;
}
</style>
<div class="container-fluid">
@ -53,6 +56,7 @@
<p><input type="text" class="form-control" placeholder="WAS" name="was" id="was" value=""></p>
<p><input type="text" class="form-control" placeholder="WANN" name="wann" id="wann" value=""></p>
<p><input type="text" class="form-control" placeholder="WO" name="wo" id="wo" value=""></p>
<p><input type="text" class="form-control" placeholder="KISTE" name="container" id="container" value=""></p>
<div class="form-group">
<div class="input-group">
@ -84,9 +88,9 @@
<!-- Modal Picture Zoom -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal fade bd-example-modal-lg" id="exampleModal_picture" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content" >
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
@ -94,11 +98,10 @@
</button>
</div>
<div class="modal-body">
<img id='img-upload' src="/upload/"/>
<img id='img-zoom' src="/upload/"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
@ -118,6 +121,7 @@
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kiste</th>
<th>foto</th>
<th></th>
</tr>
@ -128,6 +132,7 @@
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kiste</th>
<th>foto</th>
<th></th>
</tr>
@ -141,13 +146,14 @@
<td><?php echo $item["was"]; ?></td>
<td><?php echo $item["wann"]; ?></td>
<td><?php echo $item["wo"]; ?></td>
<td><button style="background: url(/upload/<?php echo $item["hash"]; ?>)" ... /></td>
<td><?php echo $item["container"];?></td>
<td><button class="btn btn-link" data-toggle="modal" data-target="#exampleModal_picture" onclick="show_picture('<?php echo $item["hash"]; ?>')"><img style="height: 48px;" src="/upload/<?php echo $item["hash"]; ?>"></button></td>
<!--<td><img style="height: 48px;" src="/upload/<?php echo $item["hash"]; ?>"></td>-->
<td>
<div class="btn-group" role="group">
<button type="button" class="btn btn-outline-secondary"><i class="fas fa-fw fa-check-circle"></i></button>
<!--<a href="/found_item_edit/<?php echo $item["id"]; ?>/" type="button" class="btn btn-outline-secondary"><i class="fas fa-fw fa-edit"></i></a>-->
<button type="button" class="btn btn-outline-secondary" data-toggle="modal" data-target="#exampleModal" onclick="fill_edit_form(<?php echo $item["id"]; ?>,'<?php echo $item["was"]; ?>','<?php echo $item["wann"]; ?>','<?php echo $item["wo"]; ?>','<?php echo $item["hash"]; ?>')">
<button type="button" class="btn btn-outline-secondary" data-toggle="modal" data-target="#exampleModal" onclick="fill_edit_form(<?php echo $item["id"]; ?>,'<?php echo $item["was"]; ?>','<?php echo $item["wann"]; ?>','<?php echo $item["wo"]; ?>','<?php echo $item["hash"]; ?>','<?php echo $item["container"];?>')">
<i class="fas fa-fw fa-edit"></i>
</button>
<button type="button" class="btn btn-outline-danger" onclick="delete_item(<?php echo $item["id"]; ?>)"><i class="fas fa-fw fa-trash-alt"></i></button>
@ -181,23 +187,19 @@
<script>
function fill_edit_form(id, was, wann, wo, hash) {
function fill_edit_form(id, was, wann, wo, hash, container) {
document.getElementById('id').value = id;
document.getElementById('was').value = was;
document.getElementById('wann').value = wann;
document.getElementById('wo').value = wo;
document.getElementById('container').value = container;
document.getElementById('img-upload').src = "/upload/"+hash;
/*document.charset = "UTF-8";
document.open("text/html");
document.write("<html>");
document.write("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><\/head>");
document.write("<body>");
document.write(PaketL + PaketB + PaketH + Raum);
document.write("<\/body><\/html>");
document.close();*/
}
function show_picture(hash){
document.getElementById('img-zoom').src = "/upload/"+hash;
}
function delete_item(id){