This commit is contained in:
d-buchmann 2025-12-02 16:08:22 +01:00 committed by GitHub
commit 812db08a17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 92 additions and 11 deletions

View file

@ -65,6 +65,12 @@ class LabelOptions
#[Groups(["extended", "full", "import"])] #[Groups(["extended", "full", "import"])]
protected float $height = 30.0; protected float $height = 30.0;
// TODO these have to go into the DB to be persisted.
// The default values preserve the current behaviour of the generator (custom css might break though...)
public int $xcount = 1;
public int $ycount = 1;
public int $skipcount = 0;
/** /**
* @var BarcodeType The type of the barcode that should be used in the label (e.g. 'qr') * @var BarcodeType The type of the barcode that should be used in the label (e.g. 'qr')
*/ */

View file

@ -81,6 +81,34 @@ class LabelOptionsType extends AbstractType
], ],
]); ]);
$builder->add('xcount', NumberType::class, [
'label' => 'label_options.page_nup.grid',
'html5' => true,
'attr' => [
'placeholder' => 'label_options.page_nup.xcount',
'min' => 1,
'step' => 1,
],
]);
$builder->add('ycount', NumberType::class, [
'label' => false,
'html5' => true,
'attr' => [
'placeholder' => 'label_options.page_nup.ycount',
'min' => 1,
'step' => 1,
],
]);
$builder->add('skipcount', NumberType::class, [
'label' => '//',
'html5' => true,
'attr' => [
'placeholder' => 'label_options.page_nup.skipcount',
'min' => 0,
'step' => 1,
],
]);
$builder->add('supported_element', EnumType::class, [ $builder->add('supported_element', EnumType::class, [
'label' => 'label_options.supported_elements.label', 'label' => 'label_options.supported_elements.label',
'class' => LabelSupportedElement::class, 'class' => LabelSupportedElement::class,

View file

@ -48,6 +48,18 @@
</div> </div>
</div> </div>
</div> </div>
<div class="mb-2 row">
{{ form_label(form.options.xcount) }}
<div class="col-sm-9">
<div class="input-group">
{{ form_widget(form.options.xcount) }}
<span class="input-group-text">x</span>
{{ form_widget(form.options.ycount) }}
<span class="input-group-text">{{ form.options.skipcount.vars.label }}</span>
{{ form_widget(form.options.skipcount) }}
</div>
</div>
</div>
{{ form_row(form.options.barcode_type) }} {{ form_row(form.options.barcode_type) }}
{{ form_row(form.options.lines) }} {{ form_row(form.options.lines) }}
</div> </div>

View file

@ -15,19 +15,54 @@
</style> </style>
</head> </head>
<body> <body>
{% for element in elements %} {% set start_page %}
{# The page div ensures the page breaks, while the page-inner elements restrict the content to the page size. Sine dompdf 3.1.1 we cannot apply the position: absolute; to the page element directly. #} {# The page div ensures the page breaks, while the page-inner elements restrict the content to the page size. Sine dompdf 3.1.1 we cannot apply the position: absolute; to the page element directly. #}
<div class="page"> <div class="page">
<div class="page-inner"> <div class="page-inner">
{% if options.barcodeType.none %} <table col="{{ options.xcount }}" row="{{ options.ycount }}"><tr>
{% include "label_system/labels/label_page_none.html.twig" %} {% endset %}
{% elseif options.barcodeType.is2D() %}
{% include "label_system/labels/label_page_qr.html.twig" %} {% set end_page %}
{% elseif options.barcodeType.is1D() %} </tr></table></div>
{% include "label_system/labels/label_page_1d.html.twig" %} {% endset %}
{{ start_page }}
{% set labels = (0 .. options.skipcount)|merge(elements) %}
{% for element in labels %}
{% if loop.first %}
{# continue #}
{% else %}
<td>
{% if element <= options.skipcount %}
{% elseif options.barcodeType.none %}
{% include "label_system/labels/label_page_none.html.twig" %}
{% elseif options.barcodeType.is2D() %}
{% include "label_system/labels/label_page_qr.html.twig" %}
{% elseif options.barcodeType.is1D() %}
{% include "label_system/labels/label_page_1d.html.twig" %}
{% endif %}
</td>
{% if not loop.last %}
{# The current row is full. Start a new row #}
{% if (loop.index > 2) and loop.index0 is divisible by(options.xcount) %}
</tr><tr>
{% endif %}
{# The current page is full and there are still labels in the queue. Start a new page #}
{% if loop.index0 is divisible by(options.xcount * options.ycount) %}
{{ end_page }}
{{ start_page }}
{% endif %}
{% else %}
{# last iteration: fill the row if the generated label count is too small #}
{% for i in (labels|length - 1) .. options.xcount %}
{% if labels|length - 1 < options.xcount and i < options.xcount %}
<td></td>
{% endif %}
{% endfor %}
{% endif %}
{% endif %} {% endif %}
</div> {% endfor %}
</div> {{ end_page }}
{% endfor %}
</body> </body>
</html> </html>