@php $sizeLabels = [ '28x19' => '28 x 19 mm', '30x19' => '30 x 19 mm', '30x28' => '30 x 28 mm', '58x40' => '58 x 40 mm', ]; $layoutLabels = [ 'classic' => 'Classic', 'price_top' => 'Price Top', 'compact' => 'Compact', ]; $code39Patterns = [ '0' => 'nnnwwnwnn','1' => 'wnnwnnnnw','2' => 'nnwwnnnnw','3' => 'wnwwnnnnn','4' => 'nnnwwnnnw', '5' => 'wnnwwnnnn','6' => 'nnwwwnnnn','7' => 'nnnwnnwnw','8' => 'wnnwnnwnn','9' => 'nnwwnnwnn', 'A' => 'wnnnnwnnw','B' => 'nnwnnwnnw','C' => 'wnwnnwnnn','D' => 'nnnnwwnnw','E' => 'wnnnwwnnn', 'F' => 'nnwnwwnnn','G' => 'nnnnnwwnw','H' => 'wnnnnwwnn','I' => 'nnwnnwwnn','J' => 'nnnnwwwnn', 'K' => 'wnnnnnnww','L' => 'nnwnnnnww','M' => 'wnwnnnnwn','N' => 'nnnnwnnww','O' => 'wnnnwnnwn', 'P' => 'nnwnwnnwn','Q' => 'nnnnnnwww','R' => 'wnnnnnwwn','S' => 'nnwnnnwwn','T' => 'nnnnwnwwn', 'U' => 'wwnnnnnnw','V' => 'nwwnnnnnw','W' => 'wwwnnnnnn','X' => 'nwnnwnnnw','Y' => 'wwnnwnnnn', 'Z' => 'nwwnwnnnn','-' => 'nwnnnnwnw','.' => 'wwnnnnwnn',' ' => 'nwwnnnwnn','$' => 'nwnwnwnnn', '/' => 'nwnwnnnwn','+' => 'nwnnnwnwn','%' => 'nnnwnwnwn','*' => 'nwnnwnwnn', ]; $buildCode39Svg = function (string $value, int $height = 26, int $narrow = 1, int $wide = 3) use ($code39Patterns): string { $value = strtoupper(trim($value)); $value = preg_replace('/[^0-9A-Z\-\.\ \$\/\+%]/', '', $value) ?: ''; if ($value === '') { $value = '0'; } $encoded = '*' . $value . '*'; $modules = []; foreach (str_split($encoded) as $index => $char) { $pattern = $code39Patterns[$char] ?? $code39Patterns['0']; foreach (str_split($pattern) as $partIndex => $part) { $modules[] = [ 'bar' => $partIndex % 2 === 0, 'width' => $part === 'w' ? $wide : $narrow, ]; } if ($index < strlen($encoded) - 1) { $modules[] = [ 'bar' => false, 'width' => $narrow, ]; } } $totalWidth = array_sum(array_column($modules, 'width')); $x = 0; $svg = ''; $svg .= ''; foreach ($modules as $module) { if ($module['bar']) { $svg .= ''; } $x += $module['width']; } $svg .= ''; return 'data:image/svg+xml;base64,' . base64_encode($svg); }; $previewSizes = [ '28x19' => ['width' => 188, 'barcode_h' => 26, 'shop' => '2.25mm', 'product' => '2.2mm', 'price' => '2.35mm'], '30x19' => ['width' => 198, 'barcode_h' => 26, 'shop' => '2.35mm', 'product' => '2.3mm', 'price' => '2.45mm'], '30x28' => ['width' => 198, 'barcode_h' => 32, 'shop' => '2.45mm', 'product' => '2.35mm', 'price' => '2.5mm'], '58x40' => ['width' => 320, 'barcode_h' => 44, 'shop' => '4.4mm', 'product' => '4.0mm', 'price' => '4.7mm'], ]; $previewSize = $previewSizes[$barcode_template_size] ?? $previewSizes['28x19']; $previewBarcode = $buildCode39Svg('1000162', $previewSize['barcode_h'], $barcode_template_size === '58x40' ? 2 : 1, $barcode_template_size === '58x40' ? 4 : 3); $previewLabelClass = 'barcode-preview-card barcode-preview-card--' . $barcode_template_size . ' ' . ($barcode_layout_style === 'compact' ? 'is-compact' : ($barcode_layout_style === 'price_top' ? 'is-price-top' : 'is-classic')); $previewShopFontSize = (int) ($barcode_shop_name_font_size ?? 14); $previewProductFontSize = (int) ($barcode_product_name_font_size ?? 12); $previewVariantFontSize = (int) ($barcode_variant_name_font_size ?? 10); @endphp @once @endonce

