From 1c6d065a9fa73c83f8fe9531848eb45fb54ecefa Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Tue, 27 Aug 2024 20:56:28 +0000 Subject: [PATCH] Bug 32742: (follow-up) Add sorting feature when printing the patron cards from the patron card creator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Lisette Scheer --- .../prog/en/modules/patroncards/print.tt | 28 +++++++++---------- patroncards/create-pdf.pl | 26 +++++++++++++++-- patroncards/print.pl | 3 ++ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt index eac2ea58f13..887f10f02fa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt @@ -23,17 +23,17 @@ [% IF ( batche.label_ids ) %] [% batche.card_count | html %] Single patron cards

- label_single_[% batche.card_count | html %].pdf + label_single_[% batche.card_count | html %].pdf

[% ELSIF ( batche.borrower_numbers ) %] [% batche.card_count | html %] Single patron cards

- label_single_[% batche.card_count | html %].pdf + label_single_[% batche.card_count | html %].pdf

[% ELSE %] Card batch number [% batche.batch_id | html %]

- label_batch_[% batche.batch_id | html %].pdf + label_batch_[% batche.batch_id | html %].pdf

[% END %] [% END %] @@ -76,17 +76,6 @@ [% IF (patronlist_id) %] [% END %]
    - [% IF (patronlist_id) %] -
  1. - - -
  2. - [% END %]
  3. + [% IF patronlist_id || batch_id %] +
  4. + + +
  5. + [% END %]
diff --git a/patroncards/create-pdf.pl b/patroncards/create-pdf.pl index 5e86deac45f..a6ba2bbd4b7 100755 --- a/patroncards/create-pdf.pl +++ b/patroncards/create-pdf.pl @@ -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); diff --git a/patroncards/print.pl b/patroncards/print.pl index efee812233a..c9fb1943104 100755 --- a/patroncards/print.pl +++ b/patroncards/print.pl @@ -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 ) { -- 2.39.5