@php $exportYear = $selectedYear ?? (int) now()->format('Y'); $exportBranch = $selectedBranch ?? null; $exportFrom = $fromDate ?? request('from_date', \Carbon\Carbon::create($exportYear, 1, 1)->toDateString()); $exportTo = $toDate ?? request('to_date', now()->toDateString()); $canSummary = $canViewSummary ?? App\Support\MscPermissions::canViewSummary(auth()->user()); $userBranchId = auth()->user()->branch_id; $defaultBranch = $exportBranch ?: ($canViewAll ? null : $userBranchId); $exportService = app(App\Services\MscExportService::class); $monthsMatrix = $exportService->availableMonthsMatrix($exportYear); $defaultMonth = $defaultBranch ? ($exportService->defaultMonth((int) $defaultBranch, $exportYear) ?? (int) now()->format('n')) : (int) now()->format('n'); $availableMonths = $defaultBranch ? $exportService->availableMonths((int) $defaultBranch, $exportYear) : []; $monthNames = collect(range(1, 12)) ->mapWithKeys(fn ($m) => [$m => \Carbon\Carbon::create(null, $m, 1)->format('M')]) ->all(); $monthFullNames = collect(range(1, 12)) ->mapWithKeys(fn ($m) => [$m => \Carbon\Carbon::create(null, $m, 1)->format('F')]) ->all(); @endphp

Export MSC reports by month, by branch, or as a combined summary for a selected period. Downloads open in a new tab.

{{-- Monthly branch report --}}

Full MSC report for one branch and month (submitted reports only). @if($defaultBranch && $availableMonths) Available for {{ $exportYear }}: {{ collect($availableMonths)->map(fn ($m) => \Carbon\Carbon::create(null, $m, 1)->format('M'))->implode(', ') }}. @endif

{{-- Period: list / bundle --}}
@if($canViewAll)
@else @endif

PDF bundle includes every report in the date range. Excel lists key totals per report.

{{-- Annual summary --}}
@if($canViewAll)
@else @endif

Dashboard-style summary: KPIs, membership trend, branch comparison, and compliance.

{{-- Combined org-wide for period --}} @if($canSummary)
@if($canViewAll)
@else @endif

Org-wide totals at period end, with a per-branch breakdown (members, savings, share capital, loans).

@endif
@once @push('scripts') @endpush @endonce