@extends('layouts.app-hr')

@section('content')
    @include('hr.employee-benefit.confirm-delete')
    <?php Fun::lang()?>
    <div class="top-header">
        <ol class="breadcrumb">
            <li><a href="#">{{__('administrator.Dashboard')}}</a></li>
            <li><a href="#">{{__('administrator.employee_benefit')}}</a></li>
        </ol>
    </div>
    <div class="page">
        <div class="top-content">
            <div class="row">
                <div class="col-sm-6 col-xs-12">
                    <div class="title-add">
                        <div class="pull-left">
                            <h3>{{__('administrator.employee_benefit')}} </h3>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6 col-xs-12">
                    <div class="title-add">
                        <div class="pull-right">
                            @can('Benefit Create')
                            <a href="{{route('hr-employee-benefit.create')}}"
                               class="button_primary">{{__('administrator.add_new')}}</a>
                                @endcan
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-body">
            <table id="datatable_products" width="100%" class="table table-striped">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>{{__('administrator.employee')}}</th>
                        <th>{{__('administrator.benefit')}}</th>
                        <th style="width: 200px;">{{ __('administrator.action') }}</th>
                    </tr>
                </thead>

            </table>
        </div>
    </div>
@endsection
@section('script')
    <script type="text/javascript">
        $(document).ready(function () {
            $(document).on('click', '.btn-delete-benefit', function(){
                var id = $(this).data('id');
                $('#delete-id').val(id);
                $('#form-delete').modal('show');
            });
            $('#datatable_products').DataTable({
                ordering: false,
                serverSide: true,
                ajax: "{{ route('datatable.hr-get-employee-benefit') }}",
                lengthMenu: [[20, 30, 50, 100, 1000], [20, 30, 50, 100, 1000]],
                columns:
                    [
                        {data: 'DT_RowIndex', orderable: false, searchable: false},
                        {data: 'emp_id', name: 'users.name'},
                        {data: 'benefit_id'},
                        {data: 'action'},
                    ],
                "initComplete": function (settings, json) {

                }
            });

            $.fn.dataTable.ext.errMode = 'throw';
        });
    </script>
@endsection
