fixed ont info
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user