Good day,
Still new to PHP and moodle, I am creating a custom report which shows as a table, the download button shows but I cant get the download button to work,
It displays the button, but when clicking it, the URL appends ?sesskey= {numbers}&downlaod=csv (or the format selected)
but there is no table and nothing downloads,
I have been using https://docs.moodle.org/dev/lib/tablelib.php as a reference, below is my code:
$records = $DB->get_records_sql($sql, $variables);
$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
$table->is_downloading($download, 'test', 'testing123');
$table->define_columns(array( All the variables));
$table->define_headers(array( All the variables));
$table->setup();
if ($records) {
foreach ($records as $record) {
$row = array();
$row[] = $record->All the variables;
$table->add_data($row);
}
}
$table->finish_output();
if (!$table->is_downloading($download, $reportname)) {
echo $OUTPUT->footer();
}