Finished the implementation of "Location Content Sheet" (closes #341)

This commit is contained in:
Bernd Bestel 2019-08-11 09:24:47 +02:00
parent 28716ed96c
commit 7004cf4400
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
5 changed files with 72 additions and 10 deletions

View File

@ -1,3 +1,5 @@
- Stock improvements
- You can now print a "Location Content Sheet" with the current stock per location - new button at the top of the stock overview page
- Chores improvements - Chores improvements
- New option "Due date rollover" per chore which means the chore can never be overdue, the due date will shift forward each day when due - New option "Due date rollover" per chore which means the chore can never be overdue, the due date will shift forward each day when due
- General improvements/fixes - General improvements/fixes

View File

@ -1293,8 +1293,23 @@ msgstr ""
msgid "When enabled the chore can never be overdue, the due date will shift forward each day when due" msgid "When enabled the chore can never be overdue, the due date will shift forward each day when due"
msgstr "" msgstr ""
msgid "Location Content Sheet"
msgstr ""
msgid "Print" msgid "Print"
msgstr "" msgstr ""
msgid "Location Content Sheet" msgid "all locations"
msgstr ""
msgid "Here you can print a page per location with the current stock, maybe to hang it there and note the consumed things on it."
msgstr ""
msgid "this location"
msgstr ""
msgid "Consumend amount"
msgstr ""
msgid "Time of printing"
msgstr "" msgstr ""

View File

@ -0,0 +1,14 @@
$(document).on("click", ".print-all-locations-button", function(e)
{
$(".page").removeClass("d-print-none").removeClass("no-page-break");
$(".print-timestamp").text(moment().format("l LT"));
window.print();
});
$(document).on("click", ".print-single-location-button", function(e)
{
$(".page").addClass("d-print-none");
$(e.currentTarget).closest(".page").removeClass("d-print-none").addClass("no-page-break");
$(".print-timestamp").text(moment().format("l LT"));
window.print();
});

View File

@ -1,40 +1,68 @@
@extends('layout.default') @extends('layout.default')
@section('title', $__t('Location Content Sheet')) @section('title', $__t('Location Content Sheet'))
@section('viewJsName', 'locationcontentsheet')
@push('pageStyles') @push('pageStyles')
<style> <style>
@media print @media print
{ {
.page { .page:not(:last-child) {
page-break-after: always !important; page-break-after: always !important;
} }
.page.no-page-break {
page-break-after: avoid !important;
}
/*
Workaround because of Firefox bug
see https://github.com/twbs/bootstrap/issues/22753
and https://bugzilla.mozilla.org/show_bug.cgi?id=1413121
*/
.row {
display: inline !important;
}
} }
</style> </style>
@endpush @endpush
@section('content') @section('content')
<h1 class="d-print-none"> <h1 class="d-print-none">
<a class="btn btn-outline-dark responsive-button" href="javascript:window.print();"> @yield('title')
<i class="fas fa-print"></i> {{ $__t('Print') }} <a class="btn btn-outline-dark responsive-button print-all-locations-button" href="#">
<i class="fas fa-print"></i> {{ $__t('Print') . ' (' . $__t('all locations') . ')' }}
</a> </a>
</h1> </h1>
<h5 class="mb-5 d-print-none">
<small class="text-muted">{{ $__t('Here you can print a page per location with the current stock, maybe to hang it there and note the consumed things on it.') }}</small>
</h5>
@foreach($locations as $location) @foreach($locations as $location)
<div class="page"> <div class="page">
<h1>{{ $location->name }}</h1> <h1 class="text-center">
@php $currentStockEntriesForLocation = FindAllObjectsInArrayByPropertyValue($currentStockLocationContent, 'location_id', $location->id); @endphp <img src="{{ $U('/img/grocy_logo.svg?v=', true) }}{{ $version }}" height="30" class="d-none d-print-flex mx-auto">
<div class="row w-50"> {{ $location->name }}
<a class="btn btn-outline-dark responsive-button print-single-location-button d-print-none" href="#">
<i class="fas fa-print"></i> {{ $__t('Print') . ' (' . $__t('this location') . ')' }}
</a>
</h1>
<h6 class="text-center mb-4 d-none d-print-block">
{{ $__t('Time of printing') }}:
<span class="d-inline print-timestamp"></span>
</h6>
<div class="row w-75">
<div class="col"> <div class="col">
<table class="table table-sm table-striped"> <table class="table">
<thead> <thead>
<tr> <tr>
<th>{{ $__t('Product') }}</th> <th>{{ $__t('Product') }}</th>
<th>{{ $__t('Amount') }}</th> <th>{{ $__t('Amount') }}</th>
<th></th> <th>{{ $__t('Consumend amount') . ' / ' . $__t('Notes') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@php $currentStockEntriesForLocation = FindAllObjectsInArrayByPropertyValue($currentStockLocationContent, 'location_id', $location->id); @endphp
@foreach($currentStockEntriesForLocation as $currentStockEntry) @foreach($currentStockEntriesForLocation as $currentStockEntry)
<tr> <tr>
<td> <td>
@ -44,7 +72,7 @@
<span>{{ $currentStockEntry->amount }}</span> <span id="product-{{ $currentStockEntry->product_id }}-qu-name">{{ $__n($currentStockEntry->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name_plural) }}</span> <span>{{ $currentStockEntry->amount }}</span> <span id="product-{{ $currentStockEntry->product_id }}-qu-name">{{ $__n($currentStockEntry->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name_plural) }}</span>
<span class="small font-italic">@if($currentStockEntry->amount_opened > 0){{ $__t('%s opened', $currentStockEntry->amount_opened) }}@endif</span> <span class="small font-italic">@if($currentStockEntry->amount_opened > 0){{ $__t('%s opened', $currentStockEntry->amount_opened) }}@endif</span>
</td> </td>
<td class="fit-content">____________________</td> <td class=""></td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>

View File

@ -24,6 +24,9 @@
<a class="btn btn-outline-dark responsive-button" href="{{ $U('/stockjournal') }}"> <a class="btn btn-outline-dark responsive-button" href="{{ $U('/stockjournal') }}">
<i class="fas fa-file-alt"></i> {{ $__t('Journal') }} <i class="fas fa-file-alt"></i> {{ $__t('Journal') }}
</a> </a>
<a class="btn btn-outline-dark responsive-button" href="{{ $U('/locationcontentsheet') }}">
<i class="fas fa-print"></i> {{ $__t('Location Content Sheet') }}
</a>
</h1> </h1>
<p id="info-expiring-products" data-next-x-days="{{ $nextXDays }}" data-status-filter="expiring" class="btn btn-lg btn-warning status-filter-button responsive-button mr-2"></p> <p id="info-expiring-products" data-next-x-days="{{ $nextXDays }}" data-status-filter="expiring" class="btn btn-lg btn-warning status-filter-button responsive-button mr-2"></p>
<p id="info-expired-products" data-status-filter="expired" class="btn btn-lg btn-danger status-filter-button responsive-button mr-2"></p> <p id="info-expired-products" data-status-filter="expired" class="btn btn-lg btn-danger status-filter-button responsive-button mr-2"></p>