You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ViewClient.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace App\Filament\Company\Resources\Sales\ClientResource\Pages;
  3. use App\Filament\Company\Resources\Sales\ClientResource;
  4. use App\Filament\Company\Resources\Sales\ClientResource\RelationManagers;
  5. use App\Filament\Company\Resources\Sales\EstimateResource\Pages\CreateEstimate;
  6. use App\Filament\Company\Resources\Sales\InvoiceResource\Pages\CreateInvoice;
  7. use App\Filament\Company\Resources\Sales\RecurringInvoiceResource\Pages\CreateRecurringInvoice;
  8. use Filament\Actions\Action;
  9. use Filament\Actions\ActionGroup;
  10. use Filament\Actions\DeleteAction;
  11. use Filament\Actions\EditAction;
  12. use Filament\Infolists\Components\Section;
  13. use Filament\Infolists\Components\TextEntry;
  14. use Filament\Infolists\Infolist;
  15. use Filament\Resources\Pages\ViewRecord;
  16. use Filament\Support\Enums\IconPosition;
  17. use Filament\Support\Enums\IconSize;
  18. use Illuminate\Contracts\Support\Htmlable;
  19. class ViewClient extends ViewRecord
  20. {
  21. protected static string $resource = ClientResource::class;
  22. public function getRelationManagers(): array
  23. {
  24. return [
  25. RelationManagers\InvoicesRelationManager::class,
  26. RelationManagers\RecurringInvoicesRelationManager::class,
  27. RelationManagers\EstimatesRelationManager::class,
  28. ];
  29. }
  30. public function getTitle(): string | Htmlable
  31. {
  32. return $this->record->name;
  33. }
  34. protected function getHeaderActions(): array
  35. {
  36. return [
  37. EditAction::make()
  38. ->label('Edit Client')
  39. ->outlined(),
  40. ActionGroup::make([
  41. ActionGroup::make([
  42. Action::make('newInvoice')
  43. ->label('New Invoice')
  44. ->icon('heroicon-m-document-plus')
  45. ->url(CreateInvoice::getUrl(['client' => $this->record->getKey()])),
  46. Action::make('newEstimate')
  47. ->label('New Estimate')
  48. ->icon('heroicon-m-document-duplicate')
  49. ->url(CreateEstimate::getUrl(['client' => $this->record->getKey()])),
  50. Action::make('newRecurringInvoice')
  51. ->label('New Recurring Invoice')
  52. ->icon('heroicon-m-arrow-path')
  53. ->url(CreateRecurringInvoice::getUrl(['client' => $this->record->getKey()])),
  54. ])->dropdown(false),
  55. DeleteAction::make(),
  56. ])
  57. ->label('Actions')
  58. ->button()
  59. ->outlined()
  60. ->dropdownPlacement('bottom-end')
  61. ->icon('heroicon-c-chevron-down')
  62. ->iconSize(IconSize::Small)
  63. ->iconPosition(IconPosition::After),
  64. ];
  65. }
  66. protected function getHeaderWidgets(): array
  67. {
  68. return [
  69. ClientResource\Widgets\InvoiceOverview::class,
  70. ];
  71. }
  72. public function infolist(Infolist $infolist): Infolist
  73. {
  74. return $infolist
  75. ->schema([
  76. Section::make('General')
  77. ->columns()
  78. ->schema([
  79. TextEntry::make('primaryContact.full_name')
  80. ->label('Primary Contact'),
  81. TextEntry::make('primaryContact.email')
  82. ->label('Primary Email'),
  83. TextEntry::make('primaryContact.first_available_phone')
  84. ->label('Primary Phone'),
  85. TextEntry::make('website')
  86. ->label('Website')
  87. ->url(static fn ($state) => $state, true),
  88. ]),
  89. Section::make('Additional Details')
  90. ->columns()
  91. ->schema([
  92. TextEntry::make('billingAddress.address_string')
  93. ->label('Billing Address')
  94. ->listWithLineBreaks(),
  95. TextEntry::make('shippingAddress.address_string')
  96. ->label('Shipping Address')
  97. ->listWithLineBreaks(),
  98. TextEntry::make('notes')
  99. ->label('Delivery Instructions'),
  100. ]),
  101. ]);
  102. }
  103. }