@extends('layouts/base_view')
@section('title')
{!! $variables['header_routes'] !!}
@endsection
@section('content')
<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card card-outline card-warning">
                    <div class="card-header">
                        <div class="d-flex flex-wrap align-items-center">
                            @include('layouts.partials.excel_upload_buttons', ['module' => 'shipment_suppliers'])
                            <a href="{{ route('shipment_suppliers.create') }}" class="btn btn-sm btn-warning mb-2 mb-md-0 button-cek-permission" data-permission="shipment_suppliers.create">
                                <i class="fas fa-plus"></i><span class="d-none d-sm-inline ml-1">Tambah Supplier</span>
                            </a>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table id="suppliersTable" class="table table-hover table-sm">
                                <thead class="bg-warning">
                                    <tr>
                                        <th width="50">No</th>
                                        <th>Kode</th>
                                        <th>Nama</th>
                                        <th>Kontak Person</th>
                                        <th>Telepon</th>
                                        <th>Hari Kontak</th>
                                        <th>Lead Time</th>
                                        <th>Kontak Berikutnya</th>
                                        <th width="100">Status</th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<script>
    $(document).ready(function() {
        // Initialize DataTable
        var table = $('#suppliersTable').DataTable({
            processing: true,
            serverSide: true,
            ajax: {
                url: "{{ route('shipment_suppliers.index') }}",
                type: 'GET'
            },
            columns: [{
                    data: 0,
                    name: 'no',
                    orderable: false,
                    searchable: false
                },
                {
                    data: 1,
                    name: 'code'
                },
                {
                    data: 2,
                    name: 'name'
                },
                {
                    data: 3,
                    name: 'contact_person'
                },
                {
                    data: 4,
                    name: 'phone'
                },
                {
                    data: 5,
                    name: 'contact_days',
                    orderable: false
                },
                {
                    data: 6,
                    name: 'lead_time_days'
                },
                {
                    data: 7,
                    name: 'next_contact',
                    orderable: false
                },
                {
                    data: 8,
                    name: 'status',
                    orderable: false
                }
            ],
            order: [
                [1, 'asc']
            ],
            pageLength: 25,
            responsive: false,
            language: {
                processing: "Memuat...",
                search: "Cari:",
                lengthMenu: "Tampilkan _MENU_ data",
                info: "Menampilkan _START_ sampai _END_ dari _TOTAL_ data",
                infoEmpty: "Menampilkan 0 sampai 0 dari 0 data",
                infoFiltered: "(difilter dari _MAX_ total data)",
                paginate: {
                    first: "Pertama",
                    last: "Terakhir",
                    next: "Selanjutnya",
                    previous: "Sebelumnya"
                },
                emptyTable: "Tidak ada data tersedia",
                zeroRecords: "Tidak ada data yang cocok"
            }
        });
    });
</script>

@include('layouts.partials.excel_upload_modal', [
    'module' => 'shipment_suppliers',
    'title' => 'Supplier Pengiriman',
    'uploadRoute' => route('shipment_suppliers.upload_excel'),
    'downloadRoute' => route('shipment_suppliers.download_template')
])

@endsection