Bug 29181: Create patron card creator batch from report result

This patch adds the option of taking the results of a report that
returns borrowernumbers and create a new patron card creator batch with
those results.

The logic of the dropdown menu has been modified in order to ensure that
duplicate patron modification options aren't shown in the menu when a
report return both borrowernumber and cardnumber.

To test, apply the patch and create a new report which will return
patron borrowernumbers, e.g.

SELECT borrowernumber, cardnumber, surname, firstname FROM borrowers
order by RAND() LIMIT 20

- Run your report
- Click the "Batch operations with..." button at the top of the result
  -  Click "Patron card creator"
- A new tab should open with a new patron card creator batch with the
  patrons from your report.

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Owen Leonard 2023-06-26 14:38:41 +00:00 committed by Tomas Cohen Arazi
parent f0f860a43d
commit c063990a92
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -1003,6 +1003,15 @@
</textarea> </textarea>
</form> </form>
<form action="/cgi-bin/koha/patroncards/edit-batch.pl" id="patron_card_creator" method="post" target="_blank">
<input type="hidden" name="op" value="add" />
<input type="hidden" name="batch_id" value="0" />
[% # Preserve the whitespace of the following textarea in order to format the values correctly %]
<textarea style="display:none;" name="bor_num_list" id="bor_num_list">
[%- borrowernumbers = PROCESS batch_list results=results batch_type='borrowernumber' | trim | html %][% IF borrowernumbers %][% SET batch_borrowernumbers = 1 %][% borrowernumbers | html %][% END -%]
</textarea>
</form>
[% BLOCK batch_list %] [% BLOCK batch_list %]
[%- FOREACH result IN results %] [%- FOREACH result IN results %]
[%- FOREACH cells IN result.cells %] [%- FOREACH cells IN result.cells %]
@ -1026,15 +1035,38 @@
<input type="hidden" name="limit" id="limit" value="20" /> <input type="hidden" name="limit" id="limit" value="20" />
</form> <!-- /#limitselect --> </form> <!-- /#limitselect -->
[% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) || ( unlimited_total > 10 && limit <= 1000 ) %] [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers || batch_borrowernumbers ) || ( unlimited_total > 10 && limit <= 1000 ) %]
<div id="toolbar" class="btn-toolbar"> <div id="toolbar" class="btn-toolbar">
[% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %] [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers || batch_borrowernumbers ) %]
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-default btn-sm dropdown-toggle" type="button" id="batch_mod_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="batch_mod_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Batch operations with [% IF unlimited_total >= limit %][% limit | html %][% ELSE %][% unlimited_total | html %][% END %] visible records Batch operations with [% IF unlimited_total >= limit %][% limit | html %][% ELSE %][% unlimited_total | html %][% END %] visible records
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" aria-labelledby="batch_mod_menu"> <ul class="dropdown-menu" aria-labelledby="batch_mod_menu">
[% FOREACH header_ro IN header_row %]
[% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' || header_ro.cell == 'borrowernumber' || header_types.item( header_ro.cell ) == 'borrowernumber' %]
[% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
[% SET show_cardnumber_ops = 1 %]
[% END %]
[% IF header_ro.cell == 'borrowernumber' || header_types.item( header_ro.cell ) == 'borrowernumber' %]
[% SET show_borrowernumber_ops = 1 %]
[% END %]
[% END %]
[% END %]
[% IF show_cardnumber_ops || show_borrowernumber_ops %]
<li class="dropdown-header">Patron records</li>
[% IF show_cardnumber_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>
[% END %]
[% IF show_borrowernumber_ops %]
<li>
<a href="#" data-submit="patron_card_creator" data-toggle="tooltip" data-placement="right" title="Send visible results to a new patron card batch" class="batch_op send_to_patron_card_batch">Patron card creator</a>
</li>
[% END %]
[% END %]
[% FOREACH header_ro IN header_row %] [% FOREACH header_ro IN header_row %]
[% IF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %] [% IF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
<li class="dropdown-header">Bibliographic records</li> <li class="dropdown-header">Bibliographic records</li>
@ -1057,12 +1089,6 @@
<a href="#" data-submit="batch_item_deletion" data-toggle="tooltip" data-placement="right" title="Send visible items to batch item deletion" class="batch_op send_to_item_del">Batch item deletion</a> <a href="#" data-submit="batch_item_deletion" data-toggle="tooltip" data-placement="right" title="Send visible items to batch item deletion" class="batch_op send_to_item_del">Batch item deletion</a>
</li> </li>
[% END %] [% END %]
[% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
<li class="dropdown-header">Patron records</li>
<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>
[% END %]
[% END # /FOREACH header_ro %] [% END # /FOREACH header_ro %]
</ul> <!-- /.dropdown-menu --> </ul> <!-- /.dropdown-menu -->
</div> <!-- /.dropdown --> </div> <!-- /.dropdown -->