From c95b1b2fb7496e415c495e865cf0d2f83788e083 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 --- 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 0c127b0..3039348 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; @@ -186,4 +187,12 @@ while ( my $item = $items->next ) { ); } +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 0b9ef23..e813bc2 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -185,8 +185,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} ); @@ -251,12 +249,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 a2159ea..d84fc45 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 %]
@@ -436,6 +466,25 @@ CheckNItems($(this).val()); }); [% END %] + + [% 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.7.4