@extends('admin.layouts.app')
@section('title','Service & Warranty')
@section('content')
<div class="page-head"><div><h1 class="page-title">Service & Warranty</h1><div class="page-subtitle">Warranty cards, claims, repair tickets and technician assignment</div></div></div>

<div class="grid-2">
<form method="POST" action="{{ route('admin.service.warranty.store') }}" class="card panel-tight grid-2">@csrf<h3 style="grid-column:1/-1;margin:0">Warranty Card</h3><div><label>Customer</label><select name="customer_id"><option value="">Select</option>@foreach($customers as $customer)<option value="{{ $customer->id }}">{{ $customer->name }}</option>@endforeach</select></div><div><label>Product</label><select name="product_id" required>@foreach($products as $product)<option value="{{ $product->id }}">{{ $product->product_name }}</option>@endforeach</select></div><div><label>Invoice No</label><input name="sale_invoice_no"></div><div><label>Serial No</label><input name="serial_no"></div><div><label>Warranty Months</label><input type="number" name="warranty_period_months" value="12"></div><div><label>Start Date</label><input type="date" name="start_date" value="{{ date('Y-m-d') }}"></div><div><label>Status</label><select name="status"><option>Active</option><option>Expired</option><option>Claimed</option></select></div><div style="grid-column:1/-1"><label>Notes</label><textarea name="notes"></textarea></div><div class="form-actions" style="grid-column:1/-1"><button class="btn primary">Create Warranty</button><a class="btn" href="{{ route('admin.service.warranty.check') }}">Warranty Check</a></div></form>
<form method="POST" action="{{ route('admin.service.claim.store') }}" class="card panel-tight grid-2">@csrf<h3 style="grid-column:1/-1;margin:0">Service Claim</h3><div><label>Customer</label><select name="customer_id"><option value="">Select</option>@foreach($customers as $customer)<option value="{{ $customer->id }}">{{ $customer->name }}</option>@endforeach</select></div><div><label>Warranty</label><select name="warranty_id"><option value="">Select</option>@foreach($warranties as $warranty)<option value="{{ $warranty->id }}">{{ $warranty->serial_no ?: 'Warranty #'.$warranty->id }}</option>@endforeach</select></div><div><label>Product</label><select name="product_id" required>@foreach($products as $product)<option value="{{ $product->id }}">{{ $product->product_name }}</option>@endforeach</select></div><div><label>Branch</label><select name="branch_id"><option value="">Select</option>@foreach($branches as $branch)<option value="{{ $branch->id }}">{{ $branch->name }}</option>@endforeach</select></div><div><label>Issue Title</label><input name="issue_title" required></div><div><label>Technician</label><input name="technician_name"></div><div><label>Status</label><select name="status"><option>Received</option><option>In Repair</option><option>Delivered</option><option>Replacement</option><option>Closed</option></select></div><div><label>Service Cost</label><input type="number" step="0.01" name="service_cost"></div><div><label>Received At</label><input type="datetime-local" name="received_at"></div><div><label>Delivered At</label><input type="datetime-local" name="delivered_at"></div><div style="grid-column:1/-1"><label>Issue Details</label><textarea name="issue_details"></textarea></div><div style="grid-column:1/-1"><label>Notes</label><textarea name="notes"></textarea></div><div class="form-actions" style="grid-column:1/-1"><button class="btn primary">Save Claim</button></div></form>
</div>
<div class="card panel-tight table-wrap"><h3>Service Claims</h3><table class="table"><thead><tr><th>Claim</th><th>Product ID</th><th>Technician</th><th>Status</th><th>Cost</th></tr></thead><tbody>@forelse($claims as $claim)<tr><td>{{ $claim->claim_no }}</td><td>{{ $claim->product_id }}</td><td>{{ $claim->technician_name ?: '—' }}</td><td>{{ $claim->status }}</td><td>{{ $claim->service_cost }}</td></tr>@empty<tr><td colspan="5">No claims found.</td></tr>@endforelse</tbody></table>{{ $claims->links() }}</div>

@endsection
