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