@php($line = $line ?? null)
@extends('layouts.app')
@section('title', __('nav.lines'))
@section('content')
<h1 class="h4 mb-3">{{ $line ? __('messages.edit') : __('messages.create') }}</h1>
<form method="post" action="{{ $line ? route('lines.update',$line) : route('lines.store') }}" class="card card-body">
@csrf @if($line)@method('PUT')@endif
<div class="row g-3">
<div class="col-md-4"><label class="form-label">{{ __('messages.phone') }}</label><input class="form-control" name="phone_number" value="{{ old('phone_number', $line?->phone_number) }}" required></div>
<div class="col-md-4"><label class="form-label">{{ __('messages.iccid') }}</label><input class="form-control" name="iccid" value="{{ old('iccid', $line?->iccid) }}"></div>
<div class="col-md-4"><label class="form-label">{{ __('messages.sim_serial') }}</label><input class="form-control" name="sim_serial" value="{{ old('sim_serial', $line?->sim_serial) }}"></div>
<div class="col-md-4"><label class="form-label">{{ __('messages.company') }}</label><select class="form-select" name="telecom_company_id" required>@foreach($companies as $c)<option value="{{ $c->id }}" @selected((string) old('telecom_company_id', $line?->telecom_company_id) === (string) $c->id)>{{ $c->name }}</option>@endforeach</select></div>
<div class="col-md-4"><label class="form-label">{{ __('messages.sim_type') }}</label><select class="form-select" name="sim_type"><option value="physical">{{ __('status.sim_physical') }}</option><option value="esim" @selected(old('sim_type', $line?->sim_type?->value) === 'esim')>{{ __('status.sim_esim') }}</option></select></div>
<div class="col-md-4">
    <label class="form-label">{{ __('messages.sale_price') }}</label>
    <input class="form-control" name="sale_price" value="{{ old('sale_price', $line?->sale_price) }}" required>
    <div class="form-text">{{ __('messages.line_price_hint') }}</div>
</div>
@if($line)
<div class="col-md-12"><input class="form-control" name="price_reason" placeholder="{{ __('messages.price_change_reason') }}"></div>
@endif
<div class="col-12"><textarea class="form-control" name="notes" placeholder="{{ __('messages.notes') }}">{{ old('notes', $line?->notes) }}</textarea></div>
</div>
<button class="btn btn-success mt-3">{{ __('messages.save') }}</button>
</form>
@endsection
