149 lines
5.2 KiB
PHP
149 lines
5.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\Cooperations\RelationManagers;
|
|
|
|
use App\Enums\ApprovalStatus;
|
|
use App\Filament\Actions\Cheerful\CreateAction;
|
|
use App\Filament\Actions\Cheerful\DeleteAction;
|
|
use App\Filament\Actions\Cheerful\EditAction;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Forms\Components\DatePicker;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class TaskAssignmentRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'taskAssignments';
|
|
|
|
protected static ?string $title = 'Penugasan';
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
DatePicker::make('start_date')
|
|
->label('Tanggal Mulai')
|
|
->required()
|
|
->native(false)
|
|
->autocomplete(false)
|
|
->autofocus(),
|
|
|
|
DatePicker::make('end_date')
|
|
->label('Tanggal Selesai')
|
|
->required()
|
|
->native(false)
|
|
->after('start_date')
|
|
->autocomplete(false),
|
|
|
|
Textarea::make('task_description')
|
|
->label('Deskripsi Tugas')
|
|
->required()
|
|
->rows(4)
|
|
->maxLength(65535)
|
|
->autocomplete(false),
|
|
|
|
TextInput::make('report_amount')
|
|
->label('Jumlah Laporan')
|
|
->numeric()
|
|
->required()
|
|
->minValue(1)
|
|
->default(1)
|
|
->autocomplete(false),
|
|
|
|
Select::make('partner_media_ids')
|
|
->label('Media yang Ditugaskan')
|
|
->relationship('partnerMedia', 'name')
|
|
->multiple()
|
|
->preload()
|
|
->required()
|
|
->autocomplete(false),
|
|
|
|
Select::make('status')
|
|
->options(ApprovalStatus::options())
|
|
->required()
|
|
->default(ApprovalStatus::PENDING),
|
|
|
|
Textarea::make('rejection_reason')
|
|
->label('Alasan Penolakan')
|
|
->rows(3)
|
|
->columnSpanFull()
|
|
->autocomplete(false),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('task_description')
|
|
->columns([
|
|
TextColumn::make('start_date')
|
|
->label('Mulai')
|
|
->date('l, d F Y'),
|
|
|
|
TextColumn::make('end_date')
|
|
->label('Selesai')
|
|
->date('l, d F Y'),
|
|
|
|
TextColumn::make('task_description')
|
|
->label('Deskripsi Tugas')
|
|
->limit(50),
|
|
|
|
TextColumn::make('report_amount')
|
|
->label('Jumlah Laporan'),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->headerActions([
|
|
CreateAction::make()
|
|
->label('Buat Penugasan')
|
|
->visible(function (): bool {
|
|
$cooperation = $this->getOwnerRecord();
|
|
|
|
return $cooperation->proposals()->accepted()->exists();
|
|
})
|
|
->successNotification(
|
|
Notification::make()
|
|
->title('Penugasan Dibuat! 🚀✨')
|
|
->body('Tugas baru berhasil ditetapkan. Media terkait akan segera mengetahuinya! 💪')
|
|
->success()
|
|
),
|
|
])
|
|
->recordActions([
|
|
EditAction::make()
|
|
->successNotification(
|
|
Notification::make()
|
|
->title('Penugasan Diperbarui! ✅')
|
|
->body('Perubahan pada penugasan berhasil disimpan. 👍')
|
|
->success()
|
|
),
|
|
|
|
DeleteAction::make()
|
|
->successNotification(
|
|
Notification::make()
|
|
->title('Penugasan Dihapus! 🗑️')
|
|
->body('Penugasan telah berhasil dihapus dari sistem. 👋')
|
|
->success()
|
|
),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make()
|
|
->successNotification(
|
|
Notification::make()
|
|
->title('Banyak Penugasan Dihapus! 🗑️👋')
|
|
->body('Semua penugasan yang dipilih telah dihapus. 🧹')
|
|
->success()
|
|
),
|
|
]),
|
|
]);
|
|
}
|
|
}
|