Andrew Wallo 5 månader sedan
förälder
incheckning
7ff767266c

+ 3
- 0
app/Enums/Setting/Template.php Visa fil

2
 
2
 
3
 namespace App\Enums\Setting;
3
 namespace App\Enums\Setting;
4
 
4
 
5
+use App\Enums\Concerns\ParsesEnum;
5
 use Filament\Support\Contracts\HasLabel;
6
 use Filament\Support\Contracts\HasLabel;
6
 
7
 
7
 enum Template: string implements HasLabel
8
 enum Template: string implements HasLabel
8
 {
9
 {
10
+    use ParsesEnum;
11
+
9
     case Default = 'default';
12
     case Default = 'default';
10
     case Modern = 'modern';
13
     case Modern = 'modern';
11
     case Classic = 'classic';
14
     case Classic = 'classic';

+ 5
- 18
app/Filament/Company/Clusters/Settings/Resources/DocumentDefaultResource.php Visa fil

9
 use App\Enums\Setting\Template;
9
 use App\Enums\Setting\Template;
10
 use App\Filament\Company\Clusters\Settings;
10
 use App\Filament\Company\Clusters\Settings;
11
 use App\Filament\Company\Clusters\Settings\Resources\DocumentDefaultResource\Pages;
11
 use App\Filament\Company\Clusters\Settings\Resources\DocumentDefaultResource\Pages;
12
+use App\Filament\Forms\Components\DocumentPreview;
12
 use App\Models\Setting\DocumentDefault;
13
 use App\Models\Setting\DocumentDefault;
13
 use Filament\Forms;
14
 use Filament\Forms;
14
 use Filament\Forms\Components\Component;
15
 use Filament\Forms\Components\Component;
128
                             ->options(Template::class),
129
                             ->options(Template::class),
129
                         ...static::getColumnLabelsSchema(),
130
                         ...static::getColumnLabelsSchema(),
130
                     ])->columnSpan(1),
131
                     ])->columnSpan(1),
131
-                Forms\Components\Grid::make()
132
-                    ->schema([
133
-                        Forms\Components\ViewField::make('preview.default')
134
-                            ->columnSpan(2)
135
-                            ->hiddenLabel()
136
-                            ->visible(static fn (Get $get) => $get('template') === 'default')
137
-                            ->view('filament.company.components.document-templates.default'),
138
-                        Forms\Components\ViewField::make('preview.modern')
139
-                            ->columnSpan(2)
140
-                            ->hiddenLabel()
141
-                            ->visible(static fn (Get $get) => $get('template') === 'modern')
142
-                            ->view('filament.company.components.document-templates.modern'),
143
-                        Forms\Components\ViewField::make('preview.classic')
144
-                            ->columnSpan(2)
145
-                            ->hiddenLabel()
146
-                            ->visible(static fn (Get $get) => $get('template') === 'classic')
147
-                            ->view('filament.company.components.document-templates.classic'),
148
-                    ])->columnSpan([
132
+                DocumentPreview::make()
133
+                    ->template(static fn (Get $get) => Template::parse($get('template')))
134
+                    ->preview()
135
+                    ->columnSpan([
149
                         'lg' => 2,
136
                         'lg' => 2,
150
                     ]),
137
                     ]),
151
             ])->columns(3);
138
             ])->columns(3);

+ 45
- 0
app/Filament/Forms/Components/DocumentPreview.php Visa fil

1
+<?php
2
+
3
+namespace App\Filament\Forms\Components;
4
+
5
+use App\Enums\Setting\Template;
6
+use Closure;
7
+use Filament\Forms\Components\Grid;
8
+
9
+class DocumentPreview extends Grid
10
+{
11
+    protected string $view = 'filament.forms.components.document-preview';
12
+
13
+    protected bool | Closure $isPreview = false;
14
+
15
+    protected Template | Closure $template = Template::Default;
16
+
17
+    protected function setUp(): void
18
+    {
19
+        parent::setUp();
20
+    }
21
+
22
+    public function preview(bool | Closure $condition = true): static
23
+    {
24
+        $this->isPreview = $condition;
25
+
26
+        return $this;
27
+    }
28
+
29
+    public function template(Template | Closure $template): static
30
+    {
31
+        $this->template = $template;
32
+
33
+        return $this;
34
+    }
35
+
36
+    public function isPreview(): bool
37
+    {
38
+        return (bool) $this->evaluate($this->isPreview);
39
+    }
40
+
41
+    public function getTemplate(): Template
42
+    {
43
+        return $this->evaluate($this->template);
44
+    }
45
+}

+ 15
- 0
app/Filament/Infolists/Components/DocumentPreview.php Visa fil

5
 use App\Enums\Accounting\DocumentType;
5
 use App\Enums\Accounting\DocumentType;
6
 use App\Enums\Setting\Template;
6
 use App\Enums\Setting\Template;
7
 use App\Models\Setting\DocumentDefault;
7
 use App\Models\Setting\DocumentDefault;
8
+use Closure;
8
 use Filament\Infolists\Components\Grid;
9
 use Filament\Infolists\Components\Grid;
9
 
10
 
10
 class DocumentPreview extends Grid
11
 class DocumentPreview extends Grid
13
 
14
 
14
     protected DocumentType $documentType = DocumentType::Invoice;
15
     protected DocumentType $documentType = DocumentType::Invoice;
15
 
16
 
17
+    protected bool | Closure $isPreview = false;
18
+
16
     protected function setUp(): void
19
     protected function setUp(): void
17
     {
20
     {
18
         parent::setUp();
21
         parent::setUp();
31
         return $this;
34
         return $this;
32
     }
35
     }
33
 
36
 
37
+    public function preview(bool | Closure $condition = true): static
38
+    {
39
+        $this->isPreview = $condition;
40
+
41
+        return $this;
42
+    }
43
+
34
     public function getType(): DocumentType
44
     public function getType(): DocumentType
