View | Details | Raw Unified | Return to bug 23291
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt (-4 / +37 lines)
Lines 44-49 Link Here
44
                                <a href="#usecardnumber">By card number</a>
44
                                <a href="#usecardnumber">By card number</a>
45
                            </li>
45
                            </li>
46
                            <li>
46
                            <li>
47
                                <a href="#usesmsnumber">By SMS number</a>
48
                            </li>
49
                            <li>
47
                                <a href="#useborrowernumber">By borrowernumber</a>
50
                                <a href="#useborrowernumber">By borrowernumber</a>
48
                            </li>
51
                            </li>
49
                            [% IF patron_lists %]
52
                            [% IF patron_lists %]
Lines 76-81 Link Here
76
                        <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
79
                        <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
77
                    </fieldset>
80
                    </fieldset>
78
                        </div>
81
                        </div>
82
                        <div id="usesmsnumber">
83
                            <fieldset class="rows">
84
                                <legend>Use a file of SMS numbers</legend>
85
                                <ol>
86
                                    <li>
87
                                        <label for="smsnumberuploadfile">File: </label> <input type="file" id="smsnumberuploadfile" name="smsnumberuploadfile" />
88
                                        <div class="hint">File must contain one SMS number per line.</div>
89
                                    </li>
90
                                </ol>
91
                            </fieldset>
92
                            <fieldset class="rows">
93
                                <legend>List SMS numbers one by one</legend>
94
                                <ol>
95
                                    <li>
96
                                        <label for="smsnumberlist">SMS number list (one number per line): </label>
97
                                        <textarea rows="10" cols="30" id="smsnumberlist" name="smsnumberlist">[% smsnumberlist | html %]</textarea>
98
                                    </li>
99
                                </ol>
100
                            </fieldset>
101
                    <fieldset class="action">
102
                        <input type="submit"  value="Continue" class="button" />
103
                        <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
104
                    </fieldset>
105
                        </div>
79
                        <div id="useborrowernumber">
106
                        <div id="useborrowernumber">
80
                            <fieldset class="rows">
107
                            <fieldset class="rows">
81
                                <legend>Use a file of borrowernumbers</legend>
108
                                <legend>Use a file of borrowernumbers</legend>
Lines 130-136 Link Here
130
                    [% op = 'noshow' # Change op to prevent display in code below %]
157
                    [% op = 'noshow' # Change op to prevent display in code below %]
131
                    <h1>Batch patrons modification</h1>
158
                    <h1>Batch patrons modification</h1>
132
                    <div class="dialog alert">
159
                    <div class="dialog alert">
133
                        <p>No patron card numbers or borrowernumbers given.</p>
160
                        <p>No patron card numbers, SMS numbers or borrowernumbers given.</p>
134
                        <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
161
                        <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
135
                         <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
162
                         <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
136
                        </form>
163
                        </form>
Lines 146-151 Link Here
146
                    [% IF ( notfoundcardnumbers ) %]
173
                    [% IF ( notfoundcardnumbers ) %]
147
                        [% IF ( useborrowernumbers ) -%]
174
                        [% IF ( useborrowernumbers ) -%]
148
                            <div class="dialog alert"><p>Warning, the following borrowernumbers were not found:</p></div>
175
                            <div class="dialog alert"><p>Warning, the following borrowernumbers were not found:</p></div>
176
                        [% ELSIF ( usesmsnumbers ) -%]
177
                            <div class="dialog alert"><p>Warning, the following SMS numbers were not found:</p></div>
149
                        [% ELSE -%]
178
                        [% ELSE -%]
150
                            <div class="dialog alert"><p>Warning, the following card numbers were not found:</p></div>
179
                            <div class="dialog alert"><p>Warning, the following card numbers were not found:</p></div>
151
                        [% END %]
180
                        [% END %]
Lines 154-159 Link Here
154
                            <thead>
183
                            <thead>
155
                                [% IF ( useborrowernumbers ) -%]
184
                                [% IF ( useborrowernumbers ) -%]
156
                                    <tr><th>Borrowernumbers not found</th></tr>
185
                                    <tr><th>Borrowernumbers not found</th></tr>
186
                                [% ELSIF ( usesmsnumbers ) -%]
187
                                    <tr><th>SMS numbers not found</th></tr>
157
                                [% ELSE -%]
188
                                [% ELSE -%]
158
                                    <tr><th>Card numbers not found</th></tr>
189
                                    <tr><th>Card numbers not found</th></tr>
159
                                [% END %]
190
                                [% END %]
Lines 481-491 Link Here
481
                /* Reset form fields on inactive tabs */
512
                /* Reset form fields on inactive tabs */
482
                var tab = $(this).find('.ui-tabs-active:first a').attr('href');
513
                var tab = $(this).find('.ui-tabs-active:first a').attr('href');
483
                if ( tab == '#usecardnumber' ) {
514
                if ( tab == '#usecardnumber' ) {
484
                    $("#borrowernumberuploadfile, #patron_list_id, #borrowernumberlist").val("");
515
                    $("#borrowernumberuploadfile, #smsnumberuploadfile, #patron_list_id, #borrowernumberlist, #smsnumberlist").val("");
516
                } else if ( tab == '#usesmsnumber' ) {
517
                    $("#borrowernumberuploadfile, #cardnumberuploadfile, #patron_list_id, #borrowernumberlist, #cardnumberlist").val("");
485
                } else if ( tab == '#useborrowernumber' ) {
518
                } else if ( tab == '#useborrowernumber' ) {
486
                    $("#cardnumberuploadfile, #cardnumberlist, #patron_list_id").val("");
519
                    $("#cardnumberuploadfile, #smsnumberuploadfile, #cardnumberlist, #patron_list_id, #smsnumberlist").val("");
487
                } else { // uselist
520
                } else { // uselist
488
                    $("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val("");
521
                    $("#borrowernumberuploadfile, #cardnumberuploadfile, #smsnumberuploadfile, #borrowernumberlist, #cardnumberlist, #smsnumberlist").val("");
489
                }
522
                }
490
            });
523
            });
491
        });
524
        });
(-)a/tools/modborrowers.pl (-14 / +32 lines)
Lines 60-65 if ( $op eq 'show' ) { Link Here
60
    my @patronidnumbers;
60
    my @patronidnumbers;
61
    my @notfoundcardnumbers;
61
    my @notfoundcardnumbers;
62
    my $useborrowernumbers = 0;
62
    my $useborrowernumbers = 0;
63
    my $usesmsnumbers  = 0;
63
64
64
    # Get cardnumbers from a file or the input area
65
    # Get cardnumbers from a file or the input area
65
    if( my $cardnumberlist = $input->param('cardnumberlist') ){
66
    if( my $cardnumberlist = $input->param('cardnumberlist') ){
Lines 73-78 if ( $op eq 'show' ) { Link Here
73
            $content =~ s/[\r\n]*$//;
74
            $content =~ s/[\r\n]*$//;
74
            push @patronidnumbers, $content if $content;
75
            push @patronidnumbers, $content if $content;
75
        }
76
        }
77
    } elsif ( my $smsnumberlist = $input->param('smsnumberlist') ){
78
        # User submitted a list of SMS numbers
79
        $usesmsnumbers = 1;
80
        push @patronidnumbers, split( /\s\n/, $smsnumberlist );
81
    } elsif ( my $smsnumberuploadfile = $input->param('smsnumberuploadfile') ){
82
        # User uploaded a file of SMS numbers
83
        $usesmsnumbers = 1;
84
        binmode $smsnumberuploadfile, ':encoding(UTF-8)';
85
        while ( my $content = <$smsnumberuploadfile> ) {
86
            next unless $content;
87
            $content =~ s/[\r\n]*$//;
88
            push @patronidnumbers, $content if $content;
89
        }
76
    } elsif ( my $borrowernumberlist = $input->param('borrowernumberlist') ){
90
    } elsif ( my $borrowernumberlist = $input->param('borrowernumberlist') ){
77
        # User submitted a list of borrowernumbers
91
        # User submitted a list of borrowernumbers
78
        $useborrowernumbers = 1;
92
        $useborrowernumbers = 1;
Lines 97-118 if ( $op eq 'show' ) { Link Here
97
    my $max_nb_attr = 0;
111
    my $max_nb_attr = 0;
98
112
99
    for my $patronidnumber ( @patronidnumbers ) {
113
    for my $patronidnumber ( @patronidnumbers ) {
100
        my $patron;
114
        my $patrons;
101
        if( $useborrowernumbers == 1 ){
115
        if( $useborrowernumbers == 1 ){
102
            $patron = Koha::Patrons->find( { borrowernumber => $patronidnumber } );
116
            $patrons = Koha::Patrons->search( { borrowernumber => $patronidnumber } );
117
        } elsif ( $usesmsnumbers == 1 ){
118
            $patrons = Koha::Patrons->search( { smsalertnumber => $patronidnumber } );
103
        } else {
119
        } else {
104
            $patron = Koha::Patrons->find( { cardnumber => $patronidnumber } );
120
            $patrons = Koha::Patrons->search( { cardnumber => $patronidnumber } );
105
        }
121
        }
106
        if ( $patron ) {
122
        if ( $patrons->count > 0 ) {
107
            if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
123
            while ( my $patron = $patrons->next ) {
108
                my $borrower = $patron->unblessed;
124
                if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
109
                my $attributes = $patron->extended_attributes;
125
                    my $borrower = $patron->unblessed;
110
                $borrower->{patron_attributes} = $attributes->as_list;
126
                    my $attributes = $patron->extended_attributes;
111
                $borrower->{patron_attributes_count} = $attributes->count;
127
                    $borrower->{patron_attributes} = $attributes->as_list;
112
                $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
128
                    $borrower->{patron_attributes_count} = $attributes->count;
113
                push @borrowers, $borrower;
129
                    $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
114
            } else {
130
                    push @borrowers, $borrower;
115
                push @notfoundcardnumbers, $patronidnumber;
131
                } else {
132
                    push @notfoundcardnumbers, $patronidnumber;
133
                }
116
            }
134
            }
117
        } else {
135
        } else {
118
            push @notfoundcardnumbers, $patronidnumber;
136
            push @notfoundcardnumbers, $patronidnumber;
Lines 168-173 if ( $op eq 'show' ) { Link Here
168
    $template->param( notfoundcardnumbers => \@notfoundcardnumbers )
186
    $template->param( notfoundcardnumbers => \@notfoundcardnumbers )
169
        if @notfoundcardnumbers;
187
        if @notfoundcardnumbers;
170
    $template->param( useborrowernumbers => $useborrowernumbers );
188
    $template->param( useborrowernumbers => $useborrowernumbers );
189
    $template->param( usesmsnumbers => $usesmsnumbers );
171
190
172
    # Construct drop-down list values
191
    # Construct drop-down list values
173
    my $branches = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
192
    my $branches = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
174
- 

Return to bug 23291