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 e5be7b0 commit 1f628b1
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 @@ -40,6 +40,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 @@ -119,7 +119,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 @@ -68,6 +68,7 @@
$PAGE->set_url('/blocks/configurable_reports/viewreport.php', ['id' => $id]);
$PAGE->requires->jquery();

$reportclass->check_filters_request();
$reportclass->create_report();

$download = ($download && $format && strpos($report->export, $format.',') !== false) ? true : false;
Expand All @@ -77,7 +78,6 @@

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

Expand Down

0 comments on commit 1f628b1

Please sign in to comment.