Home: - Empty state: 2-column with 'How it works' 5-step guide - Has data: 7/5 grid — pledges left, education right - Right column: status breakdown, sources, 'What to do next' contextual links, 'What the statuses mean' guide Money: - 8/4 two-column layout: table left, education right - Right column: 'How matching works' 4-step guide, status explainer, collection tips, quick action buttons - No more wasted right margin Reports: - 7/5 two-column layout: downloads left, education right - Right column: 'For your treasurer' 3-step guide, Gift Aid FAQ, 'Understanding your numbers' explainer - Activity log moved to right column Settings: - Removed max-w-2xl constraint, now uses full width - 7/5 two-column: checklist left, education right - Right column: 'What you're setting up' (5 items with Required badges), Privacy & data assurance, Common questions FAQ, 'Need help?' CTA - Every setting explained in human language
142 lines
5.7 KiB
Python
142 lines
5.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Redesign the ScheduledGivingDonationResource table columns.
|
|
Replace the old columns with campaign-aware, care-focused columns.
|
|
"""
|
|
import os
|
|
|
|
BASE = '/home/forge/app.charityright.org.uk'
|
|
path = os.path.join(BASE, 'app/Filament/Resources/ScheduledGivingDonationResource.php')
|
|
|
|
with open(path, 'r') as f:
|
|
c = f.read()
|
|
|
|
old_columns = """ ->columns([
|
|
IconColumn::make('donationConfirmation.confirmed_at')
|
|
->label('Confirmed ?')
|
|
->searchable()
|
|
->boolean(),
|
|
|
|
TextColumn::make('total_amount')
|
|
->label('Total')
|
|
->numeric()
|
|
->money('gbp')
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
TextColumn::make('amount_admin')
|
|
->label('Admin')
|
|
->numeric()
|
|
->money('gbp')
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
TextColumn::make('customer.name')
|
|
->label('Customer')
|
|
->description(fn (ScheduledGivingDonation $donation) => $donation->customer?->email)
|
|
->sortable()
|
|
->searchable(true, function (Builder $query, string $search) {
|
|
$query
|
|
->whereHas('customer', function (Builder $query) use ($search) {
|
|
$query
|
|
->where('first_name', 'like', "%{$search}%")
|
|
->orWhere('last_name', 'like', "%{$search}%")
|
|
->orWhere('email', 'like', "%{$search}%");
|
|
});
|
|
}),
|
|
|
|
TextColumn::make('provider_reference')
|
|
->searchable()
|
|
->label('Provider Reference'),
|
|
|
|
TextColumn::make('appeal.name')
|
|
->numeric()
|
|
->toggleable(isToggledHiddenByDefault: true)
|
|
->sortable(),
|
|
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
|
|
TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])"""
|
|
|
|
new_columns = """ ->columns([
|
|
IconColumn::make('is_active')
|
|
->label('')
|
|
->boolean()
|
|
->trueIcon('heroicon-o-check-circle')
|
|
->falseIcon('heroicon-o-x-circle')
|
|
->trueColor('success')
|
|
->falseColor('danger')
|
|
->tooltip(fn (ScheduledGivingDonation $r) => $r->is_active ? 'Active' : 'Cancelled'),
|
|
|
|
TextColumn::make('customer.name')
|
|
->label('Donor')
|
|
->description(fn (ScheduledGivingDonation $d) => $d->customer?->email)
|
|
->sortable()
|
|
->searchable(query: function (Builder $query, string $search) {
|
|
$query->whereHas('customer', fn (Builder $q) => $q
|
|
->where('first_name', 'like', "%{$search}%")
|
|
->orWhere('last_name', 'like', "%{$search}%")
|
|
->orWhere('email', 'like', "%{$search}%"));
|
|
}),
|
|
|
|
TextColumn::make('scheduledGivingCampaign.title')
|
|
->label('Campaign')
|
|
->badge()
|
|
->color(fn ($state) => match ($state) {
|
|
'30 Nights of Giving' => 'primary',
|
|
'10 Days of Giving' => 'success',
|
|
'Night of Power' => 'warning',
|
|
default => 'gray',
|
|
}),
|
|
|
|
TextColumn::make('total_amount')
|
|
->label('Per Night')
|
|
->money('gbp', divideBy: 100)
|
|
->sortable(),
|
|
|
|
TextColumn::make('payments_count')
|
|
->label('Progress')
|
|
->counts('payments')
|
|
->formatStateUsing(function ($state, ScheduledGivingDonation $record) {
|
|
$paid = $record->payments()->where('is_paid', true)->count();
|
|
$total = $state;
|
|
if ($total === 0) return 'No payments';
|
|
$pct = round($paid / $total * 100);
|
|
return "{$paid}/{$total} ({$pct}%)";
|
|
})
|
|
->color(function (ScheduledGivingDonation $record) {
|
|
$total = $record->payments()->count();
|
|
if ($total === 0) return 'gray';
|
|
$paid = $record->payments()->where('is_paid', true)->count();
|
|
$pct = $paid / $total * 100;
|
|
return $pct >= 80 ? 'success' : ($pct >= 40 ? 'warning' : 'danger');
|
|
})
|
|
->badge(),
|
|
|
|
TextColumn::make('created_at')
|
|
->label('Signed Up')
|
|
->date('d M Y')
|
|
->description(fn (ScheduledGivingDonation $d) => $d->created_at?->diffForHumans())
|
|
->sortable(),
|
|
|
|
TextColumn::make('reference_code')
|
|
->label('Ref')
|
|
->searchable()
|
|
->fontFamily('mono')
|
|
->copyable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])"""
|
|
|
|
c = c.replace(old_columns, new_columns)
|
|
|
|
with open(path, 'w') as f:
|
|
f.write(c)
|
|
print('Table columns updated')
|