Bug 37188: Allow batch modification of borrowers from reports with cardnumber or borrowernumber

Some libraries do not use cardnumbers for their patrons, but would still like to be able to batch
modify patrons from reports.

Borrowernumber is going to be authoritative - every borrower will have one - so if this column is
included in the results we should offer batch modification. If we have cardnumber, we can use that.
If we have both, we should use borrowernumber

To test:
 1 - Write a report like:
    SELECT cardnumber FROM borrowers ORDER BY rand() LIMIT 35
 2 - Run report
 3 - Click "Batch operations.." -> "Batch patron modification"
 4 - Confirm it works
 5 - Edit report:
    SELECT borrowernumber FROM borrowers ORDER BY rand() LIMIT 35
 6 - Run report
 7 - No option for batch modifying patrons
 8 - Apply patch
 9 - Run report
10 - The option for batch modificatoin now shows
11 - Confirm both batch operation types work from report
12 - Edit report:
   SELECT cardnumber,borrowernumber FROM borrowers ORDER BY rand() LIMIT 35
13 - Run report
14 - Confirm both batch operations work

Signed-off-by: Laura ONeil <laura@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Nick Clemens 2024-07-25 17:52:03 +00:00 committed by Katrin Fischer
parent 2263d9f3b0
commit 43e7dd17d1
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -1003,8 +1003,15 @@
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-show" />
[% # Preserve the whitespace of the following textarea in order to format the values correctly %]
[%- borrowernumbers = PROCESS batch_list results=results batch_type='borrowernumber' | trim | html -%]
[%- IF borrowernumbers -%]
[%- SET batch_borrowernumbers = 1 -%]
<textarea style="display:none;" name="borrowernumberlist" id="borrowernumberlist">
[%- borrowernumbers | html -%]
</textarea>
[%- END -%]
[%- cardnumbers = PROCESS batch_list results=results batch_type='cardnumber' | trim | html %]
[% IF cardnumbers %]
[% IF !batch_borrowernumbers && cardnumbers %]
[% SET batch_cardnumbers = cardnumbers.length %]
[% FOR b IN cardnumbers.split("\n") %]
<input type="hidden" name="cardnumber" value="[% b | uri %]" />
@ -1067,7 +1074,7 @@
[% END %]
[% IF show_cardnumber_ops || show_borrowernumber_ops %]
<li class="dropdown-header">Patron records</li>
[% IF show_cardnumber_ops %]
[% IF show_cardnumber_ops || show_borrowernumber_ops %]
<li>
<a href="#" data-submit="batch_patron_modification" data-toggle="tooltip" data-placement="right" title="Send visible results to batch patron modification" class="batch_op send_to_patron_mod">Batch patron modification</a>
</li>