From 19e66413fda2d98c7341b34fa228f64ffdb8f2e5 Mon Sep 17 00:00:00 2001 From: evarisk-francois Date: Tue, 30 Jul 2024 17:54:22 +0200 Subject: [PATCH] #579 [Session] add: make content not visible + editable in current view --- class/session.class.php | 2 +- view/session/session_card.php | 72 +++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/class/session.class.php b/class/session.class.php index 545be4a..2ba5679 100644 --- a/class/session.class.php +++ b/class/session.class.php @@ -121,7 +121,7 @@ class Session extends SaturneObject 'label' => ['type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'showoncombobox' => 2, 'validate' => 1, 'autofocusoncreate' => 1], 'date_start' => ['type' => 'datetime', 'label' => 'DateStart', 'enabled' => 1, 'position' => 110, 'notnull' => 1, 'visible' => 1], 'date_end' => ['type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'position' => 120, 'notnull' => 1, 'visible' => 1], - 'content' => ['type' => 'html', 'label' => 'Content', 'enabled' => 1, 'position' => 140, 'notnull' => 1, 'visible' => 3, 'validate' => 1], + 'content' => ['type' => 'html', 'label' => 'Content', 'enabled' => 1, 'position' => 140, 'notnull' => 1, 'visible' => 0, 'validate' => 1], 'type' => ['type' => 'varchar(128)', 'label' => 'Type', 'enabled' => 1, 'position' => 120, 'notnull' => 1, 'visible' => 0], 'duration' => ['type' => 'duration', 'label' => 'Duration', 'enabled' => 1, 'position' => 130, 'notnull' => 0, 'visible' => 1], 'note_public' => ['type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 150, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => 1], diff --git a/view/session/session_card.php b/view/session/session_card.php index dc139a4..db7a2a1 100644 --- a/view/session/session_card.php +++ b/view/session/session_card.php @@ -347,6 +347,17 @@ print ''; } +if ($action == 'set_content' && $user->hasRight("dolimeet", "trainingsession", "write")) { + if (!GETPOST('cancel')) { + $object->content = GETPOST('content', 'restricthtml'); + $result = $object->setValueFrom('content', $object->content); + + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } +} + // Part to show record. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); @@ -458,14 +469,50 @@ unset($object->fields['fk_project']); // Hide field already shown in banner. unset($object->fields['fk_soc']); // Hide field already shown in banner. unset($object->fields['fk_contrat']); // Hide field already shown in banner. - - $content = $object->fields['content']; - unset($object->fields['content']); - + // Common attributes. require_once DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; - $object->fields['content'] = $content; + if ($user->hasRight("dolimeet", "trainingsession", "write") && $action == 'edit_content') { + print '
'; + print ''; + print ''; + print ''; + print ''; + } + + print ''; + print $langs->trans("Content"); + print ''; + if ($user->hasRight("dolimeet", "trainingsession", "write")) { + print '' . img_edit($langs->trans('Modify')) . ''; + } + print ''; + + print ''; + print ''; + if ($user->hasRight("dolimeet", "trainingsession", "write") && $action == 'edit_content') { + $content = GETPOSTISSET('content') ? GETPOST('content', 'restricthtml') : $object->content; + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('content', $content, '', 250, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%'); + $doleditor->Create(); + } else { + print '
'; + print dolPrintHTML($object->content); + print '
'; + } + if ($user->hasRight("dolimeet", "trainingsession", "write") && $action == 'edit_content') { + print '
'; + print ''; + print ''; + print '
'; + } + print ''; + print ''; + + if ($user->hasRight("dolimeet", "trainingsession", "write") && $action == 'edit_content') { + print '
'; + } // Categories if ($conf->categorie->enabled) { @@ -483,21 +530,6 @@ print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
' . $langs->trans($content['label']) . '
'; - print '
'; - print '
' . $object->content . '
'; - print '
'; - print dol_get_fiche_end(); $documentTypeArray = ['trainingsession', 'attendancesheet', 'completioncertificate'];