Bugzilla – Attachment 159762 Details for
Bug 28844
Suggestion from existing title can alert patron in error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28844: Add link between suggestions and orders
Bug-28844-Add-link-between-suggestions-and-orders.patch (text/plain), 21.25 KB, created by
Nick Clemens (kidclamp)
on 2023-12-12 18:27:46 UTC
(
hide
)
Description:
Bug 28844: Add link between suggestions and orders
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-12-12 18:27:46 UTC
Size:
21.25 KB
patch
obsolete
>From c4a68cc568051fb57503de3b1fee6e838c03d825 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 10 May 2023 15:18:15 +0200 >Subject: [PATCH] Bug 28844: Add link between suggestions and orders > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/Acquisition/Order.pm | 19 ++++++++ > acqui/addorder.pl | 1 + > acqui/basket.pl | 6 --- > acqui/orderreceive.pl | 1 - > acqui/parcel.pl | 6 +-- > api/v1/swagger/definitions/order.yaml | 9 ++++ > api/v1/swagger/paths/acquisitions_orders.yaml | 6 ++- > .../prog/en/modules/acqui/basket.tt | 8 ++-- > .../prog/en/modules/acqui/orderreceive.tt | 35 +++++++------- > .../prog/en/modules/acqui/parcel.tt | 48 +++++++++---------- > t/db_dependent/Koha/Acquisition/Order.t | 31 +++++++++++- > 11 files changed, 111 insertions(+), 59 deletions(-) > >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index e0fea073f1a..eee73ce0533 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -297,6 +297,24 @@ sub subscription { > return Koha::Subscription->_new_from_dbic( $subscription_rs ); > } > >+=head3 suggestion >+ >+ my $suggestion = $order->suggestion >+ >+Returns the I<Koha::Suggestion> object for the suggestion associated >+to the order. >+ >+It returns B<undef> if no linked suggestion is found. >+ >+=cut >+ >+sub suggestion { >+ my ( $self ) = @_; >+ my $rs = $self->_result->suggestion; >+ return unless $rs; >+ return Koha::Suggestion->_new_from_dbic( $rs ); >+} >+ > =head3 current_item_level_holds > > my $holds = $order->current_item_level_holds; >@@ -657,6 +675,7 @@ sub to_api_mapping { > sort2 => 'statistics_2', > sort2_authcat => 'statistics_2_authcat', > subscriptionid => 'subscription_id', >+ suggestionid => 'suggestion_id', > suppliers_reference_number => undef, # EDIFACT related > suppliers_reference_qualifier => undef, # EDIFACT related > suppliers_report => undef, # EDIFACT related >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index c5b9847b019..de8d3648f89 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -264,6 +264,7 @@ my $orderinfo = { > sort2 => scalar $input->param('sort2'), > subscriptionid => scalar $input->param('subscriptionid'), > estimated_delivery_date => scalar $input->param('estimated_delivery_date'), >+ suggestionid => scalar $input->param('suggestionid'), > }; > > $orderinfo->{uncertainprice} ||= 0; >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 33253aad47b..17589b66f8d 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -27,7 +27,6 @@ use CGI qw ( -utf8 ); > use C4::Acquisition qw( GetBasket CanUserManageBasket GetBasketAsCSV NewBasket NewBasketgroup ModBasket ReopenBasket ModBasketUsers GetBasketgroup GetBasketgroups GetBasketUsers GetOrders GetOrder get_rounded_price ); > use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); > use C4::Contract qw( GetContract ); >-use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); > use Koha::Biblios; > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Booksellers; >@@ -503,11 +502,6 @@ sub get_order_infos { > > } > >- my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); >- $line{suggestionid} = $$suggestion{suggestionid}; >- $line{surnamesuggestedby} = $$suggestion{surnamesuggestedby}; >- $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby}; >- > $line{estimated_delivery_date} = $order->{estimated_delivery_date}; > > foreach my $key (qw(transferred_from transferred_to)) { >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index d8192292f2f..2ca33d16471 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -68,7 +68,6 @@ use C4::Output qw( output_html_with_http_headers ); > use C4::Budgets qw( GetBudget GetBudgetPeriods GetBudgetPeriod GetBudgetHierarchy CanUserUseBudget ); > use C4::Members; > use C4::Biblio qw( GetMarcStructure ); >-use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); > > use Koha::Acquisition::Booksellers; > use Koha::Acquisition::Currencies qw( get_active ); >diff --git a/acqui/parcel.pl b/acqui/parcel.pl >index 06172690f68..ed3ca1a8fee 100755 >--- a/acqui/parcel.pl >+++ b/acqui/parcel.pl >@@ -61,7 +61,6 @@ use C4::Acquisition qw( CancelReceipt GetInvoice GetInvoiceDetails get_rounded_p > use C4::Budgets qw( GetBudget GetBudgetByOrderNumber GetBudgetName ); > use CGI qw ( -utf8 ); > use C4::Output qw( output_html_with_http_headers ); >-use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); > > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Bookseller; >@@ -149,10 +148,7 @@ for my $order ( @orders ) { > $total_tax_excluded += get_rounded_price($line{unitprice_tax_excluded}) * $line{quantity}; > $total_tax_included += get_rounded_price($line{unitprice_tax_included}) * $line{quantity}; > >- my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); >- $line{suggestionid} = $suggestion->{suggestionid}; >- $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; >- $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; >+ $line{order_object} = $order_object; > > if ( $line{parent_ordernumber} != $line{ordernumber} ) { > if ( grep { $_->{ordernumber} == $line{parent_ordernumber} } >diff --git a/api/v1/swagger/definitions/order.yaml b/api/v1/swagger/definitions/order.yaml >index 61aaae480d9..f2c0ecfaa30 100644 >--- a/api/v1/swagger/definitions/order.yaml >+++ b/api/v1/swagger/definitions/order.yaml >@@ -204,6 +204,11 @@ properties: > - integer > - "null" > description: Subscription ID linking the order to a subscription >+ suggestion_id: >+ type: >+ - integer >+ - "null" >+ description: Suggestion ID linking the order to a suggestion > parent_order_id: > type: > - integer >@@ -264,4 +269,8 @@ properties: > - object > - "null" > description: Patron that created the order >+ suggestion: >+ type: >+ - object >+ - "null" > additionalProperties: false >diff --git a/api/v1/swagger/paths/acquisitions_orders.yaml b/api/v1/swagger/paths/acquisitions_orders.yaml >index 260597281da..5a0e7256ca1 100644 >--- a/api/v1/swagger/paths/acquisitions_orders.yaml >+++ b/api/v1/swagger/paths/acquisitions_orders.yaml >@@ -57,7 +57,6 @@ > - biblio.active_orders+count > - biblio.holds+count > - biblio.items+count >- - biblio.suggestions.suggester > - creator > - fund > - fund.budget >@@ -66,6 +65,8 @@ > - items > - items+strings > - subscription >+ - suggestion >+ - suggestion.suggester > collectionFormat: csv > responses: > "200": >@@ -177,12 +178,13 @@ > - biblio.active_orders+count > - biblio.holds+count > - biblio.items+count >- - biblio.suggestions.suggester > - fund > - current_item_level_holds+count > - invoice > - items > - subscription >+ - suggestion >+ - suggestion.suggester > collectionFormat: csv > produces: > - application/json >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index 129567a290d..ccc1648b9d1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -582,10 +582,12 @@ > [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%] > [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%] > [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%] >- [%- IF ( books_loo.suggestionid ) %] >+ [% SET suggestion = books_loo.order_object.suggestion %] >+ [% IF suggestion %] > <br/> >- Suggested by: [% books_loo.surnamesuggestedby | html %][% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby | html %] [% END %] >- (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid | uri %]&op=show">suggestion #[% books_loo.suggestionid | html %]</a>) >+ [% SET suggester = suggestion.suggester %] >+ Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %] >+ (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&op=show">suggestion #[% suggestion.suggestionid | html %]</a>) > [% END %] > </p> > [% IF ( books_loo.order_internalnote ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index c20f14bf994..94b2aaddcf0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -561,10 +561,11 @@ > }, > "embed": [ > "basket", >- "biblio.suggestions.suggester", >+ "biblio", > "fund.budget", > "items+strings", >- "creator" >+ "creator", >+ "suggestion.suggester", > ], > 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', > "columns": [ >@@ -693,13 +694,13 @@ > params['ordernumber'] = row.order_id; > params['booksellerid'] = row.basket.vendor_id; > >- if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) { >- params["suggestionid"] = row.biblio.suggestions[0].suggestion_id; >- if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { >- params['reason'] = row.biblio.suggestions[0].reason; >+ if(row.suggestion && row.suggestion.reason) { >+ params["suggestionid"] = row.suggestion.suggestion_id; >+ if($("#reason option[value='"+row.suggestion.reason+"']").length) { >+ params['reason'] = row.suggestion.reason; > } else { > params['reason'] = 'other'; >- params['other_reason'] = row.biblio.suggestions[0].reason; >+ params['other_reason'] = row.suggestion.reason; > } > } > params['datereceived'] = row.date_received; >@@ -837,14 +838,14 @@ > $("#other_reason").show(); > $(this).hide(); > } else { >- row.biblio.suggestions[0].reason = val; >+ row.suggestion.reason = val; > } > }); > > $("#order_edit").on("change", "#select-other_reason", function() { > var val = $(this).val(); > var row = $("#order_edit").data('row'); >- row.biblio.suggestions[0].reason = val; >+ row.suggestion.reason = val; > }); > > $("#order_edit").on("click", "#other_reason a", function() { >@@ -1132,30 +1133,30 @@ > o.parent().hide(); > } > }); >- if(row.biblio.suggestions.length) { >+ if(row.suggestion) { > $("#suggestion_fieldset").show(); >- if(row.biblio.suggestions[0].suggester) { >+ if(row.suggestion.suggester) { > $("#biblio_suggestion_suggester").parent().show(); > $("#biblio_suggestion_suggester") > .html( >- [row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname] >+ [row.suggestion.suggester.surname, row.suggestion.suggester.firstname] > .filter(function(name){ > return name > }) >- .join(', ')+' (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='+row.biblio.suggestions[0].suggestion_id+'&op=show">'+SUGGESTION.format(row.biblio.suggestions[0].suggestion_id)+'</a>)' >+ .join(', ')+' (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='+row.suggestion.suggestion_id+'&op=show">'+SUGGESTION.format(row.suggestion.suggestion_id)+'</a>)' > ); > } else { > $("#biblio_suggestion_suggester").parent().hide(); > } >- if(row.biblio.suggestions[0].reason) { >+ if(row.suggestion.reason) { > $("#suggestion_reason").show(); >- if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { >+ if($("#reason option[value='"+row.suggestion.reason+"']").length) { > $("#other_reason a").click(); >- $("#reason").val(row.biblio.suggestions[0].reason); >+ $("#reason").val(row.suggestion.reason); > $("#select-other_reason").val(null); > } else { > $("#reason").val("other").change(); >- $("#select-other_reason").val(row.biblio.suggestions[0].reason); >+ $("#select-other_reason").val(row.suggestion.reason); > } > > } else { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >index c015324c2b2..0d33db4c00d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -244,10 +244,13 @@ > [%- ELSIF ( order.copyrightdate > 0) -%] [% order.copyrightdate | html %] > [% END %] > [% END %] >- [% IF ( order.suggestionid ) %] >+ >+ [% SET suggestion = order.order_object.suggestion %] >+ [% IF suggestion %] >+ [% SET suggester = suggestion.suggester %] > <br/> >- Suggested by: [% order.surnamesuggestedby | html %][% IF ( order.firstnamesuggestedby ) %], [% order.firstnamesuggestedby | html %] [% END %] >- (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% order.suggestionid | uri %]&op=show">suggestion #[% order.suggestionid | html %]</a>) >+ Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %] >+ (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&op=show">suggestion #[% suggestion.suggestionid | html %]</a>) > [% END %] > <br /> > [% IF ( order.order_internalnote ) %] >@@ -394,10 +397,10 @@ > "biblio.active_orders+count", > "biblio.holds+count", > "biblio.items+count", >- "biblio.suggestions.suggester", > "fund", > "current_item_level_holds+count", >- "items" >+ "items", >+ "suggestion.suggester" > ], > "stateSave": true, // remember state on page reload > "drawCallback": function (settings) { >@@ -468,26 +471,23 @@ > result += escape_str(row.biblio.copyright_date); > } > } >- var suggestions = row.biblio.suggestions; >- if ( suggestions != null && suggestions.length > 0 ) { >- var suggestion = suggestions[0]; >- if ( suggestion.suggester != null ) { >- var suggester = suggestion.suggester; >- var suggested_by = []; >- if ( suggester.surname != null ) { >- suggested_by.push(escape_str(suggester.surname)); >- } >- if ( suggester.firstname != null ) { >- suggested_by.push(escape_str(suggester.firstname)); >- } >- >- result += "<br/>" + _("Suggested by: ") + >- '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=' >- + encodeURIComponent(suggestion.suggestionid) >- + '&op=show">' >- + suggested_by.join(", ") >- + " (#" + escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions >+ let suggestion = row.suggestion; >+ if ( suggestion && suggestion.suggester != null ) { >+ var suggester = suggestion.suggester; >+ var suggested_by = []; >+ if ( suggester.surname != null ) { >+ suggested_by.push(escape_str(suggester.surname)); >+ } >+ if ( suggester.firstname != null ) { >+ suggested_by.push(escape_str(suggester.firstname)); > } >+ >+ result += "<br/>" + _("Suggested by: ") + >+ '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=' >+ + encodeURIComponent(suggestion.suggestion_id) >+ + '&op=show">' >+ + suggested_by.join(", ") >+ + " (#" + escape_str(suggestion.suggestionid) + ")</a>"; > } > result += '</p>'; > } >diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t >index 10fdfa46851..a7de91b39ab 100755 >--- a/t/db_dependent/Koha/Acquisition/Order.t >+++ b/t/db_dependent/Koha/Acquisition/Order.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 13; >+use Test::More tests => 14; > use Test::Exception; > > use t::lib::TestBuilder; >@@ -210,6 +210,35 @@ subtest 'subscription' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'suggestion' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ my $o = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { suggestionid => undef }, # not linked to a suggestion >+ } >+ ); >+ >+ my $order = Koha::Acquisition::Orders->find( $o->ordernumber ); >+ is( $order->suggestion, undef, >+ '->suggestion should return undef if not created from a suggestion'); >+ >+ $o = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ # Will be linked to a suggestion by TestBuilder >+ } >+ ); >+ >+ $order = Koha::Acquisition::Orders->find( $o->ordernumber ); >+ is( ref( $order->suggestion ), 'Koha::Suggestion', >+ '->suggestion should return a Koha::Suggestion object if created from a suggestion'); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'duplicate_to | add_item' => sub { > plan tests => 3; > >-- >2.30.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 28844
:
151001
|
151002
|
151003
|
151004
|
151005
|
151006
|
151007
|
153157
|
153158
|
153159
|
153160
|
153161
|
153162
|
153163
|
153174
|
153175
|
153176
|
158982
|
158983
|
158984
|
158985
|
158986
|
158987
|
158988
|
158989
|
158990
|
159759
|
159760
|
159761
| 159762 |
159763
|
159764
|
159765
|
159766
|
159767
|
159768