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