@extends('layouts.app')
@section('title', ($isNew?'New ':'Edit ').'Production Entry')
@section('crumbs', '<a href="'.route('production-entries.index').'">Daily Production</a> · <b>'.($isNew?'New':'Edit').'</b>')
@section('content')
<div class="card" style="max-width:980px"><div class="card-h"><h2>{{ $isNew?'New':'Edit' }} production entry</h2><div class="sp"><span class="bdg b-info">{{ $entryNo }}</span></div></div>
<div class="card-b"><form method="POST" action="{{ $isNew?route('production-entries.store'):route('production-entries.update',$record->id) }}">@csrf @if(!$isNew)@method('PUT')@endif
<div class="frow">
<div class="fld c3"><label>Date *</label><input type="date" name="entry_date" value="{{ old('entry_date',$record->entry_date?->format('Y-m-d')) }}" required></div>
<div class="fld c3"><label>Shift *</label><select name="shift"><option value="day" {{ $record->shift==='day'?'selected':'' }}>Day</option><option value="night" {{ $record->shift==='night'?'selected':'' }}>Night</option></select></div>
<div class="fld c3"><label>Quarry *</label><select name="quarry_id" required><option value="">—</option>@foreach($quarries as $q)<option value="{{ $q->id }}" {{ $record->quarry_id==$q->id?'selected':'' }}>{{ $q->name }}</option>@endforeach</select></div>
<div class="fld c3"><label>Crusher line *</label><select name="crusher_line_id" required><option value="">—</option>@foreach($lines as $l)<option value="{{ $l->id }}" {{ $record->crusher_line_id==$l->id?'selected':'' }}>{{ $l->code }} — {{ $l->name }}</option>@endforeach</select></div>
<div class="fld c6"><label>Product *</label><select name="product_id" required><option value="">—</option>@foreach($products as $p)<option value="{{ $p->id }}" {{ $record->product_id==$p->id?'selected':'' }}>{{ $p->display_name }}</option>@endforeach</select></div>
<div class="fld c3"><label>Produced (tonnes) *</label><input type="number" step="0.001" name="produced_tonnes" value="{{ old('produced_tonnes',$record->produced_tonnes) }}" required></div>
<div class="fld c3"><label>Operator</label><input type="text" name="operator_name" value="{{ old('operator_name',$record->operator_name) }}"></div>
<div class="fld c3"><label>Operating hrs</label><input type="number" step="0.01" name="operating_hours" value="{{ old('operating_hours',$record->operating_hours) }}"></div>
<div class="fld c3"><label>Downtime hrs</label><input type="number" step="0.01" name="downtime_hours" value="{{ old('downtime_hours',$record->downtime_hours) }}"></div>
<div class="fld c3"><label>Fuel used (L)</label><input type="number" step="0.001" name="fuel_used_litres" value="{{ old('fuel_used_litres',$record->fuel_used_litres) }}"></div>
<div class="fld c12"><label>Remarks</label><input type="text" name="remarks" value="{{ old('remarks',$record->remarks) }}"></div>
</div>
<button class="btn btn-pri">Save {{ $isNew?'draft':'changes' }}</button> <a class="btn btn-ghost" href="{{ route('production-entries.index') }}">Cancel</a>
</form></div></div>
@endsection
