{{-- Vector (mPDF) label page. Renders ONE page's grid of labels. Mirrors labels.partials.preview_2 field-for-field (every print toggle + font size), but: - uses a table grid instead of flexbox (mPDF has no flexbox), and - renders the barcode as a native vector (crisp at any DPI, spec quiet zone built in). Geometry (label w/h, row/col distance, stickers per row, paper size, margins) all come from $barcode_details, identical to the HTML preview. --}} @php $stickers_in_one_row = max(1, (int) $barcode_details->stickers_in_one_row); $label_w = $barcode_details->width * 1; // inches $label_h = $barcode_details->height * 1; // inches $col_gap = $barcode_details->col_distance * 1; // inches $row_gap = $barcode_details->row_distance * 1; // inches $custom_labels = json_decode(session('business.custom_labels'), true); $product_custom_fields = ! empty($custom_labels['product']) ? $custom_labels['product'] : []; $count = count($page_products); $remainder = $count % $stickers_in_one_row; @endphp @foreach($page_products as $idx => $page_product) @if($idx % $stickers_in_one_row == 0) @endif @if(($idx + 1) % $stickers_in_one_row == 0) @endif @endforeach @if($remainder != 0) {{-- pad the final row so the grid stays aligned --}} @for($k = 0; $k < $stickers_in_one_row - $remainder; $k++) @endfor @endif
@php // Per-label fit-to-height scale from the controller: 1.0 when the content fits the // configured label height as-is, < 1.0 when fonts + bars had to be shrunk together so // the full sheet stays on a single page. Every font-size below is multiplied by it. $fs = (! empty($page_product->barcode_render) && ! empty($page_product->barcode_render['fit_scale'])) ? $page_product->barcode_render['fit_scale'] : 1; @endphp {{-- Business Name --}} @if(!empty($print['business_name']))
{{$business_name}}
@endif {{-- Product Name (+ optional lot number inline) --}} @if(!empty($print['name']))
{{$page_product->product_actual_name}} @if(!empty($print['lot_number']) && !empty($page_product->lot_number)) ({{$page_product->lot_number}}) @endif
@endif {{-- Variation --}} @if(!empty($print['variations']) && $page_product->is_dummy != 1)
{{$page_product->product_variation_name}}:{{$page_product->variation_name}}
@endif {{-- Product custom fields (each on its own line) --}} @foreach($product_custom_fields as $index => $cf) @php $field_name = 'product_custom_field' . $loop->iteration; @endphp @if(!empty($cf) && !empty($page_product->$field_name) && !empty($print[$field_name]))
{{ $cf }}: {{ $page_product->$field_name }}
@endif @endforeach {{-- Price (own line) --}} @if(!empty($print['price']))
@lang('lang_v1.price'): {{session('currency')['symbol'] ?? ''}}@if($print['price_type'] == 'inclusive'){{@num_format($page_product->sell_price_inc_tax)}}@else{{@num_format($page_product->default_sell_price)}}@endif
@endif {{-- Expiry date (own line) --}} @if(!empty($print['exp_date']) && !empty($page_product->exp_date))
@lang('product.exp_date'): {{$page_product->exp_date}}
@endif {{-- Packing date (own line) --}} @if(!empty($print['packing_date']) && !empty($page_product->packing_date))
@lang('lang_v1.packing_date'): {{$page_product->packing_date}}
@endif {{-- Barcode (native vector) --}}
@if(!empty($page_product->barcode_render)) {{-- quiet_zone_left/right pinned to the spec 10X so the light margin is guaranteed regardless of mPDF defaults, and stays consistent with the width-fit math in setBarcodeRenderProps() (which budgets the same 10X lightmL/lightmR). --}} @endif
{{-- Human-readable SKU (10px, scaled by the same fit factor as the lines above) --}}
{{$page_product->sub_sku}}