Bug 32742: (follow-up) Add sorting feature when printing the patron cards from the patron card creator

This patch also put the «Order by» field at the last position in the form

To test

1. Go to Tools > Patron card creator
2. Create a new Card batch
3. Add some patrons
4. Select all cards by clicking on checkbox in the select colunm
5. Click on «Export selected card(s)», an Export patron cards windows is opened
6. Fill the «Order by» field and submit
7. Check the cards order in the pdf
    --> notice the cards are now ordered.
8. Close the window opened in step 5
9. Click on «Export card batch», an Export patron cards windows is opened
10. repeat step 6 and 7
    --> notice the cards are now ordered.
11. Close the window opened in step 9
12. Fill the «Batch description» field and click on «Save description»
13. Click on Manage -> Card Batches
14. Click on Export button
15. repeat step 6 and 7
    --> notice the cards are now ordered.
16. Select a batch to export and click on «Export selected batches» button
17. repeat step 6 and 7
    --> notice the cards are now ordered.

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 2024-08-27 20:56:28 +00:00 committed by Katrin Fischer
parent 2e307f68d3
commit ba5689f731
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
3 changed files with 41 additions and 16 deletions

View File

@ -23,17 +23,17 @@
[% IF ( batche.label_ids ) %]
<legend>[% batche.card_count | html %] Single patron cards</legend>
<p>
<a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script | html %]?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %][% batche.label_ids | html %]">label_single_[% batche.card_count | html %].pdf</a>
<a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script | html %]?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %][% batche.label_ids | html %]&amp;order_by=[% order_by | html %]">label_single_[% batche.card_count | html %].pdf</a>
</p>
[% ELSIF ( batche.borrower_numbers ) %]
<legend>[% batche.card_count | html %] Single patron cards</legend>
<p>
<a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script | html %]?template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %][% batche.borrower_numbers | html %]">label_single_[% batche.card_count | html %].pdf</a>
<a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script | html %]?template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %][% batche.borrower_numbers | html %]&amp;order_by=[% order_by | html %]">label_single_[% batche.card_count | html %].pdf</a>
</p>
[% ELSE %]
<legend>Card batch number [% batche.batch_id | html %]</legend>
<p>
<a class="document pdf" href="/cgi-bin/koha/patroncards/create-pdf.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %]">label_batch_[% batche.batch_id | html %].pdf</a>
<a class="document pdf" href="/cgi-bin/koha/patroncards/create-pdf.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %]&amp;order_by=[% order_by | html %]">label_batch_[% batche.batch_id | html %].pdf</a>
</p>
[% END %]
[% END %]
@ -76,17 +76,6 @@
[% 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">
@ -118,6 +107,17 @@
<label style="width:9em" for="start_card">Enter starting card position: </label>
<input type="text" size="5" id="start_card" name="start_card" class="focus" title="Starting card number" value="1" />
</li>
[% IF patronlist_id || batch_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 %]
</ol>
</fieldset>
<fieldset class="action">

View File

@ -86,12 +86,25 @@ my ($llx, $lly) = 0,0;
if (@label_ids) {
my $batch_items = $batch->get_attr('items');
my @borrowernumbers;
grep {
my $label_id = $_;
push(@{$items}, grep{$_->{'label_id'} == $label_id;} @{$batch_items});
push( @borrowernumbers, grep { $_->{'label_id'} == $label_id; } @{$batch_items} );
} @label_ids;
@borrowernumbers = map { $_->{borrower_number} } @borrowernumbers;
@borrowernumbers =
map { $_->borrowernumber }
Koha::Patrons->search( { borrowernumber => { -in => \@borrowernumbers } }, { order_by => [$order_by] } )
->as_list
if ($order_by);
grep { push( @{$items}, { borrower_number => $_ } ); } @borrowernumbers;
}
elsif (@borrower_numbers) {
@borrower_numbers =
map { $_->borrowernumber }
Koha::Patrons->search( { borrowernumber => { -in => \@borrower_numbers } }, { order_by => [$order_by] } )
->as_list
if ($order_by);
grep {
push(@{$items}, {borrower_number => $_});
} @borrower_numbers;
@ -106,7 +119,16 @@ elsif ( $patronlist_id ) {
} @borrowerlist;
}
else {
$items = $batch->get_attr('items');
my $batch_items = $batch->get_attr('items');
my @borrowernumbers = map { $_->{borrower_number} } @{$batch_items};
@borrowernumbers =
map { $_->borrowernumber }
Koha::Patrons->search( { borrowernumber => { -in => \@borrowernumbers } }, { order_by => [$order_by] } )
->as_list
if ($order_by);
grep {
push(@{$items}, {borrower_number => $_});
} @borrowernumbers;
}
my $layout_xml = XMLin($layout->get_attr('layout_xml'), ForceArray => 1);

View File

@ -73,6 +73,7 @@ if ($op eq 'export') {
$template->param(
batches => \@batches,
referer => $referer,
order_by => $order_by,
);
}
elsif (@borrower_numbers) {
@ -89,6 +90,7 @@ if ($op eq 'export') {
$template->param(
batches => \@batches,
referer => $referer,
order_by => $order_by,
);
}
elsif (@batch_ids) {
@ -104,6 +106,7 @@ if ($op eq 'export') {
$template->param(
batches => \@batches,
referer => $referer,
order_by => $order_by,
);
}
elsif ($patronlist_id ) {