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.

ViewBill.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Filament\Company\Resources\Purchases\BillResource\Pages;
  3. use App\Filament\Company\Resources\Purchases\BillResource;
  4. use App\Filament\Company\Resources\Purchases\VendorResource;
  5. use App\Models\Accounting\Bill;
  6. use Filament\Actions;
  7. use Filament\Infolists\Components\Section;
  8. use Filament\Infolists\Components\TextEntry;
  9. use Filament\Infolists\Infolist;
  10. use Filament\Resources\Pages\ViewRecord;
  11. use Filament\Support\Enums\IconPosition;
  12. class ViewBill extends ViewRecord
  13. {
  14. protected static string $resource = BillResource::class;
  15. protected $listeners = [
  16. 'refresh' => '$refresh',
  17. ];
  18. protected function getHeaderActions(): array
  19. {
  20. return [
  21. Actions\EditAction::make()
  22. ->label('Edit bill')
  23. ->outlined(),
  24. Actions\ActionGroup::make([
  25. Actions\ActionGroup::make([
  26. Bill::getReplicateAction(),
  27. ])->dropdown(false),
  28. Actions\DeleteAction::make(),
  29. ])
  30. ->label('Actions')
  31. ->button()
  32. ->outlined()
  33. ->dropdownPlacement('bottom-end')
  34. ->icon('heroicon-m-chevron-down')
  35. ->iconPosition(IconPosition::After),
  36. ];
  37. }
  38. public function infolist(Infolist $infolist): Infolist
  39. {
  40. return $infolist
  41. ->schema([
  42. Section::make('Bill Details')
  43. ->columns(4)
  44. ->schema([
  45. TextEntry::make('bill_number')
  46. ->label('Invoice #'),
  47. TextEntry::make('status')
  48. ->badge(),
  49. TextEntry::make('vendor.name')
  50. ->label('Vendor')
  51. ->url(static fn (Bill $record) => $record->vendor_id ? VendorResource::getUrl('view', ['record' => $record->vendor_id]) : null)
  52. ->link(),
  53. TextEntry::make('total')
  54. ->label('Total')
  55. ->currency(static fn (Bill $record) => $record->currency_code),
  56. TextEntry::make('amount_due')
  57. ->label('Amount due')
  58. ->currency(static fn (Bill $record) => $record->currency_code),
  59. TextEntry::make('date')
  60. ->label('Date')
  61. ->date(),
  62. TextEntry::make('due_date')
  63. ->label('Due')
  64. ->asRelativeDay(),
  65. TextEntry::make('paid_at')
  66. ->label('Paid at')
  67. ->date(),
  68. ]),
  69. ]);
  70. }
  71. protected function getAllRelationManagers(): array
  72. {
  73. return [
  74. BillResource\RelationManagers\PaymentsRelationManager::class,
  75. ];
  76. }
  77. }