From 6b437d5d97038518dfdf8c38a6ea673cfaf88403 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 16 Oct 2023 14:34:51 +0000 Subject: [PATCH] Bug 35044: Update: Invoices Added fixme comment to invoices.tt, the search works so nothing to do here, but the code is not DRY Test plan, k-t-d: Preparation: Create additional fields for table 'aqinvoices': 2 text fields, one repeatable, one not-repeatable 2 AV fields, one repeatable, one not-repeatable 1) Add a new invoice for an existing vendor, visit: /cgi-bin/koha/acqui/parcels.pl?booksellerid=1 2) Input something in the mandatory "Vendor invoice" field. 3) Fill in all additional fields, click the '+New' and 'Clear' links, hit 'Save' 4) Search for invoices, visit: http://localhost:8081/cgi-bin/koha/acqui/invoices.pl 5) Click "Search" on the left column of the page 6) Click the invoice we just created. Verify all the fields show correctly. 7) Go back to the additional fields configuration, set all additional fields as "searchable" 8) Return to http://localhost:8081/cgi-bin/koha/acqui/invoices.pl 9) Perform some searches using the additional fields values. Signed-off-by: Martin Renvoize Signed-off-by: Julian Maurice --- acqui/invoice.pl | 16 ++++++++-------- acqui/parcels.pl | 6 +++--- .../prog/en/modules/acqui/invoice.tt | 1 + .../prog/en/modules/acqui/invoices.tt | 1 + .../prog/en/modules/acqui/parcels.tt | 1 + 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/acqui/invoice.pl b/acqui/invoice.pl index 2c88908086..8627944617 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -131,11 +131,13 @@ elsif ( $op && $op eq 'cud-mod' ) { my @additional_fields; my $invoice_fields = Koha::AdditionalFields->search({ tablename => 'aqinvoices' }); while ( my $field = $invoice_fields->next ) { - my $value = $input->param('additional_field_' . $field->id); - push @additional_fields, { - id => $field->id, - value => $value, - }; + my @field_values = $input->param( 'additional_field_' . $field->id ); + foreach my $value (@field_values) { + push @additional_fields, { + id => $field->id, + value => $value, + } if $value; + } } Koha::Acquisition::Invoices->find($invoiceid)->set_additional_fields(\@additional_fields); @@ -320,9 +322,7 @@ if ( $adjustments ) { $template->param( adjustments => $adjustments ); } my $invoice = Koha::Acquisition::Invoices->find($invoiceid); $template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqinvoices' } ), - additional_field_values => { map { - $_->field->id => $_->value - } $invoice->additional_field_values->as_list }, + additional_field_values => $invoice->get_additional_field_values_for_template, ); $template->param( diff --git a/acqui/parcels.pl b/acqui/parcels.pl index 0cbc6d7671..5bead818a9 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -134,12 +134,12 @@ if ($op and $op eq 'cud-confirm') { my @additional_fields; my $invoice_fields = Koha::AdditionalFields->search({ tablename => 'aqinvoices' }); while ( my $field = $invoice_fields->next ) { - my $value = $input->param('additional_field_' . $field->id); - if (defined $value) { + my @field_values = $input->param( 'additional_field_' . $field->id ); + foreach my $value (@field_values) { push @additional_fields, { id => $field->id, value => $value, - }; + } if $value; } } if (@additional_fields) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt index e4e2dd561c..049784047e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt @@ -542,6 +542,7 @@ [% Asset.js("js/form-submit.js") | $raw %] [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] [% Asset.js("js/acq.js") | $raw %] + [% Asset.js("js/additional-fields-entry.js") | $raw %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %]