From 2b8ec96fd323c9275c8404d1dab0982fe295da55 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 8 Nov 2019 15:50:57 +0100 Subject: [PATCH] Bug 23596: Edit suggestion's reason when receiving MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch displays and let the librarian edit the suggestion.reason information when receiving an order. Note that if no reason was given the edit is not possible (easily modifiable if needed but it seems that we do not want to display too much details unnecessarily) Test plan: - Create a suggestion and fill the reason - Create an order from this suggestion - Close the basket and start receiving the order => The reason is displayed and editable - Modify the reason and click Save - Receive again => The reason has been correctly modified - Play with the "Others..." option and give a specific reason Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Séverine QUEUNE Signed-off-by: Bouzid Fergani Signed-off-by: Katrin Fischer --- acqui/finishreceive.pl | 9 ++++ acqui/orderreceive.pl | 10 ++-- .../prog/en/modules/acqui/orderreceive.tt | 53 +++++++++++++++++++++- 3 files changed, 65 insertions(+), 7 deletions(-) diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index cc0552687b..a6519703c6 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -56,6 +56,7 @@ my $invoiceno = $invoice->{invoicenumber}; my $booksellerid = $input->param('booksellerid'); my $cnt = 0; my $bookfund = $input->param("bookfund"); +my $suggestion_id = $input->param("suggestionid"); my $order = GetOrder($ordernumber); my $new_ordernumber = $ordernumber; @@ -181,4 +182,12 @@ while ( my $item = $items->next ) { $item->store; } +if ($suggestion_id) { + my $reason = $input->param("reason") || ''; + my $other_reason = $input->param("other_reason"); + $reason = $other_reason if $reason eq 'other'; + my $suggestion = Koha::Suggestions->find($suggestion_id); + $suggestion->update( { reason => $reason } ) if $suggestion; +} + print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid&sticky_filters=1"); diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index f676ae81f8..d73f61b6d3 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -186,8 +186,6 @@ if( defined $order->{tax_rate_on_receiving} ) { $tax_rate = $order->{tax_rate_on_ordering} + 0.0; } -my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber}); - my $creator = Koha::Patrons->find( $order->{created_by} ); my $budget = GetBudget( $order->{budget_id} ); @@ -252,12 +250,14 @@ $template->param( datereceived => $datereceived, order_internalnote => $order_internalnote, order_vendornote => $order_vendornote, - suggestionid => $suggestion->{suggestionid}, - surnamesuggestedby => $suggestion->{surnamesuggestedby}, - firstnamesuggestedby => $suggestion->{firstnamesuggestedby}, gst_values => \@gst_values, ); +my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber}); +if ( $suggestion ) { + $template->param( suggestion => $suggestion ); +} + my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; my @budget_loop; my $periods = GetBudgetPeriods( ); 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 d8972708cd..9671bfe1d6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -42,13 +42,43 @@ - [% IF ( suggestionid ) %] + [% IF suggestion %]
Suggestion
  1. Suggested by: - [% surnamesuggestedby | html %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby | html %][% END %] (suggestion #[% suggestionid | html %]) + [% suggestion.surnamesuggestedby | html %][% IF suggestion.firstnamesuggestedby %], [% suggestion.firstnamesuggestedby | html %][% END %] (suggestion #[% suggestion.suggestionid | html %]) + [% IF suggestion.reason %] +
  2. + Reason: + [% SET avs = AuthorisedValues.GetAuthValueDropbox( 'SUGGEST' ) %] + [% SET other_reason = 1 %] + + + + [% IF other_reason %] + + [% ELSE %] + + [% END %] + Cancel + + + +
  3. + [% END %]
@@ -469,6 +499,25 @@ } $("select[name='currency']").on("change", function(){update_unitprice()} ); $("#unitprice_currency").on("change", function(){update_unitprice()} ); + + [% IF other_reason %] + $(".select-reason").hide(); + $(".select-reason").find("option[value='other']").attr("selected","selected"); + $("#other_reason").show(); + [% ELSE %] + $("#other_reason").hide(); + [% END %] + $(".select-reason").change(function(){ + if($(this).val() == "other"){ + $(this).hide(); + $("#other_reason").show(); + } + }); + $("a[href*=back]").click(function(){ + $(".select-reason").show().find("option[value='']").attr("selected","selected"); + $("#other_reason").hide(); + }); + }); [% END %] -- 2.11.0