{{ __('Barcode Print') }}

{{--

{{ __('Create a reusable template first, then pick products and quantities in the print builder below.') }}

--}}
@if($canEditSettings) @endif
{{ __('Print Builder') }}
{{ __('You can choose products first and pick the template afterward. Quantity is set per row.') }}
@if($barcodePrintTemplate)
{{ $barcodePrintTemplate->name }}
@endif
@if($canEditSettings) @endif
@forelse($barcodePrintGroups as $product) @foreach($product['variants'] ?? [] as $variant) @endforeach @empty @endforelse
{{ __('Product') }} {{ __('Barcode') }} {{ __('Shortcode') }} {{ __('Source') }} {{ __('Qty') }}
{{ $product['display_name'] }} @if(! empty($product['variants']))
{{ __('Includes variants') }}
@endif
{{ $product['barcode_number'] ?? '-' }} {{ $product['shortcode'] ?? '-' }} @if(! empty($product['has_shortcode'])) @else {{ __('Barcode') }} @endif
{{ $variant['display_name'] }}
{{ __('Variant') }}
{{ $variant['barcode_label'] ?? '-' }} {{ $variant['shortcode'] ?: '-' }} {{ $variant['barcode_source_label'] ?? __('Variant Barcode') }}
{{ __('No products found.') }}
@if($canEditSettings) @endif
{{--
{{ __('Saved Templates') }}
{{ $barcodeTemplates->count() }}
@forelse($barcodeTemplates as $template) @empty @endforelse
{{ __('Template') }} {{ __('Size') }} {{ __('Use') }}
{{ $template->name }}
{{ $layoutLabels[$template->layout_style] ?? ucfirst(str_replace('_', ' ', $template->layout_style)) }}
{{ $sizeLabels[$template->size] ?? $template->size }}
{{ __('No barcode templates found.') }}
--}} {{--
{{ __('Template Preview') }}
@if($barcode_template_name) {{ $barcode_template_name }} @endif
{{ __('Preview updates while you edit the template.') }}
@if($barcode_show_shop_name)
{{ $admin->shop_name ?? config('app.name', 'Shop') }}
@endif @if($barcode_layout_style === 'price_top' && $barcode_show_price)
Rs. 820.00
@endif @if($barcode_show_product_name)
{{ __('Sample Product Name') }}
@endif
1000162
1000162
@if($barcode_layout_style !== 'price_top' && $barcode_show_price)
Rs. 820.00
@endif
--}}
@forelse($barcodeTemplates as $template) @empty @endforelse
{{ __('Template') }} {{ __('Size') }} {{ __('Layout') }} {{ __('Options') }} {{ __('Products') }} {{ __('Actions') }}
{{ $template->name }} {{ $sizeLabels[$template->size] ?? $template->size }} {{ $layoutLabels[$template->layout_style] ?? ucfirst(str_replace('_', ' ', $template->layout_style)) }}
@if($template->show_shop_name) Shop @endif @if($template->show_product_name) Product @endif @if($template->show_price) Price @endif
{{ count($template->selected_product_ids ?? []) }} @if($canEditSettings) @endif
{{ __('No barcode templates found.') }}