@php $fmt = in_array(($format ?? '11354'), ['11354','99014'], true) ? $format : '11354'; $dymoFix = isset($dymoFix) ? (bool) $dymoFix : false; $dymoRot = isset($dymoRot) ? (int) $dymoRot : 0; $dymoDx = isset($dymoDx) ? (float) $dymoDx : 0.0; $dymoDy = isset($dymoDy) ? (float) $dymoDy : 0.0; $autoPrint = request()->has('autoprint') && filter_var(request()->query('autoprint'), FILTER_VALIDATE_BOOL); $labelPrinterMode = isset($labelPrinterMode) ? (bool) $labelPrinterMode : false; $pageWidth = $fmt === '99014' ? '54mm' : '57mm'; $pageHeight = $fmt === '99014' ? '101mm' : '32mm'; $template = is_array(data_get($item->metadati, 'generic_label_template')) ? data_get($item->metadati, 'generic_label_template') : []; $templateName = (string) ($template['template_name'] ?? 'classic-right'); $qrPosition = (string) ($template['qr_position'] ?? ($fmt === '99014' ? 'bottom-right' : 'right-center')); $qrScale = (string) ($template['qr_scale'] ?? ($fmt === '99014' ? 'lg' : 'md')); $isArchive99014 = $fmt === '99014' && $templateName === 'archive-99014'; $payload = [ 'mnemonic_code' => (string) ($template['mnemonic_code'] ?? ''), 'titolo' => (string) $item->titolo, 'linea_secondaria' => (string) data_get($item->metadati, 'linea_secondaria', ''), 'tipo_label' => (string) $item->tipo_label, 'supporto_fisico' => (string) ($item->supporto_fisico ?? ''), 'percorso_compatto' => (string) ($item->percorso_fisico ?? ''), 'ubicazione' => trim(implode(' · ', array_filter([$item->magazzino, $item->scaffale, $item->ripiano, $item->ubicazione_dettaglio]))), 'note' => (string) ($item->note ?? ''), 'stabile' => (string) ($item->stabile->denominazione ?? ''), 'stabile_code' => (string) ($item->stabile->codice_stabile ?? ''), 'stabile_address' => (string) ($item->stabile->indirizzo_completo ?? ''), 'stabile_summary' => trim(implode(' · ', array_filter([ (string) ($item->stabile->denominazione ?? ''), (string) ($item->stabile->codice_stabile ?? ''), (string) ($item->stabile->indirizzo_completo ?? ''), ]))), 'codice_univoco' => (string) $item->codice_univoco, 'amazon_url' => (string) data_get($item->metadati, 'amazon_url', ''), ]; $slotValue = static function (string $key, array $payload): string { if ($key === 'none') { return ''; } return trim((string) ($payload[$key] ?? '')); }; $titleText = $slotValue((string) ($template['title_source'] ?? 'titolo'), $payload); $subtitleText = $slotValue((string) ($template['subtitle_source'] ?? 'linea_secondaria'), $payload); $metaText = $slotValue((string) ($template['meta_source'] ?? 'percorso_compatto'), $payload); $noteText = $slotValue((string) ($template['note_source'] ?? 'note'), $payload); $templateCode = trim((string) ($template['mnemonic_code'] ?? '')); $stableLineValue = static function (string $key, array $payload): string { if ($key === 'none') { return ''; } if ($key === 'blank_line') { return '__BLANK_LINE__'; } return trim((string) ($payload[$key] ?? '')); }; $templateLineRows = is_array($template['line_rows'] ?? null) && count($template['line_rows']) > 0 ? $template['line_rows'] : [ [ 'mode' => 'source', 'source' => (string) ($template['stable_line_one_source'] ?? 'stabile_summary'), 'text' => '', ], [ 'mode' => ((string) ($template['stable_line_two_source'] ?? 'blank_line')) === 'blank_line' ? 'blank_line' : 'source', 'source' => (string) ($template['stable_line_two_source'] ?? 'blank_line'), 'text' => '', ], [ 'mode' => ((int) ($template['blank_lines_count'] ?? 0)) >= 1 ? 'blank_line' : 'none', 'source' => 'none', 'text' => '', ], [ 'mode' => ((int) ($template['blank_lines_count'] ?? 0)) >= 2 ? 'blank_line' : 'none', 'source' => 'none', 'text' => '', ], ]; $stableLines = []; foreach ($templateLineRows as $lineRow) { if (! is_array($lineRow)) { continue; } $mode = (string) ($lineRow['mode'] ?? 'none'); if ($mode === 'blank_line') { $stableLines[] = '__BLANK_LINE__'; continue; } if ($mode === 'text') { $stableLines[] = trim((string) ($lineRow['text'] ?? '')); continue; } if ($mode === 'source') { $stableLines[] = $stableLineValue((string) ($lineRow['source'] ?? 'none'), $payload); } } $blankLinesCount = max(0, min(4, (int) ($template['blank_lines_count'] ?? 2))); @endphp @if($autoPrint) @endif