Introduce a complete workflow for managing shipment-related documents
and mandatory commitment forms between the Laravel backend and
WordPress frontend.
- Laravel:
- Add `ShipmentCommitmentForm` model and migration to track signed
forms per shipment.
- Implement `CommitmentFormController` to handle fetching available
forms and uploading signed documents.
- Add PDF download endpoints for AWB, labels, and invoices via
`ShipmentPdfController`.
- Extend `User` model with notification management methods.
- Add `FinanceOverviewWidget` for Filament dashboard.
- WordPress:
- Implement AJAX handlers in `user-bridge.php` for PDF downloads and
commitment form management.
- Update `shortcodes.php` to display document download grid and
dynamic commitment form upload interface in order details.
- Add styling for document buttons and form status indicators in
`ifnex-orders.css`.
56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Models\Shipment;
|
|
use App\Models\Wallet;
|
|
use App\Models\WalletTransaction;
|
|
use Filament\Widgets\StatsOverviewWidget;
|
|
use Filament\Widgets\StatsOverviewWidget\Stat;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class FinanceOverviewWidget extends StatsOverviewWidget
|
|
{
|
|
protected static ?string $pollingInterval = '30s';
|
|
|
|
protected function getStats(): array
|
|
{
|
|
$today = now()->startOfDay();
|
|
|
|
$totalRevenue = WalletTransaction::where('type', 'order_payment')
|
|
->where('status', 'completed')
|
|
->where('amount', '>', 0)
|
|
->sum('amount');
|
|
|
|
$todayRevenue = WalletTransaction::where('type', 'order_payment')
|
|
->where('status', 'completed')
|
|
->where('amount', '>', 0)
|
|
->where('created_at', '>=', $today)
|
|
->sum('amount');
|
|
|
|
$pendingPayments = Shipment::where('status', 'approved')->count();
|
|
$pendingAmount = Shipment::where('status', 'approved')->sum('total_fee');
|
|
|
|
$totalWalletBalance = Wallet::sum('balance');
|
|
|
|
return [
|
|
Stat::make('درآمد کل (تکمیل شده)', number_format($totalRevenue) . ' ریال')
|
|
->icon('heroicon-o-currency-dollar')
|
|
->color('success'),
|
|
|
|
Stat::make('درآمد امروز', number_format($todayRevenue) . ' ریال')
|
|
->icon('heroicon-o-chart-bar')
|
|
->color('info'),
|
|
|
|
Stat::make('پرداختهای در انتظار', $pendingPayments . ' سفارش')
|
|
->description(number_format($pendingAmount) . ' ریال')
|
|
->icon('heroicon-o-clock')
|
|
->color('warning'),
|
|
|
|
Stat::make('مجموع موجودی کیفپولها', number_format($totalWalletBalance) . ' ریال')
|
|
->icon('heroicon-o-wallet')
|
|
->color('gray'),
|
|
];
|
|
}
|
|
}
|