|
17 | 17 | namespace tool_dynamic_cohorts\reportbuilder\local\entities;
|
18 | 18 |
|
19 | 19 | use core_reportbuilder\local\entities\base;
|
| 20 | +use core_reportbuilder\local\filters\boolean_select; |
| 21 | +use core_reportbuilder\local\filters\text; |
20 | 22 | use core_reportbuilder\local\report\column;
|
| 23 | +use core_reportbuilder\local\report\filter; |
21 | 24 | use lang_string;
|
22 | 25 | use tool_dynamic_cohorts\rule;
|
23 | 26 |
|
@@ -57,6 +60,10 @@ public function initialise(): base {
|
57 | 60 | $this->add_column($column);
|
58 | 61 | }
|
59 | 62 |
|
| 63 | + foreach ($this->get_all_filters() as $filter) { |
| 64 | + $this->add_filter($filter); |
| 65 | + } |
| 66 | + |
60 | 67 | return $this;
|
61 | 68 | }
|
62 | 69 |
|
@@ -174,4 +181,54 @@ protected function get_all_columns(): array {
|
174 | 181 |
|
175 | 182 | return $columns;
|
176 | 183 | }
|
| 184 | + |
| 185 | + /** |
| 186 | + * Return list of all available filters |
| 187 | + * |
| 188 | + * @return filter[] |
| 189 | + */ |
| 190 | + protected function get_all_filters(): array { |
| 191 | + $tablealias = $this->get_table_alias('tool_dynamic_cohorts'); |
| 192 | + |
| 193 | + // Name filter. |
| 194 | + $filters[] = (new filter( |
| 195 | + text::class, |
| 196 | + 'name', |
| 197 | + new lang_string('name', 'core_cohort'), |
| 198 | + $this->get_entity_name(), |
| 199 | + "{$tablealias}.name" |
| 200 | + )) |
| 201 | + ->add_joins($this->get_joins()); |
| 202 | + |
| 203 | + // Bulk processing filter. |
| 204 | + $filters[] = (new filter( |
| 205 | + boolean_select::class, |
| 206 | + 'bulkprocessing', |
| 207 | + new lang_string('rule_entity.bulkprocessing', 'tool_dynamic_cohorts'), |
| 208 | + $this->get_entity_name(), |
| 209 | + "{$tablealias}.bulkprocessing" |
| 210 | + )) |
| 211 | + ->add_joins($this->get_joins()); |
| 212 | + |
| 213 | + // Broken filter. |
| 214 | + $filters[] = (new filter( |
| 215 | + boolean_select::class, |
| 216 | + 'broken', |
| 217 | + new lang_string('broken', 'tool_dynamic_cohorts'), |
| 218 | + $this->get_entity_name(), |
| 219 | + "{$tablealias}.broken" |
| 220 | + )) |
| 221 | + ->add_joins($this->get_joins()); |
| 222 | + |
| 223 | + // Enabled filter. |
| 224 | + $filters[] = (new filter( |
| 225 | + boolean_select::class, |
| 226 | + 'enabled', |
| 227 | + new lang_string('enabled', 'tool_dynamic_cohorts'), |
| 228 | + $this->get_entity_name(), |
| 229 | + "{$tablealias}.enabled" |
| 230 | + )) |
| 231 | + ->add_joins($this->get_joins()); |
| 232 | + return $filters; |
| 233 | + } |
177 | 234 | }
|
0 commit comments