Skip to content

Commit

Permalink
Merge pull request #3 from golenkovm/issue146
Browse files Browse the repository at this point in the history
Let filters to be set before running reports
  • Loading branch information
cameron1729 authored Oct 5, 2022
2 parents 0e66a15 + e006f5b commit e4b060b
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

0 comments on commit e4b060b

Please sign in to comment.