Bugzilla – Attachment 128877 Details for
Bug 23291
Patron batch modification based on SMS number
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23291: Patron batch modification based on SMS number
Bug-23291-Patron-batch-modification-based-on-SMS-n.patch (text/plain), 11.21 KB, created by
David Nind
on 2021-12-23 04:44:34 UTC
(
hide
)
Description:
Bug 23291: Patron batch modification based on SMS number
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-12-23 04:44:34 UTC
Size:
11.21 KB
patch
obsolete
>From 9c3a3b451ae83f6e83b49378140bcf293af1b815 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 8 Dec 2021 04:30:13 +0000 >Subject: [PATCH] Bug 23291: Patron batch modification based on SMS number > >This patch is based on the patchset on bug 24019. It enabled librarians >to list SMS numbers (one per line) or upload a file of SMS numbers, just >like they can currently do with borrowernumbers or card numbers. > >Test plan: >1. Apply patch >2. Restart services >3. Create a patron list in: Tools > Patrons lists >4. Navigate to Tools > Batch patron modification >5. Observe there are 4 tabs: 'By card number', 'By SMS number', 'By >borrowernumber', 'By patron list' >6. Test each option for batch patron modifications: >- By cardnumber file >- By cardnumber list >- By SMS number file >- By SMS number list >- By borrowernumber file >- By borrowernumber list >- By patron list >7. In all of the above cases the correct patrons should be retrieved by >Koha, and modified. >8. Test uploading a SMS number shared by multiple patrons and confirm >all patrons with that SMS number are returned >9. Confirm the 'order of operations' for card numbers, SMS numbers and >borrowernumbers is followed: > - If a file is uploaded AND a list of number submitted then the list of > numbers will be used >10. Confirm batches are only submitted from the active tab > - If you upload a file OR input a list SMS numbers, and then switch to > a different tab and input a list of borrowernumbers then the SMS > numbers originally inputted should be ignored. > >Sponsored-By: Brimbank Library, Australia > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../prog/en/modules/tools/modborrowers.tt | 41 +++++++++++++++-- > tools/modborrowers.pl | 45 +++++++++++++------ > 2 files changed, 69 insertions(+), 17 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >index f60a917a9b..db84178dde 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >@@ -43,6 +43,9 @@ > <li> > <a href="#usecardnumber">By card number</a> > </li> >+ <li> >+ <a href="#usesmsnumber">By SMS number</a> >+ </li> > <li> > <a href="#useborrowernumber">By borrowernumber</a> > </li> >@@ -74,6 +77,30 @@ > <fieldset class="action"> > <input type="submit" value="Continue" class="button" /> > <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a> >+ </fieldset> >+ </div> >+ <div id="usesmsnumber"> >+ <fieldset class="rows"> >+ <legend>Use a file of SMS numbers</legend> >+ <ol> >+ <li> >+ <label for="smsnumberuploadfile">File: </label> <input type="file" id="smsnumberuploadfile" name="smsnumberuploadfile" /> >+ <div class="hint">File must contain one SMS number per line.</div> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="rows"> >+ <legend>List SMS numbers one by one</legend> >+ <ol> >+ <li> >+ <label for="smsnumberlist">SMS number list (one number per line): </label> >+ <textarea rows="10" cols="30" id="smsnumberlist" name="smsnumberlist">[% smsnumberlist | html %]</textarea> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Continue" class="button" /> >+ <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a> > </fieldset> > </div> > <div id="useborrowernumber"> >@@ -130,7 +157,7 @@ > [% op = 'noshow' # Change op to prevent display in code below %] > <h1>Batch patrons modification</h1> > <div class="dialog alert"> >- <p>No patron card numbers or borrowernumbers given.</p> >+ <p>No patron card numbers, SMS numbers or borrowernumbers given.</p> > <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get"> > <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button> > </form> >@@ -146,6 +173,8 @@ > [% IF ( notfoundcardnumbers ) %] > [% IF ( useborrowernumbers ) -%] > <div class="dialog alert"><p>Warning, the following borrowernumbers were not found:</p></div> >+ [% ELSIF ( usesmsnumbers ) -%] >+ <div class="dialog alert"><p>Warning, the following SMS numbers were not found:</p></div> > [% ELSE -%] > <div class="dialog alert"><p>Warning, the following card numbers were not found:</p></div> > [% END %] >@@ -154,6 +183,8 @@ > <thead> > [% IF ( useborrowernumbers ) -%] > <tr><th>Borrowernumbers not found</th></tr> >+ [% ELSIF ( usesmsnumbers ) -%] >+ <tr><th>SMS numbers not found</th></tr> > [% ELSE -%] > <tr><th>Card numbers not found</th></tr> > [% END %] >@@ -481,11 +512,13 @@ > /* Reset form fields on inactive tabs */ > var tab = $(this).find('.ui-tabs-active:first a').attr('href'); > if ( tab == '#usecardnumber' ) { >- $("#borrowernumberuploadfile, #patron_list_id, #borrowernumberlist").val(""); >+ $("#borrowernumberuploadfile, #smsnumberuploadfile, #patron_list_id, #borrowernumberlist, #smsnumberlist").val(""); >+ } else if ( tab == '#usesmsnumber' ) { >+ $("#borrowernumberuploadfile, #cardnumberuploadfile, #patron_list_id, #borrowernumberlist, #cardnumberlist").val(""); > } else if ( tab == '#useborrowernumber' ) { >- $("#cardnumberuploadfile, #cardnumberlist, #patron_list_id").val(""); >+ $("#cardnumberuploadfile, #smsnumberuploadfile, #cardnumberlist, #patron_list_id, #smsnumberlist").val(""); > } else { // uselist >- $("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val(""); >+ $("#borrowernumberuploadfile, #cardnumberuploadfile, #smsnumberuploadfile, #borrowernumberlist, #cardnumberlist, #smsnumberlist").val(""); > } > }); > }); >diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl >index 4ff7dfe6db..d882297b48 100755 >--- a/tools/modborrowers.pl >+++ b/tools/modborrowers.pl >@@ -60,6 +60,7 @@ if ( $op eq 'show' ) { > my @patronidnumbers; > my @notfoundcardnumbers; > my $useborrowernumbers = 0; >+ my $usesmsnumbers = 0; > > # Get cardnumbers from a file or the input area > if( my $cardnumberlist = $input->param('cardnumberlist') ){ >@@ -73,6 +74,19 @@ if ( $op eq 'show' ) { > $content =~ s/[\r\n]*$//; > push @patronidnumbers, $content if $content; > } >+ } elsif ( my $smsnumberlist = $input->param('smsnumberlist') ){ >+ # User submitted a list of SMS numbers >+ $usesmsnumbers = 1; >+ push @patronidnumbers, split( /\s\n/, $smsnumberlist ); >+ } elsif ( my $smsnumberuploadfile = $input->param('smsnumberuploadfile') ){ >+ # User uploaded a file of SMS numbers >+ $usesmsnumbers = 1; >+ binmode $smsnumberuploadfile, ':encoding(UTF-8)'; >+ while ( my $content = <$smsnumberuploadfile> ) { >+ next unless $content; >+ $content =~ s/[\r\n]*$//; >+ push @patronidnumbers, $content if $content; >+ } > } elsif ( my $borrowernumberlist = $input->param('borrowernumberlist') ){ > # User submitted a list of borrowernumbers > $useborrowernumbers = 1; >@@ -97,22 +111,26 @@ if ( $op eq 'show' ) { > my $max_nb_attr = 0; > > for my $patronidnumber ( @patronidnumbers ) { >- my $patron; >+ my $patrons; > if( $useborrowernumbers == 1 ){ >- $patron = Koha::Patrons->find( { borrowernumber => $patronidnumber } ); >+ $patrons = Koha::Patrons->search( { borrowernumber => $patronidnumber } ); >+ } elsif ( $usesmsnumbers == 1 ){ >+ $patrons = Koha::Patrons->search( { smsalertnumber => $patronidnumber } ); > } else { >- $patron = Koha::Patrons->find( { cardnumber => $patronidnumber } ); >+ $patrons = Koha::Patrons->search( { cardnumber => $patronidnumber } ); > } >- if ( $patron ) { >- if ( $logged_in_user->can_see_patron_infos( $patron ) ) { >- my $borrower = $patron->unblessed; >- my $attributes = $patron->extended_attributes; >- $borrower->{patron_attributes} = $attributes->as_list; >- $borrower->{patron_attributes_count} = $attributes->count; >- $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; >- push @borrowers, $borrower; >- } else { >- push @notfoundcardnumbers, $patronidnumber; >+ if ( $patrons->count > 0 ) { >+ while ( my $patron = $patrons->next ) { >+ if ( $logged_in_user->can_see_patron_infos( $patron ) ) { >+ my $borrower = $patron->unblessed; >+ my $attributes = $patron->extended_attributes; >+ $borrower->{patron_attributes} = $attributes->as_list; >+ $borrower->{patron_attributes_count} = $attributes->count; >+ $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; >+ push @borrowers, $borrower; >+ } else { >+ push @notfoundcardnumbers, $patronidnumber; >+ } > } > } else { > push @notfoundcardnumbers, $patronidnumber; >@@ -168,6 +186,7 @@ if ( $op eq 'show' ) { > $template->param( notfoundcardnumbers => \@notfoundcardnumbers ) > if @notfoundcardnumbers; > $template->param( useborrowernumbers => $useborrowernumbers ); >+ $template->param( usesmsnumbers => $usesmsnumbers ); > > # Construct drop-down list values > my $branches = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed; >-- >2.30.2
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 23291
:
91436
|
92429
|
92430
|
92666
|
92667
|
93859
|
101931
|
101932
|
101933
|
112469
|
112470
|
112471
|
128641
|
128876
| 128877