Grocycode: Stockentry Label view

This commit is contained in:
Katharina Bogad 2021-06-07 11:36:22 +02:00
parent 9e73349bfb
commit 3bcb0e696a
6 changed files with 72 additions and 2 deletions

View File

@ -460,9 +460,11 @@ class StockController extends BaseController
public function StockEntryGrocycodeImage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$size = $request->getQueryParam('size', null);
$stockEntry = $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch();
$gc = new Grocycode(Grocycode::PRODUCT, $stockEntry->product_id, [$stockEntry->stock_id]);
$png = (new DatamatrixFactory())->setCode((string) $gc)->getDatamatrixPngData();
$png = (new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData();
$isDownload = $request->getQueryParam('download', false);
@ -485,6 +487,15 @@ class StockController extends BaseController
return $response;
}
public function StockEntryGrocycodeLabel(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$stockEntry = $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch();
return $this->renderPage($response, 'stockentrylabel', [
'stockEntry' => $stockEntry,
'product' => $this->getDatabase()->products($stockEntry->product_id),
]);
}
public function StockSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'stocksettings', [

View File

@ -2388,4 +2388,10 @@ msgid "Download product grocycode"
msgstr "Produkt-Grocycode herunterladen"
msgid "Grocycode is a unique referer to this product in your grocy instance. Print it onto a label and scan it like any other barcode!"
msgstr "Grocycode ist eine eindeutige Referenz zu diesem Produkt in dieser Grocy-Instanz. Ausgedruckt kann es wie jeder andere Barcode gescannt werden!"
msgstr "Grocycode ist eine eindeutige Referenz zu diesem Produkt in dieser Grocy-Instanz. Ausgedruckt kann es wie jeder andere Barcode gescannt werden!"
msgid "Open print label in new Window"
msgstr "Druck-Label in neuem Fenster öffnen"
msgid "DD"
msgstr "MHD"

View File

@ -2100,3 +2100,9 @@ msgstr ""
msgid "Grocycode is a unique referer to this product in your grocy instance. Print it onto a label and scan it like any other barcode!"
msgstr ""
msgid "Open print label in new Window"
msgstr ""
msgid "DD"
msgstr ""

View File

@ -61,6 +61,7 @@ $app->group('', function (RouteCollectorProxy $group) {
$group->get('/stockjournal/summary', '\Grocy\Controllers\StockController:JournalSummary');
$group->get('/productbarcodes/{productBarcodeId}', '\Grocy\Controllers\StockController:ProductBarcodesEditForm');
$group->get('/stockentry/{entryId}/grocycode', '\Grocy\Controllers\StockController:StockEntryGrocycodeImage');
$group->get('/stockentry/{entryId}/label', '\Grocy\Controllers\StockController:StockEntryGrocycodeLabel');
}
// Stock price tracking

View File

@ -190,6 +190,12 @@
href="{{ $U('/stockentry/' . $stockEntry->id . '/grocycode?download=true') }}">
{{ $__t('Download stock entry grocycode') }}
</a>
<a class="dropdown-item stockentry-label-link"
type="button"
target="_blank"
href="{{ $U('/stockentry/' . $stockEntry->id . '/label') }}">
{{ $__t('Open print label in new Window') }}
</a>
<a class="dropdown-item show-as-dialog-link"
type="button"
href="{{ $U('/stockjournal?embedded&product=') }}{{ $stockEntry->product_id }}">

View File

@ -0,0 +1,40 @@
<html>
<head>
<title>{{ $product->name }}</title>
<link href="{{ $U('/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin.min.css?v=', true) }}{{ $version }}"
rel="stylesheet">
<style>
body {
font-family: 'Noto Sans', sans-serif;
}
img {
float: left;
margin-right: .5rem;
max-height: 25px;
width: auto;
margin-top: 2px;
}
.productname {
font-size: 20px;
display: inline-block;
font-weight: bold;
}
</style>
</head>
<body>
<p>
<!-- Size gets determined by CSS, so printing works better (more pixels = sharper printed image).
Unfortunately, this also means the code is blurred on screen. -->
<img src="{{ $U('/stockentry/'. $stockEntry->id . '/grocycode?size=100') }}">
<span class="productname">{{ $product->name }}</span><br>
@if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
<span>{{ $__t('DD') }}: {{ $stockEntry->best_before_date }}</span>
@endif
</p>
</body>
</html>