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 (-28 / +39 lines)
Lines 60-85 my $dbh = C4::Context->dbh; Link Here
60
60
61
# Show borrower informations
61
# Show borrower informations
62
if ( $op eq 'show' ) {
62
if ( $op eq 'show' ) {
63
    my $cardnumberfilefh = $input->upload('uploadcardnumberfile');
63
    my $filefh  = $input->upload('uploadfile');
64
    my $smsnumberfilefh  = $input->upload('uploadsmsnumberfile');
64
    my $filecontent    = $input->param('fileoption');
65
    my $filecontent    = $input->param('filecontent');
66
    my $patron_list_id = $input->param('patron_list_id');
65
    my $patron_list_id = $input->param('patron_list_id');
66
    my $manual_list_option = $input->param('manual_list_option');
67
    my @borrowers;
67
    my @borrowers;
68
    my @cardnumbers;
68
    my @cardnumbers;
69
    my @smsnumbers;
69
    my @smsnumbers;
70
    my ( @notfoundcardnumbers, @notfoundsmsnumbers, @from_another_group_of_libraries );
70
    my ( @notfoundcardnumbers, @notfoundsmsnumbers, @from_another_group_of_libraries );
71
71
72
    # Get cardnumbers from a file or the input area
72
    # Get cardnumbers or SMS numbers from a file, a list, or the input area
73
    my @contentlist;
73
    my @contentlist;
74
    if ($cardnumberfilefh) {
74
    if ($filefh) {
75
        while ( my $content = <$cardnumberfilefh> ) {
75
        if ($filecontent eq 'cardnumber') { # If cardnumber radio button selected, then push file content to @cardnumbers
76
            $content =~ s/[\r\n]*$//g;
76
            while ( my $content = <$filefh> ) {
77
            push @cardnumbers, $content if $content;
77
                $content =~ s/[\r\n]*$//g;
78
        }
78
                push @cardnumbers, $content if $content;
79
    } elsif ( $smsnumberfilefh ) {
79
            }
80
        while ( my $content = <$smsnumberfilefh> ) {
80
        } elsif ($filecontent eq 'sms') { # If SMS radio button selected, then push file content to @smsnumbers
81
             $content =~ s/[\r\n]*$//g;
81
            while ( my $content = <$filefh> ) {
82
             push @smsnumbers, $content if $content;
82
                $content =~ s/[\r\n]*$//g;
83
                push @smsnumbers, $content if $content;
84
            }
83
        }
85
        }
84
    } elsif ( $patron_list_id ) {
86
    } elsif ( $patron_list_id ) {
85
        my ($list) = GetPatronLists( { patron_list_id => $patron_list_id } );
87
        my ($list) = GetPatronLists( { patron_list_id => $patron_list_id } );
Lines 90-100 if ( $op eq 'show' ) { Link Here
90
        @smsnumbers =
92
        @smsnumbers =
91
          $list->patron_list_patrons()->search_related('borrowernumber')
93
          $list->patron_list_patrons()->search_related('borrowernumber')
92
          ->get_column('smsalertnumber')->all();
94
          ->get_column('smsalertnumber')->all();
93
    } else {
95
    } else { # If numbers are in the textarea, check the radio button and push into appropriate array
94
        if ( my $cardnumberlist = $input->param('cardnumberlist') ) {
96
95
            push @cardnumbers, split( /\s\n/, $cardnumberlist );
97
        my $list = $input->param('list');
96
        } elsif ( my $smsnumberlist = $input->param('smsnumberlist') ) {
98
97
            push @smsnumbers, split( /\s\n/, $smsnumberlist );
99
        if ( $manual_list_option eq 'cardnumber' ) { # If cardnumber radio button selected then push textarea content to @cardnumbers
100
            push @cardnumbers, split( /\s\n/, $list );
101
102
        } elsif ( $manual_list_option eq 'sms' ) { # If sms number radio button selected then push textarea content to @smsnumbers
103
            push @smsnumbers, split( /\s\n/, $list );
104
98
        }
105
        }
99
    }
106
    }
100
107
Lines 118-135 if ( $op eq 'show' ) { Link Here
118
        }
125
        }
119
    } else {
126
    } else {
120
        for my $smsnumber (@smsnumbers ) {
127
        for my $smsnumber (@smsnumbers ) {
121
            my $patron = Koha::Patrons->find( { smsalertnumber => $smsnumber } );
128
            my @patrons = Koha::Patrons->search( { smsalertnumber => $smsnumber } );
122
            if ( $patron ) {
129
            my $patron;
123
                if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
130
            my $borrowernumber;
124
                    $patron = $patron->unblessed;
131
            my $value;
125
                    $patron->{patron_attributes} = C4::Members::Attributes::GetBorrowerAttributes( $patron->{borrowernumber} );
132
            foreach $patron (@patrons) {
126
                    $max_nb_attr = scalar( @{ $patron->{patron_attributes} } ) if scalar( @{ $patron->{patron_attributes} } ) > $max_nb_attr;
133
                if ( $patron ) {
127
                    push @borrowers, $patron;
134
                    if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
135
                        $patron = $patron->unblessed;
136
                        $patron->{patron_attributes} = C4::Members::Attributes::GetBorrowerAttributes( $patron->{borrowernumber} );
137
                        $max_nb_attr = scalar( @{ $patron->{patron_attributes} } ) if scalar( @{ $patron->{patron_attributes} } ) > $max_nb_attr;
138
                        push @borrowers, $patron;
139
                    } else {
140
                        push @notfoundsmsnumbers, $smsnumber;
141
                    }
128
                } else {
142
                } else {
129
                    push @notfoundsmsnumbers, $smsnumber;
143
                    push @notfoundsmsnumbers, $smsnumber;
130
                }
144
                }
131
            } else {
132
                push @notfoundsmsnumbers, $smsnumber;
133
            }
145
            }
134
        }
146
        }
135
    }
147
    }
136
- 

Return to bug 23291