@extends('layouts.app')
@section('title','Units')
@section('content')
<div class="page-head"><div><h1>Units of measure</h1><p>Base, purchase, and sales units with decimal controls.</p></div></div><div class="row g-2"><div class="col-lg-4"><form method="POST" action="{{ route('units.store') }}" class="card-erp">@csrf<div class="card-erp-header">New unit</div><div class="card-erp-body"><label class="form-label">Code</label><input name="code" class="form-control mb-2" required><label class="form-label">English name</label><input name="name_en" class="form-control mb-2" required><label class="form-label">Arabic name</label><input name="name_ar" class="form-control mb-2" dir="rtl" required><div class="row g-2"><div class="col"><label class="form-label">Short</label><input name="short_name_en" class="form-control"></div><div class="col"><label class="form-label">Arabic short</label><input name="short_name_ar" dir="rtl" class="form-control"></div></div><input type="hidden" name="allow_decimal" value="0"><div class="form-check mt-3"><input class="form-check-input" type="checkbox" name="allow_decimal" value="1" checked><label class="form-check-label">Allow decimal quantity</label></div><button class="btn btn-primary w-100 mt-3">Create unit</button></div></form></div><div class="col-lg-8"><div class="card-erp"><div class="table-responsive"><table class="table table-dense"><thead><tr><th>Code</th><th>English</th><th>Arabic</th><th>Decimal</th><th></th></tr></thead><tbody>@foreach($units as $u)<tr><form method="POST" action="{{ route('units.update',$u) }}">@csrf @method('PUT')<td><input name="code" class="form-control" value="{{ $u->code }}"></td><td><input name="name_en" class="form-control" value="{{ $u->name_en }}"><input type="hidden" name="short_name_en" value="{{ $u->short_name_en }}"></td><td><input name="name_ar" dir="rtl" class="form-control" value="{{ $u->name_ar }}"><input type="hidden" name="short_name_ar" value="{{ $u->short_name_ar }}"></td><td><select name="allow_decimal" class="form-select"><option value="1" @selected($u->allow_decimal)>Yes</option><option value="0" @selected(!$u->allow_decimal)>No</option></select></td><td><button class="btn btn-light border btn-dense">Save</button></td></form></tr>@endforeach</tbody></table></div></div></div></div>
@endsection
