@extends('layouts.admin')
@section('title','Performa Teknisi')
@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="card">
  <div class="table-responsive">
    <table class="table table-hover mb-0">
      <thead><tr><th>Teknisi</th><th>Divisi</th><th class="text-center">Ditugaskan</th><th class="text-center">Diselesaikan</th><th class="text-center">% Selesai</th></tr></thead>
      <tbody>
      @forelse($technicians as $t)
      @php $pct = $t->tickets_assigned ? round($t->tickets_resolved/$t->tickets_assigned*100) : 0; @endphp
      <tr>
        <td><a href="{{ route('admin.users.show',$t) }}" class="fw-semibold text-decoration-none">{{ $t->name }}</a></td>
        <td><span class="badge bg-light text-dark border">{{ $t->division }}</span></td>
        <td class="text-center">{{ $t->tickets_assigned }}</td>
        <td class="text-center text-success">{{ $t->tickets_resolved }}</td>
        <td class="text-center">
          <div class="d-flex align-items-center gap-2">
            <div class="flex-1" style="background:#e5e7eb;border-radius:4px;height:8px;flex:1"><div style="background:{{ $pct>=80?'#10b981':($pct>=50?'#f59e0b':'#ef4444') }};height:100%;border-radius:4px;width:{{ $pct }}%"></div></div>
            <span class="small">{{ $pct }}%</span>
          </div>
        </td>
      </tr>
      @empty<tr><td colspan="5" class="text-center text-muted py-4">Tidak ada data</td></tr>
      @endforelse
      </tbody>
    </table>
  </div>
</div>
@endsection
