Merge pull request #205 from allerta-vvf/master

[skip-ci] Updates
This commit is contained in:
Matteo Gheza 2021-04-30 14:43:40 +02:00 committed by GitHub
commit b1c0c65875
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1521 additions and 1138 deletions

17
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/server"
schedule:
interval: daily
# open-pull-requests-limit: 10
versioning-strategy: increase
allow:
- dependency-type: direct
- dependency-type: indirect
- package-ecosystem: npm
directory: "/server/resources"
schedule:
interval: daily
# open-pull-requests-limit: 10
versioning-strategy: increase

View File

@ -186,7 +186,7 @@ jobs:
run: |
ls
sudo wget -O deployment.phar https://github.com/dg/ftp-deployment/releases/download/v3.4.0/deployment.phar
echo '<?php $remotes = [ "staging" => [ "remote" => "${{ secrets.DEPLOY_URL }}", "sentry_env" => "staging" ] ]; ?>' > deployment_remotes.php
echo '<?php $remotes = [ "staging" => [ "remote" => "${{ secrets.DEPLOY_URL }}", "sentry_env" => "staging", "skip_composer_upload" => true ] ]; ?>' > deployment_remotes.php
cat deployment_remotes.php
ls
php deployment.phar deployment.php --section staging
@ -232,7 +232,7 @@ jobs:
run: |
ls
sudo wget -O deployment.phar https://github.com/dg/ftp-deployment/releases/download/v3.4.0/deployment.phar
echo '<?php $remotes = [ "production" => [ "remote" => "${{ secrets.DEPLOY_URL }}", "sentry_env" => "prod" ] ]; ?>' > deployment_remotes.php
echo '<?php $remotes = [ "production" => [ "remote" => "${{ secrets.DEPLOY_URL }}", "sentry_env" => "prod", "skip_composer_upload" => true ] ]; ?>' > deployment_remotes.php
cat deployment_remotes.php
ls
php deployment.phar deployment.php --section production

View File

@ -8,26 +8,6 @@ Allerta VVF is an unofficial **open source firefighters' management software** f
This is only a **development version**.
||it works :heavy_check_mark:|it's in beta :clock8:|it doesn't work :x:|
|:-:|:-:|:-:|:-:|
|Availability|:heavy_check_mark:|||
|"Services"|:heavy_check_mark:|||
|"Trainings"|:heavy_check_mark:|||
|Token check|:heavy_check_mark:|||
|Installation|:heavy_check_mark:|||
|CLI Installation|:heavy_check_mark:|||
|Docker Installation|:heavy_check_mark:|||
|Translation|:heavy_check_mark:|||
|User managament||:clock8:||
|Options|:heavy_check_mark:|||
|Logs|:heavy_check_mark:|||
|Graphs|||:x:|
|User profile editor|||:x:|
|Images||:clock8:||
|Api||:clock8:||
|Telegram bot||:clock8:||
|Twilio||:clock8:||
## Main repository
https://github.com/allerta-vvf/allerta-vvf

View File

