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 |
- |
|
|