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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt (-21 / +9 lines)
Lines 29-44 Link Here
29
                <h1>Batch patron modification</h1>
29
                <h1>Batch patron modification</h1>
30
                <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
30
                <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
31
                    <fieldset class="rows">
31
                    <fieldset class="rows">
32
                        <legend>Use a file of cardnumbers</legend>
32
                        <legend>Use a file of cardnumbers or SMS numbers</legend>
33
                        <ol>
33
                        <ol>
34
                            <li><label for="uploadfile">File: </label> <input type="file" id="uploadcardnumberfile" name="uploadcardnumberfile" /></li>
34
                            <li><label for="cardnumberfile">Cardnumbers:</label><input type="radio" name="fileoption" id="cardnumberfile" value="cardnumber" checked></input></li>
35
                        </ol>
35
                            <li><label for="smsnumberfile">SMS numbers:</label><input type="radio" name="fileoption" id="smsnumberfile" value="sms"></input></li>
36
                    </fieldset>
36
                            <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
37
38
                    <fieldset class="rows">
39
                        <legend>Use a file of SMS numbers</legend>
40
                        <ol>
41
                            <li><label for="uploadfile">File: </label> <input type="file" id="uploadsmsnumberfile" name="uploadsmsnumberfile" /></li>
42
                        </ol>
37
                        </ol>
43
                    </fieldset>
38
                    </fieldset>
44
39
Lines 60-80 Link Here
60
                    [% END %]
55
                    [% END %]
61
56
62
                    <fieldset class="rows">
57
                    <fieldset class="rows">
63
                        <legend>Or list cardnumbers one by one</legend>
58
                        <legend>Or list cardnumbers or SMS numbers one by one</legend>
64
                        <ol>
59
                        <ol>
65
                            <li>
60
                            <li><label for="cardnumberlist">Cardnumbers:</label><input type="radio" name="manual_list_option" id="cardnumberlist" value="cardnumber" checked></input></li>
66
                              <label for="cardnumberlist">Card number list (one cardnumber per line): </label>
61
                            <li><label for="smsnumberfile">SMS numbers:</label><input type="radio" name="manual_list_option" id="smsnumberlist" value="sms"></input></li>
67
                              <textarea rows="10" cols="30" id="cardnumberlist" name="cardnumberlist">[% cardnumberlist | html %]</textarea>
68
                            </li>
69
                        </ol>
70
                    </fieldset>
71
62
72
                    <fieldset class="rows">
73
                        <legend>Or list SMS numbers one by one</legend>
74
                        <ol>
75
                            <li>
63
                            <li>
76
                              <label for="smsnumberlist">SMS number list (one SMS number per line): </label>
64
                              <label for="list">List (one cardnumber or SMS number per line): </label>
77
                              <textarea rows="10" cols="30" id="smsnumberlist" name="smsnumberlist">[% smsnumberlist | html %]</textarea>
65
                              <textarea rows="10" cols="30" id="list" name="list">[% list | html %]</textarea>
78
                            </li>
66
                            </li>
79
                        </ol>
67
                        </ol>
80
                    </fieldset>
68
                    </fieldset>
