sertificate_add.blade.php
4.46 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
@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">Название сертификата:</label>
<div class="form-group__item">
@error('name')
<div class="error red">{{ $message }}</div>
@enderror
<input type="text" name="name" id="name" class="input" value="{{ old('name') ?? '' }}" required>
</div>
</div>
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">Действия сертификата до:</label>
<div class="form-group__item">
@error('end_begin')
<div class="error red">{{ $message }}</div>
@enderror
<input type="text" name="end_begin" id="end_begin" class="input" value="{{ old('end_begin') ?? '' }}" required>
</div>
</div>
</div>
<div class="flex">
<button class="button add-serificate-button mr-10">Сохранить</button>
<a href="{{ route('worker.cabinet') }}" class="button button_light">Назад</a>
</div>
</div>
</div>
<div class="hide">
<div id="after_add_serificate_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_sertificate',['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_serificate_chat-button" data-fancybox data-src="#after_add_serificate_chat"></button>
</div>
@endsection
@section('scripts')
<script>
$(function(){
$('.add-serificate-button').click(function(){
var this_btn = $(this);
spinStart(this_btn);
var wrap = this_btn.closest('.cabinet__inputs');
var name = wrap.find('[name="name"]').val();
var end_date = wrap.find('[name="end_begin"]').val();
var worker_id = wrap.find('[name="worker_id"]').val();
wrap.find('.error-block').html('');
wrap.find('input').removeClass('border-red');
if (!name) {
wrap.find('[name="name"]').addClass('border-red');
spinStop(this_btn);
return;
}
if (!end_date) {
wrap.find('[name="end_begin"]').addClass('border-red');
spinStop(this_btn);
return;
}
$.ajax({
type: 'POST',
url: "{{ route('worker.add_serificate') }}",
data: {
worker_id: worker_id,
name: name,
end_begin: end_date
},
dataType: 'json',
headers: {
'X-CSRF-TOKEN': $('[name="_token"]').val()
},
success: function(res){
spinStop(this_btn);
$('.open-after_add_serificate_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