@extends('layouts.admin')
@section('title','Edit WO '.$workorder->wo_number)
@section('content')
<div class="row justify-content-center"><div class="col-lg-8">
<div class="card">
  <div class="card-header">Edit Work Order {{ $workorder->wo_number }}</div>
  <div class="card-body">
    <form action="{{ route('admin.workorders.update',$workorder) }}" method="POST">
    @csrf @method('PUT')
    <div class="row g-3">
      <div class="col-md-6">
        <label class="form-label fw-semibold">Divisi</label>
        <input type="text" class="form-control" value="{{ $workorder->division }}" disabled>
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Tipe</label>
        <input type="text" class="form-control" value="{{ strtoupper($workorder->type) }}" disabled>
      </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 }}" {{ $workorder->assigned_to==$t->id?'selected':'' }}>{{ $t->name }}</option>
          @endforeach
        </select>
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Nama Item</label>
        <input type="text" class="form-control" value="{{ $workorder->item_name }}" disabled>
      </div>
      <div class="col-12">
        <label class="form-label fw-semibold">Diagnosa</label>
        <textarea name="diagnosis" class="form-control" rows="3">{{ $workorder->diagnosis }}</textarea>
      </div>
      <div class="col-12">
        <label class="form-label fw-semibold">Tindakan yang Dilakukan</label>
        <textarea name="action_taken" class="form-control" rows="3">{{ $workorder->action_taken }}</textarea>
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Estimasi Biaya (Rp)</label>
        <input type="number" name="estimated_cost" class="form-control" value="{{ $workorder->estimated_cost }}" min="0">
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Biaya Final (Rp)</label>
        <input type="number" name="final_cost" class="form-control" value="{{ $workorder->final_cost }}" min="0">
      </div>
      <div class="col-12">
        <label class="form-label fw-semibold">Catatan</label>
        <textarea name="notes" class="form-control" rows="2">{{ $workorder->notes }}</textarea>
      </div>
      <div class="col-12 d-flex gap-2 justify-content-end">
        <a href="{{ route('admin.workorders.show',$workorder) }}" class="btn btn-secondary">Batal</a>
        <button type="submit" class="btn btn-primary"><i class="fas fa-save me-1"></i>Simpan</button>
      </div>
    </div>
    </form>
  </div>
</div>
</div></div>
@endsection
