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