Grocycode: Print Label from product form

This commit is contained in:
Katharina Bogad 2021-06-08 18:19:54 +02:00
parent 6951c1dfac
commit a7c5d2931e
2 changed files with 29 additions and 8 deletions

View File

@ -301,6 +301,21 @@ $('#name').focus();
$('.input-group-qu').trigger('change');
Grocy.FrontendHelpers.ValidateForm('product-form');
$(document).on('click', '.stockentry-grocycode-product-label-print', function(e)
{
e.preventDefault();
document.activeElement.blur();
var productId = $(e.currentTarget).attr('data-product-id');
Grocy.Api.Get('stock/products/' + productId + '/printlabel', function(labelData)
{
if (Grocy.Webhooks.labelprinter !== undefined)
{
Grocy.FrontendHelpers.RunWebhook(Grocy.Webhooks.labelprinter, labelData);
}
});
});
$(document).on('click', '.qu-conversion-delete-button', function(e)
{
var objectId = $(e.currentTarget).attr('data-qu-conversion-id');

View File

@ -25,11 +25,7 @@
@if($mode == 'edit')
<script>
Grocy.EditObjectId = {
{
$product - > id
}
};
Grocy.EditObjectId = {{ $product->id }};
</script>
@if(!empty($product->picture_file_name))
@ -445,8 +441,18 @@
<p>
<img src="{{ $U('/product/' . $product->id . '/grocycode') }}"
class="float-lg-left mr-2">
{{ $__t('Grocycode is a unique referer to this product in your grocy instance. Print it onto a label and scan it like any other barcode!') }}<br>
<a href="{{ $U('/product/' . $product->id . '/grocycode?download=true') }}">{{ $__t('Download') }}</a>
{{ $__t('Grocycode is a unique referer to this product in your grocy instance. Print it onto a label and scan it like any other barcode!') }}
</p>
<p>
<a class="btn btn-outline-primary btn-sm"
href="{{ $U('/product/' . $product->id . '/grocycode?download=true') }}">{{ $__t('Download') }}</a>
@if(GROCY_FEATURE_FLAG_LABELPRINTER)
<a class="btn btn-outline-primary btn-sm stockentry-grocycode-product-label-print"
data-product-id="{{ $product->id }}"
href="#">
{{ $__t('Print Product Label') }}
</a>
@endif
</p>
</div>
</div>
@ -693,4 +699,4 @@
</div>
</div>
</div>
@stop
@stop