@extends('layouts.layoutMaster')

@section('title', __('Sales 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="__('Sales Orders')"
    :breadcrumbs="[
        ['name' => __('System Core'), 'url' => route('systemcore.dashboard')],
        ['name' => __('Sales Orders')]
    ]"
/>

<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h5 class="mb-0">{{ __('Sales Orders') }}</h5>
        <a href="{{ route('systemcore.sales-orders.create') }}" class="btn btn-primary">
            <i class="bx bx-plus"></i> {{ __('Add Sales Order') }}
        </a>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table id="salesOrdersTable" class="table table-hover">
                <thead>
                    <tr>
                        <th>{{ __('Order Number') }}</th>
                        <th>{{ __('Customer') }}</th>
                        <th>{{ __('Order Date') }}</th>
                        <th>{{ __('Delivery Date') }}</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.sales-orders.ajax") }}',
        store: '{{ route("systemcore.sales-orders.store") }}',
        update: (id) => '{{ route("systemcore.sales-orders.index") }}/' + id,
        destroy: (id) => '{{ route("systemcore.sales-orders.index") }}/' + id
    },
    labels: {
        confirmDelete: @json(__('Are you sure?')),
        deleteWarning: @json(__('You will not be able to recover this sales order!')),
        yesDelete: @json(__('Yes, delete it!')),
        cancel: @json(__('Cancel')),
        success: @json(__('Success')),
        deleteSuccess: @json(__('Sales order deleted successfully')),
        error: @json(__('Error')),
        deleteError: @json(__('Failed to delete sales order')),
        searchPlaceholder: @json(__('Search sales 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/sales-orders.js'])
@endsection
