fixed ont info
This commit is contained in:
54
Layout/default/WarehouseArticle/LABEL_BULK.php
Normal file
54
Layout/default/WarehouseArticle/LABEL_BULK.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
|
||||
// QR code options - small padding, high quality
|
||||
$options = new QROptions([
|
||||
'outputType' => QRCode::OUTPUT_IMAGE_PNG,
|
||||
'scale' => 10,
|
||||
'quietzoneSize' => 1,
|
||||
]);
|
||||
$qrcode = new QRCode($options);
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
* { margin: 0; padding: 0; }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
body { font-family: Arial, sans-serif; color: #000; }
|
||||
table { border-collapse: collapse; }
|
||||
.label-page {
|
||||
height: 25mm;
|
||||
width: 50mm;
|
||||
overflow: hidden;
|
||||
page-break-after: always;
|
||||
}
|
||||
/* Last page should not have a break if possible, but wkhtmltopdf handles it fine usually */
|
||||
.label-page:last-child {
|
||||
page-break-after: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php foreach($articles as $article):
|
||||
$qrData = "WA:" . $article->id . ":" . $article->articleNumber;
|
||||
$qrCodeBase64 = $qrcode->render($qrData);
|
||||
?>
|
||||
<div class="label-page">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width: 50mm; height: 25mm;">
|
||||
<tr>
|
||||
<td style="width: 22mm; height: 25mm; vertical-align: middle; text-align: center;">
|
||||
<img src="<?php echo $qrCodeBase64; ?>" style="width: 21mm; height: 21mm;">
|
||||
</td>
|
||||
<td style="height: 25mm; vertical-align: middle; padding-left: 1mm; padding-right: 1mm;">
|
||||
<img src="<?php echo BASEDIR; ?>/public/assets/images/xinon-full-transparent.png" style="width: 24mm; height: auto; display: block; margin-bottom: 1mm;">
|
||||
<div style="font-size: 10px; font-weight: bold; color: #000; text-align: center;"><?php echo htmlspecialchars($article->articleNumber); ?></div>
|
||||
<div style="font-size: 7px; color: #000; margin-top: 1px; word-wrap: break-word; overflow: hidden; text-align: center;"><?php echo htmlspecialchars($article->title); ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -423,7 +423,6 @@ Vue.component('warehouse-article-modal', {
|
||||
v-model="formData.articleNumber"
|
||||
placeholder="Wird automatisch generiert"
|
||||
required
|
||||
disabled
|
||||
form-label
|
||||
sm/>
|
||||
</div>
|
||||
|
||||
23
public/js/pages/WarehouseCategory/WarehouseCategory.js
Normal file
23
public/js/pages/WarehouseCategory/WarehouseCategory.js
Normal file
@@ -0,0 +1,23 @@
|
||||
Vue.component('warehouse-category', {
|
||||
//language=Vue
|
||||
template: `
|
||||
<tt-card>
|
||||
<warehouse-administration-switch/>
|
||||
<tt-table-crud
|
||||
@openHistory="historyModal = true; historyModalId = $event.id"
|
||||
@printLabels="printLabels($event)"
|
||||
/>
|
||||
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
|
||||
</tt-card>
|
||||
`, 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');
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user