From f4cbdd3954cdb48d2570360f26982c46f2c8e668 Mon Sep 17 00:00:00 2001 From: christianbeeznst Date: Wed, 11 Sep 2024 17:35:05 -0500 Subject: [PATCH] Internal: Enhance tables and charts: spacing, alignment, titles, Excel export - refs BT#21957 --- assets/css/app.scss | 4 ++ public/main/admin/statistics/index.php | 59 ++++++++++---------- public/main/inc/lib/sortable_table.class.php | 39 +++++++------ public/main/inc/lib/statistics.lib.php | 25 +++++++-- 4 files changed, 76 insertions(+), 51 deletions(-) diff --git a/assets/css/app.scss b/assets/css/app.scss index 1bcb94c9a7..59b124137c 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -853,6 +853,10 @@ form .field { @apply w-full md:w-1/2 px-4; } +.section-header__title { + @apply mt-4; +} + //@import 'primevue-md-light-indigo/theme.css'; //@import '~primevue/resources/primevue.min.css'; //@import '~primeflex/primeflex.css'; diff --git a/public/main/admin/statistics/index.php b/public/main/admin/statistics/index.php index 7647b29eed..4cead99b55 100644 --- a/public/main/admin/statistics/index.php +++ b/public/main/admin/statistics/index.php @@ -486,10 +486,10 @@ switch ($report) { $content .= $table->toHtml(); - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= '
'; + $content .= '
'; + $content .= '

'; + $content .= '

'; + $content .= '

'; $content .= '
'; $tableCourse = new HTML_Table(['class' => 'table table-responsive']); @@ -518,15 +518,14 @@ switch ($report) { $content .= $tableCourse->toHtml(); - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= '
'; - + $content .= '
'; + $content .= '
'; + $content .= '
'; + $content .= '
'; $content .= '
'; - $content .= '
'; - $content .= '
'; + $content .= '
'; + $content .= '
'; $content .= '
'; } @@ -720,24 +719,24 @@ switch ($report) { $startDate = $values['daterange_start']; $endDate = $values['daterange_end']; - $graph = '
'; - $graph .= '
'; - $graph .= '
'; - $graph .= '
'; + $graph = '
'; + $graph .= '
'; + $graph .= '
'; + $graph .= '
'; $graph .= '
'; - $graph .= '
'; - $graph .= '
'; - $graph .= '
'; + $graph .= '
'; + $graph .= '
'; + $graph .= '
'; $graph .= '
'; - $graph .= '
'; - $graph .= '
'; - $graph .= '
'; + $graph .= '
'; + $graph .= '
'; + $graph .= '
'; $graph .= '
'; - $graph .= '
'; - $graph .= '
'; + $graph .= '
'; + $graph .= '
'; $graph .= '
'; $conditions = []; @@ -769,7 +768,7 @@ switch ($report) { $table->actionButtons = [ 'export' => [ - 'label' => get_lang('ExportAsXLS'), + 'label' => get_lang('Export As XLS'), 'icon' => Display::getMdiIcon(ActionIcon::EXPORT_SPREADSHEET,'ch-tool-icon'), ], ]; @@ -842,7 +841,7 @@ switch ($report) { $userLanguage = ''; if (!empty($user['locale'])) { - $userLanguage = $languages[$user['locale']]; + $userLanguage = $languages[$user['locale']] ?? 'en'; } $languageTarget = ''; @@ -1447,12 +1446,12 @@ switch ($report) {
'; break; case 'users': - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= '
'; - + $content .= '
'; + $content .= '
'; + $content .= '
'; + $content .= '
'; $content .= '
'; + // total amount of users $teachers = $students = []; $countInvisible = isset($_GET['count_invisible_courses']) ? intval($_GET['count_invisible_courses']) : null; diff --git a/public/main/inc/lib/sortable_table.class.php b/public/main/inc/lib/sortable_table.class.php index 8deac67bac..d58a303c87 100644 --- a/public/main/inc/lib/sortable_table.class.php +++ b/public/main/inc/lib/sortable_table.class.php @@ -417,21 +417,28 @@ class SortableTable extends HTML_Table } } $html .= ''; - $html .= '
'; - $html .= '
'; + $html .= '
'; + $html .= '
'; + + if (count($this->actionButtons) > 0) { + $html .= '
'; + $html .= '
'; + + foreach ($this->actionButtons as $action => $data) { + $label = $data['label']; + $icon = $data['icon']; + $html .= ''.$icon.' '.$label.''; + } + $html .= '
'; + $html .= '
'; + } if (count($this->form_actions) > 0) { - $html .= '
'; - $html .= ''. - get_lang('Select all').''; - $html .= ''. - get_lang('Deselect all').' '; + $html .= '
'; + $html .= '' + .get_lang('Select all').''; + $html .= '' + .get_lang('Deselect all').''; $items = []; foreach ($this->form_actions as $action => $label) { @@ -451,13 +458,13 @@ class SortableTable extends HTML_Table // Pagination if ($this->get_total_number_of_items() > $this->default_items_per_page) { - $html .= '
'; + $html .= '
'; $html .= ''; $html .= '
'; } - $html .= '
'; //btn-group - $html .= '
'; + $html .= '
'; // btn-group + $html .= '
'; // sortable-buttons-actions if (count($this->form_actions) > 0) { $html .= ''; } diff --git a/public/main/inc/lib/statistics.lib.php b/public/main/inc/lib/statistics.lib.php index 71888fbb32..cf0a5e832e 100644 --- a/public/main/inc/lib/statistics.lib.php +++ b/public/main/inc/lib/statistics.lib.php @@ -1223,12 +1223,19 @@ class Statistics url: "'.$url.'", type: "POST", success: function(data) { - Chart.defaults.responsive = true; + Chart.defaults.responsive = false; var ctx = document.getElementById("'.$elementId.'").getContext("2d"); + ctx.canvas.width = 420; + ctx.canvas.height = 420; var chart = new Chart(ctx, { type: "'.$type.'", data: data, - options: {'.$options.'} + options: { + plugins: { + '.$options.' + }, + cutout: "25%" + } }); var title = chart.options.plugins.title.text; $("#'.$elementId.'_title").html(title); @@ -1251,13 +1258,21 @@ class Statistics $(function() { Chart.defaults.responsive = '.$responsiveValue.'; var ctx = document.getElementById("'.$elementId.'").getContext("2d"); - ctx.canvas.width = 400; - ctx.canvas.height = 400; + ctx.canvas.width = 420; + ctx.canvas.height = 420; var chart = new Chart(ctx, { type: "'.$type.'", data: '.$data.', - options: {'.$options.'} + options: { + plugins: { + '.$options.' + }, + cutout: "25%" + } }); + var title = chart.options.plugins.title.text; + $("#'.$elementId.'_title").html(title); + $("#'.$elementId.'_table").html(chart.data.datasets[0].data); }); ';