prev_company_form.blade.php
4.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@extends('workers.cabinet_layout', ['title' => 'Рекомендация - РекаМоре'])
@section('cabinet_content')
<h3 class="cabinet__h4 font30">Рекомендация</h3>
<div class="cabinet__inputs">
@csrf
<input type="hidden" name="worker_id" id="worker_id" class="input" value="{{ $worker->id }}">
<div class="error-block"></div>
<div class="cabinet__body-item width100">
<div class="cabinet__inputs">
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">Название компании:<span class="red">*</span></label>
<div class="form-group__item">
<input type="text" name="name_company" id="name_company" class="input" value="{{ old('name_company') ?? '' }}" required>
</div>
</div>
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">ФИО сотрудника:<span class="red">*</span></label>
<div class="form-group__item">
<input type="text" name="direct" id="direct" class="input" value="{{ old('direct') ?? '' }}" required>
</div>
</div>
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">Должность сотрудника:</label>
<div class="form-group__item">
<input type="text" name="telephone" id="telephone" class="input" value="{{ old('telephone') ?? '' }}">
</div>
</div>
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">Телефон сотрудника:</label>
<div class="form-group__item">
<input type="text" name="telephone2" id="telephone2" class="input" value="{{ old('telephone2') ?? '' }}">
</div>
</div>
</div>
<div class="flex">
<button class="button add-company-button mr-10">Сохранить</button>
<a href="{{ route('worker.cabinet') }}" class="button button_light">Назад</a>
</div>
</div>
</div>
<div class="hide">
<div id="after_add_company_chat" class="modal-dialog">
<div class="modal-dialog-title">
<h2>Рекомендация успешно добавлена</h2>
</div>
<div class="modal-dialog-body pt-20"></div>
<div class="modal-dialog-footer center">
<a href="{{ route('worker.new_prev_company',['worker' => $worker->id]) }}" class="button remove-chat-button mr-20">Добавить еще</a>
<a href="{{ route('worker.cabinet') }}" class="button button_light" onclick="$.fancybox.close();">Закончить</a>
</div>
</div>
<button class="open-after_add_company_chat-button" data-fancybox data-src="#after_add_company_chat"></button>
</div>
@endsection
@section('scripts')
<script>
$(function(){
$('.add-company-button').click(function(){
var this_btn = $(this);
spinStart(this_btn);
var wrap = this_btn.closest('.cabinet__inputs');
var data = {};
var form_is_not_filled = false;
wrap.find('.error-block').html('');
wrap.find('input').removeClass('border-red');
wrap.find('input').each(function(){
var val = $(this).val().trim();
if ($(this).is('[required]') && !val){
$(this).addClass('border-red');
form_is_not_filled = true;
}
var name = $(this).attr('name');
data[name] = val;
});
if (form_is_not_filled){
spinStop(this_btn);
return;
}
$.ajax({
type: 'POST',
url: "{{ route('worker.add_prev_company') }}",
data: data,
dataType: 'json',
headers: {
'X-CSRF-TOKEN': $('[name="_token"]').val()
},
success: function(res){
spinStop(this_btn);
$('.open-after_add_company_chat-button').click();
},
error: function(jqXHR, exception){
if (jqXHR && jqXHR.responseJSON && jqXHR.responseJSON.message){
wrap.find('.error-block').html(jqXHR.responseJSON.message);
}
spinStop(this_btn);
}
});
});
});
</script>
@endsection