diff --git a/Layout/default/WarehouseArticle/LABEL_BULK.php b/Layout/default/WarehouseArticle/LABEL_BULK.php
new file mode 100644
index 000000000..12ebdd864
--- /dev/null
+++ b/Layout/default/WarehouseArticle/LABEL_BULK.php
@@ -0,0 +1,54 @@
+ QRCode::OUTPUT_IMAGE_PNG,
+ 'scale' => 10,
+ 'quietzoneSize' => 1,
+]);
+$qrcode = new QRCode($options);
+?>
+
+
+
+
+
+
+id . ":" . $article->articleNumber;
+ $qrCodeBase64 = $qrcode->render($qrData);
+?>
+
+
+
+
+
+ |
+
+
+ articleNumber); ?>
+ title); ?>
+ |
+
+
+
+
+
+
diff --git a/application/WarehouseArticle/WarehouseArticleController.php b/application/WarehouseArticle/WarehouseArticleController.php
index c80214bfd..a33c825d5 100644
--- a/application/WarehouseArticle/WarehouseArticleController.php
+++ b/application/WarehouseArticle/WarehouseArticleController.php
@@ -111,7 +111,7 @@ class WarehouseArticleController extends TTCrud {
if ($categoryId) {
$category = WarehouseCategory::get($categoryId);
if ($category && $category->articleNumberPrefix) {
- $expectedPrefix = $category->articleNumberPrefix;
+ $expectedPrefix = str_pad($category->articleNumberPrefix, 4, '0', STR_PAD_LEFT);
$articlePrefix = substr($articleNumber, 0, strlen($expectedPrefix));
if ($articlePrefix !== $expectedPrefix) {
self::sendError("Artikelnummer muss mit dem Kategorie-Prefix '{$expectedPrefix}' beginnen.");
@@ -178,7 +178,7 @@ class WarehouseArticleController extends TTCrud {
if (!$category) self::sendError("Kategorie nicht gefunden");
if (!$category->articleNumberPrefix) self::sendError("Kategorie hat keinen Artikelnummer-Prefix");
- $prefix = $category->articleNumberPrefix;
+ $prefix = str_pad($category->articleNumberPrefix, 4, '0', STR_PAD_LEFT);
$db = FronkDB::singleton();
// Get all existing article numbers with this prefix, sorted
@@ -262,4 +262,30 @@ class WarehouseArticleController extends TTCrud {
readfile($filename);
die();
}
+
+ protected function printLabelsByCategoryAction() {
+ $categoryId = intval($this->request->categoryId);
+ if (!$categoryId) {
+ self::sendError("Kategorie nicht angegeben", 400);
+ }
+
+ $articles = WarehouseArticleModel::getAll(['category_id' => $categoryId], 10000, 0, ['key' => 'articleNumber', 'order' => 'ASC']);
+ if (empty($articles)) {
+ self::sendError("Keine Artikel in dieser Kategorie gefunden", 404);
+ }
+
+ $pdf_vars = ['articles' => $articles];
+ $pdf = new PdfForm("WarehouseArticle/LABEL_BULK", $pdf_vars);
+ $wkhtmltopdfArgs = "--page-height 25mm --page-width 50mm --margin-top 0 --margin-bottom 0 --margin-left 0 --margin-right 0 --disable-smart-shrinking --encoding utf-8 --dpi 96";
+
+ $filename = $pdf->render($wkhtmltopdfArgs);
+
+ $category = WarehouseCategory::get($categoryId);
+ $categoryName = $category ? $category->name : 'category-' . $categoryId;
+
+ header('Content-Type: application/pdf');
+ header('Content-Disposition: inline; filename="labels-' . str_replace(' ', '_', $categoryName) . '.pdf"');
+ readfile($filename);
+ die();
+ }
}
diff --git a/application/WarehouseCategory/WarehouseCategoryController.php b/application/WarehouseCategory/WarehouseCategoryController.php
index 26d16ab83..bf396801d 100644
--- a/application/WarehouseCategory/WarehouseCategoryController.php
+++ b/application/WarehouseCategory/WarehouseCategoryController.php
@@ -16,7 +16,39 @@ class WarehouseCategoryController extends TTCrud {
];
// @formatter:on
- protected array $additionalActions = [['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary']];
+ protected array $additionalActions = [
+ ['key' => 'printLabels', 'title' => 'Labels drucken', 'class' => 'fas fa-print text-primary'],
+ ['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary']
+ ];
+
+ protected array $additionalJSVariables = ['WAREHOUSE_ADMIN' => true];
+
+ public function printLabelsAction() {
+ $categoryId = intval($this->request->id);
+ $articles = WarehouseArticleModel::getAll(['category_id' => $categoryId], 10000, 0, ['key' => 'articleNumber', 'order' => 'ASC']);
+
+ if (empty($articles)) {
+ echo "Keine Artikel in dieser Kategorie.";
+ die();
+ }
+
+ $pdf_vars = [
+ 'articles' => $articles
+ ];
+
+ $pdf = new PdfForm("WarehouseArticle/LABEL_BULK", $pdf_vars);
+ $wkhtmltopdfArgs = "--page-height 25mm --page-width 50mm --margin-top 0 --margin-bottom 0 --margin-left 0 --margin-right 0 --disable-smart-shrinking --encoding utf-8 --dpi 96";
+
+ $filename = $pdf->render($wkhtmltopdfArgs);
+
+ $category = WarehouseCategory::get($categoryId);
+ $categoryName = $category ? $category->name : 'category-' . $categoryId;
+
+ header('Content-Type: application/pdf');
+ header('Content-Disposition: inline; filename="labels-' . str_replace(' ', '_', $categoryName) . '.pdf"');
+ readfile($filename);
+ die();
+ }
protected function beforeCreate(): bool {
$this->postData['articleNumberPrefix'] = $this->getNextFreePrefix();
diff --git a/public/js/pages/WarehouseArticle/WarehouseArticle.js b/public/js/pages/WarehouseArticle/WarehouseArticle.js
index 362a3943b..b8ad34990 100644
--- a/public/js/pages/WarehouseArticle/WarehouseArticle.js
+++ b/public/js/pages/WarehouseArticle/WarehouseArticle.js
@@ -423,7 +423,6 @@ Vue.component('warehouse-article-modal', {
v-model="formData.articleNumber"
placeholder="Wird automatisch generiert"
required
- disabled
form-label
sm/>
diff --git a/public/js/pages/WarehouseCategory/WarehouseCategory.js b/public/js/pages/WarehouseCategory/WarehouseCategory.js
new file mode 100644
index 000000000..adc23ef5e
--- /dev/null
+++ b/public/js/pages/WarehouseCategory/WarehouseCategory.js
@@ -0,0 +1,23 @@
+Vue.component('warehouse-category', {
+ //language=Vue
+ template: `
+
+
+
+
+
+ `, data() {
+ return {
+ window: window, historyModal: false, historyModalId: null,
+ }
+ },
+ methods: {
+ printLabels(event) {
+ const url = window.TT_CONFIG.BASE_PATH + "/WarehouseCategory/printLabels?id=" + event.id;
+ window.open(url, '_blank');
+ }
+ }
+})