@extends('layouts.layoutMaster')

@section('title', __('Purchase Orders'))

@section('vendor-style')
@vite([
    'resources/assets/vendor/libs/datatables-bs5/datatables.bootstrap5.scss',
    'resources/assets/vendor/libs/datatables-responsive-bs5/responsive.bootstrap5.scss',
    'resources/assets/vendor/libs/sweetalert2/sweetalert2.scss'
])
@endsection

@section('vendor-script')
@vite([
    'resources/assets/vendor/libs/datatables-bs5/datatables-bootstrap5.js',
    'resources/assets/vendor/libs/sweetalert2/sweetalert2.js'
])
@endsection

@section('content')
<x-breadcrumb
    :title="__('Purchase Orders')"
    :breadcrumbs="[
        ['name' => __('System Core'), 'url' => route('systemcore.dashboard')],
        ['name' => __('Purchase Orders')]
    ]"
/>

<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h5 class="mb-0">{{ __('Purchase Orders') }}</h5>
        <a href="{{ route('systemcore.purchase-orders.create') }}" class="btn btn-primary">
            <i class="bx bx-plus"></i> {{ __('Add Purchase Order') }}
        </a>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table id="purchaseOrdersTable" class="table table-hover">
                <thead>
                    <tr>
                        <th>{{ __('Order Number') }}</th>
                        <th>{{ __('Supplier') }}</th>
                        <th>{{ __('Order Date') }}</th>
                        <th>{{ __('Expected Delivery') }}</th>
                        <th>{{ __('Total Amount') }}</th>
                        <th>{{ __('Status') }}</th>
                        <th>{{ __('Payment Status') }}</th>
                        <th>{{ __('Actions') }}</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
@endsection

@section('page-script')
<script>
const pageData = {
    urls: {
        datatable: '{{ route("systemcore.purchase-orders.ajax") }}',
        store: '{{ route("systemcore.purchase-orders.store") }}',
        update: (id) => '{{ route("systemcore.purchase-orders.index") }}/' + id,
        destroy: (id) => '{{ route("systemcore.purchase-orders.index") }}/' + id
    },
    labels: {
        confirmDelete: @json(__('Are you sure?')),
        deleteWarning: @json(__('You will not be able to recover this purchase order!')),
        yesDelete: @json(__('Yes, delete it!')),
        cancel: @json(__('Cancel')),
        success: @json(__('Success')),
        deleteSuccess: @json(__('Purchase order deleted successfully')),
        error: @json(__('Error')),
        deleteError: @json(__('Failed to delete purchase order')),
        searchPlaceholder: @json(__('Search purchase orders...')),
        processing: @json(__('Processing...')),
        lengthMenu: @json(__('Show _MENU_ entries')),
        info: @json(__('Showing _START_ to _END_ of _TOTAL_ entries')),
        infoEmpty: @json(__('No entries to show')),
        infoFiltered: @json(__('(filtered from _MAX_ total entries)')),
        emptyTable: @json(__('No data available')),
        zeroRecords: @json(__('No matching records found')),
        paginate: {
            first: @json(__('First')),
            last: @json(__('Last')),
            next: @json(__('Next')),
            previous: @json(__('Previous'))
        }
    }
};
</script>
@vite(['Modules/SystemCore/resources/assets/js/purchase-orders.js'])
@endsection
