From d210dbabea81465602d066495f1938a4fc175619 Mon Sep 17 00:00:00 2001 From: Andrii Nugged <nugged@gmail.com> Date: Mon, 3 Jun 2024 03:50:24 +0300 Subject: [PATCH] Bug 37014: Fix after-modal-POST to transmit "not_returned" message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bug report addresses an issue where the message "Item was not checked in" erroneously appears during the second POST after a manual or modal check-in process. 1. In circ/returns.pl: - Introduced a new hash `%rinot_returned` to track items not returned across pages. - Updated the logic to capture the "not returned" status from the query parameters. - Adjusted the input processing loop to include `not_returned` status. - Modified the section handling barcode check-ins to appropriately initialize and update the `not_returned` status. 2. returns.tt: - Added hidden input fields in the template to include `not_returned` status in the form submissions. The changes ensure that the "not_returned" status is correctly tracked and displayed, preventing the erroneous message from appearing on subsequent POST requests. 1. Perform a manual check-in of an item, but make some warning modal appear: for ex., transfer: check-in the item in not home library. 2. Press OK on the modal. There will be a POST transition again to redraw the checked-in items list. 3. Verify that the "Item was not checked in" message appears erroneously near the item's row. 4. Apply the patch. 5. Repeat steps 1-3 and check that there will be no erroneous "Item was not checked in" message. Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com> --- circ/returns.pl | 8 +++++++- koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/circ/returns.pl b/circ/returns.pl index fb3f135b71..019d8e36c8 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -103,6 +103,7 @@ my $returned_counter = C4::Context->preference('numReturnedItemsToShow') || 8; my %returneditems; my %riduedate; my %riborrowernumber; +my %rinot_returned; my @inputloop; foreach ( $query->param ) { my $counter; @@ -120,6 +121,7 @@ foreach ( $query->param ) { my $barcode = $query->param("ri-$counter"); my $duedate = $query->param("dd-$counter"); my $borrowernumber = $query->param("bn-$counter"); + my $not_returned = $query->param("nr-$counter"); $counter++; # decode barcode ## Didn't we already decode them before passing them back last time?? @@ -130,12 +132,14 @@ foreach ( $query->param ) { $returneditems{$counter} = $barcode; $riduedate{$counter} = $duedate; $riborrowernumber{$counter} = $borrowernumber; + $rinot_returned{$counter} = $not_returned; ####################### $input{counter} = $counter; $input{barcode} = $barcode; $input{duedate} = $duedate; $input{borrowernumber} = $borrowernumber; + $input{not_returned} = $not_returned; push( @inputloop, \%input ); } @@ -386,6 +390,7 @@ if ($barcode && $op eq 'cud-checkin') { $returneditems{0} = $barcode; $riborrowernumber{0} = $borrower->{'borrowernumber'}; $riduedate{0} = $duedate; + $rinot_returned{0} = 0; $input{borrowernumber} = $borrower->{'borrowernumber'}; $input{duedate} = $duedate; unless ( $dropboxmode ) { @@ -429,6 +434,7 @@ if ($barcode && $op eq 'cud-checkin') { } $input{duedate} = $duedate; $input{not_returned} = 1; + $rinot_returned{0} = 1; $returneditems{0} = $barcode; $riduedate{0} = $duedate; push( @inputloop, \%input ); @@ -811,7 +817,7 @@ foreach ( sort { $a <=> $b } keys %returneditems ) { # we could handle that better displaying a message in the template - $ri{not_returned} = 1 unless $returned; + $ri{not_returned} = $rinot_returned{$_}; my $biblio = $item->biblio; # FIXME pass $item to the template and we are done here... $ri{itembiblionumber} = $biblio->biblionumber; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 474a3e6473..7091e5ef8e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -436,6 +436,7 @@ <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" /> <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" /> <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" /> + <input type="hidden" name="nr-[% inputloo.counter | html %]" value="[% inputloo.not_returned | html %]" /> [% END %] <button type="submit" class="approve" accesskey="y"><i class="fa fa-check"></i> Yes, checkin (Y)</button> </form> @@ -519,6 +520,7 @@ <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" /> <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" /> <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" /> + <input type="hidden" name="nr-[% inputloo.counter | html %]" value="[% inputloo.not_returned | html %]" /> [% END %] [% IF item.onloan %] <button type="submit" class="btn btn-default"><i class="fa fa-check"></i> Confirm checkin and mark missing items as lost</button> @@ -591,6 +593,7 @@ <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" /> <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" /> <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" /> + <input type="hidden" name="nr-[% inputloo.counter | html %]" value="[% inputloo.not_returned | html %]" /> [% END %] <div class="modal-header"> @@ -679,6 +682,7 @@ <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" /> <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" /> <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" /> + <input type="hidden" name="nr-[% inputloo.counter | html %]" value="[% inputloo.not_returned | html %]" /> [% END %] <input type="hidden" name="op" value="cud-affect_reserve" /> @@ -789,6 +793,7 @@ <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" /> <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" /> <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" /> + <input type="hidden" name="nr-[% inputloo.counter | html %]" value="[% inputloo.not_returned | html %]" /> [% END %] </div> <!-- /.modal-footer --> </form> <!-- /#mainform --> @@ -873,6 +878,7 @@ <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" /> <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" /> <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" /> + <input type="hidden" name="nr-[% inputloo.counter | html %]" value="[% inputloo.not_returned | html %]" /> [% END %] <input type="hidden" name="op" value="cud-affect_reserve" /> @@ -1142,6 +1148,7 @@ <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" /> <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" /> <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" /> + <input type="hidden" name="nr-[% inputloo.counter | html %]" value="[% inputloo.not_returned | html %]" /> [% END %] </div> </div> -- 2.45.1