diff --git a/cont/list.php b/cont/list.php
index 9c57aad..2d87d95 100644
--- a/cont/list.php
+++ b/cont/list.php
@@ -38,15 +38,15 @@
print_r("
");
print_r("
");
- print_r("
$item->Anzahl $item->Einheit
");
- print_r("
$item->Name
");
+ print_r("
$item->Anzahl $item->Einheit
");
+ print_r("
$item->Name
");
print_r("");
print_r("
");
diff --git a/js/list.js b/js/list.js
index f39f8f2..ff115a9 100644
--- a/js/list.js
+++ b/js/list.js
@@ -5,6 +5,8 @@ $(document).ready(function () {
$("#nameField").focus();
$("#anzahl").on("focus", function () { $(this).select(); });
$("#nameField").on("focus", function () { $(this).select(); });
+ $(".edit-listitem").click(editItem);
+ $(".del-listitem").click(deleteSingleItem);
});
function highlightNewEntry(){
@@ -27,16 +29,37 @@ function highlightNewEntry(){
function deleteCheckeditems() {
$.post({
- url: "api/list/del",
- data: {
- function: "del"
- },
+ url: "api/list/clear",
success: function () {
location.reload();
}
});
}
+function deleteSingleItem() {
+ var id = $(this).parent().parent().parent().find("input[type=checkbox]").data("id");
+ $.post({
+ url: "api/list/del",
+ data: {
+ id: id
+ },
+ success: function (data) {
+ location.reload();
+ }
+ });
+}
+
+function editItem(){
+ var row = $(this).parent().parent().parent();
+ var amount = row.find(".list-row-amount").data("amount");
+ var unit = row.find(".list-row-amount").data("unit");
+ var name = row.find(".list-row-name").html();
+ row.find(".list-row-amount").html("");
+ row.find(".list-row-name").html("");
+ row.find(".list-row-amount").append("");
+ row.find(".list-row-name").append('');
+}
+
function checkItem() {
var dataId = $(this).data("id");
$.post({
diff --git a/php/classes.list.php b/php/classes.list.php
index f6c0e3a..74c22f5 100644
--- a/php/classes.list.php
+++ b/php/classes.list.php
@@ -52,6 +52,15 @@
}
}
+ function removeSingleItem($id){
+ include $_SESSION["docroot"].'/config/config.php';
+ include $_SESSION["docroot"].'/php/connect.php';
+ $deleteQuery = $mysqli->prepare("DELETE FROM `Einkauf` WHERE `Einkauf`.`ID` = ?;");
+ $deleteQuery->bind_param("s", $id);
+ $deleteQuery->execute();
+ $mysqli->close();
+ }
+
function removeChecked(){
include $_SESSION["docroot"].'/config/config.php';
include $_SESSION["docroot"].'/php/connect.php';
diff --git a/php/edit-list.php b/php/edit-list.php
index 76dff09..eb5a4f6 100644
--- a/php/edit-list.php
+++ b/php/edit-list.php
@@ -14,6 +14,10 @@
break;
case 'del':
+ $shopping->removeSingleItem($_POST["id"]);
+ break;
+
+ case 'clear':
$shopping->removeChecked();
break;