@@ -, +, @@
---
Koha/Object/Mixin/AdditionalFields.pm | 43 ++++++
.../en/includes/additional-fields-display.inc | 30 ++--
.../en/includes/additional-fields-entry.inc | 133 +++++++++++++-----
.../prog/en/includes/filter-orders.inc | 2 +-
.../prog/en/modules/acqui/histsearch.tt | 2 +-
.../prog/js/additional-fields-entry.js | 28 ++++
6 files changed, 190 insertions(+), 48 deletions(-)
create mode 100644 koha-tmpl/intranet-tmpl/prog/js/additional-fields-entry.js
--- a/Koha/Object/Mixin/AdditionalFields.pm
+++ a/Koha/Object/Mixin/AdditionalFields.pm
@@ -91,6 +91,49 @@ sub set_additional_fields {
}
}
+=head3 get_additional_field_values_for_template
+
+Returns additional field values in the format expected by the .tt file
+
+ my $fields = Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template;
+
+Expected format is a hash of arrays, where the hash key is the field id and its respective array contains
+the field values 'value' for that field. Example where field_id = 2 is the only repeatable field:
+
+{
+ '3' => ['first value for field 3'],
+ '1' => ['first value for field 1'],
+ '4' => ['first value for field 4'],
+ '2' => [
+ 'first value for field 2',
+ 'second value for field 2',
+ 'third value for field 2'
+ ]
+};
+
+=cut
+
+sub get_additional_field_values_for_template {
+ my ($self) = @_;
+
+ my $additional_field_ids = $self->additional_field_values->search(
+ {},
+ {
+ columns => ['field_id'],
+ distinct => 1,
+ }
+ );
+
+ my %fields;
+ while ( my $additional_field_value = $additional_field_ids->next ) {
+ my @values = map ( $_->value,
+ $self->additional_field_values->search( { field_id => $additional_field_value->field_id } )->as_list );
+ $fields{ $additional_field_value->field_id } = \@values;
+ }
+
+ return \%fields;
+}
+
=head3 additional_field_values
Returns additional field values
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-display.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-display.inc
@@ -1,11 +1,25 @@
[% USE AuthorisedValues %]
[% FOR field IN available %]
-
- [% field.name | html %]:
- [% IF field.authorised_value_category %]
- [% AuthorisedValues.GetByCode( field.authorised_value_category, values.${field.name} ) | html %]
- [% ELSE %]
- [% values.${field.name} | html %]
- [% END %]
-
+ [% IF is_table_cell %]
+
+ [% END %]
+ [% SET values_list = [] %]
+ [% FOR value IN values.${field.id} %]
+ [% IF field.authorised_value_category %]
+ [% values_list.push(AuthorisedValues.GetByCode( field.authorised_value_category, value )) %]
+ [% ELSE %]
+ [% values_list.push(value) %]
+ [% END %]
+ [% END %]
+ [% IF value_only %]
+ [% values_list.join(', ') | html %]
+ [% ELSIF !values_list.empty %]
+
+ [% field.name | html %]:
+ [% values_list.join(', ') | html %]
+
+ [% END %]
+ [% IF is_table_cell %]
+
+ [% END %]
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-entry.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-entry.inc
@@ -3,67 +3,124 @@
[% USE ClassSources %]
[% USE ItemTypes %]
[% IF wrap_fieldset != 0 %]
-