Introduce a comprehensive design system across WordPress and Laravel to ensure visual consistency. Implement new financial reporting capabilities and Excel export functionality within the Filament admin panel. - Add `DESIGN_SYSTEM.md` to define brand colors, typography, and spacing - Implement `FinancialReport` page in Filament for transaction and shipment summaries - Add Excel export support for `ShipmentResource` and `WalletTransactionResource` using Laravel Excel - Refactor WordPress plugin and Filament CSS to utilize the new design system variables - Update project status to reflect new reporting and design milestones
100 lines
2.9 KiB
PHP
100 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use App\Models\WalletTransaction;
|
|
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
use Maatwebsite\Excel\Concerns\WithStyles;
|
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class WalletTransactionsExport implements FromQuery, WithHeadings, WithMapping, WithStyles, ShouldAutoSize
|
|
{
|
|
protected $filters;
|
|
|
|
public function __construct(array $filters = [])
|
|
{
|
|
$this->filters = $filters;
|
|
}
|
|
|
|
public function query()
|
|
{
|
|
$query = WalletTransaction::query()
|
|
->with(['wallet.user', 'creator', 'approver'])
|
|
->orderByDesc('created_at');
|
|
|
|
if (!empty($this->filters['type'])) {
|
|
$query->where('type', $this->filters['type']);
|
|
}
|
|
|
|
if (!empty($this->filters['status'])) {
|
|
$query->where('status', $this->filters['status']);
|
|
}
|
|
|
|
if (!empty($this->filters['gateway'])) {
|
|
$query->where('gateway', $this->filters['gateway']);
|
|
}
|
|
|
|
if (!empty($this->filters['from_date'])) {
|
|
$query->where('created_at', '>=', $this->filters['from_date']);
|
|
}
|
|
|
|
if (!empty($this->filters['to_date'])) {
|
|
$query->where('created_at', '<=', $this->filters['to_date']);
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'شناسه',
|
|
'کاربر',
|
|
'ایمیل',
|
|
'مبلغ (ریال)',
|
|
'نوع',
|
|
'وضعیت',
|
|
'درگاه',
|
|
'کد پیگیری',
|
|
'توضیحات',
|
|
'یادداشت ادمین',
|
|
'موجودی قبل',
|
|
'موجودی بعد',
|
|
'تاریخ ایجاد',
|
|
'تایید کننده',
|
|
];
|
|
}
|
|
|
|
public function map($transaction): array
|
|
{
|
|
return [
|
|
$transaction->id,
|
|
$transaction->wallet->user->name ?? 'نامشخص',
|
|
$transaction->wallet->user->email ?? 'نامشخص',
|
|
$transaction->amount,
|
|
$transaction->type->label(),
|
|
$transaction->status->label(),
|
|
$transaction->gateway?->label() ?? '-',
|
|
$transaction->gateway_reference_id ?? '-',
|
|
$transaction->description ?? '-',
|
|
$transaction->admin_notes ?? '-',
|
|
$transaction->balance_before ?? 0,
|
|
$transaction->balance_after ?? 0,
|
|
$transaction->created_at?->format('Y/m/d H:i'),
|
|
$transaction->approver?->name ?? '-',
|
|
];
|
|
}
|
|
|
|
public function styles(Worksheet $sheet)
|
|
{
|
|
return [
|
|
// First row as bold text.
|
|
1 => ['font' => ['bold' => true, 'size' => 12]],
|
|
];
|
|
}
|
|
}
|