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