form_additional_documents.blade.php 3.06 KB
@extends('workers.cabinet_layout', ['title' => 'Дополнительные документы - РекаМоре'])

@section('scripts')
<script>
    $(function () {
        $('.sertificates_js').change(function(){
            var this_btn = $(this);
            var wrap = this_btn.closest('.cabinet__inputs-item');
            var infoblock_id = this_btn.attr('data-info');
            var val = this_btn.val();

            $.ajax({
                type: "GET",
                url: "{{ route('worker.delete_add_diplom', ['worker' => $worker->id]) }}",
                data: "&infoblok_id=" + infoblock_id+"&val="+val,
                success: function (data) {
                    wrap.find('.form-group__label').append('<span class="success font12 ml-10 green">Сохранено</span>');
                    setTimeout(function(){
                        wrap.find('.form-group__label .success').fadeOut(300, function(){
                            wrap.find('.form-group__label .success').remove();
                        });
                    }, 2000);
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                error: function (data) {
                    data = JSON.stringify(data);
                    console.log('Error: ' + data);
                }
            });
        });
    });
</script>
@endsection

@section('cabinet_content')
<div class="mb-40" name="ajax_dop_diplomi" id="ajax_dop_diplomi">
    @csrf

    <div class="cabinet__body-item">
        <div class="cabinet__anketa">
            <h2 class="title cabinet__title">Дополнительные документы</h2>
        </div>
    </div>

    <div class="cabinet__body-item">
        <div class="cabinet__inputs">
            @if ($info_blocks->count())
            @foreach ($info_blocks as $info_block)
            <div class="cabinet__inputs-item form-group">
                <label class="form-group__label">{{ $info_block->name }}:</label>

                <div class="form-group__item">
                    @php $status = 0; @endphp
                    @if (!empty($worker->dop_info[$info_block->id]) && $worker->dop_info[$info_block->id]['status'])
                        @php $status = $worker->dop_info[$info_block->id]['status']; @endphp
                    @endif

                    <select data-info="{{ $info_block->id }}" class="js-select2 sertificates_js">
                    @foreach($additional_document_statuses as $key => $value)
                        <option value="{{ $key }}" @if ($status == $key) selected @endif>{{ $value }}</option>
                    @endforeach
                    </select>
                </div>
            </div>
            @endforeach
            @endif

            <div class="cabinet__body-item cabinet__inputs-item-full-row">
                <div class="cabinet__buttons_flex">
                    <a href="{{ route('worker.cabinet') }}" class="button button_light active">Назад</a>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection