@@ -, +, @@ - By cardnumber file - By cardnumber list - By SMS number file - By SMS number list - By borrowernumber file - By borrowernumber list - By patron list - If a file is uploaded AND a list of number submitted then the list of numbers will be used - 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. --- .../prog/en/modules/tools/modborrowers.tt | 41 ++++++++++++++++++-- tools/modborrowers.pl | 45 +++++++++++++++------- 2 files changed, 69 insertions(+), 17 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt @@ -44,6 +44,9 @@ By card number
  • + By SMS number +
  • +
  • By borrowernumber
  • [% IF patron_lists %] @@ -76,6 +79,30 @@ Cancel +
    +
    + Use a file of SMS numbers +
      +
    1. + +
      File must contain one SMS number per line.
      +
    2. +
    +
    +
    + List SMS numbers one by one +
      +
    1. + + +
    2. +
    +
    +
    + + Cancel +
    +
    Use a file of borrowernumbers @@ -130,7 +157,7 @@ [% op = 'noshow' # Change op to prevent display in code below %]

    Batch patrons modification

    -

    No patron card numbers or borrowernumbers given.

    +

    No patron card numbers, SMS numbers or borrowernumbers given.

    @@ -146,6 +173,8 @@ [% IF ( notfoundcardnumbers ) %] [% IF ( useborrowernumbers ) -%]

    Warning, the following borrowernumbers were not found:

    + [% ELSIF ( usesmsnumbers ) -%] +

    Warning, the following SMS numbers were not found:

    [% ELSE -%]

    Warning, the following card numbers were not found:

    [% END %] @@ -154,6 +183,8 @@ [% IF ( useborrowernumbers ) -%] Borrowernumbers not found + [% ELSIF ( usesmsnumbers ) -%] + SMS numbers not found [% ELSE -%] Card numbers not found [% 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(""); } }); }); --- a/tools/modborrowers.pl +++ a/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; --