@extends('layouts.app-hr')

@section('content')
    <?php Fun::lang()?>
    <div class="top-header">
        <ol class="breadcrumb">
            <li><a href="#">{{__('administrator.Dashboard')}}</a></li>
            <li><a href="{{route('hr-employee.index')}}">{{__('administrator.generate-salary')}}</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.generate-salary')}} </h3>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6 col-xs-12">
                    <div class="title-add">
                        <div class="pull-right">
                            @if(Gate::check('Salary  Create'))
                                <a href="{{route('hr-generate-salary.create')}}"
                                   class="button_primary">{{__('administrator.add_new')}}</a>
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-body">
            <table id="datatables" width="100%" class="table table-striped">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>{{__('administrator.employee')}}</th>
                        <th>{{__('administrator.month')}}</th>
                        <th>{{__('administrator.year')}}</th>
                        <th>{{__('administrator.basic_salary')}}</th>
                        <th>{{__('administrator.advance_salary')}}</th>
                        <th>{{__('administrator.take_leave')}}</th>
                        <th>{{__('administrator.benefit')}}</th>
                        <th>{{__('administrator.total_ot')}}</th>
                        <th>{{__('administrator.net_pay_kh')}}</th>
                        <th>{{__('administrator.net_pay_th')}}</th>
                        <th>{{__('administrator.net_pay')}}</th>
                        <th>{{__('administrator.action')}}</th>
                    </tr>
                </thead>

            </table>
        </div>
    </div>
    @include('hr.generate-salary.confirm-delete')
@endsection
@section('js')
    <script type="text/javascript">
        $(document).ready(function () {

            $(document).on('click', '.btn-delete-gen', function () {
                var id = $(this).data('id');
                $('#delete-id').val(id);
                $('#form-delete').modal('show');
            })

            $('#datatables').DataTable({
                ordering: false,
                serverSide: true,
                ajax: "{{ route('datatable.hr-gen-salary') }}",
                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: 'f_month'},
                        {data: 'f_year'},
                        {data: 'basic_salary'},
                        {data: 'advance_salary'},
                        {data: 'take_leave'},
                        {data: 'benefit'},
                        {data: 'total_ot'},
                        {data: 'net_pay_kh'},
                        {data: 'net_pay_th'},
                        {data: 'net_pay'},
                        {data: 'action'},
                    ],
                "initComplete": function (settings, json) {
                }
            });
            $.fn.dataTable.ext.errMode = 'throw';
        });
    </script>
@endsection
