Bugzilla – Attachment 167956 Details for
Bug 32742
Add sorting options to patron list export
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32742: Patron's lists option are not in alphabetical
Bug-32742-Patrons-lists-option-are-not-in-alphabet.patch (text/plain), 11.45 KB, created by
Alexandre Noel
on 2024-06-21 12:24:21 UTC
(
hide
)
Description:
Bug 32742: Patron's lists option are not in alphabetical
Filename:
MIME Type:
Creator:
Alexandre Noel
Created:
2024-06-21 12:24:21 UTC
Size:
11.45 KB
patch
obsolete
>From b08535d381adeb19f4fa56170e12cda1aa2ebe6c Mon Sep 17 00:00:00 2001 >From: Alexandre Noel <alexandre.noel@inlibro.com> >Date: Fri, 21 Jun 2024 07:53:53 -0400 >Subject: [PATCH] Bug 32742: Patron's lists option are not in alphabetical >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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. > >It's also working for export in Patron card creator page. > >To test > >1. Go to Tools > Patron card creator >2. Create a new patron card batch >3. Add some patrons >4. Test the "Order by" option for different export button > 5. In an export form, Select the "Order by" field and submit > 6. Check that it's ordered > >Export buttons : >--> manage > card batches (or /cgi-bin/koha/patroncards/manage.pl?card_element=batch) > > Export (from the table) > > Select few batches > Export selected batches > > Export from patron list >--> Click "Edit" of your batch in the table > > Export card batch > > Export (from a row of the patrons table) note that this export > doesn't need the order by option. > > Select few patrons > Export selected card(s) >--- > .../prog/en/modules/patroncards/print.tt | 29 ++++++++--------- > patroncards/create-pdf.pl | 32 +++++++++++++++---- > patroncards/print.pl | 15 +++++---- > 3 files changed, 49 insertions(+), 27 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 545a05879b..7a6f2edf1f 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 ) %] > <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 %]&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]]&layout_back_id=[% batche.layout_back_id | html %]&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 %]&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]]&layout_back_id=[% batche.layout_back_id | html %]&start_card=[% batche.start_card | html %][% batche.label_ids | html %]&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 %]&layout_id=[% batche.layout_id | html %]&layout_back_id=[% batche.layout_back_id | html %]&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 %]&layout_id=[% batche.layout_id | html %]&layout_back_id=[% batche.layout_back_id | html %]&start_card=[% batche.start_card | html %][% batche.borrower_numbers | html %]&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 %]&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]&layout_back_id=[% batche.layout_back_id | html %]&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 %]&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]&layout_back_id=[% batche.layout_back_id | html %]&start_card=[% batche.start_card | html %]&order_by=[% order_by | html %]">label_batch_[% batche.batch_id | html %].pdf</a> > </p> > [% END %] > [% END %] >@@ -77,17 +77,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"> >@@ -114,7 +103,17 @@ > </select> > <span class="hint">Used for duplex printers (needs a '1 up template')</span> > </li> >- >+ [% IF ( card_count != 1 ) %] >+ <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="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" /> >diff --git a/patroncards/create-pdf.pl b/patroncards/create-pdf.pl >index fbe4708c58..e79b0d78ba 100755 >--- a/patroncards/create-pdf.pl >+++ b/patroncards/create-pdf.pl >@@ -91,24 +91,44 @@ eval { > my ( $llx, $lly ) = 0, 0; > ( undef, undef, $llx, $lly ) = $pc_template->get_label_position($start_card); > >+ # sort the borrower list by the order_by field >+ sub sort_borrowerlist { >+ my ( $list, $order_by ) = @_; # $list is a reference to an array of borrower numbers >+ my @borrower_list = @$list; >+ if ($order_by) { >+ @borrower_list = >+ map { $_->borrowernumber } >+ Koha::Patrons->search( { borrowernumber => { -in => \@borrower_list } }, { order_by => [$order_by] } ) >+ ->as_list; >+ } >+ return @borrower_list; >+ } >+ > if (@label_ids) { > my $batch_items = $batch->get_attr('items'); >+ my @selected_borrower; > grep { > my $label_id = $_; >- push( @{$items}, grep { $_->{'label_id'} == $label_id; } @{$batch_items} ); >+ push( @selected_borrower, grep { $_->{'label_id'} == $label_id; } @{$batch_items} ); > } @label_ids; >+ @selected_borrower = map { $_->{borrower_number} } @selected_borrower; >+ @selected_borrower = sort_borrowerlist( \@selected_borrower, $order_by ) if ($order_by); >+ grep { push( @{$items}, { borrower_number => $_ } ); } @selected_borrower; > } elsif (@borrower_numbers) { >+ @borrower_numbers = sort_borrowerlist( \@borrower_numbers, $order_by ) if ($order_by); > grep { push( @{$items}, { borrower_number => $_ } ); } @borrower_numbers; > } 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); >+ @borrowerlist = sort_borrowerlist( \@borrowerlist, $order_by ) if ($order_by); > grep { push( @{$items}, { borrower_number => $_ } ); } @borrowerlist; >+ } elsif ($batch_id) { >+ $items = $batch->get_attr('items'); >+ my @borrowerlist = map { $_->{'borrower_number'} } @{$items}; >+ @borrowerlist = sort_borrowerlist( \@borrowerlist, $order_by ) if ($order_by); >+ @{$items} = map { { borrower_number => $_ } } @borrowerlist; >+ > } else { > $items = $batch->get_attr('items'); > } >diff --git a/patroncards/print.pl b/patroncards/print.pl >index b4745ffbff..803d4a7806 100755 >--- a/patroncards/print.pl >+++ b/patroncards/print.pl >@@ -77,8 +77,9 @@ if ( $op eq 'cud-export' ) { #FIXME Seems like a GET operation? > } > ); > $template->param( >- batches => \@batches, >- referer => $referer, >+ batches => \@batches, >+ referer => $referer, >+ order_by => $order_by, > ); > } elsif (@borrower_numbers) { > my $borrower_number_param = '&borrower_number='; >@@ -96,8 +97,9 @@ if ( $op eq 'cud-export' ) { #FIXME Seems like a GET operation? > } > ); > $template->param( >- batches => \@batches, >- referer => $referer, >+ batches => \@batches, >+ referer => $referer, >+ order_by => $order_by, > ); > } elsif (@batch_ids) { > foreach my $batch_id (@batch_ids) { >@@ -114,8 +116,9 @@ if ( $op eq 'cud-export' ) { #FIXME Seems like a GET operation? > ); > } > $template->param( >- batches => \@batches, >- referer => $referer, >+ batches => \@batches, >+ referer => $referer, >+ order_by => $order_by, > ); > } elsif ($patronlist_id) { > $template->param( >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32742
:
155468
|
155469
|
155572
|
167956
|
168069
|
170786
|
170787
|
170882
|
170883
|
170884
|
170916
|
170917
|
170918
|
176400
|
176401
|
176402