initial JS-less version

This commit is contained in:
Matteo Gheza 2021-05-12 19:34:49 +02:00
parent c6477c83ff
commit 8419cf7fcd
21 changed files with 890 additions and 11 deletions

View File

@ -1,5 +1,10 @@
<?php
require_once 'ui.php';
$_SESSION["token_list"] = bin2hex(random_bytes(64));
loadtemplate('list.html', ['title' => t("Availability List", false), 'token_list' => $_SESSION['token_list']]);
if($JSless){
$query_results = $db->select("SELECT * FROM `".DB_PREFIX."_profiles` ORDER BY available DESC, chief DESC, services ASC, availability_minutes ASC, name ASC");
} else {
$query_results = null;
}
loadtemplate('list.html', ['title' => t("Availability List", false), 'token_list' => $_SESSION['token_list'], 'query_results' => $query_results]);
bdump($_SESSION);

View File

@ -1,3 +1,8 @@
<?php
require_once 'ui.php';
loadtemplate('log.html', ['title' => t('Logs', false)]);
if($JSless){
$query_results = $db->select("SELECT * FROM `".DB_PREFIX."_log` ORDER BY `timestamp` DESC");
} else {
$query_results = null;
}
loadtemplate('log.html', ['title' => t('Logs', false), 'query_results' => $query_results]);

View File

