@extends('layouts.app')
@section('title', ($isNew?'New ':'Edit ').'Client IPC')
@section('crumbs', '<a href="'.route('client-ipcs.index').'">Client IPCs</a> · <b>'.($isNew?'New':'Edit').'</b>')
@section('content')
<div class="card" style="max-width:860px"><div class="card-h"><h2>{{ $isNew?'New':'Edit' }} interim payment certificate</h2><div class="sp"><span class="bdg b-info">{{ $docNo }}</span></div></div>
<div class="card-b"><form method="POST" action="{{ $isNew?route('client-ipcs.store'):route('client-ipcs.update',$record->id) }}">@csrf @if(!$isNew)@method('PUT')@endif
<div class="frow">
<div class="fld c6"><label>Project *</label><select name="project_id" required><option value="">—</option>@foreach($projects as $p)<option value="{{ $p->id }}" {{ $record->project_id==$p->id?'selected':'' }}>{{ $p->display_name }}</option>@endforeach</select></div>
<div class="fld c3"><label>IPC date *</label><input type="date" name="ipc_date" value="{{ old('ipc_date',$record->ipc_date?->format('Y-m-d') ?? date('Y-m-d')) }}" required></div>
<div class="fld c3"><label>Gross valuation *</label><input type="number" step="0.01" name="gross_valuation" value="{{ old('gross_valuation',$record->gross_valuation) }}" required></div>
<div class="fld c3"><label>Period from</label><input type="date" name="period_from" value="{{ old('period_from',$record->period_from?->format('Y-m-d')) }}"></div>
<div class="fld c3"><label>Period to</label><input type="date" name="period_to" value="{{ old('period_to',$record->period_to?->format('Y-m-d')) }}"></div>
<div class="fld c3"><label>Advance repayment</label><input type="number" step="0.01" name="advance_repayment" value="{{ old('advance_repayment',$record->advance_repayment ?? 0) }}"></div>
<div class="fld c3"><label>WHT (blank = auto 7.5%)</label><input type="number" step="0.01" name="tax_withheld" value="{{ old('tax_withheld',$record->tax_withheld) }}"></div>
<div class="fld c12"><label>Remarks</label><input type="text" name="remarks" value="{{ old('remarks',$record->remarks) }}"></div>
</div>
<p class="muted small">On certification, a draft sales invoice is raised to the project client automatically.</p>
<button class="btn btn-pri">Submit IPC</button> <a class="btn btn-ghost" href="{{ route('client-ipcs.index') }}">Cancel</a>
</form></div></div>
@endsection
