@php $docTitle = $docTitle ?? 'Document'; $indexRoute = $indexRoute ?? ''; $updateRoute = $updateRoute ?? ''; $tab = $tab ?? 'options'; $labelGroups = [ 'headers' => ['title' => 'Document labels', 'desc' => 'Titles, addresses, and header text', 'icon' => 'ri-file-text-line', 'keys' => []], 'columns' => ['title' => 'Table columns', 'desc' => 'Headings for line items on the document', 'icon' => 'ri-table-line', 'keys' => []], 'copies' => ['title' => 'Copy labels', 'desc' => 'Wording on duplicate & triplicate copies', 'icon' => 'ri-file-copy-line', 'keys' => []], 'custom' => ['title' => 'Custom fields', 'desc' => 'Optional extra fields on the document', 'icon' => 'ri-edit-box-line', 'keys' => []], ]; foreach (array_keys($labelDefs ?? []) as $key) { if (str_starts_with($key, 'col_')) { $labelGroups['columns']['keys'][] = $key; } elseif (str_starts_with($key, 'custom_field')) { $labelGroups['custom']['keys'][] = $key; } elseif (str_starts_with($key, 'copy_')) { $labelGroups['copies']['keys'][] = $key; } else { $labelGroups['headers']['keys'][] = $key; } } $labelGroups = array_values(array_filter($labelGroups, fn ($g) => count($g['keys']) > 0)); $optionGroupMeta = [ 'layout' => ['title' => 'Layout & addresses', 'icon' => 'ri-layout-masonry-line'], 'totals' => ['title' => 'Totals & amounts', 'icon' => 'ri-money-rupee-circle-line'], 'parties' => ['title' => 'Customer & vendor', 'icon' => 'ri-user-line'], 'signatures' => ['title' => 'Signatures', 'icon' => 'ri-quill-pen-line'], 'content' => ['title' => 'Content', 'icon' => 'ri-article-line'], 'general' => ['title' => 'General', 'icon' => 'ri-settings-3-line'], ]; $optionGroups = []; foreach ($optionDefs ?? [] as $key => $def) { $group = 'general'; if (str_contains($key, 'signature')) { $group = 'signatures'; } elseif (str_contains($key, 'shipping') || str_contains($key, 'header')) { $group = 'layout'; } elseif (str_contains($key, 'contact') || str_contains($key, 'bill_to') || str_contains($key, 'quote_to') || str_contains($key, 'vendor')) { $group = 'parties'; } elseif (str_contains($key, 'terms')) { $group = 'content'; } elseif (preg_match('/(total|amount|due|net|tax|words|received|paid)/', $key)) { $group = 'totals'; } $optionGroups[$group][$key] = $def; } @endphp
Control PDF/print layout and customize field labels for your company.