Bugzilla – Attachment 112469 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: Find patrons by smsalertnumber in the batch patron modification
Bug-23291-Find-patrons-by-smsalertnumber-in-the-ba.patch (text/plain), 12.83 KB, created by
Aleisha Amohia
on 2020-10-25 03:44:07 UTC
(
hide
)
Description:
Bug 23291: Find patrons by smsalertnumber in the batch patron modification
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2020-10-25 03:44:07 UTC
Size:
12.83 KB
patch
obsolete
>From c35e6037dd33e45b2cbff4c4161df1d6e8fb66c5 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 10 Jul 2019 03:05:18 +0000 >Subject: [PATCH] Bug 23291: Find patrons by smsalertnumber in the batch patron > modification > >Add ability to paste in sms numbers (one per line) or upload a file of >sms numbers and find patrons with matching smsalertnumber values. > >If an sms number is not found then this is displayed in a yellow box to >the librarian i.e. the batch patron modification tool will behave as it >does currently when a cardnumber is not found. > >Test plan: >1. Go to Tools > Batch patron modification > >2. Notice there is a file upload (for cardnumbers) and a text input area >(for cardnumbers) > >3. Apply patch and restart memached and plack > >4. Refresh the page and notice a file upload (for sms numbers) and file >text input area (for sms numbers) have been added > >5. Create a file with valid sms numbers matching smsalertnumber values >of patrons (one per line) > >6. Select/upload the file into the sms number file upload and submit the >form > >7. Notice the patrons are found and you can batch modify them. Select a >date in the 'Restriction expiration' datepicker and submit and notice >this is added to the selected borrowers in the borrowers.debarred, >borrowers.debarredcomment fields and borrower_debarment table. > >8. Create a file with some valid and some invalid sms numbers (i.e. some >smsnumbers belonging to patrons in their smsalertnumber field and some >not matching) > >9. Upload your file from 8 in the SMS number file upload and notice that >error handling means the invalid/non-matching sms numbers are shown >below the yellow box at the top of the page whilst matching sms numbers >have returned patrons which you can edit > >10. Confirm card number file upload still works by making a file of >valid cardnumbers and uploading it in the Batch patron modification tool >and noticing the patrons are successfully returned > >11. In the batch patron modification tool paste valid sms numbers into the sms number text area input (0ne >per line) and submit the batch patron modification. Notice that the >patrons are successfully returned and displayed. > >12. Repeat step 11 but this time paste in valid and invalid sms numbers >and notice error handling means sms numbers which did not match >borrowers, smsalertnumber are shown under the yellow box at the top of >the page and patrons who matched sms numbers are shown below in the >table > >13. Repeat step 11 this time input only invalid sms numbers and submit. > >Notice that a page showing the yellow notice box and a list of all >smsnumbers which could not be found are returned. > >14. Repeat step 11 submitting valid smsnumbers in the cardnumber text area field and you will >notice that a page showing the yellow notice box and a list of all non >matching cardnumbers. > >15. In your Koha home directory run: sudo koha-shell <instancename> > >Then run: prove xt > >16. Confirm all test pass > >17. Sign off > >Sponsored-By: Brimbank Library, Australia > >Signed-off-by: George Williams <george@nekls.org> >--- > .../prog/en/modules/tools/modborrowers.tt | 42 +++++++++++-- > tools/modborrowers.pl | 72 ++++++++++++++++------ > 2 files changed, 90 insertions(+), 24 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 9147d522f95..affdae92480 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >@@ -29,9 +29,16 @@ > <h1>Batch patron modification</h1> > <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl"> > <fieldset class="rows"> >- <legend>Use a file</legend> >+ <legend>Use a file of cardnumbers</legend> > <ol> >- <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li> >+ <li><label for="uploadfile">File: </label> <input type="file" id="uploadcardnumberfile" name="uploadcardnumberfile" /></li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="rows"> >+ <legend>Use a file of SMS numbers</legend> >+ <ol> >+ <li><label for="uploadfile">File: </label> <input type="file" id="uploadsmsnumberfile" name="uploadsmsnumberfile" /></li> > </ol> > </fieldset> > >@@ -61,6 +68,17 @@ > </li> > </ol> > </fieldset> >+ >+ <fieldset class="rows"> >+ <legend>Or list SMS numbers one by one</legend> >+ <ol> >+ <li> >+ <label for="smsnumberlist">SMS number list (one SMS number per line): </label> >+ <textarea rows="10" cols="30" id="smsnumberlist" name="smsnumberlist">[% smsnumberlist | html %]</textarea> >+ </li> >+ </ol> >+ </fieldset> >+ > <input type="hidden" name="op" value="show" /> > <fieldset class="action"> > <input type="submit" value="Continue" class="button" /> >@@ -69,11 +87,11 @@ > </form> > [% END %] > >- [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%] >+ [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) && (!notfoundsmsnumbers) # Alert if no patrons given%] > [% op = 'noshow' # Change op to prevent display in code below %] > <h1>Batch patrons modification</h1> > <div class="dialog alert"> >- <p>No patron card numbers given.</p> >+ <p>No patron card numbers/SMS numbers 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> >@@ -100,6 +118,21 @@ > </table> > [% END %] > >+ [% IF ( notfoundsmsnumbers ) %] >+ <div class="dialog alert"><p>Warning, the following sms numbers were not found:</p></div> >+ <table style="margin:auto;"> >+ <thead> >+ <tr><th>SMS numbers not found</th></tr> >+ </thead> >+ <tbody> >+ [% FOREACH notfoundsmsnumber IN notfoundsmsnumbers %] >+ <tr><td>[% notfoundsmsnumber.smsalertnumber | html %]</td></tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% END %] >+ >+ > [% IF ( op == 'show_results' ) %] > [% IF ( errors ) %] > <div class="dialog alert"> >@@ -109,6 +142,7 @@ > [% IF ( error.error == 'can_not_update' ) %] > <li>Can not update patron. > [% IF ( error.cardnumber ) %] Cardnumber: [% error.cardnumber | html %] [% END %] >+ [% IF ( error.smsnumber ) %] SMS number: [% error.smsnumber | html %] [% END %] > (Borrowernumber: [% error.borrowernumber | html %]) > </li> > [% ELSE %] >diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl >index 5a0193f75b5..4c280b86f03 100755 >--- a/tools/modborrowers.pl >+++ b/tools/modborrowers.pl >@@ -57,48 +57,77 @@ my $dbh = C4::Context->dbh; > > # Show borrower informations > if ( $op eq 'show' ) { >- my $filefh = $input->upload('uploadfile'); >+ my $cardnumberfilefh = $input->upload('uploadcardnumberfile'); >+ my $smsnumberfilefh = $input->upload('uploadsmsnumberfile'); > my $filecontent = $input->param('filecontent'); > my $patron_list_id = $input->param('patron_list_id'); > my @borrowers; > my @cardnumbers; >- my @notfoundcardnumbers; >+ my @smsnumbers; >+ my ( @notfoundcardnumbers, @notfoundsmsnumbers ); > > # Get cardnumbers from a file or the input area >- if ($filefh) { >- while ( my $content = <$filefh> ) { >+ if ( $cardnumberfilefh ) { >+ while ( my $content = <$cardnumberfilefh> ) { > $content =~ s/[\r\n]*$//g; > push @cardnumbers, $content if $content; > } >+ } elsif ( $smsnumberfilefh ) { >+ while ( my $content = <$smsnumberfilefh> ) { >+ $content =~ s/[\r\n]*$//g; >+ push @smsnumbers, $content if $content; >+ } > } elsif ( $patron_list_id ) { > my ($list) = GetPatronLists( { patron_list_id => $patron_list_id } ); > > @cardnumbers = > $list->patron_list_patrons()->search_related('borrowernumber') > ->get_column('cardnumber')->all(); >- >+ @smsnumbers = >+ $list->patron_list_patrons()->search_related('borrowernumber') >+ ->get_column('smsalertnumber')->all(); > } else { >- if ( my $list = $input->param('cardnumberlist') ) { >- push @cardnumbers, split( /\s\n/, $list ); >+ if ( my $cardnumberlist = $input->param('cardnumberlist') ) { >+ push @cardnumbers, split( /\s\n/, $cardnumberlist ); >+ } elsif ( my $smsnumberlist = $input->param('smsnumberlist') ) { >+ push @smsnumbers, split( /\s\n/, $smsnumberlist ); > } > } > > my $max_nb_attr = 0; >- for my $cardnumber ( @cardnumbers ) { >- my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } ); >- 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; >+ if ( @cardnumbers ) { >+ for my $cardnumber ( @cardnumbers ) { >+ my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } ); >+ 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, $cardnumber; >+ } >+ I } >+ } >+ } else { >+ for my $smsnumber (@smsnumbers ) { >+ my $patron = Koha::Patrons->find( { smsalertnumber => $smsnumber } ); >+ 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, $patron; >+ } else { >+ push @notfoundsmsnumbers, $smsnumber; >+ } > } else { >- push @notfoundcardnumbers, $cardnumber; >+ push @notfoundsmsnumbers, $smsnumber; > } >- } else { >- push @notfoundcardnumbers, $cardnumber; > } > } > >@@ -148,6 +177,9 @@ if ( $op eq 'show' ) { > $template->param( borrowers => \@borrowers ); > $template->param( attributes_header => \@attributes_header ); > @notfoundcardnumbers = map { { cardnumber => $_ } } @notfoundcardnumbers; >+ @notfoundsmsnumbers = map { { smsalertnumber => $_ } } @notfoundsmsnumbers; >+ $template->param( notfoundsmsnumbers => \@notfoundsmsnumbers ) if @notfoundsmsnumbers; >+ > $template->param( notfoundcardnumbers => \@notfoundcardnumbers ) > if @notfoundcardnumbers; > >-- >2.11.0
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