@extends('layouts.admin')
@section('title','Konfigurasi SLA')
@section('content')
<ul class="nav nav-tabs mb-3">
  <li class="nav-item"><a class="nav-link" href="{{ route('admin.settings.index') }}">Perusahaan</a></li>
  <li class="nav-item"><a class="nav-link active" href="{{ route('admin.settings.sla') }}">SLA Config</a></li>
  <li class="nav-item"><a class="nav-link" href="{{ route('admin.settings.activity') }}">Activity Log</a></li>
</ul>
<form action="{{ route('admin.settings.sla.update') }}" method="POST">@csrf
@foreach($configs as $cfg)
<div class="card mb-3">
  <div class="card-header d-flex justify-content-between align-items-center">
    <span class="fw-bold">{{ $cfg->name }} @if($cfg->is_default)<span class="badge bg-primary ms-1">Default</span>@endif</span>
    @if($cfg->client_id)<span class="text-muted small">Klien spesifik</span>@endif
  </div>
  <div class="card-body">
    <input type="hidden" name="configs[{{ $cfg->id }}][name]" value="{{ $cfg->name }}">
    <input type="hidden" name="configs[{{ $cfg->id }}][client_id]" value="{{ $cfg->client_id }}">
    <div class="table-responsive">
      <table class="table table-bordered table-sm">
        <thead class="table-light"><tr><th>Prioritas</th><th>Response Time (menit)</th><th>Solve Time (menit)</th></tr></thead>
        <tbody>
        @foreach(['critical','high','medium','low'] as $p)
        <tr>
          <td class="fw-semibold align-middle"><span class="badge bg-{{ ['critical'=>'danger','high'=>'warning','medium'=>'info','low'=>'secondary'][$p] }}">{{ strtoupper($p) }}</span></td>
          <td><input type="number" name="configs[{{ $cfg->id }}][{{ $p }}_response]" class="form-control form-control-sm" value="{{ $cfg->{$p.'_response'} }}" min="1" required></td>
          <td><input type="number" name="configs[{{ $cfg->id }}][{{ $p }}_solve]" class="form-control form-control-sm" value="{{ $cfg->{$p.'_solve'} }}" min="1" required></td>
        </tr>
        @endforeach
        </tbody>
      </table>
    </div>
  </div>
</div>
@endforeach
<div class="d-flex justify-content-end"><button type="submit" class="btn btn-primary"><i class="fas fa-save me-1"></i>Simpan SLA</button></div>
</form>
@endsection
