simedkom/app/Filament/Resources/Manage/Cooperations/RelationManagers/CooperationProposalRelationManager.php
Yoga Pangestu ab318a030b feat(notification): enhance user notifications for cooperation and verification processes
- Added detailed notifications for users and admins upon acceptance, rejection, and submission of proposals, verifications, and reports.
- Improved user experience with personalized messages and actionable links in notifications.
- Refactored notification logic across various actions to ensure consistent messaging and clarity.
- Introduced new notification titles and bodies to better reflect the status of actions taken.
2026-01-13 15:53:07 +07:00

127 lines
4.6 KiB
PHP

<?php
namespace App\Filament\Resources\Manage\Cooperations\RelationManagers;
use App\Enums\ApprovalStatus;
use App\Filament\Resources\Manage\Cooperations\Actions\Proposal\AcceptAction;
use App\Filament\Resources\Manage\Cooperations\Actions\Proposal\RejectAction;
use App\Models\CooperationProposal;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\ViewAction;
use Filament\Infolists\Components\TextEntry;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Joaopaulolndev\FilamentPdfViewer\Infolists\Components\PdfViewerEntry;
class CooperationProposalRelationManager extends RelationManager
{
protected static string $relationship = 'proposals';
protected static ?string $title = 'Proposal';
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('e_catalog')
->columns([
TextColumn::make('partnerMedia.name')
->label('Media')
->searchable()
->visible(! auth()->user()->hasRole('Perusahaan')),
TextColumn::make('e_catalog')
->label('E-Catalog')
->url(fn (CooperationProposal $record): ?string => $record->e_catalog)
->openUrlInNewTab()
->color('primary'),
TextColumn::make('description')
->label('Deskripsi'),
TextColumn::make('status')
->label('Status')
->badge(),
TextColumn::make('submitted_at')
->label('Diajukan')
->dateTime('l, d F Y H:i:s')
->sortable(),
TextColumn::make('responded_at')
->label('Ditanggapi')
->dateTime('l, d F Y H:i:s')
->sortable(),
TextColumn::make('rejectionReasons.reason')
->label('Alasan Penolakan')
->searchable(),
])
->filters([])
->headerActions([])
->recordActions([
ViewAction::make(),
AcceptAction::make('accept'),
RejectAction::make('reject'),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
public function infolist(Schema $infolist): Schema
{
return $infolist
->components([
Grid::make(2)
->schema([
TextEntry::make('partnerMedia.name')
->label('Media')
->visible(! auth()->user()->hasRole('Perusahaan')),
TextEntry::make('status')
->label('Status')
->badge(),
TextEntry::make('submitted_at')
->label('Diajukan')
->dateTime('l, d F Y H:i:s'),
TextEntry::make('responded_at')
->label('Ditanggapi')
->dateTime('l, d F Y H:i:s'),
]),
TextEntry::make('e_catalog')
->label('E-Catalog')
->url(fn (CooperationProposal $record): ?string => $record->e_catalog)
->openUrlInNewTab()
->color('primary')
->visible(fn (CooperationProposal $record): ?string => $record->e_catalog),
TextEntry::make('description')
->label('Deskripsi')
->columnSpanFull(),
PdfViewerEntry::make('proposal_attachment')
->label('Lampiran Proposal')
->getStateUsing(fn (CooperationProposal $record): ?string => optional($record->getMedia('cooperations')->where('custom_properties.doc_type', 'proposal-attachment')->sortByDesc('created_at')->first())->getPathRelativeToRoot())
->disk(config('filesystems.default')),
TextEntry::make('rejectionReasons.reason')
->label('Alasan Penolakan')
->listWithLineBreaks()
->visible(fn (CooperationProposal $record): bool => $record->status === ApprovalStatus::REJECTED && $record->rejectionReasons->isNotEmpty())
->columnSpanFull(),
])
->columns(1);
}
}