Code translations

This commit is contained in:
Matteo Gheza 2020-11-25 11:29:19 +01:00
parent 5006090ec1
commit c7c89acc7f
21 changed files with 247 additions and 304 deletions

View File

@ -1,4 +0,0 @@
<?php
require_once 'ui.php';
loadtemplate('accessdenied.html', ['title' => 'Access Denied']);
?>

View File

@ -90,13 +90,13 @@ $dispatcher = FastRoute\simpleDispatcher(
'POST', '/user', function ($vars) {
requireToken();
global $user, $user_info;
$capo = isset($_POST["capo"]) ? $_POST["capo"]==1 : false;
$autista = isset($_POST["autista"]) ? $_POST["autista"]==1 : false;
$chief = isset($_POST["chief"]) ? $_POST["chief"]==1 : false;
$driver = isset($_POST["driver"]) ? $_POST["driver"]==1 : false;
$hidden = isset($_POST["hidden"]) ? $_POST["hidden"]==1 : false;
$disabled = isset($_POST["disabled"]) ? $_POST["disabled"]==1 : false;
if(isset($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $_POST["birthday"])) {
try{
$userId = $user->add_user($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $_POST["birthday"], $capo, $autista, $hidden, $disabled, $user_info["id"]);
$userId = $user->add_user($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $_POST["birthday"], $chief, $driver, $hidden, $disabled, $user_info["id"]);
} catch (\Delight\Auth\InvalidEmailException $e) {
return ["status" => "error", "message" => "Invalid email address"];
} catch (\Delight\Auth\InvalidPasswordException $e) {

View File

@ -23,62 +23,18 @@ class tools
$this->profiler_enabled = $profiler_enabled;
}
public function validate_form_data($data, $noempty=true, $value=null)
public function validate_form($data, $expected_value=null, $data_source=null)
{
if(!is_array($data) && isset($data) && !empty($data)) {
if(substr($data, 0, 6) == '$post-') {
$data = substr($data, 6);
if(isset($_POST[$data])) {
$data = $_POST[$data];
}
}
}
if(is_array($data)) {
if(empty($data)) {
$continue = false;
return false;
} else {
$continue = true;
}
if($continue) {
foreach($data as $key=>$value){
if(!is_array($value) && isset($value) && !empty($value)) {
if(substr($value, 0, 6) == '$post-') {
$value = substr($value, 6);
if(isset($_POST[$value])) {
$value = $_POST[$value];
}
}
}
if($continue) {
if(!is_array($value)) {
bdump($value);
bdump("_");
$validazione = $this->validate_form_data($value, $noempty, $value);
if(!$validazione) {
$continue = false;
return false;
}
}
}
}
if($continue) {
return true;
}
}
} else if(isset($data)) {
if(!empty($data)) {
if(!is_null($value)) {
return $value == $data;
} else {
bdump($data);
return true;
}
} else {
return false;
if(is_array($data)){
foreach($data as $element){
if (!$this->validate_form($element, $data_source, $expected_value)) return false;
}
return true;
} else {
return false;
if(is_null($data_source) || !is_array($data_source)){
$data_source = $_POST;
}
return !is_null($data) && isset($data_source[$data]) && !is_null($data_source[$data]) && (!is_null($expected_value) ? $data_source[$data] == $expected_value : true);
}
}
@ -363,17 +319,17 @@ class database
$this->exec($sql, false);
}
public function add_service($data, $codice, $uscita, $rientro, $capo, $autisti, $personale, $luogo, $note, $tipo, $increment, $inserted_by)
public function add_service($date, $code, $beginning, $end, $chief, $drivers, $crew, $place, $notes, $type, $increment, $inserted_by)
{
$autisti = implode(",", $autisti);
bdump($autisti);
$personale = implode(",", $personale);
bdump($personale);
$drivers = implode(",", $drivers);
bdump($drivers);
$crew = implode(",", $crew);
bdump($crew);
$increment = implode(",", $increment);
bdump($increment);
$data = date('Y-m-d H:i:s', strtotime($data));
$sql = "INSERT INTO `%PREFIX%_services` (`id`, `data`, `codice`, `uscita`, `rientro`, `capo`, `autisti`, `personale`, `luogo`, `note`, `tipo`, `increment`, `inserted_by`) VALUES (NULL, :data, :codice, :uscita, :rientro, :capo, :autisti, :personale, :luogo, :note, :tipo, :increment, :inserted_by);";
$this->exec($sql, false, [":data" => $data, ":codice" => $codice, "uscita" => $uscita, ":rientro" => $rientro, ":capo" => $capo, ":autisti" => $autisti, ":personale" => $personale, ":luogo" => $luogo, ":note" => $note, ":tipo" => $tipo, ":increment" => $increment, ":inserted_by" => $inserted_by]);
$date = date('Y-m-d H:i:s', strtotime($date));
$sql = "INSERT INTO `%PREFIX%_services` (`id`, `date`, `code`, `beginning`, `end`, `chief`, `drivers`, `crew`, `place`, `notes`, `type`, `increment`, `inserted_by`) VALUES (NULL, :date, :code, :beginning, :end, :chief, :drivers, :crew, :place, :notes, :type, :increment, :inserted_by);";
$this->exec($sql, false, [":date" => $date, ":code" => $code, "beginning" => $beginning, ":end" => $end, ":chief" => $chief, ":drivers" => $drivers, ":crew" => $crew, ":place" => $place, ":notes" => $notes, ":type" => $type, ":increment" => $increment, ":inserted_by" => $inserted_by]);
$this->increment($increment);
}
@ -384,21 +340,21 @@ class database
}
public function change_service($id, $data, $codice, $uscita, $rientro, $capo, $autisti, $personale, $luogo, $note, $tipo, $increment, $inserted_by)
public function change_service($id, $date, $code, $beginning, $end, $chief, $drivers, $crew, $place, $notes, $type, $increment, $inserted_by)
{
$this->remove_service($id); // TODO: update, instead of removing and re-adding (with another id)
$this->add_service($data, $codice, $uscita, $rientro, $capo, $autisti, $personale, $luogo, $note, $tipo, $increment, $inserted_by);
$this->add_service($date, $code, $beginning, $end, $chief, $drivers, $crew, $place, $notes, $type, $increment, $inserted_by);
}
public function add_training($data, $name, $start_time, $end_time, $capo, $personale, $luogo, $note, $increment, $inserted_by)
public function add_training($date, $name, $start_time, $end_time, $chief, $crew, $place, $notes, $increment, $inserted_by)
{
$personale = implode(",", $personale);
bdump($personale);
$crew = implode(",", $crew);
bdump($crew);
$increment = implode(",", $increment);
bdump($increment);
$data = date('Y-m-d H:i:s', strtotime($data));
$sql = "INSERT INTO `%PREFIX%_trainings` (`id`, `data`, `name`, `inizio`, `fine`, `capo`, `personale`, `luogo`, `note`, `increment`, `inserted_by`) VALUES (NULL, :data, :name, :start_time, :end_time, :capo, :personale, :luogo, :note, :increment, :inserted_by);";
$this->exec($sql, false, [":data" => $data, ":name" => $name, "start_time" => $start_time, ":end_time" => $end_time, ":capo" => $capo, ":personale" => $personale, ":luogo" => $luogo, ":note" => $note, ":increment" => $increment, ":inserted_by" => $inserted_by]);
$date = date('Y-m-d H:i:s', strtotime($date));
$sql = "INSERT INTO `%PREFIX%_trainings` (`id`, `date`, `name`, `beginning`, `end`, `chief`, `crew`, `place`, `notes`, `increment`, `inserted_by`) VALUES (NULL, :date, :name, :start_time, :end_time, :chief, :crew, :place, :notes, :increment, :inserted_by);";
$this->exec($sql, false, [":date" => $date, ":name" => $name, "start_time" => $start_time, ":end_time" => $end_time, ":chief" => $chief, ":crew" => $crew, ":place" => $place, ":notes" => $notes, ":increment" => $increment, ":inserted_by" => $inserted_by]);
$this->increment_trainings($increment);
}
@ -410,11 +366,11 @@ class database
}
public function change_training($id, $data, $name, $start_time, $end_time, $capo, $personale, $luogo, $note, $increment, $inserted_by)
public function change_training($id, $date, $name, $start_time, $end_time, $chief, $crew, $place, $notes, $increment, $inserted_by)
{
$this->remove_training($id); // TODO: update, instead of removing and re-adding (with another id)
bdump("removed");
$this->add_training($data, $name, $start_time, $end_time, $capo, $personale, $luogo, $note, $increment, $inserted_by);
$this->add_training($date, $name, $start_time, $end_time, $chief, $crew, $place, $notes, $increment, $inserted_by);
}
}
@ -464,11 +420,11 @@ class user
if(!$this->authenticated()) {
if($this->database->getOption("intrusion_save")) {
if($this->database->getOption("intrusion_save_info")) {
$params = [":page" => $this->tools->get_page_url(), ":ip" => $this->tools->get_ip(), ":data" => date("d/m/Y"), ":ora" => date("H:i.s"), ":servervar" => json_encode($_SERVER)];
$params = [":page" => $this->tools->get_page_url(), ":ip" => $this->tools->get_ip(), ":date" => date("d/m/Y"), ":hour" => date("H:i.s"), ":server_var" => json_encode($_SERVER)];
} else {
$params = [":page" => $this->tools->get_page_url(), ":ip" => "redacted", ":data" => date("d/m/Y"), ":ora" => date("H:i.s"), ":servervar" => json_encode(["redacted" => "true"])];
$params = [":page" => $this->tools->get_page_url(), ":ip" => "redacted", ":date" => date("d/m/Y"), ":hour" => date("H:i.s"), ":server_var" => json_encode(["redacted" => "true"])];
}
$sql = "INSERT INTO `%PREFIX%_intrusions` (`id`, `page`, `data`, `ora`, `ip`, `servervar`) VALUES (NULL, :page, :data, :ora, :ip, :servervar)";
$sql = "INSERT INTO `%PREFIX%_intrusions` (`id`, `page`, `date`, `hour`, `ip`, `server_var`) VALUES (NULL, :page, :date, :hour, :ip, :server_var)";
$this->database->exec($sql, false, $params);
}
if($redirect) {
@ -631,18 +587,18 @@ class user
}
}
public function add_user($email, $name, $username, $password, $birthday, $capo, $autista, $hidden, $disabled, $inserted_by)
public function add_user($email, $name, $username, $password, $birthday, $chief, $driver, $hidden, $disabled, $inserted_by)
{
$this->tools->profiler_start("Add user");
$userId = $this->auth->admin()->createUserWithUniqueUsername($email, $password, $username);
if($userId) {
$hidden = $hidden ? 1 : 0;
$disabled = $disabled ? 1 : 0;
$capo = $capo ? 1 : 0;
$autista = $autista ? 1 : 0;
$sql = "INSERT INTO `%PREFIX%_profiles` (`hidden`, `disabled`, `name`, `chief`, `autista`) VALUES (:hidden, :disabled, :name, :chief, :autista)";
$this->database->exec($sql, false, [":hidden" => $hidden, ":disabled" => $disabled, ":name" => $name, ":chief" => $capo, ":autista" => $autista]);
if($capo == 1) {
$chief = $chief ? 1 : 0;
$driver = $driver ? 1 : 0;
$sql = "INSERT INTO `%PREFIX%_profiles` (`hidden`, `disabled`, `name`, `chief`, `driver`) VALUES (:hidden, :disabled, :name, :chief, :driver)";
$this->database->exec($sql, false, [":hidden" => $hidden, ":disabled" => $disabled, ":name" => $name, ":chief" => $chief, ":driver" => $driver]);
if($chief == 1) {
$this->auth->admin()->addRoleForUserById($userId, Role::FULL_VIEWER);
}
$this->log("User created", $userId, $inserted_by, date("d/m/Y"), date("H:i.s"));

View File

@ -38,11 +38,11 @@ describe("User management", () => {
.type(user.birthday)
.should('have.value', user.birthday)
if(user.chief){
cy.get("input[name='capo']")
cy.get("input[name='chief']")
.check({force: true})
}
if(user.driver){
cy.get("input[name='autista']")
cy.get("input[name='driver']")
.check({force: true})
}
cy.contains("Submit").click()
@ -61,8 +61,8 @@ describe("User management", () => {
username: user.username,
password: user.password,
birthday: user.birthday,
capo: user.chief | 0,
autista: user.driver | 0,
chief: user.chief | 0,
driver: user.driver | 0,
hidden: 0,
disabled: 0
}})

View File

@ -1,47 +1,58 @@
<?php
require_once 'ui.php';
if($tools->validate_form_data('$post-mod', true, "add")) {
if($tools->validate_form_data(['$post-data', '$post-codice', '$post-uscita', '$post-rientro', '$post-capo', '$post-luogo', '$post-note', '$post-tipo', '$post-token'])) {
function debug(){
echo("<pre>"); var_dump($_POST); echo("</pre>"); exit();
}
if($tools->validate_form("mod", "add")) {
if($tools->validate_form(['date', 'code', 'beginning', 'end', 'place', 'notes', 'type', 'token'])) {
if($_POST["token"] == $_SESSION['token']) {
bdump("adding service");
$database->add_service($_POST["data"], $_POST["codice"], $_POST["uscita"], $_POST["rientro"], $_POST["capo"][0], $tools->extract_unique($_POST["autisti"]), $tools->extract_unique($_POST["personale"]), $_POST["luogo"], $_POST["note"], $_POST["tipo"], $tools->extract_unique([$_POST["capo"],$_POST["autisti"],$_POST["personale"]]), $user->name());
$database->add_service($_POST["date"], $_POST["code"], $_POST["beginning"], $_POST["end"], $_POST["chief"][0], $tools->extract_unique($_POST["drivers"]), $tools->extract_unique($_POST["crew"]), $_POST["place"], $_POST["notes"], $_POST["type"], $tools->extract_unique([$_POST["chief"],$_POST["drivers"],$_POST["crew"]]), $user->name());
$tools->redirect("services.php");
} else {
$tools->redirect("accessdenied.php");
debug(); //TODO: remove debug info
}
} else {
debug();
}
} elseif($tools->validate_form_data('$post-mod', true, "edit")) {
if($tools->validate_form_data(['$post-id', '$post-data', '$post-codice', '$post-uscita', '$post-rientro', '$post-capo', '$post-luogo', '$post-note', '$post-tipo', '$post-token'])) {
} elseif($tools->validate_form("mod", "edit")) {
if($tools->validate_form(['id', 'date', 'code', 'beginning', 'end', 'place', 'notes', 'type', 'token'])) {
if($_POST["token"] == $_SESSION['token']) {
bdump($_POST);
bdump("editing service");
$database->change_service($_POST["id"], $_POST["data"], $_POST["codice"], $_POST["uscita"], $_POST["rientro"], $_POST["capo"][0], $tools->extract_unique($_POST["autisti"]), $tools->extract_unique($_POST["personale"]), $_POST["luogo"], $_POST["note"], $_POST["tipo"], $tools->extract_unique([$_POST["capo"],$_POST["autisti"],$_POST["personale"]]), $user->name());
$database->change_service($_POST["id"], $_POST["date"], $_POST["code"], $_POST["beginning"], $_POST["end"], $_POST["chief"][0], $tools->extract_unique($_POST["drivers"]), $tools->extract_unique($_POST["crew"]), $_POST["place"], $_POST["notes"], $_POST["type"], $tools->extract_unique([$_POST["chief"],$_POST["drivers"],$_POST["crew"]]), $user->name());
$tools->redirect("services.php");
} else {
$tools->redirect("accessdenied.php");
debug();
}
} else {
debug();
}
} elseif($tools->validate_form_data('$post-mod', true, "delete")) {
} elseif($tools->validate_form("mod", "delete")) {
bdump("removing service");
if($tools->validate_form_data(['$post-id', '$post-increment', '$post-token'])) {
if($tools->validate_form(['id', 'increment', 'token'])) {
if($_POST["token"] == $_SESSION['token']) {
bdump("removing service");
$database->remove_service($_POST["id"], $_POST["increment"]);
$tools->redirect("services.php");
} else {
$tools->redirect("accessdenied.php");
echo("1");
debug();
}
} else {
echo("2");
debug();
}
} else {
if(isset($_GET["add"])||isset($_GET["edit"])||isset($_GET["delete"])||isset($_GET["mod"])) {
$_SESSION["token"] = bin2hex(random_bytes(64));
}
$personale = $database->exec("SELECT * FROM `%PREFIX%_profiles` ORDER BY name ASC;", true); // Pesco i dati della table e li ordino in base al name
$tipologie = $database->exec("SELECT `name` FROM `%PREFIX%_tipo` ORDER BY name ASC", true); // Pesco le tipologie della table
$crew = $database->exec("SELECT * FROM `%PREFIX%_profiles` ORDER BY name ASC;", true); // Pesco i dati della table e li ordino in base al name
$types = $database->exec("SELECT `name` FROM `%PREFIX%_type` ORDER BY name ASC", true); // Pesco le tipologie della table
$modalità = (isset($_GET["add"])) ? "add" : ((isset($_GET["edit"])) ? "edit" : ((isset($_GET["delete"])) ? "delete" : "add"));
bdump($modalità, "modalità");
bdump($tipologie, "tipologie");
bdump($personale, "personale");
bdump($types, "types");
bdump($crew, "crew");
$id = "";
if(isset($_GET["id"])) {
$id = $_GET["id"];
@ -58,12 +69,12 @@ if($tools->validate_form_data('$post-mod', true, "add")) {
}
if($modalità=="edit" || $modalità=="delete") {
if(empty($id)) {
$tools->redirect("accessdenied.php");
echo("<pre>"); var_dump($_POST); echo("</pre>");
} elseif (!$database->exists("services", $id)) {
$tools->redirect("accessdenied.php");
echo("<pre>"); var_dump($_POST); echo("</pre>");
}
}
loadtemplate('edit_service.html', ['service' => ['id' => $id, 'token' => $_SESSION['token'], 'modalità' => $modalità, 'personale' => $personale, 'tipologie' => $tipologie], 'values' => $values, 'increment' => $increment, 'title' => ucfirst($modalità) . ' '.ucfirst(t("service", false))]);
loadtemplate('edit_service.html', ['service' => ['id' => $id, 'token' => $_SESSION['token'], 'modalità' => $modalità, 'crew' => $crew, 'types' => $types], 'values' => $values, 'increment' => $increment, 'title' => ucfirst($modalità) . ' '.ucfirst(t("service", false))]);
bdump($_SESSION['token'], "token");
}
?>

View File

@ -1,50 +1,59 @@
<?php
require_once 'ui.php';
if($tools->validate_form_data('$post-mod', true, "add")) {
if($tools->validate_form_data(['$post-data', '$post-name', '$post-start_time', '$post-end_time', '$post-luogo', '$post-note', '$post-token'])) {
function debug(){
echo("<pre>"); var_dump($_POST); echo("</pre>"); exit();
}
if($tools->validate_form("mod", "add")) {
if($tools->validate_form(['date', 'name', 'start_time', 'end_time', 'place', 'notes', 'token'])) {
if($_POST["token"] == $_SESSION['token']) {
bdump("adding training");
$database->add_training($_POST["data"], $_POST["name"], $_POST["start_time"], $_POST["end_time"], $_POST["capo"][0], $tools->extract_unique($_POST["personale"]), $_POST["luogo"], $_POST["note"], $tools->extract_unique([$_POST["capo"],$_POST["personale"]]), $user->name());
$database->add_training($_POST["date"], $_POST["name"], $_POST["start_time"], $_POST["end_time"], $_POST["chief"][0], $tools->extract_unique($_POST["crew"]), $_POST["place"], $_POST["notes"], $tools->extract_unique([$_POST["chief"],$_POST["crew"]]), $user->name());
$tools->redirect("trainings.php");
} else {
$tools->redirect("accessdenied.php");
debug(); //TODO: remove debug info
}
} else {
debug();
}
} elseif($tools->validate_form_data('$post-mod', true, "edit")) {
if($tools->validate_form_data(['$post-id', '$post-data', '$post-name', '$post-start_time', '$post-end_time', '$post-capo', '$post-luogo', '$post-note', '$post-token'])) {
} elseif($tools->validate_form("mod", "edit")) {
if($tools->validate_form(['id', 'date', 'name', 'start_time', 'end_time', 'chief', 'place', 'notes', 'token'])) {
if($_POST["token"] == $_SESSION['token']) {
bdump($_POST);
bdump("editing training");
$database->change_training($_POST["id"], $_POST["data"], $_POST["name"], $_POST["start_time"], $_POST["end_time"], $_POST["capo"][0], $tools->extract_unique($_POST["personale"]), $_POST["luogo"], $_POST["note"], $tools->extract_unique([$_POST["capo"],$_POST["personale"]]), $user->name());
$database->change_training($_POST["id"], $_POST["date"], $_POST["name"], $_POST["start_time"], $_POST["end_time"], $_POST["chief"][0], $tools->extract_unique($_POST["crew"]), $_POST["place"], $_POST["notes"], $tools->extract_unique([$_POST["chief"],$_POST["crew"]]), $user->name());
$tools->redirect("trainings.php");
} else {
$tools->redirect("accessdenied.php");
debug();
}
} else {
debug();
}
} elseif($tools->validate_form_data('$post-mod', true, "delete")) {
} elseif($tools->validate_form("mod", "delete")) {
bdump("removing training");
if($tools->validate_form_data(['$post-id', '$post-increment', '$post-token'])) {
if($tools->validate_form(['id', 'increment', 'token'])) {
if($_POST["token"] == $_SESSION['token']) {
bdump("removing training");
$database->remove_training($_POST["id"], $_POST["increment"]);
$tools->redirect("trainings.php");
} else {
$tools->redirect("accessdenied.php");
debug();
}
} else {
debug();
}
} else {
if(isset($_GET["add"])||isset($_GET["edit"])||isset($_GET["delete"])||isset($_GET["mod"])) {
$_SESSION["token"] = bin2hex(random_bytes(64));
}
$personale = $database->exec("SELECT * FROM `%PREFIX%_profiles` ORDER BY name ASC;", true); // Pesco i dati della table e li ordino in base al name
$crew = $database->exec("SELECT * FROM `%PREFIX%_profiles` ORDER BY name ASC;", true); // Pesco i dati della table e li ordino in base al name
$modalità = (isset($_GET["add"])) ? "add" : ((isset($_GET["edit"])) ? "edit" : ((isset($_GET["delete"])) ? "delete" : "add"));
bdump($modalità, "modalità");
bdump($personale, "personale");
bdump($crew, "crew");
$id = "";
if(isset($_GET["id"])) {
$id = $_GET["id"];
bdump($database->exists("trainings", $id));
$values = $database->exec("SELECT * FROM `%PREFIX%_trainings` WHERE `id` = :id", true, [":id" => $id])[0]; // Pesco le tipologie della table
$values = $database->exec("SELECT * FROM `%PREFIX%_trainings` WHERE `id` = :id", true, [":id" => $id])[0]; // Pesco le types della table
bdump($values);
} else {
$values = [];
@ -61,7 +70,7 @@ if($tools->validate_form_data('$post-mod', true, "add")) {
//$tools->redirect("accessdenied.php");
}
}
loadtemplate('edit_training.html', ['training' => ['id' => $id, 'token' => $_SESSION['token'], 'modalità' => $modalità, 'personale' => $personale], 'values' => $values, 'increment' => $increment, 'title' => ucfirst($modalità) . ' '.ucfirst(t("training", false))]);
loadtemplate('edit_training.html', ['training' => ['id' => $id, 'token' => $_SESSION['token'], 'modalità' => $modalità, 'crew' => $crew], 'values' => $values, 'increment' => $increment, 'title' => ucfirst($modalità) . ' '.ucfirst(t("training", false))]);
bdump($_SESSION['token'], "token");
}
?>

View File

@ -1,42 +1,49 @@
<?php
require_once 'ui.php';
if($tools->validate_form_data('$post-mod', true, "add")) {
if($tools->validate_form_data(['$post-mail', '$post-name', '$post-username', '$post-password', '$post-birthday', '$post-token'])) {
function debug(){
echo("<pre>"); var_dump($_POST); echo("</pre>"); exit();
}
if($tools->validate_form("mod", "add")) {
if($tools->validate_form(['mail', 'name', 'username', 'password', 'birthday', 'token'])) {
if($_POST["token"] == $_SESSION['token']) {
bdump("adding user");
bdump($_POST);
$capo = isset($_POST["capo"]) ? 1 : 0;
$autista = isset($_POST["autista"]) ? 1 : 0;
$chief = isset($_POST["chief"]) ? 1 : 0;
$driver = isset($_POST["driver"]) ? 1 : 0;
$hidden = isset($_POST["visible"]) ? 0 : 1;
$disabled = isset($_POST["enabled"]) ? 0 : 1;
$user->add_user($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $_POST["birthday"], $capo, $autista, $hidden, $disabled, $user->name());
$user->add_user($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $_POST["birthday"], $chief, $driver, $hidden, $disabled, $user->name());
$tools->redirect("list.php");
} else {
$tools->redirect("accessdenied.php");
debug();
}
} else {
debug();
}
/*} elseif($tools->validate_form_data('$post-mod', true, "edit")) {
if($tools->validate_form_data(['$post-id', '$post-data', '$post-codice', '$post-uscita', '$post-rientro', '$post-capo', '$post-luogo', '$post-note', '$post-tipo', '$post-token'])) {
/*} elseif($tools->validate_form("mod", "edit")) {
if($tools->validate_form(['mail', 'name', 'username', 'password', 'birthday', 'token'])) {
if($_POST["token"] == $_SESSION['token']){
bdump($_POST);
bdump("editing service");
$database->change_service($_POST["id"], $_POST["data"], $_POST["codice"], $_POST["uscita"], $_POST["rientro"], $_POST["capo"], $tools->extract_unique($_POST["autisti"]), $tools->extract_unique($_POST["personale"]), $_POST["luogo"], $_POST["note"], $_POST["tipo"], $tools->extract_unique([$_POST["capo"],$_POST["autisti"],$_POST["personale"]]), $user->name());
$database->change_service($_POST["id"], $_POST["date"], $_POST["code"], $_POST["beginning"], $_POST["end"], $_POST["chief"], $tools->extract_unique($_POST["drivers"]), $tools->extract_unique($_POST["crew"]), $_POST["place"], $_POST["notes"], $_POST["type"], $tools->extract_unique([$_POST["chief"],$_POST["drivers"],$_POST["crew"]]), $user->name());
$tools->redirect("services.php");
} else {
$tools->redirect("accessdenied.php");
}
}
*/
} elseif($tools->validate_form_data('$post-mod', true, "delete")) {
bdump("removing service");
if($tools->validate_form_data(['$post-id', '$post-token'])) {
} elseif($tools->validate_form("mod", "delete")) {
bdump("removing service");
if($tools->validate_form(['id', 'token'])) {
if($_POST["token"] == $_SESSION['token']) {
bdump("removing user");
$user->remove_user($_POST["id"]);
$tools->redirect("list.php");
} else {
$tools->redirect("accessdenied.php");
debug();
}
} else {
debug();
}
} else {
if(isset($_GET["add"])||isset($_GET["edit"])||isset($_GET["delete"])||isset($_GET["mod"])) {
@ -48,7 +55,7 @@ if($tools->validate_form_data('$post-mod', true, "add")) {
if(isset($_GET["id"])) {
$id = $_GET["id"];
bdump($database->exists("profiles", $id));
$values = $database->exec("SELECT * FROM `%PREFIX%_profiles` WHERE `id` = :id", true, [":id" => $id])[0]; // Pesco le tipologie della table
$values = $database->exec("SELECT * FROM `%PREFIX%_profiles` WHERE `id` = :id", true, [":id" => $id])[0]; // Pesco le types della table
bdump($values);
} else {
$values = [];

View File

@ -237,41 +237,32 @@ function initDB()
$prefix = DB_PREFIX;
$connection->exec(
"
CREATE TABLE IF NOT EXISTS `".$prefix."_certificati` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`codice` text NOT NULL,
`name` text NOT NULL,
`services` text NOT NULL,
`url` text NOT NULL,
`file` text NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_trainings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`data` date NOT NULL,
`date` date NOT NULL,
`name` varchar(999) NOT NULL,
`inizio` time NOT NULL,
`fine` time NOT NULL,
`personale` text NOT NULL,
`capo` text NOT NULL,
`luogo` text NOT NULL,
`note` text NOT NULL,
`beginning` time NOT NULL,
`end` time NOT NULL,
`crew` text NOT NULL,
`chief` text NOT NULL,
`place` text NOT NULL,
`notes` text NOT NULL,
`increment` varchar(999) NOT NULL DEFAULT 'test',
`inserted_by` varchar(200) NOT NULL DEFAULT 'test',
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_services` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`data` date NOT NULL,
`codice` text NOT NULL,
`uscita` time NOT NULL,
`rientro` time NOT NULL,
`capo` varchar(999) NOT NULL DEFAULT 'test',
`autisti` varchar(999) NOT NULL DEFAULT 'test',
`personale` varchar(999) NOT NULL DEFAULT 'test',
`luogo` varchar(999) NOT NULL DEFAULT 'test',
`note` varchar(999) NOT NULL DEFAULT 'test',
`tipo` text NOT NULL,
`date` date NOT NULL,
`code` text NOT NULL,
`beginning` time NOT NULL,
`end` time NOT NULL,
`chief` varchar(999) NOT NULL DEFAULT 'test',
`drivers` varchar(999) NOT NULL DEFAULT 'test',
`crew` varchar(999) NOT NULL DEFAULT 'test',
`place` varchar(999) NOT NULL DEFAULT 'test',
`notes` varchar(999) NOT NULL DEFAULT 'test',
`type` text NOT NULL,
`increment` varchar(999) NOT NULL,
`inserted_by` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
@ -279,10 +270,10 @@ PRIMARY KEY (`id`)
CREATE TABLE IF NOT EXISTS `".$prefix."_intrusions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`page` varchar(999) COLLATE utf8mb4_unicode_ci NOT NULL,
`data` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`ora` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`date` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`hour` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`ip` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`servervar` varchar(9999) COLLATE utf8mb4_unicode_ci NOT NULL,
`server_var` varchar(9999) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_log` (
@ -301,11 +292,11 @@ CREATE TABLE IF NOT EXISTS `".$prefix."_minutes` (
`list` mediumtext NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_tipo` (
CREATE TABLE IF NOT EXISTS `".$prefix."_type` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `nametipologia` (`name`(99))
UNIQUE KEY `type_name` (`name`(99))
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
@ -330,13 +321,13 @@ CREATE TABLE IF NOT EXISTS `".$prefix."_profiles` (
`name` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`available` tinyint(1) NOT NULL DEFAULT 0,
`chief` tinyint(1) NOT NULL DEFAULT 0,
`autista` tinyint(1) NOT NULL DEFAULT 0,
`telefono` varchar(25) DEFAULT NULL,
`driver` tinyint(1) NOT NULL DEFAULT 0,
`phone_number` varchar(25) DEFAULT NULL,
`services` int(11) NOT NULL DEFAULT 0,
`trainings` int(11) NOT NULL DEFAULT 0,
`online_time` int(11) NOT NULL DEFAULT 0,
`availability_minutes` int(11) NOT NULL DEFAULT 0,
`immagine` varchar(1000) DEFAULT NULL,
`image` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Id` (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
@ -413,7 +404,7 @@ PRIMARY KEY (`id`),
KEY `Id` (`id`)
) ENGINE = InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `".$prefix."_dbversion` (`version`, `timestamp`) VALUES('1', current_timestamp());
INSERT INTO `".$prefix."_tipo` (`id`, `name`) VALUES (NULL, 'type1'), (NULL, 'type2');"
INSERT INTO `".$prefix."_type` (`id`, `name`) VALUES (NULL, 'type1'), (NULL, 'type2');"
);
} catch (Exception $e) {
if(is_cli()) {

View File

@ -18,8 +18,8 @@ foreach($risultato as $row){
"available" => $row["available"],
"chief" => $row['chief'],
"online" => (time()-$row["online_time"])<=30 ? 1 : 0,
"driver" => $row['autista'],
"phone" => $row['telefono'],
"driver" => $row['driver'],
"phone" => $row['phone_number'],
"services" => $row['services'],
"availability_minutes" => $row['availability_minutes']
];
@ -41,9 +41,9 @@ foreach($risultato as $row){
$response[] = [
(time()-$row["online_time"])<=30 ? "<u>".$firstCell."</u>" : $firstCell,
$secondCell,
$row['autista'] ? "<img alt='driver' src='./resources/images/wheel.png' width='20px'>" : "",
$row['telefono'] ? "<a href='tel:+".$row['telefono']."'><i class='fa fa-phone'></i></a>" : "",
$row['telefono'] ? "<a href='https://api.whatsapp.com/send?phone=+".$row['telefono']."text=ALLERTA IN CORSO.%20Mettiti%20in%20contatto%20con%20$name_encoded'><i class='fa fa-whatsapp' style='color:green'></i></a>" : "",
$row['driver'] ? "<img alt='driver' src='./resources/images/wheel.png' width='20px'>" : "",
$row['phone_number'] ? "<a href='tel:+".$row['phone_number']."'><i class='fa fa-phone'></i></a>" : "",
$row['phone_number'] ? "<a href='https://api.whatsapp.com/send?phone=+".$row['phone_number']."text=ALLERTA IN CORSO.%20Mettiti%20in%20contatto%20con%20$name_encoded'><i class='fa fa-whatsapp' style='color:green'></i></a>" : "",
$row['services'],
$row['availability_minutes'],
"<a href='user_details.php?user=".$row['id']."'><p>".t("Altri dettagli", false)."</p></a>"

View File

@ -4,36 +4,36 @@ init_class();
$user->requirelogin(false);
$user->online_time_update();
$risultato = $database->exec("SELECT * FROM `%PREFIX%_services` ORDER BY data DESC, uscita DESC", true);
$risultato = $database->exec("SELECT * FROM `%PREFIX%_services` ORDER BY date DESC, beginning DESC", true);
$response = [];
foreach($risultato as $row){
$chief = $user->nameById($row["capo"]);
$chief = $user->nameById($row["chief"]);
$drivers_array = explode(",", $row['autisti']);
$drivers_array = explode(",", $row['drivers']);
foreach($drivers_array as $key=>$name){
$drivers_array[$key] = $user->nameById($name);
}
$drivers = implode(", ", $drivers_array);
$others_people_array = explode(",", $row['personale']);
foreach($others_people_array as $key=>$name){
$others_people_array[$key] = $user->nameById($name);
$others_crew_array = explode(",", $row['crew']);
foreach($others_crew_array as $key=>$name){
$others_crew_array[$key] = $user->nameById($name);
}
$others_people = implode(", ", $others_people_array);
$others_crew = implode(", ", $others_crew_array);
$response[] = [
$row['data'],
$row['codice'],
$row['uscita'],
$row['rientro'],
$row['date'],
$row['code'],
$row['beginning'],
$row['end'],
$chief,
$drivers,
$others_people,
s($row['luogo'],false,true),
s($row['note'],false,true),
s($row['tipo'],false,true),
$database->getOption("service_edit") ? "<a href='edit_service.php?edit&id={$row['id']}'><i style='font-size: 40px' class='fa fa-edit'></i></a>" : null,
$database->getOption("service_remove") ? "<a href='edit_service.php?delete&id={$row['id']}&increment={$row['increment']}'><i style='font-size: 40px' class='fa fa-trash'></i></a>" : null
$others_crew,
s($row['place'],false,true),
s($row['notes'],false,true),
s($row['type'],false,true),
$database->getOption("service_edit") ? "<a class='pjax_disable' href='edit_service.php?edit&id={$row['id']}'><i style='font-size: 40px' class='fa fa-edit'></i></a>" : null,
$database->getOption("service_remove") ? "<a class='pjax_disable' href='edit_service.php?delete&id={$row['id']}&increment={$row['increment']}'><i style='font-size: 40px' class='fa fa-trash'></i></a>" : null
];
}
header("Content-type: application/json");

View File

@ -4,28 +4,28 @@ init_class();
$user->requirelogin(false);
$user->online_time_update();
$risultato = $database->exec("SELECT * FROM `%PREFIX%_trainings` ORDER BY data DESC, inizio desc", true);
$risultato = $database->exec("SELECT * FROM `%PREFIX%_trainings` ORDER BY date DESC, beginning desc", true);
$response = [];
foreach($risultato as $row){
$chief = $user->nameById($row["capo"]);
$chief = $user->nameById($row["chief"]);
$others_people_array = explode(",", $row['personale']);
foreach($others_people_array as $key=>$name){
$others_people_array[$key] = $user->nameById($name);
$others_crew_array = explode(",", $row['crew']);
foreach($others_crew_array as $key=>$name){
$others_crew_array[$key] = $user->nameById($name);
}
$others_people = implode(", ", $others_people_array);
$others_crew = implode(", ", $others_crew_array);
$response[] = [
$row['data'],
$row['date'],
$row['name'],
$row['inizio'],
$row['fine'],
$row['beginning'],
$row['end'],
$chief,
$others_people,
s($row['luogo'],false,true),
s($row['note'],false,true),
$database->getOption("training_edit") ? "<a href='edit_training.php?edit&id={$row['id']}'><i style='font-size: 40px' class='fa fa-edit'></i></a>" : null,
$database->getOption("training_remove") ? "<a href='edit_training.php?delete&id={$row['id']}&increment={$row['increment']}'><i style='font-size: 40px' class='fa fa-trash'></i></a>" : null
$others_crew,
s($row['place'],false,true),
s($row['notes'],false,true),
$database->getOption("training_edit") ? "<a class='pjax_disable' href='edit_training.php?edit&id={$row['id']}'><i style='font-size: 40px' class='fa fa-edit'></i></a>" : null,
$database->getOption("training_remove") ? "<a class='pjax_disable' href='edit_training.php?delete&id={$row['id']}&increment={$row['increment']}'><i style='font-size: 40px' class='fa fa-trash'></i></a>" : null
];
}
header("Content-type: application/json");

View File

@ -274,12 +274,12 @@ echo("<h1>".t("Personal data",false)." <b>$name</b></h1><br><br>");
echo('<img alt="VVF" src="./resources/images/distaccamento.png" width="150" class="img-resposive"><br><br><br>');
$disp = vero1($row['available'], "<i class='fa fa-check' style='color:green' width='22px'></i>", "<i class='fa fa-times' style='color:red' width='22px'></i>");
$chief = vero1($row['chief'], "<img src='./resources/images/red_helmet.png' width='22px'>", "<img src='./resources/images/black_helmet.png' width='22px'>");
$autista = vero1($row['autista'], "<img src='./resources/images/wheel.png' width='22px'>");
$driver = vero1($row['driver'], "<img src='./resources/images/wheel.png' width='22px'>");
echo("<p>".t("Name",false).": <b>$name</b></p><br>");
echo("<p>".t("Available",false).": <b>{$disp}</b></p><br>");
echo("<p>".t("Chief",false).": <b>{$chief}</b></p><br>");
echo("<p>".t("Driver",false).": <b>{$autista}</b></p><br>");
echo("<p>".t("Phone number",false)." <i class='fa fa-phone' style='color:green' width='22px'></i>: <b><a href='tel:{$row['telefono']}'>{$row['telefono']}</a></b></p><br>");
echo("<p>".t("Driver",false).": <b>{$driver}</b></p><br>");
echo("<p>".t("Phone number",false)." <i class='fa fa-phone' style='color:green' width='22px'></i>: <b><a href='tel:{$row['phone_number']}'>{$row['phone_number']}</a></b></p><br>");
echo("<p>".t("Availability Minutes",false)." <br>(".t("This month",false).") <i class='demo-icon icon-hourglass'></i>: <b>{$row['availability_minutes']} minutes</b></p><br>");
echo("<p>".t("Services",false).": <b>{$row['services']}</b></p><br>");
}

View File

@ -29,8 +29,8 @@ function set_marker(LatLng){
marker.remove();
}
console.log(LatLng);
if($("input[name='luogo']").val() !== undefined){
$("input[name='luogo']").val(LatLng.lat + ";" + LatLng.lng);
if($("input[name='place']").val() !== undefined){
$("input[name='place']").val(LatLng.lat + ";" + LatLng.lng);
}
marker = L.marker(LatLng, {icon: iconDefault}).addTo(map);
}

View File

@ -1,24 +0,0 @@
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.1.3/howler.min.js"
integrity="sha256-/Q4ZPy6sMbk627wHxuaWSIXS1y7D2KnMhsm/+od7ptE=" crossorigin="anonymous"></script>
</head>
<body>
<div class='text-center' id="err">
<script>
var sound = new Howl({
src: ['{{ urlsoftware }}/resources/sounds/{{ error_sound }}'],
autoplay: true,
volume: 0.9,
onend: function () {
console.log('Finito');
}
});
sound.play();
</script>
Possibile attività di hacking del software rilevata
<img src='{{ urlsoftware }}/resources/images/{{ error_image }}'></img>
</div>
<h1>Abbiamo rilevato un' attività sospetta provenire dal tuo dispositivo o dalla tua rete.<br>Se non stavi facendo
niente di brutto, e ritieni che questo sia un error, la<br>preghiamo di contattare l'assistenza.</h1>
</body>

View File

@ -10,8 +10,8 @@
<div class="container">
<label><b>{{ 'Service day'|t }}</b></label>
<div class="input-group">
<input aria-label="Date picker" placeholder="DD/MM/YYY" autocomplete="off" name="data" data-provide="datepicker"
value="{{ values.data }}" type="text" class="form-control">
<input aria-label="Date picker" placeholder="DD/MM/YYY" autocomplete="off" name="date" data-provide="datepicker"
value="{{ values.date }}" type="text" class="form-control">
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
</div>
@ -19,58 +19,58 @@
<br>
<br>
<label><b>{{ 'code'|t }}</b></label>
<input id="progressivo" type="text" name="codice" placeholder="1234/5" required value="{{ values.codice }}">
<input id="progressivo" type="text" name="code" placeholder="1234/5" required value="{{ values.code }}">
<br>
<br>
<label for="timePicker1"><b>{{ 'Start time'|t }}</b></label>
<input id="timePicker1" type="time" name="uscita" required value="{{ values.uscita }}">
<input id="timePicker1" type="time" name="beginning" required value="{{ values.beginning }}">
<br>
<br>
<label for="timePicker2"><b>{{ 'End time'|t }}</b></label>
<input id="timePicker2" type="time" name="rientro" required value="{{ values.rientro }}">
<input id="timePicker2" type="time" name="end" required value="{{ values.end }}">
<br>
<br>
<label><b>{{ 'Chief'|t }}</b></label>
<br>
{% for user in service.personale %}
{% for user in service.crew %}
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="form-check">
<input aria-label="{{ username(user.id) }}" class="form-check-input capo capo-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='capo[]'
<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[]'
value='{{ user.id }}'>
<label class="form-check-label" for="capo-{{ user.id }}">
<label class="form-check-label" for="chief-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endfor %}
<script>
$('.capo').on('change', function () {
$('.chief').on('change', function () {
$('input[name="' + this.name + '"]').not(this).prop('checked', false);
});
</script>
<br>
<label><b>{{ 'Drivers'|t }}</b></label>
<br>
{% for user in service.personale %}
{% if user.autista == 1 %}
{% for user in service.crew %}
{% if user.driver == 1 %}
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="form-check">
<input aria-label="{{ username(user.id) }}" class="form-check-input autisti autisti-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='autisti[]'
<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[]'
value='{{ user.id }}'>
<label class="form-check-label" for="autisti-{{ user.id }}">
<label class="form-check-label" for="drivers-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endif %}
{% endfor %}
<br>
<label><b>{{ 'Others people'|t }}</b></label>
<label><b>{{ 'Crew'|t }}</b></label>
<br>
{% for user in service.personale %}
{% for user in service.crew %}
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="form-check">
<input aria-label="{{ username(user.id) }}" class="form-check-input personale personale-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='personale[]'
<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[]'
value='{{ user.id }}'>
<label class="form-check-label" for="personale-{{ user.id }}">
<label class="form-check-label" for="crew-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
@ -85,23 +85,23 @@
class="btn btn-primary">{{ 'Search'|t }}</button>
<div id="results"></div>
</div>
<input type="hidden" name="luogo" value="" />
<input type="hidden" name="place" value="" />
<script src="resources/dist/maps.js" onload="load_map();"></script>
{% else %}
<label><b>{{ 'Service place'|t }}</b></label>
<input type="text" name="luogo" required value="{{ values.luogo }}">
<input type="text" name="place" required value="{{ values.place }}">
{% endif %}
<br>
<br>
<label><b>{{ 'Others notes (ex. others infos)'|t }}</b></label><br>
<textarea name='note' id='note'></textarea>
<textarea name='notes' id='notes'></textarea>
<br>
<br>
<label><b>{{ 'Service type'|t }}</b></label>
<br>
<select name='tipo' class="tipi">
{% for tipo in service.tipologie %}
<option value='{{ tipo.name }}'>{{ tipo.name }}</option>
<select name='type' class="tipi">
{% for type in service.types %}
<option value='{{ type.name }}'>{{ type.name }}</option>
{% endfor %}
</select>
<br>
@ -113,24 +113,23 @@
</form>
<script>
{% if service.modalità == "edit" %}
$.each('{{ values.capo }}'.split(','), function (index, value) {
$('.capo-' + value).prop('checked', true);
$.each('{{ values.chief }}'.split(','), function (index, value) {
$('.chief-' + value).prop('checked', true);
});
$.each('{{ values.autisti }}'.split(','), function (index, value) {
$('.autisti-' + value).prop('checked', true);
$.each('{{ values.drivers }}'.split(','), function (index, value) {
$('.drivers-' + value).prop('checked', true);
});
$.each('{{ values.personale }}'.split(','), function (index, value) {
$('.personale-' + value).prop('checked', true);
$.each('{{ values.crew }}'.split(','), function (index, value) {
$('.crew-' + value).prop('checked', true);
});
$(".tipi").val('{{ values.tipo }}');
$('#note').val('{{ values.note }}');
$(".tipi").val('{{ values.type }}');
$('#notes').val('{{ values.notes }}');
{% endif %}
$('form').submit(function () {
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 }}");
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;
}

View File

@ -10,8 +10,8 @@
<div class="container">
<label><b>{{ 'Training day'|t }}</b></label>
<div class="input-group">
<input aria-label="Date picker" placeholder="DD/MM/YYY" autocomplete="off" name="data" data-provide="datepicker"
value="{{ values.data }}" type="text" class="form-control">
<input aria-label="Date picker" placeholder="DD/MM/YYY" autocomplete="off" name="date" data-provide="datepicker"
value="{{ values.date }}" type="text" class="form-control">
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
</div>
@ -23,50 +23,50 @@
<br>
<br>
<label for="timePicker1"><b>{{ 'Start time'|t }}</b></label>
<input id="timePicker1" type="time" name="start_time" required value="{{ values.inizio }}">
<input id="timePicker1" type="time" name="start_time" required value="{{ values.beginning }}">
<br>
<br>
<label for="timePicker2"><b>{{ 'End time'|t }}</b></label>
<input id="timePicker2" type="time" name="end_time" required value="{{ values.fine }}">
<input id="timePicker2" type="time" name="end_time" required value="{{ values.end }}">
<br>
<br>
<label><b>{{ 'Chief'|t }}</b></label>
<br>
{% for user in training.personale %}
{% for user in training.crew %}
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="form-check">
<input aria-label="{{ username(user.id) }}" class="form-check-input capo capo-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='capo[]'
<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[]'
value='{{ user.id }}'>
<label class="form-check-label" for="capo-{{ user.id }}">
<label class="form-check-label" for="chief-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endfor %}
<script>
$('.capo').on('change', function () {
$('.chief').on('change', function () {
$('input[name="' + this.name + '"]').not(this).prop('checked', false);
});
</script>
<br>
<label><b>{{ 'Others people'|t }}</b></label>
<label><b>{{ 'Crew'|t }}</b></label>
<br>
{% for user in training.personale %}
{% for user in training.crew %}
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="form-check">
<input aria-label="{{ username(user.id) }}" class="form-check-input personale personale-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='personale[]'
<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[]'
value='{{ user.id }}'>
<label class="form-check-label" for="personale-{{ user.id }}">
<label class="form-check-label" for="crew-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endfor %}
<br>
<label><b>{{ 'Training place'|t }}</b></label>
<input type="text" name="luogo" required value="{{ values.luogo }}">
<input type="text" name="place" required value="{{ values.place }}">
<br>
<br>
<label><b>{{ 'Others notes (ex. others infos)'|t }}</b></label><br>
<textarea name='note'></textarea>
<textarea name='notes'></textarea>
<br>
<br>
<input id="modalità" type="hidden" value="{{ training.modalità }}" name="mod"></input>
@ -77,13 +77,13 @@
</form>
<script>
{% if training.modalità == "edit" %}
$.each('{{ values.capo|striptags|e("js") }}'.split(','), function (index, value) {
$('.capo-' + value).prop('checked', true);
$.each('{{ values.chief|striptags|e("js") }}'.split(','), function (index, value) {
$('.chief-' + value).prop('checked', true);
});
$.each('{{ values.personale|striptags|e("js") }}'.split(','), function (index, value) {
$('.personale-' + value).prop('checked', true);
$.each('{{ values.crew|striptags|e("js") }}'.split(','), function (index, value) {
$('.crew-' + value).prop('checked', true);
});
$('#note').val('{{ values.note|e("js") }}');
$('#notes').val('{{ values.notes|e("js") }}');
{% endif %}
</script>
{% endif %}

View File

@ -27,7 +27,7 @@
<label><b>{{ 'Birthday'|t }}</b></label>
<div class="input-group">
<input placeholder="DD/MM/YYY" autocomplete="off" name="birthday" data-provide="datepicker"
value="{{ values.data }}" type="text" class="form-control">
value="{{ values.date }}" type="text" class="form-control">
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
</div>
@ -40,11 +40,11 @@
}
</style>
<label><b>{{ 'Chief'|t }}</b></label><br>
<input type="checkbox" name="capo" data-toggle="toggle" data-style="workaround">
<input type="checkbox" name="chief" data-toggle="toggle" data-style="workaround">
<br>
<br>
<label><b>{{ 'Driver'|t }}</b></label><br>
<input type="checkbox" name="autista" data-toggle="toggle" data-style="workaround">
<input type="checkbox" name="driver" data-toggle="toggle" data-style="workaround">
<br>
<br>
<label><b>{{ 'Visible'|t }}</b></label><br>

View File

@ -20,7 +20,7 @@
<th>{{ 'End time'|t }}</th>
<th>{{ 'Chief'|t }}</th>
<th>{{ 'Drivers'|t }}</th>
<th>{{ 'People'|t }}</th>
<th>{{ 'Crew'|t }}</th>
<th>{{ 'Place'|t }}</th>
<th>{{ 'Notes'|t }}</th>
<th>{{ 'Type'|t }}</th>

View File

@ -19,7 +19,7 @@
<th>{{ 'Start time'|t }}</th>
<th>{{ 'End time'|t }}</th>
<th>{{ 'Chief'|t }}</th>
<th>{{ 'People'|t }}</th>
<th>{{ 'Crew'|t }}</th>
<th>{{ 'Place'|t }}</th>
<th>{{ 'Notes'|t }}</th>
{% if option('training_edit') %}

View File

@ -21,7 +21,7 @@ return [
"Chief" => "Chief",
"Driver" => "Driver",
"Drivers" => "Drivers",
"People" => "People",
"Crew" => "Crew",
"Date" => "Date",
"code" => "code",
"Start time" => "Start time",
@ -48,7 +48,6 @@ return [
"Made by" => "Made by",
"Datetime" => "Datetime",
"Service day" => "Service day",
"Others people" => "Others people",
"Service place" => "Service place",
"Service type" => "Service type",
"Training day" => "Training day",

View File

@ -21,7 +21,7 @@ return [
"Chief" => "Caposquadra",
"Driver" => "Autista",
"Drivers" => "Autisti",
"People" => "Persone",
"Crew" => "Altre persone",
"Date" => "Data",
"code" => "codice",
"Start time" => "Tempo inizio",
@ -48,7 +48,6 @@ return [
"Made by" => "Fatto da",
"Datetime" => "Data e ora",
"Service day" => "Giorno dell'intervento",
"Others people" => "Altre persone",
"Service place" => "Luogo dell'intervento",
"Service type" => "Tipologia dell'intervento",
"Training day" => "Giorno dell'addestramento",