@extends('layouts.app-hr')
@section('content')
    <?php Fun::lang() ?>
    @include('hr.take-leave-authorize.modal-status')
    @include('hr.take-leave-authorize.modal-deduct')
    <div class="top-header">
        <ol class="breadcrumb">
            <li><a href="#">{{__('administrator.dashboard')}}</a></li>
        </ol>
    </div>
    <div id="page" 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.take_leave_authorize')}} </h3>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="alert-message alert-success" style="display: none">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <i class="fa fa-check"></i>
            <h3>Success</h3>
            <p class="message"></p>
        </div>
        <div class="box-body">
            <table id="datatable_leave" class="table table-striped table-bordered table-hover nowrap">
                <thead>
                    <tr>
                        <th >#</th>
                        <th >{{__('administrator.employee')}}</th>
                        <th >{{__('administrator.from_date')}}</th>
                        <th >{{__('administrator.to_date')}}</th>
                        <th >{{__('administrator.request_date')}}</th>
                        <th >{{__('administrator.request_to')}}</th>
                        <th >{{__('administrator.leave_type')}}</th>
                        <th >{{__('administrator.total_leave')}}</th>
                        <th >{{__('administrator.status')}}</th>
                        <th style="width: 200px;">{{__('administrator.action')}}</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
@endsection


@section('js')

    <script type="text/javascript">
        $(function () {
            $(document).on('click', '.btn_status_authorize', function(){
                var id = $(this).data('id');
                $('#id').val(id);
                $('#form-status').modal('show');
            });

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

            $('#datatable_leave').DataTable({
                ordering: false,
                serverSide: true,
                searchable: false,
                ajax: '{{ route("take-leave-authorize.index") }}',
                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: 'from_date'},
                    { data: 'to_date'},
                    { data: 'request_date'},
                    { data: 'request_to'},
                    { data: 'leave_type'},
                    { data: 'num_take_leave'},
                    { data: 'approve'},
                    { data: 'action',searchable: false},
                ],
            });

        });

    </script>
@stop
