Skip to content
Snippets Groups Projects
Commit 1c70de06 authored by Laur0r's avatar Laur0r
Browse files

Add filter to view.php

parent 970932c4
No related branches found
No related tags found
No related merge requests found
......@@ -45,9 +45,9 @@ class interaction_attention_table extends interaction_table {
* @param int $uniqueid Unique id of this table.
* @param int[] $courseids List of ids for courses that require attention.
*/
public function __construct($uniqueid, $courseids) {
public function __construct($uniqueid, $courseids, $filterdata) {
parent::__construct($uniqueid);
global $PAGE;
global $PAGE, $DB;
$fields = "p.id as processid, c.id as courseid, c.fullname as coursefullname, c.shortname as courseshortname, " .
"c.startdate, cc.name as category , s.id as stepinstanceid, s.instancename as stepinstancename, ".
......@@ -59,13 +59,27 @@ class interaction_attention_table extends interaction_table {
'left join {course_categories} cc on c.category = cc.id';
$ids = implode(',', $courseids);
$where = 'FALSE';
$where = ['FALSE'];
if ($ids) {
$where = 'p.courseid IN (' . $ids . ')';
$where = ['p.courseid IN (' . $ids . ')'];
}
$params = [];
if ($filterdata) {
if ($filterdata && $filterdata->shortname) {
$where[] = $DB->sql_like('c.shortname', ':shortname', false, false);
$params['shortname'] = '%' . $DB->sql_like_escape($filterdata->shortname) . '%';
}
if ($filterdata && $filterdata->fullname) {
$where[] = $DB->sql_like('c.fullname', ':fullname', false, false);
$params['fullname'] = '%' . $DB->sql_like_escape($filterdata->fullname) . '%';
}
}
$this->column_nosort = array('status', 'tools');
$this->set_sql($fields, $from, $where, []);
$this->set_sql($fields, $from, join(" AND ", $where), $params);
$this->define_baseurl($PAGE->url);
$this->init();
}
......
......@@ -52,7 +52,7 @@ class view_controller {
* @throws \dml_exception
* @throws \invalid_parameter_exception
*/
public function handle_view($renderer) {
public function handle_view($renderer, $filterdata) {
global $DB;
$courses = get_user_capability_course('tool/lifecycle:managecourses', null, false);
......@@ -91,7 +91,7 @@ class view_controller {
}
echo $renderer->heading(get_string('tablecoursesrequiringattention', 'tool_lifecycle'), 3);
$table1 = new interaction_attention_table('tool_lifecycle_interaction', $requiresinteraction);
$table1 = new interaction_attention_table('tool_lifecycle_interaction', $requiresinteraction, $filterdata);
echo $renderer->box_start("managing_courses_tables");
$table1->out(50, false);
......
......@@ -63,6 +63,28 @@ $renderer = $PAGE->get_renderer('tool_lifecycle');
echo $renderer->header();
$controller->handle_view($renderer);
$mform = new \tool_lifecycle\local\form\form_backups_filter();
// Cache handling.
$cache = cache::make('tool_lifecycle', 'mformdata');
if ($mform->is_cancelled()) {
$cache->delete('coursebackups_filter');
redirect($PAGE->url);
} else if ($data = $mform->get_data()) {
$cache->set('coursebackups_filter', $data);
} else {
$data = $cache->get('coursebackups_filter');
if ($data) {
$mform->set_data($data);
}
}
echo '<br>';
$mform->display();
echo '<br>';
$controller->handle_view($renderer, $data);
echo $renderer->footer();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment