Bugzilla – Attachment 92667 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: Retrieve all patrons with given SMS number, and change inputs
Bug-23291-Retrieve-all-patrons-with-given-SMS-numb.patch (text/plain), 9.25 KB, created by
ByWater Sandboxes
on 2019-09-09 16:16:10 UTC
(
hide
)
Description:
Bug 23291: Retrieve all patrons with given SMS number, and change inputs
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2019-09-09 16:16:10 UTC
Size:
9.25 KB
patch
obsolete
>From c2b521961e1c00b1e82053b29ba3cbf2a994f754 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 19 Aug 2019 19:24:16 +1200 >Subject: [PATCH] Bug 23291: Retrieve all patrons with given SMS number, and > change inputs > >This patch now handles situations where more than one patron has a given >SMS number. > >The inputs are now more concise as radio buttons are now present for users >to indicate whether the file they are uploading or the list of numbers they >are entering are cardnumbers or SMS numbers. > >Test plan same as first patch, although take into account slight changes >to inputs. >Also test an SMS number that more than one patron has and check that all >patrons with that number are displayed. > >Sponsored-by: Brimbank Library, Australia >Authored-by: Alex Buckley and Hayley Mapley (Catalyst IT) > >Signed-off-by: George Williams <george@nekls.org> >--- > .../prog/en/modules/tools/modborrowers.tt | 30 +++------- > tools/modborrowers.pl | 66 +++++++++++++--------- > 2 files changed, 48 insertions(+), 48 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 777fd5f042..ce47452d6a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >@@ -29,16 +29,11 @@ > <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 of cardnumbers</legend> >+ <legend>Use a file of cardnumbers or SMS numbers</legend> > <ol> >- <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> >+ <li><label for="cardnumberfile">Cardnumbers:</label><input type="radio" name="fileoption" id="cardnumberfile" value="cardnumber" checked></input></li> >+ <li><label for="smsnumberfile">SMS numbers:</label><input type="radio" name="fileoption" id="smsnumberfile" value="sms"></input></li> >+ <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li> > </ol> > </fieldset> > >@@ -60,21 +55,14 @@ > [% END %] > > <fieldset class="rows"> >- <legend>Or list cardnumbers one by one</legend> >+ <legend>Or list cardnumbers or SMS numbers one by one</legend> > <ol> >- <li> >- <label for="cardnumberlist">Card number list (one cardnumber per line): </label> >- <textarea rows="10" cols="30" id="cardnumberlist" name="cardnumberlist">[% cardnumberlist | html %]</textarea> >- </li> >- </ol> >- </fieldset> >+ <li><label for="cardnumberlist">Cardnumbers:</label><input type="radio" name="manual_list_option" id="cardnumberlist" value="cardnumber" checked></input></li> >+ <li><label for="smsnumberfile">SMS numbers:</label><input type="radio" name="manual_list_option" id="smsnumberlist" value="sms"></input></li> > >- <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> >+ <label for="list">List (one cardnumber or SMS number per line): </label> >+ <textarea rows="10" cols="30" id="list" name="list">[% list | html %]</textarea> > </li> > </ol> > </fieldset> >diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl >index 8fa625b707..ce358fec0e 100755 >--- a/tools/modborrowers.pl >+++ b/tools/modborrowers.pl >@@ -60,26 +60,28 @@ my $dbh = C4::Context->dbh; > > # Show borrower informations > if ( $op eq 'show' ) { >- my $cardnumberfilefh = $input->upload('uploadcardnumberfile'); >- my $smsnumberfilefh = $input->upload('uploadsmsnumberfile'); >- my $filecontent = $input->param('filecontent'); >+ my $filefh = $input->upload('uploadfile'); >+ my $filecontent = $input->param('fileoption'); > my $patron_list_id = $input->param('patron_list_id'); >+ my $manual_list_option = $input->param('manual_list_option'); > my @borrowers; > my @cardnumbers; > my @smsnumbers; > my ( @notfoundcardnumbers, @notfoundsmsnumbers, @from_another_group_of_libraries ); > >- # Get cardnumbers from a file or the input area >+ # Get cardnumbers or SMS numbers from a file, a list, or the input area > my @contentlist; >- 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; >+ if ($filefh) { >+ if ($filecontent eq 'cardnumber') { # If cardnumber radio button selected, then push file content to @cardnumbers >+ while ( my $content = <$filefh> ) { >+ $content =~ s/[\r\n]*$//g; >+ push @cardnumbers, $content if $content; >+ } >+ } elsif ($filecontent eq 'sms') { # If SMS radio button selected, then push file content to @smsnumbers >+ while ( my $content = <$filefh> ) { >+ $content =~ s/[\r\n]*$//g; >+ push @smsnumbers, $content if $content; >+ } > } > } elsif ( $patron_list_id ) { > my ($list) = GetPatronLists( { patron_list_id => $patron_list_id } ); >@@ -90,11 +92,16 @@ if ( $op eq 'show' ) { > @smsnumbers = > $list->patron_list_patrons()->search_related('borrowernumber') > ->get_column('smsalertnumber')->all(); >- } else { >- if ( my $cardnumberlist = $input->param('cardnumberlist') ) { >- push @cardnumbers, split( /\s\n/, $cardnumberlist ); >- } elsif ( my $smsnumberlist = $input->param('smsnumberlist') ) { >- push @smsnumbers, split( /\s\n/, $smsnumberlist ); >+ } else { # If numbers are in the textarea, check the radio button and push into appropriate array >+ >+ my $list = $input->param('list'); >+ >+ if ( $manual_list_option eq 'cardnumber' ) { # If cardnumber radio button selected then push textarea content to @cardnumbers >+ push @cardnumbers, split( /\s\n/, $list ); >+ >+ } elsif ( $manual_list_option eq 'sms' ) { # If sms number radio button selected then push textarea content to @smsnumbers >+ push @smsnumbers, split( /\s\n/, $list ); >+ > } > } > >@@ -118,18 +125,23 @@ if ( $op eq 'show' ) { > } > } else { > for my $smsnumber (@smsnumbers ) { >- my $patron = Koha::Patrons->find( { smsalertnumber => $smsnumber } ); >- if ( $patron ) { >- if ( $logged_in_user->can_see_patron_infos( $patron ) ) { >- $patron = $patron->unblessed; >- $patron->{patron_attributes} = C4::Members::Attributes::GetBorrowerAttributes( $patron->{borrowernumber} ); >- $max_nb_attr = scalar( @{ $patron->{patron_attributes} } ) if scalar( @{ $patron->{patron_attributes} } ) > $max_nb_attr; >- push @borrowers, $patron; >+ my @patrons = Koha::Patrons->search( { smsalertnumber => $smsnumber } ); >+ my $patron; >+ my $borrowernumber; >+ my $value; >+ foreach $patron (@patrons) { >+ if ( $patron ) { >+ if ( $logged_in_user->can_see_patron_infos( $patron ) ) { >+ $patron = $patron->unblessed; >+ $patron->{patron_attributes} = C4::Members::Attributes::GetBorrowerAttributes( $patron->{borrowernumber} ); >+ $max_nb_attr = scalar( @{ $patron->{patron_attributes} } ) if scalar( @{ $patron->{patron_attributes} } ) > $max_nb_attr; >+ push @borrowers, $patron; >+ } else { >+ push @notfoundsmsnumbers, $smsnumber; >+ } > } else { > push @notfoundsmsnumbers, $smsnumber; > } >- } else { >- push @notfoundsmsnumbers, $smsnumber; > } > } > } >-- >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