add QR-Code target page

This commit is contained in:
/jedi/ 2019-02-23 10:43:45 +01:00
parent fa57cb3fd4
commit e7fd1720f2
14 changed files with 694 additions and 782 deletions

View file

@ -139,9 +139,6 @@ switch($_GET["action"]) {
$successmsg = "one item edited"; $successmsg = "one item edited";
if(isset($_FILES["image"])&& hasval($_FILES["image"]["tmp_name"])){ if(isset($_FILES["image"])&& hasval($_FILES["image"]["tmp_name"])){
if(!file_exists ( "upload/")){
mkdir("upload/");
}
$hash = md5($_FILES['image']['name'].time()); $hash = md5($_FILES['image']['name'].time());
if(move_uploaded_file($_FILES['image']['tmp_name'], "upload/".$hash)){ if(move_uploaded_file($_FILES['image']['tmp_name'], "upload/".$hash)){
@ -154,7 +151,10 @@ switch($_GET["action"]) {
if (!$stmt->execute()) { if (!$stmt->execute()) {
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error; $errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
} }
makethumb($hash);
if(!makethumb($hash)){
$errormsg = "thumbnail creation failed";
}
$successmsg = "one item edited"; $successmsg = "one item edited";
}else{ }else{
@ -169,12 +169,12 @@ switch($_GET["action"]) {
} }
break; break;
case "add_found_item": case "add_found_item":
if (hasval($_POST["was"])&& hasval($_POST["container"])) { if (hasval($_POST["was"])&& hasval($_POST["container"])&& hasval($_POST["uid"])) {
/* Prepared statement, stage 1: prepare */ /* Prepared statement, stage 1: prepare */
if (!($stmt = $mysqli->prepare("INSERT INTO found_items(was, container) VALUES (?, ?)"))) { if (!($stmt = $mysqli->prepare("INSERT INTO found_items(uid, was, container) VALUES (?, ?, ?)"))) {
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error; $errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
} }
if (!$stmt->bind_param("ss", $_POST["was"], $_POST["container"])) { if (!$stmt->bind_param("sss", $_POST["uid"], $_POST["was"], $_POST["container"])) {
$errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; $errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
} }
if (!$stmt->execute()) { if (!$stmt->execute()) {
@ -183,9 +183,6 @@ switch($_GET["action"]) {
$item_id = $mysqli->insert_id; $item_id = $mysqli->insert_id;
if(isset($_FILES["image"])){ if(isset($_FILES["image"])){
if(!file_exists ( "upload/")){
mkdir("upload/");
}
$hash = md5($_FILES['image']['name'].time()); $hash = md5($_FILES['image']['name'].time());
if(move_uploaded_file($_FILES['image']['tmp_name'], "upload/".$hash)){ if(move_uploaded_file($_FILES['image']['tmp_name'], "upload/".$hash)){
@ -198,7 +195,9 @@ switch($_GET["action"]) {
if (!$stmt->execute()) { if (!$stmt->execute()) {
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error; $errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
} }
makethumb($hash); if(!makethumb($hash)){
$errormsg = "thumbnail creation failed";
}
$successmsg = "upload ok"; $successmsg = "upload ok";
}else{ }else{
$errormsg = "upload failed"; $errormsg = "upload failed";
@ -210,68 +209,7 @@ switch($_GET["action"]) {
} }
break; break;
case "get_found_table": case "get_found_table":
?> include "templates/found_item_table.php";
<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>kiste</th>
<th>foto</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kiste</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><?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"]; ?>', '<?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>
</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; exit;
break; break;
default: default:

7
css/c3cloc.css Normal file
View file

@ -0,0 +1,7 @@
#img-upload{
width: 100%;
}
#img-zoom{
width: 100%;
}

View file

@ -42,13 +42,25 @@ function get_lostitems($onlyUnmatched = false){
function get_founditem($id){ function get_founditem($id){
global $mysqli; global $mysqli;
$res = $mysqli->query("SELECT * FROM found_items, files WHERE found_items.id = $id AND found_items.id = files.item_id ORDER BY files.id DESC"); $res = $mysqli->query("SELECT * FROM found_items, files WHERE MD5(found_items.id) = '".md5($id)."' AND found_items.id = files.item_id ORDER BY files.id DESC");
$ret = array(); if ($row = $res->fetch_assoc()) {
while ($row = $res->fetch_assoc()) { return $row;
$ret[] = $row; }else{
return false;
}
}
function get_founditem_by_uid($uid){
global $mysqli;
$res = $mysqli->query("SELECT * FROM found_items, files WHERE MD5(found_items.uid) = '".md5($uid)."' AND found_items.id = files.item_id ORDER BY files.id DESC");
if ($row = $res->fetch_assoc()) {
return $row;
}else{
return false;
} }
return $ret;
} }
function get_matches(){ function get_matches(){

View file

@ -72,15 +72,6 @@
</script> </script>
<!-- Bootstrap core JavaScript-->
<script src="/vendor/jquery/jquery.min.js"></script>
<script src="/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="/vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Page level plugin JavaScript--> <!-- Page level plugin JavaScript-->
<script src="/vendor/chart.js/Chart.min.js"></script> <script src="/vendor/chart.js/Chart.min.js"></script>

View file

@ -7,13 +7,6 @@
*/ */
?> ?>
<style>
#img-upload{
width: 100%;
}
</style>
<div class="container-fluid"> <div class="container-fluid">
<!-- Breadcrumbs--> <!-- Breadcrumbs-->
@ -24,6 +17,10 @@
<li class="breadcrumb-item active">Found</li> <li class="breadcrumb-item active">Found</li>
</ol> </ol>
<?php
//include "templates/popups.php"
?>
<div id="alertmessage" class="collapse alert alert-danger" role="alert"> <div id="alertmessage" class="collapse alert alert-danger" role="alert">
This is a danger alert—check it out! This is a danger alert—check it out!
</div> </div>
@ -33,44 +30,9 @@
A simple success alert—check it out! A simple success alert—check it out!
</div> </div>
<!-- Area Chart Example--> <?php
<div class="card mb-3"> include "templates/found_item_add.php"
<div class="card-header"> ?>
<i class="fas fa-plus"></i>
Add Found Item
</div>
<div class="card-body">
<form method="POST" action="#" id="lost_form">
<!--div-- class="form-group">
<input type="text" class="form-control" placeholder="WANN" name="wann" value="<?php echo date("Y-m-d H:i:s");?>"></p>
</div-->
<div class="form-group">
<input type="text" class="form-control" placeholder="WAS" name="was" autocomplete="off">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="KISTE" name="container" autocomplete="off">
</div>
<div class="form-group">
<div class="input-group">
<div class="custom-file btn-file">
<input type="file" class="custom-file-input" id="inputGroupImage" name="image" accept="image/*" capture="environment">
<label class="custom-file-label" for="inputGroupImage">Choose Image</label>
<input type="text" class="form-control" readonly>
</div>
</div>
<img id='img-upload'/>
</div>
<div class="form-group">
<button type="submit" class="form-control btn btn-primary" onclick="add_found_item(); return false;">Submit</button>
</div>
</form>
</div>
<!--div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div-->
</div>
<!-- DataTables Example --> <!-- DataTables Example -->
@ -80,51 +42,9 @@
Lost Items</div> Lost Items</div>
<div class="card-body"> <div class="card-body">
<div class="table-responsive"> <div class="table-responsive">
<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>kontakt</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kontakt</th>
</tr>
</tfoot>
<tbody>
<?php <?php
foreach( get_lostitems(true) as $item){ include "templates/lost_item_table.php"
?> ?>
<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><?php echo $item["contact"]; ?></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>
</div> </div>
</div> </div>
<!--div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div--> <!--div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div-->
@ -132,163 +52,3 @@
</div> </div>
<!-- /.container-fluid --> <!-- /.container-fluid -->
<script>
function add_found_item(){
var fileInput = document.querySelector('#inputGroupImage');
var xhr = new XMLHttpRequest();
xhr.open('POST', '/ajax.php?action=add_found_item');
xhr.upload.onprogress = function(e)
{
/*
* values that indicate the progression
* e.loaded
* e.total
*/
$("#alertmessage").collapse('hide');
$("#successmessage").html((100*e.loaded/e.total)+"%").collapse('show');
console.log("progress");
console.log(e);
};
xhr.upload.onabort = function (e) {
console.log("abort");
console.log(e);
};
xhr.upload.onload = function (e) {
console.log("load");
console.log(e);
};
xhr.upload.ontimeout = function (e) {
console.log("timeout");
console.log(e);
};
xhr.upload.onerror = function (e) {
console.log("error");
console.log(e);
$("#successmessage").collapse('hide');
$("#alertmessage").html("error").collapse('show');
};
xhr.onload = function(e)
{
console.log("foo load");
console.log(e);
reply = JSON.parse(xhr.responseText);
console.log(reply);
if(reply.status == "ok"){
$( "#lost_form" ).trigger("reset");
$('#img-upload').attr('src', "");
$("#alertmessage").collapse('hide');
$("#successmessage").html(reply.message).collapse('show');
}else{
$("#successmessage").collapse('hide');
$("#alertmessage").html(reply.message).collapse('show');
}
};
// upload success
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status != 200) {
reply = JSON.parse(xhr.responseText);
console.log(reply);
$("#successmessage").collapse('hide');
$("#alertmessage").html(reply.message).collapse('show');
}
}else{
console.log(xhr.readyState);
}
}
var form = new FormData(document.querySelector("#lost_form"));
form.append('title', fileInput.files[0].name);
form.append('image', fileInput.files[0]);
xhr.send(form);
/*
$.post( "/ajax.php?action=add_found_item", $( "#lost_form" ).serialize() ).done(function( data ) {;
reply = JSON.parse(data);
if(reply.status == "ok"){
$( "#lost_form" ).trigger("reset");
$("#alertmessage").collapse('hide');
$("#successmessage").html(reply.message).collapse('show');
}else{
$("#successmessage").collapse('hide');
$("#alertmessage").html(reply.message).collapse('show');
}
}).fail(function() {
$("#successmessage").collapse('hide');
$("#alertmessage").html("error").collapse('show');
});*/
}
</script>
<!-- Page level plugin JavaScript-->
<script src="/vendor/chart.js/Chart.min.js"></script>
<!-- Custom scripts for all pages-->
<script src="/js/sb-admin.min.js"></script>
<!-- Demo scripts for this page-->
<script src="/js/demo/chart-area-demo.js"></script>
<script src="/js/demo/chart-bar-demo.js"></script>
<script src="/js/demo/chart-pie-demo.js"></script>
<script>
$(document).ready( function() {
$(document).on('change', '.btn-file :file', function() {
var input = $(this),
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [label]);
});
$('.btn-file :file').on('fileselect', function(event, label) {
var input = $(this).parents('.input-group').find(':text'),
log = label;
if( input.length ) {
input.val(log);
} else {
if( log ) alert(log);
}
});
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#img-upload').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#inputGroupImage").change(function(){
readURL(this);
});
});
</script>

View file

@ -0,0 +1,175 @@
<?php
/**
* Created by PhpStorm.
* User: jedi
* Date: 2/22/19
* Time: 11:31 PM
*/
?>
<div class="card mb-3">
<div class="card-header">
<i class="fas fa-plus"></i>
Add Found Item
</div>
<div class="card-body">
<form method="POST" action="" id="lost_form">
<div class="form-group">
<input type="text" class="form-control" placeholder="UID" name="uid" value="<?php echo $uid; ?>"></p>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="WAS" name="was" autocomplete="off">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="KISTE" name="container" autocomplete="off">
</div>
<div class="form-group">
<div class="input-group">
<div class="custom-file btn-file">
<input type="file" class="custom-file-input" id="inputGroupImage" name="image" accept="image/*" capture="environment">
<label class="custom-file-label" for="inputGroupImage">Choose Image</label>
<input type="text" class="form-control" readonly>
</div>
</div>
<img id='img-upload'/>
</div>
<div class="form-group">
<button type="submit" class="form-control btn btn-primary" onclick="add_found_item(); return false;">Submit</button>
</div>
</form>
</div>
<!--div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div-->
</div>
<script>
function add_found_item(){
var fileInput = document.querySelector('#inputGroupImage');
var xhr = new XMLHttpRequest();
xhr.open('POST', '/ajax.php?action=add_found_item');
xhr.upload.onprogress = function(e)
{
/*
* values that indicate the progression
* e.loaded
* e.total
*/
$("#alertmessage").collapse('hide');
$("#successmessage").html((100*e.loaded/e.total)+"%").collapse('show');
console.log("progress");
console.log(e);
};
xhr.upload.onabort = function (e) {
console.log("abort");
console.log(e);
};
xhr.upload.onload = function (e) {
console.log("load");
console.log(e);
};
xhr.upload.ontimeout = function (e) {
console.log("timeout");
console.log(e);
};
xhr.upload.onerror = function (e) {
console.log("error");
console.log(e);
$("#successmessage").collapse('hide');
$("#alertmessage").html("error").collapse('show');
};
xhr.onload = function(e)
{
console.log("foo load");
console.log(e);
reply = JSON.parse(xhr.responseText);
console.log(reply);
if(reply.status == "ok"){
$( "#lost_form" ).trigger("reset");
$('#img-upload').attr('src', "");
$("#alertmessage").collapse('hide');
$("#successmessage").html(reply.message).collapse('show');
location.reload();
}else{
$("#successmessage").collapse('hide');
$("#alertmessage").html(reply.message).collapse('show');
}
};
// upload success
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status != 200) {
reply = JSON.parse(xhr.responseText);
console.log(reply);
$("#successmessage").collapse('hide');
$("#alertmessage").html(reply.message).collapse('show');
}
}else{
console.log(xhr.readyState);
}
}
var form = new FormData(document.querySelector("#lost_form"));
form.append('title', fileInput.files[0].name);
form.append('image', fileInput.files[0]);
xhr.send(form);
}
$(document).ready( function() {
$(document).on('change', '.btn-file :file', function() {
var input = $(this),
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [label]);
});
$('.btn-file :file').on('fileselect', function(event, label) {
var input = $(this).parents('.input-group').find(':text'),
log = label;
if( input.length ) {
input.val(log);
} else {
if( log ) alert(log);
}
});
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#img-upload').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#inputGroupImage").change(function(){
readURL(this);
});
});
</script>

View file

@ -1,34 +1,4 @@
<?php
$id = $_GET["id"];
$item = get_founditem($id)[0];
?>
<style>
#img-upload{
width: 100%;
}
</style>
<div class="container-fluid">
<!-- Breadcrumbs-->
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="#">Dashboard</a>
</li>
<li class="breadcrumb-item">Found</li>
<li class="breadcrumb-item active">Edit</li>
</ol>
<div id="alertmessage" class="collapse alert alert-danger" role="alert">
This is a danger alert—check it out!
</div>
<div id="successmessage" class="collapse alert alert-success" role="alert">
A simple success alert—check it out!
</div>
<!-- Area Chart Example--> <!-- Area Chart Example-->
<div class="card mb-3"> <div class="card mb-3">
@ -37,8 +7,9 @@ $item = get_founditem($id)[0];
Edit Item Edit Item
</div> </div>
<div class="card-body"> <div class="card-body">
<form method="POST" action="/action.php?action=edit_found" id="found_form"> <form method="POST" action="" id="found_form">
<p><input type="text" readonly="true" class="form-control" placeholder="ID" name="id" value="<?php echo $id; ?>"></p> <p><input type="text" readonly="true" class="form-control" placeholder="ID" name="id" value="<?php echo $item["id"]; ?>"></p>
<p><input type="text" readonly="true" class="form-control" placeholder="UID" name="uid" value="<?php echo $item["uid"]; ?>"></p>
<p><input type="text" class="form-control" placeholder="WANN" name="wann" value="<?php echo $item["date"]; ?>"></p> <p><input type="text" class="form-control" placeholder="WANN" name="wann" value="<?php echo $item["date"]; ?>"></p>
<p><input type="text" class="form-control" placeholder="WO" name="wo" value="<?php echo $item["wo"]; ?>"></p> <p><input type="text" class="form-control" placeholder="WO" name="wo" value="<?php echo $item["wo"]; ?>"></p>
<p><input type="text" class="form-control" placeholder="WAS" name="was" value="<?php echo $item["was"]; ?>"></p> <p><input type="text" class="form-control" placeholder="WAS" name="was" value="<?php echo $item["was"]; ?>"></p>
@ -55,11 +26,8 @@ $item = get_founditem($id)[0];
<p><button type="submit" class="form-control" onclick="edit_found_item(); return false;">Save</button></p> <p><button type="submit" class="form-control" onclick="edit_found_item(); return false;">Save</button></p>
</form> </form>
</div> </div>
<div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div>
</div> </div>
</div>
<!-- /.container-fluid -->
<script> <script>
@ -150,48 +118,8 @@ $item = get_founditem($id)[0];
xhr.send(form); xhr.send(form);
/*
$.post( "/ajax.php?action=add_found_item", $( "#lost_form" ).serialize() ).done(function( data ) {;
reply = JSON.parse(data);
if(reply.status == "ok"){
$( "#lost_form" ).trigger("reset");
$("#alertmessage").collapse('hide');
$("#successmessage").html(reply.message).collapse('show');
}else{
$("#successmessage").collapse('hide');
$("#alertmessage").html(reply.message).collapse('show');
}
}).fail(function() {
$("#successmessage").collapse('hide');
$("#alertmessage").html("error").collapse('show');
});*/
} }
</script>
<!-- Bootstrap core JavaScript-->
<script src="/vendor/jquery/jquery.min.js"></script>
<script src="/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="/vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Page level plugin JavaScript-->
<script src="/vendor/chart.js/Chart.min.js"></script>
<!-- Custom scripts for all pages-->
<script src="/js/sb-admin.min.js"></script>
<!-- Demo scripts for this page-->
<script src="/js/demo/chart-area-demo.js"></script>
<script src="/js/demo/chart-bar-demo.js"></script>
<script src="/js/demo/chart-pie-demo.js"></script>
<script>
$(document).ready( function() { $(document).ready( function() {
$(document).on('change', '.btn-file :file', function() { $(document).on('change', '.btn-file :file', function() {

View file

@ -0,0 +1,78 @@
<?php
/**
* Created by PhpStorm.
* User: jedi
* Date: 2/22/19
* Time: 9:34 PM
*/
?>
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>UID</th>
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kiste</th>
<th>foto</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>UID</th>
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kiste</th>
<th>foto</th>
<th></th>
</tr>
</tfoot>
<tbody>
<?php
foreach( get_founditems(true) as $item){
?>
<tr>
<td><?php echo $item["uid"]; ?> </td>
<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>
<button class="btn btn-link" data-toggle="modal" data-target="#exampleModal_picture" onclick="show_picture('<?php echo $item["hash"]; ?>')">
<img style="height: 48px;" src="/thumb/<?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"]; ?>','<?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>
</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>

View file

@ -5,34 +5,12 @@
* Date: 12/27/18 * Date: 12/27/18
* Time: 4:46 AM * Time: 4:46 AM
*/ */
if(isset($_GET["event"])&&isset($_GET["id"])){
$uid = $_GET["id"];
}
?> ?>
<style>
.btn-file {
position: relative;
overflow: hidden;
}
.btn-file input[type=file] {
position: absolute;
top: 0;
right: 0;
min-width: 100%;
min-height: 100%;
font-size: 100px;
text-align: right;
filter: alpha(opacity=0);
opacity: 0;
outline: none;
background: white;
cursor: inherit;
display: block;
}
#img-upload{
width: 100%;
}
</style>
<div class="container-fluid"> <div class="container-fluid">
<!-- Breadcrumbs--> <!-- Breadcrumbs-->
@ -40,8 +18,7 @@
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="#">Dashboard</a> <a href="#">Dashboard</a>
</li> </li>
<li class="breadcrumb-item">Lost</li> <li class="breadcrumb-item active">Found</li>
<li class="breadcrumb-item active">Add</li>
</ol> </ol>
<div id="alertmessage" class="collapse alert alert-danger" role="alert"> <div id="alertmessage" class="collapse alert alert-danger" role="alert">
@ -53,97 +30,10 @@
A simple success alert—check it out! A simple success alert—check it out!
</div> </div>
<!-- Area Chart Example--> <?php
<div class="card mb-3"> if($item = get_founditem_by_uid($uid)){
<div class="card-header"> include "templates/found_item_edit.php";
<i class="fas fa-plus"></i>
Insert Item into DB
</div>
<div class="card-body">
<form method="POST" action="/action.php?action=lost" id="lost_form">
<p><input type="text" class="form-control" placeholder="WANN" name="wann" value="<?php echo date("Y-m-d H:i:s");?>"></p>
<p><input type="file" accept="image/*;capture=camera"></p>
<p><input type="file" name="image" accept="image/*" capture="environment"></p>
<p><input type="text" class="form-control" placeholder="KONTAKT" name="contact" autocomplete="off"></p>
<p><button type="submit" class="form-control" onclick="testajax(); return false;">Submit</button></p>
<div class="form-group">
<img id='img-upload'/>
<div class="input-group">
<div class="custom-file btn-file">
<input type="file" class="custom-file-input" id="inputGroupImage" name="image" accept="image/*" capture="environment">
<label class="custom-file-label" for="inputGroupImage">Choose file</label>
<input type="text" class="form-control" readonly>
</div>
</div>
</div>
</form>
</div>
<div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div>
</div>
</div>
<!-- /.container-fluid -->
<!-- Bootstrap core JavaScript-->
<script src="/vendor/jquery/jquery.min.js"></script>
<script src="/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="/vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Page level plugin JavaScript-->
<script src="/vendor/chart.js/Chart.min.js"></script>
<!-- Custom scripts for all pages-->
<script src="/js/sb-admin.min.js"></script>
<!-- Demo scripts for this page-->
<script src="/js/demo/chart-area-demo.js"></script>
<script src="/js/demo/chart-bar-demo.js"></script>
<script src="/js/demo/chart-pie-demo.js"></script>
<script>
$(document).ready( function() {
$(document).on('change', '.btn-file :file', function() {
var input = $(this),
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [label]);
});
$('.btn-file :file').on('fileselect', function(event, label) {
var input = $(this).parents('.input-group').find(':text'),
log = label;
if( input.length ) {
input.val(log);
}else{ }else{
if( log ) alert(log); include "templates/found_item_add.php";
} }
?>
});
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#img-upload').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#inputGroupImage").change(function(){
readURL(this);
});
});
</script>

View file

@ -18,14 +18,9 @@
<li class="breadcrumb-item active">Lost</li> <li class="breadcrumb-item active">Lost</li>
</ol> </ol>
<div id="alertmessage" class="collapse alert alert-danger" role="alert"> <?php
This is a danger alert—check it out! include "templates/popups.php"
</div> ?>
<div id="successmessage" class="collapse alert alert-success" role="alert">
A simple success alert—check it out!
</div>
<!-- Area Chart Example--> <!-- Area Chart Example-->
<div class="card mb-3"> <div class="card mb-3">
@ -35,11 +30,21 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<form method="POST" action="/action.php?action=lost" id="lost_form"> <form method="POST" action="/action.php?action=lost" id="lost_form">
<p><input type="text" class="form-control" placeholder="WANN" name="wann" value="<?php echo date("Y-m-d H:i:s");?>"></p> <div class="form-group">
<p><input type="text" class="form-control" placeholder="WO" name="wo"></p> <input type="text" class="form-control" placeholder="WANN" name="wann" value="<?php echo date("Y-m-d H:i:s");?>">
<p><input type="text" class="form-control" placeholder="WAS" name="was"></p> </div>
<p><input type="text" class="form-control" placeholder="KONTAKT" name="contact" autocomplete="off"></p> <div class="form-group">
<p><button type="submit" class="form-control" onclick="testajax(); return false;">Submit</button></p> <input type="text" class="form-control" placeholder="WO" name="wo">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="WAS" name="was">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="KONTAKT" name="contact" autocomplete="off">
</div>
<div class="form-group">
<button type="submit" class="form-control btn btn-primary" onclick="testajax(); return false;">Submit</button>
</div>
</form> </form>
</div> </div>
<!--div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div--> <!--div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div-->
@ -51,61 +56,10 @@
<i class="fas fa-table"></i> <i class="fas fa-table"></i>
Found Items</div> Found Items</div>
<div class="card-body"> <div class="card-body">
<div class="table-responsive"> <div class="table-responsive" id="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 <?php
foreach( get_founditems(true) as $item){ include "templates/found_item_table.php";
?> ?>
<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="/thumb/<?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-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>
</div> </div>
</div> </div>
<!--div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div--> <!--div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div-->
@ -136,6 +90,180 @@
</script> </script>
<script>
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;
}
function show_picture(hash){
document.getElementById('img-zoom').src = "/upload/"+hash;
}
function delete_item(id){
$.post( "/ajax.php?action=delete_found_item", {id: id} ).done(function( data ) {
reply = JSON.parse(data);
if(reply.status == "ok"){
update_found_table();
$("#alertmessage").collapse('hide');
$("#successmessage").html(reply.message).collapse('show');
}else{
$("#successmessage").collapse('hide');
$("#alertmessage").html(reply.message).collapse('show');
}
}).fail(function() {
$("#successmessage").collapse('hide');
$("#alertmessage").html("error").collapse('show');
});
}
function update_found_table() {
$.get( "/ajax.php?action=get_found_table" ).done(function( data ) {
$("#found_table").html(data);
}).fail(function() {
$("#successmessage").collapse('hide');
$("#alertmessage").html("error").collapse('show');
});
}
function edit_found_item() {
var fileInput = document.querySelector('#inputGroupImage');
var xhr = new XMLHttpRequest();
xhr.open('POST', '/ajax.php?action=edit_found_item');
xhr.upload.onprogress = function (e) {
/*
* values that indicate the progression
* e.loaded
* e.total
*/
$("#alertmessage").collapse('hide');
$("#successmessage").html((100 * e.loaded / e.total) + "%").collapse('show');
console.log("progress");
console.log(e);
};
xhr.upload.onabort = function (e) {
console.log("abort");
console.log(e);
};
xhr.upload.onload = function (e) {
console.log("load");
console.log(e);
};
xhr.upload.ontimeout = function (e) {
console.log("timeout");
console.log(e);
};
xhr.upload.onerror = function (e) {
console.log("error");
console.log(e);
$("#successmessage").collapse('hide');
$("#alertmessage").html("error").collapse('show');
};
xhr.onload = function (e) {
console.log("foo load");
console.log(e);
reply = JSON.parse(xhr.responseText);
console.log(reply);
if (reply.status == "ok") {
$("#lost_form").trigger("reset");
$('#img-upload').attr('src', "");
$("#alertmessage").collapse('hide');
$("#successmessage").html(reply.message).collapse('show');
update_found_table();
} else {
$("#successmessage").collapse('hide');
$("#alertmessage").html(reply.message).collapse('show');
}
};
// upload success
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status != 200) {
reply = JSON.parse(xhr.responseText);
console.log(reply);
$("#successmessage").collapse('hide');
$("#alertmessage").html(reply.message).collapse('show');
}
} else {
console.log(xhr.readyState);
}
}
var form = new FormData(document.querySelector("#found_form"));
if(fileInput.files.length >0) {
form.append('title', fileInput.files[0].name);
form.append('image', fileInput.files[0]);
}
xhr.send(form);
}
</script>
<script>
$(document).ready( function() {
$(document).on('change', '.btn-file :file', function() {
var input = $(this),
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [label]);
});
$('.btn-file :file').on('fileselect', function(event, label) {
var input = $(this).parents('.input-group').find(':text'),
log = label;
if( input.length ) {
input.val(log);
} else {
if( log ) alert(log);
}
});
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#img-upload').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#inputGroupImage").change(function(){
readURL(this);
});
});
</script>
<!-- Page level plugin JavaScript--> <!-- Page level plugin JavaScript-->
<script src="/vendor/chart.js/Chart.min.js"></script> <script src="/vendor/chart.js/Chart.min.js"></script>

