Skip to content

Commit

Permalink
Let filters to be set before running reports
Browse files Browse the repository at this point in the history
  • Loading branch information
golenkovm committed Sep 13, 2022
1 parent f63cf94 commit e006f5b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions lang/en/block_configurable_reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
$string['field'] = "Field";

// Report form
$string['applyfilters'] = "Apply filters to run the report";
$string['typeofreport'] = "Type of report";
$string['enablejsordering'] = "Enable JavaScript ordering";
$string['enablejspagination'] = "Enable JavaScript Pagination";
Expand Down
6 changes: 5 additions & 1 deletion report.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,11 @@ public function print_report_page(\moodle_page $moodlepage) {

$this->print_export_options();
} else {
echo '<div class="centerpara">'.get_string('norecordsfound', 'block_configurable_reports').'</div>';
if (isset($this->filterform) && !$this->filterform->get_data()) {
echo '<div class="centerpara">'.get_string('applyfilters', 'block_configurable_reports').'</div>';
} else {
echo '<div class="centerpara">'.get_string('norecordsfound', 'block_configurable_reports').'</div>';
}
}

echo '<div class="centerpara"><br />';
Expand Down
2 changes: 1 addition & 1 deletion reports/sql/report.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function create_report() {

$sql = $this->prepare_sql($sql);

if ($rs = $this->execute_query($sql)) {
if (isset($this->filterform) && $this->filterform->get_data() && $rs = $this->execute_query($sql)) {
foreach ($rs as $row) {
if (empty($finaltable)) {
foreach ($row as $colname => $value) {
Expand Down
2 changes: 1 addition & 1 deletion viewreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@
$download = ($download && $format && strpos($report->export, $format.',') !== false) ? true : false;

if ($download && $report->type == "sql") $reportclass->setForExport(true);
$reportclass->check_filters_request();
$reportclass->create_report();

$action = (!empty($download)) ? 'download' : 'view';
cr_add_to_log($report->courseid, 'configurable_reports', $action, '/block/configurable_reports/viewreport.php?id='.$id, $report->name);

// No download, build navigation header etc..
if (!$download) {
$reportclass->check_filters_request();
$reportname = format_string($report->name);
$navlinks = array();

Expand Down

1 comment on commit e006f5b

@giselebrugger
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
The only thing that didn't work was exporting the report. The file is generated but empty.
Any idea where the problem might be?

Please sign in to comment.