diff --git a/controllers/StockController.php b/controllers/StockController.php index 2ff38b14..6b682ded 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -332,7 +332,14 @@ class StockController extends BaseController $listId = $request->getQueryParams()['list']; } - return $this->renderPage($response, 'shoppinglist', [ + $template = 'shoppinglist'; + + if (isset($request->getQueryParams()['print'])) + { + $template = 'shoppinglistprint'; + } + + return $this->renderPage($response, $template, [ 'listItems' => $this->getDatabase()->shopping_list()->where('shopping_list_id = :1', $listId), 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), diff --git a/localization/strings.pot b/localization/strings.pot index b6951360..1d16a488 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2008,3 +2008,6 @@ msgstr "" msgid "Show on stock overview page" msgstr "" + +msgid "Open print preview" +msgstr "" diff --git a/public/viewjs/components/shoppinglisttable.js b/public/viewjs/components/shoppinglisttable.js new file mode 100644 index 00000000..874a86bf --- /dev/null +++ b/public/viewjs/components/shoppinglisttable.js @@ -0,0 +1,41 @@ +var collapsedGroups = {}; + +//tableId is desclared in shoppinglisttable.blade.php + +var shoppingListTable = $(tableId).DataTable({ + 'order': [[3, 'asc']], + "orderFixed": [[1, 'asc']], + 'columnDefs': [ + { 'orderable': false, 'targets': 0 }, + { 'searchable': false, "targets": 0 }, + { 'visible': false, 'targets': 1 } + ].concat($.fn.dataTable.defaults.columnDefs), + 'rowGroup': { + dataSrc: 1, + startRender: function(rows, group) + { + var collapsed = !!collapsedGroups[group]; + var toggleClass = collapsed ? "fa-caret-right" : "fa-caret-down"; + + rows.nodes().each(function(row) + { + row.style.display = collapsed ? "none" : ""; + }); + + return $("
| + | +Hidden product group | +Hidden status | +{{ $__t('Product') }} / {{ $__t('Note') }} | +{{ $__t('Amount') }} | + + @include('components.userfields_thead', array( + 'userfields' => $userfields + )) + @include('components.userfields_thead', array( + 'userfields' => $productUserfields + )) + +
|---|---|---|---|---|
| + @if(!$isPrint) + + + + + + + + + + product_id)) data-toggle="tooltip" title="{{ $__t('Add %1$s of %2$s to stock', $listItem->amount . ' ' . $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name_plural), FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name, $listItem->amount) }}" @endif> + + + @endif + | + ++ @if(!empty(FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)) {{ FindObjectInArrayByPropertyValue($productGroups, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)->name }} @else {{ $__t('Ungrouped') }} @endif + | ++ @if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $listItem->product_id) !== null) belowminstockamount @endif + @if($listItem->done != 1) xxUNDONExx @endif + | + +
+ @if(!empty($listItem->product_id)) {{ FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name }} @endif{!! nl2br($listItem->note) !!} + |
+ + @if(!empty($listItem->product_id)) + @php + $listItem->amount_origin_qu = $listItem->amount; + $product = FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id); + $productQuConversions = FindAllObjectsInArrayByPropertyValue($quantityUnitConversionsResolved, 'product_id', $product->id); + $productQuConversions = FindAllObjectsInArrayByPropertyValue($productQuConversions, 'from_qu_id', $product->qu_id_stock); + $productQuConversion = FindObjectInArrayByPropertyValue($productQuConversions, 'to_qu_id', $listItem->qu_id); + if ($productQuConversion) + { + $listItem->amount = $listItem->amount * $productQuConversion->factor; + } + @endphp + @endif + {{ $listItem->amount }} @if(!empty($listItem->product_id)){{ $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name_plural) }}@endif + | + + + @include('components.userfields_tbody', array( + 'userfields' => $userfields, + 'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $listItem->id) + )) + @include('components.userfields_tbody', array( + 'userfields' => $productUserfields, + 'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $listItem->product_id) + )) + +