Skip to content

Commit 6f70e87

Browse files
committed
WP-5345 add all custom fields to the certificate issues report
1 parent d430034 commit 6f70e87

File tree

1 file changed

+22
-0
lines changed
  • classes/reportbuilder/local/entities

1 file changed

+22
-0
lines changed

classes/reportbuilder/local/entities/issue.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use tool_certificate\reportbuilder\local\filters\status;
2929
use tool_certificate\reportbuilder\local\formatters\certificate as formatter;
3030
use tool_certificate\permission;
31+
use core_reportbuilder\local\helpers\custom_fields;
3132

3233
/**
3334
* Certificate issue entity class implementation
@@ -38,6 +39,8 @@
3839
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3940
*/
4041
class issue extends base {
42+
/** @var custom_fields */
43+
protected $customfields;
4144

4245
/**
4346
* Database tables that this entity uses and their default aliases
@@ -153,6 +156,8 @@ protected function get_all_columns(): array {
153156
->add_field("{$certificateissuealias}.expires")
154157
->add_callback([formatter::class, 'certificate_issued_status']);
155158

159+
$columns = array_merge($columns, $this->get_custom_fields()->get_columns());
160+
156161
return $columns;
157162
}
158163

@@ -207,6 +212,23 @@ protected function get_all_filters(): array {
207212
))
208213
->add_joins($this->get_joins());
209214

215+
$filters = array_merge($filters, $this->get_custom_fields()->get_filters());
216+
210217
return $filters;
211218
}
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+
}
212234
}

0 commit comments

Comments
 (0)