allerta-vvf/server/templates/edit_service.html

196 lines
7.9 KiB
HTML
Raw Normal View History

2020-04-27 23:27:39 +02:00
<!DOCTYPE html>
<html>
<head>
2020-11-14 23:00:36 +01:00
<link href="favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
2020-11-27 23:53:14 +01:00
<script src="{{ urlsoftware }}/resources/dist/{{ resource('main.js') }}"></script>
2021-03-04 09:52:11 +01:00
{% if enable_debug_bar %}{{ debug_bar_head|raw }}{% endif %}
2020-04-27 23:27:39 +02:00
</head>
<body>
2020-11-14 23:00:36 +01:00
{% if service.modalità == "edit" or service.modalità == "add" %}
<form method="post">
<div class="container">
<label><b>{{ 'Service day'|t }}</b></label>
<div class="input-group">
2020-11-25 11:29:19 +01:00
<input aria-label="Date picker" placeholder="DD/MM/YYY" autocomplete="off" name="date" data-provide="datepicker"
value="{{ values.date }}" type="text" class="form-control">
2020-11-14 23:00:36 +01:00
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
2020-11-14 23:00:36 +01:00
</div>
</div>
2020-11-14 23:00:36 +01:00
<br>
<br>
<label><b>{{ 'code'|t }}</b></label>
2020-11-25 11:29:19 +01:00
<input id="progressivo" type="text" name="code" placeholder="1234/5" required value="{{ values.code }}">
2020-11-14 23:00:36 +01:00
<br>
<br>
<label for="timePicker1"><b>{{ 'Start time'|t }}</b></label>
2020-11-25 11:29:19 +01:00
<input id="timePicker1" type="time" name="beginning" required value="{{ values.beginning }}">
2020-11-14 23:00:36 +01:00
<br>
<br>
<label for="timePicker2"><b>{{ 'End time'|t }}</b></label>
2020-11-25 11:29:19 +01:00
<input id="timePicker2" type="time" name="end" required value="{{ values.end }}">
2020-11-14 23:00:36 +01:00
<br>
<br>
<label><b>{{ 'Chief'|t }}</b></label>
<br>
2020-11-25 11:29:19 +01:00
{% for user in service.crew %}
2020-11-14 23:00:36 +01:00
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="form-check">
2020-11-25 11:29:19 +01:00
<input aria-label="{{ username(user.id) }}" class="form-check-input chief chief-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='chief[]'
2020-11-14 23:00:36 +01:00
value='{{ user.id }}'>
2020-11-25 11:29:19 +01:00
<label class="form-check-label" for="chief-{{ user.id }}">
2020-11-14 23:00:36 +01:00
{{ username(user.id) }}
</label>
</div>
{% endfor %}
<script>
2020-11-25 11:29:19 +01:00
$('.chief').on('change', function () {
2020-11-14 23:00:36 +01:00
$('input[name="' + this.name + '"]').not(this).prop('checked', false);
});
</script>
<br>
<label><b>{{ 'Drivers'|t }}</b></label>
<br>
2020-11-25 11:29:19 +01:00
{% for user in service.crew %}
{% if user.driver == 1 %}
2020-11-14 23:00:36 +01:00
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="form-check">
2020-11-25 11:29:19 +01:00
<input aria-label="{{ username(user.id) }}" class="form-check-input drivers drivers-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='drivers[]'
2020-11-14 23:00:36 +01:00
value='{{ user.id }}'>
2020-11-25 11:29:19 +01:00
<label class="form-check-label" for="drivers-{{ user.id }}">
2020-11-14 23:00:36 +01:00
{{ username(user.id) }}
</label>
</div>
{% endif %}
{% endfor %}
<br>
2020-11-25 11:29:19 +01:00
<label><b>{{ 'Crew'|t }}</b></label>
2020-11-14 23:00:36 +01:00
<br>
2020-11-25 11:29:19 +01:00
{% for user in service.crew %}
2020-11-14 23:00:36 +01:00
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="form-check">
2020-11-25 11:29:19 +01:00
<input aria-label="{{ username(user.id) }}" class="form-check-input crew crew-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='crew[]'
2020-11-14 23:00:36 +01:00
value='{{ user.id }}'>
2020-11-25 11:29:19 +01:00
<label class="form-check-label" for="crew-{{ user.id }}">
2020-11-14 23:00:36 +01:00
{{ username(user.id) }}
</label>
</div>
{% endfor %}
<br>
{% if option('use_location_picker') %}
<label><b>{{ 'Service place'|t }}</b></label>
<div id="map"></div>
<div id="search">
<input type="text" name="addr" value="" id="addr" size="10" />
2021-04-05 19:13:40 +02:00
<button type="button" onclick="addrSearch('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');"
2020-11-14 23:00:36 +01:00
class="btn btn-primary">{{ 'Search'|t }}</button>
<div id="results"></div>
</div>
2020-11-25 11:29:19 +01:00
<input type="hidden" name="place" value="" />
2021-04-05 19:13:40 +02:00
<script src="{{ urlsoftware }}/resources/dist/{{ resource('maps.js') }}" onload="loadMap();"></script>
2020-11-14 23:00:36 +01:00
{% else %}
<label><b>{{ 'Service place'|t }}</b></label>
2020-11-25 11:29:19 +01:00
<input type="text" name="place" required value="{{ values.place }}">
2020-11-14 23:00:36 +01:00
{% endif %}
<br>
<br>
<label><b>{{ 'Others notes (ex. others infos)'|t }}</b></label><br>
2020-11-25 11:29:19 +01:00
<textarea name='notes' id='notes'></textarea>
2020-11-14 23:00:36 +01:00
<br>
<br>
<label><b>{{ 'Service type'|t }}</b></label>
<br>
2021-03-20 19:21:38 +01:00
<select name='type' class="types">
2020-11-25 11:29:19 +01:00
{% for type in service.types %}
<option value='{{ type.name }}'>{{ type.name }}</option>
2020-11-14 23:00:36 +01:00
{% endfor %}
2021-03-20 21:19:24 +01:00
{% if service.types is empty %}
<option id="empty_option" value=''></option>
{% endif %}
2021-03-20 19:21:38 +01:00
<option value='add_new'>{{ 'Add type...'|t }}</option>
2020-11-14 23:00:36 +01:00
</select>
<br>
<input id="modalità" type="hidden" value="{{ service.modalità }}" name="mod"></input>
<input id="token" type="hidden" value="{{ service.token }}" name="token"></input>
<input id="id" type="hidden" value="{{ service.id }}" name="id"></input>
<button type="submit">{{ 'Submit'|t }}</button>
</div>
2020-11-14 23:00:36 +01:00
</form>
<script>
2021-03-20 19:21:38 +01:00
$( ".types" ).change(function() {
2021-03-20 21:19:24 +01:00
$('#empty_option').remove();
2021-03-20 19:21:38 +01:00
var type = "";
$( ".types option:selected" ).each(function() {
type = $( this ).val();
});
console.log(type);
if(type == "add_new"){
new_type = prompt("{{ 'Insert type name:'|t }}");
if(!new_type) return;
$.ajax({
url: "resources/ajax/ajax_add_type.php",
method: "POST",
data: {
type: new_type
},
success: function (data) {
$('option:last-of-type').before($('<option>').val(new_type).text(new_type));
$('option[value='+new_type+']').prop('selected', 'selected').change();
toastr.success(`{{ "Type '%s' added successfully."|t|format('${new_type}') }}`);
}
});
}
});
2020-11-14 23:00:36 +01:00
{% if service.modalità == "edit" %}
2020-11-25 11:29:19 +01:00
$.each('{{ values.chief }}'.split(','), function (index, value) {
$('.chief-' + value).prop('checked', true);
2020-04-27 23:27:39 +02:00
});
2020-11-25 11:29:19 +01:00
$.each('{{ values.drivers }}'.split(','), function (index, value) {
$('.drivers-' + value).prop('checked', true);
2020-11-14 23:00:36 +01:00
});
2020-11-25 11:29:19 +01:00
$.each('{{ values.crew }}'.split(','), function (index, value) {
$('.crew-' + value).prop('checked', true);
2020-11-14 23:00:36 +01:00
});
2020-11-25 11:29:19 +01:00
$(".tipi").val('{{ values.type }}');
$('#notes').val('{{ values.notes }}');
2020-11-13 15:22:26 +01:00
{% endif %}
2020-11-14 23:00:36 +01:00
$('form').submit(function () {
2021-03-20 19:21:38 +01:00
var type = "";
$( ".types option:selected" ).each(function() {
type = $( this ).val();
});
2021-03-20 21:19:24 +01:00
if(type == "add_new" || type == ""){
2021-03-20 19:21:38 +01:00
toastr.error("{{ 'You must select a valid service type!'|t }}");
return false;
}
2020-11-14 23:00:36 +01:00
var progressivo_valido = /^[0-9/]{3,6}$/
var progressivo = $('#progressivo').val();
if (!progressivo_valido.test(progressivo)) {
2020-11-25 11:29:19 +01:00
var invia_progressivo = confirm("{{ 'The code has been detected as incorrect, do you want to add the service anyway?'|t }}");
2020-11-14 23:00:36 +01:00
} else {
var invia_progressivo = true;
}
return invia_progressivo;
});
</script>
{% endif %}
{% if service.modalità == "delete" %}
<div style="margin: 0 auto; text-align: center">
<p>{{ 'Are you sure you want to delete the service?'|t }}</p>
<form method="post">
<input id="modalità" type="hidden" value="delete" name="mod"></input>
<input id="token" type="hidden" value="{{ service.token }}" name="token"></input>
<input id="id" type="hidden" value="{{ service.id }}" name="id"></input>
<input id="increment" type="hidden" value="{{ increment }}" name="increment"></input>
2021-03-23 18:45:47 +01:00
<button id="remove" type="submit">{{ 'Submit'|t }}</button>
2020-11-14 23:00:36 +01:00
</form>
<script>
$('form').submit(function () {
return confirm("{{ 'The action cannot be canceled. Are you sure you want to continue?'|t }}");
});
</script>
2020-04-27 23:27:39 +02:00
</div>
2020-11-14 23:00:36 +01:00
{% endif %}
2021-03-04 09:52:11 +01:00
{% if enable_debug_bar %}{{ debug_bar|raw }}{% endif %}
2020-04-27 23:27:39 +02:00
</body>
</html>