|
@@ -5,6 +5,7 @@ namespace App\Filament\Company\Resources\Sales\EstimateResource\Pages;
|
5
|
5
|
use App\Enums\Accounting\DocumentType;
|
6
|
6
|
use App\Filament\Company\Resources\Sales\ClientResource;
|
7
|
7
|
use App\Filament\Company\Resources\Sales\EstimateResource;
|
|
8
|
+use App\Filament\Infolists\Components\BannerEntry;
|
8
|
9
|
use App\Filament\Infolists\Components\DocumentPreview;
|
9
|
10
|
use App\Models\Accounting\Estimate;
|
10
|
11
|
use Filament\Actions;
|
|
@@ -17,6 +18,7 @@ use Filament\Support\Enums\FontWeight;
|
17
|
18
|
use Filament\Support\Enums\IconPosition;
|
18
|
19
|
use Filament\Support\Enums\IconSize;
|
19
|
20
|
use Filament\Support\Enums\MaxWidth;
|
|
21
|
+use Illuminate\Support\HtmlString;
|
20
|
22
|
|
21
|
23
|
class ViewEstimate extends ViewRecord
|
22
|
24
|
{
|
|
@@ -63,6 +65,31 @@ class ViewEstimate extends ViewRecord
|
63
|
65
|
{
|
64
|
66
|
return $infolist
|
65
|
67
|
->schema([
|
|
68
|
+ BannerEntry::make('inactiveAdjustments')
|
|
69
|
+ ->label('Inactive adjustments')
|
|
70
|
+ ->warning()
|
|
71
|
+ ->icon('heroicon-o-exclamation-triangle')
|
|
72
|
+ ->visible(fn (Estimate $record) => $record->hasInactiveAdjustments() && $record->canBeApproved())
|
|
73
|
+ ->columnSpanFull()
|
|
74
|
+ ->description(function (Estimate $record) {
|
|
75
|
+ $inactiveAdjustments = collect();
|
|
76
|
+
|
|
77
|
+ foreach ($record->lineItems as $lineItem) {
|
|
78
|
+ foreach ($lineItem->adjustments as $adjustment) {
|
|
79
|
+ if ($adjustment->isInactive() && $inactiveAdjustments->doesntContain($adjustment->name)) {
|
|
80
|
+ $inactiveAdjustments->push($adjustment->name);
|
|
81
|
+ }
|
|
82
|
+ }
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ $adjustmentsList = $inactiveAdjustments->map(static function ($name) {
|
|
86
|
+ return "<span class='font-medium'>{$name}</span>";
|
|
87
|
+ })->join(', ');
|
|
88
|
+
|
|
89
|
+ $output = "<p class='text-sm'>This estimate contains inactive adjustments that need to be addressed before approval: {$adjustmentsList}</p>";
|
|
90
|
+
|
|
91
|
+ return new HtmlString($output);
|
|
92
|
+ }),
|
66
|
93
|
Section::make('Estimate Details')
|
67
|
94
|
->columns(4)
|
68
|
95
|
->schema([
|