@ -48,7 +48,6 @@ $baseConfig = [
vendor/nikic/fast-route/test
vendor/twig/twig/src/Node/Expression/Test
vendor/twig/twig/src/Test
vendor
*.lock
*.zip
',
@ -82,6 +81,10 @@ foreach ($remotes as $key => $value) {
if(isset($value["after"]) && $value["after"] === false){
$config[$key]["after"] = [];
}
if(isset($config[$key]["skip_composer_upload"]) && $config[$key]["skip_composer_upload"]){
$config[$key]["ignore"] .= "
vendor";
}
}
return $config;

View File

@ -2,6 +2,12 @@
"name": "allerta-vvf/allerta-vvf",
"description": "Un software di allertamento per i vvf",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/allerta-vvf/tiny-html-minifier"
}
],
"require": {
"twig/twig": "^3.2.1",
"delight-im/auth": "^8.3.0",
@ -12,7 +18,9 @@
"brick/phonenumber": "^0.2.2",
"sentry/sdk": "^3.1",
"maximebf/debugbar": "^1.16",
"ministryofweb/php-osm-tiles": "^2.0"
"azuyalabs/yasumi": "^2.3",
"ministryofweb/php-osm-tiles": "^2.0",
"jenstornell/tiny-html-minifier": "dev-master"
},
"license": "GPL-3.0-or-later",
"authors": [

178
server/composer.lock generated
View File

@ -4,8 +4,78 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "990b7f16635b967bd1cafc536774530d",
"content-hash": "ae7c144f55a8641ac68db46c3943d7ec",
"packages": [
{
"name": "azuyalabs/yasumi",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/azuyalabs/yasumi.git",
"reference": "e2f37e6de3b15642b83275a24bbfe101cd5c7791"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/azuyalabs/yasumi/zipball/e2f37e6de3b15642b83275a24bbfe101cd5c7791",
"reference": "e2f37e6de3b15642b83275a24bbfe101cd5c7791",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=7.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"fzaninotto/faker": "^1.9",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^8.5"
},
"suggest": {
"ext-calendar": "For calculating the date of Easter"
},
"type": "library",
"autoload": {
"psr-4": {
"Yasumi\\": "src/Yasumi/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sacha Telgenhof",
"email": "me@sachatelgenhof.com",
"role": "Maintainer"
}
],
"description": "The easy PHP Library for calculating holidays.",
"homepage": "https://www.yasumi.dev",
"keywords": [
"Bank",
"calculation",
"calendar",
"celebration",
"date",
"holiday",
"holidays",
"national",
"time"
],
"support": {
"docs": "https://www.yasumi.dev",
"issues": "https://github.com/azuyalabs/yasumi/issues",
"source": "https://github.com/azuyalabs/yasumi"
},
"funding": [
{
"url": "https://www.buymeacoffee.com/sachatelgenhof",
"type": "other"
}
],
"time": "2020-06-22T12:46:20+00:00"
},
{
"name": "brick/phonenumber",
"version": "0.2.2",
@ -393,16 +463,16 @@
},
{
"name": "giggsey/libphonenumber-for-php",
"version": "8.12.20",
"version": "8.12.22",
"source": {
"type": "git",
"url": "https://github.com/giggsey/libphonenumber-for-php.git",
"reference": "743585979ef96f2be123518c0a58083cf678bd47"
"reference": "dc9992c35e52235c36241ebb5ddc280ceebe3c09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/743585979ef96f2be123518c0a58083cf678bd47",
"reference": "743585979ef96f2be123518c0a58083cf678bd47",
"url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/dc9992c35e52235c36241ebb5ddc280ceebe3c09",
"reference": "dc9992c35e52235c36241ebb5ddc280ceebe3c09",
"shasum": ""
},
"require": {
@ -416,7 +486,7 @@
"pear/versioncontrol_git": "^0.5",
"phing/phing": "^2.7",
"php-coveralls/php-coveralls": "^1.0|^2.0",
"symfony/console": "^2.8|^3.0",
"symfony/console": "^2.8|^3.0|^v4.4|^v5.2",
"symfony/phpunit-bridge": "^4.2 || ^5"
},
"type": "library",
@ -462,7 +532,7 @@
"issues": "https://github.com/giggsey/libphonenumber-for-php/issues",
"source": "https://github.com/giggsey/libphonenumber-for-php"
},
"time": "2021-03-17T11:05:55+00:00"
"time": "2021-04-29T07:34:59+00:00"
},
{
"name": "giggsey/locale",
@ -574,16 +644,16 @@
},
{
"name": "guzzlehttp/psr7",
"version": "1.8.1",
"version": "1.8.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "35ea11d335fd638b5882ff1725228b3d35496ab1"
"reference": "dc960a912984efb74d0a90222870c72c87f10c91"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/35ea11d335fd638b5882ff1725228b3d35496ab1",
"reference": "35ea11d335fd638b5882ff1725228b3d35496ab1",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/dc960a912984efb74d0a90222870c72c87f10c91",
"reference": "dc960a912984efb74d0a90222870c72c87f10c91",
"shasum": ""
},
"require": {
@ -643,9 +713,9 @@
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/1.8.1"
"source": "https://github.com/guzzle/psr7/tree/1.8.2"
},
"time": "2021-03-21T16:25:00+00:00"
"time": "2021-04-26T09:17:50+00:00"
},
{
"name": "http-interop/http-factory-guzzle",
@ -760,6 +830,47 @@
},
"time": "2021-02-22T10:52:38+00:00"
},
{
"name": "jenstornell/tiny-html-minifier",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/allerta-vvf/tiny-html-minifier.git",
"reference": "5e997f570fe637a4c1c996bdcc8f9beaa26940a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/allerta-vvf/tiny-html-minifier/zipball/5e997f570fe637a4c1c996bdcc8f9beaa26940a2",
"reference": "5e997f570fe637a4c1c996bdcc8f9beaa26940a2",
"shasum": ""
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"Minifier\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Jens Törnell",
"email": "webblayout@gmail.com"
}
],
"description": "Minify HTML in PHP with just a single class",
"keywords": [
"html",
"minifier",
"minify"
],
"support": {
"source": "https://github.com/allerta-vvf/tiny-html-minifier/tree/master"
},
"time": "2021-04-27T22:20:43+00:00"
},
{
"name": "maximebf/debugbar",
"version": "v1.16.5",
@ -884,26 +995,26 @@
"source": {
"type": "git",
"url": "https://github.com/nikic/FastRoute.git",
"reference": "7723b1dcb0084baaa1f36df25d5720b7b85b62d6"
"reference": "b5543adef5e16738471a52fdf55ff802edf1141d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/7723b1dcb0084baaa1f36df25d5720b7b85b62d6",
"reference": "7723b1dcb0084baaa1f36df25d5720b7b85b62d6",
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/b5543adef5e16738471a52fdf55ff802edf1141d",
"reference": "b5543adef5e16738471a52fdf55ff802edf1141d",
"shasum": ""
},
"require": {
"php": ">=7.1.0"
"php": ">=7.4.0"
},
"require-dev": {
"doctrine/coding-standard": "^6.0 || ^7.0",
"phpbench/phpbench": "^0.16.9",
"doctrine/coding-standard": "^9.0",
"phpbench/phpbench": "^1.0@beta",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^7.5 || ^8.5"
"phpunit/phpunit": "^9.5"
},
"default-branch": true,
"type": "library",
@ -939,7 +1050,7 @@
"issues": "https://github.com/nikic/FastRoute/issues",
"source": "https://github.com/nikic/FastRoute/tree/master"
},
"time": "2020-09-28T10:21:28+00:00"
"time": "2021-04-27T09:57:16+00:00"
},
{
"name": "php-http/client-common",
@ -1692,16 +1803,16 @@
},
{
"name": "sentry/sentry",
"version": "3.2.0",
"version": "3.2.1",
"source": {
"type": "git",
"url": "https://github.com/getsentry/sentry-php.git",
"reference": "899b0de58c1e01feb54829b3094af74252aff385"
"reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/899b0de58c1e01feb54829b3094af74252aff385",
"reference": "899b0de58c1e01feb54829b3094af74252aff385",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f",
"reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f",
"shasum": ""
},
"require": {
@ -1780,7 +1891,7 @@
],
"support": {
"issues": "https://github.com/getsentry/sentry-php/issues",
"source": "https://github.com/getsentry/sentry-php/tree/3.2.0"
"source": "https://github.com/getsentry/sentry-php/tree/3.2.1"
},
"funding": [
{
@ -1792,7 +1903,7 @@
"type": "custom"
}
],
"time": "2021-03-03T11:54:34+00:00"
"time": "2021-04-06T07:55:41+00:00"
},
{
"name": "spatie/array-to-xml",
@ -2896,16 +3007,16 @@
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.5.8",
"version": "3.6.0",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4"
"reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4",
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
"reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
"shasum": ""
},
"require": {
@ -2948,13 +3059,14 @@
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
},
"time": "2020-10-23T02:01:07+00:00"
"time": "2021-04-09T00:54:41+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"nikic/fast-route": 20
"nikic/fast-route": 20,
"jenstornell/tiny-html-minifier": 20
},
"prefer-stable": false,
"prefer-lowest": false,