View file

@ -0,0 +1,53 @@
<?php
/**
* Created by PhpStorm.
* User: jedi
* Date: 2/22/19
* Time: 9:50 PM
*/
?>
<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>kontakt</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kontakt</th>
</tr>
</tfoot>
<tbody>
<?php
foreach( get_lostitems(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><?php echo $item["contact"]; ?></td>
<!--td>
<?php
foreach(explode(",",$item["tags"]) as $tag){
?>
<span class="label label-default"><?php echo $tag; ?></span>
<?php
}
?>
</td-->
</tr>
<?php
}
?>
</tbody>
</table>

View file

@ -30,6 +30,7 @@
<!-- Custom styles for this template--> <!-- Custom styles for this template-->
<link href="/css/sb-admin.css" rel="stylesheet"> <link href="/css/sb-admin.css" rel="stylesheet">
<link href="/css/c3cloc.css" rel="stylesheet">
<!-- Bootstrap core JavaScript--> <!-- Bootstrap core JavaScript-->
<script src="/vendor/jquery/jquery.min.js"></script> <script src="/vendor/jquery/jquery.min.js"></script>

91
templates/popups.php Normal file
View file

@ -0,0 +1,91 @@
<?php
/**
* Created by PhpStorm.
* User: jedi
* Date: 2/22/19
* Time: 10:03 PM
*/
?>
<div id="alertmessage" class="collapse alert alert-danger" role="alert">
This is a danger alert—check it out!
</div>
<div id="successmessage" class="collapse alert alert-success" role="alert">
A simple success alert—check it out!
</div>
<!-- Modal Edit Found Item -->
<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-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="card mb-3">
<div class="card-header">
<i class="fas fa-edit"></i>
Edit Item
</div>
<div class="card-body">
<form method="POST" action="/action.php?action=edit_found" id="found_form">
<p><input type="text" readonly="true" class="form-control" placeholder="ID" name="id" id="id" value=""></p>
<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">
<div class="custom-file btn-file">
<input type="file" class="custom-file-input" id="inputGroupImage" name="image" accept="image/*" capture="environment">
<label class="custom-file-label" for="inputGroupImage">Choose Image</label>
</div>
</div>
<img id='img-upload' src="/upload/"/>
</div>
<div class="form-group">
<button type="submit" data-dismiss="modal" class="btn btn-primary form-control" onclick="edit_found_item(); return false;">Save</button>
</div>
<div class="form-group">
<button type="button" class="btn btn-secondary form-control" data-dismiss="modal">Close</button>
</div>
</form>
</div>
<div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal Picture Zoom -->
<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">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<img id='img-zoom' src="/upload/"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

View file

@ -6,14 +6,6 @@
* Time: 4:48 AM * Time: 4:48 AM
*/ */
?> ?>
<style>
#img-upload{
width: 100%;
}
#img-zoom{
width: 100%;
}
</style>
<div class="container-fluid"> <div class="container-fluid">
@ -25,87 +17,13 @@
<li class="breadcrumb-item active">Found</li> <li class="breadcrumb-item active">Found</li>
</ol> </ol>
<div id="alertmessage" class="collapse alert alert-danger" role="alert"> <?php
This is a danger alert—check it out! include "templates/popups.php"
</div> ?>
<div id="successmessage" class="collapse alert alert-success" role="alert">
A simple success alert—check it out!
</div>
<!-- Modal Edit Found Item -->
<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-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="card mb-3">
<div class="card-header">
<i class="fas fa-edit"></i>
Edit Item
</div>
<div class="card-body">
<form method="POST" action="/action.php?action=edit_found" id="found_form">
<p><input type="text" readonly="true" class="form-control" placeholder="ID" name="id" id="id" value=""></p>
<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">
<div class="custom-file btn-file">
<input type="file" class="custom-file-input" id="inputGroupImage" name="image" accept="image/*" capture="environment">
<label class="custom-file-label" for="inputGroupImage">Choose Image</label>
</div>
</div>
<img id='img-upload' src="/upload/"/>
</div>
<div class="form-group">
<button type="submit" data-dismiss="modal" class="btn btn-primary form-control" onclick="edit_found_item(); return false;">Save</button>
</div>
<div class="form-group">
<button type="button" class="btn btn-secondary form-control" data-dismiss="modal">Close</button>
</div>
</form>
</div>
<div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal Picture Zoom -->
<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">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<img id='img-zoom' src="/upload/"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- DataTables Example --> <!-- DataTables Example -->
<div class="card mb-3"> <div class="card mb-3">
@ -114,67 +32,9 @@
Data Table Example</div> Data Table Example</div>
<div class="card-body"> <div class="card-body">
<div class="table-responsive" id="found_table"> <div class="table-responsive" id="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>kiste</th>
<th>foto</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>was</th>
<th>wann</th>
<th>wo</th>
<th>kiste</th>
<th>foto</th>
<th></th>
</tr>
</tfoot>
<tbody>
<?php <?php
foreach( get_founditems(true) as $item){ include "templates/found_item_table.php";
?> ?>
<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><?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"]; ?>','<?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>
</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>
</div> </div>
</div> </div>
<div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div> <div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div>