{{-- reports/tickets.blade.php --}}
@extends('layouts.admin')
@section('title','Laporan Tiket')
@section('content')
<div class="card mb-3">
  <div class="card-body py-2">
    <form class="row g-2" method="GET"><div class="col-md-3"><label class="form-label small">Dari</label><input type="date" name="from" class="form-control form-control-sm" value="{{ $from }}"></div><div class="col-md-3"><label class="form-label small">Sampai</label><input type="date" name="to" class="form-control form-control-sm" value="{{ $to }}"></div><div class="col-auto d-flex align-items-end"><button type="submit" class="btn btn-primary btn-sm">Filter</button></div></form>
  </div>
</div>
<div class="row g-3 mb-3">
  <div class="col-md-3"><div class="card p-3 text-center"><div class="text-muted small">Total Tiket</div><div class="fw-bold fs-3">{{ $data['total'] }}</div></div></div>
  <div class="col-md-3"><div class="card p-3 text-center"><div class="text-muted small">Diselesaikan</div><div class="fw-bold fs-3 text-success">{{ $data['resolved'] }}</div></div></div>
  <div class="col-md-3"><div class="card p-3 text-center"><div class="text-muted small">% Selesai</div><div class="fw-bold fs-3">{{ $data['total'] ? round($data['resolved']/$data['total']*100) : 0 }}%</div></div></div>
</div>
<div class="row g-3">
  <div class="col-md-6"><div class="card"><div class="card-header">Per Prioritas</div><div class="card-body">@foreach(['critical','high','medium','low'] as $p)<div class="d-flex justify-content-between py-1 border-bottom"><span class="small">{{ strtoupper($p) }}</span><span class="badge bg-secondary">{{ $data['by_priority'][$p]??0 }}</span></div>@endforeach</div></div></div>
  <div class="col-md-6"><div class="card"><div class="card-header">Per Divisi</div><div class="card-body">@foreach(['JPN','FixLab','Havva'] as $d)<div class="d-flex justify-content-between py-1 border-bottom"><span class="small">{{ $d }}</span><span class="badge bg-secondary">{{ $data['by_division'][$d]??0 }}</span></div>@endforeach</div></div></div>
  <div class="col-12"><div class="card"><div class="card-header">Per Teknisi</div><div class="table-responsive"><table class="table table-sm mb-0"><thead><tr><th>Teknisi</th><th>Ditugaskan</th><th>Diselesaikan</th><th>% Selesai</th></tr></thead><tbody>@forelse($data['by_technician'] as $r)<tr><td>{{ $r->assignedTo?->name ?? '—' }}</td><td>{{ $r->c }}</td><td>—</td><td>—</td></tr>@empty<tr><td colspan="4" class="text-center text-muted">Tidak ada data</td></tr>@endforelse</tbody></table></div></div></div>
</div>
@endsection
