@extends('layouts.app')
@section('title','Translation Dictionary')
@section('content')
<div class="page-head"><div><h1>Product translation dictionary</h1><p>Deterministic English → Arabic suggestions; billing always uses saved product names.</p></div></div><div class="row g-2"><div class="col-lg-4"><form method="POST" action="{{ route('settings.translation-dictionary.store') }}" class="card-erp">@csrf<div class="card-erp-header">Add dictionary term</div><div class="card-erp-body"><label class="form-label">English term</label><input name="english_term" class="form-control mb-2" required><label class="form-label">Arabic term</label><input name="arabic_term" class="form-control mb-2" dir="rtl" required><label class="form-label">Type</label><select name="type" class="form-select mb-3">@foreach($types as $t)<option>{{ $t }}</option>@endforeach</select><button class="btn btn-primary w-100">Add term</button></div></form><form method="POST" enctype="multipart/form-data" action="{{ route('settings.translation-dictionary.import') }}" class="card-erp">@csrf<div class="card-erp-header">Import CSV</div><div class="card-erp-body"><input type="file" name="file" class="form-control mb-2" accept=".csv" required><small class="text-muted">Columns: English Term, Arabic Term, Type</small><button class="btn btn-light border w-100 mt-2">Import</button></div></form></div><div class="col-lg-8"><div class="card-erp"><div class="card-erp-body"><form class="row g-2"><div class="col-7"><input name="search" class="form-control" value="{{ request('search') }}" placeholder="Search terms"></div><div class="col-3"><select name="type" class="form-select"><option value="">All types</option>@foreach($types as $t)<option @selected(request('type')===$t)>{{ $t }}</option>@endforeach</select></div><div class="col-2"><button class="btn btn-dark w-100">Filter</button></div></form></div><div class="table-responsive"><table class="table table-dense"><thead><tr><th>English</th><th>Arabic</th><th>Type</th><th></th></tr></thead><tbody>@foreach($dictionaries as $d)<tr><form method="POST" action="{{ route('settings.translation-dictionary.update',$d) }}">@csrf @method('PUT')<td><input name="english_term" class="form-control" value="{{ $d->english_term }}"></td><td><input name="arabic_term" dir="rtl" class="form-control" value="{{ $d->arabic_term }}"></td><td><select name="type" class="form-select">@foreach($types as $t)<option @selected($d->type===$t)>{{ $t }}</option>@endforeach</select></td><td><button class="btn btn-light border btn-dense">Save</button></td></form></tr>@endforeach</tbody></table></div>@if($dictionaries->hasPages())<div class="card-erp-body border-top">{{ $dictionaries->links() }}</div>@endif</div></div></div>
@endsection
