@extends('layouts.admin')
@section('title','Buat Work Order')
@section('content')
<div class="row justify-content-center"><div class="col-lg-8">
<div class="card">
  <div class="card-header">Form Work Order Baru</div>
  <div class="card-body">
    <form action="{{ route('admin.workorders.store') }}" method="POST" enctype="multipart/form-data">@csrf
    <div class="row g-3">
      <div class="col-md-6">
        <label class="form-label fw-semibold">Divisi *</label>
        <select name="division" class="form-select" required>
          <option value="FixLab">FixLab (Hardware Repair)</option>
          <option value="Havva">Havva (CCTV)</option>
        </select>
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Tipe *</label>
        <select name="type" class="form-select" required>
          <option value="repair">Perbaikan</option>
          <option value="installation">Pemasangan</option>
        </select>
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Klien (opsional)</label>
        <select name="client_id" class="form-select">
          <option value="">-- Perorangan / Tanpa Klien --</option>
          @foreach($clients as $c)<option value="{{ $c->id }}">{{ $c->name }}</option>@endforeach
        </select>
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Assign Teknisi</label>
        <select name="assigned_to" class="form-select">
          <option value="">-- Belum ditugaskan --</option>
          @foreach($technicians as $t)<option value="{{ $t->id }}">{{ $t->name }}</option>@endforeach
        </select>
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Nama Customer (jika perorangan)</label>
        <input type="text" name="customer_name" class="form-control" value="{{ old('customer_name') }}">
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">No. HP Customer</label>
        <input type="text" name="customer_phone" class="form-control" value="{{ old('customer_phone') }}">
      </div>
      <div class="col-md-4">
        <label class="form-label fw-semibold">Nama Item / Perangkat *</label>
        <input type="text" name="item_name" class="form-control" required value="{{ old('item_name') }}" placeholder="Laptop, CCTV DVR, dll">
      </div>
      <div class="col-md-4">
        <label class="form-label fw-semibold">Merk</label>
        <input type="text" name="item_brand" class="form-control" value="{{ old('item_brand') }}">
      </div>
      <div class="col-md-4">
        <label class="form-label fw-semibold">Serial Number</label>
        <input type="text" name="item_serial" class="form-control" value="{{ old('item_serial') }}">
      </div>
      <div class="col-12">
        <label class="form-label fw-semibold">Keluhan / Masalah *</label>
        <textarea name="reported_issue" class="form-control" rows="3" required>{{ old('reported_issue') }}</textarea>
      </div>
      <div class="col-12">
        <label class="form-label fw-semibold">Foto Kondisi Awal (bisa multiple)</label>
        <input type="file" name="photos[]" class="form-control" accept="image/*" multiple>
      </div>
      <div class="col-12">
        <label class="form-label fw-semibold">Catatan</label>
        <textarea name="notes" class="form-control" rows="2">{{ old('notes') }}</textarea>
      </div>
      <div class="col-12 d-flex gap-2 justify-content-end">
        <a href="{{ route('admin.workorders.index') }}" class="btn btn-secondary">Batal</a>
        <button type="submit" class="btn btn-primary"><i class="fas fa-save me-1"></i>Buat Work Order</button>
      </div>
    </div>
    </form>
  </div>
</div>
</div></div>
@endsection
