@extends('layouts.app-hr')

@section('content')
    <?php Fun::lang()?>
    <style>

    </style>
    <div class="top-header">
        <ol class="breadcrumb">
            <li><a href="#">{{__('administrator.Dashboard')}}</a></li>
            <li><a href="{{route('hr-job-post.index')}}">{{__('administrator.job_position')}}</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.job_position')}} </h3>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6 col-xs-12">
                    <div class="title-add">
                        <div class="pull-right">
                            @if(Gate::check('Job Position Create'))
                                <a href="{{route('hr-job-post.create')}}"
                                   class="button_primary">{{__('administrator.add_new')}}</a>
                            @endif
                        </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.code')}}</th>
                    <th>{{ __('administrator.job_title') }}</th>
                    <th>{{ __('administrator.department') }}</th>
                    <th>{{ __('administrator.employment_type') }}</th>
                    <th>{{ __('administrator.location') }}</th>
                    <th>{{ __('administrator.closing_date') }}</th>
                    <th>{{ __('administrator.action') }}</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </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.code') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 code"></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.job_title') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 job_title"></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.job_function') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 job_function"></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.department') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 department"></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.sex') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 sex"></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.age') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 age"></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.description') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 job_description"></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.education_level') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 education_level"></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.employment_type') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 employment_type"></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.year_of_exp') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 exp_year"></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.requirement') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 requirement"></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.salary') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 salary"></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.benefit') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 benefit"></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.hiring') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 hiring_amt"></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.location') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 location"></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.closing_date') }}</div>
                            <div class="form-group col-sm-7 col-xs-12 closing_date"></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('script')
    <script type="text/javascript">
        $(document).on('click', '.viewot', function () {
            var id = $(this).data('id');
            $('#viewModal').modal('show');
            $.ajax({
                url: "{{route('hr.view-job-post')}}",
                type: 'GET',
                data: {
                    "id": id,
                },
                success: function (data) {
                    $('.code').text(data.datas.job_code);
                    $('.job_title').text(data.datas.job_title);
                    $('.job_description').text(data.datas.job_description);
                    $('.requirement').text(data.datas.requirement);
                    $('.department').text(data.datas.department);
                    $('.employment_type').text(data.datas.employment_type);
                    $('.exp_year').text(data.datas.exp_year);
                    $('.job_function').text(data.datas.job_function);
                    $('.education_level').text(data.datas.education_level);
                    $('.salary').html(data.datas.salary);
                    $('.hiring_amt').text(data.datas.hiring_amt);
                    $('.sex').text(data.datas.sex);
                    $('.age').html(data.datas.age);
                    $('.location').text(data.datas.location);
                    $('.closing_date').text(data.datas.closing_date);
                    $('.benefit').html(data.datas.benefit);

                    $('body :not(script)').contents().filter(function () {
                        return this.nodeType === 3;
                    }).replaceWith(function () {
                        return this.nodeValue.replace(/1/g, '{{__('administrator.1')}}').replace(/2/g, '{{__('administrator.2')}}').replace(/3/g, '{{__('administrator.3')}}').replace(/4/g, '{{__('administrator.4')}}').replace(/5/g, '{{__('administrator.5')}}').replace(/6/g, '{{__('administrator.6')}}').replace(/7/g, '{{__('administrator.7')}}').replace(/8/g, '{{__('administrator.8')}}').replace(/9/g, '{{__('administrator.9')}}').replace(/0/g, '{{__('administrator.0')}}');
                    });
                }
            });
        });
        $(document).ready(function () {
            $('#datatable_products').DataTable({
                ordering: false,
                serverSide: true,
                ajax: "{{ route('datatable.hr-get-job-post') }}",
                columns:
                    [
                        {data: 'DT_RowIndex', 'searchable': false},
                        {data: 'job_code'},
                        {data: 'job_title'},
                        {data: 'department'},
                        {data: 'employment_type'},
                        {data: 'location'},
                        {data: 'closing_date'},
                        {data: 'action'},
                    ],
                "initComplete": function (settings, json) {

                }
            });

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