<x-ui.layout.page :title="__('training.courses')" page-icon="fe fe-book-open">
    @can('training.create')
        <div class="card mb-3"><div class="card-body">
            <form method="POST" action="{{ route('hr.training.courses.store') }}" class="row g-3">@csrf
                <div class="col-md-3"><x-ui.form.input name="code" :label="__('training.fields.code')" required /></div>
                <div class="col-md-4"><x-ui.form.input name="name" :label="__('training.fields.name')" required /></div>
                <div class="col-md-2"><x-ui.form.input name="default_hours" type="number" step="0.5" :label="__('training.fields.hours')" /></div>
                <div class="col-md-2"><x-ui.form.input name="default_cost" type="number" step="0.01" :label="__('training.fields.cost')" /></div>
                <input type="hidden" name="is_active" value="1">
                <div class="col-md-1 d-flex align-items-end"><x-ui.buttons.primary type="submit">{{ __('common.save') }}</x-ui.buttons.primary></div>
            </form>
        </div></div>
    @endcan
    <x-ui.operational.index-shell>
        <x-ui.table.table :columns="[['label'=>__('training.fields.code')],['label'=>__('training.fields.name')],['label'=>__('training.fields.hours')],['label'=>__('training.fields.cost')],['label'=>__('training.fields.status')]]">
            @forelse($courses as $course)
                <x-ui.table.row><td>{{ $course->code }}</td><td>{{ $course->name }}</td><td>{{ $course->default_hours }}</td><td>{{ number_format((float)$course->default_cost,2) }}</td><td>{{ $course->is_active ? __('common.active') : __('common.inactive') }}</td></x-ui.table.row>
            @empty<x-ui.table.row><td colspan="5"><x-ui.operational.empty-state :title="__('training.empty_courses')" /></td></x-ui.table.row>@endforelse
        </x-ui.table.table>
        <x-slot:pagination>{{ $courses->links() }}</x-slot:pagination>
    </x-ui.operational.index-shell>
</x-ui.layout.page>
