mirror of
https://github.com/grocy/grocy.git
synced 2025-10-14 17:24:07 +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:
@@ -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);
|
||||
|
||||
$png = (new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData();
|
||||
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]);
|
||||
|
||||
$png = (new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData();
|
||||
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);
|
||||
|
||||
|
Reference in New Issue
Block a user