@extends('layouts.app')
@section('title','Accounting Periods') @section('page_title','Accounting Periods')
@section('content')<div class="page-header"><div><h1>Fiscal Years & Period Locks</h1><p class="muted">Posted transactions cannot be entered into locked periods. Reopening requires special permission and a reason.</p></div></div>
@foreach($years as $year)<div class="card" style="margin-bottom:20px"><div class="card-header"><div><h3>{{ $year->name }}</h3><span class="muted">{{ $year->starts_on->format('d M Y') }} – {{ $year->ends_on->format('d M Y') }}</span></div><span class="badge">{{ ucfirst($year->status) }}</span></div><div class="table-wrap"><table><thead><tr><th>Period</th><th>Dates</th><th>Status</th><th>Locked By</th><th>Reason</th><th></th></tr></thead><tbody>@foreach($year->periods as $period)<tr><td><strong>{{ $period->name }}</strong></td><td>{{ $period->starts_on->format('d M Y') }} – {{ $period->ends_on->format('d M Y') }}</td><td><span class="badge {{ $period->is_locked?'badge-danger':'badge-success' }}">{{ $period->is_locked?'Locked':'Open' }}</span></td><td>{{ $period->lockedBy?->name ?? '—' }}</td><td>{{ $period->lock_reason ?: '—' }}</td><td class="text-right">@if($period->is_locked&&auth()->user()->hasPermission('periods.reopen'))<form class="inline-form" method="post" action="{{ route('periods.reopen',$period) }}">@csrf <input class="control control-sm" name="reason" placeholder="Reopen reason" required><button class="btn btn-warning btn-sm">Reopen</button></form>@elseif(!$period->is_locked&&auth()->user()->hasPermission('periods.manage'))<form class="inline-form" method="post" action="{{ route('periods.lock',$period) }}">@csrf <input class="control control-sm" name="reason" placeholder="Lock reason" required><button class="btn btn-danger btn-sm">Lock</button></form>@endif</td></tr>@endforeach</tbody></table></div></div>@endforeach
@endsection
