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('Note interne').' + + '.tr('Note interne').' + '.($notes->count() ?: '').' + +
  • '; + } + + // Tab per le checklist + if ($structure->permission != '-' && $structure->use_checklists) { + echo ' +
  • + '.tr('Checklist').'
  • '; } @@ -273,97 +286,21 @@ if (empty($record) || !$has_access) { }); '; - if ($structure->permission != '-') { + if ($structure->permission != '-' && $structure->use_notes) { echo '
    '; - $note = $structure->notes($id_record); - if (!empty($note)) { - echo ' -
    -
    -

    '.tr('Note interne').'

    -
    + include DOCROOT.'/plugins/notes.php'; -
    -
    '; + echo ' +
    '; + } - foreach ($note as $nota) { - $utente = $nota->user; - $nome = $utente->anagrafica ? $utente->anagrafica->ragione_sociale.' ('.$utente->username.')' : $utente->username; - $photo = $utente->photo; + if ($structure->permission != '-' && $structure->use_checklists) { + echo ' +
    '; - echo ' -
    -
    - '.$nome.' - - '.timestampFormat($nota->created_at).' - -
    '; - - if ($photo) { - echo ' - '; - } else { - echo ' - - '; - } - - echo ' -
    -
    '; - - if (!empty($nota->notification_date)) { - echo ' - - '.dateFormat($nota->notification_date).' - '; - } - - if ($user->is_admin || $utente->id == $user->id) { - echo ' - '; - } - - echo ' -
    - '.$nota->content.' -
    -
    '; - } - echo ' -
    -
    -
    '; - } else { - echo ' -

    '.tr('Non sono presenti note interne').'

    '; - } - - if ($structure->permission == 'rw') { - echo ' -
    - - - - {[ "type": "date", "label": "'.tr('Data di notifica').'", "name": "data_notifica" ]} - - {[ "type": "ckeditor", "label": "'.tr('Nuova nota').'", "name": "contenuto", "required": 1]} - - -
    -
    - -
    -
    -
    '; - } + include DOCROOT.'/plugins/checks.php'; echo '
    '; @@ -438,7 +375,8 @@ if (empty($record) || !$has_access) { '; } - echo ' '; + echo ' + '; } else { echo '
    diff --git a/include/common/articolo.php b/include/common/articolo.php index a1d2d2598..0462ad51f 100644 --- a/include/common/articolo.php +++ b/include/common/articolo.php @@ -58,7 +58,6 @@ if (!isset($options['edit_articolo']) || !empty($options['edit_articolo'])) { echo ' - -'; - - return $result; - } - - public static function renderChecklist($check, $level = 0) - { - $result = ' -
  • - '.str_repeat(' ', $level * 8).' - - - '.$check->content.' - -
    - '.timestampFormat($check->checked_at).' - -
    -
  • - '; - - return $result; - } -} diff --git a/modules/checklists/src/Traits/ChecklistTrait.php b/modules/checklists/src/Traits/ChecklistTrait.php index 1a7f65428..47a0f7c2a 100644 --- a/modules/checklists/src/Traits/ChecklistTrait.php +++ b/modules/checklists/src/Traits/ChecklistTrait.php @@ -7,18 +7,23 @@ use Modules\Checklists\Checklist; trait ChecklistTrait { - public function checks($id_record) + public function checks() { - return $this->hasMany(Check::class, $this->component_identifier)->where('id_record', $id_record)->orderBy('created_at')->get(); + return $this->hasMany(Check::class, $this->component_identifier); + } + + public function recordChecks($id_record) + { + return $this->checks()->where('id_record', $id_record)->orderBy('order')->get(); } public function mainChecks($id_record) { - return $this->hasMany(Check::class, $this->component_identifier)->where('id_record', $id_record)->whereNull('id_parent')->orderBy('id_utente_assegnato', 'created_at')->get(); + return $this->checks()->where('id_record', $id_record)->whereNull('id_parent')->orderBy('order')->get(); } public function checklists() { - return $this->hasMany(Checklist::class, $this->component_identifier)->orderBy('created_at')->get(); + return $this->hasMany(Checklist::class, $this->component_identifier); } } diff --git a/modules/dashboard/widgets/notifiche.php b/modules/dashboard/widgets/notifiche.php new file mode 100644 index 000000000..707333fd0 --- /dev/null +++ b/modules/dashboard/widgets/notifiche.php @@ -0,0 +1,68 @@ +where('permission', '<>', '-'); +foreach ($moduli as $modulo) { + $note = $modulo->notes()->where('notification_date', '>=', date('Y-m-d'))->get(); + $notes = $notes->merge($note); +} + +if (!empty($is_number_request)) { + echo $notes->count(); + + return; +} + +if (empty($notes)) { + 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 ' +

    '.$modulo->title.'

    + + + + + + '; + + foreach ($note as $nota) { + echo ' + + + + + '; + } + + 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().') +
    '; +} diff --git a/modules/interventi/widgets/interventi_confermati.php b/modules/interventi/widgets/interventi_confermati.php index 2e666b99b..c7f9cd182 100644 --- a/modules/interventi/widgets/interventi_confermati.php +++ b/modules/interventi/widgets/interventi_confermati.php @@ -9,7 +9,7 @@ if (!empty($rs)) { - + '; foreach ($rs as $r) { diff --git a/plugins/checks.php b/plugins/checks.php new file mode 100644 index 000000000..f0097ef28 --- /dev/null +++ b/plugins/checks.php @@ -0,0 +1,119 @@ + +
    +

    '.tr('Checklist').'

    +
    +
    +
    +
    + + '.tr('Caricamento...').' +
    +
    '; + +// Form per la creazione di una nuova checklist +if ($structure->permission == 'rw') { + echo ' + + +
    +
    '; +} + +$checks = $structure->mainChecks($id_record); + +echo ' + +
    +'; + +echo ' + + +'; diff --git a/plugins/notes.php b/plugins/notes.php new file mode 100644 index 000000000..f8d829c68 --- /dev/null +++ b/plugins/notes.php @@ -0,0 +1,93 @@ + +
    +

    '.tr('Note interne').'

    +
    + +
    +
    '; + + foreach ($notes as $nota) { + $utente = $nota->user; + $photo = $utente->photo; + + echo ' +
    +
    + '.$utente->nome_completo.' + + '.timestampFormat($nota->created_at).' + +
    '; + + if ($photo) { + echo ' + '; + } else { + echo ' + + '; + } + + echo ' +
    +
    '; + + if (!empty($nota->notification_date)) { + echo ' + + '.dateFormat($nota->notification_date).' + + + '; + } + + if ($user->is_admin || $utente->id == $user->id) { + echo ' + '; + } + + echo ' +
    + '.$nota->content.' +
    +
    '; + } + echo ' +
    +
    + '; +} else { + echo ' +

    '.tr('Non sono presenti note interne').'

    '; +} + +if ($structure->permission == 'rw') { + echo ' + + + + + {[ "type": "date", "label": "'.tr('Data di notifica').'", "name": "data_notifica" ]} + + {[ "type": "ckeditor", "label": "'.tr('Nuova nota').'", "name": "contenuto", "required": 1]} + + +
    +
    + +
    +
    + '; +} diff --git a/src/HTMLBuilder/HTMLBuilder.php b/src/HTMLBuilder/HTMLBuilder.php index 4b7aa9900..275a2e197 100644 --- a/src/HTMLBuilder/HTMLBuilder.php +++ b/src/HTMLBuilder/HTMLBuilder.php @@ -75,7 +75,6 @@ class HTMLBuilder protected static $managers = [ 'list' => [ 'filelist_and_upload' => Manager\FileManager::class, - 'checklists' => \Modules\Checklists\HTMLBuilder\ChecklistManager::class, 'button' => Manager\ButtonManager::class, 'csrf' => Manager\CSRFManager::class, 'custom_fields' => Manager\FieldManager::class, diff --git a/src/HTMLBuilder/Manager/WidgetManager.php b/src/HTMLBuilder/Manager/WidgetManager.php index 3fe44d655..7abbb0117 100644 --- a/src/HTMLBuilder/Manager/WidgetManager.php +++ b/src/HTMLBuilder/Manager/WidgetManager.php @@ -91,11 +91,42 @@ class WidgetManager implements ManagerInterface } } - // Generazione del codice HTML + return $this->render($widget, $widget['text'], $value); + } + + protected function chart($widget, $number = null) + { + $content = null; + if (!empty($widget['php_include'])) { + $is_title_request = true; + + ob_start(); + include DOCROOT.'/'.$widget['php_include']; + $content = ob_get_clean(); + } + + return $this->render($widget, $content, $number); + } + + protected function custom($widget) + { + $content = null; + if (!empty($widget['php_include'])) { + $is_number_request = true; + ob_start(); + include DOCROOT.'/'.$widget['php_include']; + $content = ob_get_clean(); + } + + return $this->chart($widget, $content); + } + + protected function render($widget, $title, $number = null) + { $result = ' -'; + '; if (!empty($widget['more_link'])) { $result .= ' @@ -124,21 +155,36 @@ class WidgetManager implements ManagerInterface } $result .= ' -
    - - - -
    - - '.$widget['text'].' +
    + '; - '.(!empty($widget['help']) ? '' : '').' - - '.$value.' -
    + if (!empty($widget['icon'])) { + $result .= ' + '; + } + + $result .= ' +
    + +
    + + '.$title.' + + '.(!empty($widget['help']) ? '' : '').' + '; + + if (isset($number)) { + $result .= ' + '.$number.''; + } + + $result .= '
    '; + $result .= ' +
    '; + if (!empty($widget['more_link'])) { $result .= ' '; @@ -150,57 +196,6 @@ class WidgetManager implements ManagerInterface return $result; } - protected function chart($widget) - { - return $this->custom($widget); - } - - protected function custom($widget) - { - $result = ' - '; - - $result .= ' - -
    - '; - - if (!empty($widget['icon'])) { - $result .= ' - '; - } - - $result .= ' - - -
    - '; - - if (!empty($widget['php_include'])) { - $result_ob = ''; - - ob_start(); - - include DOCROOT.'/'.$widget['php_include']; - $result_ob = ob_get_contents(); - - ob_end_clean(); - - $result .= $result_ob; - } - - $result .= ' - -
    '; - - $result .= ' -
    '; - - return $result; - } - protected function group($options) { $query = 'SELECT id FROM zz_widgets WHERE id_module = '.prepare($options['id_module']).' AND (|position|) AND enabled = 1 ORDER BY `order` ASC'; diff --git a/src/Traits/Components/NoteTrait.php b/src/Traits/Components/NoteTrait.php index d3951a04a..020007c9b 100644 --- a/src/Traits/Components/NoteTrait.php +++ b/src/Traits/Components/NoteTrait.php @@ -6,8 +6,13 @@ use Models\Note; trait NoteTrait { - public function notes($id_record) + public function notes() { - return $this->hasMany(Note::class, $this->component_identifier)->where('id_record', $id_record)->orderBy('created_at')->get(); + return $this->hasMany(Note::class, $this->component_identifier); + } + + public function recordNotes($id_record) + { + return $this->notes()->where('id_record', $id_record)->orderBy('created_at')->get(); } } diff --git a/src/Traits/StoreTrait.php b/src/Traits/StoreTrait.php index 538ceb35c..74eff4dd5 100644 --- a/src/Traits/StoreTrait.php +++ b/src/Traits/StoreTrait.php @@ -61,7 +61,9 @@ trait StoreTrait ->orWhere(self::$name, $identifier) ->first(); - self::$collection->push($result); + if (!empty($result)) { + self::$collection->push($result); + } return $result; } diff --git a/src/Util/Autofill.php b/src/Util/Autofill.php index d4625a62d..5d003a9c6 100644 --- a/src/Util/Autofill.php +++ b/src/Util/Autofill.php @@ -80,7 +80,6 @@ class Autofill $result = ''; $number = $this->getAdditionalNumber(); - //dd($this->space, $number);exit(); for ($i = 0; $i < $number; ++$i) { $result .= ' diff --git a/update/2_4_10.sql b/update/2_4_10.sql index 57a3cbbd3..7f2992ea2 100644 --- a/update/2_4_10.sql +++ b/update/2_4_10.sql @@ -28,7 +28,7 @@ INSERT INTO `zz_hooks` (`id`, `name`, `class`, `frequency`, `id_module`) VALUES (NULL, 'Ricevute', 'Modules\\Aggiornamenti\\UpdateHook', '7 day', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Aggiornamenti')); -- --- Aggiunta nuovi campi per tracciamento sedi +-- Aggiunta nuovi campi per tracciamento sedi -- ALTER TABLE `mg_movimenti` ADD `idsede_azienda` INT NOT NULL AFTER `idautomezzo`, ADD `idsede_controparte` INT NOT NULL AFTER `idsede_azienda`; @@ -106,7 +106,7 @@ UPDATE `zz_views` SET `query` = 'CONCAT_WS(co_movimenti_modelli.nome, co_movimen UPDATE `co_movimenti_modelli` SET `nome` = `descrizione` WHERE `nome` = ''; --- Rimuovo le interruzioni di riga per descrizioni vuote +-- Rimuovo le interruzioni di riga per descrizioni vuote -- UPDATE `in_interventi` SET `descrizione` = REPLACE(`descrizione`, '\n', '') where `descrizione` LIKE '%\n'; -- Aggiunto tabella co_tipi_scadenze @@ -181,6 +181,7 @@ UPDATE `in_interventi_tecnici` INNER JOIN `in_tipiintervento` ON `in_interventi_ ALTER TABLE `in_interventi_tecnici` CHANGE `idtipointervento` `idtipointervento` INT(11) NOT NULL, ADD FOREIGN KEY (`idtipointervento`) REFERENCES `in_tipiintervento`(`idtipointervento`); UPDATE `in_tariffe` INNER JOIN `in_tipiintervento` ON `in_tariffe`.`idtipointervento` = `in_tipiintervento`.`codice` SET `in_tariffe`.`idtipointervento` = `in_tipiintervento`.`idtipointervento`; +DELETE FROM `in_tariffe` WHERE `idtipointervento` NOT IN (SELECT `idtipointervento` FROM `in_tipiintervento`); ALTER TABLE `in_tariffe` CHANGE `idtipointervento` `idtipointervento` INT(11) NOT NULL, ADD FOREIGN KEY (`idtipointervento`) REFERENCES `in_tipiintervento`(`idtipointervento`); -- Ottimizzazione query Fatture diff --git a/update/2_4_11.sql b/update/2_4_11.sql index ce5fdc39a..a86fae880 100644 --- a/update/2_4_11.sql +++ b/update/2_4_11.sql @@ -212,19 +212,27 @@ CREATE TABLE IF NOT EXISTS `zz_checks` ( `id_module` int(11), `id_plugin` int(11), `id_record` int(11) NOT NULL, - `id_utente` int(11) NOT NULL, - `id_utente_assegnato` int(11) NOT NULL, + `created_by` int(11) NOT NULL, `checked_at` TIMESTAMP NULL, `content` TEXT, `id_parent` int(11), + `order` int(11), PRIMARY KEY (`id`), FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_utente_assegnato`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE, + FOREIGN KEY (`created_by`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE, FOREIGN KEY (`id_parent`) REFERENCES `zz_checks`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB; +CREATE TABLE IF NOT EXISTS `zz_check_user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_utente` int(11) NOT NULL, + `id_check` int(11) NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE, + FOREIGN KEY (`id_check`) REFERENCES `zz_checks`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB; + CREATE TABLE IF NOT EXISTS `zz_checklists` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255), @@ -240,11 +248,18 @@ CREATE TABLE IF NOT EXISTS `zz_checklist_items` ( `id_checklist` int(11), `content` TEXT, `id_parent` int(11), + `order` int(11), PRIMARY KEY (`id`), FOREIGN KEY (`id_checklist`) REFERENCES `zz_checklists`(`id`) ON DELETE CASCADE, FOREIGN KEY (`id_parent`) REFERENCES `zz_checklist_items`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB; +-- Gestione di note e checklists +ALTER TABLE `zz_modules` ADD `use_notes` BOOLEAN DEFAULT FALSE, ADD `use_checklists` BOOLEAN DEFAULT FALSE; +UPDATE `zz_modules` SET `use_notes` = 1 WHERE `name` IN ('Anagrafiche', 'Interventi', 'Preventivi', 'Contratti', 'Fatture di vendita', 'Fatture di acquisto', 'Scadenzario', 'Ordini cliente', 'Ordini fornitore', 'Articoli', 'Ddt di vendita', 'Ddt di acquisto', 'MyImpianti'); +UPDATE `zz_modules` SET `use_checklists` = 1 WHERE `name` IN ('Interventi', 'MyImpianti'); + +-- Modulo per i template delle Checklist INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Checklists', 'Checklists', 'checklists', 'SELECT |select| FROM `zz_checklists` WHERE 1=1 HAVING 2=2', '', 'fa fa-check-square-o', '2.4.11', '2.4.11', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Strumenti'), '1', '1'); INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES @@ -264,3 +279,6 @@ UPDATE `zz_prints` SET `options` = '{"pricing": true, "last-page-footer": true}' UPDATE `zz_prints` SET `options` = '{"pricing": false, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Preventivo (senza costi)'; UPDATE `zz_prints` SET `options` = '{"pricing": true, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Contratto'; UPDATE `zz_prints` SET `options` = '{"pricing": false, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Contratto (senza costi)'; + +-- Widget per le notifiche delle note interne +INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`) VALUES (NULL, 'Note interne', 'custom', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Dashboard'), 'controller_top', 'col-md-12', NULL, '#4ccc4c', 'fa fa-file-text-o ', '', './modules/dashboard/widgets/notifiche.php', 'popup', './modules/dashboard/widgets/notifiche.php', 'Notifiche interne', '1', '1'); diff --git a/update/tables.php b/update/tables.php index e6e28c0e7..1c971dade 100644 --- a/update/tables.php +++ b/update/tables.php @@ -81,6 +81,10 @@ return [ 'or_tipiordine', 'zz_api_resources', 'zz_currencies', + 'zz_checks', + 'zz_check_user', + 'zz_checklists', + 'zz_checklist_items', 'zz_documenti', 'zz_documenti_categorie', 'zz_email_print', @@ -96,6 +100,7 @@ return [ 'zz_logs', 'zz_modules', 'zz_operations', + 'zz_notes', 'zz_permissions', 'zz_plugins', 'zz_prints',
    '.tr('Attività').''.tr('Data richiesta').''.tr('Data richiesta').'