@extends('layouts.base')

@section('content-header')
<div class="col-12">
    <div class="container" style="display: contents">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h1 class="m-0"> Kasir <small>kasir 3.0</small></h1>
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                <li class="breadcrumb-item"><a href="#">Home</a></li>
                <li class="breadcrumb-item"><a href="#">Kasir</a></li>
                <li class="breadcrumb-item active">History</li>
                </ol>
            </div>
        </div>
    </div>
</div>
@endsection

@section('content')
<div class="col-12 mt-2">
    <div class="container" style="display: contents">
        <div class="card">
            <div class="card bg-warning" style="min-height:5px; border-radius:1px;"></div>
            <div class="card-body">
                {{-- <h5 class="card-title">Form List Data</h5> --}}
                <div class="table-responsive mt-3">
                    <table id="tabelku" class="table table-hover display" style="width: 100%">
                        <thead>
                            <tr>
                                <th class="text-center">No</th>
                                <th>Kode Pesanan</th>
                                <th>Kasir</th>
                                <th>Tanggal & Jam</th>
                                <th>Total Pesanan</th>
                                <th>Diskon(%)</th>
                                <th>Total</th>
                                <th class="text-center"><i class="fas fa-cog"></i></th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@push('styles')
    <!-- Toastr -->
    <style>
        @media only screen and (max-width : 991px) {
            /* Styles */
        }

        @media only screen and (max-width : 768px) {
            /* Styles */
        }

        @media only screen and (max-width : 414px) {
            /* Styles */
        }
    </style>
    <link rel="stylesheet" href="{{ asset('assets/plugins/toastr/toastr.min.css') }}">
    <link rel="stylesheet" href="{{asset('assets/datatables/datatables.min.css')}}">
@endpush

@push('scripts')
    <script src="{{ asset('assets/datatables/datatables.min.js') }}"></script>
    <script>
        $(document).ready( function () {
            $('#tabelku').DataTable({
                processing: true,
                serverSide: true,
                ajax: '{{ route('history.getDataHistory') }}',
                columns: [
                {data: 'nomor', name: 'nomor', orderable: false, className: 'text-center'},
                {data: 'kode_pesanan', name: 'kode_pesanan'},
                {data: 'nama_user', name: 'nama_user'},
                {data: 'created_at', name: 'created_at'},
                {data: 'total_pesanan', name: 'total_pesanan', className: 'text-center'},
                {
                    data: 'diskon_persen',
                    name: 'diskon_persen',
                    className: 'text-center',
                    render: function(data){
                        return data ?? 0;
                    }
                },
                {data: 'grand_total', name: 'grand_total'},
                {data: 'ubah', name: 'ubah', className: 'text-center'},
                ]
            })
        })
    </script>
    <script>
        function print(id) {
            var url = "{{ route('history.print', '') }}/" + id + '?print=true'
            window.open(url, '_blank');
        }
    </script>
@endpush