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