35
     {
45
     {
36
         return $this->documentType;
46
         return $this->documentType;
37
     }
47
     }
38
 
48
 
49
+    public function isPreview(): bool
50
+    {
51
+        return (bool) $this->evaluate($this->isPreview);
52
+    }
53
+
39
     public function getTemplate(): Template
54
     public function getTemplate(): Template
40
     {
55
     {
41
         if ($this->documentType === DocumentType::RecurringInvoice) {
56
         if ($this->documentType === DocumentType::RecurringInvoice) {

+ 25
- 0
resources/css/filament/company/theme.css Visa fil

105
 .doc-template-container {
105
 .doc-template-container {
106
     color: initial;
106
     color: initial;
107
 }
107
 }
108
+
109
+.doc-template-container .overflow-x-auto,
110
+.doc-template-paper {
111
+    scrollbar-width: thin;
112
+}
113
+
114
+.doc-template-paper.preview {
115
+    zoom: 0.5;
116
+}
117
+
118
+@media (min-width: 1024px) {
119
+    .doc-template-paper.preview {
120
+        zoom: 0.85;
121
+    }
122
+}
123
+
124
+.doc-template-paper:not(.preview) {
125
+    zoom: 0.65;
126
+}
127
+
128
+@media (min-width: 1024px) {
129
+    .doc-template-paper:not(.preview) {
130
+        zoom: 1;
131
+    }
132
+}

+ 4
- 8
resources/views/components/company/document-template/container.blade.php Visa fil

5
 <div
5
 <div
6
     @class([
6
     @class([
7
         'doc-template-container flex justify-center',
7
         'doc-template-container flex justify-center',
8
-        'scale-[0.85] origin-top' => $preview === true,
9
     ])
8
     ])
10
 >
9
 >
11
-    <div class="overflow-auto">
10
+    <div class="max-w-full overflow-x-auto shadow-xl ring-1 ring-gray-950/5 dark:ring-white/10">
12
         <div
11
         <div
13
             @class([
12
             @class([
14
-                'doc-template-paper bg-[#ffffff] shadow-xl ring-1 ring-gray-950/5 dark:ring-white/10',
15
-                'w-[51.25rem] h-[64rem]' => $preview === false,
16
-                'w-[48rem] h-[61.75rem]' => $preview === true,
17
-            ])
18
-            @style([
19
-                'scrollbar-width: thin;' => $preview === false,
13
+                'doc-template-paper bg-[#ffffff] overflow-y-auto',
14
+                'w-[51.25rem] h-[64rem]' => ! $preview,
15
+                'w-[48rem] min-h-[61.75rem] preview' => $preview,
20
             ])
16
             ])
21
         >
17
         >
22
             {{ $slot }}
18
             {{ $slot }}

+ 1
- 1
resources/views/components/company/document-template/footer.blade.php Visa fil

1
-<footer {{ $attributes->class(['doc-template-footer']) }}>
1
+<footer {{ $attributes->class(['doc-template-footer min-h-48']) }}>
2
     {{ $slot }}
2
     {{ $slot }}
3
 </footer>
3
 </footer>

+ 13
- 26
resources/views/filament/company/components/document-templates/classic.blade.php Visa fil

1
-@php
2
-    $data = $this->form->getRawState();
3
-    $document = \App\DTO\DocumentPreviewDTO::fromSettings($this->record, $data);
4
-@endphp
5
-
6
-{!! $document->getFontHtml() !!}
7
-
8
-<style>
9
-    .doc-template-paper {
10
-        font-family: '{{ $document->font->getLabel() }}', sans-serif;
11
-    }
12
-</style>
13
-
14
-<x-company.document-template.container class="classic-template-container" preview>
1
+<x-company.document-template.container class="classic-template-container" :preview="$preview">
15
     <!-- Header Section -->
2
     <!-- Header Section -->
16
     <x-company.document-template.header class="classic-template-header">
3
     <x-company.document-template.header class="classic-template-header">
17
         <div class="w-2/3 text-left">
4
         <div class="w-2/3 text-left">
18
-            <div class="text-xs">
19
-                <strong class="text-xs block">{{ $document->company->name }}</strong>
5
+            <div class="text-sm">
6
+                <strong class="text-sm block">{{ $document->company->name }}</strong>
20
                 @if($formattedAddress = $document->company->getFormattedAddressHtml())
7
                 @if($formattedAddress = $document->company->getFormattedAddressHtml())
21
                     {!! $formattedAddress !!}
8
                     {!! $formattedAddress !!}
22
                 @endif
9
                 @endif
36
             <x-icons.document-header-decoration
23
             <x-icons.document-header-decoration
37
                 color="{{ $document->accentColor }}"
24
                 color="{{ $document->accentColor }}"
38
                 text="{{ $document->header }}"
25
                 text="{{ $document->header }}"
39
-                class="w-48"
26
+                class="w-60"
40
             />
27
             />
41
             <hr class="grow-[2] py-0.5 border-solid border-y-2" style="border-color: {{ $document->accentColor }};">
28
             <hr class="grow-[2] py-0.5 border-solid border-y-2" style="border-color: {{ $document->accentColor }};">
42
         </div>
29
         </div>
43
         @if ($document->subheader)
30
         @if ($document->subheader)
44
-            <p class="text-xs text-center text-gray-600">{{ $document->subheader }}</p>
31
+            <p class="text-sm text-center text-gray-600">{{ $document->subheader }}</p>
45
         @endif
32
         @endif
46
 
33
 
47
         <div class="flex justify-between items-end">
34
         <div class="flex justify-between items-end">
48
             <!-- Billing Details -->
35
             <!-- Billing Details -->
49
-            <div class="text-xs">
36
+            <div class="text-sm">
50
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
37
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
51
-                <p class="text-xs font-bold">{{ $document->client->name }}</p>
38
+                <p class="text-sm font-bold">{{ $document->client->name }}</p>
52
                 @if($formattedAddress = $document->client->getFormattedAddressHtml())
39
                 @if($formattedAddress = $document->client->getFormattedAddressHtml())
53
                     {!! $formattedAddress !!}
40
                     {!! $formattedAddress !!}
54
                 @endif
41
                 @endif
55
             </div>
42
             </div>
56
 
43
 
57
-            <div class="text-xs">
44
+            <div class="text-sm">
58
                 <table class="min-w-full">
45
                 <table class="min-w-full">
59
                     <tbody>
46
                     <tbody>
60
                     <tr>
47
                     <tr>
84
     <!-- Line Items -->
71
     <!-- Line Items -->
85
     <x-company.document-template.line-items class="classic-template-line-items px-6">
72
     <x-company.document-template.line-items class="classic-template-line-items px-6">
86
         <table class="w-full text-left table-fixed">
73
         <table class="w-full text-left table-fixed">
87
-            <thead class="text-xs leading-relaxed">
74
+            <thead class="text-sm leading-relaxed">
88
             <tr>
75
             <tr>
89
                 <th class="text-left w-[50%] py-4">{{ $document->columnLabel->items }}</th>
76
                 <th class="text-left w-[50%] py-4">{{ $document->columnLabel->items }}</th>
90
                 <th class="text-center w-[10%] py-4">{{ $document->columnLabel->units }}</th>
77
                 <th class="text-center w-[10%] py-4">{{ $document->columnLabel->units }}</th>
92
                 <th class="text-right w-[20%] py-4">{{ $document->columnLabel->amount }}</th>
79
                 <th class="text-right w-[20%] py-4">{{ $document->columnLabel->amount }}</th>
93
             </tr>
80
             </tr>
94
             </thead>
81
             </thead>
95
-            <tbody class="text-xs border-y-2 border-dotted border-gray-300">
82
+            <tbody class="text-sm border-y-2 border-dotted border-gray-300">
96
             @foreach($document->lineItems as $item)
83
             @foreach($document->lineItems as $item)
97
                 <tr>
84
                 <tr>
98
                     <td class="text-left font-semibold py-3">
85
                     <td class="text-left font-semibold py-3">
110
         </table>
97
         </table>
111
 
98
 
112
         <!-- Financial Details and Notes -->
99
         <!-- Financial Details and Notes -->
113
-        <div class="flex justify-between text-xs space-x-1 pt-4">
100
+        <div class="flex justify-between text-sm space-x-1 pt-4">
114
             <!-- Notes Section -->
101
             <!-- Notes Section -->
115
             <div class="w-[60%] py-2">
102
             <div class="w-[60%] py-2">
116
                 <p class="font-semibold">{{ $document->footer }}</p>
103
                 <p class="font-semibold">{{ $document->footer }}</p>
119
             <!-- Financial Summary -->
106
             <!-- Financial Summary -->
120
             <div class="w-[40%]">
107
             <div class="w-[40%]">
121
                 <table class="w-full table-fixed whitespace-nowrap">
108
                 <table class="w-full table-fixed whitespace-nowrap">
122
-                    <tbody class="text-xs">
109
+                    <tbody class="text-sm">
123
                     @if($document->subtotal)
110
                     @if($document->subtotal)
124
                         <tr>
111
                         <tr>
125
                             <td class="text-right font-semibold py-2">Subtotal:</td>
112
                             <td class="text-right font-semibold py-2">Subtotal:</td>
159
     </x-company.document-template.line-items>
146
     </x-company.document-template.line-items>
160
 
147
 
161
     <!-- Footer -->
148
     <!-- Footer -->
162
-    <x-company.document-template.footer class="classic-template-footer p-6 text-xs">
149
+    <x-company.document-template.footer class="classic-template-footer p-6 text-sm">
163
         <h4 class="font-semibold mb-2">Terms & Conditions</h4>
150
         <h4 class="font-semibold mb-2">Terms & Conditions</h4>
164
         <p class="break-words line-clamp-4">{{ $document->terms }}</p>
151
         <p class="break-words line-clamp-4">{{ $document->terms }}</p>
165
     </x-company.document-template.footer>
152
     </x-company.document-template.footer>

+ 11
- 24
resources/views/filament/company/components/document-templates/default.blade.php Visa fil

1
-@php
2
-    $data = $this->form->getRawState();
3
-    $document = \App\DTO\DocumentPreviewDTO::fromSettings($this->record, $data);
4
-@endphp
5
-
6
-{!! $document->getFontHtml() !!}
7
-
8
-<style>
9
-    .doc-template-paper {
10
-        font-family: '{{ $document->font->getLabel() }}', sans-serif;
11
-    }
12
-</style>
13
-
14
-<x-company.document-template.container class="default-template-container" preview>
1
+<x-company.document-template.container class="default-template-container" :preview="$preview">
15
 
2
 
16
     <x-company.document-template.header class="default-template-header border-b">
3
     <x-company.document-template.header class="default-template-header border-b">
17
         <div class="w-1/3">
4
         <div class="w-1/3">
25
                 <div>
12
                 <div>
26
                     <h1 class="text-3xl font-light uppercase">{{ $document->header }}</h1>
13
                     <h1 class="text-3xl font-light uppercase">{{ $document->header }}</h1>
27
                     @if ($document->subheader)
14
                     @if ($document->subheader)
28
-                        <p class="text-xs text-gray-600">{{ $document->subheader }}</p>
15
+                        <p class="text-sm text-gray-600">{{ $document->subheader }}</p>
29
                     @endif
16
                     @endif
30
                 </div>
17
                 </div>
31
-                <div class="text-xs">
32
-                    <strong class="text-xs block">{{ $document->company->name }}</strong>
18
+                <div class="text-sm">
19
+                    <strong class="text-sm block">{{ $document->company->name }}</strong>
33
                     @if($formattedAddress = $document->company->getFormattedAddressHtml())
20
                     @if($formattedAddress = $document->company->getFormattedAddressHtml())
34
                         {!! $formattedAddress !!}
21
                         {!! $formattedAddress !!}
35
                     @endif
22
                     @endif
41
     <x-company.document-template.metadata class="default-template-metadata space-y-4">
28
     <x-company.document-template.metadata class="default-template-metadata space-y-4">
42
         <div class="flex justify-between items-end">
29
         <div class="flex justify-between items-end">
43
             <!-- Billing Details -->
30
             <!-- Billing Details -->
44
-            <div class="text-xs">
31
+            <div class="text-sm">
45
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
32
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
46
-                <p class="text-xs font-bold">{{ $document->client->name }}</p>
33
+                <p class="text-sm font-bold">{{ $document->client->name }}</p>
47
                 @if($formattedAddress = $document->client->getFormattedAddressHtml())
34
                 @if($formattedAddress = $document->client->getFormattedAddressHtml())
48
                     {!! $formattedAddress !!}
35
                     {!! $formattedAddress !!}
49
                 @endif
36
                 @endif
50
             </div>
37
             </div>
51
 
38
 
52
-            <div class="text-xs">
39
+            <div class="text-sm">
53
                 <table class="min-w-full">
40
                 <table class="min-w-full">
54
                     <tbody>
41
                     <tbody>
55
                     <tr>
42
                     <tr>
79
     <!-- Line Items Table -->
66
     <!-- Line Items Table -->
80
     <x-company.document-template.line-items class="default-template-line-items">
67
     <x-company.document-template.line-items class="default-template-line-items">
81
         <table class="w-full text-left table-fixed">
68
         <table class="w-full text-left table-fixed">
82
-            <thead class="text-xs leading-relaxed" style="background: {{ $document->accentColor }}">
69
+            <thead class="text-sm leading-relaxed" style="background: {{ $document->accentColor }}">
83
             <tr class="text-white">
70
             <tr class="text-white">
84
                 <th class="text-left pl-6 w-[50%] py-2">{{ $document->columnLabel->items }}</th>
71
                 <th class="text-left pl-6 w-[50%] py-2">{{ $document->columnLabel->items }}</th>
85
                 <th class="text-center w-[10%] py-2">{{ $document->columnLabel->units }}</th>
72
                 <th class="text-center w-[10%] py-2">{{ $document->columnLabel->units }}</th>
87
                 <th class="text-right pr-6 w-[20%] py-2">{{ $document->columnLabel->amount }}</th>
74
                 <th class="text-right pr-6 w-[20%] py-2">{{ $document->columnLabel->amount }}</th>
88
             </tr>
75
             </tr>
89
             </thead>
76
             </thead>
90
-            <tbody class="text-xs border-b-2 border-gray-300">
77
+            <tbody class="text-sm border-b-2 border-gray-300">
91
             @foreach($document->lineItems as $item)
78
             @foreach($document->lineItems as $item)
92
                 <tr>
79
                 <tr>
93
                     <td class="text-left pl-6 font-semibold py-3">
80
                     <td class="text-left pl-6 font-semibold py-3">
102
                 </tr>
89
                 </tr>
103
             @endforeach
90
             @endforeach
104
             </tbody>
91
             </tbody>
105
-            <tfoot class="text-xs summary-section">
92
+            <tfoot class="text-sm summary-section">
106
             @if($document->subtotal)
93
             @if($document->subtotal)
107
                 <tr>
94
                 <tr>
108
                     <td class="pl-6 py-2" colspan="2"></td>
95
                     <td class="pl-6 py-2" colspan="2"></td>
145
     </x-company.document-template.line-items>
132
     </x-company.document-template.line-items>
146
 
133
 
147
     <!-- Footer Notes -->
134
     <!-- Footer Notes -->
148
-    <x-company.document-template.footer class="classic-template-footer flex flex-col text-xs p-6">
135
+    <x-company.document-template.footer class="default-template-footer flex flex-col text-sm p-6">
149
         <div>
136
         <div>
150
             <h4 class="font-semibold mb-2">Terms & Conditions</h4>
137
             <h4 class="font-semibold mb-2">Terms & Conditions</h4>
151
             <p class="break-words line-clamp-4">{{ $document->terms }}</p>
138
             <p class="break-words line-clamp-4">{{ $document->terms }}</p>

+ 2
- 15
resources/views/filament/company/components/document-templates/modern.blade.php Visa fil

1
-@php
2
-    $data = $this->form->getRawState();
3
-    $document = \App\DTO\DocumentPreviewDTO::fromSettings($this->record, $data);
4
-@endphp
5
-
6
-{!! $document->getFontHtml() !!}
7
-
8
-<style>
9
-    .doc-template-paper {
10
-        font-family: '{{ $document->font->getLabel() }}', sans-serif;
11
-    }
12
-</style>
13
-
14
-<x-company.document-template.container class="modern-template-container" preview>
1
+<x-company.document-template.container class="modern-template-container" :preview="$preview">
15
     <!-- Colored Header with Logo -->
2
     <!-- Colored Header with Logo -->
16
     <x-company.document-template.header class="bg-gray-800 h-24">
3
     <x-company.document-template.header class="bg-gray-800 h-24">
17
         <!-- Logo -->
4
         <!-- Logo -->
33
     <!-- Company Details -->
20
     <!-- Company Details -->
34
     <x-company.document-template.metadata class="modern-template-metadata space-y-8">
21
     <x-company.document-template.metadata class="modern-template-metadata space-y-8">
35
         <div class="text-sm">
22
         <div class="text-sm">
36
-            <h2 class="text-lg font-semibold">{{ $document->company->name }}</h2>
23
+            <strong class="text-sm block">{{ $document->company->name }}</strong>
37
             @if($formattedAddress = $document->company->getFormattedAddressHtml())
24
             @if($formattedAddress = $document->company->getFormattedAddressHtml())
38
                 {!! $formattedAddress !!}
25
                 {!! $formattedAddress !!}
39
             @endif
26
             @endif

+ 21
- 0
resources/views/filament/forms/components/document-preview.blade.php Visa fil

1
+@php
2
+    $data = $this->form->getRawState();
3
+    $document = \App\DTO\DocumentPreviewDTO::fromSettings($this->record, $data);
4
+    $template = $getTemplate();
5
+    $preview = $isPreview();
6
+@endphp
7
+
8
+{!! $document->getFontHtml() !!}
9
+
10
+<style>
11
+    .doc-template-paper {
12
+        font-family: '{{ $document->font->getLabel() }}', sans-serif;
13
+    }
14
+</style>
15
+
16
+<div {{ $attributes }}>
17
+    @include("filament.company.components.document-templates.{$template->value}", [
18
+        'document' => $document,
19
+        'preview' => $preview,
20
+    ])
21
+</div>

+ 3
- 2
resources/views/filament/infolists/components/document-preview.blade.php Visa fil

1
 @php
1
 @php
2
     $document = \App\DTO\DocumentDTO::fromModel($getRecord());
2
     $document = \App\DTO\DocumentDTO::fromModel($getRecord());
3
     $template = $getTemplate();
3
     $template = $getTemplate();
4
+    $preview = $isPreview();
4
 @endphp
5
 @endphp
5
 
6
 
6
 {!! $document->getFontHtml() !!}
7
 {!! $document->getFontHtml() !!}
12
 </style>
13
 </style>
13
 
14
 
14
 <div {{ $attributes }}>
15
 <div {{ $attributes }}>
15
-    @include("filament.infolists.components.document-templates.{$template->value}", [
16
+    @include("filament.company.components.document-templates.{$template->value}", [
16
         'document' => $document,
17
         'document' => $document,
17
-        'preview' => false,
18
+        'preview' => $preview,
18
     ])
19
     ])
19
 </div>
20
 </div>

+ 0
- 153
resources/views/filament/infolists/components/document-templates/classic.blade.php Visa fil

1
-<x-company.document-template.container class="classic-template-container">
2
-    <!-- Header Section -->
3
-    <x-company.document-template.header class="classic-template-header">
4
-        <div class="w-2/3 text-left">
5
-            <div class="text-sm">
6
-                <strong class="text-sm block">{{ $document->company->name }}</strong>
7
-                @if($formattedAddress = $document->company->getFormattedAddressHtml())
8
-                    {!! $formattedAddress !!}
9
-                @endif
10
-            </div>
11
-        </div>
12
-
13
-        <div class="w-1/3 flex justify-end">
14
-            @if($document->logo && $document->showLogo)
15
-                <x-company.document-template.logo :src="$document->logo"/>
16
-            @endif
17
-        </div>
18
-    </x-company.document-template.header>
19
-
20
-    <x-company.document-template.metadata class="classic-template-metadata space-y-4">
21
-        <div class="items-center flex">
22
-            <hr class="grow-[2] py-0.5 border-solid border-y-2" style="border-color: {{ $document->accentColor }};">
23
-            <x-icons.document-header-decoration
24
-                color="{{ $document->accentColor }}"
25
-                text="{{ $document->header }}"
26
-                class="w-60"
27
-            />
28
-            <hr class="grow-[2] py-0.5 border-solid border-y-2" style="border-color: {{ $document->accentColor }};">
29
-        </div>
30
-        @if ($document->subheader)
31
-            <p class="text-sm text-center text-gray-600">{{ $document->subheader }}</p>
32
-        @endif
33
-
34
-        <div class="flex justify-between items-end">
35
-            <!-- Billing Details -->
36
-            <div class="text-sm">
37
-                <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
38
-                <p class="text-sm font-bold">{{ $document->client->name }}</p>
39
-                @if($formattedAddress = $document->client->getFormattedAddressHtml())
40
-                    {!! $formattedAddress !!}
41
-                @endif
42
-            </div>
43
-
44
-            <div class="text-sm">
45
-                <table class="min-w-full">
46
-                    <tbody>
47
-                    <tr>
48
-                        <td class="font-semibold text-right pr-2">{{ $document->label->number }}:</td>
49
-                        <td class="text-left pl-2">{{ $document->number }}</td>
50
-                    </tr>
51
-                    @if($document->referenceNumber)
52
-                        <tr>
53
-                            <td class="font-semibold text-right pr-2">{{ $document->label->referenceNumber }}:</td>
54
-                            <td class="text-left pl-2">{{ $document->referenceNumber }}</td>
55
-                        </tr>
56
-                    @endif
57
-                    <tr>
58
-                        <td class="font-semibold text-right pr-2">{{ $document->label->date }}:</td>
59
-                        <td class="text-left pl-2">{{ $document->date }}</td>
60
-                    </tr>
61
-                    <tr>
62
-                        <td class="font-semibold text-right pr-2">{{ $document->label->dueDate }}:</td>
63
-                        <td class="text-left pl-2">{{ $document->dueDate }}</td>
64
-                    </tr>
65
-                    </tbody>
66
-                </table>
67
-            </div>
68
-        </div>
69
-    </x-company.document-template.metadata>
70
-
71
-    <!-- Line Items -->
72
-    <x-company.document-template.line-items class="classic-template-line-items px-6">
73
-        <table class="w-full text-left table-fixed">
74
-            <thead class="text-sm leading-relaxed">
75
-            <tr>
76
-                <th class="text-left w-[50%] py-4">{{ $document->columnLabel->items }}</th>
77
-                <th class="text-center w-[10%] py-4">{{ $document->columnLabel->units }}</th>
78
-                <th class="text-right w-[20%] py-4">{{ $document->columnLabel->price }}</th>
79
-                <th class="text-right w-[20%] py-4">{{ $document->columnLabel->amount }}</th>
80
-            </tr>
81
-            </thead>
82
-            <tbody class="text-sm border-y-2 border-dotted border-gray-300">
83
-            @foreach($document->lineItems as $item)
84
-                <tr>
85
-                    <td class="text-left font-semibold py-3">
86
-                        {{ $item->name }}
87
-                        @if($item->description)
88
-                            <div class="text-gray-600 font-normal line-clamp-2 mt-1">{{ $item->description }}</div>
89
-                        @endif
90
-                    </td>
91
-                    <td class="text-center py-3">{{ $item->quantity }}</td>
92
-                    <td class="text-right py-3">{{ $item->unitPrice }}</td>
93
-                    <td class="text-right py-3">{{ $item->subtotal }}</td>
94
-                </tr>
95
-            @endforeach
96
-            </tbody>
97
-        </table>
98
-
99
-        <!-- Financial Details and Notes -->
100
-        <div class="flex justify-between text-sm space-x-1 pt-4">
101
-            <!-- Notes Section -->
102
-            <div class="w-[60%] py-2">
103
-                <p class="font-semibold">{{ $document->footer }}</p>
104
-            </div>
105
-
106
-            <!-- Financial Summary -->
107
-            <div class="w-[40%]">
108
-                <table class="w-full table-fixed whitespace-nowrap">
109
-                    <tbody class="text-sm">
110
-                    @if($document->subtotal)
111
-                        <tr>
112
-                            <td class="text-right font-semibold py-2">Subtotal:</td>
113
-                            <td class="text-right py-2">{{ $document->subtotal }}</td>
114
-                        </tr>
115
-                    @endif
116
-                    @if($document->discount)
117
-                        <tr class="text-success-800">
118
-                            <td class="text-right py-2">Discount:</td>
119
-                            <td class="text-right py-2">
120
-                                ({{ $document->discount }})
121
-                            </td>
122
-                        </tr>
123
-                    @endif
124
-                    @if($document->tax)
125
-                        <tr>
126
-                            <td class="text-right py-2">Tax:</td>
127
-                            <td class="text-right py-2">{{ $document->tax }}</td>
128
-                        </tr>
129
-                    @endif
130
-                    <tr>
131
-                        <td class="text-right font-semibold border-t py-2">Total:</td>
132
-                        <td class="text-right border-t py-2">{{ $document->total }}</td>
133
-                    </tr>
134
-                    @if($document->amountDue)
135
-                        <tr>
136
-                            <td class="text-right font-semibold border-t-4 border-double py-2">{{ $document->label->amountDue }}
137
-                                ({{ $document->currencyCode }}):
138
-                            </td>
139
-                            <td class="text-right border-t-4 border-double py-2">{{ $document->amountDue }}</td>
140
-                        </tr>
141
-                    @endif
142
-                    </tbody>
143
-                </table>
144
-            </div>
145
-        </div>
146
-    </x-company.document-template.line-items>
147
-
148
-    <!-- Footer -->
149
-    <x-company.document-template.footer class="classic-template-footer min-h-48 p-6 text-sm">
150
-        <h4 class="font-semibold mb-2">Terms & Conditions</h4>
151
-        <p class="break-words line-clamp-4">{{ $document->terms }}</p>
152
-    </x-company.document-template.footer>
153
-</x-company.document-template.container>

+ 0
- 147
resources/views/filament/infolists/components/document-templates/default.blade.php Visa fil

1
-<x-company.document-template.container class="default-template-container">
2
-
3
-    <x-company.document-template.header class="default-template-header border-b">
4
-        <div class="w-1/3">
5
-            @if($document->logo && $document->showLogo)
6
-                <x-company.document-template.logo :src="$document->logo"/>
7
-            @endif
8
-        </div>
9
-
10
-        <div class="w-2/3 text-right">
11
-            <div class="space-y-4">
12
-                <div>
13
-                    <h1 class="text-3xl font-light uppercase">{{ $document->header }}</h1>
14
-                    @if ($document->subheader)
15
-                        <p class="text-sm text-gray-600">{{ $document->subheader }}</p>
16
-                    @endif
17
-                </div>
18
-                <div class="text-sm">
19
-                    <strong class="text-sm block">{{ $document->company->name }}</strong>
20
-                    @if($formattedAddress = $document->company->getFormattedAddressHtml())
21
-                        {!! $formattedAddress !!}
22
-                    @endif
23
-                </div>
24
-            </div>
25
-        </div>
26
-    </x-company.document-template.header>
27
-
28
-    <x-company.document-template.metadata class="default-template-metadata space-y-4">
29
-        <div class="flex justify-between items-end">
30
-            <!-- Billing Details -->
31
-            <div class="text-sm">
32
-                <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
33
-                <p class="text-sm font-bold">{{ $document->client->name }}</p>
34
-                @if($formattedAddress = $document->client->getFormattedAddressHtml())
35
-                    {!! $formattedAddress !!}
36
-                @endif
37
-            </div>
38
-
39
-            <div class="text-sm">
40
-                <table class="min-w-full">
41
-                    <tbody>
42
-                    <tr>
43
-                        <td class="font-semibold text-right pr-2">{{ $document->label->number }}:</td>
44
-                        <td class="text-left pl-2">{{ $document->number }}</td>
45
-                    </tr>
46
-                    @if($document->referenceNumber)
47
-                        <tr>
48
-                            <td class="font-semibold text-right pr-2">{{ $document->label->referenceNumber }}:</td>
49
-                            <td class="text-left pl-2">{{ $document->referenceNumber }}</td>
50
-                        </tr>
51
-                    @endif
52
-                    <tr>
53
-                        <td class="font-semibold text-right pr-2">{{ $document->label->date }}:</td>
54
-                        <td class="text-left pl-2">{{ $document->date }}</td>
55
-                    </tr>
56
-                    <tr>
57
-                        <td class="font-semibold text-right pr-2">{{ $document->label->dueDate }}:</td>
58
-                        <td class="text-left pl-2">{{ $document->dueDate }}</td>
59
-                    </tr>
60
-                    </tbody>
61
-                </table>
62
-            </div>
63
-        </div>
64
-    </x-company.document-template.metadata>
65
-
66
-    <!-- Line Items Table -->
67
-    <x-company.document-template.line-items class="default-template-line-items">
68
-        <table class="w-full text-left table-fixed">
69
-            <thead class="text-sm leading-relaxed" style="background: {{ $document->accentColor }}">
70
-            <tr class="text-white">
71
-                <th class="text-left pl-6 w-[50%] py-2">{{ $document->columnLabel->items }}</th>
72
-                <th class="text-center w-[10%] py-2">{{ $document->columnLabel->units }}</th>
73
-                <th class="text-right w-[20%] py-2">{{ $document->columnLabel->price }}</th>
74
-                <th class="text-right pr-6 w-[20%] py-2">{{ $document->columnLabel->amount }}</th>
75
-            </tr>
76
-            </thead>
77
-            <tbody class="text-sm border-b-2 border-gray-300">
78
-            @foreach($document->lineItems as $item)
79
-                <tr>
80
-                    <td class="text-left pl-6 font-semibold py-3">
81
-                        {{ $item->name }}
82
-                        @if($item->description)
83
-                            <div class="text-gray-600 font-normal line-clamp-2 mt-1">{{ $item->description }}</div>
84
-                        @endif
85
-                    </td>
86
-                    <td class="text-center py-3">{{ $item->quantity }}</td>
87
-                    <td class="text-right py-3">{{ $item->unitPrice }}</td>
88
-                    <td class="text-right pr-6 py-3">{{ $item->subtotal }}</td>
89
-                </tr>
90
-            @endforeach
91
-            </tbody>
92
-            <tfoot class="text-sm summary-section">
93
-            @if($document->subtotal)
94
-                <tr>
95
-                    <td class="pl-6 py-2" colspan="2"></td>
96
-                    <td class="text-right font-semibold py-2">Subtotal:</td>
97
-                    <td class="text-right pr-6 py-2">{{ $document->subtotal }}</td>
98
-                </tr>
99
-            @endif
100
-            @if($document->discount)
101
-                <tr class="text-success-800">
102
-                    <td class="pl-6 py-2" colspan="2"></td>
103
-                    <td class="text-right py-2">Discount:</td>
104
-                    <td class="text-right pr-6 py-2">
105
-                        ({{ $document->discount }})
106
-                    </td>
107
-                </tr>
108
-            @endif
109
-            @if($document->tax)
110
-                <tr>
111
-                    <td class="pl-6 py-2" colspan="2"></td>
112
-                    <td class="text-right py-2">Tax:</td>
113
-                    <td class="text-right pr-6 py-2">{{ $document->tax }}</td>
114
-                </tr>
115
-            @endif
116
-            <tr>
117
-                <td class="pl-6 py-2" colspan="2"></td>
118
-                <td class="text-right font-semibold border-t py-2">Total:</td>
119
-                <td class="text-right border-t pr-6 py-2">{{ $document->total }}</td>
120
-            </tr>
121
-            @if($document->amountDue)
122
-                <tr>
123
-                    <td class="pl-6 py-2" colspan="2"></td>
124
-                    <td class="text-right font-semibold border-t-4 border-double py-2">{{ $document->label->amountDue }}
125
-                        ({{ $document->currencyCode }}):
126
-                    </td>
127
-                    <td class="text-right border-t-4 border-double pr-6 py-2">{{ $document->amountDue }}</td>
128
-                </tr>
129
-            @endif
130
-            </tfoot>
131
-        </table>
132
-    </x-company.document-template.line-items>
133
-
134
-    <!-- Footer Notes -->
135
-    <x-company.document-template.footer class="classic-template-footer min-h-48 flex flex-col text-sm p-6">
136
-        <div>
137
-            <h4 class="font-semibold mb-2">Terms & Conditions</h4>
138
-            <p class="break-words line-clamp-4">{{ $document->terms }}</p>
139
-        </div>
140
-
141
-        @if($document->footer)
142
-            <div class="mt-auto text-center py-4">
143
-                <p class="font-semibold">{{ $document->footer }}</p>
144
-            </div>
145
-        @endif
146
-    </x-company.document-template.footer>
147
-</x-company.document-template.container>

+ 0
- 147
resources/views/filament/infolists/components/document-templates/modern.blade.php Visa fil

1
-<x-company.document-template.container class="modern-template-container">
2
-    <!-- Colored Header with Logo -->
3
-    <x-company.document-template.header class="bg-gray-800 h-24">
4
-        <!-- Logo -->
5
-        <div class="w-2/3">
6
-            @if($document->logo && $document->showLogo)
7
-                <x-company.document-template.logo class="ml-8" :src="$document->logo"/>
8
-            @endif
9
-        </div>
10
-
11
-        <!-- Ribbon Container -->
12
-        <div class="w-1/3 absolute right-0 top-0 p-3 h-32 flex flex-col justify-end rounded-bl-sm"
13
-             style="background: {{ $document->accentColor }};">
14
-            @if($document->header)
15
-                <h1 class="text-4xl font-bold text-white text-center uppercase">{{ $document->header }}</h1>
16
-            @endif
17
-        </div>
18
-    </x-company.document-template.header>
19
-
20
-    <!-- Company Details -->
21
-    <x-company.document-template.metadata class="modern-template-metadata space-y-8">
22
-        <div class="text-sm">
23
-            <h2 class="text-lg font-semibold">{{ $document->company->name }}</h2>
24
-            @if($formattedAddress = $document->company->getFormattedAddressHtml())
25
-                {!! $formattedAddress !!}
26
-            @endif
27
-        </div>
28
-
29
-        <div class="flex justify-between items-end">
30
-            <!-- Billing Details -->
31
-            <div class="text-sm">
32
-                <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
33
-                <p class="text-sm font-bold"
34
-                   style="color: {{ $document->accentColor }}">{{ $document->client->name }}</p>
35
-
36
-                @if($formattedAddress = $document->client->getFormattedAddressHtml())
37
-                    {!! $formattedAddress !!}
38
-                @endif
39
-            </div>
40
-
41
-            <div class="text-sm">
42
-                <table class="min-w-full">
43
-                    <tbody>
44
-                    <tr>
45
-                        <td class="font-semibold text-right pr-2">{{ $document->label->number }}:</td>
46
-                        <td class="text-left pl-2">{{ $document->number }}</td>
47
-                    </tr>
48
-                    @if($document->referenceNumber)
49
-                        <tr>
50
-                            <td class="font-semibold text-right pr-2">{{ $document->label->referenceNumber }}:</td>
51
-                            <td class="text-left pl-2">{{ $document->referenceNumber }}</td>
52
-                        </tr>
53
-                    @endif
54
-                    <tr>
55
-                        <td class="font-semibold text-right pr-2">{{ $document->label->date }}:</td>
56
-                        <td class="text-left pl-2">{{ $document->date }}</td>
57
-                    </tr>
58
-                    <tr>
59
-                        <td class="font-semibold text-right pr-2">{{ $document->label->dueDate }}:</td>
60
-                        <td class="text-left pl-2">{{ $document->dueDate }}</td>
61
-                    </tr>
62
-                    </tbody>
63
-                </table>
64
-            </div>
65
-        </div>
66
-    </x-company.document-template.metadata>
67
-
68
-    <!-- Line Items Table -->
69
-    <x-company.document-template.line-items class="modern-template-line-items">
70
-        <table class="w-full text-left table-fixed">
71
-            <thead class="text-sm leading-relaxed">
72
-            <tr class="text-gray-600">
73
-                <th class="text-left pl-6 w-[50%] py-4">{{ $document->columnLabel->items }}</th>
74
-                <th class="text-center w-[10%] py-4">{{ $document->columnLabel->units }}</th>
75
-                <th class="text-right w-[20%] py-4">{{ $document->columnLabel->price }}</th>
76
-                <th class="text-right pr-6 w-[20%] py-4">{{ $document->columnLabel->amount }}</th>
77
-            </tr>
78
-            </thead>
79
-            <tbody class="text-sm border-y-2">
80
-            @foreach($document->lineItems as $index => $item)
81
-                <tr @class(['bg-gray-100' => $index % 2 === 0])>
82
-                    <td class="text-left pl-6 font-semibold py-3">
83
-                        {{ $item->name }}
84
-                        @if($item->description)
85
-                            <div class="text-gray-600 font-normal line-clamp-2 mt-1">{{ $item->description }}</div>
86
-                        @endif
87
-                    </td>
88
-                    <td class="text-center py-3">{{ $item->quantity }}</td>
89
-                    <td class="text-right py-3">{{ $item->unitPrice }}</td>
90
-                    <td class="text-right pr-6 py-3">{{ $item->subtotal }}</td>
91
-                </tr>
92
-            @endforeach
93
-            </tbody>
94
-            <tfoot class="text-sm summary-section">
95
-            @if($document->subtotal)
96
-                <tr>
97
-                    <td class="pl-6 py-2" colspan="2"></td>
98
-                    <td class="text-right font-semibold py-2">Subtotal:</td>
99
-                    <td class="text-right pr-6 py-2">{{ $document->subtotal }}</td>
100
-                </tr>
101
-            @endif
102
-            @if($document->discount)
103
-                <tr class="text-success-800">
104
-                    <td class="pl-6 py-2" colspan="2"></td>
105
-                    <td class="text-right py-2">Discount:</td>
106
-                    <td class="text-right pr-6 py-2">
107
-                        ({{ $document->discount }})
108
-                    </td>
109
-                </tr>
110
-            @endif
111
-            @if($document->tax)
112
-                <tr>
113
-                    <td class="pl-6 py-2" colspan="2"></td>
114
-                    <td class="text-right py-2">Tax:</td>
115
-                    <td class="text-right pr-6 py-2">{{ $document->tax }}</td>
116
-                </tr>
117
-            @endif
118
-            <tr>
119
-                <td class="pl-6 py-2" colspan="2"></td>
120
-                <td class="text-right font-semibold border-t py-2">Total:</td>
121
-                <td class="text-right border-t pr-6 py-2">{{ $document->total }}</td>
122
-            </tr>
123
-            @if($document->amountDue)
124
-                <tr>
125
-                    <td class="pl-6 py-2" colspan="2"></td>
126
-                    <td class="text-right font-semibold border-t-4 border-double py-2">{{ $document->label->amountDue }}
127
-                        ({{ $document->currencyCode }}):
128
-                    </td>
129
-                    <td class="text-right border-t-4 border-double pr-6 py-2">{{ $document->amountDue }}</td>
130
-                </tr>
131
-            @endif
132
-            </tfoot>
133
-        </table>
134
-    </x-company.document-template.line-items>
135
-
136
-    <!-- Footer Notes -->
137
-    <x-company.document-template.footer class="modern-template-footer">
138
-        <h4 class="font-semibold px-6 text-sm" style="color: {{ $document->accentColor }}">
139
-            Terms & Conditions
140
-        </h4>
141
-        <span class="border-t-2 my-2 border-gray-300 block w-full"></span>
142
-        <div class="flex justify-between space-x-4 px-6 text-sm">
143
-            <p class="w-1/2 break-words line-clamp-4">{{ $document->terms }}</p>
144
-            <p class="w-1/2 break-words line-clamp-4">{{ $document->footer }}</p>
145
-        </div>
146
-    </x-company.document-template.footer>
147
-</x-company.document-template.container>

Laddar…
Avbryt
Spara