Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,7 @@ public function getLabels(Request $request): JsonResponse
// bulkedit=false and count=0 are default values for label generation
$label = $label->with('assets', $assets)
->with('settings', $settings)
->with('offset', max(0, (int) $request->input('offset', 0)))
->with('bulkedit', false)
->with('count', 0);

Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/Assets/BulkAssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,12 @@ public function edit(Request $request): View|RedirectResponse
case 'labels':
$this->authorize('view', Asset::class);

$offset = max(0, (int) $request->input('offset', 0));

return (new Label)
->with('assets', $assets)
->with('settings', Setting::getSettings())
->with('offset', $offset)
->with('bulkedit', true)
->with('count', 0);

Expand Down
16 changes: 16 additions & 0 deletions resources/views/blade/table/bulk-assets.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ class="form-inline"
@endif
</select>

<label for="table-label-offset" class="js-label-offset-toggle" style="margin-left: 8px; margin-right: 6px;">
Offset
</label>
<input
id="table-label-offset"
type="number"
name="offset"
class="form-control js-label-offset js-label-offset-toggle"
value="0"
min="0"
step="1"
style="width: 120px;"
aria-label="label offset"
title="Skip this many labels before printing"
>

<button class="btn btn-theme" id="{{ Illuminate\Support\Str::camel($name) }}Button" disabled>{{ trans('button.go') }}</button>
</label>
</div>
Expand Down
15 changes: 14 additions & 1 deletion resources/views/hardware/labels.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
$settings->labels_height = $settings->labels_height - $settings->labels_display_bgutter;
// Leave space on bottom for 1D barcode if necessary
$qr_size = ($settings->alt_barcode_enabled=='1') && ($settings->label2_1d_type!='') ? $settings->labels_height - .3 : $settings->labels_height - 0.1;
$offset = max(0, (int) ($offset ?? 0));
$count = (int) ($count ?? 0);
$total_labels = count($assets) + $offset;

Check notice on line 17 in resources/views/hardware/labels.blade.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

resources/views/hardware/labels.blade.php#L17

Operation must be bracketed
?>

<style>
Expand Down Expand Up @@ -106,6 +109,16 @@
@endif
</style>

@for ($i = 0; $i < $offset; $i++)
<?php $count++; ?>
<div class="label"></div>

@if (($count % $settings->labels_per_page == 0) && $count!=$total_labels)
<div class="page-break"></div>
<div class="next-padding">&nbsp;</div>
@endif
@endfor

@foreach ($assets as $asset)
<?php $count++; ?>
<div class="label">
Expand Down Expand Up @@ -166,7 +179,7 @@

</div>

@if (($count % $settings->labels_per_page == 0) && $count!=count($assets))
@if (($count % $settings->labels_per_page == 0) && $count!=$total_labels)
<div class="page-break"></div>
<div class="next-padding">&nbsp;</div>
@endif
Expand Down
16 changes: 16 additions & 0 deletions resources/views/partials/asset-bulk-actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ class="form-inline"
@endif
</select>

<label for="asset-label-offset" class="js-label-offset-toggle" style="margin-left: 8px; margin-right: 6px;">
Offset
</label>
<input
id="asset-label-offset"
type="number"
name="offset"
class="form-control js-label-offset js-label-offset-toggle"
value="0"
min="0"
step="1"
style="width: 120px;"
aria-label="label offset"
title="Skip this many labels before printing"
>

<button class="btn btn-theme" id="{{ (isset($id_button)) ? $id_button : 'bulkAssetEditButton' }}" disabled>{{ trans('button.go') }}</button>
</form>
</div>
22 changes: 22 additions & 0 deletions resources/views/partials/bootstrap-table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,28 @@ function dateRowCheckStyle(value) {
}
});

function updateLabelOffsetInputState($form) {
var action = $form.find('select[name="bulk_actions"]').val();
var $offsetInput = $form.find('.js-label-offset');
var $offsetToggles = $form.find('.js-label-offset-toggle');

if ($offsetInput.length === 0) {
return;
}

var enabled = action === 'labels';
$offsetInput.prop('disabled', !enabled);
$offsetToggles.toggle(enabled);
}

$(document).on('change', 'form select[name="bulk_actions"]', function () {
updateLabelOffsetInputState($(this).closest('form'));
});

$('form').each(function () {
updateLabelOffsetInputState($(this));
});



// This specifies the footer columns that should have special styles associated
Expand Down