docs.blade.php
7.44 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
@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">
<input type="text" name="job_title" id="job_title" class="input" value="{{ old('job_title') ?? $doc->job_title ?? '' }}" 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="teplohod" id="teplohod" class="input" value="{{ old('teplohod') ?? $doc->teplohod ?? '' }}" 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="GWT" id="GWT" class="input" value="{{ old('GWT') ?? $doc->GWT ?? '' }}" 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="Marka_GD" id="Marka_GD" class="input" value="{{ old('Marka_GD') ?? $doc->Marka_GD ?? '' }}">
</div>
</div>
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">Мощность (кВт)</label>
<div class="form-group__item">
<input type="text" name="KBT" id="KBT" class="input" value="{{ old('KBT') ?? $doc->KBT ?? '' }}">
</div>
</div>
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">Водоизмещение (GRT)</label>
<div class="form-group__item">
<input type="text" name="GRT" id="GRT" class="input" value="{{ old('GRT') ?? $doc->GRT ?? '' }}" 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="name_company" id="name_company" class="input" value="{{ old('name_company') ?? $doc->name_company ?? '' }}" 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="Begin_work"
id="Begin_work"
class="input"
placeholder="11.11.2011"
value="{{ old('begin_work') ?? $doc->begin_work ?? '' }}">
</div>
</div>
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">Окончание контракта</label>
<div class="form-group__item">
<input
type="text"
name="End_work"
id="End_work"
class="input"
placeholder="11.11.2011"
value="{{ old('end_work') ?? $doc->end_work ?? '' }}">
</div>
</div>
</div>
<div class="flex">
<button class="button add-place-of-work-button mr-10">Сохранить</button>
<a href="{{ route('worker.cabinet') }}" class="button button_light">Назад</a>
</div>
</div>
</div>
<div class="hide">
<div id="after_add_place_of_work_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.add_document', ['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_place_of_work_chat-button" data-fancybox data-src="#after_add_place_of_work_chat"></button>
</div>
@endsection
@section('scripts')
<script>
$(function(){
$('.add-place-of-work-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;
var date_format_regex = /^\d{2}\.\d{2}\.\d{4}$/;
wrap.find('.error-block').html('');
wrap.find('input').removeClass('border-red');
wrap.find('input').each(function(){
var val = $(this).val().trim();
var name = $(this).attr('name');
if ($(this).is('[required]') && !val){
$(this).addClass('border-red');
form_is_not_filled = true;
} else if ($(this).attr('name') === 'Begin_work' || $(this).attr('name') === 'End_work') {
if (!date_format_regex.test(val)) {
$(this).addClass('border-red');
$(this).after('<span class="error-block">Неверный формат даты (дд.мм.гггг).</span>');
form_is_not_filled = true;
}
}
data[name] = val;
});
if (form_is_not_filled) {
spinStop(this_btn);
return;
}
$.ajax({
type: 'POST',
url: "{{ route('worker.add_document_save') }}",
data: data,
dataType: 'json',
headers: {
'X-CSRF-TOKEN': $('[name="_token"]').val()
},
success: function(res){
spinStop(this_btn);
$('.open-after_add_place_of_work_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