diff --git a/actions.php b/actions.php index b9bb77280..8a3bcf832 100644 --- a/actions.php +++ b/actions.php @@ -108,6 +108,17 @@ elseif (filter('op') == 'add_nota') { flash()->info(tr('Nota interna aggiunta correttamente!')); } +// Rimozione data di notifica dalla nota interna +elseif (filter('op') == 'notification_nota') { + $id_nota = post('id_nota'); + $nota = Note::find($id_nota); + + $nota->notification_date = null; + $nota->save(); + + flash()->info(tr('Data di notifica rimossa dalla nota interna!')); +} + // Rimozione nota interna elseif (filter('op') == 'delete_nota') { $id_nota = post('id_nota'); @@ -122,10 +133,14 @@ elseif (filter('op') == 'delete_nota') { elseif (filter('op') == 'clone_checklist') { $content = post('content'); $checklist_id = post('checklist'); - $assigned_user = User::find(post('assigned_user')); + + $users = post('assigned_users'); + $users = array_clean($users); + + $group_id = post('group_id'); $checklist = Checklist::find($checklist_id); - $checklist->copia($user, $assigned_user, $id_record); + $checklist->copia($user, $id_record, $users, $group_id); } // Aggiunta check alla checklist @@ -133,9 +148,13 @@ elseif (filter('op') == 'add_check') { $content = post('content'); $parent_id = post('parent') ?: null; - $assigned_user = User::find(post('assigned_user')); + $users = post('assigned_users'); + $users = array_clean($users); - $check = Check::build($user, $structure, $id_record, $content, $assigned_user, $parent_id); + $group_id = post('group_id'); + + $check = Check::build($user, $structure, $id_record, $content, $parent_id); + $check->setAccess($users, $group_id); } // Rimozione di un check della checklist @@ -143,8 +162,10 @@ elseif (filter('op') == 'delete_check') { $check_id = post('check_id'); $check = Check::find($check_id); - if (!empty($check)) { + if (!empty($check) && $check->user->id == $user->id) { $check->delete(); + } else { + flash()->error(tr('Impossibile eliminare il check!')); } } @@ -153,8 +174,21 @@ elseif (filter('op') == 'toggle_check') { $check_id = post('check_id'); $check = Check::find($check_id); - if (!empty($check)) { + if (!empty($check) && $check->assignedUsers->pluck('id')->search($user->id) !== false) { $check->toggleCheck(); + } else { + flash()->error(tr('Impossibile cambiare lo stato del check!')); + } +} + +// Gestione ordine per le checklist +elseif (filter('op') == 'sort_checks') { + $ids = explode(',', $_POST['order']); + $order = 0; + + foreach ($ids as $id) { + $dbo->query('UPDATE `zz_checks` SET `order` = '.prepare($order).' WHERE id = '.prepare($id)); + ++$order; } } diff --git a/ajax.php b/ajax.php index 00402a238..d2c611bc0 100644 --- a/ajax.php +++ b/ajax.php @@ -55,7 +55,7 @@ switch (get('op')) { break; case 'checklists': - echo '{( "name": "checklists", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'", "id_plugin": "'.$id_plugin.'" )}'; + include DOCROOT.'/plugins/checks.php'; break; diff --git a/assets/src/css/style.css b/assets/src/css/style.css index 595960d6f..32d46fc87 100644 --- a/assets/src/css/style.css +++ b/assets/src/css/style.css @@ -851,39 +851,6 @@ input.small-width { font-weight: bold; } -/* Checklist */ -ul.checklist { - list-style-type: none; - margin: 0; - padding: 0; -} - -ul.checklist li { - cursor: pointer; - position: relative; - padding: 12px 8px 12px 10px; - font-size: 18px; - transition: 0.2s; - - /* make the list items unselectable */ - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -ul.checklist li:hover { - background: #ddd; -} - -ul.checklist li.checked { - background: #eee; -} - -ul.checklist li.checked > .check-text { - text-decoration: line-through; -} - .component-loader { position: absolute; z-index: 20; @@ -898,3 +865,9 @@ ul.checklist li.checked > .check-text { top: 50%; color: #333; } + +/* Checklist */ +.todo-list ul { + list-style: none; + margin-left: 11px; +} diff --git a/assets/src/js/functions/functions.js b/assets/src/js/functions/functions.js index ab2da8133..70b34e15c 100644 --- a/assets/src/js/functions/functions.js +++ b/assets/src/js/functions/functions.js @@ -68,15 +68,10 @@ function openLink(event, link) { } /** - * Funzione per far scrollare la pagina fino a un id + focus e offset + * Funzione per far scrollare la pagina fino a un offset * @param integer offset - * @param string id */ -function scrollToAndFocus(offset, id) { - if (id) { - offset += $('#' + id).offset().top; - } - +function scrollToOffset(offset) { $('html,body').animate({ scrollTop: offset }, 'slow'); @@ -420,32 +415,7 @@ function submitAjax(form, data, callback, errorCallback) { $("#main_loading").fadeOut(); - // Visualizzazione messaggi - $.ajax({ - url: globals.rootdir + '/ajax.php', - type: 'get', - data: { - op: 'flash', - }, - success: function (flash) { - messages = JSON.parse(flash); - - info = messages.info ? messages.info : {}; - Object.keys(info).forEach(function (element) { - toastr["success"](info[element]); - }); - - warning = messages.warning ? messages.warning : {}; - Object.keys(warning).forEach(function (element) { - toastr["warning"](warning[element]); - }); - - error = messages.error ? messages.error : {}; - Object.keys(error).forEach(function (element) { - toastr["error"](error[element]); - }); - } - }); + renderMessages(); }, error: function (data) { $("#main_loading").fadeOut(); @@ -460,6 +430,34 @@ function submitAjax(form, data, callback, errorCallback) { return valid; } +function renderMessages() { + // Visualizzazione messaggi + $.ajax({ + url: globals.rootdir + '/ajax.php', + type: 'get', + data: { + op: 'flash', + }, + success: function (flash) { + messages = JSON.parse(flash); + + info = messages.info ? messages.info : {}; + Object.keys(info).forEach(function (element) { + toastr["success"](info[element]); + }); + + warning = messages.warning ? messages.warning : {}; + Object.keys(warning).forEach(function (element) { + toastr["warning"](warning[element]); + }); + + error = messages.error ? messages.error : {}; + Object.keys(error).forEach(function (element) { + toastr["error"](error[element]); + }); + } + }); +} function removeHash() { history.replaceState(null, null, ' '); } diff --git a/assets/src/js/functions/prototypes.js b/assets/src/js/functions/prototypes.js index e0571e905..7c63036ca 100644 --- a/assets/src/js/functions/prototypes.js +++ b/assets/src/js/functions/prototypes.js @@ -17,3 +17,10 @@ String.prototype.toEnglish = function () { Number.prototype.toLocale = function () { return numeral(this).format(); }; + +jQuery.fn.scrollTo = function(elem, speed) { + $(this).animate({ + scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top + }, speed == undefined ? 1000 : speed); + return this; +}; diff --git a/assets/src/js/navigation.js b/assets/src/js/navigation.js index 16984d976..fc2bfdf3c 100644 --- a/assets/src/js/navigation.js +++ b/assets/src/js/navigation.js @@ -28,7 +28,7 @@ $(document).ready(function () { // Riporto l'utente allo scroll precedente if (sessionStorage['scrollTop_' + globals.id_module + '_' + globals.id_record] != undefined) { setTimeout(function () { - scrollToAndFocus(sessionStorage['scrollTop_' + globals.id_module + '_' + globals.id_record]); + scrollToOffset(sessionStorage['scrollTop_' + globals.id_module + '_' + globals.id_record]); }, 1); } } diff --git a/editor.php b/editor.php index 60b167c26..5943f9ae2 100755 --- a/editor.php +++ b/editor.php @@ -93,10 +93,23 @@ if (empty($record) || !$has_access) { } // Tab per le note interne - if ($structure->permission != '-') { + if ($structure->permission != '-' && $structure->use_notes) { + $notes = $structure->recordNotes($id_record); + echo '
'.tr('Non sono presenti note interne').'
'; - } - - if ($structure->permission == 'rw') { - echo ' - '; - } + include DOCROOT.'/plugins/checks.php'; echo ''.tr('Non ci sono note da notificare').'.
'; + + return; +} + +$moduli = $notes->groupBy('id_module')->sortBy('notification_date'); +foreach ($moduli as $module_id => $note) { + $modulo = Module::get($module_id); + + echo ' +'.tr('Record').' | +'.tr('Contenuto').' | +'.tr('Data di notifica').' | +
---|---|---|
'.$nota->id_record.' | ++ '.Modules::link($module_id, $nota->id_record, null, null, null, true, 'tab_note').' + + '.$nota->content.' + + '.$nota->user->nome_completo.' + | ++ '.$nota->notification_date.' + ('.Carbon::parse($nota->notification_date)->diffForHumans().') + | +
'.tr('Attività ').' | -'.tr('Data richiesta').' | +'.tr('Data richiesta').' |
---|