|
28 | 28 | use tool_certificate\reportbuilder\local\filters\status;
|
29 | 29 | use tool_certificate\reportbuilder\local\formatters\certificate as formatter;
|
30 | 30 | use tool_certificate\permission;
|
| 31 | +use core_reportbuilder\local\helpers\custom_fields; |
31 | 32 |
|
32 | 33 | /**
|
33 | 34 | * Certificate issue entity class implementation
|
|
38 | 39 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
39 | 40 | */
|
40 | 41 | class issue extends base {
|
| 42 | + /** @var custom_fields */ |
| 43 | + protected $customfields; |
41 | 44 |
|
42 | 45 | /**
|
43 | 46 | * Database tables that this entity uses and their default aliases
|
@@ -153,6 +156,8 @@ protected function get_all_columns(): array {
|
153 | 156 | ->add_field("{$certificateissuealias}.expires")
|
154 | 157 | ->add_callback([formatter::class, 'certificate_issued_status']);
|
155 | 158 |
|
| 159 | + $columns = array_merge($columns, $this->get_custom_fields()->get_columns()); |
| 160 | + |
156 | 161 | return $columns;
|
157 | 162 | }
|
158 | 163 |
|
@@ -207,6 +212,23 @@ protected function get_all_filters(): array {
|
207 | 212 | ))
|
208 | 213 | ->add_joins($this->get_joins());
|
209 | 214 |
|
| 215 | + $filters = array_merge($filters, $this->get_custom_fields()->get_filters()); |
| 216 | + |
210 | 217 | return $filters;
|
211 | 218 | }
|
| 219 | + |
| 220 | + /** |
| 221 | + * Get the custom fields helper |
| 222 | + * |
| 223 | + * @return custom_fields |
| 224 | + */ |
| 225 | + protected function get_custom_fields(): custom_fields { |
| 226 | + if ($this->customfields === null) { |
| 227 | + $tablealias = $this->get_table_alias('tool_certificate_issues'); |
| 228 | + $this->customfields = new custom_fields("{$tablealias}.id", $this->get_entity_name(), |
| 229 | + 'tool_certificate', 'issue', 0); |
| 230 | + $this->customfields->add_joins($this->get_joins()); |
| 231 | + } |
| 232 | + return $this->customfields; |
| 233 | + } |
212 | 234 | }
|
0 commit comments