|
Lines 57-104
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 $filefh = $input->upload('uploadfile'); |
60 |
my $cardnumberfilefh = $input->upload('uploadcardnumberfile'); |
|
|
61 |
my $smsnumberfilefh = $input->upload('uploadsmsnumberfile'); |
| 61 |
my $filecontent = $input->param('filecontent'); |
62 |
my $filecontent = $input->param('filecontent'); |
| 62 |
my $patron_list_id = $input->param('patron_list_id'); |
63 |
my $patron_list_id = $input->param('patron_list_id'); |
| 63 |
my @borrowers; |
64 |
my @borrowers; |
| 64 |
my @cardnumbers; |
65 |
my @cardnumbers; |
| 65 |
my @notfoundcardnumbers; |
66 |
my @smsnumbers; |
|
|
67 |
my ( @notfoundcardnumbers, @notfoundsmsnumbers ); |
| 66 |
|
68 |
|
| 67 |
# Get cardnumbers from a file or the input area |
69 |
# Get cardnumbers from a file or the input area |
| 68 |
if ($filefh) { |
70 |
if ( $cardnumberfilefh ) { |
| 69 |
while ( my $content = <$filefh> ) { |
71 |
while ( my $content = <$cardnumberfilefh> ) { |
| 70 |
$content =~ s/[\r\n]*$//g; |
72 |
$content =~ s/[\r\n]*$//g; |
| 71 |
push @cardnumbers, $content if $content; |
73 |
push @cardnumbers, $content if $content; |
| 72 |
} |
74 |
} |
|
|
75 |
} elsif ( $smsnumberfilefh ) { |
| 76 |
while ( my $content = <$smsnumberfilefh> ) { |
| 77 |
$content =~ s/[\r\n]*$//g; |
| 78 |
push @smsnumbers, $content if $content; |
| 79 |
} |
| 73 |
} elsif ( $patron_list_id ) { |
80 |
} elsif ( $patron_list_id ) { |
| 74 |
my ($list) = GetPatronLists( { patron_list_id => $patron_list_id } ); |
81 |
my ($list) = GetPatronLists( { patron_list_id => $patron_list_id } ); |
| 75 |
|
82 |
|
| 76 |
@cardnumbers = |
83 |
@cardnumbers = |
| 77 |
$list->patron_list_patrons()->search_related('borrowernumber') |
84 |
$list->patron_list_patrons()->search_related('borrowernumber') |
| 78 |
->get_column('cardnumber')->all(); |
85 |
->get_column('cardnumber')->all(); |
| 79 |
|
86 |
@smsnumbers = |
|
|
87 |
$list->patron_list_patrons()->search_related('borrowernumber') |
| 88 |
->get_column('smsalertnumber')->all(); |
| 80 |
} else { |
89 |
} else { |
| 81 |
if ( my $list = $input->param('cardnumberlist') ) { |
90 |
if ( my $cardnumberlist = $input->param('cardnumberlist') ) { |
| 82 |
push @cardnumbers, split( /\s\n/, $list ); |
91 |
push @cardnumbers, split( /\s\n/, $cardnumberlist ); |
|
|
92 |
} elsif ( my $smsnumberlist = $input->param('smsnumberlist') ) { |
| 93 |
push @smsnumbers, split( /\s\n/, $smsnumberlist ); |
| 83 |
} |
94 |
} |
| 84 |
} |
95 |
} |
| 85 |
|
96 |
|
| 86 |
my $max_nb_attr = 0; |
97 |
my $max_nb_attr = 0; |
| 87 |
for my $cardnumber ( @cardnumbers ) { |
98 |
if ( @cardnumbers ) { |
| 88 |
my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } ); |
99 |
for my $cardnumber ( @cardnumbers ) { |
| 89 |
if ( $patron ) { |
100 |
my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } ); |
| 90 |
if ( $logged_in_user->can_see_patron_infos( $patron ) ) { |
101 |
if ( $patron ) { |
| 91 |
my $borrower = $patron->unblessed; |
102 |
if ( $logged_in_user->can_see_patron_infos( $patron ) ) { |
| 92 |
my $attributes = $patron->extended_attributes; |
103 |
my $borrower = $patron->unblessed; |
| 93 |
$borrower->{patron_attributes} = $attributes->as_list; |
104 |
my $attributes = $patron->extended_attributes; |
| 94 |
$borrower->{patron_attributes_count} = $attributes->count; |
105 |
$borrower->{patron_attributes} = $attributes->as_list; |
| 95 |
$max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; |
106 |
$borrower->{patron_attributes_count} = $attributes->count; |
| 96 |
push @borrowers, $borrower; |
107 |
$max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; |
|
|
108 |
push @borrowers, $borrower; |
| 109 |
} else { |
| 110 |
push @notfoundcardnumbers, $cardnumber; |
| 111 |
} |
| 112 |
I } |
| 113 |
} |
| 114 |
} else { |
| 115 |
for my $smsnumber (@smsnumbers ) { |
| 116 |
my $patron = Koha::Patrons->find( { smsalertnumber => $smsnumber } ); |
| 117 |
if ( $patron ) { |
| 118 |
if ( $logged_in_user->can_see_patron_infos( $patron ) ) { |
| 119 |
my $borrower = $patron->unblessed; |
| 120 |
my $attributes = $patron->extended_attributes; |
| 121 |
$borrower->{patron_attributes} = $attributes->as_list; |
| 122 |
$borrower->{patron_attributes_count} = $attributes->count; |
| 123 |
$max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; |
| 124 |
push @borrowers, $patron; |
| 125 |
} else { |
| 126 |
push @notfoundsmsnumbers, $smsnumber; |
| 127 |
} |
| 97 |
} else { |
128 |
} else { |
| 98 |
push @notfoundcardnumbers, $cardnumber; |
129 |
push @notfoundsmsnumbers, $smsnumber; |
| 99 |
} |
130 |
} |
| 100 |
} else { |
|
|
| 101 |
push @notfoundcardnumbers, $cardnumber; |
| 102 |
} |
131 |
} |
| 103 |
} |
132 |
} |
| 104 |
|
133 |
|
|
Lines 148-153
if ( $op eq 'show' ) {
Link Here
|
| 148 |
$template->param( borrowers => \@borrowers ); |
177 |
$template->param( borrowers => \@borrowers ); |
| 149 |
$template->param( attributes_header => \@attributes_header ); |
178 |
$template->param( attributes_header => \@attributes_header ); |
| 150 |
@notfoundcardnumbers = map { { cardnumber => $_ } } @notfoundcardnumbers; |
179 |
@notfoundcardnumbers = map { { cardnumber => $_ } } @notfoundcardnumbers; |
|
|
180 |
@notfoundsmsnumbers = map { { smsalertnumber => $_ } } @notfoundsmsnumbers; |
| 181 |
$template->param( notfoundsmsnumbers => \@notfoundsmsnumbers ) if @notfoundsmsnumbers; |
| 182 |
|
| 151 |
$template->param( notfoundcardnumbers => \@notfoundcardnumbers ) |
183 |
$template->param( notfoundcardnumbers => \@notfoundcardnumbers ) |
| 152 |
if @notfoundcardnumbers; |
184 |
if @notfoundcardnumbers; |
| 153 |
|
185 |
|
| 154 |
- |
|
|