Implement Popup Window for Edit Found Items

This commit is contained in:
Katharina 2019-02-22 15:30:43 +01:00 committed by /jedi/
parent 6c17a76393
commit 33ec4480d6
4 changed files with 406 additions and 103 deletions

View file

@ -7,6 +7,7 @@
*/
include "backend.php";
include "functions.php";
function hasval($var){
return isset($var) && !empty($var);
@ -102,10 +103,10 @@ switch($_GET["action"]) {
}
break;
case "edit_found_item":
if(hasval($_POST["id"]) && hasval($_POST["was"]) && hasval($_POST["wann"])) {
if(hasval($_POST["id"]) && hasval($_POST["was"])) {
/* Prepared statement, stage 1: prepare */
$was=$_POST["was"];
if (!($stmt = $mysqli->prepare("UPDATE found_items SET was=?, wo=?, `date`=? WHERE id = ?"))) {
if (!($stmt = $mysqli->prepare("UPDATE found_items SET was=?, wo=?, wann=? WHERE id = ?"))) {
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$stmt->bind_param("sssi", $_POST["was"] , $_POST["wo"], $_POST["wann"], $_POST["id"])) {
@ -115,7 +116,9 @@ switch($_GET["action"]) {
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
if(isset($_FILES["image"])){
$successmsg = "one item edited";
if(isset($_FILES["image"])&& hasval($_FILES["image"]["tmp_name"])){
if(!file_exists ( "upload/")){
mkdir("upload/");
}
@ -132,11 +135,11 @@ switch($_GET["action"]) {
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
$successmsg = "one item edited";
}else{
$errormsg = "upload failed";
}
}else{
$errormsg = "upload failed";
}
@ -179,12 +182,73 @@ switch($_GET["action"]) {
$errormsg = "upload failed";
}
}else{
$errormsg = "upload failed";
}
}else{
$errormsg = "all values have to be set";
}
break;
case "get_found_table":
?>
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>ID</th>
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>foto</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>foto</th>
<th></th>
</tr>
</tfoot>
<tbody>
<?php
foreach( get_founditems(true) as $item){
?>
<tr>
<td><?php echo $item["id"]; ?> </td>
<td><?php echo $item["was"]; ?></td>
<td><?php echo $item["wann"]; ?></td>
<td><?php echo $item["wo"]; ?></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"]; ?>')">
<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>
</div>
</td>
<!--td>
<?php
foreach(explode(",",$item["tags"]) as $tag){
?>
<span class="label label-default"><?php echo $tag; ?></span>
<?php
}
?>
</td>
<td><?php echo $item["id"]; ?></td-->
</tr>
<?php
}
?>
</tbody>
</table>
<?php
exit;
break;
default:
$errormsg = "action unknown";
break;