Bug 32742: Patron's lists option are not in alphabetical order

This patch add sorting feature to the patron card lists export option

To test

1. Go to Tools > Patron lists
2. Create a new patron list
3. Add 10 patrons in a random order (not in alphabetical nor in cardnumber sequence)
4. Go back to Tools > Patron lists management page
5. Find your list, click on 'Action' and select 'Print patron cards'
6. Check the cards order in the pdf
    --> notice these cards aren't in alphabetical order.
7. Apply the patch
8. Repeat step 4, 5
9. Fill the «Order by» field and submit
10. Check the cards order in the pdf
    --> notice the cards are now ordered.

Signed-off-by: Émily-Rose Francoeur <emily-rose.francoeur@inLibro.com>
Signed-off-by: Kelly <kelly@bwatersolutions.com>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Hammat Wele 2023-09-08 22:04:05 +00:00 committed by Katrin Fischer
parent a1f8daa9aa
commit 2e307f68d3
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
3 changed files with 16 additions and 1 deletions

View File

@ -47,7 +47,7 @@
<div id="export_patron_list">
<h3>Click on the link to download the patron cards from the patron list.</h3>
<p>
<a class="document pdf" href="/cgi-bin/koha/patroncards/create-pdf.pl?patronlist_id=[% patronlist_id | html %]&amp;template_id=[% template_id | html %]&amp;layout_id=[% layout_id | html %]&amp;layout_back_id=[% layout_back_id | html %]&amp;start_card=[% start_card | html %]">label_patronlist_[% patronlist_id | html %].pdf</a>
<a class="document pdf" href="/cgi-bin/koha/patroncards/create-pdf.pl?patronlist_id=[% patronlist_id | html %]&amp;template_id=[% template_id | html %]&amp;layout_id=[% layout_id | html %]&amp;layout_back_id=[% layout_back_id | html %]&amp;start_card=[% start_card | html %]&amp;order_by=[% order_by | html %]">label_patronlist_[% patronlist_id | html %].pdf</a>
</p>
</div>
[% ELSE %]
@ -76,6 +76,17 @@
[% IF (patronlist_id) %] <input type="hidden" name="patronlist_id" value="[% patronlist_id | html %]" /> [% END %]
<fieldset class="rows">
<ol>
[% IF (patronlist_id) %]
<li>
<label style="width:9em" for="order_by">Order by: </label>
<select name="order_by" id="order_by">
<option value=""></option>
<option value="cardnumber">Card number</option>
<option value="firstname">First name</option>
<option value="surname">Surname</option>
</select>
</li>
[% END %]
<li>
<label style="width:9em" for="template_id">Select a template to be applied: </label>
<select name="template_id" id="template_id">

View File

@ -49,6 +49,7 @@ my $start_card = $cgi->param('start_card') || 1;
my @label_ids = $cgi->multi_param('label_id');
my @borrower_numbers = $cgi->multi_param('borrower_number');
my $patronlist_id = $cgi->param('patronlist_id');
my $order_by = $cgi->param('order_by') || undef;
my $items = undef; # items = cards
my $new_page = 0;
@ -99,6 +100,7 @@ elsif ( $patronlist_id ) {
my ($list) = GetPatronLists( { patron_list_id => $patronlist_id } );
my @borrowerlist = $list->patron_list_patrons()->search_related('borrowernumber')
->get_column('borrowernumber')->all();
@borrowerlist = map { $_->borrowernumber } Koha::Patrons->search( {borrowernumber => { -in => \@borrowerlist }}, { order_by => [$order_by]} )->as_list if($order_by);
grep {
push(@{$items}, {borrower_number => $_});
} @borrowerlist;

View File

@ -47,6 +47,7 @@ my $start_card = $cgi->param('start_card') || 1;
my @borrower_numbers = $cgi->multi_param('borrower_number');
my $output_format = $cgi->param('output_format') || 'pdf';
my $referer = $cgi->param('referer') || undef;
my $order_by = $cgi->param('order_by') || undef;
my $layouts = undef;
my $templates = undef;
@ -113,6 +114,7 @@ if ($op eq 'export') {
layout_back_id => $layout_back_id,
start_card => $start_card,
referer => $referer,
order_by => $order_by,
);
}
}