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
@php
use App\Models\TaskTime;
@endphp
<form id="task-time-form" action="{{ route('task_time_save') }}" method="post">
@csrf
@method('POST')
<div class="row">
<input type="hidden" id="user_pad_id" name="user_pad_id" value="{{ $user_pad_id }}">
<input type="hidden" id="tarefa_id" name="tarefa_id" value="">
<input type="hidden" id="type" name="type" value="">
<input type="hidden" id="id" name="id" value="">
<div class="mb-4 col-sm-2">
<div class="">
<label class="form-label" for="cod_atividade">Cód. Atividade</label>
<input class="form-control @error('cod_atividade') is-invalid @enderror ajax-errors" type="text" name="cod_atividade" id="cod_atividade" readonly>
</div>
@include('components.divs.errors', [
'field' => 'cod_atividade_create'
])
</div>
<div class="col-sm-10">
<div class="mt-3">
<label for="weekday">Dia da Semana</label>
<select name="weekday" id="weekday" class="form-select @error('weekday') is-invalid @enderror ajax-errors">
@foreach(TaskTime::listWeekDays() as $id => $text)
<option value="{{$id}}">{{$text}}</option>
@endforeach
</select>
@include('components.divs.errors', [
'field' => 'weekday_create'
])
</div>
</div>
<div class="col-sm-12">
<div class="">
<label for="slct_tarefa_id">Atividade</label>
<select name="slct_tarefa_id" id="slct_tarefa_id" class="form-select @error('slct_tarefa_id') is-invalid @enderror ajax-errors">
</select>
</div>
@include('components.divs.errors', [
'field' => 'slct_tarefa_id_create'
])
</div>
<div class="col-sm-6">
<div class="mt-3">
<label class="form-label" for="start_time">Horário Inicial</label>
<input type="time" min="07:30" max="21:15" name="start_time" id="start_time" class="form-control @error('start_time') is-invalid @enderror ajax-errors" >
@include('components.divs.errors', [
'field' => 'start_time_create',
])
</div>
</div>
<div class="col-sm-6">
<div class="mt-3">
<label class="form-label" for="end_time">Horário Final</label>
<input type="time" min="07:30" max="21:15" name="end_time" id="end_time" class="form-control @error('end_time') is-invalid @enderror ajax-errors" >
@include('components.divs.errors', [
'field' => 'end_time_create',
])
</div>
</div>
</div>
<div class="mt-1 text-end">
<div class="modal-footer">
@include('components.buttons.btn-save', [
'id' => 'btn_submit',
'content' => 'Cadastrar',
])
@include('components.buttons.btn-close_modal')
</div>
</div>
</form>
@include('pad.components.scripts.ajaxValidation', [
'btn_submit_id' => 'btn_submit',
'form_id' => 'task-time-form',
'route' => route('task_time_validation'),
'form_type' => 'create',
])
<script type="text/javascript">
$('#weekday').select2(
{
allowClear: true,
placeholder: 'Dia da Semana',
dropdownParent: $('#modal')
})
$('#slct_tarefa_id').select2(
{
allowClear: true,
placeholder: 'Tarefa',
language: {
noResults: function() {
return "Resultados não Encontrados";
}
},
ajax: {
url: '{{ route("task_search") }}',
data: function(params) {
return {
q: params.term,
user_pad_id : {{$user_pad_id}}
}
},
dataType: 'json'
},
dropdownParent: $('#modal')
})
$('#slct_tarefa_id').on('change', function(e)
{
const type = $('#type')
const tarefa_id = $('#tarefa_id')
$('#cod_atividade').val('')
if($(this).val()) {
const value = $(this).val()
const split_data = value.split('|')
const split_tarefa_id = split_data[0].split('_')
const split_type = split_data[1].split('_')
const _tarefa_id = split_tarefa_id[1]
const _type = split_type[1]
type.val(_type)
tarefa_id.val(_tarefa_id)
$.ajax({
url: '{{ route("task_time_search") }}',
type: 'GET',
data: {
tarefa_id: _tarefa_id,
type: _type
},
dataType: 'json',
success: (response) => {
const cod_atividade = response.task.cod_atividade
$('#cod_atividade').val(cod_atividade)
},
error: (xhr, status, error) => {
console.error('Erro na requisição!');
}
});
}
})
</script>