(-)a/tools/modborrowers.pl (-30 / +38 lines)
Lines 57-81 my $dbh = C4::Context->dbh; Link Here
57
57
58
# Show borrower informations
58
# Show borrower informations
59
if ( $op eq 'show' ) {
59
if ( $op eq 'show' ) {
60
    my $cardnumberfilefh = $input->upload('uploadcardnumberfile');
60
    my $filefh  = $input->upload('uploadfile');
61
    my $smsnumberfilefh  = $input->upload('uploadsmsnumberfile');
61
    my $filecontent    = $input->param('fileoption');
62
    my $filecontent    = $input->param('filecontent');
63
    my $patron_list_id = $input->param('patron_list_id');
62
    my $patron_list_id = $input->param('patron_list_id');
63
    my $manual_list_option = $input->param('manual_list_option');
64
    my @borrowers;
64
    my @borrowers;
65
    my @cardnumbers;
65
    my @cardnumbers;
66
    my @smsnumbers;
66
    my @smsnumbers;
67
    my ( @notfoundcardnumbers, @notfoundsmsnumbers );
67
    my ( @notfoundcardnumbers, @notfoundsmsnumbers );
68
68
69
    # Get cardnumbers from a file or the input area
69
    # Get cardnumbers or SMS numbers from a file, a list, or the input area
70
    if ( $cardnumberfilefh ) {
70
    if ($filefh) {
71
        while ( my $content = <$cardnumberfilefh> ) {
71
        if ($filecontent eq 'cardnumber') { # If cardnumber radio button selected, then push file content to @cardnumbers
72
            $content =~ s/[\r\n]*$//g;
72
            while ( my $content = <$filefh> ) {
73
            push @cardnumbers, $content if $content;
73
                $content =~ s/[\r\n]*$//g;
74
        }
74
                push @cardnumbers, $content if $content;
75
    } elsif ( $smsnumberfilefh ) {
75
            }
76
        while ( my $content = <$smsnumberfilefh> ) {
76
        } elsif ($filecontent eq 'sms') { # If SMS radio button selected, then push file content to @smsnumbers
77
             $content =~ s/[\r\n]*$//g;
77
            while ( my $content = <$filefh> ) {
78
             push @smsnumbers, $content if $content;
78
                $content =~ s/[\r\n]*$//g;
79
                push @smsnumbers, $content if $content;
80
            }
79
        }
81
        }
80
    } elsif ( $patron_list_id ) {
82
    } elsif ( $patron_list_id ) {
81
        my ($list) = GetPatronLists( { patron_list_id => $patron_list_id } );
83
        my ($list) = GetPatronLists( { patron_list_id => $patron_list_id } );
Lines 86-96 if ( $op eq 'show' ) { Link Here
86
        @smsnumbers =
88
        @smsnumbers =
87
          $list->patron_list_patrons()->search_related('borrowernumber')
89
          $list->patron_list_patrons()->search_related('borrowernumber')
88
          ->get_column('smsalertnumber')->all();
90
          ->get_column('smsalertnumber')->all();
89
    } else {
91
    } else { # If numbers are in the textarea, check the radio button and push into appropriate array
90
        if ( my $cardnumberlist = $input->param('cardnumberlist') ) {
92
91
            push @cardnumbers, split( /\s\n/, $cardnumberlist );
93
        my $list = $input->param('list');
92
        } elsif ( my $smsnumberlist = $input->param('smsnumberlist') ) {
94
93
            push @smsnumbers, split( /\s\n/, $smsnumberlist );
95
        if ( $manual_list_option eq 'cardnumber' ) { # If cardnumber radio button selected then push textarea content to @cardnumbers
96
            push @cardnumbers, split( /\s\n/, $list );
97
98
        } elsif ( $manual_list_option eq 'sms' ) { # If sms number radio button selected then push textarea content to @smsnumbers
99
            push @smsnumbers, split( /\s\n/, $list );
100
94
        }
101
        }
95
    }
102
    }
96
103
Lines 113-132 if ( $op eq 'show' ) { Link Here
113
        }
120
        }
114
    } else {
121
    } else {
115
        for my $smsnumber (@smsnumbers ) {
122
        for my $smsnumber (@smsnumbers ) {
116
            my $patron = Koha::Patrons->find( { smsalertnumber => $smsnumber } );
123
            my @patrons = Koha::Patrons->search( { smsalertnumber => $smsnumber } );
117
            if ( $patron ) {
124
            foreach my $patron (@patrons) {
118
                if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
125
                if ( $patron ) {
119
                    my $borrower = $patron->unblessed;
126
                    if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
120
                    my $attributes = $patron->extended_attributes;
127
                        my $borrower = $patron->unblessed;
121
                    $borrower->{patron_attributes} = $attributes->as_list;
128
                        my $attributes = $patron->extended_attributes;
122
                    $borrower->{patron_attributes_count} = $attributes->count;
129
                        $borrower->{patron_attributes} = $attributes->as_list;
123
                    $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
130
                        $borrower->{patron_attributes_count} = $attributes->count;
124
                    push @borrowers, $patron;
131
                        $max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr;
132
                        push @borrowers, $patron;
133
                    } else {
134
                        push @notfoundsmsnumbers, $smsnumber;
135
                    }
125
                } else {
136
                } else {
126
                    push @notfoundsmsnumbers, $smsnumber;
137
                    push @notfoundsmsnumbers, $smsnumber;
127
                }
138
                }
128
            } else {
129
                push @notfoundsmsnumbers, $smsnumber;
130
            }
139
            }
131
        }
140
        }
132
    }
141
    }
133
- 

Return to bug 23291