Bugzilla – Attachment 169669 Details for
Bug 35044
Additional fields: Allow for repeatable fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35044: Update: Acquisition orders
Bug-35044-Update-Acquisition-orders.patch (text/plain), 6.33 KB, created by
Julian Maurice
on 2024-07-26 07:53:06 UTC
(
hide
)
Description:
Bug 35044: Update: Acquisition orders
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2024-07-26 07:53:06 UTC
Size:
6.33 KB
patch
obsolete
>From 2cbe25d4e651ad1ce24152dd3c4fe0447fafa5de Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Mon, 16 Oct 2023 12:36:06 +0000 >Subject: [PATCH] Bug 35044: Update: Acquisition orders > >Test plan, k-t-d: > >Preparation: Create additional fields for table 'aqorders': >2 text fields, one repeatable, one not-repeatable >2 AV fields, one repeatable, one not-repeatable >2 MARC fields, one 'get' and one 'set', both non-repeatable, MARC field >942$c >Attempt to create a repeatable MARC field (get or set). Notice you're >unable to. > >1) Add a new order for an existing basket, with an existing record, > visit: >/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=1&basketno=1&biblionumber=76 >2) Set the mandatory "Koha item type" for the item. Click the 'Add item' > button below. >3) Notice the accounting details now have quantity:1 >4) Set the mandatory "Fund" input in accounting details. >5) At the bottom, fill in all additional fields, click the '+New' and > 'Clear' links, hit 'Save' >6) In the orders table shown, click "Modify". Notice all the fields are > presented correctly in the edit form. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >--- > acqui/addorder.pl | 35 ++++++++++--------- > acqui/neworderempty.pl | 15 ++++---- > .../prog/en/modules/acqui/neworderempty.tt | 1 + > 3 files changed, 28 insertions(+), 23 deletions(-) > >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index 2fc99b66eb..45bfa93b40 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -117,17 +117,17 @@ if it is an order from an existing suggestion : the id of this suggestion. > =cut > > use Modern::Perl; >-use CGI qw ( -utf8 ); >+use CGI qw ( -utf8 ); > use JSON qw ( to_json encode_json ); > > use C4::Acquisition qw( FillWithDefaultValues ModOrderUsers ); >-use C4::Auth qw( get_template_and_user ); >+use C4::Auth qw( get_template_and_user ); > use C4::Barcodes; >-use C4::Biblio qw( AddBiblio GetMarcFromKohaField TransformHtmlToXml TransformKohaToMarc ); >-use C4::Budgets qw( GetBudget GetBudgetSpent GetBudgetOrdered FieldsForCalculatingFundValues ); >-use C4::Items qw( AddItemFromMarc ); >-use C4::Log qw( logaction ); >-use C4::Output qw( output_html_with_http_headers ); >+use C4::Biblio qw( AddBiblio GetMarcFromKohaField TransformHtmlToXml TransformKohaToMarc ); >+use C4::Budgets qw( GetBudget GetBudgetSpent GetBudgetOrdered FieldsForCalculatingFundValues ); >+use C4::Items qw( AddItemFromMarc ); >+use C4::Log qw( logaction ); >+use C4::Output qw( output_html_with_http_headers ); > use C4::Suggestions qw( ModSuggestion ); > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Currencies qw( get_active ); >@@ -387,17 +387,19 @@ if ( $op eq 'cud-order' ) { > ModOrderUsers( $order->ordernumber, @order_users ); > > # Retrieve and save additional fields values >- my @additional_fields = Koha::AdditionalFields->search( { tablename => 'aqorders' } )->as_list; >- my @additional_field_values; >- foreach my $af (@additional_fields) { >- my $id = $af->id; >- my $value = $input->param("additional_field_$id"); >- push @additional_field_values, { >- id => $id, >- value => $value, >+ my @additional_fields; >+ my $order_fields = Koha::AdditionalFields->search( { tablename => 'aqorders' } ); >+ while ( my $field = $order_fields->next ) { >+ my @field_values = $input->param( 'additional_field_' . $field->id ); >+ foreach my $value (@field_values){ >+ push @additional_fields, >+ { >+ id => $field->id, >+ value => $value, >+ } if $value; > }; > } >- $order->set_additional_fields( \@additional_field_values ); >+ $order->set_additional_fields( \@additional_fields ); > > # now, add items if applicable > if ( $basket->effective_create_items eq 'ordering' ) { >@@ -482,4 +484,3 @@ if ( $op eq 'cud-order' ) { > print $input->redirect("/cgi-bin/koha/acqui/basket.pl?basketno=$basketno"); > exit; > } >- >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index 95c31d9aa8..3937ef89c5 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -424,26 +424,29 @@ $quantity //= 0; > # Get additional fields > my $record; > my @additional_fields = Koha::AdditionalFields->search({ tablename => 'aqorders' })->as_list; >-my %additional_field_values; >+my $additional_field_values; > my $items; > if ($ordernumber) { > my $order = Koha::Acquisition::Orders->find($ordernumber); >- foreach my $value ($order->additional_field_values->as_list) { >- $additional_field_values{$value->field_id} = $value->value; >- } >+ $additional_field_values = $order->get_additional_field_values_for_template; > $items = $order->items; > } elsif ( $biblionumber ) { >+ my %additional_field_values; > foreach my $af (@additional_fields) { >+ my @marc_field_values; > if ($af->marcfield) { > $record //= Koha::Biblios->find($biblionumber)->metadata->record; > my ($field, $subfield) = split /\$/, $af->marcfield; >- $additional_field_values{$af->id} = $record->subfield($field, $subfield); >+ push @marc_field_values, $record->subfield( $field, $subfield ) if $record->subfield( $field, $subfield ); >+ $additional_field_values{ $af->id } = \@marc_field_values; > } > } >+ $additional_field_values = \%additional_field_values > } >+ > $template->param( > additional_fields => \@additional_fields, >- additional_field_values => \%additional_field_values, >+ additional_field_values => $additional_field_values, > items => $items, > ); > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >index a8aa424cfe..5789477959 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -51,6 +51,7 @@ > [% Asset.js("js/acq.js") | $raw %] > [% Asset.js("js/additem.js") | $raw %] > [% Asset.js("js/cataloging.js") | $raw %] >+ [% Asset.js("js/additional-fields-entry.js") | $raw %] > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'select2.inc' %] > <script> >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35044
:
157324
|
157325
|
157326
|
157327
|
157328
|
157329
|
157330
|
157331
|
157332
|
157333
|
157334
|
158113
|
158498
|
158499
|
158500
|
158501
|
158502
|
158503
|
158504
|
158505
|
158506
|
158507
|
158508
|
158857
|
158858
|
158859
|
158860
|
158861
|
158862
|
158863
|
158864
|
158865
|
158866
|
158867
|
158868
|
159268
|
160177
|
160178
|
160179
|
160180
|
160181
|
160182
|
160183
|
160184
|
160185
|
160186
|
160187
|
160188
|
160189
|
164162
|
164163
|
164164
|
164165
|
164166
|
164167
|
164168
|
164169
|
164170
|
164171
|
164172
|
164173
|
164174
|
167690
|
168537
|
168538
|
168539
|
168540
|
168541
|
168542
|
168543
|
168544
|
168545
|
168546
|
168547
|
168548
|
169545
|
169546
|
169547
|
169603
|
169604
|
169605
|
169606
|
169607
|
169643
|
169644
|
169645
|
169646
|
169647
|
169648
|
169649
|
169650
|
169651
|
169652
|
169653
|
169654
|
169655
|
169656
|
169657
|
169658
|
169659
|
169660
|
169661
|
169662
|
169663
|
169664
|
169665
|
169666
|
169667
|
169668
| 169669 |
169670
|
169671
|
169672
|
169673
|
169674
|
169675
|
169676
|
169677
|
169678
|
169679
|
169680
|
169681
|
169682
|
169683
|
169684
|
169697
|
170501