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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 Illuminate\Contracts\Support\Htmlable;
  18. class ViewClient extends ViewRecord
  19. {
  20. protected static string $resource = ClientResource::class;
  21. protected function getAllRelationManagers(): array
  22. {
  23. return [
  24. RelationManagers\InvoicesRelationManager::class,
  25. RelationManagers\RecurringInvoicesRelationManager::class,
  26. RelationManagers\EstimatesRelationManager::class,
  27. ];
  28. }
  29. public function getTitle(): string | Htmlable
  30. {
  31. return $this->record->name;
  32. }
  33. protected function getHeaderActions(): array
  34. {
  35. return [
  36. EditAction::make()
  37. ->label('Edit client')
  38. ->outlined(),
  39. ActionGroup::make([
  40. ActionGroup::make([
  41. Action::make('newInvoice')
  42. ->label('New invoice')
  43. ->icon('heroicon-m-document-plus')
  44. ->url(CreateInvoice::getUrl(['client' => $this->record->getKey()])),
  45. Action::make('newEstimate')
  46. ->label('New estimate')
  47. ->icon('heroicon-m-document-duplicate')
  48. ->url(CreateEstimate::getUrl(['client' => $this->record->getKey()])),
  49. Action::make('newRecurringInvoice')
  50. ->label('New recurring invoice')
  51. ->icon('heroicon-m-arrow-path')
  52. ->url(CreateRecurringInvoice::getUrl(['client' => $this->record->getKey()])),
  53. ])->dropdown(false),
  54. DeleteAction::make(),
  55. ])
  56. ->label('Actions')
  57. ->button()
  58. ->outlined()
  59. ->dropdownPlacement('bottom-end')
  60. ->icon('heroicon-m-chevron-down')
  61. ->iconPosition(IconPosition::After),
  62. ];
  63. }
  64. protected function getHeaderWidgets(): array
  65. {
  66. return [
  67. ClientResource\Widgets\InvoiceOverview::class,
  68. ];
  69. }
  70. public function infolist(Infolist $infolist): Infolist
  71. {
  72. return $infolist
  73. ->schema([
  74. Section::make('General')
  75. ->columns()
  76. ->schema([
  77. TextEntry::make('primaryContact.full_name')
  78. ->label('Primary contact'),
  79. TextEntry::make('primaryContact.email')
  80. ->label('Primary email'),
  81. TextEntry::make('primaryContact.first_available_phone')
  82. ->label('Primary phone'),
  83. TextEntry::make('website')
  84. ->label('Website')
  85. ->url(static fn ($state) => $state, true),
  86. ]),
  87. Section::make('Additional Details')
  88. ->columns()
  89. ->schema([
  90. TextEntry::make('billingAddress.address_string')
  91. ->label('Billing address')
  92. ->listWithLineBreaks(),
  93. TextEntry::make('shippingAddress.address_string')
  94. ->label('Shipping address')
  95. ->listWithLineBreaks(),
  96. TextEntry::make('notes')
  97. ->label('Delivery instructions'),
  98. ]),
  99. ]);
  100. }
  101. }