@props(['project','users'])
@php($items=\DB::table('project_risks_issues')->where('project_id',$project->id)->whereNotIn('status',['resolved','closed'])->latest()->get())
<div class="card mt-4"><div class="card-header"><h5 class="mb-0">Open risks &amp; issues</h5></div><div class="card-body"><form method="POST" action="{{ route('projects.risks-issues.store',$project) }}" class="row g-2 mb-3">@csrf<div class="col-md-2"><select class="form-select" name="type"><option value="risk">Risk</option><option value="issue">Issue</option></select></div><div class="col-md-3"><input class="form-control" name="title" placeholder="Title" required></div><div class="col-md-2"><select class="form-select" name="owner_id" required>@foreach($users as $user)<option value="{{ $user->id }}">{{ $user->name }}</option>@endforeach</select></div><div class="col-md-2"><select class="form-select" name="severity">@foreach(['low','medium','high','critical'] as $value)<option>{{ $value }}</option>@endforeach</select></div><div class="col-md-2"><select class="form-select" name="probability">@foreach(['low','medium','high'] as $value)<option>{{ $value }}</option>@endforeach</select></div><div class="col-md-1"><input class="form-control" type="date" name="due_date"></div><div class="col-12"><textarea class="form-control" name="mitigation" placeholder="Mitigation / corrective action"></textarea><input type="hidden" name="status" value="open"></div><div class="col-auto"><button class="btn btn-primary">Add</button></div></form><table class="table table-sm"><thead><tr><th>Type</th><th>Title</th><th>Severity</th><th>Probability</th><th>Due</th><th>Status</th></tr></thead><tbody>@forelse($items as $item)<tr><td>{{ ucfirst($item->type) }}</td><td>{{ $item->title }}<small class="d-block">{{ $item->mitigation }}</small></td><td>{{ ucfirst($item->severity) }}</td><td>{{ ucfirst($item->probability) }}</td><td>{{ $item->due_date }}</td><td>{{ ucfirst($item->status) }}</td></tr>@empty<tr><td colspan="6" class="text-muted">No open risks or issues.</td></tr>@endforelse</tbody></table></div></div>
