2018-12-27 04:24:44 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: jedi
|
|
|
|
* Date: 12/27/18
|
|
|
|
* Time: 4:48 AM
|
|
|
|
*/
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div class="container-fluid">
|
|
|
|
|
|
|
|
<!-- Breadcrumbs-->
|
|
|
|
<ol class="breadcrumb">
|
|
|
|
<li class="breadcrumb-item">
|
|
|
|
<a href="#">Dashboard</a>
|
|
|
|
</li>
|
2018-12-27 18:51:29 +00:00
|
|
|
<li class="breadcrumb-item active">Found</li>
|
2018-12-27 04:24:44 +00:00
|
|
|
</ol>
|
|
|
|
|
2019-02-23 09:43:45 +00:00
|
|
|
<?php
|
|
|
|
include "templates/popups.php"
|
|
|
|
?>
|
2019-02-21 23:10:56 +00:00
|
|
|
|
2019-02-22 14:30:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-12-27 04:24:44 +00:00
|
|
|
<!-- DataTables Example -->
|
|
|
|
<div class="card mb-3">
|
|
|
|
<div class="card-header">
|
|
|
|
<i class="fas fa-table"></i>
|
|
|
|
Data Table Example</div>
|
|
|
|
<div class="card-body">
|
2019-02-22 14:30:43 +00:00
|
|
|
<div class="table-responsive" id="found_table">
|
2019-02-23 09:43:45 +00:00
|
|
|
<?php
|
|
|
|
include "templates/found_item_table.php";
|
|
|
|
?>
|
2019-03-02 01:17:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-12-27 04:24:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<p class="small text-center text-muted my-5">
|
|
|
|
<em>More table examples coming soon...</em>
|
|
|
|
</p>
|
|
|
|
|
2019-02-21 23:10:56 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
|
2019-03-02 01:16:37 +00:00
|
|
|
function fill_edit_form(item) {
|
|
|
|
document.getElementById('id').value = item.id;
|
|
|
|
document.getElementById('was').value = item.was;
|
|
|
|
document.getElementById('wann').value = item.wann;
|
|
|
|
document.getElementById('wo').value = item.wo;
|
|
|
|
document.getElementById('container').value = item.container;
|
|
|
|
if(item.files&&item.files.length>0){
|
|
|
|
document.getElementById('img-upload').src = "/upload/"+item.files[0].hash;
|
|
|
|
}else{
|
|
|
|
document.getElementById('img-upload').src = "";
|
|
|
|
}
|
2019-02-22 14:30:43 +00:00
|
|
|
|
2019-02-22 19:47:26 +00:00
|
|
|
}
|
2019-02-22 14:30:43 +00:00
|
|
|
|
2019-02-22 19:47:26 +00:00
|
|
|
function show_picture(hash){
|
|
|
|
document.getElementById('img-zoom').src = "/upload/"+hash;
|
2019-02-22 14:30:43 +00:00
|
|
|
}
|
|
|
|
|
2019-02-21 23:10:56 +00:00
|
|
|
function delete_item(id){
|
2019-02-22 14:30:43 +00:00
|
|
|
$.post( "/ajax.php?action=delete_found_item", {id: id} ).done(function( data ) {
|
2019-02-21 23:10:56 +00:00
|
|
|
reply = JSON.parse(data);
|
|
|
|
if(reply.status == "ok"){
|
2019-02-22 14:30:43 +00:00
|
|
|
update_found_table();
|
2019-02-21 23:10:56 +00:00
|
|
|
$("#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');
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-02-22 14:30:43 +00:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-02-21 23:10:56 +00:00
|
|
|
</script>
|
|
|
|
|
2018-12-27 04:24:44 +00:00
|
|
|
</div>
|
|
|
|
<!-- /.container-fluid -->
|
|
|
|
|