diff --git a/config-dist.php b/config-dist.php index 9c28d1e80..aa6530457 100644 --- a/config-dist.php +++ b/config-dist.php @@ -187,7 +187,7 @@ Setting('FEATURE_FLAG_BATTERIES', true); Setting('FEATURE_FLAG_EQUIPMENT', true); Setting('FEATURE_FLAG_CALENDAR', true); -Setting('FEATURE_FLAG_LABELPRINTER', true); +Setting('FEATURE_FLAG_LABELPRINTER', false); // Sub feature flags Setting('FEATURE_FLAG_STOCK_PRICE_TRACKING', true); diff --git a/controllers/StockApiController.php b/controllers/StockApiController.php index e25c1144d..5bc8c7cb4 100644 --- a/controllers/StockApiController.php +++ b/controllers/StockApiController.php @@ -626,7 +626,7 @@ public function ProductPrintLabel(\Psr\Http\Message\ServerRequestInterface $requ (new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON); } - return $this->ApiResponse($response, $webhookData); + return $this->EmptyApiResponse($response); } public function StockEntryPrintLabel(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) @@ -649,7 +649,7 @@ public function StockEntryPrintLabel(\Psr\Http\Message\ServerRequestInterface $r (new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON); } - return $this->ApiResponse($response, $webhookData); + return $this->EmptyApiResponse($response); } public function RemoveProductFromShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) diff --git a/controllers/StockController.php b/controllers/StockController.php index 3907c1321..7146e2680 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -174,10 +174,14 @@ public function ProductEditForm(\Psr\Http\Message\ServerRequestInterface $reques public function ProductGrocycodeImage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { + $size = $request->getQueryParam('size', null); $product = $this->getDatabase()->products($args['productId']); $gc = new Grocycode(Grocycode::PRODUCT, $product->id); - $png = (new DatamatrixFactory())->setCode((string) $gc)->getDatamatrixPngData(); + + // Explicitly suppress errors, otherwise deprecations warnings would cause invalid PNG data + // See also https://github.com/jucksearm/php-barcode/issues/3 + $png = @(new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData(); $isDownload = $request->getQueryParam('download', false); @@ -464,7 +468,10 @@ public function StockEntryGrocycodeImage(\Psr\Http\Message\ServerRequestInterfac $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)->setSize($size)->getDatamatrixPngData(); + + // Explicitly suppress errors, otherwise deprecations warnings would cause invalid PNG data + // See also https://github.com/jucksearm/php-barcode/issues/3 + $png = @(new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData(); $isDownload = $request->getQueryParam('download', false); diff --git a/docs/grocycode.md b/docs/grocycode.md index 5e00f104a..fe0cef740 100644 --- a/docs/grocycode.md +++ b/docs/grocycode.md @@ -1,7 +1,7 @@ -Grocycode +grocycode ========== -Grocycode is, in essence, a simple way to reference to arbitrary grocy entities. +grocycode is, in essence, a simple way to reference to arbitrary grocy entities. Each grocycode includes a magic, an entitiy identifier, an id and an ordered set of extra data. It is supported to be entered anywhere grocy expects one to read a barcode, but can also reference grocy-internal properties like specific stock entries, or specific batteries. @@ -33,22 +33,22 @@ Example In this example, we encode a *Product* with ID *13*, which results in `grcy:p:13` when serialized. -Product Grocycodes +Product grocycodes ---- -Product Grocycodes extend the data format to include an optional stock id, thus may reference a specific stock entry directly. +Product grocycodes extend the data format to include an optional stock id, thus may reference a specific stock entry directly. Example: `grcy:p:13:60bf8b5244b04` -Battery Grocycodes +Battery grocycodes ---- -Currently, Battery Grocycodes do not define any extra fields. +Currently, Battery grocycodes do not define any extra fields. -Chore Grocycodes +Chore grocycodes ---- -Currently, Chore Grocycodes do not define any extra fields. +Currently, Chore grocycodes do not define any extra fields. Visual Encoding ---- @@ -63,4 +63,4 @@ so that the double colons get entered correctly. Notes --- -[0]: Obviously, it needs to be encoded into some usable visual representation and then read. So probably you only want to encode stuff that can be typed on a keyboard. \ No newline at end of file +[0]: Obviously, it needs to be encoded into some usable visual representation and then read. So probably you only want to encode stuff that can be typed on a keyboard. diff --git a/grocy.openapi.json b/grocy.openapi.json index 5d786086c..becda7fbc 100644 --- a/grocy.openapi.json +++ b/grocy.openapi.json @@ -1402,7 +1402,7 @@ "in": "path", "name": "entryId", "required": true, - "description": "A valid stock row id", + "description": "A valid stock entry id", "schema": { "type": "integer" } @@ -1441,7 +1441,7 @@ "in": "path", "name": "entryId", "required": true, - "description": "A valid stock row id", + "description": "A valid stock entry id", "schema": { "type": "integer" } @@ -1529,6 +1529,40 @@ } } }, + "/stock/entry/{entryId}/printlabel": { + "get": { + "summary": "Prints the label of the given stock entry", + "tags": [ + "Stock" + ], + "parameters": [ + { + "in": "path", + "name": "entryId", + "required": true, + "description": "A valid stock entry id", + "schema": { + "type": "integer" + } + } + ], + "responses": { + "204": { + "description": "The operation was successful" + }, + "400": { + "description": "The operation was not successful (possible errors are: Not existing stock entry, error on WebHook execution)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error400" + } + } + } + } + } + } + }, "/stock/volatile": { "get": { "summary": "Returns all products which are due soon, overdue, expired or currently missing", @@ -1850,6 +1884,10 @@ "type": "number", "format": "integer", "description": "If omitted, no store will be affected" + }, + "print_stock_label": { + "type": "boolean", + "description": "True when the stock entry label should be printed" } }, "example": { @@ -2213,6 +2251,40 @@ } } }, + "/stock/products/{productId}/printlabel": { + "get": { + "summary": "Prints the product label of the given product", + "tags": [ + "Stock" + ], + "parameters": [ + { + "in": "path", + "name": "productId", + "required": true, + "description": "A valid product id", + "schema": { + "type": "integer" + } + } + ], + "responses": { + "204": { + "description": "The operation was successful" + }, + "400": { + "description": "The operation was not successful (possible errors are: Not existing product, error on WebHook execution)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error400" + } + } + } + } + } + } + }, "/stock/products/{productIdToKeep}/merge/{productIdToRemove}": { "post": { "summary": "Merges two products into one", diff --git a/localization/de/strings.po b/localization/de/strings.po index b88161372..66135bc1d 100644 --- a/localization/de/strings.po +++ b/localization/de/strings.po @@ -2374,51 +2374,3 @@ msgstr "Druckoptionen" msgid "A product or a note is required" msgstr "Ein Produkt oder eine Notiz ist erforderlich" - -msgid "Grocycode" -msgstr "Grocycode" - -msgid "Download" -msgstr "Herunterladen" - -msgid "Download stock entry grocycode" -msgstr "Bestandseingrags-Grocycode herunterladen" - -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!" - -msgid "Open print label in new Window" -msgstr "Druck-Label in neuem Fenster öffnen" - -msgid "DD" -msgstr "MHD" - -msgid "Print stock label" -msgstr "Etikett drucken" - -msgid "Print Product Label" -msgstr "Produkt-Etikett drucken" - -msgid "Print stock entry label" -msgstr "Etikett drucken" - -msgid "Stock label" -msgstr "Etikett" - -msgid "No Label" -msgstr "Kein Etikett" - -msgid "Single Label" -msgstr "Ein Etikett pro Einkauf" - -msgid "Label per Unit" -msgstr "Ein Etikett pro Mengeneinheit" - -msgid "Allow label printing per unit" -msgstr "Erlaube Etikettendruck pro Mengeneinheit" - -msgid "Allow printing of one label per unit in a purchase (after conversion). E.g. 1 purchased pack adding 10 pieces of stock would print 10 labels." -msgstr "Erlaube Etikettendruck pro Mengeneinheit nach Umrechnung. Beispiel: 1 gekauftes Paket, das 10 Einheiten hinzufügt, druckt 10 Etiketten." \ No newline at end of file diff --git a/localization/strings.pot b/localization/strings.pot index 6d2857259..9847421ab 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2078,7 +2078,7 @@ msgstr "" msgid "A product or a note is required" msgstr "" -msgid "Grocycode" +msgid "grocycode" msgstr "" msgid "Download" @@ -2090,46 +2090,42 @@ msgstr "" msgid "Download product grocycode" msgstr "" -msgid "" -"If enabled, the min. stock amount of sub products will be accumulated into this product, means the sub product will never be \"\n" -"\t\t\t\t\t\t\tmissing\",\n" -"\t\t\t\t\t\t\tonly\n" -"\t\t\t\t\t\t\tthis\n" -"\t\t\t\t\t\t\tproduct" +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 "Grocycode is a unique referer to this product in your grocy instance. Print it onto a label and scan it like any other barcode!" +# Abbreviation for "due date" +msgid "DD" msgstr "" -msgid "Open print label in new Window" +msgid "Print on label printer" msgstr "" -msgid "DD" +msgid "Stock entry label" msgstr "" -msgid "Print stock label" +msgid "No label" msgstr "" -msgid "Print Product Label" +msgid "Single label" msgstr "" -msgid "Print stock entry label" +msgid "Label per unit" msgstr "" -msgid "Stock label" +msgid "Allow label printing per unit" msgstr "" -msgid "No Label" +msgid "Allow printing of one label per unit on purchase (after conversion) - e.g. 1 purchased pack adding 10 pieces of stock would print 10 labels" msgstr "" -msgid "Single Label" +msgid "Error while executing WebHook" msgstr "" -msgid "Label per Unit" +msgid "Print product grocycode on label printer" msgstr "" -msgid "Allow label printing per unit" +msgid "Print stock entry grocycode on label printer" msgstr "" -msgid "Allow printing of one label per unit in a purchase (after conversion). E.g. 1 purchased pack adding 10 pieces of stock would print 10 labels." +msgid "Open stock entry print label in new window" msgstr "" diff --git a/public/js/grocy.js b/public/js/grocy.js index 1fad2d8f5..034ac2ec9 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -488,7 +488,7 @@ Grocy.FrontendHelpers.RunWebhook = function(webhook, data, repetitions = 1) if (!hasAlreadyFailed) { hasAlreadyFailed = true; - Grocy.FrontendHelpers.ShowGenericError(__t("Unable to connect to webhook.", { "status": status, "errorThrown": errorThrown })); + Grocy.FrontendHelpers.ShowGenericError(__t("Error while executing WebHook", { "status": status, "errorThrown": errorThrown })); } }); } diff --git a/views/productform.blade.php b/views/productform.blade.php index cf4309d86..0ec74462c 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -145,12 +145,7 @@ class="custom-control custom-select" for="cumulate_min_stock_amount_of_sub_products">{{ $__t('Accumulate sub products min. stock amount') }} + title="{{ $__t('If enabled, the min. stock amount of sub products will be accumulated into this product, means the sub product will never be "missing", only this product') }}"> @@ -414,7 +409,7 @@ class="form-text text-info d-none">
' @@ -426,28 +421,32 @@ class="form-text text-info d-none">' $disable_per_unit = ""; if($mode == 'edit') { - switch($product->default_print_stock_label) { - case 0: $no_label = "selected"; break; - case 1: $single_label = "selected"; break; - case 2: $per_unit_label = "selected"; break; - default: break; // yolo - } - if($product->allow_label_per_unit == 0) { - $disable_per_unit="disabled"; - $per_unit_label = ""; - } + switch($product->default_print_stock_label) { + case 0: $no_label = "selected"; break; + case 1: $single_label = "selected"; break; + case 2: $per_unit_label = "selected"; break; + default: break; // yolo + } + if($product->allow_label_per_unit == 0) { + $disable_per_unit="disabled"; + $per_unit_label = ""; + } } @endphp