Added columns from filter form not in download

Re: Added columns from filter form not in download

by Chardelle Busch -
Number of replies: 0
Picture of Core developers

Ok, so in my report index.php file I call my options form, then I have this code:

// Define variables.

if ($id) {

    $report = $DB->get_record('local_customreports', array('id' => $id));

    $toform = new StdClass();

    $queryparams = unserialize($report->queryparams);

    foreach ($queryparams as $param => $value) {

        $toform->{$param} = $value;

    }

    $courseids = $queryparams['course'];   

    $requestedcohort = $queryparams['cohort'];

    $completionstatus = $queryparams['completionstatus'];

    $datefrom = $queryparams['datefrom'];

    $dateto = $queryparams['dateto'];

    if (!empty($queryparams['coloptions'])) {

        $profieldids = array_keys($queryparams['coloptions']);

    }

    $cachedata = '';

    $mform->set_data($toform);

} else {

    $cache = cache::make_from_params(cache_store::MODE_SESSION, 'report_trainingsummary', 'search');

     if ($cachedata = $cache->get('data')) {

    // Cache form submission so that it is preserved while paging through the report.

    $mform->set_data($cachedata);

    }

}

 // Form has been submitted or we have cached data.

$data = ($mform->is_submitted() ? $mform->get_data() : fullclone($cachedata));

if ($data) {

    if (!empty($data->course)) {

        $courseids = $data->course;

    }

    if (!empty($data->cohort)) {

    $requestedcohort = $data->cohort;

    }   

    if (!empty($data->completionstatus)) {

    $completionstatus = $data->completionstatus;

    }

    if (!empty($data->datefrom)) {

        $datefrom = $data->datefrom;

    }

    if (!empty($data->dateto)) {

        $dateto = $data->dateto;

    }

    if (!empty($data->coloptions)) {

        $profieldids = array_keys($data->coloptions);   

    }

    unset($data->submitbutton);

    $cache->set('data', $data);

}


Hope this helps!