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 authored and Nathan Nguyen committed Nov 21, 2024
1 parent 3fc4b0d commit dd91194
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 @@ -65,6 +65,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 @@ -1011,7 +1011,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>';
}
}

if ($this->config->displayprintbutton) {
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 @@ -182,7 +182,7 @@ public function create_report(): bool {

$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 @@ -75,13 +75,13 @@
if ($download && $report->type === "sql") {
$reportclass->set_forexport(true);
}
$reportclass->check_filters_request();
$reportclass->create_report();

$action = (!empty($download)) ? 'download' : 'view';

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

Expand Down

0 comments on commit dd91194

Please sign in to comment.