@ -1,3 +1,7 @@
#jsDisabledNotice {
display: none;
}
body:not(table) {
max-width: 100%;
overflow-x: hidden;

View File

@ -152,6 +152,9 @@ var fillTableLoaded = undefined;
window.addEventListener("securitypolicyviolation", console.error.bind(console));
$(function() {
$("#topNavBar").show();
$("#content").show();
$("#footer").show();
$("#menuButton").on("click", function() {
const topNavBar = document.getElementById("topNavBar");
if (topNavBar.className === "topnav") {

View File

@ -1,4 +1,9 @@
<?php
require_once 'ui.php';
loadtemplate('services.html', ['title' => t('Services', false)]);
if($JSless){
$query_results = $db->select("SELECT * FROM `".DB_PREFIX."_services` ORDER BY date DESC, beginning DESC");
} else {
$query_results = null;
}
loadtemplate('services.html', ['title' => t('Services', false), 'query_results' => $query_results]);
?>

View File

@ -0,0 +1,106 @@
{% apply minimize %}
<!DOCTYPE html>
<html lang="it">
<head>
{% block head %}
<title>{{ title }} - ALLERTA sistema gestionale {{ owner }}</title>
<link href="{{ urlsoftware }}/resources/images/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
<meta name="viewport" content="user-scalable=no, initial-scale=1">
<meta name="google" content="notranslate">
<meta name="robots" content="none">
{% endblock %}
</head>
<body>
{% if show_menu %}
{% block menu %}
{# Menu #}
<style>
.topnav {
background-color: red;
overflow: hidden;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.active {
background-color: #4caf50;
color: white;
}
.topnav .icon {
display: none;
}
</style>
<div class="topnav" id="topNavBar">
<a href="{{ urlsoftware }}list.php" class="active">{{ 'Availability List'|t }}</a>
<a href="{{ urlsoftware }}services.php">{{ 'Services'|t }}</a>
<a href="{{ urlsoftware }}trainings.php">{{ 'Trainings'|t }}</a>
<a href="{{ urlsoftware }}log.php">{{ 'Logs'|t }}</a>
<a href='{{ urlsoftware }}logout.php' style="float: right;" id="logout">{{ 'Hi, %s.'|t|format(user.name) }} {{ 'Logout'|t }}</a>
</div>
{# /Menu #}
{% endblock %}
{% endif %}
<style>
.text-center{
text-align: center;
}
.btn{
padding: .5rem 1rem;
font-size: 1.25rem;
line-height: 1.5;
border-radius: .3rem;
color: white;
}
.btn-success{
background-color: #1e7e34;
border-color: #1c7430;
}
.btn-danger{
background-color: #ff0019;
border-color: #ff0019;
}
.btn-small{
font-size: 0.75rem;
}
table .tHead th {
font-weight: bold;
}
table .tBody th {
font-weight: normal;
}
</style>
{# Content #}
<div id="content">
{% block pjax_content %}
{% if message %}
<div class="alert alert-info m-3" role="alert">
{{ message|raw }}
</div>
{% endif %}
{% block content %}{% endblock %}
{% endblock %}
</div>
{# /Content #}
{% if show_footer %}
{% block footer %}
{# Footer #}
<div id="footer" class="footer text-center p-3" style="background-color: rgba(0, 0, 0, 0.2)">
Allerta-VVF, software libero realizzato per {{ owner }}.
</div>
<script>location.href="?JSless=0";</script>
{# /Footer #}
{% endblock %}
{% endif %}
</body>
</html>
{% endapply %}

View File

@ -0,0 +1,212 @@
{% extends "base.html" %}
{% block menu %}
{% endblock %}
{% block content %}
TODO
{% if service.modalità == "edit" or service.modalità == "add" %}
<form method="post">
<div class="container">
<div class="form-group">
<label for="date-picker">{{ 'Service day'|t }}</label>
<input id="date-picker" aria-label="Date picker" placeholder="DD/MM/YYY" autocomplete="off" name="date" data-provide="datepicker"
value="{{ values.date }}" type="text" class="form-control">
</div>
<div class="form-group">
<label for="progressivo">{{ 'code'|t|capitalize }}</label>
<input id="progressivo" class="form-control" type="text" name="code" placeholder="1234/5" required value="{{ values.code }}">
</div>
<div class="form-group">
<label for="timePicker1">{{ 'Start time'|t }}</label>
<input id="timePicker1" class="form-control" type="time" name="beginning" required value="{{ values.beginning }}">
</div>
<div class="form-group">
<label for="timePicker2">{{ 'End time'|t }}</label>
<input id="timePicker2" class="form-control" type="time" name="end" required value="{{ values.end }}">
</div>
<div class="form-group">
<label>{{ 'Chief'|t }}</label>
<br>
{% for user in service.crew %}
{% if user.chief == 1 and not user.hidden %}
<div class="form-check">
<input aria-label="{{ username(user.id) }}" id="chief-{{ user.id }}" class="form-check-input chief chief-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='chief[]'
value='{{ user.id }}'>
<label class="form-check-label" for="chief-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endif %}
{% endfor %}
</div>
<script>
$('.chief').on('change', function () {
$('input[name="' + this.name + '"]').not(this).prop('checked', false);
});
</script>
<div class="form-group">
<label>{{ 'Drivers'|t }}</label>
<br>
{% for user in service.crew %}
{% if user.driver == 1 and not user.hidden %}
<div class="form-check">
<input aria-label="{{ username(user.id) }}" id="drivers-{{ user.id }}" class="form-check-input drivers drivers-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='drivers[]'
value='{{ user.id }}'>
<label class="form-check-label" for="drivers-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endif %}
{% endfor %}
</div>
<div class="form-group">
<label>{{ 'Crew'|t }}</label>
<br>
{% for user in service.crew %}
{% if not user.hidden %}
<div class="form-check">
<input aria-label="{{ username(user.id) }}" id="crew-{{ user.id }}" class="form-check-input crew crew-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='crew[]'
value='{{ user.id }}'>
<label class="form-check-label" for="crew-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endif %}
{% endfor %}
</div>
{% if option('use_location_picker') %}
<label>{{ 'Service place'|t }}</label>
<div id="map"></div>
<div id="search">
<div class="form-inline">
<div class="form-group mx-sm-3 mb-2">
<input type="text" class="form-control" name="addr" value="" id="addr" size="50" />
</div>
<div class="form-group mx-sm-3 mb-2">
<button id="search_button" type="button" onclick="allertaJS.maps.addrSearch('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');"
class="btn btn-primary mb-2">{{ 'Search'|t }}</button>
</div>
</div>
<div id="results"></div>
</div>
<input type="hidden" name="place" value="" />
{{ script('maps.js', 'allertaJS.maps.loadMap();') }}
{% else %}
<div class="form-group">
<label>{{ 'Service place'|t }}</label>
<input type="text" name="place" class="form-control" required value="{{ values.place }}">
</div>
<br>
{% endif %}
<div class="form-group">
<label for="notes">{{ 'Others notes (ex. others infos)'|t }}</label><br>
<textarea class="form-control" id="notes" name='notes'></textarea>
</div>
<br>
<div class="form-group">
<label>{{ 'Service type'|t }}</label>
<br>
<select id="types" class="form-control" name='type' class="types">
{% for type in service.types %}
<option value='{{ type.name }}'>{{ type.name }}</option>
{% endfor %}
{% if service.types is empty %}
<option id="empty_option" value=''></option>
{% endif %}
<option value='add_new'>{{ 'Add type...'|t }}</option>
</select>
</div>
<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 id="submit_button" type="submit" class="btn btn-primary">{{ 'Submit'|t }}</button>
</div>
</form>
<script>
$( "#types" ).change(function() {
$('#empty_option').remove();
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+')|raw }}');
}
});
}
});
{% if service.modalità == "edit" %}
{% if option('use_location_picker') %}
{% set place = values.place|split('#')[0] %}
allertaJS.maps.setMarker(new L.LatLng({{place|split(';')[0]}}, {{place|split(';')[1]}}), true);
{% endif %}
$.each('{{ values.chief }}'.split(','), function (index, value) {
$('.chief-' + value).prop('checked', true);
});
$.each('{{ values.drivers }}'.split(','), function (index, value) {
$('.drivers-' + value).prop('checked', true);
});
$.each('{{ values.crew }}'.split(','), function (index, value) {
$('.crew-' + value).prop('checked', true);
});
$("#types").val('{{ values.type }}');
$('#notes').val('{{ values.notes }}');
{% endif %}
$('form').submit(function () {
var type = "";
$( "#types option:selected" ).each(function() {
type = $( this ).val();
});
if(type == "add_new" || type == ""){
toastr.error("{{ 'You must select a valid service type!'|t }}");
return false;
}
var progressivo_valido = /^[0-9/]{3,6}$/
var progressivo = $('#progressivo').val();
if (!progressivo_valido.test(progressivo)) {
var invia_progressivo = confirm("{{ 'The code has been detected as incorrect, do you want to add the service anyway?'|t }}");
} 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>
<button id="remove" type="submit">{{ 'Submit'|t }}</button>
</form>
<script>
$('form').submit(function () {
return confirm("{{ 'The action cannot be canceled. Are you sure you want to continue?'|t }}");
});
</script>
</div>
{% endif %}
{% block footer %}
{% endblock %}
{% endblock %}

View File

@ -0,0 +1,136 @@
{% extends "base.html" %}
{% block menu %}
{% endblock %}
{% block content %}
TODO
{% if training.modalità == "edit" or training.modalità == "add" %}
<form method="post">
<div class="container">
<div class="form-group">
<label for="date-picker">{{ 'Training day'|t }}</label>
<input id="date-picker" aria-label="Date picker" placeholder="DD/MM/YYY" autocomplete="off" name="date" data-provide="datepicker"
value="{{ values.date }}" type="text" class="form-control">
</div>
<div class="form-group">
<label for="name">{{ 'Name'|t }}</label>
<input id="name" class="form-control" type="text" name="name" placeholder="1° training" required value="{{ values.name }}">
</div>
<div class="form-group">
<label for="timePicker1">{{ 'Start time'|t }}</label>
<input id="timePicker1" class="form-control" type="time" name="start_time" required value="{{ values.beginning }}">
</div>
<div class="form-group">
<label for="timePicker2">{{ 'End time'|t }}</label>
<input id="timePicker2" class="form-control" type="time" name="end_time" required value="{{ values.end }}">
</div>
<div class="form-group">
<label>{{ 'Chief'|t }}</label>
<br>
{% for user in training.crew %}
{% if not user.hidden %}
<div class="form-check">
<input aria-label="{{ username(user.id) }}" id="chief-{{ user.id }}" class="form-check-input chief chief-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='chief[]'
value='{{ user.id }}'>
<label class="form-check-label" for="chief-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endif %}
{% endfor %}
</div>
<script>
$('.chief').on('change', function () {
$('input[name="' + this.name + '"]').not(this).prop('checked', false);
});
</script>
<div class="form-group">
<label>{{ 'Crew'|t }}</label>
<br>
{% for user in training.crew %}
{% if not user.hidden %}
<div class="form-check">
<input aria-label="{{ username(user.id) }}" id="crew-{{ user.id }}" class="form-check-input crew crew-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='crew[]'
value='{{ user.id }}'>
<label class="form-check-label" for="crew-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endif %}
{% endfor %}
</div>
{% if option('use_location_picker') %}
<label>{{ 'Training place'|t }}</label>
<div id="map"></div>
<div id="search">
<div class="form-inline">
<div class="form-group mx-sm-3 mb-2">
<input type="text" class="form-control" name="addr" value="" id="addr" size="50" />
</div>
<div class="form-group mx-sm-3 mb-2">
<button id="search_button" type="button" onclick="allertaJS.maps.addrSearch('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');"
class="btn btn-primary mb-2">{{ 'Search'|t }}</button>
</div>
</div>
<div id="results"></div>
</div>
<input type="hidden" name="place" value="" />
{{ script('maps.js', 'allertaJS.maps.loadMap();') }}
{% else %}
<div class="form-group">
<label for="place">{{ 'Training place'|t }}</label>
<input id="place" type="text" class="form-control" name="place" required value="{{ values.place }}">
</div>
<br>
{% endif %}
<div class="form-group">
<label for="notes">{{ 'Others notes (ex. others infos)'|t }}</label><br>
<textarea class="form-control" id="notes" name='notes'></textarea>
</div>
<br>
<input id="modalità" type="hidden" value="{{ training.modalità }}" name="mod"></input>
<input id="id" type="hidden" value="{{ training.id }}" name="id"></input>
<input id="token" type="hidden" value="{{ training.token }}" name="token"></input>
<button id="submit_button" type="submit" class="btn btn-primary">{{ 'Submit'|t }}</button>
</div>
</form>
<script>
{% if training.modalità == "edit" %}
{% if option('use_location_picker') %}
{% set place = values.place|split('#')[0] %}
allertaJS.maps.setMarker(new L.LatLng({{place|split(';')[0]}}, {{place|split(';')[1]}}), true);
{% endif %}
$.each('{{ values.chief|striptags|e("js") }}'.split(','), function (index, value) {
$('.chief-' + value).prop('checked', true);
});
$.each('{{ values.crew|striptags|e("js") }}'.split(','), function (index, value) {
$('.crew-' + value).prop('checked', true);
});
$('#notes').val('{{ values.notes|e("js") }}');
{% endif %}
</script>
{% endif %}
{% if training.modalità == "delete" %}
<div style="margin: 0 auto; text-align: center">
<p>{{ 'Are you sure you want to delete the training?'|t }}</p>
<form method="post">
<input id="modalità" type="hidden" value="delete" name="mod"></input>
<input id="token" type="hidden" value="{{ training.token }}" name="token"></input>
<input id="id" type="hidden" value="{{ training.id }}" name="id"></input>
<button id="remove" type="submit">{{ 'Submit'|t }}</button>
</form>
<script>
$('form').submit(function () {
return confirm("{{ 'The action cannot be canceled. Are you sure you want to continue?'|t }}");
});
</script>
</div>
{% endif %}
{% block footer %}
{% endblock %}
{% endblock %}

View File

@ -0,0 +1,84 @@
{% extends "base.html" %}
{% block menu %}
{% endblock %}
{% block content %}
TODO
{% if modalità == "edit" or modalità == "add" %}
<form method="post">
<div class="container">
<div class="form-group">
<label for="mail">{{ 'E-mail'|t }}</label>
<input id="mail" class="form-control" type="text" name="mail" placeholder="{{ 'user@provider-email-domain.com'|t }}" required>
</div>
<div class="form-group">
<label for="name">{{ 'Name'|t }}</label>
<input id="name" class="form-control" type="text" name="name" placeholder="{{ 'Name Surname'|t }}" required>
</div>
<div class="form-group">
<label for="username">{{ 'Username'|t }}</label>
<input id="username" class="form-control" type="text" name="username" placeholder="{{ 'name.surname'|t }}" required>
</div>
<div class="form-group">
<label>{{ 'Password'|t }}</label>
<input id="password" class="form-control" type="text" name="password" required>
</div>
<div class="form-group">
<label for="phone_number">{{ 'Phone number'|t }}</label>
<input id="phone_number" class="form-control" type="tel" name="phone_number" required>
</div>
<div class="form-group">
<label for="date-picker">{{ 'Birthday'|t }}</label>
<input id="date-picker" placeholder="DD/MM/YYY" autocomplete="off" name="birthday" data-provide="datepicker"
value="{{ values.date }}" type="text" class="form-control">
</div>
<style>
.toggle.workaround {
border: 1px solid black;
}
</style>
<div class="form-group">
<label for="chief">{{ 'Chief'|t }}</label><br>
<input id="chief" class="form-control" type="checkbox" name="chief" data-toggle="toggle" data-style="workaround">
</div>
<div class="form-group">
<label for="driver">{{ 'Driver'|t }}</label><br>
<input id="driver" class="form-control" type="checkbox" name="driver" data-toggle="toggle" data-style="workaround">
</div>
<div class="form-group">
<label for="visible">{{ 'Visible'|t }}</label><br>
<input id="visible" class="form-control" type="checkbox" name="visible" checked data-toggle="toggle" data-style="workaround">
</div>
<div class="form-group">
<label for="enabled">{{ 'Enabled'|t }}</label><br>
<input id="enabled" class="form-control" type="checkbox" name="enabled" checked data-toggle="toggle" data-style="workaround">
</div>
<br>
<input id="modalità" type="hidden" value="{{ modalità }}" name="mod"></input>
<input id="token" type="hidden" value="{{ token }}" name="token"></input>
<button type="submit" class="btn btn-primary">{{ 'Submit'|t }}</button>
</div>
</form>
{% endif %}
{% if modalità == "delete" %}
<div style="margin: 0 auto; text-align: center">
<p>{{ 'Are you sure you want to delete the user?'|t }}</p>
<form method="post">
<input id="modalità" type="hidden" value="delete" name="mod"></input>
<input id="token" type="hidden" value="{{ token }}" name="token"></input>
<input id="id" type="hidden" value="{{ id }}" name="id"></input>
<button id="remove" type="submit">{{ 'Submit'|t }}</button>
</form>
<script>
$('form').submit(function () {
return confirm("{{ 'The action cannot be canceled. Are you sure you want to continue?'|t }}");
});
</script>
</div>
{% endif %}
{% block footer %}
{% endblock %}
{% endblock %}

View File

@ -0,0 +1,41 @@
{% extends "base.html" %}
{% block menu %}
{% endblock %}
{% block content %}
<div class="align-items-center container d-flex justify-content-center" id="modulogin">
<form method="post">
<img alt="VVF" src="{{ urlsoftware }}/resources/images/logo.png" class="img-resposive"><br><br>
<div class="form-group">
<input type="text" name="name" placeholder="{{ 'username'|t|capitalize }}" required="" autocomplete="username" autofocus="" class="form-control">
</div>
<div class="form-group">
<input type="password" name="password" placeholder="{{ 'password'|t|capitalize }}" required="" autocomplete="current-password" class="form-control">
</div>
{% if option('force_remember_cookie') %}
<input type="hidden" name="remember_me" value='1' id="remember_me checkbox1" type="checkbox">
{% else %}
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember_me" value="1" id="remember_me checkbox1">
<label class="form-check-label" for="checkbox1">{{ 'Stay connected'|t }}</label>
</div>
</div>
{% endif %}
<input type="submit" name="login" class="btn btn-block btn-lg btn-success" value="{{ 'Login'|t }}">
</form>
{% if error %}
<div id="err" class="alert alert-danger m-3" role="alert">
<h4 class="alert-heading">{{ error.text|t }}</h4>
<p>{{ 'Error'|t}} {{ 'code'|t}} {{ error.code }}. {{ 'Check the entered credentials and make sure they are correct'|t }}.</p>
<img src='{{ urlsoftware }}/resources/images/{{ error_image }}'></img>
</div>
{% endif %}
</div>
<br><br>
{% block footer %}
{% endblock %}
{% endblock %}

View File

@ -0,0 +1,59 @@
{% extends "base.html" %}
{% block content %}
<br>
<div class="text-center">
<p>{{ 'Are you available in case of alert?'|t }}</p>
<button class="btn btn-success">{{ 'Activate'|t }}</button>
<button class="btn btn-danger">{{ 'Deactivate'|t }}</button>
</div>
<br>
<br>
<img alt="VVF" src="./resources/images/owner.png" width="150"
style="display: block; margin-left: auto; margin-right: auto;">
<br>
<br>
<table style="width:100%">
<tr class="tHead">
<th>{{ 'Name'|t }}</th>
<th>{{ 'Available'|t }}</th>
{% if user.full_viewer %}
<th>{{ 'Driver'|t }}</th>
<th>{{ 'Call'|t }}</th>
<th>{{ 'Write'|t }}</th>
<th>{{ 'Services'|t }}</th>
<th>{{ 'Availability Minutes'|t }}</th>
{# <th>{{ 'Other'|t }}</th> TODO: fix "Other" page #}
{% endif %}
</tr>
{% for row in query_results %}
<tr class="tBody">
<th>{{ username(row.id) }}</th>
<th>{{ yesOrNo(row.available) }}</th>
{% if user.full_viewer %}
<th>{{ yesOrNo(row.driver) }}</th>
{% if row.phone_number %}
<th><a href='tel:{{ row.phone_number }}'>Chiama</a></th>
{% else %}
<th></th>
{% endif %}
{% if row.phone_number %}
<th><a href='https://api.whatsapp.com/send?phone={{ row.phone_number }}&text=ALLERTA IN CORSO.%20Mettiti%20in%20contatto%20con%20{{ username(row.id)|url_encode }}'>Manda un messaggio</a></th>
{% else %}
<th></th>
{% endif %}
<th>{{ row.services }}</th>
<th>{{ row.availability_minutes }}</th>
{# <th>{{ 'Other'|t }}</th> TODO: fix "Other" page #}
{% endif %}
</tr>
{% endfor %}
</table>
<br><br>
<p style="text-align: center;">
<button class="btn btn-success btn-small">{{ 'Add user'|t }}</button>
</p>
<br>
<br>
{% endblock %}

View File

@ -0,0 +1,26 @@
{% extends "base.html" %}
{% block content %}
<br>
<img alt="VVF" src="./resources/images/owner.png" width="150"
style="display: block; margin-left: auto; margin-right: auto;">
<br>
<table style="width:100%">
<tr class="tHead">
<th>{{ 'Action'|t }}</th>
<th>{{ 'Interested'|t }}</th>
<th>{{ 'Made by'|t }}</th>
<th>{{ 'Datetime'|t }}</th>
</tr>
{% for row in query_results %}
<tr class="tBody">
<th>{{ row.action }}</th>
<th>{{ username(row.changed) }}</th>
<th>{{ username(row.editor) }}</th>
<th>{{ row.timestamp }}</th>
</tr>
{% endfor %}
</table>
<br>
<br>
{% endblock %}

View File

@ -0,0 +1 @@
{% extends "list.html" %}

View File

@ -0,0 +1,66 @@
{% extends "base.html" %}
{% block content %}
<br>
<img alt="VVF" src="./resources/images/owner.png" width="150"
style="display: block; margin-left: auto; margin-right: auto;">
<br>
<p style="text-align: center;">
<button class="btn btn-success btn-small">{{ 'Add service'|t }}</button>
</p>
<br>
<table style="width:100%">
<tr class="tHead">
<th>{{ 'Date'|t }}</th>
<th>{{ 'code'|t|capitalize }}</th>
<th>{{ 'Start time'|t }}</th>
<th>{{ 'End time'|t }}</th>
<th>{{ 'Chief'|t }}</th>
<th>{{ 'Drivers'|t }}</th>
<th>{{ 'Crew'|t }}</th>
<th>{{ 'Place'|t }}</th>
<th>{{ 'Notes'|t }}</th>
<th>{{ 'Type'|t }}</th>
{% if option('service_edit') %}
<th>{{ 'Edit'|t }}</th>
{% endif %}
{% if option('service_remove') %}
<th>{{ 'Remove'|t }}</th>
{% endif %}
</tr>
{% for row in query_results %}
<tr class="tBody">
<th>{{ row.date }}</th>
<th>{{ row.code }}</th>
<th>{{ row.beginning }}</th>
<th>{{ row.end }}</th>
<th>{{ username(row.chief) }}</th>
<th>{{ username_list(row.drivers) }}</th>
<th>{{ username_list(row.crew) }}</th>
<th>
{% if "#" in row.place %}
{% set mapImageID = row.place|split('#')[1] %}
{% set place = row.place|split('#')[0] %}
{% set place_lat = place|split(';')[0] %}
{% set place_lng = place|split(';')[1] %}
<img src="resources/images/map_cache/{{ mapImageID }}.png"></img><br>
{% endif %}
<a href="https://www.google.com/maps/search/?api=1&query={{ place_lat }},{{ place_lng }}" target="_blank">Apri la mappa in Google Maps</a><br>
<a href="https://www.openstreetmap.org/#map=18/{{ place_lat }}/{{ place_lng }}" target="_blank">Apri la mappa in OpenStreetMap</a><br>
Lat: <b>{{ place_lat }}</b><br>
Lng: <b>{{ place_lng }}</b><br>
</th>
<th>{{ row.notes }}</th>
<th>{{ row.type }}</th>
{% if option('service_edit') %}
<th><a href='edit_service.php?edit&id={{ row.id }}'>Modifica</a></th>
{% endif %}
{% if option('service_remove') %}
<th><a href='edit_service.php?delete&id={{ row.id }}'>Rimuovi</a></th>
{% endif %}
</tr>
{% endfor %}
</table>
<br>
<br>
{% endblock %}

View File

@ -0,0 +1,62 @@
{% extends "base.html" %}
{% block content %}
<br>
<img alt="VVF" src="./resources/images/owner.png" width="150"
style="display: block; margin-left: auto; margin-right: auto;">
<br>
<p style="text-align: center;">
<a id='add' href="edit_training.php?add">{{ 'Add training'|t }}</a>
</p>
<br>
<table style="width:100%">
<tr class="tHead">
<th>{{ 'Date'|t }}</th>
<th>{{ 'Name'|t }}</th>
<th>{{ 'Start time'|t }}</th>
<th>{{ 'End time'|t }}</th>
<th>{{ 'Chief'|t }}</th>
<th>{{ 'Crew'|t }}</th>
<th>{{ 'Place'|t }}</th>
<th>{{ 'Notes'|t }}</th>
{% if option('training_edit') %}
<th>{{ 'Edit'|t }}</th>
{% endif %}
{% if option('training_remove') %}
<th>{{ 'Remove'|t }}</th>
{% endif %}
</tr>
{% for row in query_results %}
<tr class="tBody">
<th>{{ row.date }}</th>
<th>{{ row.name }}</th>
<th>{{ row.beginning }}</th>
<th>{{ row.end }}</th>
<th>{{ username(row.chief) }}</th>
<th>{{ username_list(row.crew) }}</th>
<th>
{% if "#" in row.place %}
{% set mapImageID = row.place|split('#')[1] %}
{% set place = row.place|split('#')[0] %}
{% set place_lat = place|split(';')[0] %}
{% set place_lng = place|split(';')[1] %}
<img src="resources/images/map_cache/{{ mapImageID }}.png"></img><br>
{% endif %}
<a href="https://www.google.com/maps/search/?api=1&query={{ place_lat }},{{ place_lng }}" target="_blank">Apri la mappa in Google Maps</a><br>
<a href="https://www.openstreetmap.org/#map=18/{{ place_lat }}/{{ place_lng }}" target="_blank">Apri la mappa in OpenStreetMap</a><br>
Lat: <b>{{ place_lat }}</b><br>
Lng: <b>{{ place_lng }}</b><br>
</th>
<th>{{ row.notes }}</th>
{% if option('training_edit') %}
<th><a href='edit_training.php?edit&id={{ row.id }}'>Modifica</a></th>
{% endif %}
{% if option('training_remove') %}
<th><a href='edit_training.php?delete&id={{ row.id }}'>Rimuovi</a></th>
{% endif %}
</tr>
{% endfor %}
</table>
<br>
<br>
{% endblock %}

View File

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block content %}
<br>
<div id='details'>
TEST - TODO<br>
{{ user.id }}
</div>
{% endblock %}

View File

@ -56,7 +56,7 @@
{% if show_menu %}
{% block menu %}
{# Menu #}
<div class="topnav" id="topNavBar">
<div style="display: none" class="topnav" id="topNavBar">
<a href="{{ urlsoftware }}list.php" class="active">{{ 'Availability List'|t }}</a>
<a href="{{ urlsoftware }}services.php">{{ 'Services'|t }}</a>
<a href="{{ urlsoftware }}trainings.php">{{ 'Trainings'|t }}</a>
@ -71,8 +71,11 @@
<div class="alert alert-danger m-3" id="offline_alert" style="display: none" role="alert">
<b>{{ 'You are offline'|t }}.</b> {{ 'Last update'|t }}: <p style="display: inline" id="offline_update"></p>
</div>
<div id="jsDisabledNotice">
<p>{{ "JavaScript is disabled or it's not supported in your browser but it's required for using Allerta-VVF. If you want to continue, please enable JS <a href='?JSless=1'>or use the JS-less version</a>."|t|raw }}</p>
</div>
{# Content #}
<div id="content">
<div style="display: none" id="content">
{% block pjax_content %}
{% if message %}
<div class="alert alert-info m-3" role="alert">
@ -88,7 +91,7 @@
{% if show_footer %}
{% block footer %}
{# Footer #}
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2);">
<div id="footer" class="footer text-center p-3" style="background-color: rgba(0, 0, 0, 0.2); display: none;">
Allerta-VVF, software libero realizzato per {{ owner }}.<br>
<p style="margin-bottom: 0" id="frontend_version">Frontend versione </p>
</div>

View File

@ -1,3 +1,9 @@
<?php
require_once 'ui.php';
loadtemplate('trainings.html', ['title' => t('Trainings', false)]);
if($JSless){
$query_results = $db->select("SELECT * FROM `".DB_PREFIX."_trainings` ORDER BY date DESC, beginning desc");
} else {
$query_results = null;
}
loadtemplate('trainings.html', ['title' => t('Trainings', false), 'query_results' => $query_results]);
?>

View File

@ -123,5 +123,8 @@ return [
"Sun" => "Sun",
"Do you want to exclude holidays from schedules?" => "Do you want to exclude holidays from schedules?",
"Select all" => "Select all",
"Remove selections" => "Remove selections"
"Remove selections" => "Remove selections",
"JavaScript is disabled or it's not supported in your browser but it's required for using Allerta-VVF. If you want to continue, please enable JS <a href='?JSless=1'>or use the JS-less version</a>." => "JavaScript is disabled or it's not supported in your browser but it's required for using Allerta-VVF. If you want to continue, please enable JS <a href='?JSless=1'>or use the JS-less version</a>.",
"yes" => "yes",
"no" => "no"
];

View File

@ -123,5 +123,8 @@ return [
"Sun" => "Dom",
"Do you want to exclude holidays from schedules?" => "Vuoi escudere giorni festivi dalla programmazione degli orari?",
"Select all" => "Seleziona tutti",
"Remove selections" => "Rimuovi selezioni"
"Remove selections" => "Rimuovi selezioni",
"JavaScript is disabled or it's not supported in your browser but it's required for using Allerta-VVF. If you want to continue, please enable JS <a href='?JSless=1'>or use the JS-less version</a>." => "JavaScript è disabilitato o non è supportato dal tuo browser, ma è richiesto per utilizzare Allerta-VVF. Per continuare, abilita JS <a href='?JSless=1'>o usa la versione senza JS</a>.",
"yes" => "si",
"no" => "no"
];

View File

@ -19,10 +19,25 @@ $webpack_manifest = json_decode(
file_get_contents(realpath("resources/dist/assets-manifest.json")),
true
);
if(isset($_COOKIE["JSless"])){
$templates_dir = $_COOKIE["JSless"] ? "templates/JSless" : "templates";
$JSless = true;
} else {
$templates_dir = "templates";
$JSless = false;
}
if(isset($_GET["JSless"])){
setcookie("JSless", $_GET["JSless"] ? true : false, time() + (86400 * 365));
$templates_dir = $_GET["JSless"] ? "templates/JSless" : "templates";
$JSless = true;
}
try {
$loader = new \Twig\Loader\FilesystemLoader('templates');
$loader = new \Twig\Loader\FilesystemLoader($templates_dir);
} catch (Exception $e) {
$loader = new \Twig\Loader\FilesystemLoader('../templates');
$loader = new \Twig\Loader\FilesystemLoader('../'.$templates_dir);
}
$twig = new \Twig\Environment(
$loader, [
@ -51,6 +66,18 @@ $function_username = new \Twig\TwigFunction(
);
$twig->addFunction($function_username);
$function_username_list = new \Twig\TwigFunction(
'username_list', function ($id_list) {
global $user;
$user_list = [];
foreach (explode(",", $id_list) as $id) {
$user_list[] = $user->nameById($id);
}
return implode(", ", $user_list);
}
);
$twig->addFunction($function_username_list);
$function_resource = new \Twig\TwigFunction(
'resource', function ($file) {
global $webpack_manifest;
@ -88,6 +115,19 @@ $filter_minimize = new \Twig\TwigFilter(
}, ['is_safe' => ['html']]
);
$twig->addFilter($filter_minimize);
$function_yesOrNo = new \Twig\TwigFunction(
'yesOrNo', function ($bool, $onlyString=false) {
$string = t($bool ? "yes" : "no", false);
if($onlyString){
return $string;
} else {
$colour = $bool ? "green" : "red";
return "<p style='color: $colour'>$string</p>";
}
}, ['is_safe' => ['html']]
);
$twig->addFunction($function_yesOrNo);
p_stop();
$template = null;