I have a doubt that I do not know if it is viable to carry it out.
I'm using a plugin for moodle called "configurable report". This plugin allows you to create reports through sql queries that you create yourself. I have been given the case of needing to pass some variable from one report to another, that is, from one query to another.
To put yourself in situation, I have the following:
SELECT DISTINCT gr.name AS 'Nombre del grupo', concat('<a class="button" href="%%WWWROOT%%/blocks/configurable_reports/viewreport.php?id=445','&mode=posts">Ver</a>') AS 'Miembros del grupo'
As you can see, I'm doing a query to get the groups and in turn concateno a button that leads to another query, well, it is to that query where I would like to send the choice of that group to use in the subsequent consultation.
Thank you very much.
public function print_report_page() {
global $DB, $CFG, $OUTPUT, $USER;
cr_print_js_function();
$components = cr_unserialize($this->config->components);
$template = (isset($components['template']['config']) && $components['template']['config']->enabled && $components['template']['config']->record) ? $components['template']['config'] : false;
if ($template) {
$this->print_template($template);
return true;
}
// Debug.
$debug = optional_param('debug', false, PARAM_BOOL);
if ($debug or !empty($this->config->debug)) {
echo \html_writer::empty_tag('hr');
echo \html_writer::tag('div', $this->sql, ['id' => 'debug', 'style' => 'direction:ltr;text-align:left;']);
echo \html_writer::empty_tag('hr');
}
echo '<div class="centerpara">';
echo format_text($this->config->summary);
echo '</div>';
$this->print_filters();
if ($this->finalreport->table && !empty($this->finalreport->table->data[0])) {
echo "<div id=\"printablediv\">\n";
$this->print_graphs();
if ($this->config->jsordering) {
$this->add_jsordering();
}
$this->totalrecords = count($this->finalreport->table->data);
if ($this->config->pagination) {
$page = optional_param('page', 0, PARAM_INT);
$this->totalrecords = count($this->finalreport->table->data);
$this->finalreport->table->data = array_slice($this->finalreport->table->data, $page * $this->config->pagination, $this->config->pagination);
}
cr_print_table($this->finalreport->table);
if ($this->config->pagination) {
$postfiltervars = '';
$request = array_merge($_POST, $_GET);
if ($request) {
foreach ($request as $key => $val) {
if (strpos($key, 'filter_') !== false) {
if (is_array($val)) {
foreach ($val as $k => $v) {
$postfiltervars .= "&{$key}[$k]=".$v;
}
} else {
$postfiltervars .= "&$key=".$val;
}
}
}
}
$pagingbar = new paging_bar($this->totalrecords, $page, $this->config->pagination, "viewreport.php?id=".$this->config->id."&courseid=".$this->config->courseid."$postfiltervars&");
$pagingbar->pagevar = 'page';
echo $OUTPUT->render($pagingbar);
}
// Report statistics.
$a = new \stdClass();
$a->totalrecords = $this->totalrecords;
echo \html_writer::tag('div', get_string('totalrecords', 'block_configurable_reports', $a), ['id' => 'totalrecords']);
echo \html_writer::tag('div', get_string('lastexecutiontime', 'block_configurable_reports', $this->config->lastexecutiontime / 1000), array('id' => 'lastexecutiontime'));
if (!empty($this->finalreport->calcs->data[0])) {
echo '<br /><br /><br /><div class="centerpara"><b>'.get_string('columncalculations', 'block_configurable_reports').'</b></div><br />';
echo html_writer::table($this->finalreport->calcs);
}
echo "</div>";
$this->print_export_options();
} else {
echo '<div class="centerpara">'.get_string('norecordsfound', 'block_configurable_reports').'</div>';
}
echo '<div class="centerpara"><br />';
echo $OUTPUT->pix_icon('print', get_string('printreport', 'block_configurable_reports'), 'block_configurable_reports');
echo " <a href=\"javascript: printDiv('printablediv')\">".get_string('printreport', 'block_configurable_reports')."</a>";
echo "</div>\n";
}