From 5a91c86b81e3cf5a007656bb6805046fe8711e10 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 20 Sep 2019 17:40:45 +0200 Subject: [PATCH] Added an option to print a shopping list (references #245) --- localization/strings.pot | 8 +---- public/viewjs/shoppinglist.js | 6 ++++ views/shoppinglist.blade.php | 58 +++++++++++++++++++++++++++++++---- 3 files changed, 59 insertions(+), 13 deletions(-) diff --git a/localization/strings.pot b/localization/strings.pot index faf49cd3..1c2a9249 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1490,11 +1490,5 @@ msgstr "" msgid "Added %1$s of %2$s to the shopping list \"%3$s\"" msgstr "" -msgid "datatables_loc" -msgstr "" - -msgid "{}" -msgstr "" - -msgid "{}}" +msgid "Output" msgstr "" diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index cc224cbb..e655a747 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -303,3 +303,9 @@ function OnListItemRemoved() } } OnListItemRemoved(); + +$(document).on("click", "#print-shopping-list-button", function(e) +{ + $(".print-timestamp").text(moment().format("l LT")); + window.print(); +}); diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index bd6243b2..04526872 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -16,7 +16,7 @@ @endpush @section('content') -
+

@yield('title') @@ -37,7 +37,7 @@

-
+
- -
+
@@ -71,7 +77,7 @@
-
+
@@ -131,7 +137,7 @@
-
+
@include('components.calendarcard')
@@ -150,4 +156,44 @@
+ +
+

+ + {{ $__t("Shopping list") }} +

+ @if (FindObjectInArrayByPropertyValue($shoppingLists, 'id', $selectedShoppingListId)->name != $__t("Shopping list")) +

+ {{ FindObjectInArrayByPropertyValue($shoppingLists, 'id', $selectedShoppingListId)->name }} +

+ @endif +
+ {{ $__t('Time of printing') }}: + +
+
+
+ + + + + + + + + @foreach($listItems as $listItem) + + + + + @endforeach + +
{{ $__t('Product') }} / {{ $__t('Note') }}{{ $__t('Amount') }}
+ @if(!empty($listItem->product_id)) {{ FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name }}
@endif{!! nl2br($listItem->note) !!} +
+ {{ $listItem->amount }} @if(!empty($listItem->product_id)){{ $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->qu_id_purchase)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->qu_id_purchase)->name_plural) }}@endif +
+
+
+
@stop