View File

@ -403,6 +403,7 @@ class user
private $profile_names = null;
public $auth = null;
public $authenticated = false;
public $holidays = null;
public function __construct($database, $tools)
{
@ -432,6 +433,7 @@ class user
$this->authenticated = $this->auth->isLoggedIn();
$this->profile_names = $this->database->exec("SELECT `id`, `name` FROM `%PREFIX%_profiles`;", true);
$this->user_names = $this->database->exec("SELECT `id`, `username` FROM `%PREFIX%_users`;", true);
$this->holidays = Yasumi\Yasumi::create($this->database->get_option("holidays_provider") ?: "USA", date("Y"), $this->database->get_option("holidays_language") ?: "en_US");
}
public function authenticated()
@ -504,10 +506,16 @@ class user
return $name;
}
public function hidden()
public function hidden($user = null)
{
$profiles = $this->database->exec("SELECT `name` FROM `%PREFIX%_profiles` WHERE hidden = 1;", true);
return $profiles;
if(is_null($user)){
$user = $this->auth->getUserId();
}
$result = $this->database->exec("SELECT `hidden` FROM `%PREFIX%_profiles` WHERE id = :id;", true, [":id" => $user]);
if(isset($result[0]) && isset($result[0]["hidden"])){
return boolval($result[0]["hidden"]);
}
return false;
}
public function available($name)
@ -599,16 +607,18 @@ class user
if(is_null($editor)){
$editor = $changed;
}
if($this->database->get_option("log_save_ip")){
$ip = $this->tools->get_ip();
} else {
$ip = null;
if(!$this->hidden($editor)){
if($this->database->get_option("log_save_ip")){
$ip = $this->tools->get_ip();
} else {
$ip = null;
}
$source_type = defined("REQUEST_USING_API") ? "api" : "web";
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? mb_strimwidth($_SERVER['HTTP_USER_AGENT'], 0, 200, "...") : null;
$params = [":action" => $action, ":changed" => $changed, ":editor" => $editor, ":timestamp" => $timestamp, ":ip" => $ip, "source_type" => $source_type, "user_agent" => $user_agent];
$sql = "INSERT INTO `%PREFIX%_log` (`id`, `action`, `changed`, `editor`, `timestamp`, `ip`, `source_type`, `user_agent`) VALUES (NULL, :action, :changed, :editor, :timestamp, :ip, :source_type, :user_agent)";
$this->database->exec($sql, false, $params);
}
$source_type = defined("REQUEST_USING_API") ? "api" : "web";
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? mb_strimwidth($_SERVER['HTTP_USER_AGENT'], 0, 200, "...") : null;
$params = [":action" => $action, ":changed" => $changed, ":editor" => $editor, ":timestamp" => $timestamp, ":ip" => $ip, "source_type" => $source_type, "user_agent" => $user_agent];
$sql = "INSERT INTO `%PREFIX%_log` (`id`, `action`, `changed`, `editor`, `timestamp`, `ip`, `source_type`, `user_agent`) VALUES (NULL, :action, :changed, :editor, :timestamp, :ip, :source_type, :user_agent)";
$this->database->exec($sql, false, $params);
$this->tools->profiler_stop();
}

