diff --git a/module/LogisticsBundle/Controller/FlesserkeArticleController.php b/module/LogisticsBundle/Controller/FlesserkeArticleController.php
index 21d341cfa3..ebf91924a3 100644
--- a/module/LogisticsBundle/Controller/FlesserkeArticleController.php
+++ b/module/LogisticsBundle/Controller/FlesserkeArticleController.php
@@ -143,6 +143,25 @@ public function editAction(): ViewModel
);
}
+ public function deleteAction()
+ {
+ $this->initAjax();
+
+ $article = $this->getFlesserkeArticleEntity();
+ if ($article === null) {
+ return new ViewModel();
+ }
+
+ $this->getEntityManager()->remove($article);
+ $this->getEntityManager()->flush();
+
+ return new ViewModel(
+ array(
+ 'result' => (object) array('status' => 'success'),
+ )
+ );
+ }
+
public function searchAction(): ViewModel
{
$this->initAjax();
diff --git a/module/LogisticsBundle/Controller/InventoryArticleController.php b/module/LogisticsBundle/Controller/InventoryArticleController.php
index d9d9d12371..064474f7e7 100644
--- a/module/LogisticsBundle/Controller/InventoryArticleController.php
+++ b/module/LogisticsBundle/Controller/InventoryArticleController.php
@@ -384,6 +384,25 @@ public function editArticlesAction(): ViewModel
);
}
+ public function deleteAction()
+ {
+ $this->initAjax();
+
+ $article = $this->getInventoryArticleEntity();
+ if ($article === null) {
+ return new ViewModel();
+ }
+
+ $this->getEntityManager()->remove($article);
+ $this->getEntityManager()->flush();
+
+ return new ViewModel(
+ array(
+ 'result' => (object) array('status' => 'success'),
+ )
+ );
+ }
+
public function searchArticlesAction(): ViewModel
{
$this->initAjax();
diff --git a/module/LogisticsBundle/Resources/config/install/acl.config.php b/module/LogisticsBundle/Resources/config/install/acl.config.php
index 866114851e..e0c119996c 100644
--- a/module/LogisticsBundle/Resources/config/install/acl.config.php
+++ b/module/LogisticsBundle/Resources/config/install/acl.config.php
@@ -51,10 +51,10 @@
'index', 'view', 'add', 'edit', 'cancel', 'remove',
),
'logistics_inventory_article' => array(
- 'index', 'add', 'edit', 'search', 'addArticles', 'editArticles', 'searchArticles',
+ 'index', 'add', 'delete', 'edit', 'search', 'addArticles', 'editArticles', 'searchArticles',
),
'logistics_flesserke_article' => array(
- 'index', 'add', 'edit', 'search', 'addArticles', 'editArticles', 'searchArticles',
+ 'index', 'add', 'delete', 'edit', 'search', 'addArticles', 'editArticles', 'searchArticles',
),
),
);
diff --git a/module/LogisticsBundle/Resources/views/logistics/flesserke-article/delete.twig b/module/LogisticsBundle/Resources/views/logistics/flesserke-article/delete.twig
new file mode 100644
index 0000000000..89e8fe679b
--- /dev/null
+++ b/module/LogisticsBundle/Resources/views/logistics/flesserke-article/delete.twig
@@ -0,0 +1,3 @@
+{% autoescape false %}
+ {{ result|json_encode }}
+{% endautoescape %}
diff --git a/module/LogisticsBundle/Resources/views/logistics/flesserke-article/index.twig b/module/LogisticsBundle/Resources/views/logistics/flesserke-article/index.twig
index 02f5b45050..a03e966868 100644
--- a/module/LogisticsBundle/Resources/views/logistics/flesserke-article/index.twig
+++ b/module/LogisticsBundle/Resources/views/logistics/flesserke-article/index.twig
@@ -119,6 +119,9 @@
{{ translate('Edit') }}
+
+ {{ translate('Delete') }}
+
{% endif %}
@@ -152,6 +155,25 @@
$(document).ready(function () {
$('.category-collapse').click(collapse);
+ $('.delete-article').click(function (e) {
+ e.preventDefault();
+ const url = $(this).attr('href');
+
+ if (confirm('{{ translate('Are you sure you want to delete this article?') }}')) {
+ $.ajax({
+ url: url,
+ type: 'DELETE',
+ success: function (result) {
+ alert('{{ translate('Article deleted successfully.') }}');
+ location.reload();
+ },
+ error: function (xhr, status, error) {
+ alert('{{ translate('An error occurred while deleting the article.') }}');
+ }
+ });
+ }
+ });
+
$('a[rel=popover], span[rel=popover]').popover({'trigger': 'hover', 'html': true});
{% if hasAccess('logistics_flesserke_article', 'search') %}
diff --git a/module/LogisticsBundle/Resources/views/logistics/inventory-article/delete.twig b/module/LogisticsBundle/Resources/views/logistics/inventory-article/delete.twig
new file mode 100644
index 0000000000..9737a77083
--- /dev/null
+++ b/module/LogisticsBundle/Resources/views/logistics/inventory-article/delete.twig
@@ -0,0 +1,3 @@
+{% autoescape false %}
+ {{ result|json_encode }}
+{% endautoescape %}
\ No newline at end of file
diff --git a/module/LogisticsBundle/Resources/views/logistics/inventory-article/index.twig b/module/LogisticsBundle/Resources/views/logistics/inventory-article/index.twig
index 2f694de311..d98e987b40 100644
--- a/module/LogisticsBundle/Resources/views/logistics/inventory-article/index.twig
+++ b/module/LogisticsBundle/Resources/views/logistics/inventory-article/index.twig
@@ -126,6 +126,9 @@
{{ translate('Edit') }}
+
+ {{ translate('Delete') }}
+
{% endif %}
@@ -161,6 +164,9 @@
{{ translate('Edit') }}
+
+ {{ translate('Delete') }}
+
{% endif %}
@@ -197,6 +203,25 @@
$('a[rel=popover], span[rel=popover]').popover({'trigger': 'hover', 'html': true});
+ $('.delete-article').click(function (e) {
+ e.preventDefault();
+ const url = $(this).attr('href');
+
+ if (confirm('{{ translate('Are you sure you want to delete this article?') }}')) {
+ $.ajax({
+ url: url,
+ type: 'DELETE',
+ success: function (result) {
+ alert('{{ translate('Article deleted successfully.') }}');
+ location.reload();
+ },
+ error: function (xhr, status, error) {
+ alert('{{ translate('An error occurred while deleting the article.') }}');
+ }
+ });
+ }
+ });
+
{% if hasAccess('logistics_inventory_article', 'search') %}
$.searchDatabase({
defaultPage: $('#default_page'),
@@ -249,6 +274,7 @@
}
});
{% endif %}
+
});
function openSearchRequest(e) {