@extends('layouts.app-hr')

@section('content')
    @include('hr.overtime-request.confirm-delete')
    <?php Fun::lang()?>
    <div class="top-header">
        <ol class="breadcrumb">
            <li><a href="#">{{__('administrator.Dashboard')}}</a></li>
            <li><a href="#">{{__('administrator.overtime')}}</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.overtime')}} </h3>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6 col-xs-12">
                    <div class="title-add">
                        <div class="pull-right">
                            @can('Overtime Create')
                                <a href="{{route('hr-overtime-request.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.project')}}</th>
                        <th>{{ __('administrator.date')}}</th>
                        <th>{{ __('administrator.from')}}</th>
                        <th>{{ __('administrator.to')}}</th>
                        <th>{{ __('administrator.total_hour')}}</th>
                        <th>{{ __('administrator.ot_rate')}}</th>
                        <th>{{ __('administrator.ot_type')}}</th>
                        <th>{{ __('administrator.status')}}</th>
                        <th style="width: 200px;">{{ __('administrator.action')}}</th>
                    </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
    </div>
    <div class="modal fade bs-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-dm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h3 class="modal-title">{{ __('administrator.are_you_sure')}}</h3>
                </div>
                <br/>
                <form role="form" method="POST" id="form_update">
                    {{csrf_field()}}
                    <div class="row">
                        <div class="col-md-12">
                            <div class="col-md-12">
                                <input type="hidden" name="id" id="id">
                            </div>
                            <div class="form-group col-sm-12 col-xs-12">
                                <label class="required">{{ __('administrator.status')}}</label>
                                <select name="status" class="form-control input-lg select2" required>
                                    <option value="">{{ __('administrator.please_select')}}</option>
                                    <option value="1">{{ __('administrator.approve')}}
                                    </option>
                                    <option value="2">{{ __('administrator.reject')}}
                                    </option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" data-dismiss="modal" class="btn btn-danger"><i
                                    class="fa fa-close"></i> {{ __('administrator.close')}}
                        </button>
                        <button type="submit" class="btn btn-success" data-toggle="modal"><i
                                    class="fa fa-save"></i> {{ __('administrator.save')}}
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="modal fade bs-modal-lg" id="viewModal" tabindex="-2" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-dm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h3 class="modal-title">{{ __('administrator.info_detail') }} </h3>
                </div>
                <br/>
                <div class="row">
                    <div class="col-md-12">
                        <div class="form-group col-sm-12 col-xs-12">
                            <div class="form-group col-sm-2 col-xs-12"></div>
                            <div class="form-group col-sm-3 col-xs-12">{{ __('administrator.employee') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 emp"></div>
                        </div>
                        <div class="form-group col-sm-12 col-xs-12">
                            <div class="form-group col-sm-2 col-xs-12"></div>
                            <div class="form-group col-sm-3 col-xs-12">{{ __('administrator.project') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 project"></div>
                        </div>
                        <div class="form-group col-sm-12 col-xs-12">
                            <div class="form-group col-sm-2 col-xs-12"></div>
                            <div class="form-group col-sm-3 col-xs-12">{{ __('administrator.date') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 date"></div>
                        </div>
                        <div class="form-group col-sm-12 col-xs-12">
                            <div class="form-group col-sm-2 col-xs-12"></div>
                            <div class="form-group col-sm-3 col-xs-12">{{ __('administrator.from') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 start"></div>
                        </div>
                        <div class="form-group col-sm-12 col-xs-12">
                            <div class="form-group col-sm-2 col-xs-12"></div>
                            <div class="form-group col-sm-3 col-xs-12">{{ __('administrator.to') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 end"></div>
                        </div>
                        <div class="form-group col-sm-12 col-xs-12">
                            <div class="form-group col-sm-2 col-xs-12"></div>
                            <div class="form-group col-sm-3 col-xs-12">{{ __('administrator.note') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 note"></div>
                        </div>
                        <div class="form-group col-sm-12 col-xs-12">
                            <div class="form-group col-sm-2 col-xs-12"></div>
                            <div class="form-group col-sm-3 col-xs-12">{{ __('administrator.status') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 status"></div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" data-dismiss="modal" class="btn btn-danger"><i
                                class="fa fa-close"></i> {{ __('administrator.close') }}
                    </button>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('js')
    <script type="text/javascript">
        $(document).ready(function () {
            $(document).on('click', '.delete-overtime', function () {
                var id = $(this).data('id');
                $('#delete-id').val(id);
                $('#form-delete').modal('show');
            });
            $(document).on('click', '.viewPopLink', function () {
                var id = $(this).data('id');
                var url = "{{route('hr.overtime-change-status')}}";
                $('#form_update').attr('action', url + '?id=' + id);
                $('#myModal').modal('show');
            });
            $(document).on('click', '.viewot', function () {
                var id = $(this).data('id');
                $('#viewModal').modal('show');
                $.ajax({
                    url: "{{route('hr.overtime')}}",
                    type: 'GET',
                    data: {
                        "id": id,
                    },
                    success: function (data) {
                        $('.emp').text(data.datas.employee);
                        $('.project').text(data.datas.project);
                        $('.date').text(data.datas.dates);
                        $('.start').text(data.datas.starts);
                        $('.end').text(data.datas.ends);
                        $('.note').text(data.datas.note);
                        $('.status').html(data.datas.statuss);
                    }
                });
            });

            $('#datatable_products').DataTable({
                ordering: false,
                serverSide: true,
                ajax: "{{ route('datatable.hr-get-overtime') }}",
                lengthMenu: [[20, 30, 50, 100, 1000], [20, 30, 50, 100, 1000]],
                columns:
                    [
                        {data: 'DT_RowIndex', orderable: false, searchable: false},
                        {data: 'emp_id'},
                        {data: 'project'},
                        {data: 'ot_date'},
                        {data: 'start'},
                        {data: 'end'},
                        {data: 'total_hour'},
                        {data: 'ot_rate'},
                        {data: 'ot_type'},
                        {data: 'status'},
                        {data: 'action'},
                    ],
                "initComplete": function (settings, json) {
                }
            });
            $.fn.dataTable.ext.errMode = 'throw';
        });
    </script>
@endsection