View File

@ -36,7 +36,12 @@ $cronJobDateTime = [
];
$start = $database->get_option("cron_job_enabled") && ((isset($_POST['cron']) && $_POST['cron'] == "cron_job-".$database->get_option("cron_job_code")) || (isset($_SERVER['HTTP_CRON']) && $_SERVER['HTTP_CRON'] == "cron_job-".$database->get_option("cron_job_code")));
$start_reset = $execDateTime == $cronJobDateTime;
$start_reset = ( $execDateTime["day"] == $cronJobDateTime["day"] &&
$execDateTime["day"] == $cronJobDateTime["day"] &&
$execDateTime["month"] == $cronJobDateTime["month"] &&
$execDateTime["year"] == $cronJobDateTime["year"] &&
$execDateTime["hour"] == $cronJobDateTime["hour"] &&
$execDateTime["minutes"] - $cronJobDateTime["minutes"] < 5 );
$action = "Availability Minutes ";
if($start) {
@ -96,6 +101,11 @@ if($start) {
];
$id = $row["id"];
$user_id = $row["user"];
$selected_holidays = json_decode($row["holidays"]);
$selected_holidays_dates = [];
foreach ($selected_holidays as $holiday){
$selected_holidays_dates[] = $user->holidays->getHoliday($holiday)->format('Y-m-d');
}
foreach ($row["schedules"] as $key => $value) {
$schedule = [
"day" => (int) $value[0]+1,
@ -115,7 +125,7 @@ if($start) {
$now["minutes"] - $schedule["minutes"] <= 30
){
if(!in_array($user_id,$schedules_users)) $schedules_users[] = $user_id;
if($schedule["hour"] == $last_exec["hour"] ? $schedule["minutes"] !== $last_exec["minutes"] : true){
if($schedule["hour"] == $last_exec["hour"] ? $schedule["minutes"] !== $last_exec["minutes"] : true && !in_array(date('Y-m-d'), $selected_holidays_dates)){
$last_exec_new = $schedule["day"].";".sprintf("%02d", $schedule["hour"]).":".sprintf("%02d", $schedule["minutes"]);
$database->exec("UPDATE `%PREFIX%_schedules` SET `last_exec` = :last_exec WHERE `id` = :id;", false, [":id" => $id, ":last_exec" => $last_exec_new]);
$database->exec("UPDATE `%PREFIX%_profiles` SET available = '1', availability_last_change = 'cron' WHERE `id` = :user_id;", false, [":user_id" => $user_id]);

View File

@ -1,3 +0,0 @@
<?php
require_once 'ui.php';
loadtemplate('graphics.html', ['title' => 'Graphics']);

View File

@ -424,6 +424,7 @@ CREATE TABLE `".$prefix."_schedules` (
`user` INT NOT NULL,
`profile_name` VARCHAR(500) NOT NULL DEFAULT 'default',
`schedules` VARCHAR(10000) NULL DEFAULT NULL,
`holidays` VARCHAR(10000) NULL DEFAULT NULL,
`last_exec` VARCHAR(7) NULL DEFAULT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
@ -498,6 +499,8 @@ function initOptions($name, $visible, $developer, $password, $report_email, $own
'use_location_picker' => 1,
'force_language' => 0,
'force_remember_cookie' => 0,
'holidays_provider' => 'USA',
'holidays_language' => 'en_US',
'messages' => "{}"
];
$query = "";

View File

@ -52,8 +52,13 @@ if(!empty($result)){
$hour = $hour[0] == "0" ? substr($hour,1) : $hour;
$old_schedules[$schedule[0]][$hour] = true;
}
$old_holidays = json_decode($result[0]["holidays"]);
if(is_null($old_holidays)){
$old_holidays = [];
}
} else {
$old_schedules = [];
$old_holidays = [];
}
?>
<style>
@ -127,6 +132,35 @@ endif;
</tbody>
</table>
<br>
<?php
$holidays_selection_question = t("Do you want to exclude holidays from schedules?",false);
$holidays_select_all = t("Select all", false);
$holidays_select_none = t("Remove selections", false);
echo(<<<EOL
<div class="form-group">
<label>{$holidays_selection_question}</label>
<a onclick="$('.holiday_check').prop('checked', true);" class="text-primary">{$holidays_select_all}</a> / <a onclick="$('.holiday_check').prop('checked', false);" class="text-primary">{$holidays_select_none}</a>
EOL);
$i = 0;
foreach ($user->holidays as $holiday) {
$i++;
$holiday_name = $holiday->getName();
$holiday_shortname = $holiday->shortName;
$is_holiday_selected = in_array($holiday_shortname, $old_holidays) ? "checked" : "";
echo(<<<EOT
<div class="form-check">
<input class="form-check-input holiday_check" name="holiday_check" type="checkbox" value="{$holiday_shortname}" id="holidayCheckbox{$i}" {$is_holiday_selected}>
<label class="form-check-label" for="holidayCheckbox{$i}">
{$holiday_name} ({$holiday})
</label>
</div>
EOT);
}
echo("</div>");
?>
<script>
function init_modal() {
<?php if($orienation == "landscape"){ ?>$(".modal-dialog").css("max-width", "99%");<?php } ?>
@ -218,11 +252,13 @@ function extractSelections(){
function submit_changes(){
let hours = extractSelections();
let holidays = $.map($('input[name="holiday_check"]:checked'), function(c){return c.value; });
$.ajax({
url: "resources/ajax/ajax_availability_schedule.php",
method: "POST",
data: {
hours: hours
hours: hours,
holidays: holidays
},
success: function (data) {
console.log(data);

View File

@ -7,15 +7,17 @@ $user_id = $user->auth->getUserId();
$result = $database->exec("SELECT * FROM `%PREFIX%_schedules` WHERE `user`={$user_id};", true);
if(!empty($result)){
$result[0]["schedules"] = json_decode($result[0]["schedules"]);
$result[0]["holidays"] = json_decode($result[0]["holidays"]);
}
if(isset($_POST["hours"])){
$hours = (string) json_encode($_POST["hours"]);
echo($hours);
$holidays = (string) json_encode($_POST["holidays"]);
echo($hours."-".$holidays);
if(!empty($result)){
$database->exec("UPDATE `%PREFIX%_schedules` SET `schedules` = :schedules WHERE `id` = :id;", false, [":id" => $result[0]["id"], ":schedules" => $hours]);
$database->exec("UPDATE `%PREFIX%_schedules` SET schedules = :schedules, holidays = :holidays WHERE `id` = :id;", false, [":id" => $result[0]["id"], ":schedules" => $hours, ":holidays" => $holidays]);
} else {
$database->exec("INSERT INTO `%PREFIX%_schedules` (`user`, `schedules`) VALUES (:user, :schedules);", false, [":user" => $user_id, ":schedules" => $hours]);
$database->exec("INSERT INTO `%PREFIX%_schedules` (`user`, `schedules`, `holidays`) VALUES (:user, :schedules, :holidays);", false, [":user" => $user_id, ":schedules" => $hours, ":holidays" => $holidays]);
}
} else {
echo(json_encode(empty($result) ? [] : $result[0]));

View File

@ -6,11 +6,9 @@ $user->online_time_update();
$result = $database->exec("SELECT * FROM `%PREFIX%_profiles` ORDER BY available DESC, chief DESC, services ASC, availability_minutes ASC, name ASC;", true);
$hidden = $user->hidden();
$response = [];
foreach($result as $row){
if(!in_array($row['name'], $hidden) && ($row['hidden'] == 0 && $row['disabled'] == 0)){
if(!$user->hidden($row["id"])){
if($user->requireRole(Role::FULL_VIEWER)){
$name = $user->nameById($row["id"]);
$name_encoded = urlencode($user->name());

View File

@ -6,8 +6,6 @@ $user->online_time_update();
$result = $database->exec("SELECT * FROM `%PREFIX%_log` ORDER BY `timestamp` DESC", true);
$hidden = $user->hidden();
//https://stackoverflow.com/a/2524761
function isValidTimeStamp($timestamp)
{
@ -18,31 +16,29 @@ function isValidTimeStamp($timestamp)
$response = [];
foreach($result as $row){
if(!in_array($row['changed'], $hidden) OR in_array($user->name(), $hidden)){
if(isValidTimeStamp($row["timestamp"])){
$date = new DateTime();
$date->setTimestamp($row["timestamp"]);
$date = $date->format('Y-m-d H:i:s');
} else {
$date = $row["timestamp"];
}
if(!is_null($row["changed"])){
$changedName = $user->nameById($row["changed"]);
} else {
$changedName = "N/A";
}
if(!is_null($row["editor"])){
$editorName = $user->nameById($row["editor"]);
} else {
$editorName = "N/A";
}
$response[] = [
t($row["action"], false),
$changedName,
$editorName,
$date
];
if(isValidTimeStamp($row["timestamp"])){
$date = new DateTime();
$date->setTimestamp($row["timestamp"]);
$date = $date->format('Y-m-d H:i:s');
} else {
$date = $row["timestamp"];
}
if(!is_null($row["changed"])){
$changedName = $user->nameById($row["changed"]);
} else {
$changedName = "N/A";
}
if(!is_null($row["editor"])){
$editorName = $user->nameById($row["editor"]);
} else {
$editorName = "N/A";
}
$response[] = [
t($row["action"], false),
$changedName,
$editorName,
$date
];
}
$tools->ajax_page_response($response);
?>

File diff suppressed because it is too large Load Diff

View File

@ -11,52 +11,52 @@
"author": "",
"license": "GPL3",
"dependencies": {
"@babel/core": "^7.12.16",
"@babel/plugin-transform-runtime": "^7.12.15",
"@babel/preset-env": "^7.12.16",
"@babel/core": "^7.14.0",
"@babel/plugin-transform-runtime": "^7.13.15",
"@babel/preset-env": "^7.14.0",
"@fiverr/afterbuild-webpack-plugin": "^1.0.0",
"@fortawesome/fontawesome-free": "^5.15.2",
"@sentry/browser": "^6.1.0",
"@sentry/tracing": "^6.1.0",
"@sentry/webpack-plugin": "^1.14.0",
"@fortawesome/fontawesome-free": "^5.15.3",
"@sentry/browser": "^6.3.4",
"@sentry/tracing": "^6.3.4",
"@sentry/webpack-plugin": "^1.15.1",
"babel-loader": "^8.2.2",
"bootstrap": "^4.6.0",
"bootstrap-datepicker": "^1.9.0",
"bootstrap-toggle": "^2.2.2",
"clean-webpack-plugin": "^3.0.0",
"colors": "^1.4.0",
"copy-webpack-plugin": "^6.4.1",
"css-loader": "^4.3.0",
"copy-webpack-plugin": "^8.1.1",
"css-loader": "^5.2.4",
"datatables.net-bs4": "^1.10.23",
"datatables.net-buttons-bs4": "^1.6.5",
"datatables.net-plugins": "^1.10.22",
"datatables.net-plugins": "^1.10.23",
"datatables.net-responsive-bs4": "^2.2.7",
"expose-loader": "^1.0.3",
"expose-loader": "^2.0.0",
"file-loader": "^6.2.0",
"font-awesome": "^4.7.0",
"glob": "^7.1.6",
"howler": "^2.2.1",
"jquery": "^3.5.1",
"jquery": "^3.6.0",
"jquery-pjax": "^2.0.1",
"jszip": "^3.6.0",
"leaflet": "^1.7.1",
"leaflet.locatecontrol": "^0.72.2",
"pdfmake": "^0.1.70",
"leaflet.locatecontrol": "^0.73.0",
"pdfmake": "^0.1.71",
"popper.js": "^1.16.1",
"sass": "^1.32.7",
"sass-loader": "^10.1.1",
"style-loader": "^1.3.0",
"sass": "^1.32.12",
"sass-loader": "^11.0.1",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^4.2.3",
"time-input-polyfill": "^1.0.9",
"time-input-polyfill": "^1.0.10",
"toastr": "^2.1.4",
"webpack": "^5.24.2",
"webpack": "^5.36.1",
"webpack-assets-manifest": "^3.1.1",
"webpack-inject-plugin": "^1.5.5",
"webpack-merge": "^5.7.3"
},
"devDependencies": {
"speed-measure-webpack-plugin": "^1.4.2",
"webpack-bundle-analyzer": "^4.4.0",
"webpack-cli": "^4.5.0"
"speed-measure-webpack-plugin": "^1.5.0",
"webpack-bundle-analyzer": "^4.4.1",
"webpack-cli": "^4.6.0"
}
}

View File

@ -1,3 +1,4 @@
{% apply minimize %}
<!DOCTYPE html>
<html lang="it">
<head>
@ -54,24 +55,23 @@
<body>
{% if show_menu %}
{% block menu %}
<!-- Menu -->
{# Menu #}
<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 }}graphics.php" #}>{{ 'Graphics'|t }}</a>
<a style="float: right;" id="logout">{{ 'Hi, %s.'|t|format(user.name) }} <b
onclick="location.href='{{ urlsoftware }}logout.php';">{{ 'Logout'|t }}</b></a>
<a class="pjax_disable icon" id="menuButton"></a>
</div>
<!-- /Menu -->
{# /Menu #}
{% endblock %}
{% endif %}
<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>
<!-- Content -->
{# Content #}
<div id="content">
{% block pjax_content %}
{% if message %}
@ -83,17 +83,18 @@
{% block content %}{% endblock %}
{% endblock %}
</div>
<!-- /Content -->
{# /Content #}
{% if enable_debug_bar %}{{ debug_bar|raw }}{% endif %}
{% if show_footer %}
{% block footer %}
<!-- Footer -->
{# Footer #}
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2);">
Allerta-VVF, software libero realizzato per {{ owner }}.<br>
<p style="margin-bottom: 0" id="frontend_version">Frontend versione </p>
</div>
<!-- /Footer -->
{# /Footer #}
{% endblock %}
{% endif %}
</body>
</html>
</html>
{% endapply %}

View File

@ -1,15 +0,0 @@
{% 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>
<div id="list" hidden></div>
<b>TODO</b>
<script>
alert("TODO");
</script>
<br>
<br>
{% endblock %}

View File

@ -104,7 +104,7 @@
<th>{{ 'Write'|t }}</th>
<th>{{ 'Services'|t }}</th>
<th>{{ 'Availability Minutes'|t }}</th>
<!-- <th>{{ 'Other'|t }}</th> TODO: fix "Other" page -->
{# <th>{{ 'Other'|t }}</th> TODO: fix "Other" page #}
{% endif %}
</tr>
</thead>

View File

@ -12,7 +12,6 @@ return [
"Services" => "Services",
"Trainings" => "Trainings",
"Logs" => "Logs",
"Graphics" => "Graphics",
"Technical Support" => "Technical Support",
"Hi, %s." => "Hi, %s.",
"Logout" => "Logout",
@ -121,5 +120,8 @@ return [
"Thu" => "Thu",
"Fri" => "Fri",
"Sat" => "Sat",
"Sun" => "Sun"
"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"
];

View File

@ -12,7 +12,6 @@ return [
"Services" => "Interventi",
"Trainings" => "Esercitazioni",
"Logs" => "Logs",
"Graphics" => "Grafici",
"Technical Support" => "Supporto Tecnico",
"Hi, %s." => "Ciao, %s.",
"Logout" => "Logout",
@ -121,5 +120,8 @@ return [
"Thu" => "Gio",
"Fri" => "Ven",
"Sat" => "Sab",
"Sun" => "Dom"
"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"
];

View File

@ -22,18 +22,20 @@ try {
} catch (Exception $e) {
$loader = new \Twig\Loader\FilesystemLoader('../templates');
}
$filter = new \Twig\TwigFilter(
't', function ($string) {
global $translations;
return $translations->translate($string);
}
);
$twig = new \Twig\Environment(
$loader, [
//'cache' => 'compilation'
]
);
$twig->addFilter($filter);
$filter_translate = new \Twig\TwigFilter(
't', function ($string) {
global $translations;
return $translations->translate($string);
}
);
$twig->addFilter($filter_translate);
$function_option = new \Twig\TwigFunction(
'option', function ($option) {
global $database;
@ -41,6 +43,7 @@ $function_option = new \Twig\TwigFunction(
}
);
$twig->addFunction($function_option);
$function_username = new \Twig\TwigFunction(
'username', function ($id) {
global $user;
@ -48,6 +51,7 @@ $function_username = new \Twig\TwigFunction(
}
);
$twig->addFunction($function_username);
$function_resource = new \Twig\TwigFunction(
'resource', function ($file) {
global $webpack_manifest;
@ -55,6 +59,20 @@ $function_resource = new \Twig\TwigFunction(
}
);
$twig->addFunction($function_resource);
$filter_minimize = new \Twig\TwigFilter(
'minimize', function ($content) {
if(isset($_REQUEST["skip_minify"])){
return $content;
} else {
return Minifier\TinyMinify::html($content, [
'collapse_whitespace' => true,
'disable_comments' => true,
]);
}
}, ['is_safe' => ['html']]
);
$twig->addFilter($filter_minimize);
p_stop();
$template = null;