diff --git a/api/index.php b/api/index.php
index 71345c139..eeadfa26c 100644
--- a/api/index.php
+++ b/api/index.php
@@ -5,6 +5,7 @@ function serverError()
$error = error_get_last();
if ($error['type'] == E_ERROR) {
ob_end_clean();
+ print_r($error);
die(API::error('serverError'));
}
}
@@ -39,11 +40,6 @@ try {
$result = $api->create($request);
break;
case 'GET':
- if (empty($request)) {
- $request = Filter::getGET();
- unset($request['token']);
- }
-
if (!empty($request)) {
$result = $api->retrieve($request);
} else {
diff --git a/assets/src/css/style.css b/assets/src/css/style.css
index 9999b9a3a..d8140cbb8 100644
--- a/assets/src/css/style.css
+++ b/assets/src/css/style.css
@@ -526,8 +526,10 @@ span.form-control {
.main-header .logo {
display: none;
}
- .fixed .content-wrapper,
- .fixed .right-side {
+ .content-wrapper,
+ .right-side,
+ .left-side,
+ .main-sidebar {
padding-top: 50px;
}
}
@@ -552,3 +554,9 @@ div.DTS tbody th {
word-wrap: break-word;
max-width: 500px;
}
+
+.table-responsive th,
+.table-responsive td,
+input {
+ min-width: 200px;
+}
diff --git a/call.php b/call.php
index d6887baea..cb20c3bfd 100644
--- a/call.php
+++ b/call.php
@@ -10,9 +10,9 @@ if (isset($id_record)) {
$posizione .= ', '.$id_record;
}
-$dbo->query('UPDATE zz_semaphores SET updated = NOW() WHERE id_utente = '.prepare($_SESSION['idutente']).' AND posizione = '.prepare($posizione));
+$dbo->query('UPDATE zz_semaphores SET updated = NOW() WHERE id_utente = '.prepare($_SESSION['id_utente']).' AND posizione = '.prepare($posizione));
$dbo->query('DELETE FROM zz_semaphores WHERE DATE_ADD(updated, INTERVAL '.(get_var('Timeout notifica di presenza (minuti)') * 2).' SECOND) <= NOW()');
-$datas = $dbo->fetchArray('SELECT DISTINCT * FROM zz_semaphores INNER JOIN zz_users ON zz_semaphores.id_utente=zz_users.idutente WHERE id_utente != '.prepare($_SESSION['idutente']).' AND posizione = '.prepare($posizione));
+$datas = $dbo->fetchArray('SELECT DISTINCT * FROM zz_semaphores INNER JOIN zz_users ON zz_semaphores.id_utente=zz_users.id_utente WHERE zz_semaphores.id_utente != '.prepare($_SESSION['id_utente']).' AND posizione = '.prepare($posizione));
$result = [];
if ($datas != null) {
diff --git a/core.php b/core.php
index b2b2aeb3e..ff67d0a54 100644
--- a/core.php
+++ b/core.php
@@ -235,7 +235,7 @@ if (!API::isAPIRequest()) {
// Retrocompatibilità
$user_idanagrafica = $user['idanagrafica'];
- $rs = $dbo->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `idutente`='.prepare($_SESSION['idutente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `idmodule`, `clause` FROM `zz_group_module` WHERE `idgruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `idutente`='.prepare($_SESSION['idutente']).')) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
+ $rs = $dbo->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `id_utente`='.prepare($_SESSION['id_utente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `idmodule`, `clause` FROM `zz_group_module` WHERE `idgruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `id_utente`='.prepare($_SESSION['id_utente']).')) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
$modules_info = [];
for ($i = 0; $i < count($rs); ++$i) {
diff --git a/editor.php b/editor.php
index 9ab807b7b..d3530fe5c 100755
--- a/editor.php
+++ b/editor.php
@@ -28,8 +28,8 @@ include $docroot.'/actions.php';
$advanced_sessions = get_var('Attiva notifica di presenza utenti sul record');
if ($advanced_sessions) {
- $dbo->query('DELETE FROM zz_semaphores WHERE id_utente='.prepare($_SESSION['idutente']).' AND posizione='.prepare($id_module.', '.$id_record));
- $dbo->query('INSERT INTO zz_semaphores (id_utente, posizione, updated) VALUES ('.prepare($_SESSION['idutente']).', '.prepare($id_module.', '.$id_record).', NOW())');
+ $dbo->query('DELETE FROM zz_semaphores WHERE id_utente='.prepare($_SESSION['id_utente']).' AND posizione='.prepare($id_module.', '.$id_record));
+ $dbo->query('INSERT INTO zz_semaphores (id_utente, posizione, updated) VALUES ('.prepare($_SESSION['id_utente']).', '.prepare($id_module.', '.$id_record).', NOW())');
echo '
diff --git a/lib/classes/API.php b/lib/classes/API.php
index c6fe6bc08..93273c1f3 100644
--- a/lib/classes/API.php
+++ b/lib/classes/API.php
@@ -45,7 +45,7 @@ class API extends \Util\Singleton
{
$user = Auth::user();
- if (!self::isAPIRequest() || empty($user)) {
+ if (!self::isAPIRequest() || (empty($user) && self::getRequest()['resource'] != 'login')) {
throw new InvalidArgumentException();
}
}
@@ -101,13 +101,18 @@ class API extends \Util\Singleton
$updated = $request['upd'];
$created = $request['crd'];
- $dbo = Database::getConnection();
+ // Paginazione dell'API
+ $page = (int) $request['page'] ?: 0;
+ $length = Settings::get('Lunghezza pagine per API');
+
+ $database = Database::getConnection();
+ $dbo = $database;
$kind = 'retrieve';
$resources = self::getResources()[$kind];
$resource = $request['resource'];
- if (!in_array($resource, $resources)) {
+ if (!in_array($resource, array_keys($resources))) {
$excluded = explode(',', Settings::get('Tabelle escluse per la sincronizzazione API automatica'));
if (!in_array($resource, $excluded)) {
$table = $resource;
@@ -121,10 +126,6 @@ class API extends \Util\Singleton
include $filename;
}
- // Paginazione dell'API
- $page = (int) $request['page'] ?: 0;
- $length = Settings::get('Lunghezza pagine per API');
-
// Generazione automatica delle query
if (empty($results) && !empty($table)) {
try {
@@ -199,7 +200,8 @@ class API extends \Util\Singleton
}
// Database
- $dbo = Database::getConnection();
+ $database = Database::getConnection();
+ $dbo = $database;
$dbo->query('START TRANSACTION');
@@ -333,7 +335,13 @@ class API extends \Util\Singleton
*/
public static function getRequest()
{
- return (array) json_decode(file_get_contents('php://input'), true);
+ $request = (array) json_decode(file_get_contents('php://input'), true);
+
+ if ($_SERVER['REQUEST_METHOD'] == 'GET' && empty($request)) {
+ $request = Filter::getGET();
+ }
+
+ return $request;
}
/**
diff --git a/lib/classes/Auth.php b/lib/classes/Auth.php
index 101fc8581..420b36b40 100644
--- a/lib/classes/Auth.php
+++ b/lib/classes/Auth.php
@@ -45,22 +45,19 @@ class Auth extends \Util\Singleton
if ($database->isInstalled()) {
if (API::isAPIRequest()) {
$token = API::getRequest()['token'];
- $token = !empty($token) ? $token : get('token');
$id = $database->fetchArray('SELECT `id_utente` FROM `zz_tokens` WHERE `token` = '.prepare($token))[0]['id_utente'];
}
// Controllo sulla sessione attiva
- elseif (!empty($_SESSION['idutente'])) {
- $id = $_SESSION['idutente'];
+ elseif (!empty($_SESSION['id_utente'])) {
+ $id = $_SESSION['id_utente'];
}
if (!empty($id)) {
$this->identifyUser($id);
}
- if (!empty($_SESSION['idutente']) && $this->isAuthenticated()) {
- $this->saveToSession();
- }
+ $this->saveToSession();
}
}
@@ -83,20 +80,20 @@ class Auth extends \Util\Singleton
$log['ip'] = get_client_ip();
$log['stato'] = self::$status['failed']['code'];
- $users = $database->fetchArray('SELECT idutente, password, enabled FROM zz_users WHERE username = '.prepare($username).' LIMIT 1');
+ $users = $database->fetchArray('SELECT id_utente, password, enabled FROM zz_users WHERE username = '.prepare($username).' LIMIT 1');
if (!empty($users)) {
$user = $users[0];
if (!empty($user['enabled'])) {
- $this->identifyUser($user['idutente']);
+ $this->identifyUser($user['id_utente']);
$module = $this->getFirstModule();
if (
$this->isAuthenticated() &&
- $this->password_check($password, $user['password'], $user['idutente']) &&
+ $this->password_check($password, $user['password'], $user['id_utente']) &&
!empty($module)
) {
- $log['idutente'] = $this->infos['idutente'];
+ $log['id_utente'] = $this->infos['id_utente'];
$log['stato'] = self::$status['success']['code'];
$this->saveToSession();
@@ -105,7 +102,7 @@ class Auth extends \Util\Singleton
$log['stato'] = self::$status['unauthorized']['code'];
}
- $this->logout();
+ $this->destory();
}
} else {
$log['stato'] = self::$status['disabled']['code'];
@@ -154,7 +151,7 @@ class Auth extends \Util\Singleton
// Controllo in automatico per futuri cambiamenti dell'algoritmo di password
if ($rehash) {
$database = Database::getConnection();
- $database->update('zz_users', ['password' => self::hashPassword($password)], ['idutente' => $user_id]);
+ $database->update('zz_users', ['password' => self::hashPassword($password)], ['id_utente' => $user_id]);
}
return $result;
@@ -165,14 +162,16 @@ class Auth extends \Util\Singleton
*/
protected function saveToSession()
{
- foreach ($this->infos as $key => $value) {
- $_SESSION[$key] = $value;
- }
+ if(session_status() == PHP_SESSION_ACTIVE && $this->isAuthenticated()){
+ foreach ($this->infos as $key => $value) {
+ $_SESSION[$key] = $value;
+ }
- $identifier = md5($_SESSION['idutente'].$_SERVER['HTTP_USER_AGENT']);
- if ((empty($_SESSION['last_active']) || time() < $_SESSION['last_active'] + (60 * 60)) && (empty($_SESSION['identifier']) || $_SESSION['identifier'] == $identifier)) {
- $_SESSION['last_active'] = time();
- $_SESSION['identifier'] = $identifier;
+ $identifier = md5($_SESSION['id_utente'].$_SERVER['HTTP_USER_AGENT']);
+ if ((empty($_SESSION['last_active']) || time() < $_SESSION['last_active'] + (60 * 60)) && (empty($_SESSION['identifier']) || $_SESSION['identifier'] == $identifier)) {
+ $_SESSION['last_active'] = time();
+ $_SESSION['identifier'] = $identifier;
+ }
}
}
@@ -186,7 +185,7 @@ class Auth extends \Util\Singleton
$database = Database::getConnection();
try {
- $results = $database->fetchArray('SELECT idutente, idanagrafica, username, (SELECT nome FROM zz_groups WHERE id=idgruppo) AS gruppo FROM zz_users WHERE idutente = '.prepare($user_id).' AND enabled = 1 LIMIT 1', false, ['session' => false]);
+ $results = $database->fetchArray('SELECT id_utente, idanagrafica, username, (SELECT nome FROM zz_groups WHERE id=idgruppo) AS gruppo FROM zz_users WHERE id_utente = '.prepare($user_id).' AND enabled = 1 LIMIT 1', false, ['session' => false]);
if (!empty($results)) {
$results[0]['is_admin'] = ($results[0]['gruppo'] == 'Amministratori');
@@ -233,7 +232,7 @@ class Auth extends \Util\Singleton
*/
public function destory()
{
- if ($this->isAuthenticated() || !empty($_SESSION['idutente'])) {
+ if ($this->isAuthenticated() || !empty($_SESSION['id_utente'])) {
$this->infos = null;
$this->first_module = null;
diff --git a/lib/classes/Database.php b/lib/classes/Database.php
index e815006f1..134e208c5 100644
--- a/lib/classes/Database.php
+++ b/lib/classes/Database.php
@@ -86,8 +86,8 @@ class Database extends Util\Singleton
$this->pdo = $pdo;
- if (empty($this->charset)) {
- $this->charset = version_compare($this->getMySQLVersion(), '5.5.3') >= 0 ? 'utf8mb4' : 'utf8';
+ if (empty($this->charset) && version_compare($this->getMySQLVersion(), '5.5.3') >= 0) {
+ $this->charset = 'utf8mb4';
}
// Fix per problemi di compatibilità delle password MySQL 4.1+ (da versione precedente)
diff --git a/lib/classes/HTMLBuilder/Handler/DateHandler.php b/lib/classes/HTMLBuilder/Handler/DateHandler.php
index 99e4212a9..fc5304c77 100644
--- a/lib/classes/HTMLBuilder/Handler/DateHandler.php
+++ b/lib/classes/HTMLBuilder/Handler/DateHandler.php
@@ -54,6 +54,7 @@ class DateHandler implements HandlerInterface
{
$values['class'][] = 'text-center';
$values['class'][] = 'timestamp-picker';
+ $values['class'][] = 'timestamp-mask';
$values['value'] = (\Translator::getLocaleFormatter()->isTimestamp($values['value'])) ? $values['value'] : '';
}
diff --git a/lib/classes/Modules.php b/lib/classes/Modules.php
index 9d7b3dc7f..2e8c07303 100644
--- a/lib/classes/Modules.php
+++ b/lib/classes/Modules.php
@@ -38,7 +38,7 @@ class Modules
$user = Auth::user();
- $results = $database->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `idutente` = '.prepare($user['idutente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `idmodule`, `clause`, `position` FROM `zz_group_module` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `idutente` = '.prepare($user['idutente']).') AND `enabled` = 1) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
+ $results = $database->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `id_utente` = '.prepare($user['id_utente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `idmodule`, `clause`, `position` FROM `zz_group_module` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `id_utente` = '.prepare($user['id_utente']).') AND `enabled` = 1) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
$modules = [];
$additionals = [];
@@ -210,7 +210,7 @@ class Modules
$user = Auth::user();
- $datas = $database->fetchArray('SELECT * FROM `zz_views` WHERE `id_module`='.prepare($id).' AND `id` IN (SELECT `id_vista` FROM `zz_group_view` WHERE `id_gruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `idutente`='.prepare($user['idutente']).')) ORDER BY `order` ASC');
+ $datas = $database->fetchArray('SELECT * FROM `zz_views` WHERE `id_module`='.prepare($id).' AND `id` IN (SELECT `id_vista` FROM `zz_group_view` WHERE `id_gruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `id_utente`='.prepare($user['id_utente']).')) ORDER BY `order` ASC');
if (!empty($datas)) {
$select = '';
diff --git a/lib/deprecated.php b/lib/deprecated.php
index 9a8f75fa8..bba3793c0 100644
--- a/lib/deprecated.php
+++ b/lib/deprecated.php
@@ -133,7 +133,7 @@ function get_permessi($nome_modulo)
trigger_error(_('Funzione deprecata!'), E_USER_DEPRECATED);
$dbo = \Database::getConnection();
- $query = 'SELECT *, (SELECT idanagrafica FROM zz_users WHERE idutente='.prepare($_SESSION['idutente']).') AS idanagrafica FROM zz_permissions WHERE idgruppo=(SELECT idgruppo FROM zz_users WHERE idutente='.prepare($_SESSION['idutente']).') AND idmodule=(SELECT id FROM zz_modules WHERE name='.prepare($nome_modulo).')';
+ $query = 'SELECT *, (SELECT idanagrafica FROM zz_users WHERE id_utente='.prepare($_SESSION['id_utente']).') AS idanagrafica FROM zz_permissions WHERE idgruppo=(SELECT idgruppo FROM zz_users WHERE id_utente='.prepare($_SESSION['id_utente']).') AND idmodule=(SELECT id FROM zz_modules WHERE name='.prepare($nome_modulo).')';
$rs = $dbo->fetchArray($query);
if (count($rs) <= 0) {
// Ultimo tentativo: se non ci sono i permessi ma sono l'amministratore posso comunque leggere il modulo
diff --git a/lib/functions.js b/lib/functions.js
index 505e576ac..6d235da61 100644
--- a/lib/functions.js
+++ b/lib/functions.js
@@ -16,7 +16,12 @@ var isMobile = {
},
any: function () {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
+ },
+ complete: function () {
+ return (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) ||
+ /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4)));
}
+
};
// Aggiunta dell'ingranaggio all'unload della pagina
@@ -159,6 +164,10 @@ $(document).ready(function () {
}
});
+ if (isMobile.complete()) {
+ $(".sidebar-menu").sortable("disable");
+ }
+
// Tabs
$('#tabs').tabs();
@@ -168,18 +177,21 @@ $(document).ready(function () {
$('ul.nav a[href="' + hash + '"]').tab('show');
}
- // Salvo lo scroll per riportare qui l'utente al reload
- $(window).on('scroll', function () {
- if (localStorage != undefined) {
- localStorage.setItem('scrollTop_' + globals.id_module + '_' + globals.id_record, $(document).scrollTop());
- }
- });
+ // Nel caso la navigazione sia da mobile, disabilito il ritorno al punto precedente
+ if (!isMobile.complete()) {
+ // Salvo lo scroll per riportare qui l'utente al reload
+ $(window).on('scroll', function () {
+ if (localStorage != undefined) {
+ localStorage.setItem('scrollTop_' + globals.id_module + '_' + globals.id_record, $(document).scrollTop());
+ }
+ });
- // Riporto l'utente allo scroll precedente
- if (localStorage['scrollTop_' + globals.id_module + '_' + globals.id_record] != undefined) {
- setTimeout(function () {
- scrollToAndFocus(localStorage['scrollTop_' + globals.id_module + '_' + globals.id_record]);
- }, 1);
+ // Riporto l'utente allo scroll precedente
+ if (localStorage['scrollTop_' + globals.id_module + '_' + globals.id_record] != undefined) {
+ setTimeout(function () {
+ scrollToAndFocus(localStorage['scrollTop_' + globals.id_module + '_' + globals.id_record]);
+ }, 1);
+ }
}
$('.nav-tabs a').click(function (e) {
@@ -443,7 +455,6 @@ function start_datatables() {
order: [],
lengthChange: false,
scrollY: "50vh",
- stateSave: true,
});
}
});
@@ -502,6 +513,12 @@ function start_datatables() {
scrollX: '100%',
retrieve: true,
stateSave: true,
+ stateSaveCallback: function (settings, data) {
+ localStorage.setItem('DataTables_' + id_module + '-' + id_plugin + '-' + id_parent, JSON.stringify(data));
+ },
+ stateLoadCallback: function (settings) {
+ return JSON.parse(localStorage.getItem('DataTables_' + id_module + '-' + id_plugin + '-' + id_parent));
+ },
columnDefs: [{
searchable: false,
orderable: false,
@@ -919,18 +936,30 @@ jQuery.fn.selectData = function () {
// Inputmask
function start_inputmask() {
- $(".date-mask").inputmask(moment.localeData().longDateFormat('L').toLowerCase(), {
- "placeholder": moment.localeData().longDateFormat('L').toLowerCase()
+ var date = moment.localeData().longDateFormat('L').toLowerCase();
+ $(".date-mask").inputmask(date, {
+ "placeholder": date
+ });
+/*
+ $(".timestamp-mask").inputmask(date + ' ' + moment.localeData().longDateFormat('LT').toLowerCase().replace('mm', 'ss'), {
+ "placeholder": date + ' ' + moment.localeData().longDateFormat('LT').toLowerCase().replace('mm', 'ss')
+ });
+*/
+ $(".timestamp-mask").inputmask("timestamp", {
+ mask: "2/1/y h:s",
+ placeholder: "dd/mm/yyyy hh:mm",
+ separator: "/",
+ alias: "datetime",
+ hourFormat: "24"
});
$('.email-mask').inputmask('Regex', {
regex: "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+(?:\\.[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+)*@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$",
});
- if (isMobile.any()) {
- $('.inputmask-decimal').each(function () {
- val = $(this).val().toEnglish();
- $(this).attr('type', 'tel').val(val);
+ if (isMobile.complete()) {
+ $('.inputmask-decimal, .date-mask, .timestamp-mask').each(function () {
+ $(this).attr('type', 'tel');
});
} else {
$('.inputmask-decimal').each(function () {
diff --git a/lib/init.js b/lib/init.js
index 029c59676..8f921f2ae 100644
--- a/lib/init.js
+++ b/lib/init.js
@@ -44,7 +44,10 @@ $(document).ready(function () {
$this.datetimepicker({
locale: globals.locale,
icons: icons,
+ collapse: false,
+ sideBySide: true,
useCurrent: false,
+ stepping: 5,
minDate: $this.attr('min-date') ? $this.attr('min-date') : false,
maxDate: $this.attr('max-date') ? $this.attr('max-date') : false,
});
diff --git a/lib/permissions_check.php b/lib/permissions_check.php
deleted file mode 100644
index a0d78346c..000000000
--- a/lib/permissions_check.php
+++ /dev/null
@@ -1,61 +0,0 @@
-fetchArray("SELECT name FROM zz_modules WHERE id='".$html->form('id_module')."'");
- $module_name = $rs[0]['name'];
- }
-
-
- //Il modulo "Info" è visibile da tutti
- if( $module_name == 'Info' ){
- $permessi[$module_name] = 'r';
- }
-
- else{
- $rs = $dbo->fetchArray("SELECT idanagrafica FROM zz_users WHERE idutente='".$_SESSION['idutente']."'");
- $user_idanagrafica = $rs[0]['idanagrafica'];
-
- $query = "SELECT *, (SELECT idanagrafica FROM zz_users WHERE idutente='".$_SESSION['idutente']."') AS idanagrafica FROM zz_permissions WHERE idgruppo=(SELECT idgruppo FROM zz_users WHERE idutente='".$_SESSION['idutente']."') AND idmodule=(SELECT id FROM zz_modules WHERE name='".$module_name."')";
- $rs = $dbo->fetchArray($query);
-
-
- if( sizeof($rs)<=0 ){
- //Ultimo tentativo: se non ci sono i permessi ma sono l'amministratore posso comunque leggere il modulo
- if( $_SESSION['is_admin']==1 ){
- $permessi[$module_name] = 'rw';
- }
- else{
- echo "
Non hai i permessi per accedere a questo modulo.
\n";
- $permessi[$module_name] = '-';
- exit;
- }
- }
- else{
- if( $rs[0]['permessi']=='-' ){
- echo "
Non hai i permessi per accedere a questo modulo.
\n";
- $permessi[$module_name] = '-';
- exit;
- }
- else if( $rs[0]['permessi']=='r' ){
- $permessi[$module_name] = 'r';
- }
- else if( $rs[0]['permessi']=='rw' ){
- $permessi[$module_name] = 'rw';
- }
- }
-
-
- //Carico i filtri dei WHERE in base al modulo e all'utente loggato
- $qp = "SELECT *, (SELECT idanagrafica FROM zz_users WHERE idutente='".$_SESSION['idutente']."') AS idanagrafica, (SELECT name FROM zz_modules WHERE id=idmodule) AS nome_modulo FROM zz_group_module WHERE idgruppo=(SELECT idgruppo FROM zz_users WHERE idutente='".$_SESSION['idutente']."')";
- $rsp = $dbo->fetchArray($qp);
- for( $i=0; $i
diff --git a/lib/user_check.php b/lib/user_check.php
deleted file mode 100644
index 90f4fce29..000000000
--- a/lib/user_check.php
+++ /dev/null
@@ -1,17 +0,0 @@
-
diff --git a/log.php b/log.php
index 6ea2757d8..7e4981c58 100644
--- a/log.php
+++ b/log.php
@@ -35,14 +35,14 @@ echo '
if (Auth::admin()) {
$q = 'SELECT * FROM `zz_logs` ORDER BY `created_at` DESC LIMIT 0, 100';
} else {
- $q = 'SELECT * FROM `zz_logs` WHERE `idutente`='.prepare($_SESSION['idutente']).' ORDER BY `created_at` DESC LIMIT 0, 100';
+ $q = 'SELECT * FROM `zz_logs` WHERE `id_utente`='.prepare($_SESSION['id_utente']).' ORDER BY `created_at` DESC LIMIT 0, 100';
}
$rs = $dbo->fetchArray($q);
$n = sizeof($rs);
for ($i = 0; $i < $n; ++$i) {
$id = $rs[$i]['id'];
- $idutente = $rs[$i]['idutente'];
+ $id_utente = $rs[$i]['id_utente'];
$username = $rs[$i]['username'];
$ip = $rs[$i]['ip'];
diff --git a/modules/ddt/edit.php b/modules/ddt/edit.php
index f434c2047..195b25a03 100644
--- a/modules/ddt/edit.php
+++ b/modules/ddt/edit.php
@@ -69,7 +69,7 @@ if ($dir == 'uscita') {
- '.$r['ragione_sociale'].'
- '._('Orario').'
- '._('Ore').'
- '._('Km').'
- '._('Sconto ore').'
- '._('Sconto km').'
-
+ '.$r['ragione_sociale'].'
+ '._('Orario inizio').'
+ '._('Orario fine').'
+ '._('Ore').'
+ '._('Km').'
+ '._('Sconto ore').'
+ '._('Sconto km').'
+
';
}
@@ -88,9 +89,8 @@ if (!empty($rs2)) {
$costo_km_consuntivo = $r['prezzo_km_consuntivo'];
$costo_ore_consuntivo = $r['prezzo_ore_consuntivo'];
- $orario_inizio = !empty($r['orario_inizio']) ? Translator::timestampToLocale($r['orario_inizio']) : $r['orario_inizio'];
- $orario_fine = !empty($r['orario_fine']) ? Translator::timestampToLocale($r['orario_fine']) : $r['orario_fine'];
- $orario = $orario_inizio.' - '.$orario_fine;
+ $orario_inizio = $r['orario_inizio'];
+ $orario_fine = $r['orario_fine'];
$km = $r['km'];
$ore = $r['ore'];
@@ -120,20 +120,34 @@ if (!empty($rs2)) {
echo '
';
- // Orario
+ // Orario di inizio
echo '
';
if ($rs[0]['stato'] == 'Fatturato') {
echo '
- '.$ora_dal1.'
- ';
+ '.$orario_inizio.'
+ ';
} else {
echo '
- ';
+ {[ "type": "timestamp", "name": "orario_inizio['.$id.']", "id": "inizio_'.$id.'", "value": "'.$orario_inizio.'", "class": "orari" ]}';
}
echo '
';
+ // Orario di fine
+ echo '
+ ';
+ if ($rs[0]['stato'] == 'Fatturato') {
+ echo '
+ '.$orario_fine.'
+ ';
+ } else {
+ echo '
+ {[ "type": "timestamp", "name": "orario_fine['.$id.']", "id": "fine_'.$id.'", "value": "'.$orario_fine.'", "class": "orari", "min-date": "'.$orario_inizio.'" ]}';
+ }
+ echo '
+ ';
+
// ORE
echo '
@@ -251,36 +265,29 @@ echo '
?>
-
- orario = $('#orario_'+idriga).val();
- o = orario.split(' - ');
+
-
-
diff --git a/modules/utenti/actions.php b/modules/utenti/actions.php
index c3e86207f..779e2e6a5 100644
--- a/modules/utenti/actions.php
+++ b/modules/utenti/actions.php
@@ -2,26 +2,26 @@
include_once __DIR__.'/../../core.php';
-$id_utente = filter('idutente');
+$id_utente = filter('id_utente');
switch (filter('op')) {
// Abilita utente
case 'enable':
- if ($dbo->query('UPDATE zz_users SET enabled=1 WHERE idutente='.prepare($id_utente))) {
+ if ($dbo->query('UPDATE zz_users SET enabled=1 WHERE id_utente='.prepare($id_utente))) {
$_SESSION['infos'][] = _('Utente abilitato!');
}
break;
// Disabilita utente
case 'disable':
- if ($dbo->query('UPDATE zz_users SET enabled=0 WHERE idutente='.prepare($id_utente))) {
+ if ($dbo->query('UPDATE zz_users SET enabled=0 WHERE id_utente='.prepare($id_utente))) {
$_SESSION['infos'][] = _('Utente disabilitato!');
}
break;
// Cambio di password e usernome dell'utente
case 'change_pwd':
- $id_utente = filter('idutente');
+ $id_utente = filter('id_utente');
$min_length = filter('min_length');
$min_length_username = filter('min_length_username');
@@ -34,7 +34,7 @@ switch (filter('op')) {
} elseif ($password != $password_rep) {
$_SESSION['errors'][] = _('Le password non coincidono');
} else {
- $dbo->query('UPDATE zz_users SET password='.prepare(Auth::hashPassword($password)).' WHERE idutente='.prepare($id_utente));
+ $dbo->query('UPDATE zz_users SET password='.prepare(Auth::hashPassword($password)).' WHERE id_utente='.prepare($id_utente));
$_SESSION['infos'][] = _('Password aggiornata!');
}
@@ -42,13 +42,13 @@ switch (filter('op')) {
$username = filter('username');
// Se ho modificato l'username, verifico che questo non sia già stato usato
- $rs = $dbo->fetchArray('SELECT username FROM zz_users WHERE idutente='.prepare($id_utente));
+ $rs = $dbo->fetchArray('SELECT username FROM zz_users WHERE id_utente='.prepare($id_utente));
if ($rs[0]['username'] != $username) {
- $n = $dbo->fetchNum('SELECT idutente FROM zz_users WHERE username='.prepare($username));
+ $n = $dbo->fetchNum('SELECT id_utente FROM zz_users WHERE username='.prepare($username));
if ($n == 0) {
- $dbo->query('UPDATE zz_users SET username='.prepare($username).' WHERE idutente='.prepare($id_utente));
+ $dbo->query('UPDATE zz_users SET username='.prepare($username).' WHERE id_utente='.prepare($id_utente));
$_SESSION['infos'][] = _('Username aggiornato!');
} else {
@@ -111,7 +111,7 @@ switch (filter('op')) {
// Elimina utente
case 'delete':
- if ($dbo->query('DELETE FROM zz_users WHERE idutente='.prepare($id_utente))) {
+ if ($dbo->query('DELETE FROM zz_users WHERE id_utente='.prepare($id_utente))) {
$_SESSION['infos'][] = _('Utente eliminato!');
}
break;
diff --git a/modules/utenti/api/create.php b/modules/utenti/api/create.php
new file mode 100644
index 000000000..89db30f62
--- /dev/null
+++ b/modules/utenti/api/create.php
@@ -0,0 +1,34 @@
+attempt($request['username'], $request['password'])) {
+ $user = Auth::user();
+
+ // Generazione del token per l'utente
+ $tokens = $database->fetchArray('SELECT `token` FROM `zz_tokens` WHERE `enabled` = 1 AND `id_utente` = '.prepare($user['id_utente']));
+ if (empty($tokens)) {
+ $token = secure_random_string();
+ $database->insert('zz_tokens', [
+ 'id_utente' => $user['id_utente'],
+ 'token' => $token,
+ ]);
+ } else {
+ $token = $tokens[0]['token'];
+ }
+
+ $results = $dbo->fetchArray('SELECT `ragione_sociale`, `codice`, `piva`, `codice_fiscale`, `indirizzo`, `citta`, `provincia`, (SELECT `nome` FROM `an_nazioni` WHERE `an_nazioni`.`id` = `an_anagrafiche`.`id_nazione`) AS nazione, `telefono`, `fax`, `indirizzo`, `citta`, `provincia`, `indirizzo`, `citta`, `an_anagrafiche`.`email` FROM `zz_users` LEFT JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `zz_users`.`idanagrafica` WHERE `id_utente` = '.prepare($user['id_utente']))[0];
+
+ $results['token'] = $token;
+ } else {
+ $results = [
+ 'status' => API::getStatus()['unauthorized']['code'],
+ ];
+ }
+
+ break;
+}
+
+return [
+ 'login',
+];
diff --git a/modules/utenti/edit.php b/modules/utenti/edit.php
index c1e681771..1bbffe577 100644
--- a/modules/utenti/edit.php
+++ b/modules/utenti/edit.php
@@ -47,14 +47,14 @@ if (count($utenti) != 0) {
*/
echo '
';
- // Disabilitazione utente, se diverso da idutente #1 (admin)
- if ($utenti[$u]['idutente'] != '1') {
+ // Disabilitazione utente, se diverso da id_utente #1 (admin)
+ if ($utenti[$u]['id_utente'] != '1') {
if ($utenti[$u]['enabled'] == 1) {
echo '
- ';
+ ';
} else {
echo '
- ';
+ ';
}
} else {
echo '
@@ -63,12 +63,12 @@ if (count($utenti) != 0) {
// Cambio password e nome utente
echo '
- ';
+ ';
- // Eliminazione utente, se diverso da idutente #1 (admin)
- if ($utenti[$u]['idutente'] != '1') {
+ // Eliminazione utente, se diverso da id_utente #1 (admin)
+ if ($utenti[$u]['id_utente'] != '1') {
echo '
- ';
+ ';
} else {
echo '
';
diff --git a/modules/utenti/user.php b/modules/utenti/user.php
index 9c73d8580..7ca229136 100644
--- a/modules/utenti/user.php
+++ b/modules/utenti/user.php
@@ -6,11 +6,11 @@ include_once __DIR__.'/../../core.php';
$min_length = 8;
$min_length_username = 4;
$idgruppo = intval(filter('idgruppo'));
-$id_utente = filter('idutente');
+$id_utente = filter('id_utente');
if (!empty($id_utente)) {
$value = 'change_pwd';
- $rs = $dbo->fetchArray('SELECT username FROM zz_users WHERE idutente='.prepare($id_utente));
+ $rs = $dbo->fetchArray('SELECT username FROM zz_users WHERE id_utente='.prepare($id_utente));
$username = $rs[0]['username'];
$message = _('Modifica');
} else {
@@ -27,7 +27,7 @@ echo '
';
if (!empty($id_utente)) {
echo '
- ';
+ ';
}
echo '
diff --git a/templates/riepilogo_interventi/pdfgen.riepilogo_interventi.php b/templates/riepilogo_interventi/pdfgen.riepilogo_interventi.php
index fc0a84985..65f93ddb0 100644
--- a/templates/riepilogo_interventi/pdfgen.riepilogo_interventi.php
+++ b/templates/riepilogo_interventi/pdfgen.riepilogo_interventi.php
@@ -8,7 +8,7 @@ $id_module = $html->form('id_module');
$fields = [];
$select = '*';
-$datas = $dbo->fetchArray('SELECT * FROM zz_views WHERE id_module='.$id_module.' AND id IN (SELECT id_vista FROM zz_group_view WHERE id_gruppo=(SELECT idgruppo FROM zz_users WHERE idutente='.$_SESSION['idutente'].')) ORDER BY `order` ASC');
+$datas = $dbo->fetchArray('SELECT * FROM zz_views WHERE id_module='.$id_module.' AND id IN (SELECT id_vista FROM zz_group_view WHERE id_gruppo=(SELECT idgruppo FROM zz_users WHERE id_utente='.$_SESSION['id_utente'].')) ORDER BY `order` ASC');
if ($datas != null) {
$select = '';
foreach ($datas as $data) {
diff --git a/update/2_3.php b/update/2_3.php
index 013078da7..4305e39bc 100644
--- a/update/2_3.php
+++ b/update/2_3.php
@@ -21,20 +21,6 @@ if (!empty($array)) {
$database->insert('zz_group_view', $array);
}
-// Generazione delle chiavi di default per gli utenti
-$utenti = $database->fetchArray('SELECT `idutente` FROM `zz_users`');
-
-$array = [];
-foreach ($utenti as $utente) {
- $array[] = [
- 'id_utente' => $utente['idutente'],
- 'token' => secure_random_string(),
- ];
-}
-if (!empty($array)) {
- $database->insert('zz_tokens', $array);
-}
-
/*
* Fix
*/
diff --git a/update/2_3.sql b/update/2_3.sql
index 35e63801d..a8e01d4a4 100644
--- a/update/2_3.sql
+++ b/update/2_3.sql
@@ -666,22 +666,25 @@ ALTER TABLE `zz_permissions` ADD FOREIGN KEY (`idmodule`) REFERENCES `zz_modules
ALTER TABLE `zz_plugins` ADD FOREIGN KEY (`idmodule_from`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, ADD FOREIGN KEY (`idmodule_to`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE;
-- Aggiunta di chiavi esterne in zz_users
-ALTER TABLE `zz_users` CHANGE `idutente` `idutente` int(11) NOT NULL AUTO_INCREMENT, ADD FOREIGN KEY (`idgruppo`) REFERENCES `zz_groups`(`id`) ON DELETE CASCADE;
+ALTER TABLE `zz_users` CHANGE `idutente` `id_utente` int(11) NOT NULL AUTO_INCREMENT, ADD FOREIGN KEY (`idgruppo`) REFERENCES `zz_groups`(`id`) ON DELETE CASCADE;
-- Aggiunta di chiavi esterne in zz_logs
-ALTER TABLE `zz_logs` DROP `password`, CHANGE `idutente` `idutente` int(11), CHANGE `timestamp` `timestamp` datetime;
-UPDATE `zz_logs` SET `idutente` = NULL WHERE `idutente` = 0;
-ALTER TABLE `zz_logs` ADD FOREIGN KEY (`idutente`) REFERENCES `zz_users`(`idutente`) ON DELETE CASCADE;
+ALTER TABLE `zz_logs` DROP `password`, CHANGE `idutente` `id_utente` int(11), CHANGE `timestamp` `timestamp` datetime;
+UPDATE `zz_logs` SET `id_utente` = NULL WHERE `id_utente` = 0;
+ALTER TABLE `zz_logs` ADD FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id_utente`) ON DELETE CASCADE;
-- Aggiunta di chiavi esterne in zz_semaphores
-ALTER TABLE `zz_semaphores` ADD FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`idutente`) ON DELETE CASCADE;
+ALTER TABLE `zz_semaphores` ADD FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id_utente`) ON DELETE CASCADE;
-- Aggiunta della tabella per gestire le chiavi di accesso all'API
CREATE TABLE IF NOT EXISTS `zz_tokens` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
`id_utente` int(11) NOT NULL,
- `token` varchar(255) NOT NULL,
- PRIMARY KEY (`id_utente`),
- FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`idutente`) ON DELETE CASCADE
+ `token` varchar(255) NOT NULL UNIQUE,
+ `descrizione` varchar(255),
+ `enabled` boolean NOT NULL DEFAULT 1,
+ PRIMARY KEY (`id`),
+ FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id_utente`) ON DELETE CASCADE
) ENGINE=InnoDB;
-- Modifica di an_sedi per sostituire le nazioni con i corrispettivi nella tabella apposita