Bug 25261: (QA follow-up) Add confirmation to issues table
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 5 Aug 2020 09:52:48 +0000 (10:52 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 1 Oct 2020 08:33:10 +0000 (10:33 +0200)
The issues table allows for checkins and was not appropriately
requireing confirmation for the multi-part confirmation added in this
bug.

Test plan
1/ Enable the feature as per previous patches
2/ Checkot an item with attached materials
3/ Navigate to a page that display your users issues table (the checkout
page is a reasonable example)
4/ You should have the option to select items for return in the table
(If not, use the column settings to enable the feature)
5/ Select at least the item with attached materials to return
6/ Upon clicking the return buttton you should find that items without
additional materials are returned as expected, but rows with additional
materials turn yellow and contain a message and additional checkbox for
confirmation in the table.
7/ Ensure the checkbox is selected and click the return button again
8/ This item should have been returned.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/js/checkouts.js
svc/checkouts

index 44151ae..1b576b5 100644 (file)
@@ -130,6 +130,15 @@ $(document).ready(function() {
             }, "json")
         });
 
+        $(".confirm:checked:visible").each(function() {
+            itemnumber = $(this).val();
+            id = "#checkin_" + itemnumber;
+            materials = $(this).data('materials');
+
+            $(this).replaceWith("<span class='confirm' id='checkin_" + itemnumber + "'>" + __("Confirm") + " (<span>" + materials + "</span>): <input type='checkbox' class='checkin' name='checkin' value='" + itemnumber +"'></input></span>");
+            $(id).parent().parent().addClass('warn');
+        });
+
         $(".renew:checked:visible").each(function() {
             var override_limit = $("#override_limit").is(':checked') ? 1 : 0;
 
@@ -543,6 +552,8 @@ $(document).ready(function() {
                     "mDataProp": function ( oObj ) {
                         if ( oObj.can_renew_error == "on_reserve" ) {
                             return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + __("On hold") + "</a>";
+                        } else if ( oObj.materials ) {
+                            return "<input type='checkbox' class='confirm' id='confirm_" + oObj.itemnumber + "' name='confirm' value='" + oObj.itemnumber + "' data-materials='" + oObj.materials.escapeHtml() + "'></input>";
                         } else {
                             return "<input type='checkbox' class='checkin' id='checkin_" + oObj.itemnumber + "' name='checkin' value='" + oObj.itemnumber +"'></input>";
                         }
index 968388a..3e92e40 100755 (executable)
@@ -104,6 +104,7 @@ my $sql = '
         items.damaged,
         items.location,
         items.enumchron,
+        items.materials,
 
         DATEDIFF( issues.issuedate, CURRENT_DATE() ) AS not_issued_today,
 
@@ -139,6 +140,7 @@ $sth->execute(@parameters);
 
 my $item_level_itypes = C4::Context->preference('item-level_itypes');
 my $claims_returned_lost_value = C4::Context->preference('ClaimReturnedLostValue');
+my $confirm_parts_required = C4::Context->preference("CircConfirmItemParts");
 
 my $itemtypes = { map { $_->{itemtype} => $_->{translated_description} } @{ Koha::ItemTypes->search_with_localization->unblessed } };
 
@@ -194,6 +196,11 @@ while ( my $c = $sth->fetchrow_hashref() ) {
             { kohafield => 'items.damaged', authorised_value => $c->{damaged} } );
         $damaged = $av->{lib} ? $av->{lib} : '';
     }
+    my $materials;
+    if ( $c->{materials} && $confirm_parts_required ) {
+        my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $c->{materials} });
+        $materials = $descriptions->{lib} // $c->{materials};
+    }
     my @subtitles = split(/ \| /, $c->{'subtitle'} // '' );
     my $checkout = {
         DT_RowId             => $c->{itemnumber} . '-' . $c->{borrowernumber},
@@ -256,6 +263,7 @@ while ( my $c = $sth->fetchrow_hashref() ) {
         lost    => $lost,
         claims_returned => $claims_returned,
         damaged => $damaged,
+        materials => $materials,
         borrower => {
             surname    => $c->{surname},
             firstname  => $c->{firstname},