mirror of
				https://github.com/grocy/grocy.git
				synced 2025-10-31 18:49:38 +00:00 
			
		
		
		
	Made the used grocycode barcode type configurable
DataMatrix reading via Quagga2 doesn't work currently, so default to an supported 1D barcode (=> Code128)
This commit is contained in:
		| @@ -8,7 +8,9 @@ | ||||
|   - The product edit page | ||||
|   - The context/more menu per line on the stock overview and stock entries page | ||||
|   - Automatically on purchase (new option on the purchase page, defaults can be configured per product) | ||||
| - The used barcode type is `DataMatrix` | ||||
| - The used barcode type can be configured via the `config.php` option `GROCYCODE_TYPE`: | ||||
|   - `1D` (default) will produce a `Code128` 1D barcode (supported by the integrated camera barcode scanner) | ||||
|   - `2D` will produce a `DataMatrix` 2D barcode (currently not supported by the integrated camera barcode scanner, but can be probably printed smaller) | ||||
| - Label printer functionality can be enabled via the new feature flag `FEATURE_FLAG_LABELPRINTER` (defaults to disabled) | ||||
| - Label printer communication happens via WebHooks - see the new `LABEL_PRINTER*` `config.php` options | ||||
| - Those grocycodes can also be used without a label printer - you can view or download the pictures and print them manually | ||||
|   | ||||
| @@ -193,6 +193,10 @@ Setting('LABEL_PRINTER_PARAMS', ['font_family' => 'Source Sans Pro (Regular)']); | ||||
| // Use JSON or normal POST request variables? | ||||
| Setting('LABEL_PRINTER_HOOK_JSON', false); | ||||
|  | ||||
| // 1D (=> Code128) or 2D (=> DataMatrix) | ||||
| Setting('GROCYCODE_TYPE', '1D'); | ||||
|  | ||||
|  | ||||
| // Feature flags | ||||
| // grocy was initially about "stock management for your household", many other things | ||||
| // came and still come by, because they are useful - here you can disable the parts | ||||
|   | ||||
| @@ -4,6 +4,7 @@ namespace Grocy\Controllers; | ||||
|  | ||||
| use Grocy\Helpers\Grocycode; | ||||
| use Grocy\Services\RecipesService; | ||||
| use jucksearm\barcode\lib\BarcodeFactory; | ||||
| use jucksearm\barcode\lib\DatamatrixFactory; | ||||
|  | ||||
| class StockController extends BaseController | ||||
| @@ -179,7 +180,14 @@ class StockController extends BaseController | ||||
|  | ||||
| 		$gc = new Grocycode(Grocycode::PRODUCT, $product->id); | ||||
|  | ||||
| 		if (GROCY_GROCYCODE_TYPE == '2D') | ||||
| 		{ | ||||
| 			$png = (new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData(); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			$png = (new BarcodeFactory())->setType('C128')->setCode((string) $gc)->setHeight($size)->getBarcodePngData(); | ||||
| 		} | ||||
|  | ||||
| 		$isDownload = $request->getQueryParam('download', false); | ||||
|  | ||||
| @@ -471,7 +479,14 @@ class StockController extends BaseController | ||||
| 		$stockEntry = $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch(); | ||||
| 		$gc = new Grocycode(Grocycode::PRODUCT, $stockEntry->product_id, [$stockEntry->stock_id]); | ||||
|  | ||||
| 		if (GROCY_GROCYCODE_TYPE == '2D') | ||||
| 		{ | ||||
| 			$png = (new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData(); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			$png = (new BarcodeFactory())->setType('C128')->setCode((string) $gc)->setHeight($size)->getBarcodePngData(); | ||||
| 		} | ||||
|  | ||||
| 		$isDownload = $request->getQueryParam('download', false); | ||||
|  | ||||
|   | ||||
| @@ -53,7 +53,7 @@ Currently, Chore grocycodes do not define any extra fields. | ||||
| Visual Encoding | ||||
| ---- | ||||
|  | ||||
| Grocy uses DataMatrix 2D Barcodes to encode grocycodes into a visual representation. In principle, there is no problem with using | ||||
| Grocy uses DataMatrix 2D (or alternatively Code128 1D) Barcodes to encode grocycodes into a visual representation. In principle, there is no problem with using | ||||
| other encoding formats like QR codes; however DataMatrix uses less space for the same information and redundancy and is a bit | ||||
| easier read by 2D barcode scanners, especially on non-flat surfaces. | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,9 +1,5 @@ | ||||
| Grocy.Components.BarcodeScanner = {}; | ||||
|  | ||||
| //import Quagga2DatamatrixReader from '../../components_unmanaged/quagga2-reader-datamatrix/index.js' | ||||
|  | ||||
| Quagga.registerReader("datamatrix", Quagga2DatamatrixReader); | ||||
|  | ||||
| Grocy.Components.BarcodeScanner.LiveVideoSizeAdjusted = false; | ||||
| Grocy.Components.BarcodeScanner.CheckCapabilities = async function() | ||||
| { | ||||
| @@ -101,7 +97,6 @@ Grocy.Components.BarcodeScanner.StartScanning = function() | ||||
| 				"ean_reader", | ||||
| 				"ean_8_reader", | ||||
| 				"code_128_reader", | ||||
| 				"datamatrix", | ||||
| 				"code_39_reader" | ||||
| 			], | ||||
| 			debug: { | ||||
|   | ||||
| @@ -9,7 +9,6 @@ | ||||
| @once | ||||
| @push('pageScripts') | ||||
| <script src="{{ $U('/node_modules/@ericblade/quagga2/dist/quagga.min.js?v=', true) }}{{ $version }}"></script> | ||||
| <script src="{{ $U('/components_unmanaged/quagga2-reader-datamatrix/index.js', true) }}?v={{ $version }}"></script> | ||||
| @endpush | ||||
| @endonce | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user